@form8ion/javascript 12.1.0 → 12.2.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
@@ -428,14 +428,18 @@ async function liftProvenance ({projectRoot, packageDetails}) {
428
428
  }
429
429
 
430
430
  async function liftPublishable ({projectRoot, packageDetails}) {
431
- const {name: packageName, publishConfig: {access: pacakgeAccessLevel}} = packageDetails;
431
+ const {name: packageName, publishConfig: {access: packageAccessLevel}} = packageDetails;
432
+ const homepage = `https://npm.im/${packageName}`;
433
+
434
+ await javascriptCore.mergeIntoExistingPackageJson({projectRoot, config: {homepage}});
432
435
 
433
436
  return deepmerge__default["default"](
434
437
  await liftProvenance({packageDetails, projectRoot}),
435
438
  {
439
+ homepage,
436
440
  devDependencies: ['publint'],
437
441
  scripts: {'lint:publish': 'publint --strict'},
438
- badges: defineBadges(packageName, pacakgeAccessLevel)
442
+ badges: defineBadges(packageName, packageAccessLevel)
439
443
  }
440
444
  );
441
445
  }
@@ -650,6 +654,10 @@ async function scaffoldApplicationType ({projectRoot}) {
650
654
  };
651
655
  }
652
656
 
657
+ function isApplication ({packageDetails}) {
658
+ return !!packageDetails.private;
659
+ }
660
+
653
661
  async function scaffoldMonorepoType ({projectRoot}) {
654
662
  cliMessages.info('Scaffolding Monorepo Details');
655
663
 
@@ -728,7 +736,6 @@ async function scaffoldProjectType ({
728
736
  visibility,
729
737
  packageBundlers,
730
738
  scope,
731
- vcs,
732
739
  decisions,
733
740
  dialect,
734
741
  provideExample,
@@ -744,7 +751,6 @@ async function scaffoldProjectType ({
744
751
  visibility,
745
752
  scope,
746
753
  packageBundlers,
747
- vcs,
748
754
  decisions,
749
755
  dialect,
750
756
  provideExample,
@@ -772,14 +778,28 @@ async function scaffoldProjectType ({
772
778
  }
773
779
 
774
780
  async function tester$1 ({projectRoot, packageDetails}) {
775
- return await isPackage({projectRoot, packageDetails}) || isCli({projectRoot, packageDetails});
781
+ return await isPackage({projectRoot, packageDetails})
782
+ || await isCli({projectRoot, packageDetails})
783
+ || isApplication({projectRoot, packageDetails});
776
784
  }
777
785
 
778
- async function lifter$1 ({projectRoot, packageDetails}) {
786
+ function vcsRepositoryHostedOnGithub(vcs) {
787
+ return vcs && 'github' === vcs.host;
788
+ }
789
+
790
+ async function lifter$1 ({projectRoot, packageDetails, vcs}) {
779
791
  if (await isPackage({projectRoot, packageDetails})) return liftPackage$1({projectRoot, packageDetails});
780
792
  if (await isCli({projectRoot, packageDetails})) return liftCli({projectRoot, packageDetails});
781
793
 
782
- return {};
794
+ let homepage;
795
+
796
+ if (vcsRepositoryHostedOnGithub(vcs)) {
797
+ homepage = `https://github.com/${vcs.owner}/${vcs.name}#readme`;
798
+
799
+ await javascriptCore.mergeIntoExistingPackageJson({projectRoot, config: {homepage}});
800
+ }
801
+
802
+ return {homepage};
783
803
  }
784
804
 
785
805
  var projectTypes = /*#__PURE__*/Object.freeze({
@@ -795,7 +815,7 @@ function write ({projectRoot, config}) {
795
815
 
796
816
  async function addIgnore ({projectRoot, ignore}) {
797
817
  if (ignore) {
798
- const existingConfig = JSON.parse(await fs.promises.readFile(`${projectRoot}/.babelrc.json`, 'utf-8'));
818
+ const existingConfig = JSON.parse(await node_fs.promises.readFile(`${projectRoot}/.babelrc.json`, 'utf-8'));
799
819
 
800
820
  await write({projectRoot, config: {...existingConfig, ignore: [`./${ignore}/`]}});
801
821
  }
@@ -871,97 +891,44 @@ var dialects = /*#__PURE__*/Object.freeze({
871
891
  lift: lifter
872
892
  });
873
893
 
874
- function scaffoldScripts () {
875
- return {};
876
- }
877
-
878
- function projectWillBeTested(scripts) {
879
- return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
880
- }
881
-
882
- function projectShouldBeBuiltForVerification(scripts) {
883
- return 'run-s build' === scripts['pregenerate:md'];
884
- }
885
-
886
- function updateTestScript (scripts) {
887
- return {
888
- ...scripts,
889
- test: `npm-run-all --print-label${
890
- projectShouldBeBuiltForVerification(scripts) ? ' build' : ''
891
- } --parallel lint:*${
892
- projectWillBeTested(scripts) ? ' --parallel test:*' : ''
893
- }`
894
- };
895
- }
896
-
897
- function liftScripts ({existingScripts, scripts}) {
898
- return updateTestScript({...existingScripts, ...scripts});
899
- }
900
-
901
- function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
902
- return vcs && 'github' === vcs.host && {
903
- repository: pathWithinParent
904
- ? {
905
- type: 'git',
906
- url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
907
- directory: pathWithinParent
908
- }
909
- : `${vcs.owner}/${vcs.name}`,
910
- bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
911
- homepage: (javascriptCore.projectTypes.PACKAGE === packageType)
912
- ? `https://npm.im/${packageName}`
913
- : `https://github.com/${vcs.owner}/${vcs.name}#readme`
914
- };
915
- }
916
-
917
894
  function buildPackageDetails ({
918
895
  packageName,
919
- projectType,
920
896
  dialect,
921
897
  license,
922
- vcs,
923
898
  author,
924
- description,
925
- pathWithinParent
899
+ description
926
900
  }) {
927
901
  return {
928
902
  name: packageName,
929
903
  description,
930
904
  license,
931
905
  type: javascriptCore.dialects.ESM === dialect ? 'module' : 'commonjs',
932
- ...defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent),
933
906
  author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
934
- scripts: scaffoldScripts()
907
+ scripts: {}
935
908
  };
936
909
  }
937
910
 
938
911
  async function scaffoldPackage ({
939
912
  projectRoot,
940
- projectType,
941
913
  dialect,
942
914
  packageName,
943
915
  license,
944
- vcs,
945
916
  author,
946
- description,
947
- pathWithinParent
917
+ description
948
918
  }) {
949
919
  cliMessages.info('Configuring package.json');
950
920
 
951
921
  const packageData = await buildPackageDetails({
952
922
  packageName,
953
- projectType,
954
923
  dialect,
955
924
  license,
956
- vcs,
957
925
  author,
958
- description,
959
- pathWithinParent
926
+ description
960
927
  });
961
928
 
962
929
  await javascriptCore.writePackageJson({projectRoot, config: packageData});
963
930
 
964
- return {homepage: packageData.homepage};
931
+ return {};
965
932
  }
966
933
 
967
934
  function sortPackageProperties (packageContents) {
@@ -1000,6 +967,19 @@ function sortPackageProperties (packageContents) {
1000
967
  );
1001
968
  }
1002
969
 
970
+ function defineVcsHostDetails (vcs, pathWithinParent) {
971
+ return vcs && 'github' === vcs.host && {
972
+ repository: pathWithinParent
973
+ ? {
974
+ type: 'git',
975
+ url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
976
+ directory: pathWithinParent
977
+ }
978
+ : `${vcs.owner}/${vcs.name}`,
979
+ bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`
980
+ };
981
+ }
982
+
1003
983
  const details = {
1004
984
  [javascriptCore.packageManagers.NPM]: {
1005
985
  installationCommand: 'install',
@@ -1046,13 +1026,38 @@ async function install$1 (dependencies, dependenciesType, projectRoot, packageMa
1046
1026
  } else cliMessages.warn(`No ${dependenciesType} dependencies to install`);
1047
1027
  }
1048
1028
 
1029
+ function projectWillBeTested(scripts) {
1030
+ return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
1031
+ }
1032
+
1033
+ function projectShouldBeBuiltForVerification(scripts) {
1034
+ return 'run-s build' === scripts['pregenerate:md'];
1035
+ }
1036
+
1037
+ function updateTestScript (scripts) {
1038
+ return {
1039
+ ...scripts,
1040
+ test: `npm-run-all --print-label${
1041
+ projectShouldBeBuiltForVerification(scripts) ? ' build' : ''
1042
+ } --parallel lint:*${
1043
+ projectWillBeTested(scripts) ? ' --parallel test:*' : ''
1044
+ }`
1045
+ };
1046
+ }
1047
+
1048
+ function liftScripts ({existingScripts, scripts}) {
1049
+ return updateTestScript({...existingScripts, ...scripts});
1050
+ }
1051
+
1049
1052
  async function liftPackage ({
1050
1053
  projectRoot,
1051
1054
  scripts,
1052
1055
  tags,
1053
1056
  dependencies,
1054
1057
  devDependencies,
1055
- packageManager
1058
+ packageManager,
1059
+ vcs,
1060
+ pathWithinParent
1056
1061
  }) {
1057
1062
  if (scripts || tags) {
1058
1063
  cliMessages.info('Updating `package.json`', {level: 'secondary'});
@@ -1065,7 +1070,11 @@ async function liftPackage ({
1065
1070
  projectRoot,
1066
1071
  config: sortPackageProperties({
1067
1072
  ...existingPackageJsonContents,
1068
- scripts: liftScripts({existingScripts: existingPackageJsonContents.scripts, scripts}),
1073
+ ...defineVcsHostDetails(vcs, pathWithinParent),
1074
+ scripts: liftScripts({
1075
+ existingScripts: existingPackageJsonContents.scripts,
1076
+ scripts
1077
+ }),
1069
1078
  ...tags && {
1070
1079
  keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
1071
1080
  }
@@ -1098,7 +1107,7 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
1098
1107
  throw new Error('Package-manager could not be determined');
1099
1108
  }
1100
1109
 
1101
- async function lift ({projectRoot, vcs, results}) {
1110
+ async function lift ({projectRoot, vcs, results, pathWithinParent}) {
1102
1111
  cliMessages.info('Lifting JavaScript-specific details');
1103
1112
 
1104
1113
  const {
@@ -1131,7 +1140,7 @@ async function lift ({projectRoot, vcs, results}) {
1131
1140
 
1132
1141
  await liftPackage(
1133
1142
  deepmerge__default["default"].all([
1134
- {projectRoot, scripts, tags, dependencies, devDependencies, packageManager},
1143
+ {projectRoot, scripts, tags, dependencies, devDependencies, packageManager, vcs, pathWithinParent},
1135
1144
  enhancerResults
1136
1145
  ])
1137
1146
  );
@@ -1683,16 +1692,13 @@ async function scaffolder (options) {
1683
1692
  cliMessages.info('Writing project files', {level: 'secondary'});
1684
1693
 
1685
1694
  const packageName = buildPackageName(projectName, scope);
1686
- const {homepage: projectHomepage} = await scaffoldPackage({
1695
+ await scaffoldPackage({
1687
1696
  projectRoot,
1688
- projectType,
1689
1697
  dialect,
1690
1698
  packageName,
1691
1699
  license,
1692
- vcs,
1693
1700
  author,
1694
- description,
1695
- pathWithinParent
1701
+ description
1696
1702
  });
1697
1703
  const projectTypeResults = await scaffoldProjectType({
1698
1704
  projectType,
@@ -1775,7 +1781,8 @@ async function scaffolder (options) {
1775
1781
  results: deepmerge__default["default"]({devDependencies: ['npm-run-all2'], packageManager}, mergedContributions),
1776
1782
  projectRoot,
1777
1783
  configs,
1778
- vcs
1784
+ vcs,
1785
+ pathWithinParent
1779
1786
  });
1780
1787
 
1781
1788
  return {
@@ -1784,7 +1791,7 @@ async function scaffolder (options) {
1784
1791
  tags: projectTypeResults.tags,
1785
1792
  vcsIgnore: buildVcsIgnoreLists(mergedContributions.vcsIgnore),
1786
1793
  verificationCommand: `${buildDocumentationCommand(packageManager)} && ${packageManager} test`,
1787
- projectDetails: {...projectHomepage && {homepage: projectHomepage}},
1794
+ projectDetails: {...liftResults.homepage && {homepage: liftResults.homepage}},
1788
1795
  nextSteps: mergedContributions.nextSteps
1789
1796
  };
1790
1797
  }