@form8ion/javascript 7.2.4 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +133 -129
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +140 -136
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -8,13 +8,14 @@ var javascriptCore = require('@form8ion/javascript-core');
|
|
|
8
8
|
var joi = require('joi');
|
|
9
9
|
var overridablePrompts = require('@form8ion/overridable-prompts');
|
|
10
10
|
var codecov = require('@form8ion/codecov');
|
|
11
|
-
var
|
|
11
|
+
var configFile = require('@form8ion/config-file');
|
|
12
12
|
var core = require('@form8ion/core');
|
|
13
13
|
var cliMessages = require('@travi/cli-messages');
|
|
14
14
|
var commitConventionPlugin = require('@form8ion/commit-convention');
|
|
15
15
|
var hoek = require('@hapi/hoek');
|
|
16
16
|
var execa = require('@form8ion/execa-wrapper');
|
|
17
17
|
var npmConf = require('npm-conf');
|
|
18
|
+
var fs = require('fs');
|
|
18
19
|
var ini = require('ini');
|
|
19
20
|
var os = require('os');
|
|
20
21
|
var validatePackageName = require('validate-npm-package-name');
|
|
@@ -26,7 +27,6 @@ var touch = require('touch');
|
|
|
26
27
|
var path = require('path');
|
|
27
28
|
var filedirname = require('filedirname');
|
|
28
29
|
var huskyPlugin = require('@form8ion/husky');
|
|
29
|
-
var configFile = require('@form8ion/config-file');
|
|
30
30
|
var prettier = require('@form8ion/prettier');
|
|
31
31
|
var eslint = require('@form8ion/eslint');
|
|
32
32
|
|
|
@@ -82,13 +82,15 @@ const questionNames$1 = {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
async function scaffoldC8 ({projectRoot}) {
|
|
85
|
-
await
|
|
86
|
-
|
|
87
|
-
JSON
|
|
85
|
+
await configFile.write({
|
|
86
|
+
name: 'c8',
|
|
87
|
+
format: core.fileTypes.JSON,
|
|
88
|
+
path: projectRoot,
|
|
89
|
+
config: {
|
|
88
90
|
reporter: ['lcov', 'text-summary', 'html'],
|
|
89
91
|
exclude: ['src/**/*-test.js', 'test/', 'thirdparty-wrappers/', 'vendor/']
|
|
90
|
-
}
|
|
91
|
-
);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
92
94
|
|
|
93
95
|
return {
|
|
94
96
|
devDependencies: ['cross-env', 'c8'],
|
|
@@ -191,6 +193,87 @@ async function scaffoldUnitTesting ({projectRoot, frameworks, decisions, visibil
|
|
|
191
193
|
]);
|
|
192
194
|
}
|
|
193
195
|
|
|
196
|
+
async function scaffoldEslint ({config, projectRoot, additionalConfiguration}) {
|
|
197
|
+
const {scope} = config;
|
|
198
|
+
const {ignore} = additionalConfiguration;
|
|
199
|
+
|
|
200
|
+
return eslint.scaffold({scope, projectRoot, ignore});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function lifter$1 ({results: {buildDirectory, eslintConfigs, eslint: eslint$1}, projectRoot}) {
|
|
204
|
+
return eslint.lift({projectRoot, configs: [...eslintConfigs || [], ...eslint$1?.configs || []], buildDirectory});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect}) {
|
|
208
|
+
await configFile.write({
|
|
209
|
+
format: core.fileTypes.JSON,
|
|
210
|
+
path: projectRoot,
|
|
211
|
+
name: 'remark',
|
|
212
|
+
config: {
|
|
213
|
+
settings: {
|
|
214
|
+
listItemIndent: 1,
|
|
215
|
+
emphasis: '_',
|
|
216
|
+
strong: '_',
|
|
217
|
+
bullet: '*',
|
|
218
|
+
incrementListMarker: false
|
|
219
|
+
},
|
|
220
|
+
plugins: [
|
|
221
|
+
config,
|
|
222
|
+
['remark-toc', {tight: true}],
|
|
223
|
+
...javascriptCore.projectTypes.PACKAGE === projectType ? [['remark-usage', {heading: 'example'}]] : [],
|
|
224
|
+
...!vcs ? [['validate-links', {repository: false}]] : []
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return deepmerge__default["default"](
|
|
230
|
+
{
|
|
231
|
+
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
232
|
+
scripts: {
|
|
233
|
+
'lint:md': 'remark . --frail',
|
|
234
|
+
'generate:md': 'remark . --output'
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
...javascriptCore.projectTypes.PACKAGE === projectType && {
|
|
239
|
+
devDependencies: ['remark-usage'],
|
|
240
|
+
...javascriptCore.dialects.COMMON_JS !== dialect && {scripts: {'pregenerate:md': 'run-s build'}}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function scaffoldCodeStyle ({
|
|
247
|
+
projectRoot,
|
|
248
|
+
projectType,
|
|
249
|
+
dialect,
|
|
250
|
+
configs,
|
|
251
|
+
vcs,
|
|
252
|
+
configureLinting,
|
|
253
|
+
eslint
|
|
254
|
+
}) {
|
|
255
|
+
return deepmerge__default["default"].all(await Promise.all([
|
|
256
|
+
configs.eslint
|
|
257
|
+
&& configureLinting
|
|
258
|
+
&& scaffoldEslint({projectRoot, config: configs.eslint, additionalConfiguration: eslint}),
|
|
259
|
+
scaffoldRemark({
|
|
260
|
+
projectRoot,
|
|
261
|
+
projectType,
|
|
262
|
+
dialect,
|
|
263
|
+
vcs,
|
|
264
|
+
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
265
|
+
}),
|
|
266
|
+
prettier.scaffold({projectRoot, config: configs.prettier})
|
|
267
|
+
].filter(Boolean)));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
271
|
+
__proto__: null,
|
|
272
|
+
scaffold: scaffoldCodeStyle,
|
|
273
|
+
lift: lifter$1,
|
|
274
|
+
test: eslint.test
|
|
275
|
+
});
|
|
276
|
+
|
|
194
277
|
async function test$1({projectRoot}) {
|
|
195
278
|
const {engines} = JSON.parse(await fs.promises.readFile(`${projectRoot}/package.json`, 'utf8'));
|
|
196
279
|
|
|
@@ -238,8 +321,8 @@ async function scaffoldBabel ({projectRoot, preset}) {
|
|
|
238
321
|
};
|
|
239
322
|
}
|
|
240
323
|
|
|
241
|
-
async function lifter ({
|
|
242
|
-
await addIgnore({ignore: buildDirectory, projectRoot});
|
|
324
|
+
async function lifter ({results, projectRoot}) {
|
|
325
|
+
await addIgnore({ignore: results.buildDirectory, projectRoot});
|
|
243
326
|
|
|
244
327
|
return {};
|
|
245
328
|
}
|
|
@@ -493,32 +576,23 @@ async function lift ({projectRoot, vcs, results}) {
|
|
|
493
576
|
const {
|
|
494
577
|
scripts,
|
|
495
578
|
tags,
|
|
496
|
-
eslintConfigs,
|
|
497
|
-
eslint: eslint$1,
|
|
498
579
|
dependencies,
|
|
499
580
|
devDependencies,
|
|
500
|
-
packageManager: manager
|
|
501
|
-
buildDirectory
|
|
581
|
+
packageManager: manager
|
|
502
582
|
} = results;
|
|
503
583
|
|
|
504
584
|
const packageManager = await resolvePackageManager({projectRoot, packageManager: manager});
|
|
505
585
|
|
|
506
|
-
const eslintResults = await eslint.lift({
|
|
507
|
-
projectRoot,
|
|
508
|
-
configs: [...eslintConfigs || [], ...eslint$1?.configs || []],
|
|
509
|
-
buildDirectory
|
|
510
|
-
});
|
|
511
586
|
const enhancerResults = await core.applyEnhancers({
|
|
512
587
|
results,
|
|
513
|
-
enhancers: [huskyPlugin__namespace, enginesEnhancer, coveragePlugin, commitConventionPlugin__namespace, dialects],
|
|
514
|
-
options: {packageManager, projectRoot, vcs
|
|
588
|
+
enhancers: [huskyPlugin__namespace, enginesEnhancer, coveragePlugin, commitConventionPlugin__namespace, dialects, codeStylePlugin],
|
|
589
|
+
options: {packageManager, projectRoot, vcs}
|
|
515
590
|
});
|
|
516
591
|
|
|
517
592
|
await liftPackage(
|
|
518
593
|
deepmerge__default["default"].all([
|
|
519
594
|
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager},
|
|
520
|
-
enhancerResults
|
|
521
|
-
eslintResults
|
|
595
|
+
enhancerResults
|
|
522
596
|
])
|
|
523
597
|
);
|
|
524
598
|
|
|
@@ -1331,15 +1405,17 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1331
1405
|
);
|
|
1332
1406
|
}
|
|
1333
1407
|
|
|
1334
|
-
await
|
|
1335
|
-
|
|
1336
|
-
JSON
|
|
1408
|
+
await configFile.write({
|
|
1409
|
+
name: 'lockfile-lint',
|
|
1410
|
+
format: core.fileTypes.JSON,
|
|
1411
|
+
path: projectRoot,
|
|
1412
|
+
config: {
|
|
1337
1413
|
path: determineLockfilePathFor(packageManager),
|
|
1338
1414
|
type: packageManager,
|
|
1339
1415
|
'validate-https': true,
|
|
1340
1416
|
'allowed-hosts': buildAllowedHostsList({packageManager, registries})
|
|
1341
|
-
}
|
|
1342
|
-
);
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1343
1419
|
|
|
1344
1420
|
return {
|
|
1345
1421
|
devDependencies: ['lockfile-lint'],
|
|
@@ -1384,76 +1460,6 @@ async function scaffoldVerification({
|
|
|
1384
1460
|
return deepmerge__default["default"].all([testingResults, lintingResults, huskyResults]);
|
|
1385
1461
|
}
|
|
1386
1462
|
|
|
1387
|
-
async function scaffoldEslint ({config, projectRoot, additionalConfiguration}) {
|
|
1388
|
-
const {scope} = config;
|
|
1389
|
-
const {ignore} = additionalConfiguration;
|
|
1390
|
-
|
|
1391
|
-
return eslint.scaffold({scope, projectRoot, ignore});
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect}) {
|
|
1395
|
-
await configFile.write({
|
|
1396
|
-
format: core.fileTypes.JSON,
|
|
1397
|
-
path: projectRoot,
|
|
1398
|
-
name: 'remark',
|
|
1399
|
-
config: {
|
|
1400
|
-
settings: {
|
|
1401
|
-
listItemIndent: 1,
|
|
1402
|
-
emphasis: '_',
|
|
1403
|
-
strong: '_',
|
|
1404
|
-
bullet: '*',
|
|
1405
|
-
incrementListMarker: false
|
|
1406
|
-
},
|
|
1407
|
-
plugins: [
|
|
1408
|
-
config,
|
|
1409
|
-
['remark-toc', {tight: true}],
|
|
1410
|
-
...javascriptCore.projectTypes.PACKAGE === projectType ? [['remark-usage', {heading: 'example'}]] : [],
|
|
1411
|
-
...!vcs ? [['validate-links', {repository: false}]] : []
|
|
1412
|
-
]
|
|
1413
|
-
}
|
|
1414
|
-
});
|
|
1415
|
-
|
|
1416
|
-
return deepmerge__default["default"](
|
|
1417
|
-
{
|
|
1418
|
-
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
1419
|
-
scripts: {
|
|
1420
|
-
'lint:md': 'remark . --frail',
|
|
1421
|
-
'generate:md': 'remark . --output'
|
|
1422
|
-
}
|
|
1423
|
-
},
|
|
1424
|
-
{
|
|
1425
|
-
...javascriptCore.projectTypes.PACKAGE === projectType && {
|
|
1426
|
-
devDependencies: ['remark-usage'],
|
|
1427
|
-
...javascriptCore.dialects.COMMON_JS !== dialect && {scripts: {'pregenerate:md': 'run-s build'}}
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
);
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
async function scaffoldCodeStyle ({
|
|
1434
|
-
projectRoot,
|
|
1435
|
-
projectType,
|
|
1436
|
-
dialect,
|
|
1437
|
-
configs,
|
|
1438
|
-
vcs,
|
|
1439
|
-
configureLinting,
|
|
1440
|
-
eslint
|
|
1441
|
-
}) {
|
|
1442
|
-
return deepmerge__default["default"].all(await Promise.all([
|
|
1443
|
-
configs.eslint
|
|
1444
|
-
&& configureLinting
|
|
1445
|
-
&& scaffoldEslint({projectRoot, config: configs.eslint, additionalConfiguration: eslint}),
|
|
1446
|
-
scaffoldRemark({
|
|
1447
|
-
projectRoot,
|
|
1448
|
-
projectType,
|
|
1449
|
-
dialect,
|
|
1450
|
-
vcs,
|
|
1451
|
-
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
1452
|
-
}),
|
|
1453
|
-
prettier.scaffold({projectRoot, config: configs.prettier})
|
|
1454
|
-
].filter(Boolean)));
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
1463
|
async function scaffolder (options) {
|
|
1458
1464
|
cliMessages.info('Initializing JavaScript project');
|
|
1459
1465
|
|
|
@@ -1505,38 +1511,36 @@ async function scaffolder (options) {
|
|
|
1505
1511
|
description,
|
|
1506
1512
|
pathWithinParent
|
|
1507
1513
|
});
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
})
|
|
1539
|
-
]);
|
|
1514
|
+
const projectTypeResults = await scaffoldProjectType({
|
|
1515
|
+
projectType,
|
|
1516
|
+
projectRoot,
|
|
1517
|
+
projectName,
|
|
1518
|
+
packageName,
|
|
1519
|
+
packageManager,
|
|
1520
|
+
visibility,
|
|
1521
|
+
applicationTypes,
|
|
1522
|
+
packageTypes,
|
|
1523
|
+
packageBundlers,
|
|
1524
|
+
monorepoTypes,
|
|
1525
|
+
scope,
|
|
1526
|
+
tests,
|
|
1527
|
+
vcs,
|
|
1528
|
+
decisions,
|
|
1529
|
+
dialect,
|
|
1530
|
+
publishRegistry: registries.publish
|
|
1531
|
+
});
|
|
1532
|
+
const verificationResults = await scaffoldVerification({
|
|
1533
|
+
projectRoot,
|
|
1534
|
+
dialect,
|
|
1535
|
+
visibility,
|
|
1536
|
+
packageManager,
|
|
1537
|
+
vcs,
|
|
1538
|
+
registries,
|
|
1539
|
+
tests,
|
|
1540
|
+
unitTestFrameworks,
|
|
1541
|
+
decisions,
|
|
1542
|
+
pathWithinParent
|
|
1543
|
+
});
|
|
1540
1544
|
const [nodeVersion, npmResults, dialectResults, codeStyleResults, projectTypePluginResults] = await Promise.all([
|
|
1541
1545
|
scaffoldNodeVersion({projectRoot, nodeVersionCategory}),
|
|
1542
1546
|
scaffoldNpmConfig({projectType, projectRoot, registries}),
|