Skip to content

Commit 5b3976d

Browse files
LorenzoLorenzo
authored andcommitted
Added support for automatic download for node.js and npm on Windows, updated README.md and changelog/install.txt
1 parent 6d82606 commit 5b3976d

9 files changed

Lines changed: 323 additions & 120 deletions

File tree

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,32 @@ It helps you to write your scripts more quickly with hints and completions.
1010

1111
<h2>Announcement</h2>
1212
<p>
13+
1314
I'm implementing new features thanks to <strong>Flow</strong> (static type checker from Facebook).
1415
With it I can implement other <strong>features</strong> and there will be a better <strong>autocomplete</strong>
1516
(<strong style="text-decoration: underline;">smart autocomplete based on the current context</strong>).
1617

1718
This is in <strong>Beta version</strong> and I published it under another branch:
1819
<a href="https://github.com/pichillilorenzo/JavaScript-Completions/tree/v3-beta">https://github.com/pichillilorenzo/JavaScript-Completions/tree/v3-beta</a>
1920

20-
But it isn’t ready for public testing and there isn’t a documentation at the moment!
21+
but I will move it on a new repository (<strong style="text-decoration: underline;">so it will be a new plugin on Sublime Text</strong>)
22+
because it will offer not only a better autocomplete but a lot of features about creating,
23+
developing and managing javascript projects, such as:
24+
25+
- Cordova projects (run Cordova emulator, build, compile, serve Cordova projects, add plugins and platforms, etc … directly on Sublime Text!)
26+
- Ionic projects (same as Cordova projects!)
27+
- Node.js projects
28+
- Local bookmarks project
29+
- Show javascript errors with Flow
30+
- etc, etc …
31+
32+
It will be something like a <strong>JavaScript IDE</strong> on Sublime Text!
33+
34+
It isn’t ready for public testing and there isn’t a documentation at the moment!
2135
I will let you know the moment I have any news!!
2236

37+
Email me for any questions or doubts about this new project on: <a href="mailto:pichillilorenzo@gmail.com">pichillilorenzo@gmail.com</a>
38+
2339
<strong>Thanks for your support!!!</strong>
2440
</p>
2541

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,9 +1024,14 @@ def exec_node(self, folder_path, node_command_args) :
10241024
node = NodeJS()
10251025
animation_loader = AnimationLoader(["[= ]", "[ = ]", "[ = ]", "[ = ]", "[ =]", "[ = ]", "[ = ]", "[ = ]"], 0.067, "Generating docs ")
10261026
interval_animation = RepeatedTimer(animation_loader.sec, animation_loader.animate)
1027-
result = node.execute("jsdoc", node_command_args, True)
1027+
result = node.execute("jsdoc", node_command_args, is_from_bin=True)
1028+
10281029
if not result[0] :
10291030
sublime.error_message(result[1])
1031+
1032+
elif result[1].startswith("There are no input files to process") :
1033+
sublime.error_message(result[1])
1034+
10301035
animation_loader.on_complete()
10311036
interval_animation.stop()
10321037

changelog/2.6.9.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
v2.6.9
2+
3+
# Announcement
4+
5+
I'm implementing new features thanks to Flow (static type checker from Facebook).
6+
With it I can implement other features and there will be a better autocomplete
7+
(smart autocomplete based on the current context).
8+
9+
This is in Beta version and I published it on github (same repository but under another branch):
10+
https://github.com/pichillilorenzo/JavaScript-Completions/tree/v3-beta
11+
12+
but I will move it on a new repository (so it will be a new plugin on Sublime Text)
13+
because it will offer not only a better autocomplete but a lot of features about creating,
14+
developing and managing javascript projects, such as:
15+
16+
- Cordova projects (run Cordova emulator, build, compile, serve Cordova projects, add plugins and platforms, etc … directly on Sublime Text!)
17+
- Ionic projects (same as Cordova projects!)
18+
- Node.js projects
19+
- Local bookmarks project
20+
- Show javascript errors with Flow
21+
- etc, etc …
22+
23+
It will be something like a JavaScript IDE on Sublime Text!
24+
25+
It isn’t ready for public testing and there isn’t a documentation at the moment!
26+
I will let you know the moment I have any news!!
27+
28+
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
29+
30+
Thanks to all your support!!!
31+
32+
## Improvements
33+
34+
- Added support for automatic download for node.js and npm on Windows

changelog/install.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
JavaScript Completions Package
22
===============================
33

