@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 CHANGED
@@ -171,7 +171,7 @@ async function removeNyc ({
171
171
  projectRoot,
172
172
  packageManager
173
173
  }) {
174
- await Promise.all([fs.promises.unlink(`${projectRoot}/.nycrc`), fs.promises.rmdir(`${projectRoot}/.nyc_output`, {
174
+ await Promise.all([fs.promises.unlink(`${projectRoot}/.nycrc`), fs.promises.rm(`${projectRoot}/.nyc_output`, {
175
175
  recursive: true,
176
176
  force: true
177
177
  }), removeDependencies({
@@ -318,6 +318,110 @@ 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 scaffoldScripts () {
334
+ return {};
335
+ }
336
+
337
+ function projectWillBeTested(scripts) {
338
+ return Object.keys(scripts).find(scriptName => scriptName.startsWith('test:'));
339
+ }
340
+
341
+ function projectShouldBeBuiltForVerification(scripts) {
342
+ return 'run-s build' === scripts['pregenerate:md'];
343
+ }
344
+
345
+ function updateTestScript (scripts) {
346
+ return _objectSpread2(_objectSpread2({}, scripts), {}, {
347
+ test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
348
+ });
349
+ }
350
+
351
+ function liftScripts ({
352
+ existingScripts,
353
+ scripts
354
+ }) {
355
+ return updateTestScript(_objectSpread2(_objectSpread2({}, existingScripts), scripts));
356
+ }
357
+
358
+ function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
359
+ return vcs && 'github' === vcs.host && {
360
+ repository: pathWithinParent ? {
361
+ type: 'git',
362
+ url: `https://github.com/${vcs.owner}/${vcs.name}.git`,
363
+ directory: pathWithinParent
364
+ } : `${vcs.owner}/${vcs.name}`,
365
+ bugs: `https://github.com/${vcs.owner}/${vcs.name}/issues`,
366
+ homepage: javascriptCore.projectTypes.PACKAGE === packageType ? `https://npm.im/${packageName}` : `https://github.com/${vcs.owner}/${vcs.name}#readme`
367
+ };
368
+ }
369
+
370
+ function buildPackageDetails ({
371
+ packageName,
372
+ projectType,
373
+ dialect,
374
+ license,
375
+ vcs,
376
+ author,
377
+ description,
378
+ packageProperties,
379
+ pathWithinParent
380
+ }) {
381
+ return _objectSpread2(_objectSpread2(_objectSpread2({
382
+ name: packageName,
383
+ description,
384
+ license,
385
+ type: javascriptCore.dialects.ESM === dialect ? 'module' : 'commonjs'
386
+ }, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
387
+ author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
388
+ scripts: scaffoldScripts()
389
+ });
390
+ }
391
+
392
+ async function scaffoldPackage ({
393
+ projectRoot,
394
+ projectType,
395
+ dialect,
396
+ packageName,
397
+ license,
398
+ vcs,
399
+ author,
400
+ description,
401
+ packageProperties,
402
+ pathWithinParent
403
+ }) {
404
+ cliMessages.info('Configuring package.json');
405
+ const packageData = await buildPackageDetails({
406
+ packageName,
407
+ projectType,
408
+ dialect,
409
+ license,
410
+ vcs,
411
+ author,
412
+ description,
413
+ packageProperties,
414
+ pathWithinParent
415
+ });
416
+ await write({
417
+ projectRoot,
418
+ config: packageData
419
+ });
420
+ return {
421
+ homepage: packageData.homepage
422
+ };
423
+ }
424
+
321
425
  async function liftPackage ({
322
426
  projectRoot,
323
427
  scripts,
@@ -332,11 +436,17 @@ async function liftPackage ({
332
436
  });
333
437
  const pathToPackageJson = `${projectRoot}/package.json`;
334
438
  const existingPackageJsonContents = JSON.parse(await fs.promises.readFile(pathToPackageJson, 'utf8'));
335
- await fs.promises.writeFile(pathToPackageJson, JSON.stringify(_objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
336
- scripts: _objectSpread2(_objectSpread2({}, existingPackageJsonContents.scripts), scripts)
337
- }, tags && {
338
- keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
339
- }), null, 2));
439
+ await write({
440
+ projectRoot,
441
+ config: _objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
442
+ scripts: liftScripts({
443
+ existingScripts: existingPackageJsonContents.scripts,
444
+ scripts
445
+ })
446
+ }, tags && {
447
+ keywords: existingPackageJsonContents.keywords ? [...existingPackageJsonContents.keywords, ...tags] : tags
448
+ })
449
+ });
340
450
  }
341
451
 
342
452
  cliMessages.info('Installing dependencies');
@@ -890,87 +1000,6 @@ function buildVcsIgnoreLists (vcsIgnoreLists = {}) {
890
1000
  };
891
1001
  }
892
1002
 
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
1003
  function buildPackageName (projectName, scope) {
975
1004
  const name = `${scope ? `@${scope}/` : ''}${projectName}`;
976
1005
  const {
@@ -1471,22 +1500,27 @@ async function scaffoldRemark ({
1471
1500
  vcs,
1472
1501
  dialect
1473
1502
  }) {
1474
- await fs.promises.writeFile(`${projectRoot}/.remarkrc.json`, JSON.stringify({
1475
- settings: {
1476
- listItemIndent: 1,
1477
- emphasis: '_',
1478
- strong: '_',
1479
- bullet: '*',
1480
- incrementListMarker: false
1481
- },
1482
- plugins: [config, ['remark-toc', {
1483
- tight: true
1484
- }], ...(javascriptCore.projectTypes.PACKAGE === projectType ? [['remark-usage', {
1485
- heading: 'example'
1486
- }]] : []), ...(!vcs ? [['validate-links', {
1487
- repository: false
1488
- }]] : [])]
1489
- }));
1503
+ await configFile.write({
1504
+ format: core.fileTypes.JSON,
1505
+ path: projectRoot,
1506
+ name: 'remark',
1507
+ config: {
1508
+ settings: {
1509
+ listItemIndent: 1,
1510
+ emphasis: '_',
1511
+ strong: '_',
1512
+ bullet: '*',
1513
+ incrementListMarker: false
1514
+ },
1515
+ plugins: [config, ['remark-toc', {
1516
+ tight: true
1517
+ }], ...(javascriptCore.projectTypes.PACKAGE === projectType ? [['remark-usage', {
1518
+ heading: 'example'
1519
+ }]] : []), ...(!vcs ? [['validate-links', {
1520
+ repository: false
1521
+ }]] : [])]
1522
+ }
1523
+ });
1490
1524
  return deepmerge__default["default"]({
1491
1525
  devDependencies: [config, 'remark-cli', 'remark-toc'],
1492
1526
  scripts: {
@@ -1764,7 +1798,6 @@ async function scaffolder (options) {
1764
1798
  author,
1765
1799
  description,
1766
1800
  packageProperties: mergedContributions.packageProperties,
1767
- scripts: mergedContributions.scripts,
1768
1801
  pathWithinParent
1769
1802
  });
1770
1803
  const liftResults = await lift({