Skip to content

Commit 2517710

Browse files
committed
Remove Elm build configuration commands
These commands for controlling build settings are not needed for now, since support for doing full project builds has been removed from this package. The one remaining command will now find and open an elm.json file.
1 parent 4cf1db4 commit 2517710

File tree

2 files changed

+3
-144
lines changed

2 files changed

+3
-144
lines changed

Commands/Project.sublime-commands

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,6 @@
11
[
22
{
3-
"caption": "Elm Build System: View elm-package.json",
3+
"caption": "Elm Build System: View elm.json",
44
"command": "elm_project"
5-
},
6-
{
7-
"caption": "Elm Build System: Set Main Path",
8-
"command": "elm_project", "args":
9-
{
10-
"prop_name": "main_path",
11-
"caption": "Enter main path to build from: "
12-
}
13-
},
14-
{
15-
"caption": "Elm Build System: Set HTML Path",
16-
"command": "elm_project", "args":
17-
{
18-
"prop_name": "html_path",
19-
"caption": "Enter HTML path to open in browser: "
20-
}
21-
},
22-
{
23-
"caption": "Elm Build System: Set Output Path",
24-
"command": "elm_project", "args":
25-
{
26-
"prop_name": "output_path",
27-
"caption": "Enter path to build output to: "
28-
}
29-
},
30-
{
31-
"caption": "Elm Build System: Set Output Directory",
32-
"command": "elm_project", "args":
33-
{
34-
"prop_name": "output_dir",
35-
"caption": "Enter directory to build output to: "
36-
}
37-
},
38-
{
39-
"caption": "Elm Build System: Set Output Base Name",
40-
"command": "elm_project", "args":
41-
{
42-
"prop_name": "output_name",
43-
"caption": "Enter base name to build output with: "
44-
}
45-
},
46-
{
47-
"caption": "Elm Build System: Set Output Extension",
48-
"command": "elm_project", "args":
49-
{
50-
"prop_name": "output_ext",
51-
"choices":
52-
[
53-
"HTML",
54-
"JS"
55-
]
56-
}
575
}
586
]

elm_project.py

Lines changed: 2 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,15 @@ def is_enabled(self):
1111

1212
def run(self, edit, prop_name=None, choices=None, caption=None):
1313
self.window = self.view.window()
14-
if not prop_name:
15-
self.window.open_file(self.project.json_path, sublime.TRANSIENT)
16-
return
17-
self.prop_name = prop_name
18-
initial_value = getattr(self.project, prop_name)
19-
if choices:
20-
self.show_choices(choices, initial_value)
21-
else:
22-
self.window.show_input_panel(caption, initial_value, self.on_finished, None, None)
23-
24-
def show_choices(self, choices, initial_value):
25-
self.norm_choices = [choice.lower() for choice in choices]
26-
try:
27-
# ValueError: $initial_value is not in list
28-
initial_index = self.norm_choices.index(initial_value.lower())
29-
# ST2: Boost.Python.ArgumentError: Python argument types
30-
self.window.show_quick_panel(choices, self.on_choice, selected_index=initial_index)
31-
except: # simplest control flow
32-
if not is_ST2():
33-
log_string('project.logging.invalid_choice', initial_value)
34-
self.window.show_quick_panel(choices, self.on_choice)
35-
36-
def on_choice(self, index):
37-
if index != -1:
38-
self.on_finished(self.norm_choices[index])
39-
40-
def on_finished(self, value):
41-
setattr(self.project, self.prop_name, value)
42-
keys = self.project._last_updated_key_path
43-
if keys:
44-
sublime.status_message(get_string('project.updated', '.'.join(keys), value))
45-
46-
BUILD_KEY = ('sublime-build',)
47-
MAIN_KEY = BUILD_KEY + ('main',)
48-
HTML_KEY = BUILD_KEY + ('html',)
49-
OUTPUT_KEY = BUILD_KEY + ('output',)
50-
OUTPUT_PATH_KEY = OUTPUT_KEY + ('path',)
51-
OUTPUT_COMP_KEY = OUTPUT_KEY + ('components',)
52-
OUTPUT_DIR_KEY = OUTPUT_COMP_KEY + ('dir',)
53-
OUTPUT_NAME_KEY = OUTPUT_COMP_KEY + ('name',)
54-
OUTPUT_EXT_KEY = OUTPUT_COMP_KEY + ('ext',)
14+
self.window.open_file(self.project.json_path, sublime.TRANSIENT)
5515

5616
class ElmProject(object):
5717

5818
@classmethod
5919
def find_json(cls, dir_path):
6020
if not fs.isdir(fs.abspath(dir_path)):
6121
return None
62-
file_path = fs.abspath(fs.join(dir_path, 'elm-package.json'))
22+
file_path = fs.abspath(fs.join(dir_path, 'elm.json'))
6323
if fs.isfile(file_path):
6424
return file_path
6525
parent_path = fs.join(dir_path, fs.pardir)
@@ -128,52 +88,3 @@ def exists(self):
12888
@property
12989
def working_dir(self):
13090
return fs.dirname(self.json_path) if self.json_path else None
131-
132-
@property
133-
def main_path(self):
134-
return self[MAIN_KEY] or fs.relpath(self.file_path, self.working_dir)
135-
136-
@main_path.setter
137-
def main_path(self, value):
138-
self[MAIN_KEY] = value
139-
140-
@property
141-
def html_path(self):
142-
return self[HTML_KEY] or self.output_path
143-
144-
@html_path.setter
145-
def html_path(self, value):
146-
self[HTML_KEY] = value
147-
148-
@property
149-
def output_path(self):
150-
output_path = fs.join(self.output_dir, self.output_name + '.' + self.output_ext)
151-
return self[OUTPUT_PATH_KEY] or fs.normpath(output_path)
152-
153-
@output_path.setter
154-
def output_path(self, value):
155-
self[OUTPUT_PATH_KEY] = value
156-
157-
@property
158-
def output_dir(self):
159-
return self[OUTPUT_DIR_KEY] or 'build'
160-
161-
@output_dir.setter
162-
def output_dir(self, value):
163-
self[OUTPUT_DIR_KEY] = value
164-
165-
@property
166-
def output_name(self):
167-
return self[OUTPUT_NAME_KEY] or fs.splitext(fs.basename(self.main_path))[0]
168-
169-
@output_name.setter
170-
def output_name(self, value):
171-
self[OUTPUT_NAME_KEY] = value
172-
173-
@property
174-
def output_ext(self):
175-
return self[OUTPUT_EXT_KEY] or 'html'
176-
177-
@output_ext.setter
178-
def output_ext(self, value):
179-
self[OUTPUT_EXT_KEY] = value

0 commit comments

Comments
 (0)