4+
## ANNOUNCEMENT ##
5+
==================
6+
7+
I'm implementing new features thanks to Flow (static type checker from Facebook).
8+
With it I can implement other features and there will be a better autocomplete
9+
(smart autocomplete based on the current context).
10+
11+
This is in Beta version and I published it on github (same repository but under another branch):
12+
https://github.com/pichillilorenzo/JavaScript-Completions/tree/v3-beta
13+
14+
but I will move it on a new repository (so it will be a new plugin on Sublime Text)
15+
because it will offer not only a better autocomplete but a lot of features about creating,
16+
developing and managing javascript projects, such as:
17+
18+
- Cordova projects (run Cordova emulator, build, compile, serve Cordova projects, add plugins and platforms, etc … directly on Sublime Text!)
19+
- Ionic projects (same as Cordova projects!)
20+
- Node.js projects
21+
- Local bookmarks project
22+
- Show javascript errors with Flow
23+
- etc, etc …
24+
25+
It will be something like a JavaScript IDE on Sublime Text!
26+
27+
It isn’t ready for public testing and there isn’t a documentation at the moment!
28+
I will let you know the moment I have any news!!
29+
30+
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
31+
32+
Thanks to all your support!!!
33+
34+
435
How To USE
536
==========
637

helper/jsdoc/generate_jsdoc_command.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ def exec_node(self, folder_path, node_command_args) :
3232
node = NodeJS()
3333
animation_loader = AnimationLoader(["[= ]", "[ = ]", "[ = ]", "[ = ]", "[ =]", "[ = ]", "[ = ]", "[ = ]"], 0.067, "Generating docs ")
3434
interval_animation = RepeatedTimer(animation_loader.sec, animation_loader.animate)
35-
result = node.execute("jsdoc", node_command_args, True)
35+
result = node.execute("jsdoc", node_command_args, is_from_bin=True)
36+
3637
if not result[0] :
3738
sublime.error_message(result[1])
39+
40+
elif result[1].startswith("There are no input files to process") :
41+
sublime.error_message(result[1])
42+
3843
animation_loader.on_complete()
3944
interval_animation.stop()
4045

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"2.6.6": "changelog/2.6.6.txt",
55
"2.6.7": "changelog/2.6.7.txt",
66
"2.6.8": "changelog/2.6.8.txt",
7-
"2.6.81": "changelog/2.6.81.txt"
7+
"2.6.81": "changelog/2.6.81.txt",
8+
"2.6.9": "changelog/2.6.9.txt"
89
}

node/installer.py

