@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 +84 -77
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +84 -77
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -7
package/lib/index.mjs
CHANGED
|
@@ -392,14 +392,18 @@ async function liftProvenance ({projectRoot, packageDetails}) {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
async function liftPublishable ({projectRoot, packageDetails}) {
|
|
395
|
-
const {name: packageName, publishConfig: {access:
|
|
395
|
+
const {name: packageName, publishConfig: {access: packageAccessLevel}} = packageDetails;
|
|
396
|
+
const homepage = `https://npm.im/${packageName}`;
|
|
397
|
+
|
|
398
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {homepage}});
|
|
396
399
|
|
|
397
400
|
return deepmerge(
|
|
398
401
|
await liftProvenance({packageDetails, projectRoot}),
|
|
399
402
|
{
|
|
403
|
+
homepage,
|
|
400
404
|
devDependencies: ['publint'],
|
|
401
405
|
scripts: {'lint:publish': 'publint --strict'},
|
|
402
|
-
badges: defineBadges(packageName,
|
|
406
|
+
badges: defineBadges(packageName, packageAccessLevel)
|
|
403
407
|
}
|
|
404
408
|
);
|
|
405
409
|
}
|
|
@@ -614,6 +618,10 @@ async function scaffoldApplicationType ({projectRoot}) {
|
|
|
614
618
|
};
|
|
615
619
|
}
|
|
616
620
|
|
|
621
|
+
function isApplication ({packageDetails}) {
|
|
622
|
+
return !!packageDetails.private;
|
|
623
|
+
}
|
|
624
|
+
|
|
617
625
|
async function scaffoldMonorepoType ({projectRoot}) {
|
|
618
626
|
info('Scaffolding Monorepo Details');
|
|
619
627
|
|
|
@@ -692,7 +700,6 @@ async function scaffoldProjectType ({
|
|
|
692
700
|
visibility,
|
|
693
701
|
packageBundlers,
|
|
694
702
|
scope,
|
|
695
|
-
vcs,
|
|
696
703
|
decisions,
|
|
697
704
|
dialect,
|
|
698
705
|
provideExample,
|
|
@@ -708,7 +715,6 @@ async function scaffoldProjectType ({
|
|
|
708
715
|
visibility,
|
|
709
716
|
scope,
|
|
710
717
|
packageBundlers,
|
|
711
|
-
vcs,
|
|
712
718
|
decisions,
|
|
713
719
|
dialect,
|
|
714
720
|
provideExample,
|
|
@@ -736,14 +742,28 @@ async function scaffoldProjectType ({
|
|
|
736
742
|
}
|
|
737
743
|
|
|
738
744
|
async function tester$1 ({projectRoot, packageDetails}) {
|
|
739
|
-
return await isPackage({projectRoot, packageDetails})
|
|
745
|
+
return await isPackage({projectRoot, packageDetails})
|
|
746
|
+
|| await isCli({projectRoot, packageDetails})
|
|
747
|
+
|| isApplication({projectRoot, packageDetails});
|
|
740
748
|
}
|
|
741
749
|
|
|
742
|
-
|
|
750
|
+
function vcsRepositoryHostedOnGithub(vcs) {
|
|
751
|
+
return vcs && 'github' === vcs.host;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
async function lifter$1 ({projectRoot, packageDetails, vcs}) {
|
|
743
755
|
if (await isPackage({projectRoot, packageDetails})) return liftPackage$1({projectRoot, packageDetails});
|
|
744
756
|
if (await isCli({projectRoot, packageDetails})) return liftCli({projectRoot, packageDetails});
|
|
745
757
|
|
|
746
|
-
|
|
758
|
+
let homepage;
|
|
759
|
+
|
|
760
|
+
if (vcsRepositoryHostedOnGithub(vcs)) {
|
|
761
|
+
homepage = `https://github.com/${vcs.owner}/${vcs.name}#readme`;
|
|
762
|
+
|
|
763
|
+
await mergeIntoExistingPackageJson({projectRoot, config: {homepage}});
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return {homepage};
|
|
747
767
|
}
|
|
748
768
|
|
|
749
769
|
var projectTypes = /*#__PURE__*/Object.freeze({
|
|
@@ -759,7 +779,7 @@ function write ({projectRoot, config}) {
|
|
|
759
779
|
|
|
760
780
|
async function addIgnore ({projectRoot, ignore}) {
|
|
761
781
|
if (ignore) {
|
|
762
|
-
const existingConfig = JSON.parse(await promises.readFile(`${projectRoot}/.babelrc.json`, 'utf-8'));
|
|
782
|
+
const existingConfig = JSON.parse(await promises$1.readFile(`${projectRoot}/.babelrc.json`, 'utf-8'));
|
|
763
783
|
|
|
764
784
|
await write({projectRoot, config: {...existingConfig, ignore: [`./${ignore}/`]}});
|
|
765
785
|
}
|
|
@@ -835,97 +855,44 @@ var dialects = /*#__PURE__*/Object.freeze({
|
|
|
835
855
|
lift: lifter
|
|
836
856
|
});
|
|
837
857
|
|
|
838
|
-
function scaffoldScripts () {
|
|
839
|
-
return {};
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
function projectWillBeTested(scripts) {
|
|
843
|
-
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
function projectShouldBeBuiltForVerification(scripts) {
|
|
847
|
-
return 'run-s build' === scripts['pregenerate:md'];
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
function updateTestScript (scripts) {
|
|
851
|
-
return {
|
|
852
|
-
...scripts,
|
|
853
|
-
test: `npm-run-all --print-label${
|
|
854
|
-
projectShouldBeBuiltForVerification(scripts) ? ' build' : ''
|
|
855
|
-
} --parallel lint:*${
|
|
856
|
-
projectWillBeTested(scripts) ? ' --parallel test:*' : ''
|
|
857
|
-
}`
|
|
858
|
-
};
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
function liftScripts ({existingScripts, scripts}) {
|
|
862
|
-
return updateTestScript({...existingScripts, ...scripts});
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
866
|
-
return vcs && 'github' === vcs.host && {
|
|
867
|
-
repository: pathWithinParent
|
|
868
|
-
? {
|
|
869
|
-
type: 'git',
|
|
870
|
-
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
871
|
-
directory: pathWithinParent
|
|
872
|
-
}
|
|
873
|
-
: `${vcs.owner}/${vcs.name}`,
|
|
874
|
-
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
875
|
-
homepage: (projectTypes$1.PACKAGE === packageType)
|
|
876
|
-
? `https://npm.im/${packageName}`
|
|
877
|
-
: `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
|
|
881
858
|
function buildPackageDetails ({
|
|
882
859
|
packageName,
|
|
883
|
-
projectType,
|
|
884
860
|
dialect,
|
|
885
861
|
license,
|
|
886
|
-
vcs,
|
|
887
862
|
author,
|
|
888
|
-
description
|
|
889
|
-
pathWithinParent
|
|
863
|
+
description
|
|
890
864
|
}) {
|
|
891
865
|
return {
|
|
892
866
|
name: packageName,
|
|
893
867
|
description,
|
|
894
868
|
license,
|
|
895
869
|
type: dialects$1.ESM === dialect ? 'module' : 'commonjs',
|
|
896
|
-
...defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent),
|
|
897
870
|
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
898
|
-
scripts:
|
|
871
|
+
scripts: {}
|
|
899
872
|
};
|
|
900
873
|
}
|
|
901
874
|
|
|
902
875
|
async function scaffoldPackage ({
|
|
903
876
|
projectRoot,
|
|
904
|
-
projectType,
|
|
905
877
|
dialect,
|
|
906
878
|
packageName,
|
|
907
879
|
license,
|
|
908
|
-
vcs,
|
|
909
880
|
author,
|
|
910
|
-
description
|
|
911
|
-
pathWithinParent
|
|
881
|
+
description
|
|
912
882
|
}) {
|
|
913
883
|
info('Configuring package.json');
|
|
914
884
|
|
|
915
885
|
const packageData = await buildPackageDetails({
|
|
916
886
|
packageName,
|
|
917
|
-
projectType,
|
|
918
887
|
dialect,
|
|
919
888
|
license,
|
|
920
|
-
vcs,
|
|
921
889
|
author,
|
|
922
|
-
description
|
|
923
|
-
pathWithinParent
|
|
890
|
+
description
|
|
924
891
|
});
|
|
925
892
|
|
|
926
893
|
await writePackageJson({projectRoot, config: packageData});
|
|
927
894
|
|
|
928
|
-
return {
|
|
895
|
+
return {};
|
|
929
896
|
}
|
|
930
897
|
|
|
931
898
|
function sortPackageProperties (packageContents) {
|
|
@@ -964,6 +931,19 @@ function sortPackageProperties (packageContents) {
|
|
|
964
931
|
);
|
|
965
932
|
}
|
|
966
933
|
|
|
934
|
+
function defineVcsHostDetails (vcs, pathWithinParent) {
|
|
935
|
+
return vcs && 'github' === vcs.host && {
|
|
936
|
+
repository: pathWithinParent
|
|
937
|
+
? {
|
|
938
|
+
type: 'git',
|
|
939
|
+
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
940
|
+
directory: pathWithinParent
|
|
941
|
+
}
|
|
942
|
+
: `${vcs.owner}/${vcs.name}`,
|
|
943
|
+
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
|
|
967
947
|
const details = {
|
|
968
948
|
[packageManagers.NPM]: {
|
|
969
949
|
installationCommand: 'install',
|
|
@@ -1010,13 +990,38 @@ async function install$1 (dependencies, dependenciesType, projectRoot, packageMa
|
|
|
1010
990
|
} else warn(`No ${dependenciesType} dependencies to install`);
|
|
1011
991
|
}
|
|
1012
992
|
|
|
993
|
+
function projectWillBeTested(scripts) {
|
|
994
|
+
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
function projectShouldBeBuiltForVerification(scripts) {
|
|
998
|
+
return 'run-s build' === scripts['pregenerate:md'];
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function updateTestScript (scripts) {
|
|
1002
|
+
return {
|
|
1003
|
+
...scripts,
|
|
1004
|
+
test: `npm-run-all --print-label${
|
|
1005
|
+
projectShouldBeBuiltForVerification(scripts) ? ' build' : ''
|
|
1006
|
+
} --parallel lint:*${
|
|
1007
|
+
projectWillBeTested(scripts) ? ' --parallel test:*' : ''
|
|
1008
|
+
}`
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function liftScripts ({existingScripts, scripts}) {
|
|
1013
|
+
return updateTestScript({...existingScripts, ...scripts});
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1013
1016
|
async function liftPackage ({
|
|
1014
1017
|
projectRoot,
|
|
1015
1018
|
scripts,
|
|
1016
1019
|
tags,
|
|
1017
1020
|
dependencies,
|
|
1018
1021
|
devDependencies,
|
|
1019
|
-
packageManager
|
|
1022
|
+
packageManager,
|
|
1023
|
+
vcs,
|
|
1024
|
+
pathWithinParent
|
|
1020
1025
|
}) {
|
|
1021
1026
|
if (scripts || tags) {
|
|
1022
1027
|
info('Updating `package.json`', {level: 'secondary'});
|
|
@@ -1029,7 +1034,11 @@ async function liftPackage ({
|
|
|
1029
1034
|
projectRoot,
|
|
1030
1035
|
config: sortPackageProperties({
|
|
1031
1036
|
...existingPackageJsonContents,
|
|
1032
|
-
|
|
1037
|
+
...defineVcsHostDetails(vcs, pathWithinParent),
|
|
1038
|
+
scripts: liftScripts({
|
|
1039
|
+
existingScripts: existingPackageJsonContents.scripts,
|
|
1040
|
+
scripts
|
|
1041
|
+
}),
|
|
1033
1042
|
...tags && {
|
|
1034
1043
|
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
1035
1044
|
}
|
|
@@ -1062,7 +1071,7 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
|
1062
1071
|
throw new Error('Package-manager could not be determined');
|
|
1063
1072
|
}
|
|
1064
1073
|
|
|
1065
|
-
async function lift ({projectRoot, vcs, results}) {
|
|
1074
|
+
async function lift ({projectRoot, vcs, results, pathWithinParent}) {
|
|
1066
1075
|
info('Lifting JavaScript-specific details');
|
|
1067
1076
|
|
|
1068
1077
|
const {
|
|
@@ -1095,7 +1104,7 @@ async function lift ({projectRoot, vcs, results}) {
|
|
|
1095
1104
|
|
|
1096
1105
|
await liftPackage(
|
|
1097
1106
|
deepmerge.all([
|
|
1098
|
-
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager},
|
|
1107
|
+
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager, vcs, pathWithinParent},
|
|
1099
1108
|
enhancerResults
|
|
1100
1109
|
])
|
|
1101
1110
|
);
|
|
@@ -1647,16 +1656,13 @@ async function scaffolder (options) {
|
|
|
1647
1656
|
info('Writing project files', {level: 'secondary'});
|
|
1648
1657
|
|
|
1649
1658
|
const packageName = buildPackageName(projectName, scope);
|
|
1650
|
-
|
|
1659
|
+
await scaffoldPackage({
|
|
1651
1660
|
projectRoot,
|
|
1652
|
-
projectType,
|
|
1653
1661
|
dialect,
|
|
1654
1662
|
packageName,
|
|
1655
1663
|
license,
|
|
1656
|
-
vcs,
|
|
1657
1664
|
author,
|
|
1658
|
-
description
|
|
1659
|
-
pathWithinParent
|
|
1665
|
+
description
|
|
1660
1666
|
});
|
|
1661
1667
|
const projectTypeResults = await scaffoldProjectType({
|
|
1662
1668
|
projectType,
|
|
@@ -1739,7 +1745,8 @@ async function scaffolder (options) {
|
|
|
1739
1745
|
results: deepmerge({devDependencies: ['npm-run-all2'], packageManager}, mergedContributions),
|
|
1740
1746
|
projectRoot,
|
|
1741
1747
|
configs,
|
|
1742
|
-
vcs
|
|
1748
|
+
vcs,
|
|
1749
|
+
pathWithinParent
|
|
1743
1750
|
});
|
|
1744
1751
|
|
|
1745
1752
|
return {
|
|
@@ -1748,7 +1755,7 @@ async function scaffolder (options) {
|
|
|
1748
1755
|
tags: projectTypeResults.tags,
|
|
1749
1756
|
vcsIgnore: buildVcsIgnoreLists(mergedContributions.vcsIgnore),
|
|
1750
1757
|
verificationCommand: `${buildDocumentationCommand(packageManager)} && ${packageManager} test`,
|
|
1751
|
-
projectDetails: {...
|
|
1758
|
+
projectDetails: {...liftResults.homepage && {homepage: liftResults.homepage}},
|
|
1752
1759
|
nextSteps: mergedContributions.nextSteps
|
|
1753
1760
|
};
|
|
1754
1761
|
}
|