@form8ion/javascript 5.9.1 → 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);
@@ -284,18 +284,6 @@ 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
287
  function scaffoldScripts () {
300
288
  return {};
301
289
  }
@@ -341,15 +329,14 @@ function buildPackageDetails ({
341
329
  vcs,
342
330
  author,
343
331
  description,
344
- packageProperties,
345
332
  pathWithinParent
346
333
  }) {
347
- return _objectSpread2(_objectSpread2(_objectSpread2({
334
+ return _objectSpread2(_objectSpread2({
348
335
  name: packageName,
349
336
  description,
350
337
  license,
351
338
  type: dialects.ESM === dialect ? 'module' : 'commonjs'
352
- }, packageProperties), defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
339
+ }, defineVcsHostDetails(vcs, projectType, packageName, pathWithinParent)), {}, {
353
340
  author: `${author.name}${author.email ? ` <${author.email}>` : ''}${author.url ? ` (${author.url})` : ''}`,
354
341
  scripts: scaffoldScripts()
355
342
  });
@@ -364,7 +351,6 @@ async function scaffoldPackage ({
364
351
  vcs,
365
352
  author,
366
353
  description,
367
- packageProperties,
368
354
  pathWithinParent
369
355
  }) {
370
356
  info('Configuring package.json');
@@ -376,10 +362,9 @@ async function scaffoldPackage ({
376
362
  vcs,
377
363
  author,
378
364
  description,
379
- packageProperties,
380
365
  pathWithinParent
381
366
  });
382
- await write({
367
+ await writePackageJson({
383
368
  projectRoot,
384
369
  config: packageData
385
370
  });
@@ -402,7 +387,7 @@ async function liftPackage ({
402
387
  });
403
388
  const pathToPackageJson = `${projectRoot}/package.json`;
404
389
  const existingPackageJsonContents = JSON.parse(await promises.readFile(pathToPackageJson, 'utf8'));
405
- await write({
390
+ await writePackageJson({
406
391
  projectRoot,
407
392
  config: _objectSpread2(_objectSpread2({}, existingPackageJsonContents), {}, {
408
393
  scripts: liftScripts({
@@ -774,7 +759,7 @@ async function scaffoldBabel ({
774
759
  throw new Error('No babel preset provided. Cannot configure babel transpilation');
775
760
  }
776
761
 
777
- await write$1({
762
+ await write({
778
763
  path: projectRoot,
779
764
  name: 'babel',
780
765
  format: fileTypes.JSON,
@@ -822,16 +807,6 @@ async function scaffoldTypescript ({
822
807
  };
823
808
  }
824
809
 
825
- function scaffoldEsm () {
826
- return {
827
- packageProperties: {
828
- engines: {
829
- node: '>=12.20'
830
- }
831
- }
832
- };
833
- }
834
-
835
810
  function scaffoldDialect ({
836
811
  dialect,
837
812
  projectType,
@@ -856,13 +831,8 @@ function scaffoldDialect ({
856
831
  testFilenamePattern
857
832
  });
858
833
 
859
- case dialects.ESM:
860
- return scaffoldEsm();
861
-
862
834
  default:
863
- return {
864
- eslint: {}
865
- };
835
+ return {};
866
836
  }
867
837
  }
868
838
 
@@ -1129,7 +1099,7 @@ async function scaffoldPackageType ({
1129
1099
  publishRegistry
1130
1100
  }) {
1131
1101
  info('Scaffolding Package Details');
1132
- const detailsForBuild = await buildDetails({
1102
+ const [detailsForBuild] = await Promise.all([buildDetails({
1133
1103
  projectRoot,
1134
1104
  projectName,
1135
1105
  packageBundlers,
@@ -1137,28 +1107,29 @@ async function scaffoldPackageType ({
1137
1107
  packageName,
1138
1108
  dialect,
1139
1109
  decisions
1140
- });
1141
-
1142
- const details = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, dialects.BABEL === dialect && _objectSpread2({
1143
- 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 && {
1144
1123
  main: './lib/index.cjs.js',
1145
1124
  module: './lib/index.es.js',
1146
1125
  exports: {
1147
1126
  require: './lib/index.cjs.js',
1148
1127
  import: './lib/index.es.js'
1149
- },
1150
- sideEffects: false,
1151
- files: ['lib/']
1152
- }
1153
- }, detailsForBuild)), dialects.ESM === dialect && _objectSpread2({
1154
- packageProperties: {
1128
+ }
1129
+ }), dialects.ESM === dialect && {
1155
1130
  main: './lib/index.es.js',
1156
- exports: './lib/index.es.js',
1157
- sideEffects: false,
1158
- files: ['lib/']
1159
- }
1160
- }, detailsForBuild)), dialects.TYPESCRIPT === dialect && _objectSpread2({
1161
- packageProperties: {
1131
+ exports: './lib/index.es.js'
1132
+ }), dialects.TYPESCRIPT === dialect && {
1162
1133
  main: './lib/index.cjs.js',
1163
1134
  module: './lib/index.es.js',
1164
1135
  types: './lib/index.d.ts',
@@ -1166,16 +1137,9 @@ async function scaffoldPackageType ({
1166
1137
  types: './lib/index.d.ts',
1167
1138
  require: './lib/index.cjs.js',
1168
1139
  import: './lib/index.es.js'
1169
- },
1170
- sideEffects: false,
1171
- files: ['lib/']
1172
- }
1173
- }, detailsForBuild)), dialects.COMMON_JS === dialect && _objectSpread2({
1174
- packageProperties: {
1175
- files: ['index.js']
1176
- }
1177
- }, detailsForBuild));
1178
-
1140
+ }
1141
+ })
1142
+ })]);
1179
1143
  const chosenType = await chooseApplicationType({
1180
1144
  types: packageTypes,
1181
1145
  projectType: 'package',
@@ -1188,17 +1152,7 @@ async function scaffoldPackageType ({
1188
1152
  tests,
1189
1153
  scope
1190
1154
  });
1191
- return deepmerge.all([{
1192
- packageProperties: _objectSpread2({
1193
- files: ['example.js'],
1194
- publishConfig: _objectSpread2({
1195
- access: 'Public' === visibility ? 'public' : 'restricted'
1196
- }, publishRegistry && {
1197
- registry: publishRegistry
1198
- })
1199
- }, 'Public' === visibility && {
1200
- runkitExampleFilename: './example.js'
1201
- }),
1155
+ return deepmerge.all([_objectSpread2(_objectSpread2({}, detailsForBuild), {}, {
1202
1156
  documentation: scaffoldPackageDocumentation({
1203
1157
  packageName,
1204
1158
  visibility,
@@ -1213,7 +1167,7 @@ async function scaffoldPackageType ({
1213
1167
  }],
1214
1168
  scripts: {},
1215
1169
  badges: defineBadges(packageName, visibility)
1216
- }, results, details]);
1170
+ }), results]);
1217
1171
  }
1218
1172
 
1219
1173
  const defaultBuildDirectory$1 = 'lib';
@@ -1227,11 +1181,16 @@ async function scaffoldApplicationType ({
1227
1181
  decisions
1228
1182
  }) {
1229
1183
  info('Scaffolding Application Details');
1230
- const chosenType = await chooseApplicationType({
1184
+ const [chosenType] = await Promise.all([chooseApplicationType({
1231
1185
  types: applicationTypes,
1232
1186
  projectType: 'application',
1233
1187
  decisions
1234
- });
1188
+ }), mergeIntoExistingPackageJson({
1189
+ projectRoot,
1190
+ config: {
1191
+ private: true
1192
+ }
1193
+ })]);
1235
1194
  const results = await scaffoldChoice(applicationTypes, chosenType, {
1236
1195
  projectRoot,
1237
1196
  projectName,
@@ -1253,9 +1212,6 @@ async function scaffoldApplicationType ({
1253
1212
  directories: [`/${buildDirectory}/`]
1254
1213
  },
1255
1214
  buildDirectory,
1256
- packageProperties: {
1257
- private: true
1258
- },
1259
1215
  eslintConfigs: [],
1260
1216
  nextSteps: []
1261
1217
  }, results);
@@ -1297,11 +1253,22 @@ async function scaffoldCliType ({
1297
1253
  dialect,
1298
1254
  publishRegistry
1299
1255
  }) {
1300
- const rollupResults = await scaffold$1({
1256
+ const [rollupResults] = await Promise.all([scaffold$1({
1301
1257
  projectRoot,
1302
1258
  dialect,
1303
1259
  projectType: projectTypes.CLI
1304
- });
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
+ })]);
1305
1272
  return deepmerge(rollupResults, {
1306
1273
  scripts: {
1307
1274
  clean: `rimraf ./${defaultBuildDirectory}`,
@@ -1317,16 +1284,6 @@ async function scaffoldCliType ({
1317
1284
  },
1318
1285
  buildDirectory: defaultBuildDirectory,
1319
1286
  badges: defineBadges(packageName, visibility),
1320
- packageProperties: {
1321
- version: '0.0.0-semantically-released',
1322
- bin: {},
1323
- files: [`${defaultBuildDirectory}/`],
1324
- publishConfig: _objectSpread2({
1325
- access: 'Public' === visibility ? 'public' : 'restricted'
1326
- }, publishRegistry && {
1327
- registry: publishRegistry
1328
- })
1329
- },
1330
1287
  eslintConfigs: [],
1331
1288
  nextSteps: []
1332
1289
  });
@@ -1466,7 +1423,7 @@ async function scaffoldRemark ({
1466
1423
  vcs,
1467
1424
  dialect
1468
1425
  }) {
1469
- await write$1({
1426
+ await write({
1470
1427
  format: fileTypes.JSON,
1471
1428
  path: projectRoot,
1472
1429
  name: 'remark',
@@ -1683,6 +1640,19 @@ async function scaffolder (options) {
1683
1640
  level: 'secondary'
1684
1641
  });
1685
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
+ });
1686
1656
  const projectTypeResults = await scaffoldProjectType({
1687
1657
  projectType,
1688
1658
  projectRoot,
@@ -1752,20 +1722,6 @@ async function scaffolder (options) {
1752
1722
  configs,
1753
1723
  pathWithinParent
1754
1724
  })])), projectTypeResults, verificationResults, npmResults, dialectResults]);
1755
- const {
1756
- homepage: projectHomepage
1757
- } = await scaffoldPackage({
1758
- projectRoot,
1759
- projectType,
1760
- dialect,
1761
- packageName,
1762
- license,
1763
- vcs,
1764
- author,
1765
- description,
1766
- packageProperties: mergedContributions.packageProperties,
1767
- pathWithinParent
1768
- });
1769
1725
  const liftResults = await lift({
1770
1726
  results: deepmerge({
1771
1727
  devDependencies: ['npm-run-all'],