100755100644
Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ def __init__(self, node_version):
3333
def download(self):
3434
try :
3535
if os.path.exists(node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM):
36-
shutil.rmtree(node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
36+
self.rmtree(node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
3737
os.makedirs(node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
3838
else :
3939
os.makedirs(node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
4040
if os.path.exists(node_variables.NODE_MODULES_PATH):
41-
shutil.rmtree(node_variables.NODE_MODULES_PATH)
41+
self.rmtree(node_variables.NODE_MODULES_PATH)
4242
request = urllib.request.Request(self.NODE_JS_BINARY_URL)
4343
request.add_header('User-agent', r'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1')
4444
with urllib.request.urlopen(request) as response :
@@ -62,13 +62,58 @@ def extract(self):
6262
member.name = sep.join(member.name.split(sep)[1:])
6363
tar.extract(member, node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
6464
else :
65-
with zipfile.ZipFile(self.NODE_JS_BINARY_TARFILE_FULL_PATH, "r") as zip_file :
66-
for member in zip_file.namelist() :
67-
if member.endswith("/node.exe") :
68-
with zip_file.open(member) as node_file:
69-
with open(os.path.join(node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM, "node.exe"), "wb") as target :
70-
shutil.copyfileobj(node_file, target)
71-
break
65+
if node_variables.NODE_JS_OS == "win" :
66+
import string
67+
from ctypes import windll, c_int, c_wchar_p
68+
UNUSUED_DRIVE_LETTER = ""
69+
for letter in string.ascii_uppercase:
70+
if not os.path.exists(letter+":") :
71+
UNUSUED_DRIVE_LETTER = letter+":"
72+
break
73+
if not UNUSUED_DRIVE_LETTER :
74+
sublime.message_dialog("Can't install node.js and npm! UNUSUED_DRIVE_LETTER not found.")
75+
return
76+
DefineDosDevice = windll.kernel32.DefineDosDeviceW
77+
DefineDosDevice.argtypes = [ c_int, c_wchar_p, c_wchar_p ]
78+
DefineDosDevice(0, UNUSUED_DRIVE_LETTER, node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
79+
try:
80+
with zipfile.ZipFile(self.NODE_JS_BINARY_TARFILE_FULL_PATH, "r") as zip_file :
81+
for member in zip_file.namelist() :
82+
if not member.endswith("/") :
83+
with zip_file.open(member) as node_file:
84+
with open(UNUSUED_DRIVE_LETTER + "\\"+ member.replace("node-"+self.NODE_JS_VERSION+"-"+node_variables.NODE_JS_OS+"-"+node_variables.NODE_JS_ARCHITECTURE+"/", ""), "wb+") as target :
85+
shutil.copyfileobj(node_file, target)
86+
elif not member.endswith("node-"+self.NODE_JS_VERSION+"-"+node_variables.NODE_JS_OS+"-"+node_variables.NODE_JS_ARCHITECTURE+"/"):
87+
os.mkdir(UNUSUED_DRIVE_LETTER + "\\"+ member.replace("node-"+self.NODE_JS_VERSION+"-"+node_variables.NODE_JS_OS+"-"+node_variables.NODE_JS_ARCHITECTURE+"/", ""))
88+
except Exception as e:
89+
print("Error: "+traceback.format_exc())
90+
finally:
91+
DefineDosDevice(2, UNUSUED_DRIVE_LETTER, node_variables.NODE_JS_BINARIES_FOLDER_PLATFORM)
92+
93+
def rmtree(self, path) :
94+
if node_variables.NODE_JS_OS == "win" :
95+
import string
96+
from ctypes import windll, c_int, c_wchar_p
97+
UNUSUED_DRIVE_LETTER = ""
98+
for letter in string.ascii_uppercase:
99+
if not os.path.exists(letter+":") :
100+
UNUSUED_DRIVE_LETTER = letter+":"
101+
break
102+
if not UNUSUED_DRIVE_LETTER :
103+
sublime.message_dialog("Can't remove node.js! UNUSUED_DRIVE_LETTER not found.")
104+
return
105+
DefineDosDevice = windll.kernel32.DefineDosDeviceW
106+
DefineDosDevice.argtypes = [ c_int, c_wchar_p, c_wchar_p ]
107+
DefineDosDevice(0, UNUSUED_DRIVE_LETTER, path)
108+
try:
109+
shutil.rmtree(UNUSUED_DRIVE_LETTER)
110+
except Exception as e:
111+
print("Error: "+traceback.format_exc())
112+
finally:
113+
DefineDosDevice(2, UNUSUED_DRIVE_LETTER, path)
114+
else :
115+
shutil.rmtree(path)
116+
72117

73118
def on_error(self, err):
74119
self.animation_loader.on_complete()
@@ -86,8 +131,6 @@ def on_complete(self):
86131
try :
87132
npm.getCurrentNPMVersion(True)
88133
except Exception as e:
89-
if node_variables.NODE_JS_OS == "win" :
90-
sublime.error_message("Can't use \"npm\"! To use features that requires \"npm\", you must install it! Download it from https://nodejs.org site")
91134
print("Error: "+traceback.format_exc())
92135
try :
93136
npm.install_all()
@@ -128,8 +171,6 @@ def updateNPMDependencies():
128171
try :
129172
npm.getCurrentNPMVersion(True)
130173
except Exception as e:
131-
if node_variables.NODE_JS_OS == "win" :
132-
sublime.active_window().status_message("Can't use \"npm\"! To use features that requires \"npm\", you must install it! Download it from https://nodejs.org site")
133174
print("Error: "+traceback.format_exc())
134175
return
135176

@@ -158,10 +199,12 @@ def install(node_version=""):
158199
nodejs_already_installed = already_installed()
159200
if nodejs_can_start_download and not nodejs_already_installed :
160201
DownloadNodeJS( node_version ).start()
202+
return
161203
elif nodejs_can_start_download and nodejs_already_installed :
162204
node_js = NodeJS()
163205
if node_version != node_js.getCurrentNodeJSVersion(True) :
164206
DownloadNodeJS( node_version ).start()
207+
return
165208

166209
if nodejs_already_installed :
167-
create_and_start_thread(updateNPMDependencies, "checkUpgradeNPM")
210+
create_and_start_thread(updateNPMDependencies, "updateNPMDependencies")

0 commit comments

Comments
 (0)