@form8ion/javascript 11.6.0 → 11.7.0

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/lib/index.js CHANGED
@@ -503,22 +503,38 @@ async function scaffoldPackageType ({
503
503
  ]);
504
504
  }
505
505
 
506
- async function liftPublishable ({projectRoot}) {
507
- await javascriptCore.mergeIntoExistingPackageJson({projectRoot, config: {publishConfig: {provenance: true}}});
506
+ function enhanceSlsa ({packageDetails: {publishConfig: {access, provenance}}}) {
507
+ if ('public' === access && provenance) {
508
+ return {
509
+ badges: {
510
+ status: {
511
+ slsa: {
512
+ img: 'https://slsa.dev/images/gh-badge-level2.svg',
513
+ url: 'https://slsa.dev',
514
+ text: 'SLSA Level 2'
515
+ }
516
+ }
517
+ }
518
+ };
519
+ }
508
520
 
509
- return {
510
- devDependencies: ['publint'],
511
- scripts: {'lint:publish': 'publint --strict'}
512
- };
521
+ return {};
513
522
  }
514
523
 
515
- function liftPackage$1 ({projectRoot}) {
516
- return liftPublishable({projectRoot});
524
+ async function liftPublishable ({projectRoot, packageDetails}) {
525
+ await javascriptCore.mergeIntoExistingPackageJson({projectRoot, config: {publishConfig: {provenance: true}}});
526
+
527
+ return deepmerge__default["default"](
528
+ enhanceSlsa({packageDetails}),
529
+ {devDependencies: ['publint'], scripts: {'lint:publish': 'publint --strict'}}
530
+ );
517
531
  }
518
532
 
519
- async function isPackage ({projectRoot}) {
520
- const {exports, publishConfig, bin} = JSON.parse(await node_fs.promises.readFile(`${projectRoot}/package.json`, 'utf-8'));
533
+ function liftPackage$1 ({projectRoot, packageDetails}) {
534
+ return liftPublishable({projectRoot, packageDetails});
535
+ }
521
536
 
537
+ async function isPackage ({packageDetails: {exports, publishConfig, bin}}) {
522
538
  return !!exports || (!!publishConfig && !bin);
523
539
  }
524
540
 
@@ -596,14 +612,12 @@ async function scaffoldCliType ({packageName, visibility, projectRoot, dialect,
596
612
  );
597
613
  }
598
614
 
599
- async function isCli ({projectRoot}) {
600
- const {bin} = JSON.parse(await node_fs.promises.readFile(`${projectRoot}/package.json`, 'utf-8'));
601
-
615
+ async function isCli ({packageDetails: {bin}}) {
602
616
  return !!bin;
603
617
  }
604
618
 
605
- function liftCli ({projectRoot}) {
606
- return liftPublishable({projectRoot});
619
+ function liftCli ({projectRoot, packageDetails}) {
620
+ return liftPublishable({projectRoot, packageDetails});
607
621
  }
608
622
 
609
623
  async function scaffoldProjectType ({
@@ -651,14 +665,14 @@ async function scaffoldProjectType ({
651
665
  }
652
666
 
653
667
  async function lifter$1 ({projectRoot, packageDetails}) {
654
- if (await isPackage({projectRoot})) return liftPackage$1({projectRoot, packageDetails});
655
- if (await isCli({projectRoot})) return liftCli({projectRoot, packageDetails});
668
+ if (await isPackage({projectRoot, packageDetails})) return liftPackage$1({projectRoot, packageDetails});
669
+ if (await isCli({projectRoot, packageDetails})) return liftCli({projectRoot, packageDetails});
656
670
 
657
671
  return {};
658
672
  }
659
673
 
660
- async function tester$1 ({projectRoot}) {
661
- return await isPackage({projectRoot}) || isCli({projectRoot});
674
+ async function tester$1 ({projectRoot, packageDetails}) {
675
+ return await isPackage({projectRoot, packageDetails}) || isCli({projectRoot, packageDetails});
662
676
  }
663
677
 
664
678
  var projectTypes = /*#__PURE__*/Object.freeze({
@@ -1018,7 +1032,7 @@ async function lift ({projectRoot, vcs, results}) {
1018
1032
  }
1019
1033
 
1020
1034
  const pluginSchema = joi__default["default"].object({scaffolder: joi__default["default"].func().arity(1).required()});
1021
- const pluginMapSchema = joi__default["default"].object().pattern(/^/, pluginSchema);
1035
+ const pluginMapSchema = joi__default["default"].object().pattern(joi__default["default"].string(), pluginSchema);
1022
1036
 
1023
1037
  const packageBundlersSchema = pluginMapSchema.default({});
1024
1038