Skip to content

Commit 0496c28

Browse files
Added Windows Support, bug fixes for create project feature
1 parent d6f60b2 commit 0496c28

27 files changed

+589
-275
lines changed

Default.sublime-keymap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"keys": ["ctrl+alt+s"],
2626
"command": "show_hint_parameters"
2727
},
28-
{"keys": ["tab"], "command": "window_keypress", "args": {"key": "tab"}, "context": [{"key": "setting.javascript_enhancements_window"}]},
29-
{"keys": ["shift+tab"], "command": "window_keypress", "args": {"key": "shift+tab"}, "context": [{"key": "setting.javascript_enhancements_window"}]},
30-
{"keys": ["ctrl+alt+a"], "command": "window_keypress", "args": {"key": "ctrl+alt+a"}, "context": [{"key": "setting.javascript_enhancements_window"}]}
28+
{"keys": ["tab"], "command": "window_view_keypress", "args": {"key": "tab"}, "context": [{"key": "setting.javascript_enhancements_window"}]},
29+
{"keys": ["shift+tab"], "command": "window_view_keypress", "args": {"key": "shift+tab"}, "context": [{"key": "setting.javascript_enhancements_window"}]},
30+
{"keys": ["ctrl+alt+a"], "command": "window_view_keypress", "args": {"key": "ctrl+alt+a"}, "context": [{"key": "setting.javascript_enhancements_window"}]}
3131
]

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ It offers better **javascript autocomplete** and also a lot of features about cr
2020
- Yeoman generators
2121
- Local bookmarks project
2222
- JavaScript real-time errors
23-
- etc.
23+
- etc. (I will add also **React Native** and **NativeScript** support)
2424

2525
You could use it also in **existing projects** (see the [Wiki](https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/Using-it-with-an-existing-project))!
2626

@@ -35,18 +35,15 @@ If you want use this plugin, you may want **uninstall/disable** the **JavaScript
3535

