@form8ion/javascript 5.8.0 → 6.0.0-alpha.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.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, dialects, projectTypes, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers } from '@form8ion/javascript-core';
3
+ import { validateOptions, scaffoldChoice, dialects, projectTypes, writePackageJson, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers, mergeIntoExistingPackageJson } 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, writeConfigFile, fileTypes, applyEnhancers } from '@form8ion/core';
9
+ import { fileExists, applyEnhancers, fileTypes } 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 as write$1 } from '@form8ion/config-file';
27
+ import { write } 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.rmdir(`${projectRoot}/.nyc_output`, {
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,16 +284,8 @@ 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
- });
287
+ function scaffoldScripts () {
288
+ return {};
297
289
  }
298
290
 
299
291
  function projectWillBeTested(scripts) {
@@ -304,10 +296,17 @@ function projectShouldBeBuiltForVerification(scripts) {
304
296
  return 'run-s build' === scripts['pregenerate:md'];
305
297
  }
306
298
 
307
- function defineScripts(scripts) {
308
- return {
299
+ function updateTestScript (scripts) {
300
+ return _objectSpread2(_objectSpread2({}, scripts), {}, {
309
301
  test: `npm-run-all --print-label${projectShouldBeBuiltForVerification(scripts) ? ' build' : ''} --parallel lint:*${projectWillBeTested(scripts) ? ' --parallel test:*' : ''}`
310
- };
302
+ });
303
+ }
304
+
305
+ function liftScripts ({
306
+ existingScripts,
307
+ scripts
308
+ }) {
309
+ return updateTestScript(_objectSpread2(_objectSpread2({}, existingScripts), scripts));
311
310
  }
312
311
 
313
312
  function defineVcsHostDetails(vcs, packageType, packageName, pathWithinParent) {
@@ -330,18 +329,16 @@ function buildPackageDetails ({
330
329
  vcs,
331
330
  author,
332
331
  description,
333
- scripts,
334
- packageProperties,
335
332
  pathWithinParent
336
333
  }) {
337
- return _objectSpread2(_objectSpread2(_objectSpread2({
334
+ return _objectSpread2(_objectSpread2({
338
335
  name: packageName,
339
336
  description,
340
337
  license,
341
338
  type: dialects.ESM === dialect ? 'module' : 'commonjs'
342
- }, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
339
+ }, defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
343
340
  author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
344
- scripts: defineScripts(scripts)
341
+ scripts: scaffoldScripts()
345
342
  });
346
343
  }
347
344
 
@@ -349,13 +346,11 @@ async function scaffoldPackage ({
349
346
  projectRoot,
350
347
  projectType,
351
348
  dialect,
352
- scripts,
353
349
  packageName,
354
350
  license,
355
351
  vcs,
356
352
  author,
357
353
  description,
358
- packageProperties,
359
354
  pathWithinParent
360
355
  }) {
361
356
  info('Configuring package.json');
@@ -367,11 +362,9 @@ async function scaffoldPackage ({
367
362
  vcs,
368
363
  author,
369
364
  description,
370
- scripts,
371
- packageProperties,
372
365
  pathWithinParent
373
366
  });
374
- await write({
367
+ await writePackageJson({
375
368
  projectRoot,
376
369
  config: packageData
377
370
  });
@@ -380,13 +373,6 @@ async function scaffoldPackage ({
380
373
  };
381
374
  }
382
375
 
383
- function liftScripts ({
384
- existingScripts,
385
- scripts
386
- }) {
387
- return _objectSpread2(_objectSpread2({}, existingScripts), scripts);
388
- }
389
-
390
376
  async function liftPackage ({
391
377
  projectRoot,
392
378
  scripts,
@@ -401,7 +387,7 @@ async function liftPackage ({
401
387
  });
402
388
  const pathToPackageJson = `${projectRoot}/package.json`;
403
389
  const existingPackageJsonContents = JSON.parse(await promises.readFile(pathToPackageJson, 'utf8'));
404
- await write({
390
+ await writePackageJson({
405
391
  projectRoot,
406
392
  config: _objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
407
393
  scripts: liftScripts({
@@ -773,7 +759,7 @@ async function scaffoldBabel ({
773
759
  throw new Error('No babel preset provided. Cannot configure babel transpilation');
774
760
  }
775
761
 
776
- await write$1({
762
+ await write({
777
763
  path: projectRoot,
778
764
  name: 'babel',
779
765
  format: fileTypes.JSON,
@@ -821,16 +807,6 @@ async function scaffoldTypescript ({
821
807
  };
822
808
  }
823
809
 
824
- function scaffoldEsm () {
825
- return {
826
- packageProperties: {
827
- engines: {
828
- node: '>=12.20'
829
- }
830
- }
831
- };
832
- }
833
-
834
810
  function scaffoldDialect ({
835
811
  dialect,
836
812
  projectType,
@@ -855,13 +831,8 @@ function scaffoldDialect ({
855
831
  testFilenamePattern
856
832
  });
857
833
 
858
- case dialects.ESM:
859
- return scaffoldEsm();
860
-
861
834
  default:
862
- return {
863
- eslint: {}
864
- };
835
+ return {};
865
836
  }
866
837
  }
867
838
 
@@ -1128,7 +1099,7 @@ async function scaffoldPackageType ({
1128
1099
  publishRegistry
1129
1100
  }) {
1130
1101
  info('Scaffolding Package Details');
1131
- const detailsForBuild = await buildDetails({
1102
+ const [detailsForBuild] = await Promise.all([buildDetails({
1132
1103
  projectRoot,
1133
1104
  projectName,
1134
1105
  packageBundlers,
@@ -1136,28 +1107,29 @@ async function scaffoldPackageType ({
1136
1107
  packageName,
1137
1108
  dialect,
1138
1109
  decisions
1139
- });
1140
-
1141
- const details = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, dialects.BABEL === dialect && _objectSpread2({
1142
- packageProperties: {
1110
+ }), mergeIntoExistingPackageJson({
1111
+ projectRoot,
1112
+ config: _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
1113
+ files: ['example.js', ...(dialects.COMMON_JS === dialect ? ['index.js'] : ['lib/'])],
1114
+ publishConfig: _objectSpread2({
1115
+ access: 'Public' === visibility ? 'public' : 'restricted'
1116
+ }, publishRegistry && {
1117
+ registry: publishRegistry
1118
+ }),
1119
+ sideEffects: false
1120
+ }, 'Public' === visibility && {
1121
+ runkitExampleFilename: './example.js'
1122
+ }), dialects.BABEL === dialect && {
1143
1123
  main: './lib/index.cjs.js',
1144
1124
  module: './lib/index.es.js',
1145
1125
  exports: {
1146
1126
  require: './lib/index.cjs.js',
1147
1127
  import: './lib/index.es.js'
1148
- },
1149
- sideEffects: false,
1150
- files: ['lib/']
1151
- }
1152
- }, detailsForBuild)), dialects.ESM === dialect && _objectSpread2({
1153
- packageProperties: {
1128
+ }
1129
+ }), dialects.ESM === dialect && {
1154
1130
  main: './lib/index.es.js',
1155
- exports: './lib/index.es.js',
1156
- sideEffects: false,
1157
- files: ['lib/']
1158
- }
1159
- }, detailsForBuild)), dialects.TYPESCRIPT === dialect && _objectSpread2({
1160
- packageProperties: {
1131
+ exports: './lib/index.es.js'
1132
+ }), dialects.TYPESCRIPT === dialect && {
1161
1133
  main: './lib/index.cjs.js',
1162
1134
  module: './lib/index.es.js',
1163
1135
  types: './lib/index.d.ts',
@@ -1165,16 +1137,9 @@ async function scaffoldPackageType ({
1165
1137
  types: './lib/index.d.ts',
1166
1138
  require: './lib/index.cjs.js',
1167
1139
  import: './lib/index.es.js'
1168
- },
1169
- sideEffects: false,
1170
- files: ['lib/']
1171
- }
1172
- }, detailsForBuild)), dialects.COMMON_JS === dialect && _objectSpread2({
1173
- packageProperties: {
1174
- files: ['index.js']
1175
- }
1176
- }, detailsForBuild));
1177
-
1140
+ }
1141
+ })
1142
+ })]);
1178
1143
  const chosenType = await chooseApplicationType({
1179
1144
  types: packageTypes,
1180
1145
  projectType: 'package',
@@ -1187,17 +1152,7 @@ async function scaffoldPackageType ({
1187
1152
  tests,
1188
1153
  scope
1189
1154
  });
1190
- return deepmerge.all([{
1191
- packageProperties: _objectSpread2({
1192
- files: ['example.js'],
1193
- publishConfig: _objectSpread2({
1194
- access: 'Public' === visibility ? 'public' : 'restricted'
1195
- }, publishRegistry && {
1196
- registry: publishRegistry
1197
- })
1198
- }, 'Public' === visibility && {
1199
- runkitExampleFilename: './example.js'
1200
- }),
1155
+ return deepmerge.all([_objectSpread2(_objectSpread2({}, detailsForBuild), {}, {
1201
1156
  documentation: scaffoldPackageDocumentation({
1202
1157
  packageName,
1203
1158
  visibility,
@@ -1212,7 +1167,7 @@ async function scaffoldPackageType ({
1212
1167
  }],
1213
1168
  scripts: {},
1214
1169
  badges: defineBadges(packageName, visibility)
1215
- }, results, details]);
1170
+ }), results]);
1216
1171
  }
1217
1172
 
1218
1173
  const defaultBuildDirectory$1 = 'lib';
@@ -1226,11 +1181,16 @@ async function scaffoldApplicationType ({
1226
1181
  decisions
1227
1182
  }) {
1228
1183
  info('Scaffolding Application Details');
1229
- const chosenType = await chooseApplicationType({
1184
+ const [chosenType] = await Promise.all([chooseApplicationType({
1230
1185
  types: applicationTypes,
1231
1186
  projectType: 'application',
1232
1187
  decisions
1233
- });
1188
+ }), mergeIntoExistingPackageJson({
1189
+ projectRoot,
1190
+ config: {
1191
+ private: true
1192
+ }
1193
+ })]);
1234
1194
  const results = await scaffoldChoice(applicationTypes, chosenType, {
1235
1195
  projectRoot,
1236
1196
  projectName,
@@ -1252,9 +1212,6 @@ async function scaffoldApplicationType ({
1252
1212
  directories: [`/${buildDirectory}/`]
1253
1213
  },
1254
1214
  buildDirectory,
1255
- packageProperties: {
1256
- private: true
1257
- },
1258
1215
  eslintConfigs: [],
1259
1216
  nextSteps: []
1260
1217
  }, results);
@@ -1296,11 +1253,22 @@ async function scaffoldCliType ({
1296
1253
  dialect,
1297
1254
  publishRegistry
1298
1255
  }) {
1299
- const rollupResults = await scaffold$1({
1256
+ const [rollupResults] = await Promise.all([scaffold$1({
1300
1257
  projectRoot,
1301
1258
  dialect,
1302
1259
  projectType: projectTypes.CLI
1303
- });
1260
+ }), mergeIntoExistingPackageJson({
1261
+ projectRoot,
1262
+ config: {
1263
+ bin: {},
1264
+ files: [`${defaultBuildDirectory}/`],
1265
+ publishConfig: _objectSpread2({
1266
+ access: 'Public' === visibility ? 'public' : 'restricted'
1267
+ }, publishRegistry && {
1268
+ registry: publishRegistry
1269
+ })
1270
+ }
1271
+ })]);
1304
1272
  return deepmerge(rollupResults, {
1305
1273
  scripts: {
1306
1274
  clean: `rimraf ./${defaultBuildDirectory}`,
@@ -1316,16 +1284,6 @@ async function scaffoldCliType ({
1316
1284
  },
1317
1285
  buildDirectory: defaultBuildDirectory,
1318
1286
  badges: defineBadges(packageName, visibility),
1319
- packageProperties: {
1320
- version: '0.0.0-semantically-released',
1321
- bin: {},
1322
- files: [`${defaultBuildDirectory}/`],
1323
- publishConfig: _objectSpread2({
1324
- access: 'Public' === visibility ? 'public' : 'restricted'
1325
- }, publishRegistry && {
1326
- registry: publishRegistry
1327
- })
1328
- },
1329
1287
  eslintConfigs: [],
1330
1288
  nextSteps: []
1331
1289
  });
@@ -1465,7 +1423,7 @@ async function scaffoldRemark ({
1465
1423
  vcs,
1466
1424
  dialect
1467
1425
  }) {
1468
- await write$1({
1426
+ await write({
1469
1427
  format: fileTypes.JSON,
1470
1428
  path: projectRoot,
1471
1429
  name: 'remark',
@@ -1682,6 +1640,19 @@ async function scaffolder (options) {
1682
1640
  level: 'secondary'
1683
1641
  });
1684
1642
  const packageName = buildPackageName(projectName, scope);
1643
+ const {
1644
+ homepage: projectHomepage
1645
+ } = await scaffoldPackage({
1646
+ projectRoot,
1647
+ projectType,
1648
+ dialect,
1649
+ packageName,
1650
+ license,
1651
+ vcs,
1652
+ author,
1653
+ description,
1654
+ pathWithinParent
1655
+ });
1685
1656
  const projectTypeResults = await scaffoldProjectType({
1686
1657
  projectType,
1687
1658
  projectRoot,
@@ -1751,21 +1722,6 @@ async function scaffolder (options) {
1751
1722
  configs,
1752
1723
  pathWithinParent
1753
1724
  })])), projectTypeResults, verificationResults, npmResults, dialectResults]);
1754
- const {
1755
- homepage: projectHomepage
1756
- } = await scaffoldPackage({
1757
- projectRoot,
1758
- projectType,
1759
- dialect,
1760
- packageName,
1761
- license,
1762
- vcs,
1763
- author,
1764
- description,
1765
- packageProperties: mergedContributions.packageProperties,
1766
- scripts: mergedContributions.scripts,
1767
- pathWithinParent
1768
- });
1769
1725
  const liftResults = await lift({
1770
1726
  results: deepmerge({
1771
1727
  devDependencies: ['npm-run-all'],