create-pkgbld 1.4.1 → 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 CHANGED
@@ -31,9 +31,9 @@ async function execute() {
31
31
  '[package name]'
32
32
  ],
33
33
  flags: {
34
- quite: {
34
+ quiet: {
35
35
  type: Boolean,
36
- description: 'Quite mode',
36
+ description: 'Quiet mode',
37
37
  default: false
38
38
  }
39
39
  }
@@ -49,7 +49,7 @@ async function execute() {
49
49
  options.push(...await getGitOptions(targetDir));
50
50
  options.push(...getPkgbldOptions(pkg.pkg));
51
51
  const state = getOptionsValue(options);
52
- if (!args.flags.quite) {
52
+ if (!args.flags.quiet) {
53
53
  for (;;) {
54
54
  const topLevelAction = await prompts({
55
55
  type: 'select',
@@ -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) && $io1(input.scripts)) && (undefined === input.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && $io2(input.dependencies)) && (undefined === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && $io2(input.devDependencies)) && (undefined === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && $io2(input.peerDependencies)) && Object.keys(input).every(key => {
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.build || "string" === typeof input.build) && (undefined === input.lint || "string" === typeof input.lint);
511
- const $io2 = input => Object.keys(input).every(key => {
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: isValidPackageJson ? pkg : defaultPkg,
536
+ pkg,
526
537
  readme: readmeFile.toString(),
527
538
  mode: 'update'
528
539
  };
package/dist/index.mjs CHANGED
@@ -28,9 +28,9 @@ async function execute() {
28
28
  '[package name]'
29
29
  ],
30
30
  flags: {
31
- quite: {
31
+ quiet: {
32
32
  type: Boolean,
33
- description: 'Quite mode',
33
+ description: 'Quiet mode',
34
34
  default: false
35
35
  }
36
36
  }
@@ -46,7 +46,7 @@ async function execute() {
46
46
  options.push(...await getGitOptions(targetDir));
47
47
  options.push(...getPkgbldOptions(pkg.pkg));
48
48
  const state = getOptionsValue(options);
49
- if (!args.flags.quite) {
49
+ if (!args.flags.quiet) {
50
50
  for (;;) {
51
51
  const topLevelAction = await prompts({
52
52
  type: 'select',
@@ -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) && $io1(input.scripts)) && (undefined === input.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && $io2(input.dependencies)) && (undefined === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && $io2(input.devDependencies)) && (undefined === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && $io2(input.peerDependencies)) && Object.keys(input).every(key => {
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.build || "string" === typeof input.build) && (undefined === input.lint || "string" === typeof input.lint);
508
- const $io2 = input => Object.keys(input).every(key => {
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: isValidPackageJson ? pkg : defaultPkg,
533
+ pkg,
523
534
  readme: readmeFile.toString(),
524
535
  mode: 'update'
525
536
  };
package/dist/types.d.ts CHANGED
@@ -23,7 +23,11 @@ export type PackageJson = {
23
23
  version?: string;
24
24
  name?: string;
25
25
  license?: string;
26
- author?: string;
26
+ author?: string | {
27
+ name?: string;
28
+ email?: string;
29
+ url?: string;
30
+ };
27
31
  description?: string;
28
32
  scripts?: {
29
33
  build?: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.1",
2
+ "version": "1.4.3",
3
3
  "name": "create-pkgbld",
4
4
  "license": "MIT",
5
5
  "author": "Konstantin Shutkin",