create-pkgbld 1.7.1 → 1.7.2
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/dist/index.cjs +212 -10
- package/dist/index.mjs +203 -1
- package/package.json +1 -14
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,6 @@ var kleur = require('kleur');
|
|
|
11
11
|
var stringArgv = require('string-argv');
|
|
12
12
|
var childProcess = require('node:child_process');
|
|
13
13
|
var util = require('node:util');
|
|
14
|
-
var options = require('options');
|
|
15
14
|
var lodash = require('lodash');
|
|
16
15
|
|
|
17
16
|
async function getGitRoot() {
|
|
@@ -20,6 +19,209 @@ async function getGitRoot() {
|
|
|
20
19
|
return stdout.trim();
|
|
21
20
|
}
|
|
22
21
|
|
|
22
|
+
function isPackageJson(value) {
|
|
23
|
+
return (input => {
|
|
24
|
+
const $io0 = input => (undefined === input.private || "boolean" === typeof input.private) && (undefined === input.version || "string" === typeof input.version) && (undefined === input.name || "string" === typeof input.name) && (undefined === input.license || "string" === typeof input.license) && (undefined === input.readme || "string" === typeof input.readme) && (null !== input.author && (undefined === input.author || "string" === typeof input.author || "object" === typeof input.author && null !== input.author && false === Array.isArray(input.author) && $io1(input.author))) && (undefined === input.description || "string" === typeof input.description) && (undefined === input.scripts || "object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) && $io2(input.scripts)) && (undefined === input.repository || "object" === typeof input.repository && null !== input.repository && false === Array.isArray(input.repository) && $io3(input.repository)) && (undefined === input.bugs || "string" === typeof input.bugs) && (undefined === input.homepage || "string" === typeof input.homepage) && (undefined === input.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && $io4(input.dependencies)) && (undefined === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && $io4(input.devDependencies)) && (undefined === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && $io4(input.peerDependencies));
|
|
25
|
+
const $io1 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.email || "string" === typeof input.email) && (undefined === input.url || "string" === typeof input.url);
|
|
26
|
+
const $io2 = input => Object.keys(input).every(key => {
|
|
27
|
+
const value = input[key];
|
|
28
|
+
if (undefined === value)
|
|
29
|
+
return true;
|
|
30
|
+
if (RegExp(/(.*)/).test(key))
|
|
31
|
+
return "string" === typeof value;
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
const $io3 = input => (undefined === input.type || "string" === typeof input.type) && (undefined === input.url || "string" === typeof input.url);
|
|
35
|
+
const $io4 = input => Object.keys(input).every(key => {
|
|
36
|
+
const value = input[key];
|
|
37
|
+
if (undefined === value)
|
|
38
|
+
return true;
|
|
39
|
+
if (RegExp(/(.*)/).test(key))
|
|
40
|
+
return "string" === typeof value;
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
43
|
+
return "object" === typeof input && null !== input && false === Array.isArray(input) && $io0(input);
|
|
44
|
+
})(value);
|
|
45
|
+
}
|
|
46
|
+
function CommaSeparatedString(value) {
|
|
47
|
+
return value.split(',').map((arg) => arg.trim());
|
|
48
|
+
}
|
|
49
|
+
function CommaSeparatedStringOrBoolean(value) {
|
|
50
|
+
if (typeof value === 'boolean') {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
// TODO check how we get array here
|
|
54
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return CommaSeparatedString(value);
|
|
58
|
+
}
|
|
59
|
+
const cliFlagsDefaults = {
|
|
60
|
+
formats: ['es', 'cjs'],
|
|
61
|
+
umd: [],
|
|
62
|
+
compress: ['umd'],
|
|
63
|
+
sourcemaps: ['umd'],
|
|
64
|
+
preprocess: [],
|
|
65
|
+
dest: 'dist',
|
|
66
|
+
src: 'src',
|
|
67
|
+
bin: undefined,
|
|
68
|
+
includeExternals: false,
|
|
69
|
+
eject: false,
|
|
70
|
+
noTsConfig: false,
|
|
71
|
+
noUpdatePackageJson: false,
|
|
72
|
+
commonjsPattern: '[name].cjs',
|
|
73
|
+
esmPattern: '[name].mjs',
|
|
74
|
+
umdPattern: '[name].umd.js',
|
|
75
|
+
formatPackageJson: false
|
|
76
|
+
};
|
|
77
|
+
const cliFlags = {
|
|
78
|
+
umd: {
|
|
79
|
+
type: CommaSeparatedString,
|
|
80
|
+
description: 'Package subpath exports in UMD format',
|
|
81
|
+
default: cliFlagsDefaults.umd
|
|
82
|
+
},
|
|
83
|
+
compress: {
|
|
84
|
+
type: CommaSeparatedString,
|
|
85
|
+
description: 'Compress formats using terser',
|
|
86
|
+
default: cliFlagsDefaults.compress
|
|
87
|
+
},
|
|
88
|
+
sourcemaps: {
|
|
89
|
+
type: CommaSeparatedString,
|
|
90
|
+
description: 'Emit sourcemaps for the specified formats',
|
|
91
|
+
default: cliFlagsDefaults.sourcemaps
|
|
92
|
+
},
|
|
93
|
+
formats: {
|
|
94
|
+
type: CommaSeparatedString,
|
|
95
|
+
description: 'Formats to emit',
|
|
96
|
+
default: cliFlagsDefaults.formats
|
|
97
|
+
},
|
|
98
|
+
preprocess: {
|
|
99
|
+
type: CommaSeparatedString,
|
|
100
|
+
description: 'Preprocess entry points / subpath exports',
|
|
101
|
+
default: cliFlagsDefaults.preprocess
|
|
102
|
+
},
|
|
103
|
+
dest: {
|
|
104
|
+
type: String,
|
|
105
|
+
description: 'Output directory',
|
|
106
|
+
default: cliFlagsDefaults.dest
|
|
107
|
+
},
|
|
108
|
+
src: {
|
|
109
|
+
type: String,
|
|
110
|
+
description: 'Source directory',
|
|
111
|
+
default: cliFlagsDefaults.src
|
|
112
|
+
},
|
|
113
|
+
bin: {
|
|
114
|
+
type: CommaSeparatedString,
|
|
115
|
+
description: 'Executable files',
|
|
116
|
+
default: cliFlagsDefaults.bin
|
|
117
|
+
},
|
|
118
|
+
includeExternals: {
|
|
119
|
+
type: CommaSeparatedStringOrBoolean,
|
|
120
|
+
description: 'Include all/specified externals into result bundle(s)',
|
|
121
|
+
default: cliFlagsDefaults.includeExternals
|
|
122
|
+
},
|
|
123
|
+
eject: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
description: 'Eject config',
|
|
126
|
+
default: cliFlagsDefaults.eject
|
|
127
|
+
},
|
|
128
|
+
noTsConfig: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
description: 'Do not create / update tsconfig.json',
|
|
131
|
+
default: cliFlagsDefaults.noTsConfig
|
|
132
|
+
},
|
|
133
|
+
noUpdatePackageJson: {
|
|
134
|
+
type: Boolean,
|
|
135
|
+
description: 'Do not create / update package.json',
|
|
136
|
+
default: cliFlagsDefaults.noUpdatePackageJson
|
|
137
|
+
},
|
|
138
|
+
commonjsPattern: {
|
|
139
|
+
type: String,
|
|
140
|
+
description: 'CommonJS output file name pattern',
|
|
141
|
+
default: cliFlagsDefaults.commonjsPattern
|
|
142
|
+
},
|
|
143
|
+
esmPattern: {
|
|
144
|
+
type: String,
|
|
145
|
+
description: 'ES output file name pattern',
|
|
146
|
+
default: cliFlagsDefaults.esmPattern
|
|
147
|
+
},
|
|
148
|
+
umdPattern: {
|
|
149
|
+
type: String,
|
|
150
|
+
description: 'UMD output file name pattern',
|
|
151
|
+
default: cliFlagsDefaults.umdPattern
|
|
152
|
+
},
|
|
153
|
+
formatPackageJson: {
|
|
154
|
+
type: Boolean,
|
|
155
|
+
description: 'Format package.json',
|
|
156
|
+
default: cliFlagsDefaults.formatPackageJson
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const packageJsonFieldsOrder = new Set([
|
|
160
|
+
'private',
|
|
161
|
+
'type',
|
|
162
|
+
'version',
|
|
163
|
+
'name',
|
|
164
|
+
'scope',
|
|
165
|
+
'description',
|
|
166
|
+
'license',
|
|
167
|
+
'author',
|
|
168
|
+
'contributors',
|
|
169
|
+
'funding',
|
|
170
|
+
'bin',
|
|
171
|
+
'main',
|
|
172
|
+
'browser',
|
|
173
|
+
'unpkg',
|
|
174
|
+
'module',
|
|
175
|
+
'svelte',
|
|
176
|
+
'exports',
|
|
177
|
+
'imports',
|
|
178
|
+
'types',
|
|
179
|
+
'typings',
|
|
180
|
+
'typesVersions',
|
|
181
|
+
'files',
|
|
182
|
+
'packageManager',
|
|
183
|
+
'sideEffects',
|
|
184
|
+
'engines',
|
|
185
|
+
'os',
|
|
186
|
+
'cpu',
|
|
187
|
+
'man',
|
|
188
|
+
'directories',
|
|
189
|
+
'repository',
|
|
190
|
+
'bugs',
|
|
191
|
+
'homepage',
|
|
192
|
+
'readme',
|
|
193
|
+
'keywords',
|
|
194
|
+
'scripts',
|
|
195
|
+
'config',
|
|
196
|
+
'dependencies',
|
|
197
|
+
'devDependencies',
|
|
198
|
+
'peerDependencies',
|
|
199
|
+
'peerDependenciesMeta',
|
|
200
|
+
'bundleDependencies',
|
|
201
|
+
'bundledDependencies',
|
|
202
|
+
'optionalDependencies',
|
|
203
|
+
'overrides',
|
|
204
|
+
'publishConfig',
|
|
205
|
+
'workspaces'
|
|
206
|
+
]);
|
|
207
|
+
function processPackageJson(pkg, needTreatment, treatKey) {
|
|
208
|
+
const newPkg = {};
|
|
209
|
+
for (const key of packageJsonFieldsOrder) {
|
|
210
|
+
if (needTreatment(key)) {
|
|
211
|
+
newPkg[key] = treatKey(key);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
for (const key in pkg) {
|
|
215
|
+
if (!packageJsonFieldsOrder.has(key)) {
|
|
216
|
+
newPkg[key] = pkg[key];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return newPkg;
|
|
220
|
+
}
|
|
221
|
+
function toFormattedJson(json) {
|
|
222
|
+
return JSON.stringify(json, null, 2) + '\n';
|
|
223
|
+
}
|
|
224
|
+
|
|
23
225
|
const done = Symbol('done');
|
|
24
226
|
const formats = ['amd', 'cjs', 'es', 'iife', 'system', 'umd'];
|
|
25
227
|
const pkgbldBinaries = ['pkgbld', 'pkgbld-internal', 'node ../pkgbld/dist/index.js'];
|
|
@@ -103,14 +305,14 @@ async function execute() {
|
|
|
103
305
|
}
|
|
104
306
|
}
|
|
105
307
|
execute();
|
|
106
|
-
function updatePackage(pkg, options
|
|
107
|
-
pkg.pkg =
|
|
308
|
+
function updatePackage(pkg, options) {
|
|
309
|
+
pkg.pkg = processPackageJson(pkg.pkg, (key) => (key in options || key in pkg.pkg), treatKey);
|
|
108
310
|
function treatKey(key) {
|
|
109
311
|
if (key === 'scripts') {
|
|
110
312
|
({ ...pkg.pkg.scripts });
|
|
111
|
-
getScriptValue(options
|
|
313
|
+
getScriptValue(options.pkgbld);
|
|
112
314
|
}
|
|
113
|
-
return options
|
|
315
|
+
return options[key] ?? pkg.pkg[key];
|
|
114
316
|
}
|
|
115
317
|
}
|
|
116
318
|
function getScriptValue(pkgbld) {
|
|
@@ -119,7 +321,7 @@ function getScriptValue(pkgbld) {
|
|
|
119
321
|
const pkgBldCopy = { ...pkgbld };
|
|
120
322
|
delete pkgBldCopy['pkgbldBinary'];
|
|
121
323
|
delete pkgBldCopy['extraParameters'];
|
|
122
|
-
return `${binary} ${asCommandLineArgs(pkgBldCopy,
|
|
324
|
+
return `${binary} ${asCommandLineArgs(pkgBldCopy, cliFlagsDefaults)} ${extraArgs}`.trimEnd();
|
|
123
325
|
}
|
|
124
326
|
function getPromptOption(option, mutateObject) {
|
|
125
327
|
const value = mutateObject[option.field];
|
|
@@ -244,7 +446,7 @@ async function getGitOptions(targetDir, packageJson) {
|
|
|
244
446
|
return [];
|
|
245
447
|
}
|
|
246
448
|
function getPkgbldOptions(pkg) {
|
|
247
|
-
let args =
|
|
449
|
+
let args = cliFlagsDefaults;
|
|
248
450
|
const cmd = pkg.scripts?.build ?? '';
|
|
249
451
|
let binary = 'pkgbld';
|
|
250
452
|
if (cmd) {
|
|
@@ -265,7 +467,7 @@ function getPkgbldOptions(pkg) {
|
|
|
265
467
|
}
|
|
266
468
|
const parsedArgs = cleye.cli({
|
|
267
469
|
help: false,
|
|
268
|
-
flags:
|
|
470
|
+
flags: cliFlags
|
|
269
471
|
}, undefined, stringArgv.parseArgsStringToArgv(cmd));
|
|
270
472
|
args = parsedArgs.flags;
|
|
271
473
|
args.extraParameters = asCommandLineArgs(parsedArgs.unknownFlags);
|
|
@@ -431,7 +633,7 @@ async function readPackage(dir) {
|
|
|
431
633
|
const pkgFile = await fs.readFile(packageFileName);
|
|
432
634
|
const readmeFile = await fs.readFile(readmeFileName);
|
|
433
635
|
const pkg = JSON.parse(pkgFile.toString());
|
|
434
|
-
const isValidPackageJson =
|
|
636
|
+
const isValidPackageJson = isPackageJson(pkg);
|
|
435
637
|
if (!isValidPackageJson) {
|
|
436
638
|
console.error('Invalid package.json');
|
|
437
639
|
throw new Error('Invalid package.json');
|
|
@@ -454,7 +656,7 @@ async function writePackage(dir, pkg) {
|
|
|
454
656
|
const readmeFileName = path.resolve(dir, 'README.md');
|
|
455
657
|
try {
|
|
456
658
|
await fs.mkdir(dir, { recursive: true });
|
|
457
|
-
await fs.writeFile(packageFileName,
|
|
659
|
+
await fs.writeFile(packageFileName, toFormattedJson(pkg.pkg));
|
|
458
660
|
await fs.writeFile(readmeFileName, pkg.readme);
|
|
459
661
|
}
|
|
460
662
|
catch (e) {
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,6 @@ import kleur from 'kleur';
|
|
|
8
8
|
import { parseArgsStringToArgv } from 'string-argv';
|
|
9
9
|
import childProcess from 'node:child_process';
|
|
10
10
|
import util from 'node:util';
|
|
11
|
-
import { processPackageJson, cliFlags, isPackageJson, toFormattedJson, cliFlagsDefaults } from 'options';
|
|
12
11
|
import { isEqual } from 'lodash';
|
|
13
12
|
|
|
14
13
|
async function getGitRoot() {
|
|
@@ -17,6 +16,209 @@ async function getGitRoot() {
|
|
|
17
16
|
return stdout.trim();
|
|
18
17
|
}
|
|
19
18
|
|
|
19
|
+
function isPackageJson(value) {
|
|
20
|
+
return (input => {
|
|
21
|
+
const $io0 = input => (undefined === input.private || "boolean" === typeof input.private) && (undefined === input.version || "string" === typeof input.version) && (undefined === input.name || "string" === typeof input.name) && (undefined === input.license || "string" === typeof input.license) && (undefined === input.readme || "string" === typeof input.readme) && (null !== input.author && (undefined === input.author || "string" === typeof input.author || "object" === typeof input.author && null !== input.author && false === Array.isArray(input.author) && $io1(input.author))) && (undefined === input.description || "string" === typeof input.description) && (undefined === input.scripts || "object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) && $io2(input.scripts)) && (undefined === input.repository || "object" === typeof input.repository && null !== input.repository && false === Array.isArray(input.repository) && $io3(input.repository)) && (undefined === input.bugs || "string" === typeof input.bugs) && (undefined === input.homepage || "string" === typeof input.homepage) && (undefined === input.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && $io4(input.dependencies)) && (undefined === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && $io4(input.devDependencies)) && (undefined === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && $io4(input.peerDependencies));
|
|
22
|
+
const $io1 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.email || "string" === typeof input.email) && (undefined === input.url || "string" === typeof input.url);
|
|
23
|
+
const $io2 = input => Object.keys(input).every(key => {
|
|
24
|
+
const value = input[key];
|
|
25
|
+
if (undefined === value)
|
|
26
|
+
return true;
|
|
27
|
+
if (RegExp(/(.*)/).test(key))
|
|
28
|
+
return "string" === typeof value;
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
const $io3 = input => (undefined === input.type || "string" === typeof input.type) && (undefined === input.url || "string" === typeof input.url);
|
|
32
|
+
const $io4 = input => Object.keys(input).every(key => {
|
|
33
|
+
const value = input[key];
|
|
34
|
+
if (undefined === value)
|
|
35
|
+
return true;
|
|
36
|
+
if (RegExp(/(.*)/).test(key))
|
|
37
|
+
return "string" === typeof value;
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
|
+
return "object" === typeof input && null !== input && false === Array.isArray(input) && $io0(input);
|
|
41
|
+
})(value);
|
|
42
|
+
}
|
|
43
|
+
function CommaSeparatedString(value) {
|
|
44
|
+
return value.split(',').map((arg) => arg.trim());
|
|
45
|
+
}
|
|
46
|
+
function CommaSeparatedStringOrBoolean(value) {
|
|
47
|
+
if (typeof value === 'boolean') {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
// TODO check how we get array here
|
|
51
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return CommaSeparatedString(value);
|
|
55
|
+
}
|
|
56
|
+
const cliFlagsDefaults = {
|
|
57
|
+
formats: ['es', 'cjs'],
|
|
58
|
+
umd: [],
|
|
59
|
+
compress: ['umd'],
|
|
60
|
+
sourcemaps: ['umd'],
|
|
61
|
+
preprocess: [],
|
|
62
|
+
dest: 'dist',
|
|
63
|
+
src: 'src',
|
|
64
|
+
bin: undefined,
|
|
65
|
+
includeExternals: false,
|
|
66
|
+
eject: false,
|
|
67
|
+
noTsConfig: false,
|
|
68
|
+
noUpdatePackageJson: false,
|
|
69
|
+
commonjsPattern: '[name].cjs',
|
|
70
|
+
esmPattern: '[name].mjs',
|
|
71
|
+
umdPattern: '[name].umd.js',
|
|
72
|
+
formatPackageJson: false
|
|
73
|
+
};
|
|
74
|
+
const cliFlags = {
|
|
75
|
+
umd: {
|
|
76
|
+
type: CommaSeparatedString,
|
|
77
|
+
description: 'Package subpath exports in UMD format',
|
|
78
|
+
default: cliFlagsDefaults.umd
|
|
79
|
+
},
|
|
80
|
+
compress: {
|
|
81
|
+
type: CommaSeparatedString,
|
|
82
|
+
description: 'Compress formats using terser',
|
|
83
|
+
default: cliFlagsDefaults.compress
|
|
84
|
+
},
|
|
85
|
+
sourcemaps: {
|
|
86
|
+
type: CommaSeparatedString,
|
|
87
|
+
description: 'Emit sourcemaps for the specified formats',
|
|
88
|
+
default: cliFlagsDefaults.sourcemaps
|
|
89
|
+
},
|
|
90
|
+
formats: {
|
|
91
|
+
type: CommaSeparatedString,
|
|
92
|
+
description: 'Formats to emit',
|
|
93
|
+
default: cliFlagsDefaults.formats
|
|
94
|
+
},
|
|
95
|
+
preprocess: {
|
|
96
|
+
type: CommaSeparatedString,
|
|
97
|
+
description: 'Preprocess entry points / subpath exports',
|
|
98
|
+
default: cliFlagsDefaults.preprocess
|
|
99
|
+
},
|
|
100
|
+
dest: {
|
|
101
|
+
type: String,
|
|
102
|
+
description: 'Output directory',
|
|
103
|
+
default: cliFlagsDefaults.dest
|
|
104
|
+
},
|
|
105
|
+
src: {
|
|
106
|
+
type: String,
|
|
107
|
+
description: 'Source directory',
|
|
108
|
+
default: cliFlagsDefaults.src
|
|
109
|
+
},
|
|
110
|
+
bin: {
|
|
111
|
+
type: CommaSeparatedString,
|
|
112
|
+
description: 'Executable files',
|
|
113
|
+
default: cliFlagsDefaults.bin
|
|
114
|
+
},
|
|
115
|
+
includeExternals: {
|
|
116
|
+
type: CommaSeparatedStringOrBoolean,
|
|
117
|
+
description: 'Include all/specified externals into result bundle(s)',
|
|
118
|
+
default: cliFlagsDefaults.includeExternals
|
|
119
|
+
},
|
|
120
|
+
eject: {
|
|
121
|
+
type: Boolean,
|
|
122
|
+
description: 'Eject config',
|
|
123
|
+
default: cliFlagsDefaults.eject
|
|
124
|
+
},
|
|
125
|
+
noTsConfig: {
|
|
126
|
+
type: Boolean,
|
|
127
|
+
description: 'Do not create / update tsconfig.json',
|
|
128
|
+
default: cliFlagsDefaults.noTsConfig
|
|
129
|
+
},
|
|
130
|
+
noUpdatePackageJson: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
description: 'Do not create / update package.json',
|
|
133
|
+
default: cliFlagsDefaults.noUpdatePackageJson
|
|
134
|
+
},
|
|
135
|
+
commonjsPattern: {
|
|
136
|
+
type: String,
|
|
137
|
+
description: 'CommonJS output file name pattern',
|
|
138
|
+
default: cliFlagsDefaults.commonjsPattern
|
|
139
|
+
},
|
|
140
|
+
esmPattern: {
|
|
141
|
+
type: String,
|
|
142
|
+
description: 'ES output file name pattern',
|
|
143
|
+
default: cliFlagsDefaults.esmPattern
|
|
144
|
+
},
|
|
145
|
+
umdPattern: {
|
|
146
|
+
type: String,
|
|
147
|
+
description: 'UMD output file name pattern',
|
|
148
|
+
default: cliFlagsDefaults.umdPattern
|
|
149
|
+
},
|
|
150
|
+
formatPackageJson: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
description: 'Format package.json',
|
|
153
|
+
default: cliFlagsDefaults.formatPackageJson
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const packageJsonFieldsOrder = new Set([
|
|
157
|
+
'private',
|
|
158
|
+
'type',
|
|
159
|
+
'version',
|
|
160
|
+
'name',
|
|
161
|
+
'scope',
|
|
162
|
+
'description',
|
|
163
|
+
'license',
|
|
164
|
+
'author',
|
|
165
|
+
'contributors',
|
|
166
|
+
'funding',
|
|
167
|
+
'bin',
|
|
168
|
+
'main',
|
|
169
|
+
'browser',
|
|
170
|
+
'unpkg',
|
|
171
|
+
'module',
|
|
172
|
+
'svelte',
|
|
173
|
+
'exports',
|
|
174
|
+
'imports',
|
|
175
|
+
'types',
|
|
176
|
+
'typings',
|
|
177
|
+
'typesVersions',
|
|
178
|
+
'files',
|
|
179
|
+
'packageManager',
|
|
180
|
+
'sideEffects',
|
|
181
|
+
'engines',
|
|
182
|
+
'os',
|
|
183
|
+
'cpu',
|
|
184
|
+
'man',
|
|
185
|
+
'directories',
|
|
186
|
+
'repository',
|
|
187
|
+
'bugs',
|
|
188
|
+
'homepage',
|
|
189
|
+
'readme',
|
|
190
|
+
'keywords',
|
|
191
|
+
'scripts',
|
|
192
|
+
'config',
|
|
193
|
+
'dependencies',
|
|
194
|
+
'devDependencies',
|
|
195
|
+
'peerDependencies',
|
|
196
|
+
'peerDependenciesMeta',
|
|
197
|
+
'bundleDependencies',
|
|
198
|
+
'bundledDependencies',
|
|
199
|
+
'optionalDependencies',
|
|
200
|
+
'overrides',
|
|
201
|
+
'publishConfig',
|
|
202
|
+
'workspaces'
|
|
203
|
+
]);
|
|
204
|
+
function processPackageJson(pkg, needTreatment, treatKey) {
|
|
205
|
+
const newPkg = {};
|
|
206
|
+
for (const key of packageJsonFieldsOrder) {
|
|
207
|
+
if (needTreatment(key)) {
|
|
208
|
+
newPkg[key] = treatKey(key);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const key in pkg) {
|
|
212
|
+
if (!packageJsonFieldsOrder.has(key)) {
|
|
213
|
+
newPkg[key] = pkg[key];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return newPkg;
|
|
217
|
+
}
|
|
218
|
+
function toFormattedJson(json) {
|
|
219
|
+
return JSON.stringify(json, null, 2) + '\n';
|
|
220
|
+
}
|
|
221
|
+
|
|
20
222
|
const done = Symbol('done');
|
|
21
223
|
const formats = ['amd', 'cjs', 'es', 'iife', 'system', 'umd'];
|
|
22
224
|
const pkgbldBinaries = ['pkgbld', 'pkgbld-internal', 'node ../pkgbld/dist/index.js'];
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.
|
|
2
|
+
"version": "1.7.2",
|
|
3
3
|
"name": "create-pkgbld",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Konstantin Shutkin",
|
|
@@ -43,18 +43,5 @@
|
|
|
43
43
|
"prompts": "2.4.2",
|
|
44
44
|
"kleur": "4.1.5",
|
|
45
45
|
"lodash": "4.17.21"
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@types/git-user-name": "2.0.1",
|
|
49
|
-
"@types/parse-git-config": "3.0.2",
|
|
50
|
-
"@types/prompts": "2.4.6",
|
|
51
|
-
"@types/lodash": "4.14.199",
|
|
52
|
-
"@total-typescript/ts-reset": "0.5.1",
|
|
53
|
-
"pkgbld": "1.24.0",
|
|
54
|
-
"options": "0.2.0"
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "node ../pkgbld/dist/index.js --include-externals=options",
|
|
58
|
-
"lint": "eslint ./src"
|
|
59
46
|
}
|
|
60
47
|
}
|