@form8ion/javascript 5.6.0 → 5.8.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.cjs.js +136 -103
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +140 -107
- package/lib/index.es.js.map +1 -1
- package/package.json +6 -6
package/lib/index.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ var core = require('@form8ion/core');
|
|
|
14
14
|
var cliMessages = require('@travi/cli-messages');
|
|
15
15
|
var commitConventionPlugin = require('@form8ion/commit-convention');
|
|
16
16
|
var hoek = require('@hapi/hoek');
|
|
17
|
-
var execa = require('execa');
|
|
17
|
+
var execa = require('@form8ion/execa-wrapper');
|
|
18
18
|
var ini = require('ini');
|
|
19
19
|
var os = require('os');
|
|
20
20
|
var validatePackageName = require('validate-npm-package-name');
|
|
@@ -318,6 +318,109 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
|
|
|
318
318
|
lift: lift$1
|
|
319
319
|
});
|
|
320
320
|
|
|
321
|
+
function write({
|
|
322
|
+
projectRoot,
|
|
323
|
+
config
|
|
324
|
+
}) {
|
|
325
|
+
return core.writeConfigFile({
|
|
326
|
+
format: core.fileTypes.JSON,
|
|
327
|
+
name: 'package',
|
|
328
|
+
path: projectRoot,
|
|
329
|
+
config
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function projectWillBeTested(scripts) {
|
|
334
|
+
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function projectShouldBeBuiltForVerification(scripts) {
|
|
338
|
+
return 'run-s build' === scripts['pregenerate:md'];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function defineScripts(scripts) {
|
|
342
|
+
return {
|
|
343
|
+
test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
348
|
+
return vcs && 'github' === vcs.host && {
|
|
349
|
+
repository: pathWithinParent ? {
|
|
350
|
+
type: 'git',
|
|
351
|
+
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
352
|
+
directory: pathWithinParent
|
|
353
|
+
} : `${vcs.owner}/${vcs.name}`,
|
|
354
|
+
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
355
|
+
homepage: javascriptCore.projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function buildPackageDetails ({
|
|
360
|
+
packageName,
|
|
361
|
+
projectType,
|
|
362
|
+
dialect,
|
|
363
|
+
license,
|
|
364
|
+
vcs,
|
|
365
|
+
author,
|
|
366
|
+
description,
|
|
367
|
+
scripts,
|
|
368
|
+
packageProperties,
|
|
369
|
+
pathWithinParent
|
|
370
|
+
}) {
|
|
371
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
372
|
+
name: packageName,
|
|
373
|
+
description,
|
|
374
|
+
license,
|
|
375
|
+
type: javascriptCore.dialects.ESM === dialect ? 'module' : 'commonjs'
|
|
376
|
+
}, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
|
|
377
|
+
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
378
|
+
scripts: defineScripts(scripts)
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async function scaffoldPackage ({
|
|
383
|
+
projectRoot,
|
|
384
|
+
projectType,
|
|
385
|
+
dialect,
|
|
386
|
+
scripts,
|
|
387
|
+
packageName,
|
|
388
|
+
license,
|
|
389
|
+
vcs,
|
|
390
|
+
author,
|
|
391
|
+
description,
|
|
392
|
+
packageProperties,
|
|
393
|
+
pathWithinParent
|
|
394
|
+
}) {
|
|
395
|
+
cliMessages.info('Configuring package.json');
|
|
396
|
+
const packageData = await buildPackageDetails({
|
|
397
|
+
packageName,
|
|
398
|
+
projectType,
|
|
399
|
+
dialect,
|
|
400
|
+
license,
|
|
401
|
+
vcs,
|
|
402
|
+
author,
|
|
403
|
+
description,
|
|
404
|
+
scripts,
|
|
405
|
+
packageProperties,
|
|
406
|
+
pathWithinParent
|
|
407
|
+
});
|
|
408
|
+
await write({
|
|
409
|
+
projectRoot,
|
|
410
|
+
config: packageData
|
|
411
|
+
});
|
|
412
|
+
return {
|
|
413
|
+
homepage: packageData.homepage
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function liftScripts ({
|
|
418
|
+
existingScripts,
|
|
419
|
+
scripts
|
|
420
|
+
}) {
|
|
421
|
+
return _objectSpread2(_objectSpread2({}, existingScripts), scripts);
|
|
422
|
+
}
|
|
423
|
+
|
|
321
424
|
async function liftPackage ({
|
|
322
425
|
projectRoot,
|
|
323
426
|
scripts,
|
|
@@ -332,11 +435,17 @@ async function liftPackage ({
|
|
|
332
435
|
});
|
|
333
436
|
const pathToPackageJson = `${projectRoot}/package.json`;
|
|
334
437
|
const existingPackageJsonContents = JSON.parse(await fs.promises.readFile(pathToPackageJson, 'utf8'));
|
|
335
|
-
await
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
438
|
+
await write({
|
|
439
|
+
projectRoot,
|
|
440
|
+
config: _objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
|
|
441
|
+
scripts: liftScripts({
|
|
442
|
+
existingScripts: existingPackageJsonContents.scripts,
|
|
443
|
+
scripts
|
|
444
|
+
})
|
|
445
|
+
}, tags && {
|
|
446
|
+
keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
|
|
447
|
+
})
|
|
448
|
+
});
|
|
340
449
|
}
|
|
341
450
|
|
|
342
451
|
cliMessages.info('Installing dependencies');
|
|
@@ -890,87 +999,6 @@ function buildVcsIgnoreLists (vcsIgnoreLists = {}) {
|
|
|
890
999
|
};
|
|
891
1000
|
}
|
|
892
1001
|
|
|
893
|
-
function projectWillBeTested(scripts) {
|
|
894
|
-
return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
function projectShouldBeBuiltForVerification(scripts) {
|
|
898
|
-
return 'run-s build' === scripts['pregenerate:md'];
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function defineScripts(scripts) {
|
|
902
|
-
return {
|
|
903
|
-
test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
|
|
908
|
-
return vcs && 'github' === vcs.host && {
|
|
909
|
-
repository: pathWithinParent ? {
|
|
910
|
-
type: 'git',
|
|
911
|
-
url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
|
|
912
|
-
directory: pathWithinParent
|
|
913
|
-
} : `${vcs.owner}/${vcs.name}`,
|
|
914
|
-
bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
|
|
915
|
-
homepage: javascriptCore.projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
function buildPackageDetails ({
|
|
920
|
-
packageName,
|
|
921
|
-
projectType,
|
|
922
|
-
dialect,
|
|
923
|
-
license,
|
|
924
|
-
vcs,
|
|
925
|
-
author,
|
|
926
|
-
description,
|
|
927
|
-
scripts,
|
|
928
|
-
packageProperties,
|
|
929
|
-
pathWithinParent
|
|
930
|
-
}) {
|
|
931
|
-
return _objectSpread2(_objectSpread2(_objectSpread2({
|
|
932
|
-
name: packageName,
|
|
933
|
-
description,
|
|
934
|
-
license,
|
|
935
|
-
type: javascriptCore.dialects.ESM === dialect ? 'module' : 'commonjs'
|
|
936
|
-
}, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
|
|
937
|
-
author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
|
|
938
|
-
scripts: defineScripts(scripts)
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
async function scaffoldPackage ({
|
|
943
|
-
projectRoot,
|
|
944
|
-
projectType,
|
|
945
|
-
dialect,
|
|
946
|
-
scripts,
|
|
947
|
-
packageName,
|
|
948
|
-
license,
|
|
949
|
-
vcs,
|
|
950
|
-
author,
|
|
951
|
-
description,
|
|
952
|
-
packageProperties,
|
|
953
|
-
pathWithinParent
|
|
954
|
-
}) {
|
|
955
|
-
cliMessages.info('Configuring package.json');
|
|
956
|
-
const packageData = await buildPackageDetails({
|
|
957
|
-
packageName,
|
|
958
|
-
projectType,
|
|
959
|
-
dialect,
|
|
960
|
-
license,
|
|
961
|
-
vcs,
|
|
962
|
-
author,
|
|
963
|
-
description,
|
|
964
|
-
scripts,
|
|
965
|
-
packageProperties,
|
|
966
|
-
pathWithinParent
|
|
967
|
-
});
|
|
968
|
-
await fs.promises.writeFile(`${projectRoot}/package.json`, JSON.stringify(packageData));
|
|
969
|
-
return {
|
|
970
|
-
homepage: packageData.homepage
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
|
|
974
1002
|
function buildPackageName (projectName, scope) {
|
|
975
1003
|
const name = `${scope ? `@${scope}/` : ''}${projectName}`;
|
|
976
1004
|
const {
|
|
@@ -1471,22 +1499,27 @@ async function scaffoldRemark ({
|
|
|
1471
1499
|
vcs,
|
|
1472
1500
|
dialect
|
|
1473
1501
|
}) {
|
|
1474
|
-
await
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1502
|
+
await configFile.write({
|
|
1503
|
+
format: core.fileTypes.JSON,
|
|
1504
|
+
path: projectRoot,
|
|
1505
|
+
name: 'remark',
|
|
1506
|
+
config: {
|
|
1507
|
+
settings: {
|
|
1508
|
+
listItemIndent: 1,
|
|
1509
|
+
emphasis: '_',
|
|
1510
|
+
strong: '_',
|
|
1511
|
+
bullet: '*',
|
|
1512
|
+
incrementListMarker: false
|
|
1513
|
+
},
|
|
1514
|
+
plugins: [config, ['remark-toc', {
|
|
1515
|
+
tight: true
|
|
1516
|
+
}], ...(javascriptCore.projectTypes.PACKAGE === projectType ? [['remark-usage', {
|
|
1517
|
+
heading: 'example'
|
|
1518
|
+
}]] : []), ...(!vcs ? [['validate-links', {
|
|
1519
|
+
repository: false
|
|
1520
|
+
}]] : [])]
|
|
1521
|
+
}
|
|
1522
|
+
});
|
|
1490
1523
|
return deepmerge__default["default"]({
|
|
1491
1524
|
devDependencies: [config, 'remark-cli', 'remark-toc'],
|
|
1492
1525
|
scripts: {
|