3636
- Linux (64-bit)
3737
- Mac OS X
38-
39-
### For Windows users
40-
41-
For Windows support I will create a **degraded** mode without the use of **[TerminalView](https://github.com/Wramberg/TerminalView)** plugin these days, so **WATCH** the repository. Unfortunately the TerminalView plugin supports only **Linux-based OS** 😞 . Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
38+
- Windows (64-bit): released without the use of [TerminalView](https://github.com/Wramberg/TerminalView) plugin. For each feature (like also creating a project) will be used the `cmd.exe` shell (so during the creation of a project **don't close it** until it finishes!). Unfortunately the TerminalView plugin supports only **Linux-based OS** 😞 . Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
4239

4340
## Dependencies
4441

4542
In order to work properly, this plugin has some dependencies:
4643

4744
- **Sublime Text 3** (build **3124** or newer)
4845
- **Node.js** and **npm** ([nodejs.org](https://nodejs.org) or [nvm](https://github.com/creationix/nvm))
49-
- **TerminalView** sublime text plugin ([TerminalView](https://github.com/Wramberg/TerminalView))
46+
- **TerminalView** (only for _Linux_ and _Mac OS X_) sublime text plugin ([TerminalView](https://github.com/Wramberg/TerminalView))
5047

5148
**Not required**, but **useful** for typescript files (Flow wont work on this type of files):
5249

@@ -91,7 +88,7 @@ If this doesn't work too, then you could try to add the custom path that contain
9188
}
9289
```
9390

94-
**REMEMBER** to add `:` at the begin of the `PATH` value!! Like I already said, it uses the same syntax for the $PATH environment variable.
91+
For _Linux-based OS_ **REMEMBER** to add `:` (for _Windows OS_ **REMEMBER** to add `;`) at the begin of the `PATH` value!! Like I already said, it uses the same syntax for the $PATH environment variable.
9592

9693
## Usage
9794

_generated_2018_01_08_at_03_35_58.py renamed to _generated_2018_01_08_at_23_15_43.py

Lines changed: 141 additions & 129 deletions
Large diffs are not rendered by default.

changelog/0.11.00.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
v0.11.00
2+
3+
## Fixes
4+
5+
- some bug fixes for create project feature
6+
7+
## Improvements
8+
9+
- Added support for Windows without TermivalView plugin but using the cmd.exe shell
10+
11+
12+
=================================================================
13+
** THIS PLUGIN IS IN BETA! Thanks for your support in advance! **
14+
=================================================================
15+
16+
If you like it, remember to star it ⭐ on GitHub: https://github.com/pichillilorenzo/JavaScriptEnhancements
17+
18+
** USAGE **
19+
===========
20+
21+
See how it works on the Wiki: 👉👉 https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki 👈👈
22+
23+
24+
** WHAT IS THIS? **
25+
===================
26+
27+
This plugin uses Flow (javascript static type checker from Facebook) under the hood.
28+
29+
It offers better javascript autocomplete and a lot of features about creating,
30+
developing and managing javascript projects, such as:
31+
32+
- Cordova projects (run cordova emulate, build, compile, serve, etc. directly from Sublime Text!)
33+
- Ionic v1 and v2 projects (same as Cordova projects!)
34+
- Angular v1 and v2 projects
35+
- React projects
36+
- Express projects
37+
- Yeoman generators
38+
- Local bookmarks project
39+
- JavaScript real-time errors
40+
- etc. (I will add also React Native and NativeScript support)
41+
42+
You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki/Using-it-with-an-existing-project)!
43+
44+
It turns Sublime Text into a JavaScript IDE like!
45+
46+
This project is based on my other Sublime Text plugin JavaScript Completions (https://github.com/pichillilorenzo/JavaScript-Completions)
47+
48+
** NOTE **
49+
If you want use this plugin, you may want uninstall/disable the JavaScript Completions plugin, if installed.
50+
51+
** OS SUPPORTED NOW **
52+
======================
53+
54+
👉 Linux (64-bit)
55+
👉 Mac OS X
56+
👉 Windows (64-bit): released without the use of TerminalView plugin. For each feature (like also creating a project) will be used the cmd.exe shell (so during the creation of a project don't close it until it finishes!). Unfortunately the TerminalView plugin supports only Linux-based OS 😞. Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
57+
58+
❗❗ Dependencies ❗❗
59+
=======================
60+
61+
In order to work properly, this plugin has some dependencies:
62+
63+
👉 Sublime Text 3 (build 3124 or newer)
64+
👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm))
65+
👉 TerminalView (only for Linux and Mac OS X) sublime text plugin (https://github.com/Wramberg/TerminalView)
66+
67+
Not required, but useful for typescript files (Flow wont work on this type of files):
68+
69+
👉 TypeScript sublime text plugin (https://github.com/Microsoft/TypeScript-Sublime-Plugin)
70+
71+
** Flow Requirements **
72+
=======================
73+
74+
It use [Flow](https://github.com/facebook/flow) for type checking and auto-completions.
75+
76+
👉 Mac OS X
77+
👉 Linux (64-bit)
78+
👉 Windows (64-bit)
79+
80+
Email me for any questions or doubts about this new project on: pichillilorenzo@gmail.com
81+
82+
Thanks for your support! 😄😄
83+
84+
MIT License

changelog/install.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ developing and managing javascript projects, such as:
2626
- Yeoman generators
2727
- Local bookmarks project
2828
- JavaScript real-time errors
29-
- etc.
29+
- etc. (I will add also React Native and NativeScript support)
3030

3131
You could use it also in existing projects (see the Wiki - https://github.com/pichillilorenzo/JavaScriptEnhancements/wiki)!
3232

@@ -42,10 +42,7 @@ If you want use this plugin, you may want uninstall/disable the JavaScript Compl
4242

4343
👉 Linux (64-bit)
4444
👉 Mac OS X
45-
46-
### For Windows users
47-
48-
For Windows support I will create a "degraded" mode without the use of TerminalView plugin these days, so WATCH the repository. Unfortunately the TerminalView plugin supports only Linux-based OS 😞 . Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
45+
👉 Windows (64-bit): released without the use of TerminalView plugin. For each feature (like also creating a project) will be used the cmd.exe shell (so during the creation of a project don't close it until it finishes!). Unfortunately the TerminalView plugin supports only Linux-based OS 😞. Has someone any advice or idea about that? Is there something similar to the TerminalView plugin for Windows?? Thanks!
4946

5047
❗❗ Dependencies ❗❗
5148
=======================
@@ -54,7 +51,7 @@ In order to work properly, this plugin has some dependencies:
5451

5552
👉 Sublime Text 3 (build 3124 or newer)
5653
👉 Node.js and npm (https://nodejs.org or nvm (https://github.com/creationix/nvm))
57-
👉 TerminalView sublime text plugin (https://github.com/Wramberg/TerminalView)
54+
👉 TerminalView (only for Linux and Mac OS X) sublime text plugin (https://github.com/Wramberg/TerminalView)
5855

5956
Not required, but useful for typescript files (Flow wont work on this type of files):
6057

helper/Hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def apply(hook_name, value='', *args, **kwargs) :
2424
#value = hook["hook_func"](*args, **kwargs)
2525
#args = (value,) + args[1:]
2626

27-
return value
27+
#return value
2828

2929
@staticmethod
3030
def count(hook_name) :

helper/Terminal.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,14 @@ def __init__(self, cmd="", title="", cwd="", syntax=None, keep_open=False, windo
1515
self.cwd = cwd or os.path.expanduser("~")
1616
self.syntax = syntax
1717
self.keep_open = keep_open
18-
self.window = window
18+
self.window = window or sublime.active_window()
1919

2020
def run(self, cmd_args):
2121
if sublime.platform() != "windows":
2222
view = self.window.new_file()
2323
view.run_command('terminal_view_activate', args={"cmd": self.cmd, "title": self.title, "cwd": self.cwd, "syntax": self.syntax, "keep_open": self.keep_open} )
2424
self.window.run_command("terminal_view_send_string", args={"string": " ".join(cmd_args) + "\n"})
2525
else:
26-
print([self.cmd] +
27-
( ["-NoExit", "-Command"] if self.cmd.startswith("powershell") else ["/K"] )
28-
+ ( ["$Host.UI.RawUI.WindowTitle", "=", self.title] if self.cmd.startswith("powershell") else ["title", self.title] )
29-
+ ( [";", "CD", self.cwd] if self.cmd.startswith("powershell") else ["&&", "CD", self.cwd] )
30-
+ ( [";"] if self.cmd.startswith("powershell") else ["&&"] )
31-
+ cmd_args )
3226
subprocess.Popen( [self.cmd] +
3327
( ["-NoExit", "-Command"] if self.cmd.startswith("powershell") else ["/K"] )
3428
+ ( ["$Host.UI.RawUI.WindowTitle", "=", self.title] if self.cmd.startswith("powershell") else ["title", self.title] )

helper/WindowView.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def __init__(self, title="WindowView", window=None, view=None):
77
self.view.set_name(title)
88
self.view.set_read_only(True)
99
self.view.set_scratch(True)
10-
self.view.settings().set("javascript_enhancements_window", True)
10+
self.view.settings().set("javascript_enhancements_window_view", True)
1111
self.view.settings().set("gutter", False)
1212
self.view.settings().set("highlight_line", False)
1313
self.view.settings().set("auto_complete_commit_on_tab", False)
@@ -23,10 +23,10 @@ def __init__(self, title="WindowView", window=None, view=None):
2323
self.region_ids = []
2424
self.region_input_ids = []
2525

26-
Hook.add("javascript_enhancements_window_close_"+str(self.view.id()), self.destroy)
26+
Hook.add("javascript_enhancements_window_view_close_"+str(self.view.id()), self.destroy)
2727

2828
def __del__(self):
29-
Hook.removeAllHook("javascript_enhancements_window_close_"+str(self.view.id()))
29+
Hook.removeAllHook("javascript_enhancements_window_view_close_"+str(self.view.id()))
3030
for event in self.events.keys():
3131
for eventRegionKey in self.events[event].keys():
3232
for callback in self.events[event][eventRegionKey].keys():
@@ -100,7 +100,6 @@ def getInputs(self):
100100

101101
def replaceById(self, replace_region_id, text, key="", scope="", icon="", flags=sublime.HIDDEN, region_id="", padding=0, display_block=False, insert_point=None, replace_points=[]):
102102

103-
print(self.view.get_regions("input.javascriptenhancements.input"))
104103
region = self.view.get_regions(replace_region_id)
105104
if region:
106105
region = region[0]
@@ -111,9 +110,6 @@ def replaceById(self, replace_region_id, text, key="", scope="", icon="", flags=
111110

112111
self.add(text, key=key, scope=scope, icon=icon, flags=flags, region_id=region_id, padding=padding, display_block=display_block, insert_point=insert_point, replace_points=[region.begin(), region.end()])
113112

114-
print(region)
115-
print(self.view.get_regions("input.javascriptenhancements.input"))
116-
117113
def removeById(self, region_id):
118114
self.view.erase_regions(region_id)
119115

@@ -255,11 +251,11 @@ def run(self, edit, **args):
255251
if "region_id" in args and args.get("region_id"):
256252
view.add_regions(args.get("region_id"), [region], scope, icon, flags)
257253

258-
class windowKeypressCommand(sublime_plugin.TextCommand):
254+
class windowViewKeypressCommand(sublime_plugin.TextCommand):
259255
def run(self, edit, **args):
260256
view = self.view
261257

262-
if view.settings().get("javascript_enhancements_window"):
258+
if view.settings().get("javascript_enhancements_window_view"):
263259
key = args.get("key")
264260

265261
if key == "tab" or key =="shift+tab":
@@ -287,10 +283,10 @@ def run(self, edit, **args):
287283
view.sel().clear()
288284
view.sel().add(sublime.Region(region.begin()+1, region.end()-1))
289285

290-
class windowEventListener(sublime_plugin.EventListener):
286+
class windowViewEventListener(sublime_plugin.EventListener):
291287

292288
def on_modified_async(self, view):
293-
if view.settings().get("javascript_enhancements_window"):
289+
if view.settings().get("javascript_enhancements_window_view"):
294290

295291
for region in view.get_regions("input.javascriptenhancements.input"):
296292

@@ -327,7 +323,7 @@ def on_modified_async(self, view):
327323
return
328324

329325
def on_selection_modified_async(self, view):
330-
if view.settings().get("javascript_enhancements_window"):
326+
if view.settings().get("javascript_enhancements_window_view"):
331327

332328
for region in view.get_regions("input.javascriptenhancements.input"):
333329
if view.sel()[0].begin() >= region.begin() + 1 and view.sel()[0].end() <= region.end() - 1:
@@ -346,9 +342,9 @@ def on_selection_modified_async(self, view):
346342
view.set_read_only(True)
347343

348344
def on_text_command(self, view, command_name, args):
349-
if view.settings().get("javascript_enhancements_window"):
345+
if view.settings().get("javascript_enhancements_window_view"):
350346
Hook.apply(command_name, view, args)
351347

352348
def on_close(self, view):
353-
if view.settings().get("javascript_enhancements_window"):
354-
Hook.apply("javascript_enhancements_window_close_"+str(view.id()))
349+
if view.settings().get("javascript_enhancements_window_view"):
350+
Hook.apply("javascript_enhancements_window_view_close_"+str(view.id()))

helper/can_i_use/can_i_use_command.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@ def donwload_can_i_use_json_data() :
2424
if Util.download_and_save(url_can_i_use_json_data, path_to_test_can_i_use_data) :
2525
if os.path.isfile(path_to_can_i_use_data) :
2626
if not Util.checksum_sha1_equalcompare(path_to_can_i_use_data, path_to_test_can_i_use_data) :
27-
with open(path_to_test_can_i_use_data) as json_file:
28-
try :
29-
can_i_use_file = json.load(json_file)
30-
if os.path.isfile(path_to_can_i_use_data) :
31-
os.remove(path_to_can_i_use_data)
32-
os.rename(path_to_test_can_i_use_data, path_to_can_i_use_data)
33-
except Exception as e :
34-
print("Error: "+traceback.format_exc())
35-
sublime.active_window().status_message("Can't use new \"Can I use\" json data from: https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json")
27+
json_file = open(path_to_test_can_i_use_data)
28+
try :
29+
can_i_use_file = json.load(json_file)
30+
if os.path.isfile(path_to_can_i_use_data) :
31+
os.remove(path_to_can_i_use_data)
32+
json_file.close()
33+
os.rename(path_to_test_can_i_use_data, path_to_can_i_use_data)
34+
except Exception as e :
35+
print("Error: "+traceback.format_exc())
36+
sublime.active_window().status_message("Can't use new \"Can I use\" json data from: https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json")
37+
if not json_file.closed:
38+
json_file.close()
3639
if os.path.isfile(path_to_test_can_i_use_data) :
3740
os.remove(path_to_test_can_i_use_data)
3841
else :

helper/node/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def execute(self, command, command_args, chdir="", wait_terminate=True, func_std
233233
if sublime.platform() == 'windows':
234234
args = [self.cli_path, command] + command_args
235235
else :
236-
args = [self.node_js_path, self.cli_path, command] + command_args
236+
args = [self.cli_path, command] + command_args
237237

238238
return Util.execute(args[0], args[1:], chdir=chdir, wait_terminate=wait_terminate, func_stdout=func_stdout, args_func_stdout=args_func_stdout)
239239

make/_init.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
BOOKMARKS_FOLDER = os.path.join(HELPER_FOLDER, 'bookmarks')
2121

22+
WINDOWS_BATCH_FOLDER = os.path.join(PACKAGE_PATH, 'windows_batch')
23+
2224
platform_switcher = {"osx": "OSX", "linux": "Linux", "windows": "Windows"}
2325
os_switcher = {"osx": "darwin", "linux": "linux", "windows": "win"}
2426
PLATFORM = platform_switcher.get(sublime.platform())
@@ -90,6 +92,7 @@ def init(self):
9092
if os.path.exists(node_modules_path):
9193
shutil.rmtree(node_modules_path)
9294
sublime.error_message("Error during installation: can't install npm dependencies for JavaScript Enhancements plugin.\n\nThe error COULD be caused by the npm permission access (EACCES error), so in this case you need to repair/install node.js and npm in a way that doesn't require \"sudo\" command.\n\nFor example you could use a Node Version Manager, such as \"nvm\" or \"nodenv\".\n\nTry to run \"npm install\" inside the package of this plugin to see what you get.")
95+
return
9396
# else:
9497
# result = npm.update_all()
9598
# if not result[0]:
@@ -124,13 +127,14 @@ def start():
124127
sublime.error_message("Your architecture is not supported by this plugin. This plugin supports only 64bit architectures.")
125128
return
126129

127-
# try:
128-
# sys.modules["TerminalView"]
129-
# except Exception as err:
130-
# response = sublime.yes_no_cancel_dialog("TerminalView plugin is missing. TerminalView is required to be able to use \"JavaScript Enhancements\" plugin.\n\nDo you want open the github repo of it?", "Yes, open it", "No")
131-
# if response == sublime.DIALOG_YES:
132-
# sublime.active_window().run_command("open_url", args={"url": "https://github.com/Wramberg/TerminalView"})
133-
# return
130+
if sublime.platform() != 'windows':
131+
try:
132+
sys.modules["TerminalView"]
133+
except Exception as err:
134+
response = sublime.yes_no_cancel_dialog("TerminalView plugin is missing. TerminalView is required to be able to use \"JavaScript Enhancements\" plugin.\n\nDo you want open the github repo of it?", "Yes, open it", "No")
135+
if response == sublime.DIALOG_YES:
136+
sublime.active_window().run_command("open_url", args={"url": "https://github.com/Wramberg/TerminalView"})
137+
return
134138

135139
try:
136140
sys.modules["JavaScript Completions"]
@@ -166,7 +170,7 @@ def start():
166170
mainPlugin.init()
167171

168172
def plugin_loaded():
169-
173+
170174
if int(sublime.version()) >= 3124 :
171175
sublime.set_timeout_async(start, 1000)
172176
else:

messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"0.1.11": "changelog/0.1.11.txt",
77
"0.1.12": "changelog/0.1.12.txt",
88
"0.1.13": "changelog/0.1.13.txt",
9-
"0.1.14": "changelog/0.1.14.txt"
9+
"0.1.14": "changelog/0.1.14.txt",
10+
"0.11.00": "changelog/0.11.00.txt"
1011
}

0 commit comments

Comments
 (0)