create-pkgbld 1.4.2 → 1.4.3
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 +16 -5
- package/dist/index.mjs +16 -5
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -473,7 +473,7 @@ function getBasicOptions(packageName, pkg) {
|
|
|
473
473
|
}, {
|
|
474
474
|
title: 'Author',
|
|
475
475
|
field: 'author',
|
|
476
|
-
initialValue: chooseValue(pkg.pkg.author, userName() ?? '')
|
|
476
|
+
initialValue: chooseValue(toAuthorString(pkg.pkg.author), userName() ?? '')
|
|
477
477
|
}, {
|
|
478
478
|
title: 'Readme',
|
|
479
479
|
field: 'readme',
|
|
@@ -484,6 +484,15 @@ function getBasicOptions(packageName, pkg) {
|
|
|
484
484
|
function chooseValue(pkgValue, defaultValue) {
|
|
485
485
|
return pkg.mode === 'update' ? pkgValue : defaultValue;
|
|
486
486
|
}
|
|
487
|
+
function toAuthorString(author) {
|
|
488
|
+
if (typeof author === 'string' || !author) {
|
|
489
|
+
return author;
|
|
490
|
+
}
|
|
491
|
+
const name = author.name ?? '';
|
|
492
|
+
const email = author.email ?? '';
|
|
493
|
+
const url = author.url ?? '';
|
|
494
|
+
return `${name}${email ? ` <${email}>` : ''}${url ? ` (${url})` : ''}`;
|
|
495
|
+
}
|
|
487
496
|
}
|
|
488
497
|
function pad16plus(value, indent = 4, offset = 3) {
|
|
489
498
|
return value + ''.padEnd(offset - Math.floor((value.length + indent) / 8), '\t');
|
|
@@ -497,7 +506,7 @@ async function readPackage(dir) {
|
|
|
497
506
|
const readmeFile = await fs.readFile(readmeFileName);
|
|
498
507
|
const pkg = JSON.parse(pkgFile.toString());
|
|
499
508
|
const isValidPackageJson = (input => {
|
|
500
|
-
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.author || "string" === typeof input.author) && (undefined === input.description || "string" === typeof input.description) && (undefined === input.scripts || "object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) && $
|
|
509
|
+
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) && (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.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && $io3(input.dependencies)) && (undefined === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && $io3(input.devDependencies)) && (undefined === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && $io3(input.peerDependencies)) && Object.keys(input).every(key => {
|
|
501
510
|
if (["private", "version", "name", "license", "author", "description", "scripts", "dependencies", "devDependencies", "peerDependencies"].some(prop => key === prop))
|
|
502
511
|
return true;
|
|
503
512
|
const value = input[key];
|
|
@@ -507,8 +516,9 @@ async function readPackage(dir) {
|
|
|
507
516
|
return true;
|
|
508
517
|
return true;
|
|
509
518
|
});
|
|
510
|
-
const $io1 = input => (undefined === input.
|
|
511
|
-
const $io2 = input =>
|
|
519
|
+
const $io1 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.email || "string" === typeof input.email) && (undefined === input.url || "string" === typeof input.url);
|
|
520
|
+
const $io2 = input => (undefined === input.build || "string" === typeof input.build) && (undefined === input.lint || "string" === typeof input.lint);
|
|
521
|
+
const $io3 = input => Object.keys(input).every(key => {
|
|
512
522
|
const value = input[key];
|
|
513
523
|
if (undefined === value)
|
|
514
524
|
return true;
|
|
@@ -520,9 +530,10 @@ async function readPackage(dir) {
|
|
|
520
530
|
})(pkg);
|
|
521
531
|
if (!isValidPackageJson) {
|
|
522
532
|
console.error('Invalid package.json');
|
|
533
|
+
throw new Error('Invalid package.json');
|
|
523
534
|
}
|
|
524
535
|
return {
|
|
525
|
-
pkg
|
|
536
|
+
pkg,
|
|
526
537
|
readme: readmeFile.toString(),
|
|
527
538
|
mode: 'update'
|
|
528
539
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -470,7 +470,7 @@ function getBasicOptions(packageName, pkg) {
|
|
|
470
470
|
}, {
|
|
471
471
|
title: 'Author',
|
|
472
472
|
field: 'author',
|
|
473
|
-
initialValue: chooseValue(pkg.pkg.author, userName() ?? '')
|
|
473
|
+
initialValue: chooseValue(toAuthorString(pkg.pkg.author), userName() ?? '')
|
|
474
474
|
}, {
|
|
475
475
|
title: 'Readme',
|
|
476
476
|
field: 'readme',
|
|
@@ -481,6 +481,15 @@ function getBasicOptions(packageName, pkg) {
|
|
|
481
481
|
function chooseValue(pkgValue, defaultValue) {
|
|
482
482
|
return pkg.mode === 'update' ? pkgValue : defaultValue;
|
|
483
483
|
}
|
|
484
|
+
function toAuthorString(author) {
|
|
485
|
+
if (typeof author === 'string' || !author) {
|
|
486
|
+
return author;
|
|
487
|
+
}
|
|
488
|
+
const name = author.name ?? '';
|
|
489
|
+
const email = author.email ?? '';
|
|
490
|
+
const url = author.url ?? '';
|
|
491
|
+
return `${name}${email ? ` <${email}>` : ''}${url ? ` (${url})` : ''}`;
|
|
492
|
+
}
|
|
484
493
|
}
|
|
485
494
|
function pad16plus(value, indent = 4, offset = 3) {
|
|
486
495
|
return value + ''.padEnd(offset - Math.floor((value.length + indent) / 8), '\t');
|
|
@@ -494,7 +503,7 @@ async function readPackage(dir) {
|
|
|
494
503
|
const readmeFile = await fs.readFile(readmeFileName);
|
|
495
504
|
const pkg = JSON.parse(pkgFile.toString());
|
|
496
505
|
const isValidPackageJson = (input => {
|
|
497
|
-
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.author || "string" === typeof input.author) && (undefined === input.description || "string" === typeof input.description) && (undefined === input.scripts || "object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) && $
|
|
506
|
+
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) && (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.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && $io3(input.dependencies)) && (undefined === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && $io3(input.devDependencies)) && (undefined === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && $io3(input.peerDependencies)) && Object.keys(input).every(key => {
|
|
498
507
|
if (["private", "version", "name", "license", "author", "description", "scripts", "dependencies", "devDependencies", "peerDependencies"].some(prop => key === prop))
|
|
499
508
|
return true;
|
|
500
509
|
const value = input[key];
|
|
@@ -504,8 +513,9 @@ async function readPackage(dir) {
|
|
|
504
513
|
return true;
|
|
505
514
|
return true;
|
|
506
515
|
});
|
|
507
|
-
const $io1 = input => (undefined === input.
|
|
508
|
-
const $io2 = input =>
|
|
516
|
+
const $io1 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.email || "string" === typeof input.email) && (undefined === input.url || "string" === typeof input.url);
|
|
517
|
+
const $io2 = input => (undefined === input.build || "string" === typeof input.build) && (undefined === input.lint || "string" === typeof input.lint);
|
|
518
|
+
const $io3 = input => Object.keys(input).every(key => {
|
|
509
519
|
const value = input[key];
|
|
510
520
|
if (undefined === value)
|
|
511
521
|
return true;
|
|
@@ -517,9 +527,10 @@ async function readPackage(dir) {
|
|
|
517
527
|
})(pkg);
|
|
518
528
|
if (!isValidPackageJson) {
|
|
519
529
|
console.error('Invalid package.json');
|
|
530
|
+
throw new Error('Invalid package.json');
|
|
520
531
|
}
|
|
521
532
|
return {
|
|
522
|
-
pkg
|
|
533
|
+
pkg,
|
|
523
534
|
readme: readmeFile.toString(),
|
|
524
535
|
mode: 'update'
|
|
525
536
|
};
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED