create-pkgbld 1.4.2 → 1.4.4

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
@@ -111,25 +111,41 @@ function updatePackage(pkg, options) {
111
111
  'description',
112
112
  'license',
113
113
  'author',
114
+ 'contributors',
115
+ 'funding',
114
116
  'bin',
115
117
  'main',
118
+ 'browser',
116
119
  'module',
117
120
  'exports',
121
+ 'imports',
118
122
  'types',
119
123
  'typings',
120
124
  'files',
125
+ 'packageManager',
126
+ 'sideEffects',
121
127
  'engines',
128
+ 'os',
129
+ 'cpu',
130
+ 'man',
131
+ 'directories',
122
132
  'repository',
123
133
  'bugs',
124
134
  'homepage',
125
135
  'readme',
126
136
  'keywords',
127
137
  'scripts',
138
+ 'config',
128
139
  'dependencies',
129
140
  'devDependencies',
130
141
  'peerDependencies',
142
+ 'peerDependenciesMeta',
143
+ 'bundleDependencies',
144
+ 'bundledDependencies',
131
145
  'optionalDependencies',
132
- 'publishConfig'
146
+ 'overrides',
147
+ 'publishConfig',
148
+ 'workspaces'
133
149
  ]);
134
150
  const newPkg = {};
135
151
  for (const key of order) {
@@ -473,7 +489,7 @@ function getBasicOptions(packageName, pkg) {
473
489
  }, {
474
490
  title: 'Author',
475
491
  field: 'author',
476
- initialValue: chooseValue(pkg.pkg.author, userName() ?? '')
492
+ initialValue: chooseValue(toAuthorString(pkg.pkg.author), userName() ?? '')
477
493
  }, {
478
494
  title: 'Readme',
479
495
  field: 'readme',
@@ -484,6 +500,15 @@ function getBasicOptions(packageName, pkg) {
484
500
  function chooseValue(pkgValue, defaultValue) {
485
501
  return pkg.mode === 'update' ? pkgValue : defaultValue;
486
502
  }
503
+ function toAuthorString(author) {
504
+ if (typeof author === 'string' || !author) {
505
+ return author;
506
+ }
507
+ const name = author.name ?? '';
508
+ const email = author.email ?? '';
509
+ const url = author.url ?? '';
510
+ return `${name}${email ? ` <${email}>` : ''}${url ? ` (${url})` : ''}`;
511
+ }
487
512
  }
488
513
  function pad16plus(value, indent = 4, offset = 3) {
489
514
  return value + ''.padEnd(offset - Math.floor((value.length + indent) / 8), '\t');
@@ -497,7 +522,7 @@ async function readPackage(dir) {
497
522
  const readmeFile = await fs.readFile(readmeFileName);
498
523
  const pkg = JSON.parse(pkgFile.toString());
499
524
  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 => {
525
+ 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
526
  if (["private", "version", "name", "license", "author", "description", "scripts", "dependencies", "devDependencies", "peerDependencies"].some(prop => key === prop))
502
527
  return true;
503
528
  const value = input[key];
@@ -507,8 +532,9 @@ async function readPackage(dir) {
507
532
  return true;
508
533
  return true;
509
534
  });
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 => {
535
+ const $io1 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.email || "string" === typeof input.email) && (undefined === input.url || "string" === typeof input.url);
536
+ const $io2 = input => (undefined === input.build || "string" === typeof input.build) && (undefined === input.lint || "string" === typeof input.lint);
537
+ const $io3 = input => Object.keys(input).every(key => {
512
538
  const value = input[key];
513
539
  if (undefined === value)
514
540
  return true;
@@ -520,9 +546,10 @@ async function readPackage(dir) {
520
546
  })(pkg);
521
547
  if (!isValidPackageJson) {
522
548
  console.error('Invalid package.json');
549
+ throw new Error('Invalid package.json');
523
550
  }
524
551
  return {
525
- pkg: isValidPackageJson ? pkg : defaultPkg,
552
+ pkg,
526
553
  readme: readmeFile.toString(),
527
554
  mode: 'update'
528
555
  };
package/dist/index.mjs CHANGED
@@ -108,25 +108,41 @@ function updatePackage(pkg, options) {
108
108
  'description',
109
109
  'license',
110
110
  'author',
111
+ 'contributors',
112
+ 'funding',
111
113
  'bin',
112
114
  'main',
115
+ 'browser',
113
116
  'module',
114
117
  'exports',
118
+ 'imports',
115
119
  'types',
116
120
  'typings',
117
121
  'files',
122
+ 'packageManager',
123
+ 'sideEffects',
118
124
  'engines',
125
+ 'os',
126
+ 'cpu',
127
+ 'man',
128
+ 'directories',
119
129
  'repository',
120
130
  'bugs',
121
131
  'homepage',
122
132
  'readme',
123
133
  'keywords',
124
134
  'scripts',
135
+ 'config',
125
136
  'dependencies',
126
137
  'devDependencies',
127
138
  'peerDependencies',
139
+ 'peerDependenciesMeta',
140
+ 'bundleDependencies',
141
+ 'bundledDependencies',
128
142
  'optionalDependencies',
129
- 'publishConfig'
143
+ 'overrides',
144
+ 'publishConfig',
145
+ 'workspaces'
130
146
  ]);
131
147
  const newPkg = {};
132
148
  for (const key of order) {
@@ -470,7 +486,7 @@ function getBasicOptions(packageName, pkg) {
470
486
  }, {
471
487
  title: 'Author',
472
488
  field: 'author',
473
- initialValue: chooseValue(pkg.pkg.author, userName() ?? '')
489
+ initialValue: chooseValue(toAuthorString(pkg.pkg.author), userName() ?? '')
474
490
  }, {
475
491
  title: 'Readme',
476
492
  field: 'readme',
@@ -481,6 +497,15 @@ function getBasicOptions(packageName, pkg) {
481
497
  function chooseValue(pkgValue, defaultValue) {
482
498
  return pkg.mode === 'update' ? pkgValue : defaultValue;
483
499
  }
500
+ function toAuthorString(author) {
501
+ if (typeof author === 'string' || !author) {
502
+ return author;
503
+ }
504
+ const name = author.name ?? '';
505
+ const email = author.email ?? '';
506
+ const url = author.url ?? '';
507
+ return `${name}${email ? ` <${email}>` : ''}${url ? ` (${url})` : ''}`;
508
+ }
484
509
  }
485
510
  function pad16plus(value, indent = 4, offset = 3) {
486
511
  return value + ''.padEnd(offset - Math.floor((value.length + indent) / 8), '\t');
@@ -494,7 +519,7 @@ async function readPackage(dir) {
494
519
  const readmeFile = await fs.readFile(readmeFileName);
495
520
  const pkg = JSON.parse(pkgFile.toString());
496
521
  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 => {
522
+ 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
523
  if (["private", "version", "name", "license", "author", "description", "scripts", "dependencies", "devDependencies", "peerDependencies"].some(prop => key === prop))
499
524
  return true;
500
525
  const value = input[key];
@@ -504,8 +529,9 @@ async function readPackage(dir) {
504
529
  return true;
505
530
  return true;
506
531
  });
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 => {
532
+ const $io1 = input => (undefined === input.name || "string" === typeof input.name) && (undefined === input.email || "string" === typeof input.email) && (undefined === input.url || "string" === typeof input.url);
533
+ const $io2 = input => (undefined === input.build || "string" === typeof input.build) && (undefined === input.lint || "string" === typeof input.lint);
534
+ const $io3 = input => Object.keys(input).every(key => {
509
535
  const value = input[key];
510
536
  if (undefined === value)
511
537
  return true;
@@ -517,9 +543,10 @@ async function readPackage(dir) {
517
543
  })(pkg);
518
544
  if (!isValidPackageJson) {
519
545
  console.error('Invalid package.json');
546
+ throw new Error('Invalid package.json');
520
547
  }
521
548
  return {
522
- pkg: isValidPackageJson ? pkg : defaultPkg,
549
+ pkg,
523
550
  readme: readmeFile.toString(),
524
551
  mode: 'update'
525
552
  };
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.2",
2
+ "version": "1.4.4",
3
3
  "name": "create-pkgbld",
4
4
  "license": "MIT",
5
5
  "author": "Konstantin Shutkin",