@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.mjs
CHANGED
|
@@ -4,18 +4,19 @@ import { validateOptions, scaffoldChoice, projectTypes, dialects as dialects$1,
|
|
|
4
4
|
import joi from 'joi';
|
|
5
5
|
import { prompt as prompt$1, Separator } from '@form8ion/overridable-prompts';
|
|
6
6
|
import { scaffold, lift as lift$3 } from '@form8ion/codecov';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { write as write$1 } from '@form8ion/config-file';
|
|
8
|
+
import { fileTypes, fileExists, writeConfigFile, applyEnhancers } from '@form8ion/core';
|
|
9
9
|
import { info, warn, error } from '@travi/cli-messages';
|
|
10
10
|
import * as commitConventionPlugin from '@form8ion/commit-convention';
|
|
11
11
|
import { scaffold as scaffold$5 } from '@form8ion/commit-convention';
|
|
12
12
|
import hoek from '@hapi/hoek';
|
|
13
13
|
import execa from '@form8ion/execa-wrapper';
|
|
14
14
|
import npmConf from 'npm-conf';
|
|
15
|
+
import { promises } from 'fs';
|
|
15
16
|
import { stringify } from 'ini';
|
|
16
17
|
import { EOL } from 'os';
|
|
17
18
|
import validatePackageName from 'validate-npm-package-name';
|
|
18
|
-
import { scaffold as scaffold$
|
|
19
|
+
import { scaffold as scaffold$3 } from '@form8ion/rollup';
|
|
19
20
|
import mustache from 'mustache';
|
|
20
21
|
import camelcase from 'camelcase';
|
|
21
22
|
import makeDir from 'make-dir';
|
|
@@ -23,10 +24,9 @@ import touch from 'touch';
|
|
|
23
24
|
import { resolve } from 'path';
|
|
24
25
|
import filedirname from 'filedirname';
|
|
25
26
|
import * as huskyPlugin from '@form8ion/husky';
|
|
26
|
-
import { scaffold as scaffold$
|
|
27
|
-
import {
|
|
28
|
-
import { scaffold as scaffold$4 } from '@form8ion/
|
|
29
|
-
import { lift as lift$4, scaffold as scaffold$3 } from '@form8ion/eslint';
|
|
27
|
+
import { scaffold as scaffold$4 } from '@form8ion/husky';
|
|
28
|
+
import { scaffold as scaffold$2 } from '@form8ion/prettier';
|
|
29
|
+
import { scaffold as scaffold$1, lift as lift$4, test as test$2 } from '@form8ion/eslint';
|
|
30
30
|
|
|
31
31
|
const questionNames$1 = {
|
|
32
32
|
UNIT_TEST_FRAMEWORK: 'unitTestFramework',
|
|
@@ -46,13 +46,15 @@ const questionNames$1 = {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
async function scaffoldC8 ({projectRoot}) {
|
|
49
|
-
await
|
|
50
|
-
|
|
51
|
-
JSON
|
|
49
|
+
await write$1({
|
|
50
|
+
name: 'c8',
|
|
51
|
+
format: fileTypes.JSON,
|
|
52
|
+
path: projectRoot,
|
|
53
|
+
config: {
|
|
52
54
|
reporter: ['lcov', 'text-summary', 'html'],
|
|
53
55
|
exclude: ['src/**/*-test.js', 'test/', 'thirdparty-wrappers/', 'vendor/']
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
56
58
|
|
|
57
59
|
return {
|
|
58
60
|
devDependencies: ['cross-env', 'c8'],
|
|
@@ -155,6 +157,87 @@ async function scaffoldUnitTesting ({projectRoot, frameworks, decisions, visibil
|
|
|
155
157
|
]);
|
|
156
158
|
}
|
|
157
159
|
|
|
160
|
+
async function scaffoldEslint ({config, projectRoot, additionalConfiguration}) {
|
|
161
|
+
const {scope} = config;
|
|
162
|
+
const {ignore} = additionalConfiguration;
|
|
163
|
+
|
|
164
|
+
return scaffold$1({scope, projectRoot, ignore});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function lifter$1 ({results: {buildDirectory, eslintConfigs, eslint}, projectRoot}) {
|
|
168
|
+
return lift$4({projectRoot, configs: [...eslintConfigs || [], ...eslint?.configs || []], buildDirectory});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect}) {
|
|
172
|
+
await write$1({
|
|
173
|
+
format: fileTypes.JSON,
|
|
174
|
+
path: projectRoot,
|
|
175
|
+
name: 'remark',
|
|
176
|
+
config: {
|
|
177
|
+
settings: {
|
|
178
|
+
listItemIndent: 1,
|
|
179
|
+
emphasis: '_',
|
|
180
|
+
strong: '_',
|
|
181
|
+
bullet: '*',
|
|
182
|
+
incrementListMarker: false
|
|
183
|
+
},
|
|
184
|
+
plugins: [
|
|
185
|
+
config,
|
|
186
|
+
['remark-toc', {tight: true}],
|
|
187
|
+
...projectTypes.PACKAGE === projectType ? [['remark-usage', {heading: 'example'}]] : [],
|
|
188
|
+
...!vcs ? [['validate-links', {repository: false}]] : []
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
return deepmerge(
|
|
194
|
+
{
|
|
195
|
+
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
196
|
+
scripts: {
|
|
197
|
+
'lint:md': 'remark . --frail',
|
|
198
|
+
'generate:md': 'remark . --output'
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
...projectTypes.PACKAGE === projectType && {
|
|
203
|
+
devDependencies: ['remark-usage'],
|
|
204
|
+
...dialects$1.COMMON_JS !== dialect && {scripts: {'pregenerate:md': 'run-s build'}}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async function scaffoldCodeStyle ({
|
|
211
|
+
projectRoot,
|
|
212
|
+
projectType,
|
|
213
|
+
dialect,
|
|
214
|
+
configs,
|
|
215
|
+
vcs,
|
|
216
|
+
configureLinting,
|
|
217
|
+
eslint
|
|
218
|
+
}) {
|
|
219
|
+
return deepmerge.all(await Promise.all([
|
|
220
|
+
configs.eslint
|
|
221
|
+
&& configureLinting
|
|
222
|
+
&& scaffoldEslint({projectRoot, config: configs.eslint, additionalConfiguration: eslint}),
|
|
223
|
+
scaffoldRemark({
|
|
224
|
+
projectRoot,
|
|
225
|
+
projectType,
|
|
226
|
+
dialect,
|
|
227
|
+
vcs,
|
|
228
|
+
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
229
|
+
}),
|
|
230
|
+
scaffold$2({projectRoot, config: configs.prettier})
|
|
231
|
+
].filter(Boolean)));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var codeStylePlugin = /*#__PURE__*/Object.freeze({
|
|
235
|
+
__proto__: null,
|
|
236
|
+
scaffold: scaffoldCodeStyle,
|
|
237
|
+
lift: lifter$1,
|
|
238
|
+
test: test$2
|
|
239
|
+
});
|
|
240
|
+
|
|
158
241
|
async function test$1({projectRoot}) {
|
|
159
242
|
const {engines} = JSON.parse(await promises.readFile(`${projectRoot}/package.json`, 'utf8'));
|
|
160
243
|
|
|
@@ -202,8 +285,8 @@ async function scaffoldBabel ({projectRoot, preset}) {
|
|
|
202
285
|
};
|
|
203
286
|
}
|
|
204
287
|
|
|
205
|
-
async function lifter ({
|
|
206
|
-
await addIgnore({ignore: buildDirectory, projectRoot});
|
|
288
|
+
async function lifter ({results, projectRoot}) {
|
|
289
|
+
await addIgnore({ignore: results.buildDirectory, projectRoot});
|
|
207
290
|
|
|
208
291
|
return {};
|
|
209
292
|
}
|
|
@@ -457,32 +540,23 @@ async function lift ({projectRoot, vcs, results}) {
|
|
|
457
540
|
const {
|
|
458
541
|
scripts,
|
|
459
542
|
tags,
|
|
460
|
-
eslintConfigs,
|
|
461
|
-
eslint,
|
|
462
543
|
dependencies,
|
|
463
544
|
devDependencies,
|
|
464
|
-
packageManager: manager
|
|
465
|
-
buildDirectory
|
|
545
|
+
packageManager: manager
|
|
466
546
|
} = results;
|
|
467
547
|
|
|
468
548
|
const packageManager = await resolvePackageManager({projectRoot, packageManager: manager});
|
|
469
549
|
|
|
470
|
-
const eslintResults = await lift$4({
|
|
471
|
-
projectRoot,
|
|
472
|
-
configs: [...eslintConfigs || [], ...eslint?.configs || []],
|
|
473
|
-
buildDirectory
|
|
474
|
-
});
|
|
475
550
|
const enhancerResults = await applyEnhancers({
|
|
476
551
|
results,
|
|
477
|
-
enhancers: [huskyPlugin, enginesEnhancer, coveragePlugin, commitConventionPlugin, dialects],
|
|
478
|
-
options: {packageManager, projectRoot, vcs
|
|
552
|
+
enhancers: [huskyPlugin, enginesEnhancer, coveragePlugin, commitConventionPlugin, dialects, codeStylePlugin],
|
|
553
|
+
options: {packageManager, projectRoot, vcs}
|
|
479
554
|
});
|
|
480
555
|
|
|
481
556
|
await liftPackage(
|
|
482
557
|
deepmerge.all([
|
|
483
558
|
{projectRoot, scripts, tags, dependencies, devDependencies, packageManager},
|
|
484
|
-
enhancerResults
|
|
485
|
-
eslintResults
|
|
559
|
+
enhancerResults
|
|
486
560
|
])
|
|
487
561
|
);
|
|
488
562
|
|
|
@@ -1118,7 +1192,7 @@ const defaultBuildDirectory = 'bin';
|
|
|
1118
1192
|
|
|
1119
1193
|
async function scaffoldCliType ({packageName, visibility, projectRoot, dialect, publishRegistry}) {
|
|
1120
1194
|
const [rollupResults] = await Promise.all([
|
|
1121
|
-
scaffold$
|
|
1195
|
+
scaffold$3({projectRoot, dialect, projectType: projectTypes.CLI}),
|
|
1122
1196
|
mergeIntoExistingPackageJson({
|
|
1123
1197
|
projectRoot,
|
|
1124
1198
|
config: {
|
|
@@ -1295,15 +1369,17 @@ async function scaffoldLockfileLint ({projectRoot, packageManager, registries})
|
|
|
1295
1369
|
);
|
|
1296
1370
|
}
|
|
1297
1371
|
|
|
1298
|
-
await
|
|
1299
|
-
|
|
1300
|
-
JSON
|
|
1372
|
+
await write$1({
|
|
1373
|
+
name: 'lockfile-lint',
|
|
1374
|
+
format: fileTypes.JSON,
|
|
1375
|
+
path: projectRoot,
|
|
1376
|
+
config: {
|
|
1301
1377
|
path: determineLockfilePathFor(packageManager),
|
|
1302
1378
|
type: packageManager,
|
|
1303
1379
|
'validate-https': true,
|
|
1304
1380
|
'allowed-hosts': buildAllowedHostsList({packageManager, registries})
|
|
1305
|
-
}
|
|
1306
|
-
);
|
|
1381
|
+
}
|
|
1382
|
+
});
|
|
1307
1383
|
|
|
1308
1384
|
return {
|
|
1309
1385
|
devDependencies: ['lockfile-lint'],
|
|
@@ -1342,82 +1418,12 @@ async function scaffoldVerification({
|
|
|
1342
1418
|
pathWithinParent
|
|
1343
1419
|
}),
|
|
1344
1420
|
scaffoldLinting({projectRoot, packageManager, registries, vcs, pathWithinParent}),
|
|
1345
|
-
scaffold$
|
|
1421
|
+
scaffold$4({projectRoot, packageManager, pathWithinParent})
|
|
1346
1422
|
]);
|
|
1347
1423
|
|
|
1348
1424
|
return deepmerge.all([testingResults, lintingResults, huskyResults]);
|
|
1349
1425
|
}
|
|
1350
1426
|
|
|
1351
|
-
async function scaffoldEslint ({config, projectRoot, additionalConfiguration}) {
|
|
1352
|
-
const {scope} = config;
|
|
1353
|
-
const {ignore} = additionalConfiguration;
|
|
1354
|
-
|
|
1355
|
-
return scaffold$3({scope, projectRoot, ignore});
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect}) {
|
|
1359
|
-
await write$1({
|
|
1360
|
-
format: fileTypes.JSON,
|
|
1361
|
-
path: projectRoot,
|
|
1362
|
-
name: 'remark',
|
|
1363
|
-
config: {
|
|
1364
|
-
settings: {
|
|
1365
|
-
listItemIndent: 1,
|
|
1366
|
-
emphasis: '_',
|
|
1367
|
-
strong: '_',
|
|
1368
|
-
bullet: '*',
|
|
1369
|
-
incrementListMarker: false
|
|
1370
|
-
},
|
|
1371
|
-
plugins: [
|
|
1372
|
-
config,
|
|
1373
|
-
['remark-toc', {tight: true}],
|
|
1374
|
-
...projectTypes.PACKAGE === projectType ? [['remark-usage', {heading: 'example'}]] : [],
|
|
1375
|
-
...!vcs ? [['validate-links', {repository: false}]] : []
|
|
1376
|
-
]
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
|
-
|
|
1380
|
-
return deepmerge(
|
|
1381
|
-
{
|
|
1382
|
-
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
1383
|
-
scripts: {
|
|
1384
|
-
'lint:md': 'remark . --frail',
|
|
1385
|
-
'generate:md': 'remark . --output'
|
|
1386
|
-
}
|
|
1387
|
-
},
|
|
1388
|
-
{
|
|
1389
|
-
...projectTypes.PACKAGE === projectType && {
|
|
1390
|
-
devDependencies: ['remark-usage'],
|
|
1391
|
-
...dialects$1.COMMON_JS !== dialect && {scripts: {'pregenerate:md': 'run-s build'}}
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
);
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
async function scaffoldCodeStyle ({
|
|
1398
|
-
projectRoot,
|
|
1399
|
-
projectType,
|
|
1400
|
-
dialect,
|
|
1401
|
-
configs,
|
|
1402
|
-
vcs,
|
|
1403
|
-
configureLinting,
|
|
1404
|
-
eslint
|
|
1405
|
-
}) {
|
|
1406
|
-
return deepmerge.all(await Promise.all([
|
|
1407
|
-
configs.eslint
|
|
1408
|
-
&& configureLinting
|
|
1409
|
-
&& scaffoldEslint({projectRoot, config: configs.eslint, additionalConfiguration: eslint}),
|
|
1410
|
-
scaffoldRemark({
|
|
1411
|
-
projectRoot,
|
|
1412
|
-
projectType,
|
|
1413
|
-
dialect,
|
|
1414
|
-
vcs,
|
|
1415
|
-
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
1416
|
-
}),
|
|
1417
|
-
scaffold$4({projectRoot, config: configs.prettier})
|
|
1418
|
-
].filter(Boolean)));
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
1427
|
async function scaffolder (options) {
|
|
1422
1428
|
info('Initializing JavaScript project');
|
|
1423
1429
|
|
|
@@ -1469,38 +1475,36 @@ async function scaffolder (options) {
|
|
|
1469
1475
|
description,
|
|
1470
1476
|
pathWithinParent
|
|
1471
1477
|
});
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
})
|
|
1503
|
-
]);
|
|
1478
|
+
const projectTypeResults = await scaffoldProjectType({
|
|
1479
|
+
projectType,
|
|
1480
|
+
projectRoot,
|
|
1481
|
+
projectName,
|
|
1482
|
+
packageName,
|
|
1483
|
+
packageManager,
|
|
1484
|
+
visibility,
|
|
1485
|
+
applicationTypes,
|
|
1486
|
+
packageTypes,
|
|
1487
|
+
packageBundlers,
|
|
1488
|
+
monorepoTypes,
|
|
1489
|
+
scope,
|
|
1490
|
+
tests,
|
|
1491
|
+
vcs,
|
|
1492
|
+
decisions,
|
|
1493
|
+
dialect,
|
|
1494
|
+
publishRegistry: registries.publish
|
|
1495
|
+
});
|
|
1496
|
+
const verificationResults = await scaffoldVerification({
|
|
1497
|
+
projectRoot,
|
|
1498
|
+
dialect,
|
|
1499
|
+
visibility,
|
|
1500
|
+
packageManager,
|
|
1501
|
+
vcs,
|
|
1502
|
+
registries,
|
|
1503
|
+
tests,
|
|
1504
|
+
unitTestFrameworks,
|
|
1505
|
+
decisions,
|
|
1506
|
+
pathWithinParent
|
|
1507
|
+
});
|
|
1504
1508
|
const [nodeVersion, npmResults, dialectResults, codeStyleResults, projectTypePluginResults] = await Promise.all([
|
|
1505
1509
|
scaffoldNodeVersion({projectRoot, nodeVersionCategory}),
|
|
1506
1510
|
scaffoldNpmConfig({projectType, projectRoot, registries}),
|