@form8ion/javascript 15.1.0 → 15.1.2
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 +194 -171
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { fileTypes, fileExists, optionsSchemas, validateOptions, loadConfigFile,
|
|
|
4
4
|
import { scaffoldChoice, dialects as dialects$1, projectTypes as projectTypes$1, packageManagers as packageManagers$1, writePackageJson, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, mergeIntoExistingPackageJson } from '@form8ion/javascript-core';
|
|
5
5
|
import { prompt as prompt$1 } from '@form8ion/overridable-prompts';
|
|
6
6
|
import joi from 'joi';
|
|
7
|
-
import { scaffold, lift as lift$
|
|
8
|
-
import { write as write$
|
|
7
|
+
import { scaffold, lift as lift$2 } from '@form8ion/codecov';
|
|
8
|
+
import { write as write$1 } from '@form8ion/config-file';
|
|
9
9
|
import { warn, info, error } from '@travi/cli-messages';
|
|
10
10
|
import { promises } from 'node:fs';
|
|
11
11
|
import * as huskyPlugin from '@form8ion/husky';
|
|
@@ -42,8 +42,8 @@ const questionNames$1 = {
|
|
|
42
42
|
DIALECT: 'dialect'
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
async function scaffoldC8
|
|
46
|
-
await write$
|
|
45
|
+
async function scaffoldC8({projectRoot}) {
|
|
46
|
+
await write$1({
|
|
47
47
|
name: 'c8',
|
|
48
48
|
format: fileTypes.JSON,
|
|
49
49
|
path: projectRoot,
|
|
@@ -60,15 +60,15 @@ async function scaffoldC8 ({projectRoot}) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
async function scaffoldCoverage
|
|
63
|
+
async function scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent}) {
|
|
64
64
|
return deepmerge(await scaffoldC8({projectRoot}), await scaffold({vcs, visibility, pathWithinParent}));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function
|
|
67
|
+
function nyvInUse({projectRoot}) {
|
|
68
68
|
return fileExists(`${projectRoot}/.nycrc`);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
async function removeNyc
|
|
71
|
+
async function removeNyc({projectRoot}) {
|
|
72
72
|
await Promise.all([
|
|
73
73
|
promises.unlink(`${projectRoot}/.nycrc`),
|
|
74
74
|
promises.rm(`${projectRoot}/.nyc_output`, {recursive: true, force: true})
|
|
@@ -83,10 +83,10 @@ async function removeNyc ({projectRoot}) {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
async function lift$
|
|
87
|
-
const codecovResults = await lift$
|
|
86
|
+
async function lift$1({projectRoot, packageManager, vcs}) {
|
|
87
|
+
const codecovResults = await lift$2({projectRoot, packageManager, vcs});
|
|
88
88
|
|
|
89
|
-
if (await
|
|
89
|
+
if (await nyvInUse({projectRoot})) {
|
|
90
90
|
const [c8Results, nycResults] = await Promise.all([
|
|
91
91
|
scaffoldC8({projectRoot}),
|
|
92
92
|
removeNyc({projectRoot})
|
|
@@ -109,24 +109,24 @@ async function lift$2({projectRoot, packageManager, vcs}) {
|
|
|
109
109
|
return codecovResults;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
function
|
|
112
|
+
function c8InUse({projectRoot}) {
|
|
113
113
|
return fileExists(`${projectRoot}/.c8rc.json`);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
async function
|
|
117
|
-
const [c8Exists, nycExists] = await Promise.all([
|
|
116
|
+
async function testCoverageBeingCollected({projectRoot}) {
|
|
117
|
+
const [c8Exists, nycExists] = await Promise.all([c8InUse({projectRoot}), nyvInUse({projectRoot})]);
|
|
118
118
|
|
|
119
119
|
return c8Exists || nycExists;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
123
123
|
__proto__: null,
|
|
124
|
-
lift: lift$
|
|
124
|
+
lift: lift$1,
|
|
125
125
|
scaffold: scaffoldCoverage,
|
|
126
|
-
test:
|
|
126
|
+
test: testCoverageBeingCollected
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
async function
|
|
129
|
+
async function gatherUnitTestingInput({frameworks, decisions}) {
|
|
130
130
|
if (!Object.keys(frameworks).length) return 'Other';
|
|
131
131
|
|
|
132
132
|
const answers = await prompt$1([{
|
|
@@ -141,10 +141,18 @@ async function chooseFramework ({frameworks, decisions}) {
|
|
|
141
141
|
|
|
142
142
|
const pluginsSchema = joi.object().pattern(/^/, optionsSchemas.form8ionPlugin).default({});
|
|
143
143
|
|
|
144
|
-
async function scaffoldUnitTesting
|
|
144
|
+
async function scaffoldUnitTesting({
|
|
145
|
+
projectRoot,
|
|
146
|
+
frameworks,
|
|
147
|
+
decisions,
|
|
148
|
+
visibility,
|
|
149
|
+
vcs,
|
|
150
|
+
pathWithinParent,
|
|
151
|
+
dialect
|
|
152
|
+
}) {
|
|
145
153
|
const validatedFrameworks = validateOptions(pluginsSchema, frameworks);
|
|
146
154
|
const [framework, coverage] = await Promise.all([
|
|
147
|
-
|
|
155
|
+
gatherUnitTestingInput({frameworks: validatedFrameworks, decisions})
|
|
148
156
|
.then(chosenFramework => scaffoldChoice(validatedFrameworks, chosenFramework, {projectRoot, dialect})),
|
|
149
157
|
scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent})
|
|
150
158
|
]);
|
|
@@ -208,7 +216,7 @@ function validate(options) {
|
|
|
208
216
|
return validateOptions(schema, options);
|
|
209
217
|
}
|
|
210
218
|
|
|
211
|
-
function
|
|
219
|
+
function gatherDialectInput({babelPreset, typescript}) {
|
|
212
220
|
return [
|
|
213
221
|
{name: 'Common JS (no transpilation)', value: dialects$1.COMMON_JS, short: 'cjs'},
|
|
214
222
|
...babelPreset ? [{name: 'Modern JavaScript (transpiled)', value: dialects$1.BABEL, short: 'modern'}] : [],
|
|
@@ -221,11 +229,11 @@ function projectIsCLI(answers) {
|
|
|
221
229
|
return projectTypes$1.CLI === answers[questionNames$1.PROJECT_TYPE];
|
|
222
230
|
}
|
|
223
231
|
|
|
224
|
-
function projectIsPackage(answers) {
|
|
232
|
+
function projectIsPackage$1(answers) {
|
|
225
233
|
return projectTypes$1.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
226
234
|
}
|
|
227
235
|
|
|
228
|
-
function projectIsApplication(answers) {
|
|
236
|
+
function projectIsApplication$1(answers) {
|
|
229
237
|
return projectTypes$1.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
|
|
230
238
|
}
|
|
231
239
|
|
|
@@ -234,7 +242,7 @@ function packageShouldBeScoped(visibility, answers) {
|
|
|
234
242
|
}
|
|
235
243
|
|
|
236
244
|
function willBePublishedToNpm(answers) {
|
|
237
|
-
return projectIsPackage(answers) || projectIsCLI(answers);
|
|
245
|
+
return projectIsPackage$1(answers) || projectIsCLI(answers);
|
|
238
246
|
}
|
|
239
247
|
|
|
240
248
|
function shouldBeScopedPromptShouldBePresented(answers) {
|
|
@@ -323,7 +331,7 @@ async function prompt(
|
|
|
323
331
|
name: questionNames$1.DIALECT,
|
|
324
332
|
message: 'Which JavaScript dialect should this project follow?',
|
|
325
333
|
type: 'list',
|
|
326
|
-
choices:
|
|
334
|
+
choices: gatherDialectInput(configs),
|
|
327
335
|
default: 'babel'
|
|
328
336
|
},
|
|
329
337
|
...pathWithinParent ? [] : [{
|
|
@@ -377,13 +385,13 @@ async function prompt(
|
|
|
377
385
|
name: questionNames$1.PROVIDE_EXAMPLE,
|
|
378
386
|
message: 'Should an example be provided in the README?',
|
|
379
387
|
type: 'confirm',
|
|
380
|
-
when: projectIsPackage
|
|
388
|
+
when: projectIsPackage$1
|
|
381
389
|
},
|
|
382
390
|
{
|
|
383
391
|
name: questionNames$1.HOST,
|
|
384
392
|
type: 'list',
|
|
385
393
|
message: 'Where will the application be hosted?',
|
|
386
|
-
when: projectIsApplication,
|
|
394
|
+
when: projectIsApplication$1,
|
|
387
395
|
choices: [...Object.keys(hosts), 'Other']
|
|
388
396
|
}
|
|
389
397
|
], decisions);
|
|
@@ -403,28 +411,28 @@ async function prompt(
|
|
|
403
411
|
};
|
|
404
412
|
}
|
|
405
413
|
|
|
406
|
-
function
|
|
407
|
-
return write$
|
|
414
|
+
function writeBabelConfig({projectRoot, config}) {
|
|
415
|
+
return write$1({path: projectRoot, name: 'babel', format: fileTypes.JSON, config});
|
|
408
416
|
}
|
|
409
417
|
|
|
410
|
-
function
|
|
418
|
+
function loadBabelConfig({projectRoot}) {
|
|
411
419
|
return loadConfigFile({path: projectRoot, name: '.babelrc', format: fileTypes.JSON});
|
|
412
420
|
}
|
|
413
421
|
|
|
414
|
-
async function
|
|
422
|
+
async function addIgnores({projectRoot, ignore}) {
|
|
415
423
|
if (ignore) {
|
|
416
|
-
const existingConfig = await
|
|
424
|
+
const existingConfig = await loadBabelConfig({projectRoot});
|
|
417
425
|
|
|
418
|
-
await
|
|
426
|
+
await writeBabelConfig({projectRoot, config: {...existingConfig, ignore: [`./${ignore}/`]}});
|
|
419
427
|
}
|
|
420
428
|
}
|
|
421
429
|
|
|
422
|
-
async function scaffoldBabel
|
|
430
|
+
async function scaffoldBabel({projectRoot, preset}) {
|
|
423
431
|
if (!preset) {
|
|
424
432
|
throw new Error('No babel preset provided. Cannot configure babel transpilation');
|
|
425
433
|
}
|
|
426
434
|
|
|
427
|
-
await
|
|
435
|
+
await writeBabelConfig({projectRoot, config: {presets: [preset.name]}});
|
|
428
436
|
|
|
429
437
|
return {
|
|
430
438
|
dependencies: {javascript: {development: ['@babel/register', preset.packageName]}},
|
|
@@ -432,17 +440,17 @@ async function scaffoldBabel ({projectRoot, preset}) {
|
|
|
432
440
|
};
|
|
433
441
|
}
|
|
434
442
|
|
|
435
|
-
async function
|
|
436
|
-
await
|
|
443
|
+
async function liftBabel({results, projectRoot}) {
|
|
444
|
+
await addIgnores({ignore: results.buildDirectory, projectRoot});
|
|
437
445
|
|
|
438
446
|
return {};
|
|
439
447
|
}
|
|
440
448
|
|
|
441
|
-
function
|
|
449
|
+
function babelIsInUse({projectRoot}) {
|
|
442
450
|
return fileExists(`${projectRoot}/.babelrc.json`);
|
|
443
451
|
}
|
|
444
452
|
|
|
445
|
-
async function scaffoldTypescript
|
|
453
|
+
async function scaffoldTypescript({config, projectType, projectRoot, testFilenamePattern}) {
|
|
446
454
|
const shareableTsConfigPackage = `${config.scope}/tsconfig`;
|
|
447
455
|
|
|
448
456
|
await writeConfigFile({
|
|
@@ -471,7 +479,7 @@ async function scaffoldTypescript ({config, projectType, projectRoot, testFilena
|
|
|
471
479
|
};
|
|
472
480
|
}
|
|
473
481
|
|
|
474
|
-
function scaffoldDialect
|
|
482
|
+
function scaffoldDialect({dialect, projectType, projectRoot, configs, testFilenamePattern}) {
|
|
475
483
|
switch (dialect) {
|
|
476
484
|
case dialects$1.BABEL:
|
|
477
485
|
return scaffoldBabel({preset: configs.babelPreset, projectRoot});
|
|
@@ -484,12 +492,12 @@ function scaffoldDialect ({dialect, projectType, projectRoot, configs, testFilen
|
|
|
484
492
|
|
|
485
493
|
var dialects = /*#__PURE__*/Object.freeze({
|
|
486
494
|
__proto__: null,
|
|
487
|
-
lift:
|
|
495
|
+
lift: liftBabel,
|
|
488
496
|
scaffold: scaffoldDialect,
|
|
489
|
-
test:
|
|
497
|
+
test: babelIsInUse
|
|
490
498
|
});
|
|
491
499
|
|
|
492
|
-
async function writeNpmConfig
|
|
500
|
+
async function writeNpmConfig({projectRoot, config}) {
|
|
493
501
|
await promises.writeFile(`${projectRoot}/.npmrc`, stringify(config));
|
|
494
502
|
}
|
|
495
503
|
|
|
@@ -497,7 +505,7 @@ function projectWillNotBeConsumed(projectType) {
|
|
|
497
505
|
return projectTypes$1.APPLICATION === projectType || projectTypes$1.CLI === projectType;
|
|
498
506
|
}
|
|
499
507
|
|
|
500
|
-
async function
|
|
508
|
+
async function scaffoldNpmConfiguration({projectRoot, projectType}) {
|
|
501
509
|
await writeNpmConfig({
|
|
502
510
|
projectRoot,
|
|
503
511
|
config: {'update-notifier': false, ...projectWillNotBeConsumed(projectType) && {'save-exact': true}}
|
|
@@ -506,11 +514,11 @@ async function scaffoldNpmConfig ({projectRoot, projectType}) {
|
|
|
506
514
|
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
507
515
|
}
|
|
508
516
|
|
|
509
|
-
function
|
|
517
|
+
function npmConfigExists({projectRoot}) {
|
|
510
518
|
return fileExists(`${projectRoot}/.npmrc`);
|
|
511
519
|
}
|
|
512
520
|
|
|
513
|
-
async function readNpmConfig
|
|
521
|
+
async function readNpmConfig({projectRoot}) {
|
|
514
522
|
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
515
523
|
|
|
516
524
|
if (!(await fileExists(pathToConfig))) return {};
|
|
@@ -518,7 +526,7 @@ async function readNpmConfig ({projectRoot}) {
|
|
|
518
526
|
return parse(await promises.readFile(pathToConfig, 'utf-8'));
|
|
519
527
|
}
|
|
520
528
|
|
|
521
|
-
async function
|
|
529
|
+
async function liftNpmConfig({projectRoot}) {
|
|
522
530
|
const {
|
|
523
531
|
provenance,
|
|
524
532
|
'engines-strict': enginesStrict,
|
|
@@ -532,14 +540,14 @@ async function lifter$4 ({projectRoot}) {
|
|
|
532
540
|
|
|
533
541
|
var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
534
542
|
__proto__: null,
|
|
535
|
-
lift:
|
|
543
|
+
lift: liftNpmConfig,
|
|
536
544
|
read: readNpmConfig,
|
|
537
|
-
scaffold:
|
|
538
|
-
test:
|
|
545
|
+
scaffold: scaffoldNpmConfiguration,
|
|
546
|
+
test: npmConfigExists,
|
|
539
547
|
write: writeNpmConfig
|
|
540
548
|
});
|
|
541
549
|
|
|
542
|
-
async function
|
|
550
|
+
async function scaffoldNpmPackageManager({projectRoot}) {
|
|
543
551
|
const [packageContents, {stdout}] = await Promise.all([
|
|
544
552
|
promises.readFile(`${projectRoot}/package.json`, 'utf-8'),
|
|
545
553
|
execa('npm', ['--version'])
|
|
@@ -555,7 +563,7 @@ async function scaffoldNpm ({projectRoot}) {
|
|
|
555
563
|
});
|
|
556
564
|
}
|
|
557
565
|
|
|
558
|
-
function
|
|
566
|
+
function resolveLockfilePath(packageManager) {
|
|
559
567
|
const lockfilePaths = {
|
|
560
568
|
[packageManagers$1.NPM]: 'package-lock.json',
|
|
561
569
|
[packageManagers$1.YARN]: 'yarn.lock'
|
|
@@ -564,14 +572,14 @@ function determineLockfilePathFor (packageManager) {
|
|
|
564
572
|
return lockfilePaths[packageManager];
|
|
565
573
|
}
|
|
566
574
|
|
|
567
|
-
function
|
|
575
|
+
function packageManagerIsNpm({projectRoot, pinnedPackageManager = ''}) {
|
|
568
576
|
const [packageManager] = pinnedPackageManager.split('@');
|
|
569
577
|
|
|
570
578
|
return packageManagers$1.NPM === packageManager
|
|
571
|
-
|| fileExists(`${projectRoot}/${
|
|
579
|
+
|| fileExists(`${projectRoot}/${resolveLockfilePath(packageManagers$1.NPM)}`);
|
|
572
580
|
}
|
|
573
581
|
|
|
574
|
-
async function scaffoldYarn
|
|
582
|
+
async function scaffoldYarn({projectRoot}) {
|
|
575
583
|
const [packageContents, {stdout}] = await Promise.all([
|
|
576
584
|
promises.readFile(`${projectRoot}/package.json`, 'utf-8'),
|
|
577
585
|
execa('yarn', ['--version'])
|
|
@@ -587,51 +595,51 @@ async function scaffoldYarn ({projectRoot}) {
|
|
|
587
595
|
});
|
|
588
596
|
}
|
|
589
597
|
|
|
590
|
-
function
|
|
598
|
+
function packageManagerIsYarn({projectRoot, pinnedPackageManager = ''}) {
|
|
591
599
|
const [packageManager] = pinnedPackageManager.split('@');
|
|
592
600
|
|
|
593
601
|
return packageManagers$1.YARN === packageManager
|
|
594
|
-
|| fileExists(`${projectRoot}/${
|
|
602
|
+
|| fileExists(`${projectRoot}/${resolveLockfilePath(packageManagers$1.YARN)}`);
|
|
595
603
|
}
|
|
596
604
|
|
|
597
|
-
async function
|
|
605
|
+
async function packageManagerInUse({projectRoot}) {
|
|
598
606
|
const [npmFound, yarnFound] = await Promise.all([
|
|
599
|
-
|
|
600
|
-
|
|
607
|
+
packageManagerIsNpm({projectRoot}),
|
|
608
|
+
packageManagerIsYarn({projectRoot})
|
|
601
609
|
]);
|
|
602
610
|
|
|
603
611
|
return npmFound || yarnFound;
|
|
604
612
|
}
|
|
605
613
|
|
|
606
|
-
async function liftCorepack
|
|
614
|
+
async function liftCorepack() {
|
|
607
615
|
await execa('corepack', ['use', 'npm@latest']);
|
|
608
616
|
}
|
|
609
617
|
|
|
610
|
-
async function
|
|
618
|
+
async function liftPackageManagers() {
|
|
611
619
|
await liftCorepack();
|
|
612
620
|
|
|
613
621
|
return {};
|
|
614
622
|
}
|
|
615
623
|
|
|
616
624
|
const scaffolders = {
|
|
617
|
-
npm:
|
|
625
|
+
npm: scaffoldNpmPackageManager,
|
|
618
626
|
yarn: scaffoldYarn
|
|
619
627
|
};
|
|
620
628
|
|
|
621
|
-
function scaffoldPackageManager
|
|
629
|
+
function scaffoldPackageManager({projectRoot, packageManager}) {
|
|
622
630
|
return scaffolders[packageManager]({projectRoot});
|
|
623
631
|
}
|
|
624
632
|
|
|
625
|
-
async function
|
|
633
|
+
async function resolveCurrentPackageManager({projectRoot, packageManager}) {
|
|
626
634
|
if (packageManager) return packageManager;
|
|
627
635
|
|
|
628
636
|
const {packageManager: pinnedPackageManager} = JSON.parse(await promises.readFile(`${projectRoot}/package.json`, 'utf-8'));
|
|
629
637
|
|
|
630
|
-
if (await
|
|
638
|
+
if (await packageManagerIsNpm({projectRoot, pinnedPackageManager})) {
|
|
631
639
|
return packageManagers$1.NPM;
|
|
632
640
|
}
|
|
633
641
|
|
|
634
|
-
if (await
|
|
642
|
+
if (await packageManagerIsYarn({projectRoot, pinnedPackageManager})) {
|
|
635
643
|
return packageManagers$1.YARN;
|
|
636
644
|
}
|
|
637
645
|
|
|
@@ -640,14 +648,14 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
|
640
648
|
|
|
641
649
|
var packageManagers = /*#__PURE__*/Object.freeze({
|
|
642
650
|
__proto__: null,
|
|
643
|
-
defineLockfilePath:
|
|
644
|
-
determineCurrent:
|
|
645
|
-
lift:
|
|
651
|
+
defineLockfilePath: resolveLockfilePath,
|
|
652
|
+
determineCurrent: resolveCurrentPackageManager,
|
|
653
|
+
lift: liftPackageManagers,
|
|
646
654
|
scaffold: scaffoldPackageManager,
|
|
647
|
-
test:
|
|
655
|
+
test: packageManagerInUse
|
|
648
656
|
});
|
|
649
657
|
|
|
650
|
-
function
|
|
658
|
+
function scaffoldGenerationCommand(packageManager) {
|
|
651
659
|
if (packageManagers$1.NPM === packageManager) return 'npm run generate:md';
|
|
652
660
|
if (packageManagers$1.YARN === packageManager) return 'yarn generate:md';
|
|
653
661
|
|
|
@@ -657,9 +665,9 @@ function buildDocumentationCommand (packageManager) {
|
|
|
657
665
|
);
|
|
658
666
|
}
|
|
659
667
|
|
|
660
|
-
function scaffoldDocumentation
|
|
668
|
+
function scaffoldDocumentation({projectTypeResults, packageManager}) {
|
|
661
669
|
return {
|
|
662
|
-
toc: `Run \`${
|
|
670
|
+
toc: `Run \`${scaffoldGenerationCommand(packageManager)}\` to generate a table of contents`,
|
|
663
671
|
...projectTypeResults.documentation,
|
|
664
672
|
contributing: `### Dependencies
|
|
665
673
|
|
|
@@ -690,7 +698,7 @@ async function determineLatestVersionOf(nodeVersionCategory) {
|
|
|
690
698
|
return lsLine.match(/(v[0-9]+)\.[0-9]+\.[0-9]+/)[1];
|
|
691
699
|
}
|
|
692
700
|
|
|
693
|
-
function install
|
|
701
|
+
function install(nodeVersionCategory) {
|
|
694
702
|
info(`Installing ${nodeVersionCategory} version of node using nvm`, {level: 'secondary'});
|
|
695
703
|
|
|
696
704
|
const subprocess = execa('. ~/.nvm/nvm.sh && nvm install', {shell: true});
|
|
@@ -698,7 +706,7 @@ function install$1(nodeVersionCategory) {
|
|
|
698
706
|
return subprocess;
|
|
699
707
|
}
|
|
700
708
|
|
|
701
|
-
async function scaffoldNodeVersion
|
|
709
|
+
async function scaffoldNodeVersion({projectRoot, nodeVersionCategory}) {
|
|
702
710
|
if (!nodeVersionCategory) return undefined;
|
|
703
711
|
|
|
704
712
|
const lowerCaseCategory = nodeVersionCategory.toLowerCase();
|
|
@@ -708,23 +716,23 @@ async function scaffoldNodeVersion ({projectRoot, nodeVersionCategory}) {
|
|
|
708
716
|
|
|
709
717
|
await promises.writeFile(`${projectRoot}/.nvmrc`, version);
|
|
710
718
|
|
|
711
|
-
await install
|
|
719
|
+
await install(nodeVersionCategory);
|
|
712
720
|
|
|
713
721
|
return version;
|
|
714
722
|
}
|
|
715
723
|
|
|
716
|
-
function
|
|
724
|
+
function nodeVersionMangerInUse({projectRoot}) {
|
|
717
725
|
return fileExists(`${projectRoot}/.nvmrc`);
|
|
718
726
|
}
|
|
719
727
|
|
|
720
|
-
function
|
|
728
|
+
function buildIgnoreLists(vcsIgnoreLists = {}) {
|
|
721
729
|
return {
|
|
722
730
|
files: vcsIgnoreLists.files || [],
|
|
723
731
|
directories: ['/node_modules/', ...vcsIgnoreLists.directories || []]
|
|
724
732
|
};
|
|
725
733
|
}
|
|
726
734
|
|
|
727
|
-
function
|
|
735
|
+
function determinePackageName(projectName, scope) {
|
|
728
736
|
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
729
737
|
|
|
730
738
|
const {validForNewPackages, errors} = validatePackageName(name);
|
|
@@ -735,7 +743,7 @@ function buildPackageName (projectName, scope) {
|
|
|
735
743
|
throw new Error(`The package name ${name} is invalid:${EOL}\t* ${errors.join(`${EOL}\t* `)}`);
|
|
736
744
|
}
|
|
737
745
|
|
|
738
|
-
function
|
|
746
|
+
function scaffoldPackageJsonDetails({
|
|
739
747
|
packageName,
|
|
740
748
|
dialect,
|
|
741
749
|
license,
|
|
@@ -752,7 +760,7 @@ function buildPackageDetails ({
|
|
|
752
760
|
};
|
|
753
761
|
}
|
|
754
762
|
|
|
755
|
-
async function scaffoldPackage
|
|
763
|
+
async function scaffoldPackage({
|
|
756
764
|
projectRoot,
|
|
757
765
|
projectName,
|
|
758
766
|
scope,
|
|
@@ -763,11 +771,11 @@ async function scaffoldPackage ({
|
|
|
763
771
|
}) {
|
|
764
772
|
info('Configuring package.json');
|
|
765
773
|
|
|
766
|
-
const packageName =
|
|
774
|
+
const packageName = determinePackageName(projectName, scope);
|
|
767
775
|
|
|
768
776
|
await writePackageJson({
|
|
769
777
|
projectRoot,
|
|
770
|
-
config: await
|
|
778
|
+
config: await scaffoldPackageJsonDetails({
|
|
771
779
|
packageName,
|
|
772
780
|
dialect,
|
|
773
781
|
license,
|
|
@@ -816,7 +824,7 @@ function sortProperties(packageContents) {
|
|
|
816
824
|
);
|
|
817
825
|
}
|
|
818
826
|
|
|
819
|
-
function
|
|
827
|
+
function scaffoldVcsHostDetails(vcs, pathWithinParent) {
|
|
820
828
|
return vcs && 'github' === vcs.host && {
|
|
821
829
|
repository: pathWithinParent
|
|
822
830
|
? {
|
|
@@ -860,7 +868,12 @@ function getExactFlag(manager) {
|
|
|
860
868
|
return details[manager].installationFlags.exact;
|
|
861
869
|
}
|
|
862
870
|
|
|
863
|
-
async function
|
|
871
|
+
async function installDependencies(
|
|
872
|
+
dependencies,
|
|
873
|
+
dependenciesType,
|
|
874
|
+
projectRoot,
|
|
875
|
+
packageManager = packageManagers$1.NPM
|
|
876
|
+
) {
|
|
864
877
|
if (dependencies.length) {
|
|
865
878
|
info(`Installing ${dependenciesType} dependencies`, {level: 'secondary'});
|
|
866
879
|
|
|
@@ -875,7 +888,7 @@ async function install (dependencies, dependenciesType, projectRoot, packageMana
|
|
|
875
888
|
} else warn(`No ${dependenciesType} dependencies to install`);
|
|
876
889
|
}
|
|
877
890
|
|
|
878
|
-
async function
|
|
891
|
+
async function removeDependencies({packageManager, dependencies}) {
|
|
879
892
|
if (dependencies.length) {
|
|
880
893
|
info('Removing dependencies dependencies', {level: 'secondary'});
|
|
881
894
|
|
|
@@ -883,7 +896,7 @@ async function remove ({packageManager, dependencies}) {
|
|
|
883
896
|
}
|
|
884
897
|
}
|
|
885
898
|
|
|
886
|
-
async function processDependencies
|
|
899
|
+
async function processDependencies({dependencies = {}, devDependencies, projectRoot, packageManager}) {
|
|
887
900
|
info('Processing dependencies');
|
|
888
901
|
|
|
889
902
|
if (Array.isArray(devDependencies)) {
|
|
@@ -899,9 +912,9 @@ async function processDependencies ({dependencies = {}, devDependencies, project
|
|
|
899
912
|
const {javascript: {production = [], development = [], remove: dependenciesToRemove = []} = {}} = dependencies;
|
|
900
913
|
|
|
901
914
|
try {
|
|
902
|
-
await
|
|
903
|
-
await
|
|
904
|
-
await
|
|
915
|
+
await installDependencies(production, PROD_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
916
|
+
await installDependencies(development, DEV_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
917
|
+
await removeDependencies({packageManager, dependencies: dependenciesToRemove});
|
|
905
918
|
} catch (e) {
|
|
906
919
|
error('Failed to update dependencies');
|
|
907
920
|
error(e, {level: 'secondary'});
|
|
@@ -936,13 +949,14 @@ function isPostScriptFor(a, b) {
|
|
|
936
949
|
return isRelatedScript(a, b, 'post');
|
|
937
950
|
}
|
|
938
951
|
|
|
939
|
-
function
|
|
952
|
+
function stripPrefix(script) {
|
|
940
953
|
if (script.startsWith('pre')) return script.slice(3);
|
|
941
954
|
if (script.startsWith('post')) return script.slice(4);
|
|
942
955
|
return script;
|
|
943
956
|
}
|
|
944
957
|
|
|
945
|
-
function getCategoryOrder(
|
|
958
|
+
function getCategoryOrder(script) {
|
|
959
|
+
const base = stripPrefix(script);
|
|
946
960
|
if ('test' === base) return 0;
|
|
947
961
|
if (base.startsWith('lint:')) return 1;
|
|
948
962
|
if (base.startsWith('test:unit')) return 2;
|
|
@@ -958,14 +972,14 @@ function compareScriptNames(a, b) {
|
|
|
958
972
|
if (isPostScriptFor(a, b)) return 1;
|
|
959
973
|
if (isPostScriptFor(b, a)) return -1;
|
|
960
974
|
|
|
961
|
-
const
|
|
962
|
-
const bBase = getBaseScriptOf(b);
|
|
963
|
-
|
|
964
|
-
const categoryDiff = getCategoryOrder(aBase) - getCategoryOrder(bBase);
|
|
975
|
+
const categoryDiff = getCategoryOrder(a) - getCategoryOrder(b);
|
|
965
976
|
if (0 !== categoryDiff) return 0 > categoryDiff ? -1 : 1;
|
|
966
977
|
|
|
967
|
-
const
|
|
968
|
-
const
|
|
978
|
+
const aStripped = stripPrefix(a);
|
|
979
|
+
const bStripped = stripPrefix(b);
|
|
980
|
+
|
|
981
|
+
const aKey = aStripped !== a ? aStripped : a;
|
|
982
|
+
const bKey = bStripped !== b ? bStripped : b;
|
|
969
983
|
|
|
970
984
|
return aKey.localeCompare(bKey);
|
|
971
985
|
}
|
|
@@ -986,7 +1000,7 @@ function liftScripts({existingScripts, scripts}) {
|
|
|
986
1000
|
};
|
|
987
1001
|
}
|
|
988
1002
|
|
|
989
|
-
async function
|
|
1003
|
+
async function liftPackageJson({
|
|
990
1004
|
projectRoot,
|
|
991
1005
|
scripts,
|
|
992
1006
|
tags,
|
|
@@ -1008,7 +1022,7 @@ async function liftPackage$1 ({
|
|
|
1008
1022
|
projectRoot,
|
|
1009
1023
|
config: sortProperties({
|
|
1010
1024
|
...existingPackageJsonContents,
|
|
1011
|
-
...
|
|
1025
|
+
...scaffoldVcsHostDetails(vcs, pathWithinParent),
|
|
1012
1026
|
scripts: liftedScripts,
|
|
1013
1027
|
...tags && {
|
|
1014
1028
|
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
@@ -1024,11 +1038,11 @@ async function liftPackage$1 ({
|
|
|
1024
1038
|
});
|
|
1025
1039
|
}
|
|
1026
1040
|
|
|
1027
|
-
function
|
|
1041
|
+
function mapProjectVisibility({projectVisibility}) {
|
|
1028
1042
|
return 'Public' === projectVisibility ? 'public' : 'restricted';
|
|
1029
1043
|
}
|
|
1030
1044
|
|
|
1031
|
-
function
|
|
1045
|
+
function scaffoldPublishableBadges(packageName, accessLevel) {
|
|
1032
1046
|
return {
|
|
1033
1047
|
consumer: {
|
|
1034
1048
|
...'public' === accessLevel && {
|
|
@@ -1043,7 +1057,7 @@ function defineBadges (packageName, accessLevel) {
|
|
|
1043
1057
|
};
|
|
1044
1058
|
}
|
|
1045
1059
|
|
|
1046
|
-
function
|
|
1060
|
+
function scaffoldSlsa({provenance}) {
|
|
1047
1061
|
{
|
|
1048
1062
|
return {
|
|
1049
1063
|
badges: {
|
|
@@ -1059,13 +1073,13 @@ function enhanceSlsa ({provenance}) {
|
|
|
1059
1073
|
}
|
|
1060
1074
|
}
|
|
1061
1075
|
|
|
1062
|
-
async function liftProvenance
|
|
1076
|
+
async function liftProvenance({projectRoot, packageDetails}) {
|
|
1063
1077
|
const {publishConfig: {access} = {}} = packageDetails;
|
|
1064
1078
|
|
|
1065
1079
|
if ('public' === access) {
|
|
1066
1080
|
await mergeIntoExistingPackageJson({projectRoot, config: {publishConfig: {provenance: true}}});
|
|
1067
1081
|
|
|
1068
|
-
return
|
|
1082
|
+
return scaffoldSlsa({provenance: true});
|
|
1069
1083
|
}
|
|
1070
1084
|
|
|
1071
1085
|
return {};
|
|
@@ -1083,14 +1097,14 @@ async function liftPublishable({projectRoot, packageDetails}) {
|
|
|
1083
1097
|
homepage,
|
|
1084
1098
|
dependencies: {javascript: {development: ['publint']}},
|
|
1085
1099
|
scripts: {'lint:publish': 'publint --strict'},
|
|
1086
|
-
badges:
|
|
1100
|
+
badges: scaffoldPublishableBadges(packageName, packageAccessLevel)
|
|
1087
1101
|
}
|
|
1088
1102
|
);
|
|
1089
1103
|
}
|
|
1090
1104
|
|
|
1091
|
-
async function scaffoldPublishable
|
|
1105
|
+
async function scaffoldPublishable({packageName, packageAccessLevel}) {
|
|
1092
1106
|
return {
|
|
1093
|
-
badges: await
|
|
1107
|
+
badges: await scaffoldPublishableBadges(packageName, packageAccessLevel)
|
|
1094
1108
|
};
|
|
1095
1109
|
}
|
|
1096
1110
|
|
|
@@ -1104,7 +1118,7 @@ function getInstallationCommand(packageManager) {
|
|
|
1104
1118
|
);
|
|
1105
1119
|
}
|
|
1106
1120
|
|
|
1107
|
-
function scaffoldPackageDocumentation
|
|
1121
|
+
function scaffoldPackageDocumentation({scope, packageName, packageManager, visibility, provideExample}) {
|
|
1108
1122
|
return {
|
|
1109
1123
|
usage: `### Installation
|
|
1110
1124
|
${'Private' === visibility ? `
|
|
@@ -1119,13 +1133,13 @@ $ ${getInstallationCommand(packageManager)} ${packageName}
|
|
|
1119
1133
|
|
|
1120
1134
|
### Example
|
|
1121
1135
|
|
|
1122
|
-
run \`${
|
|
1136
|
+
run \`${scaffoldGenerationCommand(packageManager)}\` to inject the usage example`
|
|
1123
1137
|
: ''
|
|
1124
1138
|
}`
|
|
1125
1139
|
};
|
|
1126
1140
|
}
|
|
1127
1141
|
|
|
1128
|
-
async function
|
|
1142
|
+
async function gatherBundlerInput({bundlers, decisions}) {
|
|
1129
1143
|
if (!Object.keys(bundlers).length) return 'Other';
|
|
1130
1144
|
|
|
1131
1145
|
const answers = await prompt$1([{
|
|
@@ -1138,8 +1152,8 @@ async function chooseBundler ({bundlers, decisions}) {
|
|
|
1138
1152
|
return answers[questionNames$1.PACKAGE_BUNDLER];
|
|
1139
1153
|
}
|
|
1140
1154
|
|
|
1141
|
-
async function scaffoldBundler
|
|
1142
|
-
const chosenBundler = await
|
|
1155
|
+
async function scaffoldBundler({projectRoot, projectType, bundlers, dialect, decisions}) {
|
|
1156
|
+
const chosenBundler = await gatherBundlerInput({bundlers, decisions});
|
|
1143
1157
|
|
|
1144
1158
|
return scaffoldChoice(bundlers, chosenBundler, {projectRoot, projectType, dialect});
|
|
1145
1159
|
}
|
|
@@ -1210,7 +1224,7 @@ async function scaffoldPackageProjectType({
|
|
|
1210
1224
|
}) {
|
|
1211
1225
|
info('Scaffolding Package Details');
|
|
1212
1226
|
|
|
1213
|
-
const packageAccessLevel =
|
|
1227
|
+
const packageAccessLevel = mapProjectVisibility({projectVisibility: visibility});
|
|
1214
1228
|
const [detailsForBuild, publishableResults] = await Promise.all([
|
|
1215
1229
|
buildDetails({
|
|
1216
1230
|
projectRoot,
|
|
@@ -1275,13 +1289,15 @@ function liftPackage({projectRoot, packageDetails}) {
|
|
|
1275
1289
|
return liftPublishable({projectRoot, packageDetails});
|
|
1276
1290
|
}
|
|
1277
1291
|
|
|
1278
|
-
async function
|
|
1292
|
+
async function projectIsPackage({
|
|
1293
|
+
packageDetails: {exports: exports$1, publishConfig, bin, private: projectMarkedPrivate}
|
|
1294
|
+
}) {
|
|
1279
1295
|
return !projectMarkedPrivate && (!!exports$1 || (!!publishConfig && !bin));
|
|
1280
1296
|
}
|
|
1281
1297
|
|
|
1282
1298
|
const defaultBuildDirectory$1 = 'public';
|
|
1283
1299
|
|
|
1284
|
-
async function
|
|
1300
|
+
async function scaffoldApplication({projectRoot}) {
|
|
1285
1301
|
info('Scaffolding Application Details');
|
|
1286
1302
|
|
|
1287
1303
|
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
@@ -1301,11 +1317,11 @@ async function scaffoldApplicationType ({projectRoot}) {
|
|
|
1301
1317
|
};
|
|
1302
1318
|
}
|
|
1303
1319
|
|
|
1304
|
-
function
|
|
1320
|
+
function projectIsApplication({packageDetails}) {
|
|
1305
1321
|
return !!packageDetails.private;
|
|
1306
1322
|
}
|
|
1307
1323
|
|
|
1308
|
-
async function
|
|
1324
|
+
async function scaffoldMonorepo({projectRoot}) {
|
|
1309
1325
|
info('Scaffolding Monorepo Details');
|
|
1310
1326
|
|
|
1311
1327
|
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
@@ -1330,7 +1346,7 @@ async function scaffoldCli({
|
|
|
1330
1346
|
decisions,
|
|
1331
1347
|
packageBundlers
|
|
1332
1348
|
}) {
|
|
1333
|
-
const packageAccessLevel =
|
|
1349
|
+
const packageAccessLevel = mapProjectVisibility({projectVisibility: visibility});
|
|
1334
1350
|
const [bundlerResults, publishableResults] = await Promise.all([
|
|
1335
1351
|
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType: projectTypes$1.CLI}),
|
|
1336
1352
|
scaffoldPublishable({packageName, packageAccessLevel}),
|
|
@@ -1365,7 +1381,7 @@ async function scaffoldCli({
|
|
|
1365
1381
|
]);
|
|
1366
1382
|
}
|
|
1367
1383
|
|
|
1368
|
-
async function
|
|
1384
|
+
async function projectIsCli({packageDetails: {bin}}) {
|
|
1369
1385
|
return !!bin;
|
|
1370
1386
|
}
|
|
1371
1387
|
|
|
@@ -1373,7 +1389,7 @@ function liftCli({projectRoot, packageDetails}) {
|
|
|
1373
1389
|
return liftPublishable({projectRoot, packageDetails});
|
|
1374
1390
|
}
|
|
1375
1391
|
|
|
1376
|
-
async function scaffoldProjectType
|
|
1392
|
+
async function scaffoldProjectType({
|
|
1377
1393
|
projectType,
|
|
1378
1394
|
projectRoot,
|
|
1379
1395
|
projectName,
|
|
@@ -1403,7 +1419,7 @@ async function scaffoldProjectType ({
|
|
|
1403
1419
|
publishRegistry
|
|
1404
1420
|
});
|
|
1405
1421
|
case projectTypes$1.APPLICATION:
|
|
1406
|
-
return
|
|
1422
|
+
return scaffoldApplication({projectRoot});
|
|
1407
1423
|
case projectTypes$1.CLI:
|
|
1408
1424
|
return scaffoldCli({
|
|
1409
1425
|
packageName,
|
|
@@ -1415,7 +1431,7 @@ async function scaffoldProjectType ({
|
|
|
1415
1431
|
packageBundlers
|
|
1416
1432
|
});
|
|
1417
1433
|
case projectTypes$1.MONOREPO:
|
|
1418
|
-
return
|
|
1434
|
+
return scaffoldMonorepo({projectRoot});
|
|
1419
1435
|
case 'Other':
|
|
1420
1436
|
return {};
|
|
1421
1437
|
default:
|
|
@@ -1423,19 +1439,19 @@ async function scaffoldProjectType ({
|
|
|
1423
1439
|
}
|
|
1424
1440
|
}
|
|
1425
1441
|
|
|
1426
|
-
async function
|
|
1427
|
-
return await
|
|
1428
|
-
|| await
|
|
1429
|
-
||
|
|
1442
|
+
async function isProjectType({projectRoot, packageDetails}) {
|
|
1443
|
+
return await projectIsPackage({packageDetails})
|
|
1444
|
+
|| await projectIsCli({packageDetails})
|
|
1445
|
+
|| projectIsApplication({packageDetails});
|
|
1430
1446
|
}
|
|
1431
1447
|
|
|
1432
1448
|
function vcsRepositoryHostedOnGithub(vcs) {
|
|
1433
1449
|
return vcs && 'github' === vcs.host;
|
|
1434
1450
|
}
|
|
1435
1451
|
|
|
1436
|
-
async function
|
|
1437
|
-
if (await
|
|
1438
|
-
if (await
|
|
1452
|
+
async function liftProjectType({projectRoot, packageDetails, vcs}) {
|
|
1453
|
+
if (await projectIsPackage({packageDetails})) return liftPackage({projectRoot, packageDetails});
|
|
1454
|
+
if (await projectIsCli({packageDetails})) return liftCli({projectRoot, packageDetails});
|
|
1439
1455
|
|
|
1440
1456
|
let homepage;
|
|
1441
1457
|
|
|
@@ -1450,12 +1466,12 @@ async function lifter$2 ({projectRoot, packageDetails, vcs}) {
|
|
|
1450
1466
|
|
|
1451
1467
|
var projectTypes = /*#__PURE__*/Object.freeze({
|
|
1452
1468
|
__proto__: null,
|
|
1453
|
-
lift:
|
|
1469
|
+
lift: liftProjectType,
|
|
1454
1470
|
scaffold: scaffoldProjectType,
|
|
1455
|
-
test:
|
|
1471
|
+
test: isProjectType
|
|
1456
1472
|
});
|
|
1457
1473
|
|
|
1458
|
-
async function
|
|
1474
|
+
async function gatherProjectTypePluginInput({types, projectType, decisions}) {
|
|
1459
1475
|
if (!Object.keys(types).length) return 'Other';
|
|
1460
1476
|
|
|
1461
1477
|
const answers = await prompt$1([{
|
|
@@ -1468,7 +1484,7 @@ async function chooseProjectTypePlugin ({types, projectType, decisions}) {
|
|
|
1468
1484
|
return answers[questionNames$1.PROJECT_TYPE_CHOICE];
|
|
1469
1485
|
}
|
|
1470
1486
|
|
|
1471
|
-
async function scaffoldProjectTypePlugin
|
|
1487
|
+
async function scaffoldProjectTypePlugin({
|
|
1472
1488
|
projectRoot,
|
|
1473
1489
|
projectType,
|
|
1474
1490
|
projectName,
|
|
@@ -1484,7 +1500,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1484
1500
|
|
|
1485
1501
|
if (!pluginsForProjectType) return {};
|
|
1486
1502
|
|
|
1487
|
-
const chosenType = await
|
|
1503
|
+
const chosenType = await gatherProjectTypePluginInput({types: pluginsForProjectType, decisions, projectType});
|
|
1488
1504
|
|
|
1489
1505
|
return scaffoldChoice(
|
|
1490
1506
|
pluginsForProjectType,
|
|
@@ -1493,7 +1509,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1493
1509
|
);
|
|
1494
1510
|
}
|
|
1495
1511
|
|
|
1496
|
-
async function scaffoldTesting
|
|
1512
|
+
async function scaffoldTesting({
|
|
1497
1513
|
projectRoot,
|
|
1498
1514
|
visibility,
|
|
1499
1515
|
tests: {unit, integration},
|
|
@@ -1521,7 +1537,7 @@ async function scaffoldTesting ({
|
|
|
1521
1537
|
);
|
|
1522
1538
|
}
|
|
1523
1539
|
|
|
1524
|
-
function
|
|
1540
|
+
function buildAllowedHosts({packageManager, registries = {}}) {
|
|
1525
1541
|
return [
|
|
1526
1542
|
...!registries.registry ? [packageManager] : [],
|
|
1527
1543
|
...Object.values(Object.fromEntries(Object.entries(registries).filter(([scope]) => 'publish' !== scope)))
|
|
@@ -1534,7 +1550,7 @@ function lockfileLintSupports(packageManager) {
|
|
|
1534
1550
|
return lockfileLintSupportedPackageManagers.includes(packageManager);
|
|
1535
1551
|
}
|
|
1536
1552
|
|
|
1537
|
-
async function scaffoldLockfileLint
|
|
1553
|
+
async function scaffoldLockfileLint({projectRoot, packageManager, registries}) {
|
|
1538
1554
|
if (!lockfileLintSupports(packageManager)) {
|
|
1539
1555
|
throw new Error(
|
|
1540
1556
|
`The ${packageManager} package manager is currently not supported by lockfile-lint. `
|
|
@@ -1542,15 +1558,15 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1542
1558
|
);
|
|
1543
1559
|
}
|
|
1544
1560
|
|
|
1545
|
-
await write$
|
|
1561
|
+
await write$1({
|
|
1546
1562
|
name: 'lockfile-lint',
|
|
1547
1563
|
format: fileTypes.JSON,
|
|
1548
1564
|
path: projectRoot,
|
|
1549
1565
|
config: {
|
|
1550
|
-
path:
|
|
1566
|
+
path: resolveLockfilePath(packageManager),
|
|
1551
1567
|
type: packageManager,
|
|
1552
1568
|
'validate-https': true,
|
|
1553
|
-
'allowed-hosts':
|
|
1569
|
+
'allowed-hosts': buildAllowedHosts({packageManager, registries})
|
|
1554
1570
|
}
|
|
1555
1571
|
});
|
|
1556
1572
|
|
|
@@ -1560,7 +1576,7 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1560
1576
|
};
|
|
1561
1577
|
}
|
|
1562
1578
|
|
|
1563
|
-
function
|
|
1579
|
+
function lockfileLintInUse({projectRoot}) {
|
|
1564
1580
|
return fileExists(`${projectRoot}/.lockfile-lintrc.json`);
|
|
1565
1581
|
}
|
|
1566
1582
|
|
|
@@ -1571,10 +1587,10 @@ function read({projectRoot}) {
|
|
|
1571
1587
|
}
|
|
1572
1588
|
|
|
1573
1589
|
function write({projectRoot, config}) {
|
|
1574
|
-
return write$
|
|
1590
|
+
return write$1({name: configName, format: fileTypes.JSON, path: projectRoot, config});
|
|
1575
1591
|
}
|
|
1576
1592
|
|
|
1577
|
-
async function scaffoldLinting
|
|
1593
|
+
async function scaffoldLinting({projectRoot, packageManager, registries}) {
|
|
1578
1594
|
return scaffoldLockfileLint({projectRoot, packageManager, registries});
|
|
1579
1595
|
}
|
|
1580
1596
|
|
|
@@ -1608,8 +1624,8 @@ async function scaffoldVerification({
|
|
|
1608
1624
|
return deepmerge.all([testingResults, lintingResults, huskyResults]);
|
|
1609
1625
|
}
|
|
1610
1626
|
|
|
1611
|
-
async function scaffoldRemark
|
|
1612
|
-
await write$
|
|
1627
|
+
async function scaffoldRemark({config, projectRoot, projectType, vcs}) {
|
|
1628
|
+
await write$1({
|
|
1613
1629
|
format: fileTypes.JSON,
|
|
1614
1630
|
path: projectRoot,
|
|
1615
1631
|
name: 'remark',
|
|
@@ -1642,7 +1658,7 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
|
1642
1658
|
);
|
|
1643
1659
|
}
|
|
1644
1660
|
|
|
1645
|
-
async function scaffoldCodeStyle
|
|
1661
|
+
async function scaffoldCodeStyle({
|
|
1646
1662
|
projectRoot,
|
|
1647
1663
|
projectType,
|
|
1648
1664
|
configs,
|
|
@@ -1663,22 +1679,22 @@ async function scaffoldCodeStyle ({
|
|
|
1663
1679
|
].filter(Boolean)));
|
|
1664
1680
|
}
|
|
1665
1681
|
|
|
1666
|
-
function
|
|
1682
|
+
function liftCodeStyle(options) {
|
|
1667
1683
|
return applyEnhancers({options, enhancers: [eslintPlugin]});
|
|
1668
1684
|
}
|
|
1669
1685
|
|
|
1670
|
-
function
|
|
1686
|
+
function codeStyleConfigured(options) {
|
|
1671
1687
|
return test$1(options);
|
|
1672
1688
|
}
|
|
1673
1689
|
|
|
1674
1690
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
1675
1691
|
__proto__: null,
|
|
1676
|
-
lift:
|
|
1692
|
+
lift: liftCodeStyle,
|
|
1677
1693
|
scaffold: scaffoldCodeStyle,
|
|
1678
|
-
test:
|
|
1694
|
+
test: codeStyleConfigured
|
|
1679
1695
|
});
|
|
1680
1696
|
|
|
1681
|
-
async function
|
|
1697
|
+
async function scaffoldJavascript(options) {
|
|
1682
1698
|
info('Initializing JavaScript project');
|
|
1683
1699
|
|
|
1684
1700
|
const {
|
|
@@ -1755,7 +1771,7 @@ async function scaffolder (options) {
|
|
|
1755
1771
|
});
|
|
1756
1772
|
const [nodeVersion, npmResults, dialectResults, codeStyleResults] = await Promise.all([
|
|
1757
1773
|
scaffoldNodeVersion({projectRoot, nodeVersionCategory}),
|
|
1758
|
-
|
|
1774
|
+
scaffoldNpmConfiguration({projectType, projectRoot}),
|
|
1759
1775
|
scaffoldDialect({
|
|
1760
1776
|
dialect,
|
|
1761
1777
|
configs,
|
|
@@ -1804,16 +1820,16 @@ async function scaffolder (options) {
|
|
|
1804
1820
|
...mergedContributions,
|
|
1805
1821
|
documentation: scaffoldDocumentation({projectTypeResults, packageManager}),
|
|
1806
1822
|
tags: projectTypeResults.tags,
|
|
1807
|
-
vcsIgnore:
|
|
1808
|
-
verificationCommand: `${
|
|
1823
|
+
vcsIgnore: buildIgnoreLists(mergedContributions.vcsIgnore),
|
|
1824
|
+
verificationCommand: `${scaffoldGenerationCommand(packageManager)} && ${packageManager} test`
|
|
1809
1825
|
};
|
|
1810
1826
|
}
|
|
1811
1827
|
|
|
1812
|
-
function
|
|
1828
|
+
function registriesAreInUse() {
|
|
1813
1829
|
return true;
|
|
1814
1830
|
}
|
|
1815
1831
|
|
|
1816
|
-
function
|
|
1832
|
+
function buildRegistriesList(registries = {}) {
|
|
1817
1833
|
return Object.entries(registries)
|
|
1818
1834
|
.filter(([scope]) => 'publish' !== scope)
|
|
1819
1835
|
.reduce((acc, [scope, url]) => {
|
|
@@ -1824,7 +1840,7 @@ function buildRegistriesConfig (registries = {}) {
|
|
|
1824
1840
|
}
|
|
1825
1841
|
|
|
1826
1842
|
async function updateRegistriesInNpmConfig(registries, projectRoot) {
|
|
1827
|
-
const registriesForNpmConfig =
|
|
1843
|
+
const registriesForNpmConfig = buildRegistriesList(registries);
|
|
1828
1844
|
|
|
1829
1845
|
await writeNpmConfig({
|
|
1830
1846
|
projectRoot,
|
|
@@ -1840,15 +1856,15 @@ async function updateRegistriesInLockfileLintConfig(projectRoot, packageManager,
|
|
|
1840
1856
|
projectRoot,
|
|
1841
1857
|
config: {
|
|
1842
1858
|
...await read({projectRoot}),
|
|
1843
|
-
'allowed-hosts':
|
|
1859
|
+
'allowed-hosts': buildAllowedHosts({packageManager, registries})
|
|
1844
1860
|
}
|
|
1845
1861
|
});
|
|
1846
1862
|
}
|
|
1847
1863
|
|
|
1848
|
-
async function
|
|
1864
|
+
async function liftRegistries({projectRoot, packageManager, configs: {registries}}) {
|
|
1849
1865
|
await updateRegistriesInNpmConfig(registries, projectRoot);
|
|
1850
1866
|
|
|
1851
|
-
if (!(await
|
|
1867
|
+
if (!(await lockfileLintInUse({projectRoot}))) {
|
|
1852
1868
|
return scaffoldLockfileLint({projectRoot, packageManager, registries});
|
|
1853
1869
|
}
|
|
1854
1870
|
|
|
@@ -1859,8 +1875,8 @@ async function lifter ({projectRoot, packageManager, configs: {registries}}) {
|
|
|
1859
1875
|
|
|
1860
1876
|
var registriesPlugin = /*#__PURE__*/Object.freeze({
|
|
1861
1877
|
__proto__: null,
|
|
1862
|
-
lift:
|
|
1863
|
-
test:
|
|
1878
|
+
lift: liftRegistries,
|
|
1879
|
+
test: registriesAreInUse
|
|
1864
1880
|
});
|
|
1865
1881
|
|
|
1866
1882
|
async function test({projectRoot}) {
|
|
@@ -1869,7 +1885,7 @@ async function test({projectRoot}) {
|
|
|
1869
1885
|
return !!engines?.node;
|
|
1870
1886
|
}
|
|
1871
1887
|
|
|
1872
|
-
async function lift
|
|
1888
|
+
async function lift({packageDetails: {name}}) {
|
|
1873
1889
|
return {
|
|
1874
1890
|
dependencies: {javascript: {development: ['ls-engines']}},
|
|
1875
1891
|
scripts: {'lint:engines': 'ls-engines'},
|
|
@@ -1879,15 +1895,22 @@ async function lift$1({packageDetails: {name}}) {
|
|
|
1879
1895
|
|
|
1880
1896
|
var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
1881
1897
|
__proto__: null,
|
|
1882
|
-
lift: lift
|
|
1898
|
+
lift: lift,
|
|
1883
1899
|
test: test
|
|
1884
1900
|
});
|
|
1885
1901
|
|
|
1886
|
-
async function
|
|
1902
|
+
async function liftJavaScript({
|
|
1903
|
+
projectRoot,
|
|
1904
|
+
vcs,
|
|
1905
|
+
results,
|
|
1906
|
+
pathWithinParent,
|
|
1907
|
+
enhancers = {},
|
|
1908
|
+
configs = {}
|
|
1909
|
+
}) {
|
|
1887
1910
|
info('Lifting JavaScript-specific details');
|
|
1888
1911
|
|
|
1889
1912
|
const [packageManager, packageContents] = await Promise.all([
|
|
1890
|
-
|
|
1913
|
+
resolveCurrentPackageManager({projectRoot, packageManager: results.packageManager}),
|
|
1891
1914
|
promises.readFile(`${projectRoot}/package.json`, 'utf8')
|
|
1892
1915
|
]);
|
|
1893
1916
|
|
|
@@ -1909,15 +1932,15 @@ async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {
|
|
|
1909
1932
|
options: {packageManager, projectRoot, vcs, packageDetails: JSON.parse(packageContents), configs}
|
|
1910
1933
|
});
|
|
1911
1934
|
|
|
1912
|
-
await
|
|
1935
|
+
await liftPackageJson(deepmerge.all([{projectRoot, packageManager, vcs, pathWithinParent}, enhancerResults]));
|
|
1913
1936
|
|
|
1914
1937
|
return enhancerResults;
|
|
1915
1938
|
}
|
|
1916
1939
|
|
|
1917
|
-
async function
|
|
1940
|
+
async function projectUsesJavaScript({projectRoot}) {
|
|
1918
1941
|
const [nvmFound, jsPackageManagerFound] = await Promise.all([
|
|
1919
|
-
|
|
1920
|
-
|
|
1942
|
+
nodeVersionMangerInUse({projectRoot}),
|
|
1943
|
+
packageManagerInUse({projectRoot})
|
|
1921
1944
|
]);
|
|
1922
1945
|
|
|
1923
1946
|
const jsProjectFound = nvmFound || jsPackageManagerFound;
|
|
@@ -1929,5 +1952,5 @@ async function tester ({projectRoot}) {
|
|
|
1929
1952
|
|
|
1930
1953
|
const questionNames = {...questionNames$2, ...questionNames$1};
|
|
1931
1954
|
|
|
1932
|
-
export { lift, questionNames,
|
|
1955
|
+
export { liftJavaScript as lift, questionNames, scaffoldJavascript as scaffold, scaffoldUnitTesting, projectUsesJavaScript as test };
|
|
1933
1956
|
//# sourceMappingURL=index.js.map
|