Skip to content

Commit 2c272ee

Browse files
committed
Fix #169: Stop default options written to package.json
1 parent fd10ff5 commit 2c272ee

File tree

4 files changed

+77
-67
lines changed

4 files changed

+77
-67
lines changed

command_line.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import subprocess
3636
import plistlib
3737
import codecs
38-
import ssl
3938
from datetime import datetime, timedelta
4039

4140
from io import StringIO
@@ -125,9 +124,11 @@ def get_settings(self):
125124
for setting_group, setting_group_dict in sgroup_items:
126125
settings['setting_groups'].append(settings[setting_group])
127126

128-
self._setting_items = (list(config_obj['setting_groups'].items()) +
129-
[('export_settings', config_obj['export_settings'])] +
130-
[('compression', config_obj['compression'])])
127+
self._setting_items = (
128+
list(config_obj['setting_groups'].items()) +
129+
[('export_settings', config_obj['export_settings'])] +
130+
[('compression', config_obj['compression'])]
131+
)
131132

132133
config_obj.pop('setting_groups')
133134
config_obj.pop('export_settings')
@@ -339,7 +340,7 @@ def get_versions(self):
339340
f.write(v+os.linesep)
340341
except IOError:
341342
exc_format = utils.format_exc_info(sys.exc_info)
342-
self.show_error(error)
343+
self.show_error(exc_format)
343344
self.enable_ui_after_error()
344345
finally:
345346
if f:
@@ -369,7 +370,7 @@ def download_file_with_error_handling(self):
369370
os.remove(setting.save_file_path(version, location))
370371

371372
exc_format = utils.format_exc_info(sys.exc_info)
372-
self.show_error(error)
373+
self.show_error(exc_format)
373374
self.enable_ui_after_error()
374375

375376
def load_package_json(self, json_path=None):
@@ -472,7 +473,7 @@ def generate_json(self, global_json=False):
472473

473474
self.process_webexe_settings(dic, global_json)
474475

475-
s = json.dumps(dic, indent=4)
476+
s = json.dumps(dic, indent=4, sort_keys=True)
476477

477478
return s
478479

