generator-nsis 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -6
- package/generators/app/index.js +232 -534
- package/generators/app/templates/installer.nsi.ejs +19 -18
- package/generators/lib/choices.js +265 -0
- package/generators/lib/helpers.js +70 -0
- package/license.txt +7 -0
- package/package.json +30 -21
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-present Jan T. Sott
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# generator-nsis
|
|
2
2
|
|
|
3
|
-
[](https://github.com/idleberg/generator-nsis/blob/main/LICENSE)
|
|
4
|
+
[](https://www.npmjs.org/package/generator-nsis)
|
|
5
|
+
[](https://github.com/idleberg/generator-nsis/actions)
|
|
6
6
|
|
|
7
7
|
## Description
|
|
8
8
|
|
|
@@ -24,7 +24,7 @@ A [Yeoman](http://yeoman.io/authoring/user-interactions.html) generator for NSIS
|
|
|
24
24
|
You need [Node.js](https://nodejs.org/en/) installed and available in your `PATH` [environment variable](http://superuser.com/a/284351/195953). Use your preferred Node package manager to install the Yeoman CLI tool.
|
|
25
25
|
|
|
26
26
|
```sh
|
|
27
|
-
npm install -g yo
|
|
27
|
+
$ npm install -g yo
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
@@ -32,7 +32,7 @@ npm install -g yo
|
|
|
32
32
|
Use your preferred package manager to install this generator
|
|
33
33
|
|
|
34
34
|
```sh
|
|
35
|
-
npm i generator-nsis -g
|
|
35
|
+
$ npm i generator-nsis -g
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Usage
|
|
@@ -40,7 +40,7 @@ npm i generator-nsis -g
|
|
|
40
40
|
Run the generator and follow its instructions. Use `--help` for available flags.
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
yo nsis
|
|
43
|
+
$ yo nsis
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
*“That's all Folks!”*
|
package/generators/app/index.js
CHANGED
|
@@ -1,535 +1,233 @@
|
|
|
1
|
-
const Generator = require('yeoman-generator');
|
|
2
|
-
const pkg = require('../../package.json');
|
|
3
1
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (a.name > b.name) {
|
|
237
|
-
return 1;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return 0;
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
return languageChoices;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
languageDialog(isUnicode) {
|
|
247
|
-
const languageDialog = Object.entries(languageData).map(([key, value]) => {
|
|
248
|
-
if (key === 'English') return;
|
|
249
|
-
|
|
250
|
-
return {
|
|
251
|
-
constant: `$\{LANG_${key.toUpperCase()}}`,
|
|
252
|
-
string: (isUnicode) ? value.native : (value.long || key)
|
|
253
|
-
};
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
return languageDialog;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
inquirer() {
|
|
260
|
-
return this.prompt([
|
|
261
|
-
{
|
|
262
|
-
name: 'name',
|
|
263
|
-
message: `Application name`,
|
|
264
|
-
default: slugify(this.appname),
|
|
265
|
-
store: true
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
name: 'version',
|
|
269
|
-
message: `Application version`,
|
|
270
|
-
default: '0.0.0',
|
|
271
|
-
store: true,
|
|
272
|
-
validate: version => (this.looseVersion === true || semver.valid(version) !== null) ? true : `Not a valid ${terminalLink('semantic version', 'https://semver.org', {
|
|
273
|
-
fallback() {
|
|
274
|
-
return 'semantic version';
|
|
275
|
-
}
|
|
276
|
-
})}`
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
name: 'unicode',
|
|
280
|
-
message: 'Unicode installer',
|
|
281
|
-
type: 'confirm',
|
|
282
|
-
default: 'true',
|
|
283
|
-
store: true
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
name: 'elevation',
|
|
287
|
-
message: 'Requested execution level',
|
|
288
|
-
type: 'list',
|
|
289
|
-
default: 'user',
|
|
290
|
-
store: true,
|
|
291
|
-
choices: [ 'user', 'highest', 'admin', 'none' ]
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
name: 'compression',
|
|
295
|
-
message: 'Set compression',
|
|
296
|
-
type: 'list',
|
|
297
|
-
default: 'lzma',
|
|
298
|
-
store: true,
|
|
299
|
-
choices: [ 'zlib', 'bzip2', 'lzma' ]
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: 'pages',
|
|
303
|
-
message: 'Installer pages',
|
|
304
|
-
type: 'checkbox',
|
|
305
|
-
store: true,
|
|
306
|
-
choices: [
|
|
307
|
-
{
|
|
308
|
-
name: 'license',
|
|
309
|
-
value: 'license',
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
name: 'components',
|
|
313
|
-
value: 'components',
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
name: 'directory',
|
|
317
|
-
value: 'directory',
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
name: 'instfiles',
|
|
321
|
-
value: 'instfiles',
|
|
322
|
-
checked: true
|
|
323
|
-
}
|
|
324
|
-
]
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
name: 'spdxQuestion',
|
|
328
|
-
message: `Choose a license from ${terminalLink('SPDX License List', 'https://spdx.org/licenses/', {
|
|
329
|
-
fallback() {
|
|
330
|
-
return 'SPDX License List'
|
|
331
|
-
}
|
|
332
|
-
})}`,
|
|
333
|
-
type: 'confirm',
|
|
334
|
-
default: true,
|
|
335
|
-
store: true,
|
|
336
|
-
when: answers => answers.pages.includes('license') ? true : false
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
name: 'spdxLicense',
|
|
340
|
-
message: 'Choose a license',
|
|
341
|
-
type: 'list',
|
|
342
|
-
default: 'MIT',
|
|
343
|
-
choices: licenseChoices,
|
|
344
|
-
store: true,
|
|
345
|
-
when: answers => (answers.pages.includes('license') && answers.spdxQuestion) ? true : false
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
name: 'sections',
|
|
349
|
-
message: 'Number of sections',
|
|
350
|
-
default: 1,
|
|
351
|
-
store: true,
|
|
352
|
-
validate: number => (Number.isInteger(parseInt(number)) && parseInt(number) > 0) ? true : 'Not a valid integer'
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
name: 'callbacks',
|
|
356
|
-
message: 'Add callback functions',
|
|
357
|
-
type: 'checkbox',
|
|
358
|
-
store: true,
|
|
359
|
-
choices: [
|
|
360
|
-
{
|
|
361
|
-
name: terminalLink('.onInit', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onInit.md', {
|
|
362
|
-
fallback() {
|
|
363
|
-
return '.onInit';
|
|
364
|
-
}
|
|
365
|
-
}),
|
|
366
|
-
value: '.onInit'
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
name: terminalLink('.onGUIInit', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onGUIInit.md', {
|
|
370
|
-
fallback() {
|
|
371
|
-
return '.onGUIInit';
|
|
372
|
-
}
|
|
373
|
-
}),
|
|
374
|
-
value: '.onGUIInit'
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
name: terminalLink('.onGUIEnd', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onGUIEnd.md', {
|
|
378
|
-
fallback() {
|
|
379
|
-
return '.onGUIEnd';
|
|
380
|
-
}
|
|
381
|
-
}),
|
|
382
|
-
value: '.onGUIEnd'
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
name: terminalLink('.onInstSuccess', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onInstSuccess.md', {
|
|
386
|
-
fallback() {
|
|
387
|
-
return '.onInstSuccess';
|
|
388
|
-
}
|
|
389
|
-
}),
|
|
390
|
-
value: '.onInstSuccess'
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
name: terminalLink('.onInstFailed', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onInstFailed.md', {
|
|
394
|
-
fallback() {
|
|
395
|
-
return '.onInstFailed';
|
|
396
|
-
}
|
|
397
|
-
}),
|
|
398
|
-
value: '.onInstFailed'
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: terminalLink('.onUserAbort', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onUserAbort.md', {
|
|
402
|
-
fallback() {
|
|
403
|
-
return '.onUserAbort';
|
|
404
|
-
}
|
|
405
|
-
}),
|
|
406
|
-
value: '.onUserAbort'
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
name: terminalLink('.onVerifyInstDir', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onVerifyInstDir.md', {
|
|
410
|
-
fallback() {
|
|
411
|
-
return '.onVerifyInstDir';
|
|
412
|
-
}
|
|
413
|
-
}),
|
|
414
|
-
value: '.onVerifyInstDir'
|
|
415
|
-
},
|
|
416
|
-
{
|
|
417
|
-
name: terminalLink('.onRebootFailed', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onRebootFailed.md', {
|
|
418
|
-
fallback() {
|
|
419
|
-
return '.onRebootFailed';
|
|
420
|
-
}
|
|
421
|
-
}),
|
|
422
|
-
value: '.onRebootFailed'
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
name: terminalLink('.onSelChange', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onSelChange.md', {
|
|
426
|
-
fallback() {
|
|
427
|
-
return '.onSelChange';
|
|
428
|
-
}
|
|
429
|
-
}),
|
|
430
|
-
value: '.onSelChange'
|
|
431
|
-
},
|
|
432
|
-
{
|
|
433
|
-
name: terminalLink('.onMouseOverSection', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onMouseOverSection.md', {
|
|
434
|
-
fallback() {
|
|
435
|
-
return '.onMouseOverSection';
|
|
436
|
-
}
|
|
437
|
-
}),
|
|
438
|
-
value: '.onMouseOverSection'
|
|
439
|
-
},
|
|
440
|
-
] },
|
|
441
|
-
{
|
|
442
|
-
name: 'includes',
|
|
443
|
-
message: 'Add libraries',
|
|
444
|
-
type: 'checkbox',
|
|
445
|
-
store: true,
|
|
446
|
-
choices: async () => this.firstParty ? bundledLibraries : await getAllLibraries()
|
|
447
|
-
},
|
|
448
|
-
{
|
|
449
|
-
name: 'languages',
|
|
450
|
-
message: (this.disabled === true) ? 'Add languages other than English' : 'Add languages',
|
|
451
|
-
type: 'checkbox',
|
|
452
|
-
store: true,
|
|
453
|
-
choices: this.languageChoices()
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
name: 'languageDialog',
|
|
457
|
-
message: 'Add language dialog',
|
|
458
|
-
type: 'confirm',
|
|
459
|
-
default: 'true',
|
|
460
|
-
store: true,
|
|
461
|
-
when: answers => {
|
|
462
|
-
switch (true) {
|
|
463
|
-
case (this.options['unlock-all'] === true && answers.languages.length > 1):
|
|
464
|
-
case (this.options['unlock-all'] === false && answers.languages.length > 0):
|
|
465
|
-
return true;
|
|
466
|
-
default:
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
name: 'editInstallerScript',
|
|
473
|
-
message: 'Edit installer script',
|
|
474
|
-
type: 'confirm',
|
|
475
|
-
default: 'true',
|
|
476
|
-
store: true,
|
|
477
|
-
when: () => {
|
|
478
|
-
return (process.env.EDITOR) ? true : false;
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
]).then(props => {
|
|
482
|
-
|
|
483
|
-
if (typeof props.spdxLicense !== 'undefined') {
|
|
484
|
-
props.licenseText = spdxLicenseList[props.spdxLicense].licenseText.replace(/\n{3,}/g, '\n\n');
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (props.name.includes('&')) {
|
|
488
|
-
props.ampersand_name = props.name.replace('&', '&&');
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
props.outfile = props.version ? `${slugify(props.name)}-${props.version}-setup` : `${slugify(props.name)}-setup`;
|
|
492
|
-
|
|
493
|
-
if (props.languageDialog) {
|
|
494
|
-
if (!props.callbacks.includes('.onInit')) {
|
|
495
|
-
props.callbacks.unshift('.onInit');
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
if (props.includes.includes('MUI2')) {
|
|
500
|
-
const indexOfonGUIInit = props.callbacks.indexOf('.onGUIInit');
|
|
501
|
-
const indexOfonUserAbort = props.callbacks.indexOf('.onUserAbort');
|
|
502
|
-
if (indexOfonGUIInit !== -1) {
|
|
503
|
-
props.callbacks.splice(indexOfonGUIInit, 1, '"custom.onGUIInit"');
|
|
504
|
-
}
|
|
505
|
-
if (indexOfonUserAbort !== -1) {
|
|
506
|
-
props.callbacks.splice(indexOfonUserAbort, 1, '"custom.onUserAbort"');
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
this.fs.copyTpl(
|
|
511
|
-
this.templatePath('installer.nsi.ejs'),
|
|
512
|
-
this.destinationPath('installer.nsi'),
|
|
513
|
-
{
|
|
514
|
-
languageData: languageData,
|
|
515
|
-
pkg: props,
|
|
516
|
-
unlockAll: this.options['unlock-all']
|
|
517
|
-
}
|
|
518
|
-
);
|
|
519
|
-
|
|
520
|
-
if (typeof props.spdxLicense !== 'undefined') {
|
|
521
|
-
this.fs.copyTpl(
|
|
522
|
-
this.templatePath('license.txt.ejs'),
|
|
523
|
-
this.destinationPath('license.txt'),
|
|
524
|
-
{
|
|
525
|
-
licenseText: props.licenseText
|
|
526
|
-
}
|
|
527
|
-
);
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
if (props.editInstallerScript === true) {
|
|
531
|
-
this.spawnCommand(process.env.EDITOR, [ 'installer.nsi' ]);
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
};
|
|
2
|
+
import { meta as languageData } from '@nsis/language-data';
|
|
3
|
+
|
|
4
|
+
import { getAllLibraries, getLanguageChoices, licenseChoices } from '../lib/helpers.js';
|
|
5
|
+
import * as choices from '../lib/choices.js';
|
|
6
|
+
import Generator from 'yeoman-generator';
|
|
7
|
+
import semver from 'semver';
|
|
8
|
+
import slugify from '@sindresorhus/slugify';
|
|
9
|
+
import spdxLicenseList from 'spdx-license-list/full.js';
|
|
10
|
+
import terminalLink from 'terminal-link';
|
|
11
|
+
|
|
12
|
+
export default class extends Generator {
|
|
13
|
+
constructor(args, opts) {
|
|
14
|
+
super(args, opts);
|
|
15
|
+
|
|
16
|
+
this.option('first-party', { desc: 'Limits library inclusion to first-party', default: false });
|
|
17
|
+
this.option('loose-version', { desc: `Doesn't enforce semantic versioning`, default: false });
|
|
18
|
+
this.option('unlock-all', { desc: 'Unlocks all disabled features', default: false });
|
|
19
|
+
this.option('debug', { desc: 'Prints debug messages', default: false });
|
|
20
|
+
|
|
21
|
+
this.looseVersion = (this.options.looseVersion ? true : false);
|
|
22
|
+
this.disabled = (this.options.unlockAll ? false : true);
|
|
23
|
+
this.firstParty = (this.options.firstParty ? true : false);
|
|
24
|
+
this.debug = (this.options.debug ? true : false);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// languageDialog(isUnicode) {
|
|
28
|
+
// const languageDialog = Object.entries(languageData).map(([key, value]) => {
|
|
29
|
+
// if (key === 'English') return;
|
|
30
|
+
|
|
31
|
+
// return {
|
|
32
|
+
// constant: `$\{LANG_${key.toUpperCase()}}`,
|
|
33
|
+
// string: (isUnicode) ? value.native : (value.long || key)
|
|
34
|
+
// };
|
|
35
|
+
// });
|
|
36
|
+
|
|
37
|
+
// return languageDialog;
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
inquirer() {
|
|
41
|
+
return this.prompt([
|
|
42
|
+
{
|
|
43
|
+
name: 'name',
|
|
44
|
+
message: `Application name`,
|
|
45
|
+
default: slugify(this.appname),
|
|
46
|
+
store: true,
|
|
47
|
+
validate: name => (name.trim().length > 0) ? true : 'Not a valid name'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'version',
|
|
51
|
+
message: `Application version`,
|
|
52
|
+
default: '0.0.0',
|
|
53
|
+
store: true,
|
|
54
|
+
validate: version => (this.looseVersion === true || semver.valid(version) !== null) ? true : `Not a valid ${terminalLink('semantic version', 'https://semver.org', {
|
|
55
|
+
fallback() {
|
|
56
|
+
return 'semantic version';
|
|
57
|
+
}
|
|
58
|
+
})}`
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'unicode',
|
|
62
|
+
message: 'Unicode installer',
|
|
63
|
+
type: 'confirm',
|
|
64
|
+
default: 'true',
|
|
65
|
+
store: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'elevation',
|
|
69
|
+
message: 'Requested execution level',
|
|
70
|
+
type: 'list',
|
|
71
|
+
default: 'user',
|
|
72
|
+
store: true,
|
|
73
|
+
choices: choices.elevation
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'compression',
|
|
77
|
+
message: 'Set compression',
|
|
78
|
+
type: 'list',
|
|
79
|
+
default: 'lzma',
|
|
80
|
+
store: true,
|
|
81
|
+
choices: choices.compression
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'pages',
|
|
85
|
+
message: 'Installer pages',
|
|
86
|
+
type: 'checkbox',
|
|
87
|
+
store: true,
|
|
88
|
+
default: [ 'instfiles' ],
|
|
89
|
+
choices: choices.pages
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'spdxQuestion',
|
|
93
|
+
message: `Choose a license from ${terminalLink('SPDX License List', 'https://spdx.org/licenses/', {
|
|
94
|
+
fallback() {
|
|
95
|
+
return 'SPDX License List'
|
|
96
|
+
}
|
|
97
|
+
})}`,
|
|
98
|
+
type: 'confirm',
|
|
99
|
+
default: true,
|
|
100
|
+
store: true,
|
|
101
|
+
when: answers => answers.pages?.includes('license') ? true : false
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'spdxLicense',
|
|
105
|
+
message: 'Choose a license',
|
|
106
|
+
type: 'list',
|
|
107
|
+
default: 'MIT',
|
|
108
|
+
choices: licenseChoices,
|
|
109
|
+
store: true,
|
|
110
|
+
when: answers => answers.pages?.includes('license') && answers.spdxQuestion ? true : false
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'sections',
|
|
114
|
+
message: 'Number of sections',
|
|
115
|
+
default: 1,
|
|
116
|
+
store: true,
|
|
117
|
+
validate: number => (Number.isInteger(parseInt(number)) && parseInt(number) > 0) ? true : 'Not a valid integer'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'callbacks',
|
|
121
|
+
message: 'Add callback functions',
|
|
122
|
+
type: 'checkbox',
|
|
123
|
+
store: true,
|
|
124
|
+
default: [],
|
|
125
|
+
choices: choices.callbacks
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'includes',
|
|
129
|
+
message: 'Add libraries',
|
|
130
|
+
type: 'checkbox',
|
|
131
|
+
store: true,
|
|
132
|
+
default: [],
|
|
133
|
+
choices: async () => this.firstParty ? choices.includes : await getAllLibraries(),
|
|
134
|
+
validate: callbacks => (callbacks.includes('MUI') && callbacks.includes('MUI2')) ? 'Don\'t mix MUI versions' : true
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'languages',
|
|
138
|
+
message: (this.disabled === true) ? 'Add languages other than English' : 'Add languages',
|
|
139
|
+
type: 'checkbox',
|
|
140
|
+
store: true,
|
|
141
|
+
default: [],
|
|
142
|
+
choices: getLanguageChoices(this.disabled)
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'languageDialog',
|
|
146
|
+
message: 'Add language dialog',
|
|
147
|
+
type: 'confirm',
|
|
148
|
+
default: 'true',
|
|
149
|
+
store: true,
|
|
150
|
+
when: answers => {
|
|
151
|
+
switch (true) {
|
|
152
|
+
case (this.options['unlock-all'] === true && answers.languages?.length > 1):
|
|
153
|
+
case (this.options['unlock-all'] === false && answers.languages?.length > 0):
|
|
154
|
+
return true;
|
|
155
|
+
|
|
156
|
+
default:
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'editInstallerScript',
|
|
163
|
+
message: 'Edit installer script',
|
|
164
|
+
type: 'confirm',
|
|
165
|
+
default: 'true',
|
|
166
|
+
store: true,
|
|
167
|
+
when: () => {
|
|
168
|
+
return (process.env.EDITOR) ? true : false;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
]).then(async props => {
|
|
172
|
+
|
|
173
|
+
if (this.options.debug) {
|
|
174
|
+
console.log(props);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (typeof props.spdxLicense !== 'undefined') {
|
|
178
|
+
props.licenseText = spdxLicenseList[props.spdxLicense].licenseText.replace(/\n{3,}/g, '\n\n');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (props.name.includes('&')) {
|
|
182
|
+
props.ampersand_name = props.name.replace('&', '&&');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
props.outfile = props.version ? `${slugify(props.name)}-${props.version}-setup` : `${slugify(props.name)}-setup`;
|
|
186
|
+
|
|
187
|
+
if (props.languageDialog) {
|
|
188
|
+
if (!props.callbacks.includes('.onInit')) {
|
|
189
|
+
props.callbacks.unshift('.onInit');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (props.includes?.includes('MUI2')) {
|
|
194
|
+
const includesOnGUIInit = props.callbacks.indexOf('.onGUIInit');
|
|
195
|
+
|
|
196
|
+
if (includesOnGUIInit !== -1) {
|
|
197
|
+
props.callbacks.splice(includesOnGUIInit, 1, 'MUI.onGUIInit');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const includesOnUserAbort = props.callbacks.indexOf('.onUserAbort');
|
|
201
|
+
|
|
202
|
+
if (includesOnUserAbort !== -1) {
|
|
203
|
+
props.callbacks.splice(includesOnUserAbort, 1, 'MUI.onUserAbort');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
await this.fs.copyTplAsync(
|
|
208
|
+
this.templatePath('installer.nsi.ejs'),
|
|
209
|
+
this.destinationPath('installer.nsi'),
|
|
210
|
+
{
|
|
211
|
+
languageData: languageData,
|
|
212
|
+
pkg: props,
|
|
213
|
+
unlockAll: this.options['unlock-all'],
|
|
214
|
+
debug: this.options.debug
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
if (typeof props.spdxLicense !== 'undefined') {
|
|
219
|
+
await this.fs.copyTplAsync(
|
|
220
|
+
this.templatePath('license.txt.ejs'),
|
|
221
|
+
this.destinationPath('license.txt'),
|
|
222
|
+
{
|
|
223
|
+
licenseText: props.licenseText
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (props.editInstallerScript === true) {
|
|
229
|
+
this.spawnCommand(process.env.EDITOR, [ 'installer.nsi' ]);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Generated with generator-nsis
|
|
2
2
|
# https://github.com/idleberg/generator-nsis
|
|
3
3
|
|
|
4
|
-
# Includes ---------------------------------<% pkg.includes
|
|
5
|
-
!include "<%= include
|
|
4
|
+
# Includes ---------------------------------<% pkg.includes?.forEach( include => { %>
|
|
5
|
+
!include "<%= include %>"<% }); %>
|
|
6
6
|
|
|
7
7
|
# Settings ---------------------------------
|
|
8
8
|
Name "<%- pkg.name %>"<% if (typeof pkg.ampersand_name !== 'undefined') { %> "<%- pkg.ampersand_name %>"<% } %>
|
|
@@ -10,40 +10,40 @@ OutFile "<%= pkg.outfile %>.exe"
|
|
|
10
10
|
Unicode <%= pkg.unicode %>
|
|
11
11
|
SetCompressor <%= pkg.compression %>
|
|
12
12
|
RequestExecutionLevel <%= pkg.elevation %>
|
|
13
|
-
InstallDir "$PROGRAMFILES\<%- pkg.name %>"<% if (!pkg.includes
|
|
13
|
+
InstallDir "$PROGRAMFILES\<%- pkg.name %>"<% if (!pkg.includes?.includes('MUI2') && pkg.pages?.includes('license')) { %>
|
|
14
14
|
LicenseData "<% if (typeof pkg.spdxLicense !== 'undefined') { %>license.txt<% } %>"<% } %>
|
|
15
|
-
<% if (pkg.includes
|
|
16
|
-
# Modern UI
|
|
17
|
-
|
|
18
|
-
!define MUI_CUSTOMFUNCTION_ABORT "
|
|
15
|
+
<% if (pkg.includes?.includes('MUI2')) { %>
|
|
16
|
+
# Modern UI --------------------------------<% if (pkg.callbacks?.includes('MUI.onGUIInit')) { %>
|
|
17
|
+
!define MUI_CUSTOMFUNCTION_GUIINIT "MUI.onGUIInit"<% } %><% if (pkg.callbacks?.includes('MUI.onUserAbort')) { %>
|
|
18
|
+
!define MUI_CUSTOMFUNCTION_ABORT "MUI.onUserAbort"<% } %>
|
|
19
19
|
<% } %>
|
|
20
20
|
# Pages ------------------------------------
|
|
21
|
-
<% pkg.pages
|
|
21
|
+
<% pkg.pages?.forEach( page => { %><% if (page?.length) { %><% if (pkg.includes?.includes('MUI2')) { %>!insertmacro MUI_PAGE_<%= page.toUpperCase() %><% if (page === 'license' && typeof pkg.spdxLicense !== 'undefined') { %> "license.txt"<% } %><% } else { %>Page <%= page %><% } %><% } %>
|
|
22
22
|
<% }); %>
|
|
23
23
|
# Languages --------------------------------<% if (unlockAll === false) { %>
|
|
24
|
-
<% if (pkg.includes
|
|
25
|
-
<% if (pkg.includes
|
|
24
|
+
<% if (pkg.includes?.includes('MUI2')) { %>!insertmacro MUI_LANGUAGE "English"<% } else { %>LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"<% } %><% } %><% pkg.languages?.forEach( language => { %>
|
|
25
|
+
<% if (pkg.includes?.includes('MUI2')) { %>!insertmacro MUI_LANGUAGE "<%= language %>"<% } else { %>LoadLanguageFile "${NSISDIR}\Contrib\Language files\<%= language %>.nlf"<% } %><% }); %>
|
|
26
26
|
|
|
27
27
|
# Sections ---------------------------------<% for (let step = 0; step < parseInt(pkg.sections); step++) { %>
|
|
28
|
-
Section "section" SECTION_<%= step %>
|
|
28
|
+
Section "section" SECTION_<%= step + 1 %>
|
|
29
29
|
SectionEnd
|
|
30
|
-
<% } %><% if (pkg.includes
|
|
30
|
+
<% } %><% if (pkg.includes?.includes('MUI2')) { %>
|
|
31
31
|
# Descriptions -----------------------------<% for (let step = 0; step < parseInt(pkg.sections); step++) { %><% if (unlockAll === false) { %>
|
|
32
|
-
LangString DESC_SECTION_<%= step %> ${LANG_ENGLISH} "English description for section <%= step %>"<% } %><% pkg.languages
|
|
33
|
-
LangString DESC_SECTION_<%= step %> ${LANG_<%= language.toUpperCase() %>} "<%= language %> description for section <%= step %>"<% }); %>
|
|
32
|
+
LangString DESC_SECTION_<%= step + 1 %> ${LANG_ENGLISH} "English description for section <%= step + 1%>"<% } %><% pkg.languages?.forEach( language => { %>
|
|
33
|
+
LangString DESC_SECTION_<%= step + 1 %> ${LANG_<%= language.toUpperCase() %>} "<%= language %> description for section <%= step + 1 %>"<% }); %>
|
|
34
34
|
<% } %>
|
|
35
35
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN<% for (let step = 0; step < parseInt(pkg.sections); step++) { %>
|
|
36
|
-
!insertmacro MUI_DESCRIPTION_TEXT ${SECTION_<%= step %>} $(DESC_SECTION_<%= step %>)<% } %>
|
|
36
|
+
!insertmacro MUI_DESCRIPTION_TEXT ${SECTION_<%= step + 1 %>} $(DESC_SECTION_<%= step + 1 %>)<% } %>
|
|
37
37
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
|
38
38
|
<% } %>
|
|
39
|
-
# Functions --------------------------------<% pkg.callbacks
|
|
39
|
+
# Functions --------------------------------<% pkg.callbacks?.forEach( callback => { %>
|
|
40
40
|
Function <%- callback %>
|
|
41
41
|
<% if (callback === '.onInit' && pkg.languageDialog) { %> Call LanguageDialog<%= '\n' %><% } %>FunctionEnd
|
|
42
42
|
<% }); %><% if (pkg.languageDialog) { %>
|
|
43
43
|
Function LanguageDialog
|
|
44
44
|
Push ""
|
|
45
45
|
Push ${LANG_ENGLISH}
|
|
46
|
-
Push English<% pkg.languages
|
|
46
|
+
Push English<% pkg.languages?.forEach( language => { %>
|
|
47
47
|
Push ${LANG_<%- language.toUpperCase() %>}
|
|
48
48
|
Push "<% if (pkg.unicode) { %><%- languageData[language].native %><% } else { %><%- languageData[language].long || language %><% } %>"<% }); %>
|
|
49
49
|
Push A
|
|
@@ -53,4 +53,5 @@ Function LanguageDialog
|
|
|
53
53
|
StrCmp $LANGUAGE "cancel" 0 +2
|
|
54
54
|
Abort
|
|
55
55
|
FunctionEnd
|
|
56
|
-
<% } %>
|
|
56
|
+
<% } %>
|
|
57
|
+
<% JSON.stringify(pkg.callbacks) %>
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import terminalLink from 'terminal-link';
|
|
2
|
+
|
|
3
|
+
const docsURL = 'https://github.com/NSIS-Dev/Documentation/tree/master';
|
|
4
|
+
|
|
5
|
+
export const binary = [false, true];
|
|
6
|
+
export const elevation = ['user', 'highest', 'admin', 'none'];
|
|
7
|
+
export const compression = ['zlib', 'bzip2', 'lzma'];
|
|
8
|
+
|
|
9
|
+
export const callbacks = [
|
|
10
|
+
{
|
|
11
|
+
name: terminalLink('.onInit', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onInit.md', {
|
|
12
|
+
fallback() {
|
|
13
|
+
return '.onInit';
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
value: '.onInit'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: terminalLink('.onGUIInit', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onGUIInit.md', {
|
|
20
|
+
fallback() {
|
|
21
|
+
return '.onGUIInit';
|
|
22
|
+
}
|
|
23
|
+
}),
|
|
24
|
+
value: '.onGUIInit'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: terminalLink('.onGUIEnd', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onGUIEnd.md', {
|
|
28
|
+
fallback() {
|
|
29
|
+
return '.onGUIEnd';
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
value: '.onGUIEnd'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: terminalLink('.onInstSuccess', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onInstSuccess.md', {
|
|
36
|
+
fallback() {
|
|
37
|
+
return '.onInstSuccess';
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
value: '.onInstSuccess'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: terminalLink('.onInstFailed', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onInstFailed.md', {
|
|
44
|
+
fallback() {
|
|
45
|
+
return '.onInstFailed';
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
value: '.onInstFailed'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: terminalLink('.onUserAbort', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onUserAbort.md', {
|
|
52
|
+
fallback() {
|
|
53
|
+
return '.onUserAbort';
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
value: '.onUserAbort'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: terminalLink('.onVerifyInstDir', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onVerifyInstDir.md', {
|
|
60
|
+
fallback() {
|
|
61
|
+
return '.onVerifyInstDir';
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
value: '.onVerifyInstDir'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: terminalLink('.onRebootFailed', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onRebootFailed.md', {
|
|
68
|
+
fallback() {
|
|
69
|
+
return '.onRebootFailed';
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
value: '.onRebootFailed'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: terminalLink('.onSelChange', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onSelChange.md', {
|
|
76
|
+
fallback() {
|
|
77
|
+
return '.onSelChange';
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
value: '.onSelChange'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: terminalLink('.onMouseOverSection', 'https://github.com/NSIS-Dev/Documentation/blob/master/Callbacks/onMouseOverSection.md', {
|
|
84
|
+
fallback() {
|
|
85
|
+
return '.onMouseOverSection';
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
value: '.onMouseOverSection'
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
export const includes = [
|
|
93
|
+
{
|
|
94
|
+
name: 'Colors.nsh',
|
|
95
|
+
value: 'Colors',
|
|
96
|
+
checked: false
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: terminalLink('FileFunc.nsh', `${docsURL}/Includes/FileFunc`, {
|
|
100
|
+
fallback() {
|
|
101
|
+
return 'FileFunc.nsh';
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
value: 'FileFunc',
|
|
105
|
+
checked: false
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'InstallOptions.nsh',
|
|
109
|
+
value: 'InstallOptions',
|
|
110
|
+
checked: false
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'Integration.nsh',
|
|
114
|
+
value: 'Integration',
|
|
115
|
+
checked: false
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'LangFile.nsh',
|
|
119
|
+
value: 'LangFile',
|
|
120
|
+
checked: false
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'Library.nsh',
|
|
124
|
+
value: 'Library',
|
|
125
|
+
checked: false
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: terminalLink('LogicLib.nsh', `${docsURL}/Includes/LogicLib`, {
|
|
129
|
+
fallback() {
|
|
130
|
+
return 'LogicLib.nsh';
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
value: 'LogicLib',
|
|
134
|
+
checked: false
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: terminalLink('Memento.nsh', `${docsURL}/Includes/Memento`, {
|
|
138
|
+
fallback() {
|
|
139
|
+
return 'Memento.nsh';
|
|
140
|
+
}
|
|
141
|
+
}),
|
|
142
|
+
value: 'Memento',
|
|
143
|
+
checked: false
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'MUI.nsh',
|
|
147
|
+
value: 'MUI',
|
|
148
|
+
checked: false
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'MUI2.nsh',
|
|
152
|
+
value: 'MUI2',
|
|
153
|
+
checked: false
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'MultiUser.nsh',
|
|
157
|
+
value: 'MultiUser',
|
|
158
|
+
checked: false
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'nsDialogs.nsh',
|
|
162
|
+
value: 'nsDialogs',
|
|
163
|
+
checked: false
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'Sections.nsh',
|
|
167
|
+
value: 'Sections',
|
|
168
|
+
checked: false
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: terminalLink('StrFunc.nsh', `${docsURL}/Includes/StrFunc`, {
|
|
172
|
+
fallback() {
|
|
173
|
+
return 'StrFunc.nsh';
|
|
174
|
+
}
|
|
175
|
+
}),
|
|
176
|
+
value: 'StrFunc',
|
|
177
|
+
checked: false
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: terminalLink('TextFunc.nsh', `${docsURL}/Includes/TextFunc`, {
|
|
181
|
+
fallback() {
|
|
182
|
+
return 'TextFunc.nsh';
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
value: 'TextFunc',
|
|
186
|
+
checked: false
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'UpgradeDLL.nsh',
|
|
190
|
+
value: 'UpgradeDLL',
|
|
191
|
+
checked: false
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'Util.nsh',
|
|
195
|
+
value: 'Util',
|
|
196
|
+
checked: false
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'VB6RunTime.nsh',
|
|
200
|
+
value: 'VB6RunTime',
|
|
201
|
+
checked: false
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'VPatchLib.nsh',
|
|
205
|
+
value: 'VPatchLib',
|
|
206
|
+
checked: false
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'WinCore.nsh',
|
|
210
|
+
value: 'WinCore',
|
|
211
|
+
checked: false
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'WinMessages.nsh',
|
|
215
|
+
value: 'WinMessages',
|
|
216
|
+
checked: false
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: terminalLink('WinVer.nsh', `${docsURL}/Includes/WinVer`, {
|
|
220
|
+
fallback() {
|
|
221
|
+
return 'WinVer.nsh';
|
|
222
|
+
}
|
|
223
|
+
}),
|
|
224
|
+
value: 'WinVer',
|
|
225
|
+
checked: false
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: terminalLink('WordFunc.nsh', `${docsURL}/Includes/WordFunc`, {
|
|
229
|
+
fallback() {
|
|
230
|
+
return 'WordFunc.nsh';
|
|
231
|
+
}
|
|
232
|
+
}),
|
|
233
|
+
value: 'WordFunc',
|
|
234
|
+
checked: false
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: terminalLink('x64.nsh', `${docsURL}/Includes/x64`, {
|
|
238
|
+
fallback() {
|
|
239
|
+
return 'x64.nsh';
|
|
240
|
+
}
|
|
241
|
+
}),
|
|
242
|
+
value: 'x64',
|
|
243
|
+
checked: false
|
|
244
|
+
}
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
export const pages = [
|
|
248
|
+
{
|
|
249
|
+
name: 'license',
|
|
250
|
+
value: 'license',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: 'components',
|
|
254
|
+
value: 'components',
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: 'directory',
|
|
258
|
+
value: 'directory',
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'instfiles',
|
|
262
|
+
value: 'instfiles',
|
|
263
|
+
checked: true
|
|
264
|
+
}
|
|
265
|
+
];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { basename, extname, resolve } from 'node:path';
|
|
2
|
+
import { includes as bundledLibraries } from './choices.js';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
import { meta as languageData } from '@nsis/language-data';
|
|
5
|
+
import { nsisDir } from 'makensis';
|
|
6
|
+
import spdxLicenseList from 'spdx-license-list/full.js';
|
|
7
|
+
import terminalLink from 'terminal-link';
|
|
8
|
+
|
|
9
|
+
const spdxCodes = Object.getOwnPropertyNames(spdxLicenseList).sort();
|
|
10
|
+
|
|
11
|
+
export const licenseChoices = spdxCodes.map(obj => {
|
|
12
|
+
const licenses = {};
|
|
13
|
+
licenses['name'] = terminalLink(obj, `https://spdx.org/licenses/${obj}.html`, {
|
|
14
|
+
fallback() {
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
licenses['value'] = obj;
|
|
19
|
+
|
|
20
|
+
return licenses;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const getAllLibraries = async () => {
|
|
24
|
+
const nsisPath = await nsisDir();
|
|
25
|
+
const includeDir = resolve(nsisPath, 'Include')
|
|
26
|
+
|
|
27
|
+
const headerFiles = await glob([`${includeDir}/*.nsh`, `!${includeDir}/MUI.nsh`], {
|
|
28
|
+
ignore: bundledLibraries.map(excludedFile => `${includeDir}/${excludedFile.value}.nsh`)
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const customHeaders = headerFiles.map(headerFile => {
|
|
32
|
+
return {
|
|
33
|
+
name: `${basename(headerFile)} [3rd party]`,
|
|
34
|
+
value: basename(headerFile, extname(headerFile)),
|
|
35
|
+
checked: false
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const allLibraries = [...bundledLibraries, ...customHeaders];
|
|
40
|
+
|
|
41
|
+
return allLibraries.sort((a, z) => a.value.localeCompare(z.value));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function getLanguageChoices(disabled) {
|
|
45
|
+
const languageChoices = Object.entries(languageData).map(([key, value]) => {
|
|
46
|
+
const isDisabled = (key === 'English') ? disabled : false;
|
|
47
|
+
|
|
48
|
+
// Use long names
|
|
49
|
+
return {
|
|
50
|
+
name: value.english || key,
|
|
51
|
+
value: key,
|
|
52
|
+
disabled: isDisabled
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Sort names
|
|
57
|
+
languageChoices.sort((a, z) => {
|
|
58
|
+
if (a.name < z.name) {
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (a.name > z.name) {
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return 0;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return languageChoices;
|
|
70
|
+
}
|
package/license.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<copyright notice>
|
|
2
|
+
|
|
3
|
+
By obtaining, using, and/or copying this software and/or its associated documentation, you agree that you have read, understood, and will comply with the following terms and conditions:
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and distribute this software and its associated documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies, and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the copyright holder not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
|
|
6
|
+
|
|
7
|
+
THE COPYRIGHT HOLDER DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-nsis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Yeoman generator for NSIS scripts",
|
|
5
5
|
"author": "Jan T. Sott",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,45 +11,54 @@
|
|
|
11
11
|
"installer",
|
|
12
12
|
"setup"
|
|
13
13
|
],
|
|
14
|
-
"
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": "./generators/app",
|
|
15
16
|
"files": [
|
|
16
|
-
"generators"
|
|
17
|
+
"generators",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
17
20
|
],
|
|
18
21
|
"scripts": {
|
|
19
22
|
"lint:ejs": "ejslint generators/**/*.ejs",
|
|
20
23
|
"lint:js": "eslint generators/**/*.js --ignore-path .gitignore",
|
|
21
24
|
"lint:json": "eslint ./*.json --ignore-path .gitignore",
|
|
22
25
|
"lint": "npm-run-all --parallel lint:*",
|
|
26
|
+
"prepare": "husky",
|
|
23
27
|
"publish": "np --no-yarn",
|
|
24
|
-
"test": "
|
|
28
|
+
"test": "uvu --ignore test/__helper.js"
|
|
25
29
|
},
|
|
26
30
|
"repository": {
|
|
27
31
|
"type": "git",
|
|
28
32
|
"url": "https://github.com/idleberg/generator-nsis"
|
|
29
33
|
},
|
|
30
34
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
35
|
+
"node": ">=18"
|
|
32
36
|
},
|
|
33
37
|
"dependencies": {
|
|
34
|
-
"@nsis/language-data": "^0.9.
|
|
35
|
-
"@sindresorhus/slugify": "^
|
|
36
|
-
"
|
|
37
|
-
"makensis": "^
|
|
38
|
-
"semver": "^7.
|
|
39
|
-
"spdx-license-list": "^6.
|
|
40
|
-
"terminal-link": "^
|
|
41
|
-
"
|
|
42
|
-
"yeoman-generator": "^5.7.0"
|
|
38
|
+
"@nsis/language-data": "^0.9.2",
|
|
39
|
+
"@sindresorhus/slugify": "^2.2.1",
|
|
40
|
+
"glob": "^10.3.10",
|
|
41
|
+
"makensis": "^2.0.8",
|
|
42
|
+
"semver": "^7.5.4",
|
|
43
|
+
"spdx-license-list": "^6.8.0",
|
|
44
|
+
"terminal-link": "^3.0.0",
|
|
45
|
+
"yeoman-generator": "^7.1.1"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
48
|
+
"@lukeed/uuid": "^2.0.1",
|
|
49
|
+
"ejs-lint": "^2.0.0",
|
|
50
|
+
"eslint": "^8.56.0",
|
|
47
51
|
"eslint-plugin-json": "^3.1.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"np": "^
|
|
52
|
-
"npm-run-
|
|
52
|
+
"husky": "^9.0.7",
|
|
53
|
+
"lint-staged": "^15.2.0",
|
|
54
|
+
"mem-fs": "^4.0.0",
|
|
55
|
+
"np": "^9.2.0",
|
|
56
|
+
"npm-run-all2": "^6.1.1",
|
|
57
|
+
"tsm": "^2.3.0",
|
|
58
|
+
"uvu": "^0.5.6",
|
|
59
|
+
"yeoman-assert": "^3.1.1",
|
|
60
|
+
"yeoman-environment": "^4.3.0",
|
|
61
|
+
"yeoman-test": "^8.2.0"
|
|
53
62
|
},
|
|
54
63
|
"lint-staged": {
|
|
55
64
|
"*.ejs": "ejslint",
|