@form8ion/javascript 15.1.1 → 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 +180 -158
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
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$3 ({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
|
|
|
@@ -899,8 +912,8 @@ async function processDependencies({dependencies = {}, devDependencies, projectR
|
|
|
899
912
|
const {javascript: {production = [], development = [], remove: dependenciesToRemove = []} = {}} = dependencies;
|
|
900
913
|
|
|
901
914
|
try {
|
|
902
|
-
await
|
|
903
|
-
await
|
|
915
|
+
await installDependencies(production, PROD_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
916
|
+
await installDependencies(development, DEV_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
904
917
|
await removeDependencies({packageManager, dependencies: dependenciesToRemove});
|
|
905
918
|
} catch (e) {
|
|
906
919
|
error('Failed to update dependencies');
|
|
@@ -965,8 +978,8 @@ function compareScriptNames(a, b) {
|
|
|
965
978
|
const aStripped = stripPrefix(a);
|
|
966
979
|
const bStripped = stripPrefix(b);
|
|
967
980
|
|
|
968
|
-
const aKey = aStripped
|
|
969
|
-
const bKey = bStripped
|
|
981
|
+
const aKey = aStripped !== a ? aStripped : a;
|
|
982
|
+
const bKey = bStripped !== b ? bStripped : b;
|
|
970
983
|
|
|
971
984
|
return aKey.localeCompare(bKey);
|
|
972
985
|
}
|
|
@@ -1009,7 +1022,7 @@ async function liftPackageJson({
|
|
|
1009
1022
|
projectRoot,
|
|
1010
1023
|
config: sortProperties({
|
|
1011
1024
|
...existingPackageJsonContents,
|
|
1012
|
-
...
|
|
1025
|
+
...scaffoldVcsHostDetails(vcs, pathWithinParent),
|
|
1013
1026
|
scripts: liftedScripts,
|
|
1014
1027
|
...tags && {
|
|
1015
1028
|
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
@@ -1025,11 +1038,11 @@ async function liftPackageJson({
|
|
|
1025
1038
|
});
|
|
1026
1039
|
}
|
|
1027
1040
|
|
|
1028
|
-
function
|
|
1041
|
+
function mapProjectVisibility({projectVisibility}) {
|
|
1029
1042
|
return 'Public' === projectVisibility ? 'public' : 'restricted';
|
|
1030
1043
|
}
|
|
1031
1044
|
|
|
1032
|
-
function
|
|
1045
|
+
function scaffoldPublishableBadges(packageName, accessLevel) {
|
|
1033
1046
|
return {
|
|
1034
1047
|
consumer: {
|
|
1035
1048
|
...'public' === accessLevel && {
|
|
@@ -1044,7 +1057,7 @@ function defineBadges (packageName, accessLevel) {
|
|
|
1044
1057
|
};
|
|
1045
1058
|
}
|
|
1046
1059
|
|
|
1047
|
-
function
|
|
1060
|
+
function scaffoldSlsa({provenance}) {
|
|
1048
1061
|
{
|
|
1049
1062
|
return {
|
|
1050
1063
|
badges: {
|
|
@@ -1060,13 +1073,13 @@ function enhanceSlsa ({provenance}) {
|
|
|
1060
1073
|
}
|
|
1061
1074
|
}
|
|
1062
1075
|
|
|
1063
|
-
async function liftProvenance
|
|
1076
|
+
async function liftProvenance({projectRoot, packageDetails}) {
|
|
1064
1077
|
const {publishConfig: {access} = {}} = packageDetails;
|
|
1065
1078
|
|
|
1066
1079
|
if ('public' === access) {
|
|
1067
1080
|
await mergeIntoExistingPackageJson({projectRoot, config: {publishConfig: {provenance: true}}});
|
|
1068
1081
|
|
|
1069
|
-
return
|
|
1082
|
+
return scaffoldSlsa({provenance: true});
|
|
1070
1083
|
}
|
|
1071
1084
|
|
|
1072
1085
|
return {};
|
|
@@ -1084,14 +1097,14 @@ async function liftPublishable({projectRoot, packageDetails}) {
|
|
|
1084
1097
|
homepage,
|
|
1085
1098
|
dependencies: {javascript: {development: ['publint']}},
|
|
1086
1099
|
scripts: {'lint:publish': 'publint --strict'},
|
|
1087
|
-
badges:
|
|
1100
|
+
badges: scaffoldPublishableBadges(packageName, packageAccessLevel)
|
|
1088
1101
|
}
|
|
1089
1102
|
);
|
|
1090
1103
|
}
|
|
1091
1104
|
|
|
1092
|
-
async function scaffoldPublishable
|
|
1105
|
+
async function scaffoldPublishable({packageName, packageAccessLevel}) {
|
|
1093
1106
|
return {
|
|
1094
|
-
badges: await
|
|
1107
|
+
badges: await scaffoldPublishableBadges(packageName, packageAccessLevel)
|
|
1095
1108
|
};
|
|
1096
1109
|
}
|
|
1097
1110
|
|
|
@@ -1105,7 +1118,7 @@ function getInstallationCommand(packageManager) {
|
|
|
1105
1118
|
);
|
|
1106
1119
|
}
|
|
1107
1120
|
|
|
1108
|
-
function scaffoldPackageDocumentation
|
|
1121
|
+
function scaffoldPackageDocumentation({scope, packageName, packageManager, visibility, provideExample}) {
|
|
1109
1122
|
return {
|
|
1110
1123
|
usage: `### Installation
|
|
1111
1124
|
${'Private' === visibility ? `
|
|
@@ -1120,13 +1133,13 @@ $ ${getInstallationCommand(packageManager)} ${packageName}
|
|
|
1120
1133
|
|
|
1121
1134
|
### Example
|
|
1122
1135
|
|
|
1123
|
-
run \`${
|
|
1136
|
+
run \`${scaffoldGenerationCommand(packageManager)}\` to inject the usage example`
|
|
1124
1137
|
: ''
|
|
1125
1138
|
}`
|
|
1126
1139
|
};
|
|
1127
1140
|
}
|
|
1128
1141
|
|
|
1129
|
-
async function
|
|
1142
|
+
async function gatherBundlerInput({bundlers, decisions}) {
|
|
1130
1143
|
if (!Object.keys(bundlers).length) return 'Other';
|
|
1131
1144
|
|
|
1132
1145
|
const answers = await prompt$1([{
|
|
@@ -1139,8 +1152,8 @@ async function chooseBundler ({bundlers, decisions}) {
|
|
|
1139
1152
|
return answers[questionNames$1.PACKAGE_BUNDLER];
|
|
1140
1153
|
}
|
|
1141
1154
|
|
|
1142
|
-
async function scaffoldBundler
|
|
1143
|
-
const chosenBundler = await
|
|
1155
|
+
async function scaffoldBundler({projectRoot, projectType, bundlers, dialect, decisions}) {
|
|
1156
|
+
const chosenBundler = await gatherBundlerInput({bundlers, decisions});
|
|
1144
1157
|
|
|
1145
1158
|
return scaffoldChoice(bundlers, chosenBundler, {projectRoot, projectType, dialect});
|
|
1146
1159
|
}
|
|
@@ -1211,7 +1224,7 @@ async function scaffoldPackageProjectType({
|
|
|
1211
1224
|
}) {
|
|
1212
1225
|
info('Scaffolding Package Details');
|
|
1213
1226
|
|
|
1214
|
-
const packageAccessLevel =
|
|
1227
|
+
const packageAccessLevel = mapProjectVisibility({projectVisibility: visibility});
|
|
1215
1228
|
const [detailsForBuild, publishableResults] = await Promise.all([
|
|
1216
1229
|
buildDetails({
|
|
1217
1230
|
projectRoot,
|
|
@@ -1276,13 +1289,15 @@ function liftPackage({projectRoot, packageDetails}) {
|
|
|
1276
1289
|
return liftPublishable({projectRoot, packageDetails});
|
|
1277
1290
|
}
|
|
1278
1291
|
|
|
1279
|
-
async function
|
|
1292
|
+
async function projectIsPackage({
|
|
1293
|
+
packageDetails: {exports: exports$1, publishConfig, bin, private: projectMarkedPrivate}
|
|
1294
|
+
}) {
|
|
1280
1295
|
return !projectMarkedPrivate && (!!exports$1 || (!!publishConfig && !bin));
|
|
1281
1296
|
}
|
|
1282
1297
|
|
|
1283
1298
|
const defaultBuildDirectory$1 = 'public';
|
|
1284
1299
|
|
|
1285
|
-
async function
|
|
1300
|
+
async function scaffoldApplication({projectRoot}) {
|
|
1286
1301
|
info('Scaffolding Application Details');
|
|
1287
1302
|
|
|
1288
1303
|
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
@@ -1302,11 +1317,11 @@ async function scaffoldApplicationType ({projectRoot}) {
|
|
|
1302
1317
|
};
|
|
1303
1318
|
}
|
|
1304
1319
|
|
|
1305
|
-
function
|
|
1320
|
+
function projectIsApplication({packageDetails}) {
|
|
1306
1321
|
return !!packageDetails.private;
|
|
1307
1322
|
}
|
|
1308
1323
|
|
|
1309
|
-
async function
|
|
1324
|
+
async function scaffoldMonorepo({projectRoot}) {
|
|
1310
1325
|
info('Scaffolding Monorepo Details');
|
|
1311
1326
|
|
|
1312
1327
|
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
@@ -1331,7 +1346,7 @@ async function scaffoldCli({
|
|
|
1331
1346
|
decisions,
|
|
1332
1347
|
packageBundlers
|
|
1333
1348
|
}) {
|
|
1334
|
-
const packageAccessLevel =
|
|
1349
|
+
const packageAccessLevel = mapProjectVisibility({projectVisibility: visibility});
|
|
1335
1350
|
const [bundlerResults, publishableResults] = await Promise.all([
|
|
1336
1351
|
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType: projectTypes$1.CLI}),
|
|
1337
1352
|
scaffoldPublishable({packageName, packageAccessLevel}),
|
|
@@ -1366,7 +1381,7 @@ async function scaffoldCli({
|
|
|
1366
1381
|
]);
|
|
1367
1382
|
}
|
|
1368
1383
|
|
|
1369
|
-
async function
|
|
1384
|
+
async function projectIsCli({packageDetails: {bin}}) {
|
|
1370
1385
|
return !!bin;
|
|
1371
1386
|
}
|
|
1372
1387
|
|
|
@@ -1374,7 +1389,7 @@ function liftCli({projectRoot, packageDetails}) {
|
|
|
1374
1389
|
return liftPublishable({projectRoot, packageDetails});
|
|
1375
1390
|
}
|
|
1376
1391
|
|
|
1377
|
-
async function scaffoldProjectType
|
|
1392
|
+
async function scaffoldProjectType({
|
|
1378
1393
|
projectType,
|
|
1379
1394
|
projectRoot,
|
|
1380
1395
|
projectName,
|
|
@@ -1404,7 +1419,7 @@ async function scaffoldProjectType ({
|
|
|
1404
1419
|
publishRegistry
|
|
1405
1420
|
});
|
|
1406
1421
|
case projectTypes$1.APPLICATION:
|
|
1407
|
-
return
|
|
1422
|
+
return scaffoldApplication({projectRoot});
|
|
1408
1423
|
case projectTypes$1.CLI:
|
|
1409
1424
|
return scaffoldCli({
|
|
1410
1425
|
packageName,
|
|
@@ -1416,7 +1431,7 @@ async function scaffoldProjectType ({
|
|
|
1416
1431
|
packageBundlers
|
|
1417
1432
|
});
|
|
1418
1433
|
case projectTypes$1.MONOREPO:
|
|
1419
|
-
return
|
|
1434
|
+
return scaffoldMonorepo({projectRoot});
|
|
1420
1435
|
case 'Other':
|
|
1421
1436
|
return {};
|
|
1422
1437
|
default:
|
|
@@ -1424,10 +1439,10 @@ async function scaffoldProjectType ({
|
|
|
1424
1439
|
}
|
|
1425
1440
|
}
|
|
1426
1441
|
|
|
1427
|
-
async function
|
|
1428
|
-
return await
|
|
1429
|
-
|| await
|
|
1430
|
-
||
|
|
1442
|
+
async function isProjectType({projectRoot, packageDetails}) {
|
|
1443
|
+
return await projectIsPackage({packageDetails})
|
|
1444
|
+
|| await projectIsCli({packageDetails})
|
|
1445
|
+
|| projectIsApplication({packageDetails});
|
|
1431
1446
|
}
|
|
1432
1447
|
|
|
1433
1448
|
function vcsRepositoryHostedOnGithub(vcs) {
|
|
@@ -1435,8 +1450,8 @@ function vcsRepositoryHostedOnGithub(vcs) {
|
|
|
1435
1450
|
}
|
|
1436
1451
|
|
|
1437
1452
|
async function liftProjectType({projectRoot, packageDetails, vcs}) {
|
|
1438
|
-
if (await
|
|
1439
|
-
if (await
|
|
1453
|
+
if (await projectIsPackage({packageDetails})) return liftPackage({projectRoot, packageDetails});
|
|
1454
|
+
if (await projectIsCli({packageDetails})) return liftCli({projectRoot, packageDetails});
|
|
1440
1455
|
|
|
1441
1456
|
let homepage;
|
|
1442
1457
|
|
|
@@ -1453,10 +1468,10 @@ var projectTypes = /*#__PURE__*/Object.freeze({
|
|
|
1453
1468
|
__proto__: null,
|
|
1454
1469
|
lift: liftProjectType,
|
|
1455
1470
|
scaffold: scaffoldProjectType,
|
|
1456
|
-
test:
|
|
1471
|
+
test: isProjectType
|
|
1457
1472
|
});
|
|
1458
1473
|
|
|
1459
|
-
async function
|
|
1474
|
+
async function gatherProjectTypePluginInput({types, projectType, decisions}) {
|
|
1460
1475
|
if (!Object.keys(types).length) return 'Other';
|
|
1461
1476
|
|
|
1462
1477
|
const answers = await prompt$1([{
|
|
@@ -1469,7 +1484,7 @@ async function chooseProjectTypePlugin ({types, projectType, decisions}) {
|
|
|
1469
1484
|
return answers[questionNames$1.PROJECT_TYPE_CHOICE];
|
|
1470
1485
|
}
|
|
1471
1486
|
|
|
1472
|
-
async function scaffoldProjectTypePlugin
|
|
1487
|
+
async function scaffoldProjectTypePlugin({
|
|
1473
1488
|
projectRoot,
|
|
1474
1489
|
projectType,
|
|
1475
1490
|
projectName,
|
|
@@ -1485,7 +1500,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1485
1500
|
|
|
1486
1501
|
if (!pluginsForProjectType) return {};
|
|
1487
1502
|
|
|
1488
|
-
const chosenType = await
|
|
1503
|
+
const chosenType = await gatherProjectTypePluginInput({types: pluginsForProjectType, decisions, projectType});
|
|
1489
1504
|
|
|
1490
1505
|
return scaffoldChoice(
|
|
1491
1506
|
pluginsForProjectType,
|
|
@@ -1494,7 +1509,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1494
1509
|
);
|
|
1495
1510
|
}
|
|
1496
1511
|
|
|
1497
|
-
async function scaffoldTesting
|
|
1512
|
+
async function scaffoldTesting({
|
|
1498
1513
|
projectRoot,
|
|
1499
1514
|
visibility,
|
|
1500
1515
|
tests: {unit, integration},
|
|
@@ -1522,7 +1537,7 @@ async function scaffoldTesting ({
|
|
|
1522
1537
|
);
|
|
1523
1538
|
}
|
|
1524
1539
|
|
|
1525
|
-
function
|
|
1540
|
+
function buildAllowedHosts({packageManager, registries = {}}) {
|
|
1526
1541
|
return [
|
|
1527
1542
|
...!registries.registry ? [packageManager] : [],
|
|
1528
1543
|
...Object.values(Object.fromEntries(Object.entries(registries).filter(([scope]) => 'publish' !== scope)))
|
|
@@ -1535,7 +1550,7 @@ function lockfileLintSupports(packageManager) {
|
|
|
1535
1550
|
return lockfileLintSupportedPackageManagers.includes(packageManager);
|
|
1536
1551
|
}
|
|
1537
1552
|
|
|
1538
|
-
async function scaffoldLockfileLint
|
|
1553
|
+
async function scaffoldLockfileLint({projectRoot, packageManager, registries}) {
|
|
1539
1554
|
if (!lockfileLintSupports(packageManager)) {
|
|
1540
1555
|
throw new Error(
|
|
1541
1556
|
`The ${packageManager} package manager is currently not supported by lockfile-lint. `
|
|
@@ -1543,15 +1558,15 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1543
1558
|
);
|
|
1544
1559
|
}
|
|
1545
1560
|
|
|
1546
|
-
await write$
|
|
1561
|
+
await write$1({
|
|
1547
1562
|
name: 'lockfile-lint',
|
|
1548
1563
|
format: fileTypes.JSON,
|
|
1549
1564
|
path: projectRoot,
|
|
1550
1565
|
config: {
|
|
1551
|
-
path:
|
|
1566
|
+
path: resolveLockfilePath(packageManager),
|
|
1552
1567
|
type: packageManager,
|
|
1553
1568
|
'validate-https': true,
|
|
1554
|
-
'allowed-hosts':
|
|
1569
|
+
'allowed-hosts': buildAllowedHosts({packageManager, registries})
|
|
1555
1570
|
}
|
|
1556
1571
|
});
|
|
1557
1572
|
|
|
@@ -1561,7 +1576,7 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1561
1576
|
};
|
|
1562
1577
|
}
|
|
1563
1578
|
|
|
1564
|
-
function
|
|
1579
|
+
function lockfileLintInUse({projectRoot}) {
|
|
1565
1580
|
return fileExists(`${projectRoot}/.lockfile-lintrc.json`);
|
|
1566
1581
|
}
|
|
1567
1582
|
|
|
@@ -1572,10 +1587,10 @@ function read({projectRoot}) {
|
|
|
1572
1587
|
}
|
|
1573
1588
|
|
|
1574
1589
|
function write({projectRoot, config}) {
|
|
1575
|
-
return write$
|
|
1590
|
+
return write$1({name: configName, format: fileTypes.JSON, path: projectRoot, config});
|
|
1576
1591
|
}
|
|
1577
1592
|
|
|
1578
|
-
async function scaffoldLinting
|
|
1593
|
+
async function scaffoldLinting({projectRoot, packageManager, registries}) {
|
|
1579
1594
|
return scaffoldLockfileLint({projectRoot, packageManager, registries});
|
|
1580
1595
|
}
|
|
1581
1596
|
|
|
@@ -1609,8 +1624,8 @@ async function scaffoldVerification({
|
|
|
1609
1624
|
return deepmerge.all([testingResults, lintingResults, huskyResults]);
|
|
1610
1625
|
}
|
|
1611
1626
|
|
|
1612
|
-
async function scaffoldRemark
|
|
1613
|
-
await write$
|
|
1627
|
+
async function scaffoldRemark({config, projectRoot, projectType, vcs}) {
|
|
1628
|
+
await write$1({
|
|
1614
1629
|
format: fileTypes.JSON,
|
|
1615
1630
|
path: projectRoot,
|
|
1616
1631
|
name: 'remark',
|
|
@@ -1643,7 +1658,7 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
|
1643
1658
|
);
|
|
1644
1659
|
}
|
|
1645
1660
|
|
|
1646
|
-
async function scaffoldCodeStyle
|
|
1661
|
+
async function scaffoldCodeStyle({
|
|
1647
1662
|
projectRoot,
|
|
1648
1663
|
projectType,
|
|
1649
1664
|
configs,
|
|
@@ -1664,22 +1679,22 @@ async function scaffoldCodeStyle ({
|
|
|
1664
1679
|
].filter(Boolean)));
|
|
1665
1680
|
}
|
|
1666
1681
|
|
|
1667
|
-
function
|
|
1682
|
+
function liftCodeStyle(options) {
|
|
1668
1683
|
return applyEnhancers({options, enhancers: [eslintPlugin]});
|
|
1669
1684
|
}
|
|
1670
1685
|
|
|
1671
|
-
function
|
|
1686
|
+
function codeStyleConfigured(options) {
|
|
1672
1687
|
return test$1(options);
|
|
1673
1688
|
}
|
|
1674
1689
|
|
|
1675
1690
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
1676
1691
|
__proto__: null,
|
|
1677
|
-
lift:
|
|
1692
|
+
lift: liftCodeStyle,
|
|
1678
1693
|
scaffold: scaffoldCodeStyle,
|
|
1679
|
-
test:
|
|
1694
|
+
test: codeStyleConfigured
|
|
1680
1695
|
});
|
|
1681
1696
|
|
|
1682
|
-
async function
|
|
1697
|
+
async function scaffoldJavascript(options) {
|
|
1683
1698
|
info('Initializing JavaScript project');
|
|
1684
1699
|
|
|
1685
1700
|
const {
|
|
@@ -1756,7 +1771,7 @@ async function scaffolder (options) {
|
|
|
1756
1771
|
});
|
|
1757
1772
|
const [nodeVersion, npmResults, dialectResults, codeStyleResults] = await Promise.all([
|
|
1758
1773
|
scaffoldNodeVersion({projectRoot, nodeVersionCategory}),
|
|
1759
|
-
|
|
1774
|
+
scaffoldNpmConfiguration({projectType, projectRoot}),
|
|
1760
1775
|
scaffoldDialect({
|
|
1761
1776
|
dialect,
|
|
1762
1777
|
configs,
|
|
@@ -1805,16 +1820,16 @@ async function scaffolder (options) {
|
|
|
1805
1820
|
...mergedContributions,
|
|
1806
1821
|
documentation: scaffoldDocumentation({projectTypeResults, packageManager}),
|
|
1807
1822
|
tags: projectTypeResults.tags,
|
|
1808
|
-
vcsIgnore:
|
|
1809
|
-
verificationCommand: `${
|
|
1823
|
+
vcsIgnore: buildIgnoreLists(mergedContributions.vcsIgnore),
|
|
1824
|
+
verificationCommand: `${scaffoldGenerationCommand(packageManager)} && ${packageManager} test`
|
|
1810
1825
|
};
|
|
1811
1826
|
}
|
|
1812
1827
|
|
|
1813
|
-
function
|
|
1828
|
+
function registriesAreInUse() {
|
|
1814
1829
|
return true;
|
|
1815
1830
|
}
|
|
1816
1831
|
|
|
1817
|
-
function
|
|
1832
|
+
function buildRegistriesList(registries = {}) {
|
|
1818
1833
|
return Object.entries(registries)
|
|
1819
1834
|
.filter(([scope]) => 'publish' !== scope)
|
|
1820
1835
|
.reduce((acc, [scope, url]) => {
|
|
@@ -1825,7 +1840,7 @@ function buildRegistriesConfig (registries = {}) {
|
|
|
1825
1840
|
}
|
|
1826
1841
|
|
|
1827
1842
|
async function updateRegistriesInNpmConfig(registries, projectRoot) {
|
|
1828
|
-
const registriesForNpmConfig =
|
|
1843
|
+
const registriesForNpmConfig = buildRegistriesList(registries);
|
|
1829
1844
|
|
|
1830
1845
|
await writeNpmConfig({
|
|
1831
1846
|
projectRoot,
|
|
@@ -1841,15 +1856,15 @@ async function updateRegistriesInLockfileLintConfig(projectRoot, packageManager,
|
|
|
1841
1856
|
projectRoot,
|
|
1842
1857
|
config: {
|
|
1843
1858
|
...await read({projectRoot}),
|
|
1844
|
-
'allowed-hosts':
|
|
1859
|
+
'allowed-hosts': buildAllowedHosts({packageManager, registries})
|
|
1845
1860
|
}
|
|
1846
1861
|
});
|
|
1847
1862
|
}
|
|
1848
1863
|
|
|
1849
|
-
async function
|
|
1864
|
+
async function liftRegistries({projectRoot, packageManager, configs: {registries}}) {
|
|
1850
1865
|
await updateRegistriesInNpmConfig(registries, projectRoot);
|
|
1851
1866
|
|
|
1852
|
-
if (!(await
|
|
1867
|
+
if (!(await lockfileLintInUse({projectRoot}))) {
|
|
1853
1868
|
return scaffoldLockfileLint({projectRoot, packageManager, registries});
|
|
1854
1869
|
}
|
|
1855
1870
|
|
|
@@ -1860,8 +1875,8 @@ async function lifter ({projectRoot, packageManager, configs: {registries}}) {
|
|
|
1860
1875
|
|
|
1861
1876
|
var registriesPlugin = /*#__PURE__*/Object.freeze({
|
|
1862
1877
|
__proto__: null,
|
|
1863
|
-
lift:
|
|
1864
|
-
test:
|
|
1878
|
+
lift: liftRegistries,
|
|
1879
|
+
test: registriesAreInUse
|
|
1865
1880
|
});
|
|
1866
1881
|
|
|
1867
1882
|
async function test({projectRoot}) {
|
|
@@ -1870,7 +1885,7 @@ async function test({projectRoot}) {
|
|
|
1870
1885
|
return !!engines?.node;
|
|
1871
1886
|
}
|
|
1872
1887
|
|
|
1873
|
-
async function lift
|
|
1888
|
+
async function lift({packageDetails: {name}}) {
|
|
1874
1889
|
return {
|
|
1875
1890
|
dependencies: {javascript: {development: ['ls-engines']}},
|
|
1876
1891
|
scripts: {'lint:engines': 'ls-engines'},
|
|
@@ -1880,15 +1895,22 @@ async function lift$1({packageDetails: {name}}) {
|
|
|
1880
1895
|
|
|
1881
1896
|
var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
1882
1897
|
__proto__: null,
|
|
1883
|
-
lift: lift
|
|
1898
|
+
lift: lift,
|
|
1884
1899
|
test: test
|
|
1885
1900
|
});
|
|
1886
1901
|
|
|
1887
|
-
async function
|
|
1902
|
+
async function liftJavaScript({
|
|
1903
|
+
projectRoot,
|
|
1904
|
+
vcs,
|
|
1905
|
+
results,
|
|
1906
|
+
pathWithinParent,
|
|
1907
|
+
enhancers = {},
|
|
1908
|
+
configs = {}
|
|
1909
|
+
}) {
|
|
1888
1910
|
info('Lifting JavaScript-specific details');
|
|
1889
1911
|
|
|
1890
1912
|
const [packageManager, packageContents] = await Promise.all([
|
|
1891
|
-
|
|
1913
|
+
resolveCurrentPackageManager({projectRoot, packageManager: results.packageManager}),
|
|
1892
1914
|
promises.readFile(`${projectRoot}/package.json`, 'utf8')
|
|
1893
1915
|
]);
|
|
1894
1916
|
|
|
@@ -1915,10 +1937,10 @@ async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {
|
|
|
1915
1937
|
return enhancerResults;
|
|
1916
1938
|
}
|
|
1917
1939
|
|
|
1918
|
-
async function
|
|
1940
|
+
async function projectUsesJavaScript({projectRoot}) {
|
|
1919
1941
|
const [nvmFound, jsPackageManagerFound] = await Promise.all([
|
|
1920
|
-
|
|
1921
|
-
|
|
1942
|
+
nodeVersionMangerInUse({projectRoot}),
|
|
1943
|
+
packageManagerInUse({projectRoot})
|
|
1922
1944
|
]);
|
|
1923
1945
|
|
|
1924
1946
|
const jsProjectFound = nvmFound || jsPackageManagerFound;
|
|
@@ -1930,5 +1952,5 @@ async function tester ({projectRoot}) {
|
|
|
1930
1952
|
|
|
1931
1953
|
const questionNames = {...questionNames$2, ...questionNames$1};
|
|
1932
1954
|
|
|
1933
|
-
export { lift, questionNames,
|
|
1955
|
+
export { liftJavaScript as lift, questionNames, scaffoldJavascript as scaffold, scaffoldUnitTesting, projectUsesJavaScript as test };
|
|
1934
1956
|
//# sourceMappingURL=index.js.map
|