@@ -537,7 +538,6 @@ def load_from_json(self, json_str):
537538
for item in new_dic:
538539
setting = self.get_setting(item)
539540
if setting:
540-
setting_list.append(setting)
541541
if (setting.type == 'file' or
542542
setting.type == 'string' or
543543
setting.type == 'folder' or
@@ -556,6 +556,8 @@ def load_from_json(self, json_str):
556556
setting.value = val_str
557557
if setting.type == 'range':
558558
setting.value = new_dic[item]
559+
560+
setting_list.append(setting)
559561
if isinstance(new_dic[item], dict):
560562
stack.append((item, new_dic[item]))
561563
return setting_list
@@ -877,8 +879,8 @@ def try_make_output_dirs(self):
877879
self.make_output_dirs()
878880
except Exception:
879881
exc_format = utils.format_exc_info(sys.exc_info)
880-
self.logger.error(error)
881-
self.output_err += error
882+
self.logger.error(exc_format)
883+
self.output_err += exc_format
882884
finally:
883885
temp_dir = utils.path_join(config.TEMP_DIR, 'webexectemp')
884886
utils.rmtree(temp_dir, onerror=self.remove_readonly)
@@ -1101,6 +1103,8 @@ def copy_files_to_project_folder(self):
11011103

11021104
def convert_val_to_str(self, val):
11031105
"""Convert a setting value to a string path"""
1106+
if val is None:
1107+
return None
11041108
if isinstance(val, (list, tuple)):
11051109
return ', '.join(val)
11061110
return str(val).replace(self.project_dir()+os.path.sep, '')

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def is_installed():
8484
UPX_LIN64_PATH = 'files/compressors/upx-linux-x64'
8585

8686
ENV_VARS_PY_PATH = 'files/env_vars.py'
87-
ENV_VARS_BAT_FILE = 'files/env_vars.bat'
87+
ENV_VARS_BAT_PATH = 'files/env_vars.bat'
8888
ENV_VARS_BASH_PATH = 'files/env_vars.bash'
8989

9090
## Logger setup ----------------------------------------------

files/settings.cfg

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,139 +28,139 @@ linux_64_dir_prefix = 'nwjs-v{}-linux-x64'
2828
type='string'
2929
description='The name that your executable or app will have when exported.'
3030
[[[description]]]
31-
default_value=''
31+
default_value=None
3232
type='string'
3333
[[[version]]]
34-
default_value='0.1.0'
34+
default_value=None
3535
type='string'
3636
[[[keywords]]]
37-
default_value=''
37+
default_value=None
3838
type='string'
3939
[[[nodejs]]]
4040
display_name='Include Nodejs'
41-
default_value=True
41+
default_value=None
4242
type='check'
4343
[[[node-main]]]
4444
display_name='Node Main'
45-
default_value=''
45+
default_value=None
4646
type='file'
4747
file_types='*.js'
4848
description='A path to a nodejs script file that will be executed on startup.'
4949
[[[domain]]]
50-
default_value=''
50+
default_value=None
5151
type='string'
5252
description='Specify the host in the chrome-extension:// protocol URL used fo\n the application. The web engine will share the same cookies between your\napplication and the website under the same domain.'
5353
[[[user-agent]]]
5454
display_name='User Agent'
55-
default_value=''
55+
default_value=None
5656
type='string'
5757
description='Overrides the User-Agent header in http requests.\n\nThe following placeholders are available to composite the user agent dynamically:\n\n%name: replaced by the name field in the manifest.\n%ver: replaced by the version field in the manifest, if available.\n%nwver: replaced by the version of NW.js.\n%webkit_ver: replaced by the version of WebKit engine.\n%osinfo: replaced by the OS and CPU information you would see in browser’s user agent string.'
5858
[[[node-remote]]]
5959
display_name='Node Remote'
60-
default_value=''
60+
default_value=None
6161
type='strings'
6262
description='Enable calling node in remote pages. See the node-webkit\nmanifest format for more info.'
6363
[[[chromium-args]]]
6464
display_name='Chromium Args'
65-
default_value=''
65+
default_value=None
6666
type='string'
6767
description='Specify chromium command line arguments.\nExample value: "--disable-accelerated-video --force-cpu-draw"'
6868
[[[js-flags]]]
6969
display_name='JS Flags'
70-
default_value=''
70+
default_value=None
7171
type='string'
7272
description='Specify flags passed to the js engine.\nExample value: "--harmony_proxies --harmony_collecions"'
7373
[[[bg-script]]]
7474
display_name='Background Script'
75-
default_value=''
75+
default_value=None
7676
type='file'
7777
file_types='*.js'
7878
description='Background script. The script is executed in the background page at\nthe start of application.'
7979
[[[inject_js_start]]]
8080
display_name='Inject JS Start'
81-
default_value=''
81+
default_value=None
8282
type='file'
8383
file_types='*.js'
8484
description='A path to a js file that will be executed before any\nother script is run.'
8585
[[[inject_js_end]]]
8686
display_name='Inject JS End'
87-
default_value=''
87+
default_value=None
8888
type='file'
8989
file_types='*.js'
9090
description='A path to a js file that will be executed after the\nDOM is loaded.'
9191
[[[additional_trust_anchors]]]
9292
display_name='Trust Anchors'
93-
default_value=''
93+
default_value=None
9494
type='strings'
9595
description='A list of PEM-encoded certificates. Used as additional root\ncertificates for validation to allow connecting to services using a self-signed certificate.'
9696
[[[dom_storage_quota]]]
9797
display_name='DOM Storage (MB)'
98-
default_value=''
98+
default_value=None
9999
type='int'
100100
description='Number of mega bytes (MB) for the quota of the DOM storage.\nThe suggestion is to put double the value you want.'
101101

102102
[[webkit_settings]]
103103
[[[plugin]]]
104104
display_name='Load Plugins'
105-
default_value=True
105+
default_value=None
106106
type='check'
107107
description='Whether to load external browser plugins like Flash.\nFor example, put the Pepper flash dll or so file in a directory at the root of\nyour project called "PepperFlash" and it will be loaded.'
108108
[[[double_tap_to_zoom_enabled]]]
109109
display_name='Double-Tap Zoom'
110-
default_value=False
110+
default_value=None
111111
type='check'
112112
description='Enable zooming with double tapping on Mac OS X with 2 fingers. Mac OS X only'
113113

114114
[[web2exe_settings]]
115115
[[[export_dir]]]
116116
display_name='Output Directory'
117-
default_value=''
117+
default_value=None
118118
type='string'
119119
description='The output directory relative to the project directory.'
120120
[[[custom_script]]]
121121
display_name='Execute Script'
122-
default_value=''
122+
default_value=None
123123
copy=False
124124
type='file'
125125
description='The script to execute after a project was successfully exported.'
126126
[[[output_pattern]]]
127127
display_name='Output Name Pattern'
128-
default_value=''
128+
default_value=None
129129
type='string'
130130
description='Instead of using the App Name for the output directory, this field can\nbe used to reference different settings of the package.json to name the output folder.'
131131

132132
[[window_settings]]
133133
[[[id]]]
134-
default_value=''
134+
default_value=None
135135
type='string'
136136
description='The id used to identify the window. This will be used to remember the\nsize and position of the window and restore that geometry when a\nwindow with the same id is later opened. '
137137
[[[title]]]
138-
default_value=''
138+
default_value=None
139139
type='string'
140140
description='The default title of window created by NW.js, it’s very useful\nif you want to show your own title when the app is starting.'
141141
[[[icon]]]
142142
display_name='Window Icon'
143-
default_value=''
143+
default_value=None
144144
type='file'
145145
action='set_window_icon'
146146
file_types='*.png *.jpg *.jpeg'
147147
[[[mac_icon]]]
148-
default_value=''
148+
default_value=None
149149
type='file'
150150
action='set_mac_icon'
151151
file_types='*.png *.jpg *.jpeg *.icns'
152152
description='This icon to be displayed for the Mac Application.\nDefaults to Window Icon'
153153
[[[exe_icon]]]
154-
default_value=''
154+
default_value=None
155155
type='file'
156156
action='set_exe_icon'
157157
file_types='*.png *.jpg *.jpeg'
158158
description='This icon to be displayed for the windows exe of the app.\nDefaults to Window icon.'
159159
[[[width]]]
160-
default_value='640'
160+
default_value=None
161161
type='int'
162162
[[[height]]]
163-
default_value='480'
163+
default_value=None
164164
type='int'
165165
[[[min_width]]]
166166
default_value=None
@@ -176,39 +176,39 @@ linux_64_dir_prefix = 'nwjs-v{}-linux-x64'
176176
type='int'
177177
[[[always_on_top]]]
178178
display_name='Keep on Top'
179-
default_value=False
179+
default_value=None
180180
type='check'
181181
description='Makes the window always on top of other windows.'
182182
[[[frame]]]
183183
display_name='Window Frame'
184-
default_value=True
184+
default_value=None
185185
type='check'
186186
description='Show the frame of the window'
187187
[[[show_in_taskbar]]]
188188
display_name='Taskbar'
189-
default_value=True
189+
default_value=None
190190
type='check'
191191
description='Show the app running in the taskbar'
192192
[[[show]]]
193193
display_name='Show'
194-
default_value=True
194+
default_value=None
195195
type='check'
196196
description='Uncheck to make your app hidden on startup.'
197197
[[[visible_on_all_workspaces]]]
198198
display_name='All Workspaces'
199-
default_value=False
199+
default_value=None
200200
type='check'
201201
description='If checked, the exported app will be visible on all workspaces.\nMac & Linux Only'
202202
[[[visible]]]
203-
default_value=True
203+
default_value=None
204204
type='check'
205205
description='If unchecked, the app will have to be manually set to\nvisible in javascript.'
206206
[[[resizable]]]
207-
default_value=False
207+
default_value=None
208208
type='check'
209209
description=''
210210
[[[fullscreen]]]
211-
default_value=False
211+
default_value=None
212212
type='check'
213213
description=''
214214
[[[position]]]
@@ -218,27 +218,27 @@ linux_64_dir_prefix = 'nwjs-v{}-linux-x64'
218218
type='list'
219219
description='The position to place the window when it opens.'
220220
[[[as_desktop]]]
221-
default_value=False
221+
default_value=None
222222
type='check'
223223
description='Show as desktop background window under X11 environment. Linux Only.'
224224
[[[transparent]]]
225-
default_value=False
225+
default_value=None
226226
type='check'
227227
description='Allows window tranparency.'
228228
[[[kiosk]]]
229-
default_value=False
229+
default_value=None
230230
type='check'
231231
description='Puts the application is kiosk mode.'
232232
[[[kiosk_emulation]]]
233-
default_value=False
233+
default_value=None
234234
type='check'
235235
description='Puts the application is kiosk emulation mode. Will\nautomatically check off required settings that will emulate kiosk.'
236236
check_action='set_kiosk_emulation_options'
237237

238238
[[download_settings]]
239239
[[[nw_version]]]
240240
display_name='NW.js version'
241-
default_value='0.16.0'
241+
default_value=None
242242
values=[]
243243
type='list'
244244
button='Update'
@@ -254,32 +254,32 @@ linux_64_dir_prefix = 'nwjs-v{}-linux-x64'
254254
type='check'
255255
[[[download_dir]]]
256256
display_name='Download location'
257-
default_value='{DEFAULT_DOWNLOAD_PATH}'
257+
default_value=''
258258
type='folder'
259259

260260
[export_settings]
261261
[[windows-x32]]
262-
default_value=False
262+
default_value=None
263263
type='check'
264264
url='%(base_url)s%(win_32_dir_prefix)s.zip'
265265
binary_location='nw.exe'
266266
[[windows-x64]]
267-
default_value=False
267+
default_value=None
268268
type='check'
269269
url='%(base_url)s%(win_64_dir_prefix)s.zip'
270270
binary_location='nw.exe'
271271
[[mac-x64]]
272-
default_value=False
272+
default_value=None
273273
type='check'
274274
url='%(base_url)s%(mac_64_dir_prefix)s.zip'
275275

276276
[[linux-x64]]
277-
default_value=False
277+
default_value=None
278278
type='check'
279279
url='%(base_url)s%(linux_64_dir_prefix)s.tar.gz'
280280
binary_location='nw'
281281
[[linux-x32]]
282-
default_value=False
282+
default_value=None
283283
type='check'
284284
url='%(base_url)s%(linux_32_dir_prefix)s.tar.gz'
285285
binary_location='nw'

0 commit comments

Comments
 (0)