@form8ion/javascript 4.6.1 → 5.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
@@ -70,6 +70,7 @@ const questionNames$1 = {
70
70
  UNIT_TEST_FRAMEWORK: 'unitTestFramework',
71
71
  NODE_VERSION_CATEGORY: 'nodeVersionCategory',
72
72
  PACKAGE_MANAGER: 'packageManager',
73
+ PACKAGE_BUNDLER: 'packageBundler',
73
74
  PROJECT_TYPE: 'projectType',
74
75
  PROJECT_TYPE_CHOICE: 'projectTypeChoice',
75
76
  SHOULD_BE_SCOPED: 'shouldBeScoped',
@@ -372,6 +373,10 @@ async function lift ({
372
373
  return enhancerResults;
373
374
  }
374
375
 
376
+ const packageBundlersSchema = joi.object().pattern(/^/, joi.object({
377
+ scaffolder: joi.func().arity(1).required()
378
+ })).default({});
379
+
375
380
  function validate(options) {
376
381
  const schema = joi.object().required().keys({
377
382
  projectRoot: joi.string().required(),
@@ -437,9 +442,10 @@ function validate(options) {
437
442
  scaffolder: joi.func().arity(1).required()
438
443
  }))
439
444
  }).keys({
440
- decisions: joi.object()
445
+ unitTestFrameworks: unitTestFrameworksSchema,
446
+ packageBundlers: packageBundlersSchema
441
447
  }).keys({
442
- unitTestFrameworks: unitTestFrameworksSchema
448
+ decisions: joi.object()
443
449
  }).keys({
444
450
  registries: joi.object().pattern(joi.string(), joi.string().uri()).default({})
445
451
  });
@@ -1004,6 +1010,20 @@ function defineBadges (packageName, visibility) {
1004
1010
  };
1005
1011
  }
1006
1012
 
1013
+ async function chooseBundler ({
1014
+ bundlers,
1015
+ decisions
1016
+ }) {
1017
+ if (!Object.keys(bundlers).length) return 'Other';
1018
+ const answers = await prompt$1([{
1019
+ name: questionNames$1.PACKAGE_BUNDLER,
1020
+ type: 'list',
1021
+ message: 'Which bundler should be used?',
1022
+ choices: [...Object.keys(bundlers), new Separator(), 'Other']
1023
+ }], decisions);
1024
+ return answers[questionNames$1.PACKAGE_BUNDLER];
1025
+ }
1026
+
1007
1027
  function determinePathToTemplateFile (fileName) {
1008
1028
  return resolve(__dirname, '..', 'templates', fileName);
1009
1029
  }
@@ -1029,19 +1049,25 @@ async function buildDetails ({
1029
1049
  projectName,
1030
1050
  visibility,
1031
1051
  packageName,
1032
- dialect
1052
+ packageBundlers,
1053
+ dialect,
1054
+ decisions
1033
1055
  }) {
1034
1056
  if (dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({
1035
1057
  projectRoot,
1036
1058
  projectName
1037
1059
  });
1060
+ const chosenBundler = await chooseBundler({
1061
+ bundlers: packageBundlers,
1062
+ decisions
1063
+ });
1038
1064
  const pathToCreatedSrcDirectory = await makeDir(`${projectRoot}/src`);
1039
- const [rollupResults] = await Promise.all([scaffold$1({
1065
+ const [bundlerResults] = await Promise.all([scaffoldChoice(packageBundlers, chosenBundler, {
1040
1066
  projectRoot,
1041
1067
  dialect,
1042
1068
  projectType: projectTypes.PACKAGE
1043
1069
  }), await createExample(projectRoot, projectName), touch(`${pathToCreatedSrcDirectory}/index.js`)]);
1044
- return deepmerge(rollupResults, {
1070
+ return deepmerge(bundlerResults, {
1045
1071
  devDependencies: ['rimraf'],
1046
1072
  scripts: {
1047
1073
  clean: `rimraf ./${defaultBuildDirectory$2}`,
@@ -1073,6 +1099,7 @@ async function scaffoldPackageType ({
1073
1099
  visibility,
1074
1100
  scope,
1075
1101
  packageTypes,
1102
+ packageBundlers,
1076
1103
  tests,
1077
1104
  decisions,
1078
1105
  dialect,
@@ -1082,9 +1109,11 @@ async function scaffoldPackageType ({
1082
1109
  const detailsForBuild = await buildDetails({
1083
1110
  projectRoot,
1084
1111
  projectName,
1112
+ packageBundlers,
1085
1113
  visibility,
1086
1114
  packageName,
1087
- dialect
1115
+ dialect,
1116
+ decisions
1088
1117
  });
1089
1118
 
1090
1119
  const details = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, dialects.BABEL === dialect && _objectSpread2({
@@ -1278,6 +1307,7 @@ async function scaffoldProjectType ({
1278
1307
  visibility,
1279
1308
  applicationTypes,
1280
1309
  packageTypes,
1310
+ packageBundlers,
1281
1311
  monorepoTypes,
1282
1312
  scope,
1283
1313
  tests,
@@ -1296,6 +1326,7 @@ async function scaffoldProjectType ({
1296
1326
  visibility,
1297
1327
  scope,
1298
1328
  packageTypes,
1329
+ packageBundlers,
1299
1330
  tests,
1300
1331
  vcs,
1301
1332
  decisions,
@@ -1590,6 +1621,7 @@ async function scaffolder (options) {
1590
1621
  hosts,
1591
1622
  applicationTypes,
1592
1623
  packageTypes,
1624
+ packageBundlers,
1593
1625
  monorepoTypes,
1594
1626
  decisions,
1595
1627
  unitTestFrameworks,
@@ -1621,6 +1653,7 @@ async function scaffolder (options) {
1621
1653
  visibility,
1622
1654
  applicationTypes,
1623
1655
  packageTypes,
1656
+ packageBundlers,
1624
1657
  monorepoTypes,
1625
1658
  scope,
1626
1659
  tests,