@form8ion/javascript 12.1.0 → 12.3.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 +149 -103
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +164 -118
- package/lib/index.mjs.map +1 -1
- package/package.json +14 -12
package/lib/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
3
|
import { fileTypes, fileExists, validateOptions, applyEnhancers, writeConfigFile } from '@form8ion/core';
|
|
4
|
-
import { scaffoldChoice, projectTypes as projectTypes$1, packageManagers, mergeIntoExistingPackageJson, dialects as dialects$1, writePackageJson, DEV_DEPENDENCY_TYPE, PROD_DEPENDENCY_TYPE } from '@form8ion/javascript-core';
|
|
4
|
+
import { scaffoldChoice, projectTypes as projectTypes$1, packageManagers as packageManagers$1, mergeIntoExistingPackageJson, dialects as dialects$1, writePackageJson, DEV_DEPENDENCY_TYPE, PROD_DEPENDENCY_TYPE } from '@form8ion/javascript-core';
|
|
5
5
|
import joi from 'joi';
|
|
6
6
|
import { prompt as prompt$1, Separator } from '@form8ion/overridable-prompts';
|
|
7
7
|
import { scaffold, lift as lift$3 } from '@form8ion/codecov';
|
|
@@ -22,11 +22,11 @@ import { resolve } from 'path';
|
|
|
22
22
|
import filedirname from 'filedirname';
|
|
23
23
|
import * as huskyPlugin from '@form8ion/husky';
|
|
24
24
|
import { scaffold as scaffold$3 } from '@form8ion/husky';
|
|
25
|
+
import { promises as promises$1 } from 'node:fs';
|
|
25
26
|
import { stringify, parse } from 'ini';
|
|
26
27
|
import { scaffold as scaffold$2 } from '@form8ion/prettier';
|
|
27
28
|
import * as eslintPlugin from '@form8ion/eslint';
|
|
28
29
|
import { scaffold as scaffold$1, test as test$1 } from '@form8ion/eslint';
|
|
29
|
-
import { promises as promises$1 } from 'node:fs';
|
|
30
30
|
import sortProperties from 'sort-object-keys';
|
|
31
31
|
|
|
32
32
|
const questionNames$1 = {
|
|
@@ -214,7 +214,7 @@ async function scaffoldCodeStyle ({
|
|
|
214
214
|
].filter(Boolean)));
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
function lifter$
|
|
217
|
+
function lifter$4 (options) {
|
|
218
218
|
return applyEnhancers({options, enhancers: [eslintPlugin]});
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -225,7 +225,7 @@ function tester$3 (options) {
|
|
|
225
225
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
226
226
|
__proto__: null,
|
|
227
227
|
scaffold: scaffoldCodeStyle,
|
|
228
|
-
lift: lifter$
|
|
228
|
+
lift: lifter$4,
|
|
229
229
|
test: tester$3
|
|
230
230
|
});
|
|
231
231
|
|
|
@@ -260,7 +260,7 @@ function tester$2 ({projectRoot}) {
|
|
|
260
260
|
return fileExists(`${projectRoot}/.npmrc`);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
async function lifter$
|
|
263
|
+
async function lifter$3 ({projectRoot}) {
|
|
264
264
|
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
265
265
|
|
|
266
266
|
const {
|
|
@@ -278,7 +278,7 @@ var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
|
278
278
|
__proto__: null,
|
|
279
279
|
scaffold: scaffoldNpmConfig,
|
|
280
280
|
test: tester$2,
|
|
281
|
-
lift: lifter$
|
|
281
|
+
lift: lifter$3
|
|
282
282
|
});
|
|
283
283
|
|
|
284
284
|
async function test({projectRoot}) {
|
|
@@ -302,22 +302,22 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
|
302
302
|
});
|
|
303
303
|
|
|
304
304
|
function buildDocumentationCommand (packageManager) {
|
|
305
|
-
if (packageManagers.NPM === packageManager) return 'npm run generate:md';
|
|
306
|
-
if (packageManagers.YARN === packageManager) return 'yarn generate:md';
|
|
305
|
+
if (packageManagers$1.NPM === packageManager) return 'npm run generate:md';
|
|
306
|
+
if (packageManagers$1.YARN === packageManager) return 'yarn generate:md';
|
|
307
307
|
|
|
308
308
|
throw new Error(
|
|
309
309
|
`The ${packageManager} package manager is currently not supported. `
|
|
310
|
-
+ `Only ${Object.values(packageManagers).join(' and ')} are currently supported.`
|
|
310
|
+
+ `Only ${Object.values(packageManagers$1).join(' and ')} are currently supported.`
|
|
311
311
|
);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
function getInstallationCommand(packageManager) {
|
|
315
|
-
if (packageManagers.NPM === packageManager) return 'npm install';
|
|
316
|
-
if (packageManagers.YARN === packageManager) return 'yarn add';
|
|
315
|
+
if (packageManagers$1.NPM === packageManager) return 'npm install';
|
|
316
|
+
if (packageManagers$1.YARN === packageManager) return 'yarn add';
|
|
317
317
|
|
|
318
318
|
throw new Error(
|
|
319
319
|
`The ${packageManager} package manager is currently not supported. `
|
|
320
|
-
+ `Only ${Object.values(packageManagers).join(' and ')} are currently supported.`
|
|
320
|
+
+ `Only ${Object.values(packageManagers$1).join(' and ')} are currently supported.`
|
|
321
321
|
);
|
|
322
322
|
}
|
|
323
323
|
|
|
@@ -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,21 +742,35 @@ 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});
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function vcsRepositoryHostedOnGithub(vcs) {
|
|
751
|
+
return vcs && 'github' === vcs.host;
|
|
740
752
|
}
|
|
741
753
|
|
|
742
|
-
async function lifter$
|
|
754
|
+
async function lifter$2 ({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({
|
|
750
770
|
__proto__: null,
|
|
751
771
|
scaffold: scaffoldProjectType,
|
|
752
772
|
test: tester$1,
|
|
753
|
-
lift: lifter$
|
|
773
|
+
lift: lifter$2
|
|
754
774
|
});
|
|
755
775
|
|
|
756
776
|
function write ({projectRoot, config}) {
|
|
@@ -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
|
}
|
|
@@ -778,7 +798,7 @@ async function scaffoldBabel ({projectRoot, preset}) {
|
|
|
778
798
|
};
|
|
779
799
|
}
|
|
780
800
|
|
|
781
|
-
async function lifter ({results, projectRoot}) {
|
|
801
|
+
async function lifter$1 ({results, projectRoot}) {
|
|
782
802
|
await addIgnore({ignore: results.buildDirectory, projectRoot});
|
|
783
803
|
|
|
784
804
|
return {};
|
|
@@ -832,100 +852,47 @@ var dialects = /*#__PURE__*/Object.freeze({
|
|
|
832
852
|
__proto__: null,
|
|
833
853
|
scaffold: scaffoldDialect,
|
|
834
854
|
test: predicate,
|
|
835
|
-
lift: lifter
|
|
855
|
+
lift: lifter$1
|
|
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,8 +931,21 @@ 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
|
-
[packageManagers.NPM]: {
|
|
948
|
+
[packageManagers$1.NPM]: {
|
|
969
949
|
installationCommand: 'install',
|
|
970
950
|
installationFlags: {
|
|
971
951
|
[DEV_DEPENDENCY_TYPE]: `save-${DEV_DEPENDENCY_TYPE}`,
|
|
@@ -973,7 +953,7 @@ const details = {
|
|
|
973
953
|
exact: 'save-exact'
|
|
974
954
|
}
|
|
975
955
|
},
|
|
976
|
-
[packageManagers.YARN]: {
|
|
956
|
+
[packageManagers$1.YARN]: {
|
|
977
957
|
installationCommand: 'add',
|
|
978
958
|
installationFlags: {
|
|
979
959
|
[DEV_DEPENDENCY_TYPE]: DEV_DEPENDENCY_TYPE,
|
|
@@ -995,7 +975,7 @@ function getExactFlag(manager) {
|
|
|
995
975
|
return details[manager].installationFlags.exact;
|
|
996
976
|
}
|
|
997
977
|
|
|
998
|
-
async function install$1 (dependencies, dependenciesType, projectRoot, packageManager = packageManagers.NPM) {
|
|
978
|
+
async function install$1 (dependencies, dependenciesType, projectRoot, packageManager = packageManagers$1.NPM) {
|
|
999
979
|
if (dependencies.length) {
|
|
1000
980
|
info(`Installing ${dependenciesType} dependencies`, {level: 'secondary'});
|
|
1001
981
|
|
|
@@ -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
|
}
|
|
@@ -1048,21 +1057,65 @@ async function liftPackage ({
|
|
|
1048
1057
|
}
|
|
1049
1058
|
}
|
|
1050
1059
|
|
|
1060
|
+
function determineLockfilePathFor (packageManager) {
|
|
1061
|
+
const lockfilePaths = {
|
|
1062
|
+
[packageManagers$1.NPM]: 'package-lock.json',
|
|
1063
|
+
[packageManagers$1.YARN]: 'yarn.lock'
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
return lockfilePaths[packageManager];
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
function npmIsUsed ({projectRoot}) {
|
|
1070
|
+
return fileExists(`${projectRoot}/${determineLockfilePathFor(packageManagers$1.NPM)}`);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function yarnIsUsed ({projectRoot}) {
|
|
1074
|
+
return fileExists(`${projectRoot}/${determineLockfilePathFor(packageManagers$1.YARN)}`);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
async function jsPackageManagerIsUsed ({projectRoot}) {
|
|
1078
|
+
const [npmFound, yarnFound] = await Promise.all([
|
|
1079
|
+
npmIsUsed({projectRoot}),
|
|
1080
|
+
yarnIsUsed({projectRoot})
|
|
1081
|
+
]);
|
|
1082
|
+
|
|
1083
|
+
return npmFound || yarnFound;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
async function liftCorepack () {
|
|
1087
|
+
await execa('corepack', ['use', 'npm@latest']);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
async function lifter () {
|
|
1091
|
+
await liftCorepack();
|
|
1092
|
+
|
|
1093
|
+
return {};
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1051
1096
|
async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
1052
1097
|
if (packageManager) return packageManager;
|
|
1053
1098
|
|
|
1054
|
-
if (await
|
|
1055
|
-
return packageManagers.NPM;
|
|
1099
|
+
if (await npmIsUsed({projectRoot})) {
|
|
1100
|
+
return packageManagers$1.NPM;
|
|
1056
1101
|
}
|
|
1057
1102
|
|
|
1058
|
-
if (await
|
|
1059
|
-
return packageManagers.YARN;
|
|
1103
|
+
if (await yarnIsUsed({projectRoot})) {
|
|
1104
|
+
return packageManagers$1.YARN;
|
|
1060
1105
|
}
|
|
1061
1106
|
|
|
1062
1107
|
throw new Error('Package-manager could not be determined');
|
|
1063
1108
|
}
|
|
1064
1109
|
|
|
1065
|
-
|
|
1110
|
+
var packageManagers = /*#__PURE__*/Object.freeze({
|
|
1111
|
+
__proto__: null,
|
|
1112
|
+
test: jsPackageManagerIsUsed,
|
|
1113
|
+
lift: lifter,
|
|
1114
|
+
determineCurrent: resolvePackageManager,
|
|
1115
|
+
defineLockfilePath: determineLockfilePathFor
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
async function lift ({projectRoot, vcs, results, pathWithinParent}) {
|
|
1066
1119
|
info('Lifting JavaScript-specific details');
|
|
1067
1120
|
|
|
1068
1121
|
const {
|
|
@@ -1088,14 +1141,15 @@ async function lift ({projectRoot, vcs, results}) {
|
|
|
1088
1141
|
dialects,
|
|
1089
1142
|
codeStylePlugin,
|
|
1090
1143
|
npmConfigPlugin,
|
|
1091
|
-
projectTypes
|
|
1144
|
+
projectTypes,
|
|
1145
|
+
packageManagers
|
|
1092
1146
|
],
|
|
1093
1147
|
options: {packageManager, projectRoot, vcs, packageDetails: JSON.parse(packageContents)}
|
|
1094
1148
|
});
|
|
1095
1149
|
|
|
1096
1150
|
await liftPackage(
|
|
1097
1151
|
deepmerge.all([
|
|
1098
|
-
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager},
|
|
1152
|
+
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager, vcs, pathWithinParent},
|
|
1099
1153
|
enhancerResults
|
|
1100
1154
|
])
|
|
1101
1155
|
);
|
|
@@ -1317,8 +1371,8 @@ async function prompt(
|
|
|
1317
1371
|
name: questionNames$1.PACKAGE_MANAGER,
|
|
1318
1372
|
message: 'Which package manager will be used with this project?',
|
|
1319
1373
|
type: 'list',
|
|
1320
|
-
choices: Object.values(packageManagers),
|
|
1321
|
-
default: packageManagers.NPM
|
|
1374
|
+
choices: Object.values(packageManagers$1),
|
|
1375
|
+
default: packageManagers$1.NPM
|
|
1322
1376
|
},
|
|
1323
1377
|
{
|
|
1324
1378
|
name: questionNames$1.PROJECT_TYPE,
|
|
@@ -1432,13 +1486,17 @@ async function scaffoldNodeVersion ({projectRoot, nodeVersionCategory}) {
|
|
|
1432
1486
|
|
|
1433
1487
|
const version = await determineLatestVersionOf(nodeVersionCategory);
|
|
1434
1488
|
|
|
1435
|
-
await promises.writeFile(`${projectRoot}/.nvmrc`, version);
|
|
1489
|
+
await promises$1.writeFile(`${projectRoot}/.nvmrc`, version);
|
|
1436
1490
|
|
|
1437
1491
|
await install(nodeVersionCategory);
|
|
1438
1492
|
|
|
1439
1493
|
return version;
|
|
1440
1494
|
}
|
|
1441
1495
|
|
|
1496
|
+
function nvmIsUsed ({projectRoot}) {
|
|
1497
|
+
return fileExists(`${projectRoot}/.nvmrc`);
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1442
1500
|
function buildBadgesDetails (contributors) {
|
|
1443
1501
|
return deepmerge.all(contributors).badges;
|
|
1444
1502
|
}
|
|
@@ -1531,16 +1589,7 @@ function buildAllowedHostsList ({packageManager, registries}) {
|
|
|
1531
1589
|
];
|
|
1532
1590
|
}
|
|
1533
1591
|
|
|
1534
|
-
const lockfileLintSupportedPackageManagers = [packageManagers.NPM, packageManagers.YARN];
|
|
1535
|
-
|
|
1536
|
-
function determineLockfilePathFor(packageManager) {
|
|
1537
|
-
const lockfilePaths = {
|
|
1538
|
-
[packageManagers.NPM]: 'package-lock.json',
|
|
1539
|
-
[packageManagers.YARN]: 'yarn.lock'
|
|
1540
|
-
};
|
|
1541
|
-
|
|
1542
|
-
return lockfilePaths[packageManager];
|
|
1543
|
-
}
|
|
1592
|
+
const lockfileLintSupportedPackageManagers = [packageManagers$1.NPM, packageManagers$1.YARN];
|
|
1544
1593
|
|
|
1545
1594
|
function lockfileLintSupports(packageManager) {
|
|
1546
1595
|
return lockfileLintSupportedPackageManagers.includes(packageManager);
|
|
@@ -1647,16 +1696,13 @@ async function scaffolder (options) {
|
|
|
1647
1696
|
info('Writing project files', {level: 'secondary'});
|
|
1648
1697
|
|
|
1649
1698
|
const packageName = buildPackageName(projectName, scope);
|
|
1650
|
-
|
|
1699
|
+
await scaffoldPackage({
|
|
1651
1700
|
projectRoot,
|
|
1652
|
-
projectType,
|
|
1653
1701
|
dialect,
|
|
1654
1702
|
packageName,
|
|
1655
1703
|
license,
|
|
1656
|
-
vcs,
|
|
1657
1704
|
author,
|
|
1658
|
-
description
|
|
1659
|
-
pathWithinParent
|
|
1705
|
+
description
|
|
1660
1706
|
});
|
|
1661
1707
|
const projectTypeResults = await scaffoldProjectType({
|
|
1662
1708
|
projectType,
|
|
@@ -1739,7 +1785,8 @@ async function scaffolder (options) {
|
|
|
1739
1785
|
results: deepmerge({devDependencies: ['npm-run-all2'], packageManager}, mergedContributions),
|
|
1740
1786
|
projectRoot,
|
|
1741
1787
|
configs,
|
|
1742
|
-
vcs
|
|
1788
|
+
vcs,
|
|
1789
|
+
pathWithinParent
|
|
1743
1790
|
});
|
|
1744
1791
|
|
|
1745
1792
|
return {
|
|
@@ -1748,19 +1795,18 @@ async function scaffolder (options) {
|
|
|
1748
1795
|
tags: projectTypeResults.tags,
|
|
1749
1796
|
vcsIgnore: buildVcsIgnoreLists(mergedContributions.vcsIgnore),
|
|
1750
1797
|
verificationCommand: `${buildDocumentationCommand(packageManager)} && ${packageManager} test`,
|
|
1751
|
-
projectDetails: {...
|
|
1798
|
+
projectDetails: {...liftResults.homepage && {homepage: liftResults.homepage}},
|
|
1752
1799
|
nextSteps: mergedContributions.nextSteps
|
|
1753
1800
|
};
|
|
1754
1801
|
}
|
|
1755
1802
|
|
|
1756
1803
|
async function tester ({projectRoot}) {
|
|
1757
|
-
const [
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
fileExists(`${projectRoot}/yarn.lock`)
|
|
1804
|
+
const [nvmFound, jsPackageManagerFound] = await Promise.all([
|
|
1805
|
+
nvmIsUsed({projectRoot}),
|
|
1806
|
+
jsPackageManagerIsUsed({projectRoot})
|
|
1761
1807
|
]);
|
|
1762
1808
|
|
|
1763
|
-
return
|
|
1809
|
+
return nvmFound || jsPackageManagerFound;
|
|
1764
1810
|
}
|
|
1765
1811
|
|
|
1766
1812
|
const questionNames = {...questionNames$2, ...questionNames$1};
|