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