@form8ion/javascript 5.7.0 → 5.9.1
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.cjs.js +137 -104
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +141 -108
- package/lib/index.es.js.map +1 -1
- package/package.json +3 -3
package/lib/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
|
-
import { validateOptions, scaffoldChoice, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers
|
|
3
|
+
import { validateOptions, scaffoldChoice, dialects, projectTypes, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers } from '@form8ion/javascript-core';
|
|
4
4
|
import * as joi from 'joi';
|
|
5
5
|
import { Separator } from 'inquirer';
|
|
6
6
|
import { prompt as prompt$1 } from '@form8ion/overridable-prompts';
|
|
7
7
|
import { scaffold, lift as lift$3 } from '@form8ion/codecov';
|
|
8
8
|
import { promises } from 'fs';
|
|
9
|
-
import { fileExists,
|
|
9
|
+
import { fileExists, writeConfigFile, fileTypes, applyEnhancers } from '@form8ion/core';
|
|
10
10
|
import { info, error, warn } from '@travi/cli-messages';
|
|
11
11
|
import * as commitConventionPlugin from '@form8ion/commit-convention';
|
|
12
12
|
import { scaffold as scaffold$4 } from '@form8ion/commit-convention';
|
|
@@ -24,7 +24,7 @@ import { resolve } from 'path';
|
|
|
24
24
|
import * as huskyPlugin from '@form8ion/husky';
|
|
25
25
|
import { scaffold as scaffold$3 } from '@form8ion/husky';
|
|
26
26
|
import { lift as lift$4, scaffold as scaffold$2 } from '@form8ion/eslint';
|
|
27
|
-
import { write } from '@form8ion/config-file';
|
|
27
|
+
import { write as write$1 } from '@form8ion/config-file';
|
|
28
28
|
|
|
29
29
|
function ownKeys(object, enumerableOnly) {
|
|
30
30
|
var keys = Object.keys(object);
|
|
@@ -137,7 +137,7 @@ async function removeNyc ({
|
|
|
137
137
|
projectRoot,
|
|
138
138
|
packageManager
|
|
139
139
|
}) {
|
|
140
|
-
await Promise.all([promises.unlink(`${projectRoot}/.nycrc`), promises.
|
|
140
|
+
await Promise.all([promises.unlink(`${projectRoot}/.nycrc`), promises.rm(`${projectRoot}/.nyc_output`, {
|
|
141
141
|
recursive: true,
|
|
142
142
|
force: true
|
|
143
143
|
}), removeDependencies({
|
|
@@ -284,6 +284,110 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
|
284
284
|
lift: lift$1
|
|
285
285
|
});
|
|
286
286
|
|
|
287
|
+
function write({
|
|
288
|
+
projectRoot,
|
|
289
|
+
config
|
|
290
|
+
}) {
|
|
291
|
+
return writeConfigFile({
|
|
292
|
+
format: fileTypes.JSON,
|
|
293
|
+
name: 'package',
|
|
294
|
+
path: projectRoot,
|
|
295
|
+
config
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function scaffoldScripts () {
|
|
300
|
+
return {};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function projectWillBeTested(scripts) {
|
|
304
|
+
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function projectShouldBeBuiltForVerification(scripts) {
|
|
308
|
+
return 'run-s build' === scripts['pregenerate:md'];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function updateTestScript (scripts) {
|
|
312
|
+
return _objectSpread2(_objectSpread2({}, scripts), {}, {
|
|
313
|
+
test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function liftScripts ({
|
|
318
|
+
existingScripts,
|
|
319
|
+
scripts
|
|
320
|
+
}) {
|
|
321
|
+
return updateTestScript(_objectSpread2(_objectSpread2({}, existingScripts), scripts));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
325
|
+
return vcs && 'github' === vcs.host && {
|
|
326
|
+
repository: pathWithinParent ? {
|
|
327
|
+
type: 'git',
|
|
328
|
+
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
329
|
+
directory: pathWithinParent
|
|
330
|
+
} : `${vcs.owner}/${vcs.name}`,
|
|
331
|
+
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
332
|
+
homepage: projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function buildPackageDetails ({
|
|
337
|
+
packageName,
|
|
338
|
+
projectType,
|
|
339
|
+
dialect,
|
|
340
|
+
license,
|
|
341
|
+
vcs,
|
|
342
|
+
author,
|
|
343
|
+
description,
|
|
344
|
+
packageProperties,
|
|
345
|
+
pathWithinParent
|
|
346
|
+
}) {
|
|
347
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
348
|
+
name: packageName,
|
|
349
|
+
description,
|
|
350
|
+
license,
|
|
351
|
+
type: dialects.ESM === dialect ? 'module' : 'commonjs'
|
|
352
|
+
}, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
|
|
353
|
+
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
354
|
+
scripts: scaffoldScripts()
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async function scaffoldPackage ({
|
|
359
|
+
projectRoot,
|
|
360
|
+
projectType,
|
|
361
|
+
dialect,
|
|
362
|
+
packageName,
|
|
363
|
+
license,
|
|
364
|
+
vcs,
|
|
365
|
+
author,
|
|
366
|
+
description,
|
|
367
|
+
packageProperties,
|
|
368
|
+
pathWithinParent
|
|
369
|
+
}) {
|
|
370
|
+
info('Configuring package.json');
|
|
371
|
+
const packageData = await buildPackageDetails({
|
|
372
|
+
packageName,
|
|
373
|
+
projectType,
|
|
374
|
+
dialect,
|
|
375
|
+
license,
|
|
376
|
+
vcs,
|
|
377
|
+
author,
|
|
378
|
+
description,
|
|
379
|
+
packageProperties,
|
|
380
|
+
pathWithinParent
|
|
381
|
+
});
|
|
382
|
+
await write({
|
|
383
|
+
projectRoot,
|
|
384
|
+
config: packageData
|
|
385
|
+
});
|
|
386
|
+
return {
|
|
387
|
+
homepage: packageData.homepage
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
287
391
|
async function liftPackage ({
|
|
288
392
|
projectRoot,
|
|
289
393
|
scripts,
|
|
@@ -298,11 +402,17 @@ async function liftPackage ({
|
|
|
298
402
|
});
|
|
299
403
|
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
300
404
|
const existingPackageJsonContents = JSON.parse(await promises.readFile(pathToPackageJson, 'utf8'));
|
|
301
|
-
await
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
405
|
+
await write({
|
|
406
|
+
projectRoot,
|
|
407
|
+
config: _objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
|
|
408
|
+
scripts: liftScripts({
|
|
409
|
+
existingScripts: existingPackageJsonContents.scripts,
|
|
410
|
+
scripts
|
|
411
|
+
})
|
|
412
|
+
}, tags && {
|
|
413
|
+
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
414
|
+
})
|
|
415
|
+
});
|
|
306
416
|
}
|
|
307
417
|
|
|
308
418
|
info('Installing dependencies');
|
|
@@ -664,7 +774,7 @@ async function scaffoldBabel ({
|
|
|
664
774
|
throw new Error('No babel preset provided. Cannot configure babel transpilation');
|
|
665
775
|
}
|
|
666
776
|
|
|
667
|
-
await write({
|
|
777
|
+
await write$1({
|
|
668
778
|
path: projectRoot,
|
|
669
779
|
name: 'babel',
|
|
670
780
|
format: fileTypes.JSON,
|
|
@@ -856,87 +966,6 @@ function buildVcsIgnoreLists (vcsIgnoreLists = {}) {
|
|
|
856
966
|
};
|
|
857
967
|
}
|
|
858
968
|
|
|
859
|
-
function projectWillBeTested(scripts) {
|
|
860
|
-
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
function projectShouldBeBuiltForVerification(scripts) {
|
|
864
|
-
return 'run-s build' === scripts['pregenerate:md'];
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
function defineScripts(scripts) {
|
|
868
|
-
return {
|
|
869
|
-
test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
874
|
-
return vcs && 'github' === vcs.host && {
|
|
875
|
-
repository: pathWithinParent ? {
|
|
876
|
-
type: 'git',
|
|
877
|
-
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
878
|
-
directory: pathWithinParent
|
|
879
|
-
} : `${vcs.owner}/${vcs.name}`,
|
|
880
|
-
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
881
|
-
homepage: projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
function buildPackageDetails ({
|
|
886
|
-
packageName,
|
|
887
|
-
projectType,
|
|
888
|
-
dialect,
|
|
889
|
-
license,
|
|
890
|
-
vcs,
|
|
891
|
-
author,
|
|
892
|
-
description,
|
|
893
|
-
scripts,
|
|
894
|
-
packageProperties,
|
|
895
|
-
pathWithinParent
|
|
896
|
-
}) {
|
|
897
|
-
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
898
|
-
name: packageName,
|
|
899
|
-
description,
|
|
900
|
-
license,
|
|
901
|
-
type: dialects.ESM === dialect ? 'module' : 'commonjs'
|
|
902
|
-
}, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
|
|
903
|
-
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
904
|
-
scripts: defineScripts(scripts)
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
async function scaffoldPackage ({
|
|
909
|
-
projectRoot,
|
|
910
|
-
projectType,
|
|
911
|
-
dialect,
|
|
912
|
-
scripts,
|
|
913
|
-
packageName,
|
|
914
|
-
license,
|
|
915
|
-
vcs,
|
|
916
|
-
author,
|
|
917
|
-
description,
|
|
918
|
-
packageProperties,
|
|
919
|
-
pathWithinParent
|
|
920
|
-
}) {
|
|
921
|
-
info('Configuring package.json');
|
|
922
|
-
const packageData = await buildPackageDetails({
|
|
923
|
-
packageName,
|
|
924
|
-
projectType,
|
|
925
|
-
dialect,
|
|
926
|
-
license,
|
|
927
|
-
vcs,
|
|
928
|
-
author,
|
|
929
|
-
description,
|
|
930
|
-
scripts,
|
|
931
|
-
packageProperties,
|
|
932
|
-
pathWithinParent
|
|
933
|
-
});
|
|
934
|
-
await promises.writeFile(`${projectRoot}/package.json`, JSON.stringify(packageData));
|
|
935
|
-
return {
|
|
936
|
-
homepage: packageData.homepage
|
|
937
|
-
};
|
|
938
|
-
}
|
|
939
|
-
|
|
940
969
|
function buildPackageName (projectName, scope) {
|
|
941
970
|
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
942
971
|
const {
|
|
@@ -1437,22 +1466,27 @@ async function scaffoldRemark ({
|
|
|
1437
1466
|
vcs,
|
|
1438
1467
|
dialect
|
|
1439
1468
|
}) {
|
|
1440
|
-
await
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1469
|
+
await write$1({
|
|
1470
|
+
format: fileTypes.JSON,
|
|
1471
|
+
path: projectRoot,
|
|
1472
|
+
name: 'remark',
|
|
1473
|
+
config: {
|
|
1474
|
+
settings: {
|
|
1475
|
+
listItemIndent: 1,
|
|
1476
|
+
emphasis: '_',
|
|
1477
|
+
strong: '_',
|
|
1478
|
+
bullet: '*',
|
|
1479
|
+
incrementListMarker: false
|
|
1480
|
+
},
|
|
1481
|
+
plugins: [config, ['remark-toc', {
|
|
1482
|
+
tight: true
|
|
1483
|
+
}], ...(projectTypes.PACKAGE === projectType ? [['remark-usage', {
|
|
1484
|
+
heading: 'example'
|
|
1485
|
+
}]] : []), ...(!vcs ? [['validate-links', {
|
|
1486
|
+
repository: false
|
|
1487
|
+
}]] : [])]
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1456
1490
|
return deepmerge({
|
|
1457
1491
|
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
1458
1492
|
scripts: {
|
|
@@ -1730,7 +1764,6 @@ async function scaffolder (options) {
|
|
|
1730
1764
|
author,
|
|
1731
1765
|
description,
|
|
1732
1766
|
packageProperties: mergedContributions.packageProperties,
|
|
1733
|
-
scripts: mergedContributions.scripts,
|
|
1734
1767
|
pathWithinParent
|
|
1735
1768
|
});
|
|
1736
1769
|
const liftResults = await lift({
|