@form8ion/javascript 15.1.1 → 15.1.3
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 +190 -189
- package/lib/index.js.map +1 -1
- package/package.json +6 -5
package/lib/index.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
|
-
import {
|
|
3
|
+
import { fileExists, optionsSchemas, validateOptions, fileTypes, loadConfigFile, writeConfigFile, applyEnhancers } from '@form8ion/core';
|
|
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 {
|
|
7
|
+
import { scaffold as scaffold$1, lift as lift$2 } from '@form8ion/codecov';
|
|
8
|
+
import { scaffold, test as test$1 } from '@form8ion/c8';
|
|
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';
|
|
12
|
-
import { scaffold as scaffold$
|
|
12
|
+
import { scaffold as scaffold$2 } from '@form8ion/husky';
|
|
13
13
|
import * as commitConventionPlugin from '@form8ion/commit-convention';
|
|
14
|
-
import { scaffold as scaffold$
|
|
14
|
+
import { scaffold as scaffold$5 } from '@form8ion/commit-convention';
|
|
15
|
+
import { write as write$1 } from '@form8ion/config-file';
|
|
15
16
|
import { stringify, parse } from 'ini';
|
|
16
|
-
import { scaffold as scaffold$
|
|
17
|
+
import { scaffold as scaffold$4 } from '@form8ion/prettier';
|
|
17
18
|
import * as eslintPlugin from '@form8ion/eslint';
|
|
18
|
-
import { scaffold as scaffold$
|
|
19
|
+
import { scaffold as scaffold$3, test as test$2 } from '@form8ion/eslint';
|
|
19
20
|
import { promises as promises$1 } from 'fs';
|
|
20
21
|
import touch from 'touch';
|
|
21
22
|
import { execa } from 'execa';
|
|
@@ -42,33 +43,15 @@ const questionNames$1 = {
|
|
|
42
43
|
DIALECT: 'dialect'
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
async function
|
|
46
|
-
await
|
|
47
|
-
name: 'c8',
|
|
48
|
-
format: fileTypes.JSON,
|
|
49
|
-
path: projectRoot,
|
|
50
|
-
config: {
|
|
51
|
-
reporter: ['lcov', 'text-summary', 'html'],
|
|
52
|
-
exclude: ['src/**/*-test.js', 'test/', 'thirdparty-wrappers/', 'vendor/']
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
dependencies: {javascript: {development: ['cross-env', 'c8']}},
|
|
58
|
-
vcsIgnore: {files: [], directories: ['/coverage/']},
|
|
59
|
-
eslint: {ignore: {directories: ['/coverage/']}}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function scaffoldCoverage ({projectRoot, vcs, visibility, pathWithinParent}) {
|
|
64
|
-
return deepmerge(await scaffoldC8({projectRoot}), await scaffold({vcs, visibility, pathWithinParent}));
|
|
46
|
+
async function scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent}) {
|
|
47
|
+
return deepmerge(await scaffold({projectRoot}), await scaffold$1({vcs, visibility, pathWithinParent}));
|
|
65
48
|
}
|
|
66
49
|
|
|
67
|
-
function
|
|
50
|
+
function nyvInUse({projectRoot}) {
|
|
68
51
|
return fileExists(`${projectRoot}/.nycrc`);
|
|
69
52
|
}
|
|
70
53
|
|
|
71
|
-
async function removeNyc
|
|
54
|
+
async function removeNyc({projectRoot}) {
|
|
72
55
|
await Promise.all([
|
|
73
56
|
promises.unlink(`${projectRoot}/.nycrc`),
|
|
74
57
|
promises.rm(`${projectRoot}/.nyc_output`, {recursive: true, force: true})
|
|
@@ -83,12 +66,12 @@ async function removeNyc ({projectRoot}) {
|
|
|
83
66
|
};
|
|
84
67
|
}
|
|
85
68
|
|
|
86
|
-
async function lift$
|
|
87
|
-
const codecovResults = await lift$
|
|
69
|
+
async function lift$1({projectRoot, packageManager, vcs}) {
|
|
70
|
+
const codecovResults = await lift$2({projectRoot, packageManager, vcs});
|
|
88
71
|
|
|
89
|
-
if (await
|
|
72
|
+
if (await nyvInUse({projectRoot})) {
|
|
90
73
|
const [c8Results, nycResults] = await Promise.all([
|
|
91
|
-
|
|
74
|
+
scaffold({projectRoot}),
|
|
92
75
|
removeNyc({projectRoot})
|
|
93
76
|
]);
|
|
94
77
|
|
|
@@ -109,24 +92,20 @@ async function lift$2({projectRoot, packageManager, vcs}) {
|
|
|
109
92
|
return codecovResults;
|
|
110
93
|
}
|
|
111
94
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function tester$5 ({projectRoot}) {
|
|
117
|
-
const [c8Exists, nycExists] = await Promise.all([c8IsConfigured({projectRoot}), nycIsConfigured({projectRoot})]);
|
|
95
|
+
async function testCoverageBeingCollected({projectRoot}) {
|
|
96
|
+
const [c8Exists, nycExists] = await Promise.all([test$1({projectRoot}), nyvInUse({projectRoot})]);
|
|
118
97
|
|
|
119
98
|
return c8Exists || nycExists;
|
|
120
99
|
}
|
|
121
100
|
|
|
122
101
|
var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
123
102
|
__proto__: null,
|
|
124
|
-
lift: lift$
|
|
103
|
+
lift: lift$1,
|
|
125
104
|
scaffold: scaffoldCoverage,
|
|
126
|
-
test:
|
|
105
|
+
test: testCoverageBeingCollected
|
|
127
106
|
});
|
|
128
107
|
|
|
129
|
-
async function
|
|
108
|
+
async function gatherUnitTestingInput({frameworks, decisions}) {
|
|
130
109
|
if (!Object.keys(frameworks).length) return 'Other';
|
|
131
110
|
|
|
132
111
|
const answers = await prompt$1([{
|
|
@@ -141,10 +120,18 @@ async function chooseFramework ({frameworks, decisions}) {
|
|
|
141
120
|
|
|
142
121
|
const pluginsSchema = joi.object().pattern(/^/, optionsSchemas.form8ionPlugin).default({});
|
|
143
122
|
|
|
144
|
-
async function scaffoldUnitTesting
|
|
123
|
+
async function scaffoldUnitTesting({
|
|
124
|
+
projectRoot,
|
|
125
|
+
frameworks,
|
|
126
|
+
decisions,
|
|
127
|
+
visibility,
|
|
128
|
+
vcs,
|
|
129
|
+
pathWithinParent,
|
|
130
|
+
dialect
|
|
131
|
+
}) {
|
|
145
132
|
const validatedFrameworks = validateOptions(pluginsSchema, frameworks);
|
|
146
133
|
const [framework, coverage] = await Promise.all([
|
|
147
|
-
|
|
134
|
+
gatherUnitTestingInput({frameworks: validatedFrameworks, decisions})
|
|
148
135
|
.then(chosenFramework => scaffoldChoice(validatedFrameworks, chosenFramework, {projectRoot, dialect})),
|
|
149
136
|
scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent})
|
|
150
137
|
]);
|
|
@@ -208,7 +195,7 @@ function validate(options) {
|
|
|
208
195
|
return validateOptions(schema, options);
|
|
209
196
|
}
|
|
210
197
|
|
|
211
|
-
function
|
|
198
|
+
function gatherDialectInput({babelPreset, typescript}) {
|
|
212
199
|
return [
|
|
213
200
|
{name: 'Common JS (no transpilation)', value: dialects$1.COMMON_JS, short: 'cjs'},
|
|
214
201
|
...babelPreset ? [{name: 'Modern JavaScript (transpiled)', value: dialects$1.BABEL, short: 'modern'}] : [],
|
|
@@ -221,11 +208,11 @@ function projectIsCLI(answers) {
|
|
|
221
208
|
return projectTypes$1.CLI === answers[questionNames$1.PROJECT_TYPE];
|
|
222
209
|
}
|
|
223
210
|
|
|
224
|
-
function projectIsPackage(answers) {
|
|
211
|
+
function projectIsPackage$1(answers) {
|
|
225
212
|
return projectTypes$1.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
226
213
|
}
|
|
227
214
|
|
|
228
|
-
function projectIsApplication(answers) {
|
|
215
|
+
function projectIsApplication$1(answers) {
|
|
229
216
|
return projectTypes$1.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
|
|
230
217
|
}
|
|
231
218
|
|
|
@@ -234,7 +221,7 @@ function packageShouldBeScoped(visibility, answers) {
|
|
|
234
221
|
}
|
|
235
222
|
|
|
236
223
|
function willBePublishedToNpm(answers) {
|
|
237
|
-
return projectIsPackage(answers) || projectIsCLI(answers);
|
|
224
|
+
return projectIsPackage$1(answers) || projectIsCLI(answers);
|
|
238
225
|
}
|
|
239
226
|
|
|
240
227
|
function shouldBeScopedPromptShouldBePresented(answers) {
|
|
@@ -323,7 +310,7 @@ async function prompt(
|
|
|
323
310
|
name: questionNames$1.DIALECT,
|
|
324
311
|
message: 'Which JavaScript dialect should this project follow?',
|
|
325
312
|
type: 'list',
|
|
326
|
-
choices:
|
|
313
|
+
choices: gatherDialectInput(configs),
|
|
327
314
|
default: 'babel'
|
|
328
315
|
},
|
|
329
316
|
...pathWithinParent ? [] : [{
|
|
@@ -377,13 +364,13 @@ async function prompt(
|
|
|
377
364
|
name: questionNames$1.PROVIDE_EXAMPLE,
|
|
378
365
|
message: 'Should an example be provided in the README?',
|
|
379
366
|
type: 'confirm',
|
|
380
|
-
when: projectIsPackage
|
|
367
|
+
when: projectIsPackage$1
|
|
381
368
|
},
|
|
382
369
|
{
|
|
383
370
|
name: questionNames$1.HOST,
|
|
384
371
|
type: 'list',
|
|
385
372
|
message: 'Where will the application be hosted?',
|
|
386
|
-
when: projectIsApplication,
|
|
373
|
+
when: projectIsApplication$1,
|
|
387
374
|
choices: [...Object.keys(hosts), 'Other']
|
|
388
375
|
}
|
|
389
376
|
], decisions);
|
|
@@ -403,28 +390,28 @@ async function prompt(
|
|
|
403
390
|
};
|
|
404
391
|
}
|
|
405
392
|
|
|
406
|
-
function
|
|
407
|
-
return write$
|
|
393
|
+
function writeBabelConfig({projectRoot, config}) {
|
|
394
|
+
return write$1({path: projectRoot, name: 'babel', format: fileTypes.JSON, config});
|
|
408
395
|
}
|
|
409
396
|
|
|
410
|
-
function
|
|
397
|
+
function loadBabelConfig({projectRoot}) {
|
|
411
398
|
return loadConfigFile({path: projectRoot, name: '.babelrc', format: fileTypes.JSON});
|
|
412
399
|
}
|
|
413
400
|
|
|
414
|
-
async function
|
|
401
|
+
async function addIgnores({projectRoot, ignore}) {
|
|
415
402
|
if (ignore) {
|
|
416
|
-
const existingConfig = await
|
|
403
|
+
const existingConfig = await loadBabelConfig({projectRoot});
|
|
417
404
|
|
|
418
|
-
await
|
|
405
|
+
await writeBabelConfig({projectRoot, config: {...existingConfig, ignore: [`./${ignore}/`]}});
|
|
419
406
|
}
|
|
420
407
|
}
|
|
421
408
|
|
|
422
|
-
async function scaffoldBabel
|
|
409
|
+
async function scaffoldBabel({projectRoot, preset}) {
|
|
423
410
|
if (!preset) {
|
|
424
411
|
throw new Error('No babel preset provided. Cannot configure babel transpilation');
|
|
425
412
|
}
|
|
426
413
|
|
|
427
|
-
await
|
|
414
|
+
await writeBabelConfig({projectRoot, config: {presets: [preset.name]}});
|
|
428
415
|
|
|
429
416
|
return {
|
|
430
417
|
dependencies: {javascript: {development: ['@babel/register', preset.packageName]}},
|
|
@@ -432,17 +419,17 @@ async function scaffoldBabel ({projectRoot, preset}) {
|
|
|
432
419
|
};
|
|
433
420
|
}
|
|
434
421
|
|
|
435
|
-
async function
|
|
436
|
-
await
|
|
422
|
+
async function liftBabel({results, projectRoot}) {
|
|
423
|
+
await addIgnores({ignore: results.buildDirectory, projectRoot});
|
|
437
424
|
|
|
438
425
|
return {};
|
|
439
426
|
}
|
|
440
427
|
|
|
441
|
-
function
|
|
428
|
+
function babelIsInUse({projectRoot}) {
|
|
442
429
|
return fileExists(`${projectRoot}/.babelrc.json`);
|
|
443
430
|
}
|
|
444
431
|
|
|
445
|
-
async function scaffoldTypescript
|
|
432
|
+
async function scaffoldTypescript({config, projectType, projectRoot, testFilenamePattern}) {
|
|
446
433
|
const shareableTsConfigPackage = `${config.scope}/tsconfig`;
|
|
447
434
|
|
|
448
435
|
await writeConfigFile({
|
|
@@ -471,7 +458,7 @@ async function scaffoldTypescript ({config, projectType, projectRoot, testFilena
|
|
|
471
458
|
};
|
|
472
459
|
}
|
|
473
460
|
|
|
474
|
-
function scaffoldDialect
|
|
461
|
+
function scaffoldDialect({dialect, projectType, projectRoot, configs, testFilenamePattern}) {
|
|
475
462
|
switch (dialect) {
|
|
476
463
|
case dialects$1.BABEL:
|
|
477
464
|
return scaffoldBabel({preset: configs.babelPreset, projectRoot});
|
|
@@ -484,12 +471,12 @@ function scaffoldDialect ({dialect, projectType, projectRoot, configs, testFilen
|
|
|
484
471
|
|
|
485
472
|
var dialects = /*#__PURE__*/Object.freeze({
|
|
486
473
|
__proto__: null,
|
|
487
|
-
lift:
|
|
474
|
+
lift: liftBabel,
|
|
488
475
|
scaffold: scaffoldDialect,
|
|
489
|
-
test:
|
|
476
|
+
test: babelIsInUse
|
|
490
477
|
});
|
|
491
478
|
|
|
492
|
-
async function writeNpmConfig
|
|
479
|
+
async function writeNpmConfig({projectRoot, config}) {
|
|
493
480
|
await promises.writeFile(`${projectRoot}/.npmrc`, stringify(config));
|
|
494
481
|
}
|
|
495
482
|
|
|
@@ -497,7 +484,7 @@ function projectWillNotBeConsumed(projectType) {
|
|
|
497
484
|
return projectTypes$1.APPLICATION === projectType || projectTypes$1.CLI === projectType;
|
|
498
485
|
}
|
|
499
486
|
|
|
500
|
-
async function
|
|
487
|
+
async function scaffoldNpmConfiguration({projectRoot, projectType}) {
|
|
501
488
|
await writeNpmConfig({
|
|
502
489
|
projectRoot,
|
|
503
490
|
config: {'update-notifier': false, ...projectWillNotBeConsumed(projectType) && {'save-exact': true}}
|
|
@@ -506,11 +493,11 @@ async function scaffoldNpmConfig ({projectRoot, projectType}) {
|
|
|
506
493
|
return {scripts: {'lint:peer': 'npm ls >/dev/null'}};
|
|
507
494
|
}
|
|
508
495
|
|
|
509
|
-
function
|
|
496
|
+
function npmConfigExists({projectRoot}) {
|
|
510
497
|
return fileExists(`${projectRoot}/.npmrc`);
|
|
511
498
|
}
|
|
512
499
|
|
|
513
|
-
async function readNpmConfig
|
|
500
|
+
async function readNpmConfig({projectRoot}) {
|
|
514
501
|
const pathToConfig = `${projectRoot}/.npmrc`;
|
|
515
502
|
|
|
516
503
|
if (!(await fileExists(pathToConfig))) return {};
|
|
@@ -518,7 +505,7 @@ async function readNpmConfig ({projectRoot}) {
|
|
|
518
505
|
return parse(await promises.readFile(pathToConfig, 'utf-8'));
|
|
519
506
|
}
|
|
520
507
|
|
|
521
|
-
async function
|
|
508
|
+
async function liftNpmConfig({projectRoot}) {
|
|
522
509
|
const {
|
|
523
510
|
provenance,
|
|
524
511
|
'engines-strict': enginesStrict,
|
|
@@ -532,14 +519,14 @@ async function lifter$3 ({projectRoot}) {
|
|
|
532
519
|
|
|
533
520
|
var npmConfigPlugin = /*#__PURE__*/Object.freeze({
|
|
534
521
|
__proto__: null,
|
|
535
|
-
lift:
|
|
522
|
+
lift: liftNpmConfig,
|
|
536
523
|
read: readNpmConfig,
|
|
537
|
-
scaffold:
|
|
538
|
-
test:
|
|
524
|
+
scaffold: scaffoldNpmConfiguration,
|
|
525
|
+
test: npmConfigExists,
|
|
539
526
|
write: writeNpmConfig
|
|
540
527
|
});
|
|
541
528
|
|
|
542
|
-
async function
|
|
529
|
+
async function scaffoldNpmPackageManager({projectRoot}) {
|
|
543
530
|
const [packageContents, {stdout}] = await Promise.all([
|
|
544
531
|
promises.readFile(`${projectRoot}/package.json`, 'utf-8'),
|
|
545
532
|
execa('npm', ['--version'])
|
|
@@ -555,7 +542,7 @@ async function scaffoldNpm ({projectRoot}) {
|
|
|
555
542
|
});
|
|
556
543
|
}
|
|
557
544
|
|
|
558
|
-
function
|
|
545
|
+
function resolveLockfilePath(packageManager) {
|
|
559
546
|
const lockfilePaths = {
|
|
560
547
|
[packageManagers$1.NPM]: 'package-lock.json',
|
|
561
548
|
[packageManagers$1.YARN]: 'yarn.lock'
|
|
@@ -564,14 +551,14 @@ function determineLockfilePathFor (packageManager) {
|
|
|
564
551
|
return lockfilePaths[packageManager];
|
|
565
552
|
}
|
|
566
553
|
|
|
567
|
-
function
|
|
554
|
+
function packageManagerIsNpm({projectRoot, pinnedPackageManager = ''}) {
|
|
568
555
|
const [packageManager] = pinnedPackageManager.split('@');
|
|
569
556
|
|
|
570
557
|
return packageManagers$1.NPM === packageManager
|
|
571
|
-
|| fileExists(`${projectRoot}/${
|
|
558
|
+
|| fileExists(`${projectRoot}/${resolveLockfilePath(packageManagers$1.NPM)}`);
|
|
572
559
|
}
|
|
573
560
|
|
|
574
|
-
async function scaffoldYarn
|
|
561
|
+
async function scaffoldYarn({projectRoot}) {
|
|
575
562
|
const [packageContents, {stdout}] = await Promise.all([
|
|
576
563
|
promises.readFile(`${projectRoot}/package.json`, 'utf-8'),
|
|
577
564
|
execa('yarn', ['--version'])
|
|
@@ -587,51 +574,51 @@ async function scaffoldYarn ({projectRoot}) {
|
|
|
587
574
|
});
|
|
588
575
|
}
|
|
589
576
|
|
|
590
|
-
function
|
|
577
|
+
function packageManagerIsYarn({projectRoot, pinnedPackageManager = ''}) {
|
|
591
578
|
const [packageManager] = pinnedPackageManager.split('@');
|
|
592
579
|
|
|
593
580
|
return packageManagers$1.YARN === packageManager
|
|
594
|
-
|| fileExists(`${projectRoot}/${
|
|
581
|
+
|| fileExists(`${projectRoot}/${resolveLockfilePath(packageManagers$1.YARN)}`);
|
|
595
582
|
}
|
|
596
583
|
|
|
597
|
-
async function
|
|
584
|
+
async function packageManagerInUse({projectRoot}) {
|
|
598
585
|
const [npmFound, yarnFound] = await Promise.all([
|
|
599
|
-
|
|
600
|
-
|
|
586
|
+
packageManagerIsNpm({projectRoot}),
|
|
587
|
+
packageManagerIsYarn({projectRoot})
|
|
601
588
|
]);
|
|
602
589
|
|
|
603
590
|
return npmFound || yarnFound;
|
|
604
591
|
}
|
|
605
592
|
|
|
606
|
-
async function liftCorepack
|
|
593
|
+
async function liftCorepack() {
|
|
607
594
|
await execa('corepack', ['use', 'npm@latest']);
|
|
608
595
|
}
|
|
609
596
|
|
|
610
|
-
async function
|
|
597
|
+
async function liftPackageManagers() {
|
|
611
598
|
await liftCorepack();
|
|
612
599
|
|
|
613
600
|
return {};
|
|
614
601
|
}
|
|
615
602
|
|
|
616
603
|
const scaffolders = {
|
|
617
|
-
npm:
|
|
604
|
+
npm: scaffoldNpmPackageManager,
|
|
618
605
|
yarn: scaffoldYarn
|
|
619
606
|
};
|
|
620
607
|
|
|
621
|
-
function scaffoldPackageManager
|
|
608
|
+
function scaffoldPackageManager({projectRoot, packageManager}) {
|
|
622
609
|
return scaffolders[packageManager]({projectRoot});
|
|
623
610
|
}
|
|
624
611
|
|
|
625
|
-
async function
|
|
612
|
+
async function resolveCurrentPackageManager({projectRoot, packageManager}) {
|
|
626
613
|
if (packageManager) return packageManager;
|
|
627
614
|
|
|
628
615
|
const {packageManager: pinnedPackageManager} = JSON.parse(await promises.readFile(`${projectRoot}/package.json`, 'utf-8'));
|
|
629
616
|
|
|
630
|
-
if (await
|
|
617
|
+
if (await packageManagerIsNpm({projectRoot, pinnedPackageManager})) {
|
|
631
618
|
return packageManagers$1.NPM;
|
|
632
619
|
}
|
|
633
620
|
|
|
634
|
-
if (await
|
|
621
|
+
if (await packageManagerIsYarn({projectRoot, pinnedPackageManager})) {
|
|
635
622
|
return packageManagers$1.YARN;
|
|
636
623
|
}
|
|
637
624
|
|
|
@@ -640,14 +627,14 @@ async function resolvePackageManager ({projectRoot, packageManager}) {
|
|
|
640
627
|
|
|
641
628
|
var packageManagers = /*#__PURE__*/Object.freeze({
|
|
642
629
|
__proto__: null,
|
|
643
|
-
defineLockfilePath:
|
|
644
|
-
determineCurrent:
|
|
645
|
-
lift:
|
|
630
|
+
defineLockfilePath: resolveLockfilePath,
|
|
631
|
+
determineCurrent: resolveCurrentPackageManager,
|
|
632
|
+
lift: liftPackageManagers,
|
|
646
633
|
scaffold: scaffoldPackageManager,
|
|
647
|
-
test:
|
|
634
|
+
test: packageManagerInUse
|
|
648
635
|
});
|
|
649
636
|
|
|
650
|
-
function
|
|
637
|
+
function scaffoldGenerationCommand(packageManager) {
|
|
651
638
|
if (packageManagers$1.NPM === packageManager) return 'npm run generate:md';
|
|
652
639
|
if (packageManagers$1.YARN === packageManager) return 'yarn generate:md';
|
|
653
640
|
|
|
@@ -657,9 +644,9 @@ function buildDocumentationCommand (packageManager) {
|
|
|
657
644
|
);
|
|
658
645
|
}
|
|
659
646
|
|
|
660
|
-
function scaffoldDocumentation
|
|
647
|
+
function scaffoldDocumentation({projectTypeResults, packageManager}) {
|
|
661
648
|
return {
|
|
662
|
-
toc: `Run \`${
|
|
649
|
+
toc: `Run \`${scaffoldGenerationCommand(packageManager)}\` to generate a table of contents`,
|
|
663
650
|
...projectTypeResults.documentation,
|
|
664
651
|
contributing: `### Dependencies
|
|
665
652
|
|
|
@@ -690,7 +677,7 @@ async function determineLatestVersionOf(nodeVersionCategory) {
|
|
|
690
677
|
return lsLine.match(/(v[0-9]+)\.[0-9]+\.[0-9]+/)[1];
|
|
691
678
|
}
|
|
692
679
|
|
|
693
|
-
function install
|
|
680
|
+
function install(nodeVersionCategory) {
|
|
694
681
|
info(`Installing ${nodeVersionCategory} version of node using nvm`, {level: 'secondary'});
|
|
695
682
|
|
|
696
683
|
const subprocess = execa('. ~/.nvm/nvm.sh && nvm install', {shell: true});
|
|
@@ -698,7 +685,7 @@ function install$1(nodeVersionCategory) {
|
|
|
698
685
|
return subprocess;
|
|
699
686
|
}
|
|
700
687
|
|
|
701
|
-
async function scaffoldNodeVersion
|
|
688
|
+
async function scaffoldNodeVersion({projectRoot, nodeVersionCategory}) {
|
|
702
689
|
if (!nodeVersionCategory) return undefined;
|
|
703
690
|
|
|
704
691
|
const lowerCaseCategory = nodeVersionCategory.toLowerCase();
|
|
@@ -708,23 +695,23 @@ async function scaffoldNodeVersion ({projectRoot, nodeVersionCategory}) {
|
|
|
708
695
|
|
|
709
696
|
await promises.writeFile(`${projectRoot}/.nvmrc`, version);
|
|
710
697
|
|
|
711
|
-
await install
|
|
698
|
+
await install(nodeVersionCategory);
|
|
712
699
|
|
|
713
700
|
return version;
|
|
714
701
|
}
|
|
715
702
|
|
|
716
|
-
function
|
|
703
|
+
function nodeVersionMangerInUse({projectRoot}) {
|
|
717
704
|
return fileExists(`${projectRoot}/.nvmrc`);
|
|
718
705
|
}
|
|
719
706
|
|
|
720
|
-
function
|
|
707
|
+
function buildIgnoreLists(vcsIgnoreLists = {}) {
|
|
721
708
|
return {
|
|
722
709
|
files: vcsIgnoreLists.files || [],
|
|
723
710
|
directories: ['/node_modules/', ...vcsIgnoreLists.directories || []]
|
|
724
711
|
};
|
|
725
712
|
}
|
|
726
713
|
|
|
727
|
-
function
|
|
714
|
+
function determinePackageName(projectName, scope) {
|
|
728
715
|
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
729
716
|
|
|
730
717
|
const {validForNewPackages, errors} = validatePackageName(name);
|
|
@@ -735,7 +722,7 @@ function buildPackageName (projectName, scope) {
|
|
|
735
722
|
throw new Error(`The package name ${name} is invalid:${EOL}\t* ${errors.join(`${EOL}\t* `)}`);
|
|
736
723
|
}
|
|
737
724
|
|
|
738
|
-
function
|
|
725
|
+
function scaffoldPackageJsonDetails({
|
|
739
726
|
packageName,
|
|
740
727
|
dialect,
|
|
741
728
|
license,
|
|
@@ -752,7 +739,7 @@ function buildPackageDetails ({
|
|
|
752
739
|
};
|
|
753
740
|
}
|
|
754
741
|
|
|
755
|
-
async function scaffoldPackage
|
|
742
|
+
async function scaffoldPackage({
|
|
756
743
|
projectRoot,
|
|
757
744
|
projectName,
|
|
758
745
|
scope,
|
|
@@ -763,11 +750,11 @@ async function scaffoldPackage ({
|
|
|
763
750
|
}) {
|
|
764
751
|
info('Configuring package.json');
|
|
765
752
|
|
|
766
|
-
const packageName =
|
|
753
|
+
const packageName = determinePackageName(projectName, scope);
|
|
767
754
|
|
|
768
755
|
await writePackageJson({
|
|
769
756
|
projectRoot,
|
|
770
|
-
config: await
|
|
757
|
+
config: await scaffoldPackageJsonDetails({
|
|
771
758
|
packageName,
|
|
772
759
|
dialect,
|
|
773
760
|
license,
|
|
@@ -816,7 +803,7 @@ function sortProperties(packageContents) {
|
|
|
816
803
|
);
|
|
817
804
|
}
|
|
818
805
|
|
|
819
|
-
function
|
|
806
|
+
function scaffoldVcsHostDetails(vcs, pathWithinParent) {
|
|
820
807
|
return vcs && 'github' === vcs.host && {
|
|
821
808
|
repository: pathWithinParent
|
|
822
809
|
? {
|
|
@@ -860,7 +847,12 @@ function getExactFlag(manager) {
|
|
|
860
847
|
return details[manager].installationFlags.exact;
|
|
861
848
|
}
|
|
862
849
|
|
|
863
|
-
async function
|
|
850
|
+
async function installDependencies(
|
|
851
|
+
dependencies,
|
|
852
|
+
dependenciesType,
|
|
853
|
+
projectRoot,
|
|
854
|
+
packageManager = packageManagers$1.NPM
|
|
855
|
+
) {
|
|
864
856
|
if (dependencies.length) {
|
|
865
857
|
info(`Installing ${dependenciesType} dependencies`, {level: 'secondary'});
|
|
866
858
|
|
|
@@ -899,8 +891,8 @@ async function processDependencies({dependencies = {}, devDependencies, projectR
|
|
|
899
891
|
const {javascript: {production = [], development = [], remove: dependenciesToRemove = []} = {}} = dependencies;
|
|
900
892
|
|
|
901
893
|
try {
|
|
902
|
-
await
|
|
903
|
-
await
|
|
894
|
+
await installDependencies(production, PROD_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
895
|
+
await installDependencies(development, DEV_DEPENDENCY_TYPE, projectRoot, packageManager);
|
|
904
896
|
await removeDependencies({packageManager, dependencies: dependenciesToRemove});
|
|
905
897
|
} catch (e) {
|
|
906
898
|
error('Failed to update dependencies');
|
|
@@ -965,8 +957,8 @@ function compareScriptNames(a, b) {
|
|
|
965
957
|
const aStripped = stripPrefix(a);
|
|
966
958
|
const bStripped = stripPrefix(b);
|
|
967
959
|
|
|
968
|
-
const aKey = aStripped
|
|
969
|
-
const bKey = bStripped
|
|
960
|
+
const aKey = aStripped !== a ? aStripped : a;
|
|
961
|
+
const bKey = bStripped !== b ? bStripped : b;
|
|
970
962
|
|
|
971
963
|
return aKey.localeCompare(bKey);
|
|
972
964
|
}
|
|
@@ -1009,7 +1001,7 @@ async function liftPackageJson({
|
|
|
1009
1001
|
projectRoot,
|
|
1010
1002
|
config: sortProperties({
|
|
1011
1003
|
...existingPackageJsonContents,
|
|
1012
|
-
...
|
|
1004
|
+
...scaffoldVcsHostDetails(vcs, pathWithinParent),
|
|
1013
1005
|
scripts: liftedScripts,
|
|
1014
1006
|
...tags && {
|
|
1015
1007
|
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
@@ -1025,11 +1017,11 @@ async function liftPackageJson({
|
|
|
1025
1017
|
});
|
|
1026
1018
|
}
|
|
1027
1019
|
|
|
1028
|
-
function
|
|
1020
|
+
function mapProjectVisibility({projectVisibility}) {
|
|
1029
1021
|
return 'Public' === projectVisibility ? 'public' : 'restricted';
|
|
1030
1022
|
}
|
|
1031
1023
|
|
|
1032
|
-
function
|
|
1024
|
+
function scaffoldPublishableBadges(packageName, accessLevel) {
|
|
1033
1025
|
return {
|
|
1034
1026
|
consumer: {
|
|
1035
1027
|
...'public' === accessLevel && {
|
|
@@ -1044,7 +1036,7 @@ function defineBadges (packageName, accessLevel) {
|
|
|
1044
1036
|
};
|
|
1045
1037
|
}
|
|
1046
1038
|
|
|
1047
|
-
function
|
|
1039
|
+
function scaffoldSlsa({provenance}) {
|
|
1048
1040
|
{
|
|
1049
1041
|
return {
|
|
1050
1042
|
badges: {
|
|
@@ -1060,13 +1052,13 @@ function enhanceSlsa ({provenance}) {
|
|
|
1060
1052
|
}
|
|
1061
1053
|
}
|
|
1062
1054
|
|
|
1063
|
-
async function liftProvenance
|
|
1055
|
+
async function liftProvenance({projectRoot, packageDetails}) {
|
|
1064
1056
|
const {publishConfig: {access} = {}} = packageDetails;
|
|
1065
1057
|
|
|
1066
1058
|
if ('public' === access) {
|
|
1067
1059
|
await mergeIntoExistingPackageJson({projectRoot, config: {publishConfig: {provenance: true}}});
|
|
1068
1060
|
|
|
1069
|
-
return
|
|
1061
|
+
return scaffoldSlsa({provenance: true});
|
|
1070
1062
|
}
|
|
1071
1063
|
|
|
1072
1064
|
return {};
|
|
@@ -1084,14 +1076,14 @@ async function liftPublishable({projectRoot, packageDetails}) {
|
|
|
1084
1076
|
homepage,
|
|
1085
1077
|
dependencies: {javascript: {development: ['publint']}},
|
|
1086
1078
|
scripts: {'lint:publish': 'publint --strict'},
|
|
1087
|
-
badges:
|
|
1079
|
+
badges: scaffoldPublishableBadges(packageName, packageAccessLevel)
|
|
1088
1080
|
}
|
|
1089
1081
|
);
|
|
1090
1082
|
}
|
|
1091
1083
|
|
|
1092
|
-
async function scaffoldPublishable
|
|
1084
|
+
async function scaffoldPublishable({packageName, packageAccessLevel}) {
|
|
1093
1085
|
return {
|
|
1094
|
-
badges: await
|
|
1086
|
+
badges: await scaffoldPublishableBadges(packageName, packageAccessLevel)
|
|
1095
1087
|
};
|
|
1096
1088
|
}
|
|
1097
1089
|
|
|
@@ -1105,7 +1097,7 @@ function getInstallationCommand(packageManager) {
|
|
|
1105
1097
|
);
|
|
1106
1098
|
}
|
|
1107
1099
|
|
|
1108
|
-
function scaffoldPackageDocumentation
|
|
1100
|
+
function scaffoldPackageDocumentation({scope, packageName, packageManager, visibility, provideExample}) {
|
|
1109
1101
|
return {
|
|
1110
1102
|
usage: `### Installation
|
|
1111
1103
|
${'Private' === visibility ? `
|
|
@@ -1120,13 +1112,13 @@ $ ${getInstallationCommand(packageManager)} ${packageName}
|
|
|
1120
1112
|
|
|
1121
1113
|
### Example
|
|
1122
1114
|
|
|
1123
|
-
run \`${
|
|
1115
|
+
run \`${scaffoldGenerationCommand(packageManager)}\` to inject the usage example`
|
|
1124
1116
|
: ''
|
|
1125
1117
|
}`
|
|
1126
1118
|
};
|
|
1127
1119
|
}
|
|
1128
1120
|
|
|
1129
|
-
async function
|
|
1121
|
+
async function gatherBundlerInput({bundlers, decisions}) {
|
|
1130
1122
|
if (!Object.keys(bundlers).length) return 'Other';
|
|
1131
1123
|
|
|
1132
1124
|
const answers = await prompt$1([{
|
|
@@ -1139,8 +1131,8 @@ async function chooseBundler ({bundlers, decisions}) {
|
|
|
1139
1131
|
return answers[questionNames$1.PACKAGE_BUNDLER];
|
|
1140
1132
|
}
|
|
1141
1133
|
|
|
1142
|
-
async function scaffoldBundler
|
|
1143
|
-
const chosenBundler = await
|
|
1134
|
+
async function scaffoldBundler({projectRoot, projectType, bundlers, dialect, decisions}) {
|
|
1135
|
+
const chosenBundler = await gatherBundlerInput({bundlers, decisions});
|
|
1144
1136
|
|
|
1145
1137
|
return scaffoldChoice(bundlers, chosenBundler, {projectRoot, projectType, dialect});
|
|
1146
1138
|
}
|
|
@@ -1211,7 +1203,7 @@ async function scaffoldPackageProjectType({
|
|
|
1211
1203
|
}) {
|
|
1212
1204
|
info('Scaffolding Package Details');
|
|
1213
1205
|
|
|
1214
|
-
const packageAccessLevel =
|
|
1206
|
+
const packageAccessLevel = mapProjectVisibility({projectVisibility: visibility});
|
|
1215
1207
|
const [detailsForBuild, publishableResults] = await Promise.all([
|
|
1216
1208
|
buildDetails({
|
|
1217
1209
|
projectRoot,
|
|
@@ -1276,13 +1268,15 @@ function liftPackage({projectRoot, packageDetails}) {
|
|
|
1276
1268
|
return liftPublishable({projectRoot, packageDetails});
|
|
1277
1269
|
}
|
|
1278
1270
|
|
|
1279
|
-
async function
|
|
1271
|
+
async function projectIsPackage({
|
|
1272
|
+
packageDetails: {exports: exports$1, publishConfig, bin, private: projectMarkedPrivate}
|
|
1273
|
+
}) {
|
|
1280
1274
|
return !projectMarkedPrivate && (!!exports$1 || (!!publishConfig && !bin));
|
|
1281
1275
|
}
|
|
1282
1276
|
|
|
1283
1277
|
const defaultBuildDirectory$1 = 'public';
|
|
1284
1278
|
|
|
1285
|
-
async function
|
|
1279
|
+
async function scaffoldApplication({projectRoot}) {
|
|
1286
1280
|
info('Scaffolding Application Details');
|
|
1287
1281
|
|
|
1288
1282
|
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
@@ -1302,11 +1296,11 @@ async function scaffoldApplicationType ({projectRoot}) {
|
|
|
1302
1296
|
};
|
|
1303
1297
|
}
|
|
1304
1298
|
|
|
1305
|
-
function
|
|
1299
|
+
function projectIsApplication({packageDetails}) {
|
|
1306
1300
|
return !!packageDetails.private;
|
|
1307
1301
|
}
|
|
1308
1302
|
|
|
1309
|
-
async function
|
|
1303
|
+
async function scaffoldMonorepo({projectRoot}) {
|
|
1310
1304
|
info('Scaffolding Monorepo Details');
|
|
1311
1305
|
|
|
1312
1306
|
await mergeIntoExistingPackageJson({projectRoot, config: {private: true}});
|
|
@@ -1331,7 +1325,7 @@ async function scaffoldCli({
|
|
|
1331
1325
|
decisions,
|
|
1332
1326
|
packageBundlers
|
|
1333
1327
|
}) {
|
|
1334
|
-
const packageAccessLevel =
|
|
1328
|
+
const packageAccessLevel = mapProjectVisibility({projectVisibility: visibility});
|
|
1335
1329
|
const [bundlerResults, publishableResults] = await Promise.all([
|
|
1336
1330
|
scaffoldBundler({bundlers: packageBundlers, projectRoot, dialect, decisions, projectType: projectTypes$1.CLI}),
|
|
1337
1331
|
scaffoldPublishable({packageName, packageAccessLevel}),
|
|
@@ -1366,7 +1360,7 @@ async function scaffoldCli({
|
|
|
1366
1360
|
]);
|
|
1367
1361
|
}
|
|
1368
1362
|
|
|
1369
|
-
async function
|
|
1363
|
+
async function projectIsCli({packageDetails: {bin}}) {
|
|
1370
1364
|
return !!bin;
|
|
1371
1365
|
}
|
|
1372
1366
|
|
|
@@ -1374,7 +1368,7 @@ function liftCli({projectRoot, packageDetails}) {
|
|
|
1374
1368
|
return liftPublishable({projectRoot, packageDetails});
|
|
1375
1369
|
}
|
|
1376
1370
|
|
|
1377
|
-
async function scaffoldProjectType
|
|
1371
|
+
async function scaffoldProjectType({
|
|
1378
1372
|
projectType,
|
|
1379
1373
|
projectRoot,
|
|
1380
1374
|
projectName,
|
|
@@ -1404,7 +1398,7 @@ async function scaffoldProjectType ({
|
|
|
1404
1398
|
publishRegistry
|
|
1405
1399
|
});
|
|
1406
1400
|
case projectTypes$1.APPLICATION:
|
|
1407
|
-
return
|
|
1401
|
+
return scaffoldApplication({projectRoot});
|
|
1408
1402
|
case projectTypes$1.CLI:
|
|
1409
1403
|
return scaffoldCli({
|
|
1410
1404
|
packageName,
|
|
@@ -1416,7 +1410,7 @@ async function scaffoldProjectType ({
|
|
|
1416
1410
|
packageBundlers
|
|
1417
1411
|
});
|
|
1418
1412
|
case projectTypes$1.MONOREPO:
|
|
1419
|
-
return
|
|
1413
|
+
return scaffoldMonorepo({projectRoot});
|
|
1420
1414
|
case 'Other':
|
|
1421
1415
|
return {};
|
|
1422
1416
|
default:
|
|
@@ -1424,10 +1418,10 @@ async function scaffoldProjectType ({
|
|
|
1424
1418
|
}
|
|
1425
1419
|
}
|
|
1426
1420
|
|
|
1427
|
-
async function
|
|
1428
|
-
return await
|
|
1429
|
-
|| await
|
|
1430
|
-
||
|
|
1421
|
+
async function isProjectType({projectRoot, packageDetails}) {
|
|
1422
|
+
return await projectIsPackage({packageDetails})
|
|
1423
|
+
|| await projectIsCli({packageDetails})
|
|
1424
|
+
|| projectIsApplication({packageDetails});
|
|
1431
1425
|
}
|
|
1432
1426
|
|
|
1433
1427
|
function vcsRepositoryHostedOnGithub(vcs) {
|
|
@@ -1435,8 +1429,8 @@ function vcsRepositoryHostedOnGithub(vcs) {
|
|
|
1435
1429
|
}
|
|
1436
1430
|
|
|
1437
1431
|
async function liftProjectType({projectRoot, packageDetails, vcs}) {
|
|
1438
|
-
if (await
|
|
1439
|
-
if (await
|
|
1432
|
+
if (await projectIsPackage({packageDetails})) return liftPackage({projectRoot, packageDetails});
|
|
1433
|
+
if (await projectIsCli({packageDetails})) return liftCli({projectRoot, packageDetails});
|
|
1440
1434
|
|
|
1441
1435
|
let homepage;
|
|
1442
1436
|
|
|
@@ -1453,10 +1447,10 @@ var projectTypes = /*#__PURE__*/Object.freeze({
|
|
|
1453
1447
|
__proto__: null,
|
|
1454
1448
|
lift: liftProjectType,
|
|
1455
1449
|
scaffold: scaffoldProjectType,
|
|
1456
|
-
test:
|
|
1450
|
+
test: isProjectType
|
|
1457
1451
|
});
|
|
1458
1452
|
|
|
1459
|
-
async function
|
|
1453
|
+
async function gatherProjectTypePluginInput({types, projectType, decisions}) {
|
|
1460
1454
|
if (!Object.keys(types).length) return 'Other';
|
|
1461
1455
|
|
|
1462
1456
|
const answers = await prompt$1([{
|
|
@@ -1469,7 +1463,7 @@ async function chooseProjectTypePlugin ({types, projectType, decisions}) {
|
|
|
1469
1463
|
return answers[questionNames$1.PROJECT_TYPE_CHOICE];
|
|
1470
1464
|
}
|
|
1471
1465
|
|
|
1472
|
-
async function scaffoldProjectTypePlugin
|
|
1466
|
+
async function scaffoldProjectTypePlugin({
|
|
1473
1467
|
projectRoot,
|
|
1474
1468
|
projectType,
|
|
1475
1469
|
projectName,
|
|
@@ -1485,7 +1479,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1485
1479
|
|
|
1486
1480
|
if (!pluginsForProjectType) return {};
|
|
1487
1481
|
|
|
1488
|
-
const chosenType = await
|
|
1482
|
+
const chosenType = await gatherProjectTypePluginInput({types: pluginsForProjectType, decisions, projectType});
|
|
1489
1483
|
|
|
1490
1484
|
return scaffoldChoice(
|
|
1491
1485
|
pluginsForProjectType,
|
|
@@ -1494,7 +1488,7 @@ async function scaffoldProjectTypePlugin ({
|
|
|
1494
1488
|
);
|
|
1495
1489
|
}
|
|
1496
1490
|
|
|
1497
|
-
async function scaffoldTesting
|
|
1491
|
+
async function scaffoldTesting({
|
|
1498
1492
|
projectRoot,
|
|
1499
1493
|
visibility,
|
|
1500
1494
|
tests: {unit, integration},
|
|
@@ -1522,7 +1516,7 @@ async function scaffoldTesting ({
|
|
|
1522
1516
|
);
|
|
1523
1517
|
}
|
|
1524
1518
|
|
|
1525
|
-
function
|
|
1519
|
+
function buildAllowedHosts({packageManager, registries = {}}) {
|
|
1526
1520
|
return [
|
|
1527
1521
|
...!registries.registry ? [packageManager] : [],
|
|
1528
1522
|
...Object.values(Object.fromEntries(Object.entries(registries).filter(([scope]) => 'publish' !== scope)))
|
|
@@ -1535,7 +1529,7 @@ function lockfileLintSupports(packageManager) {
|
|
|
1535
1529
|
return lockfileLintSupportedPackageManagers.includes(packageManager);
|
|
1536
1530
|
}
|
|
1537
1531
|
|
|
1538
|
-
async function scaffoldLockfileLint
|
|
1532
|
+
async function scaffoldLockfileLint({projectRoot, packageManager, registries}) {
|
|
1539
1533
|
if (!lockfileLintSupports(packageManager)) {
|
|
1540
1534
|
throw new Error(
|
|
1541
1535
|
`The ${packageManager} package manager is currently not supported by lockfile-lint. `
|
|
@@ -1543,15 +1537,15 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1543
1537
|
);
|
|
1544
1538
|
}
|
|
1545
1539
|
|
|
1546
|
-
await write$
|
|
1540
|
+
await write$1({
|
|
1547
1541
|
name: 'lockfile-lint',
|
|
1548
1542
|
format: fileTypes.JSON,
|
|
1549
1543
|
path: projectRoot,
|
|
1550
1544
|
config: {
|
|
1551
|
-
path:
|
|
1545
|
+
path: resolveLockfilePath(packageManager),
|
|
1552
1546
|
type: packageManager,
|
|
1553
1547
|
'validate-https': true,
|
|
1554
|
-
'allowed-hosts':
|
|
1548
|
+
'allowed-hosts': buildAllowedHosts({packageManager, registries})
|
|
1555
1549
|
}
|
|
1556
1550
|
});
|
|
1557
1551
|
|
|
@@ -1561,7 +1555,7 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1561
1555
|
};
|
|
1562
1556
|
}
|
|
1563
1557
|
|
|
1564
|
-
function
|
|
1558
|
+
function lockfileLintInUse({projectRoot}) {
|
|
1565
1559
|
return fileExists(`${projectRoot}/.lockfile-lintrc.json`);
|
|
1566
1560
|
}
|
|
1567
1561
|
|
|
@@ -1572,10 +1566,10 @@ function read({projectRoot}) {
|
|
|
1572
1566
|
}
|
|
1573
1567
|
|
|
1574
1568
|
function write({projectRoot, config}) {
|
|
1575
|
-
return write$
|
|
1569
|
+
return write$1({name: configName, format: fileTypes.JSON, path: projectRoot, config});
|
|
1576
1570
|
}
|
|
1577
1571
|
|
|
1578
|
-
async function scaffoldLinting
|
|
1572
|
+
async function scaffoldLinting({projectRoot, packageManager, registries}) {
|
|
1579
1573
|
return scaffoldLockfileLint({projectRoot, packageManager, registries});
|
|
1580
1574
|
}
|
|
1581
1575
|
|
|
@@ -1603,14 +1597,14 @@ async function scaffoldVerification({
|
|
|
1603
1597
|
pathWithinParent
|
|
1604
1598
|
}),
|
|
1605
1599
|
scaffoldLinting({projectRoot, packageManager, registries}),
|
|
1606
|
-
scaffold$
|
|
1600
|
+
scaffold$2({projectRoot, packageManager, pathWithinParent})
|
|
1607
1601
|
]);
|
|
1608
1602
|
|
|
1609
1603
|
return deepmerge.all([testingResults, lintingResults, huskyResults]);
|
|
1610
1604
|
}
|
|
1611
1605
|
|
|
1612
|
-
async function scaffoldRemark
|
|
1613
|
-
await write$
|
|
1606
|
+
async function scaffoldRemark({config, projectRoot, projectType, vcs}) {
|
|
1607
|
+
await write$1({
|
|
1614
1608
|
format: fileTypes.JSON,
|
|
1615
1609
|
path: projectRoot,
|
|
1616
1610
|
name: 'remark',
|
|
@@ -1643,7 +1637,7 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
|
1643
1637
|
);
|
|
1644
1638
|
}
|
|
1645
1639
|
|
|
1646
|
-
async function scaffoldCodeStyle
|
|
1640
|
+
async function scaffoldCodeStyle({
|
|
1647
1641
|
projectRoot,
|
|
1648
1642
|
projectType,
|
|
1649
1643
|
configs,
|
|
@@ -1653,33 +1647,33 @@ async function scaffoldCodeStyle ({
|
|
|
1653
1647
|
return deepmerge.all(await Promise.all([
|
|
1654
1648
|
configs.eslint
|
|
1655
1649
|
&& configureLinting
|
|
1656
|
-
&& scaffold$
|
|
1650
|
+
&& scaffold$3({projectRoot, config: configs.eslint}),
|
|
1657
1651
|
scaffoldRemark({
|
|
1658
1652
|
projectRoot,
|
|
1659
1653
|
projectType,
|
|
1660
1654
|
vcs,
|
|
1661
1655
|
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
1662
1656
|
}),
|
|
1663
|
-
scaffold$
|
|
1657
|
+
scaffold$4({projectRoot, config: configs.prettier})
|
|
1664
1658
|
].filter(Boolean)));
|
|
1665
1659
|
}
|
|
1666
1660
|
|
|
1667
|
-
function
|
|
1661
|
+
function liftCodeStyle(options) {
|
|
1668
1662
|
return applyEnhancers({options, enhancers: [eslintPlugin]});
|
|
1669
1663
|
}
|
|
1670
1664
|
|
|
1671
|
-
function
|
|
1672
|
-
return test$
|
|
1665
|
+
function codeStyleConfigured(options) {
|
|
1666
|
+
return test$2(options);
|
|
1673
1667
|
}
|
|
1674
1668
|
|
|
1675
1669
|
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
1676
1670
|
__proto__: null,
|
|
1677
|
-
lift:
|
|
1671
|
+
lift: liftCodeStyle,
|
|
1678
1672
|
scaffold: scaffoldCodeStyle,
|
|
1679
|
-
test:
|
|
1673
|
+
test: codeStyleConfigured
|
|
1680
1674
|
});
|
|
1681
1675
|
|
|
1682
|
-
async function
|
|
1676
|
+
async function scaffoldJavascript(options) {
|
|
1683
1677
|
info('Initializing JavaScript project');
|
|
1684
1678
|
|
|
1685
1679
|
const {
|
|
@@ -1756,7 +1750,7 @@ async function scaffolder (options) {
|
|
|
1756
1750
|
});
|
|
1757
1751
|
const [nodeVersion, npmResults, dialectResults, codeStyleResults] = await Promise.all([
|
|
1758
1752
|
scaffoldNodeVersion({projectRoot, nodeVersionCategory}),
|
|
1759
|
-
|
|
1753
|
+
scaffoldNpmConfiguration({projectType, projectRoot}),
|
|
1760
1754
|
scaffoldDialect({
|
|
1761
1755
|
dialect,
|
|
1762
1756
|
configs,
|
|
@@ -1791,7 +1785,7 @@ async function scaffolder (options) {
|
|
|
1791
1785
|
{buildDirectory: `./${projectTypeResults.buildDirectory}`, projectRoot, projectName, nodeVersion}
|
|
1792
1786
|
),
|
|
1793
1787
|
scaffoldChoice(ciServices, ci, {projectRoot, vcs, visibility, projectType, projectName, nodeVersion, tests}),
|
|
1794
|
-
scaffold$
|
|
1788
|
+
scaffold$5({projectRoot, projectType, configs, pathWithinParent})
|
|
1795
1789
|
])),
|
|
1796
1790
|
projectTypeResults,
|
|
1797
1791
|
verificationResults,
|
|
@@ -1805,16 +1799,16 @@ async function scaffolder (options) {
|
|
|
1805
1799
|
...mergedContributions,
|
|
1806
1800
|
documentation: scaffoldDocumentation({projectTypeResults, packageManager}),
|
|
1807
1801
|
tags: projectTypeResults.tags,
|
|
1808
|
-
vcsIgnore:
|
|
1809
|
-
verificationCommand: `${
|
|
1802
|
+
vcsIgnore: buildIgnoreLists(mergedContributions.vcsIgnore),
|
|
1803
|
+
verificationCommand: `${scaffoldGenerationCommand(packageManager)} && ${packageManager} test`
|
|
1810
1804
|
};
|
|
1811
1805
|
}
|
|
1812
1806
|
|
|
1813
|
-
function
|
|
1807
|
+
function registriesAreInUse() {
|
|
1814
1808
|
return true;
|
|
1815
1809
|
}
|
|
1816
1810
|
|
|
1817
|
-
function
|
|
1811
|
+
function buildRegistriesList(registries = {}) {
|
|
1818
1812
|
return Object.entries(registries)
|
|
1819
1813
|
.filter(([scope]) => 'publish' !== scope)
|
|
1820
1814
|
.reduce((acc, [scope, url]) => {
|
|
@@ -1825,7 +1819,7 @@ function buildRegistriesConfig (registries = {}) {
|
|
|
1825
1819
|
}
|
|
1826
1820
|
|
|
1827
1821
|
async function updateRegistriesInNpmConfig(registries, projectRoot) {
|
|
1828
|
-
const registriesForNpmConfig =
|
|
1822
|
+
const registriesForNpmConfig = buildRegistriesList(registries);
|
|
1829
1823
|
|
|
1830
1824
|
await writeNpmConfig({
|
|
1831
1825
|
projectRoot,
|
|
@@ -1841,15 +1835,15 @@ async function updateRegistriesInLockfileLintConfig(projectRoot, packageManager,
|
|
|
1841
1835
|
projectRoot,
|
|
1842
1836
|
config: {
|
|
1843
1837
|
...await read({projectRoot}),
|
|
1844
|
-
'allowed-hosts':
|
|
1838
|
+
'allowed-hosts': buildAllowedHosts({packageManager, registries})
|
|
1845
1839
|
}
|
|
1846
1840
|
});
|
|
1847
1841
|
}
|
|
1848
1842
|
|
|
1849
|
-
async function
|
|
1843
|
+
async function liftRegistries({projectRoot, packageManager, configs: {registries}}) {
|
|
1850
1844
|
await updateRegistriesInNpmConfig(registries, projectRoot);
|
|
1851
1845
|
|
|
1852
|
-
if (!(await
|
|
1846
|
+
if (!(await lockfileLintInUse({projectRoot}))) {
|
|
1853
1847
|
return scaffoldLockfileLint({projectRoot, packageManager, registries});
|
|
1854
1848
|
}
|
|
1855
1849
|
|
|
@@ -1860,8 +1854,8 @@ async function lifter ({projectRoot, packageManager, configs: {registries}}) {
|
|
|
1860
1854
|
|
|
1861
1855
|
var registriesPlugin = /*#__PURE__*/Object.freeze({
|
|
1862
1856
|
__proto__: null,
|
|
1863
|
-
lift:
|
|
1864
|
-
test:
|
|
1857
|
+
lift: liftRegistries,
|
|
1858
|
+
test: registriesAreInUse
|
|
1865
1859
|
});
|
|
1866
1860
|
|
|
1867
1861
|
async function test({projectRoot}) {
|
|
@@ -1870,7 +1864,7 @@ async function test({projectRoot}) {
|
|
|
1870
1864
|
return !!engines?.node;
|
|
1871
1865
|
}
|
|
1872
1866
|
|
|
1873
|
-
async function lift
|
|
1867
|
+
async function lift({packageDetails: {name}}) {
|
|
1874
1868
|
return {
|
|
1875
1869
|
dependencies: {javascript: {development: ['ls-engines']}},
|
|
1876
1870
|
scripts: {'lint:engines': 'ls-engines'},
|
|
@@ -1880,15 +1874,22 @@ async function lift$1({packageDetails: {name}}) {
|
|
|
1880
1874
|
|
|
1881
1875
|
var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
1882
1876
|
__proto__: null,
|
|
1883
|
-
lift: lift
|
|
1877
|
+
lift: lift,
|
|
1884
1878
|
test: test
|
|
1885
1879
|
});
|
|
1886
1880
|
|
|
1887
|
-
async function
|
|
1881
|
+
async function liftJavaScript({
|
|
1882
|
+
projectRoot,
|
|
1883
|
+
vcs,
|
|
1884
|
+
results,
|
|
1885
|
+
pathWithinParent,
|
|
1886
|
+
enhancers = {},
|
|
1887
|
+
configs = {}
|
|
1888
|
+
}) {
|
|
1888
1889
|
info('Lifting JavaScript-specific details');
|
|
1889
1890
|
|
|
1890
1891
|
const [packageManager, packageContents] = await Promise.all([
|
|
1891
|
-
|
|
1892
|
+
resolveCurrentPackageManager({projectRoot, packageManager: results.packageManager}),
|
|
1892
1893
|
promises.readFile(`${projectRoot}/package.json`, 'utf8')
|
|
1893
1894
|
]);
|
|
1894
1895
|
|
|
@@ -1915,10 +1916,10 @@ async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {
|
|
|
1915
1916
|
return enhancerResults;
|
|
1916
1917
|
}
|
|
1917
1918
|
|
|
1918
|
-
async function
|
|
1919
|
+
async function projectUsesJavaScript({projectRoot}) {
|
|
1919
1920
|
const [nvmFound, jsPackageManagerFound] = await Promise.all([
|
|
1920
|
-
|
|
1921
|
-
|
|
1921
|
+
nodeVersionMangerInUse({projectRoot}),
|
|
1922
|
+
packageManagerInUse({projectRoot})
|
|
1922
1923
|
]);
|
|
1923
1924
|
|
|
1924
1925
|
const jsProjectFound = nvmFound || jsPackageManagerFound;
|
|
@@ -1930,5 +1931,5 @@ async function tester ({projectRoot}) {
|
|
|
1930
1931
|
|
|
1931
1932
|
const questionNames = {...questionNames$2, ...questionNames$1};
|
|
1932
1933
|
|
|
1933
|
-
export { lift, questionNames,
|
|
1934
|
+
export { liftJavaScript as lift, questionNames, scaffoldJavascript as scaffold, scaffoldUnitTesting, projectUsesJavaScript as test };
|
|
1934
1935
|
//# sourceMappingURL=index.js.map
|