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