@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.cjs.js CHANGED
@@ -104,6 +104,7 @@ const questionNames$1 = {
104
104
  UNIT_TEST_FRAMEWORK: 'unitTestFramework',
105
105
  NODE_VERSION_CATEGORY: 'nodeVersionCategory',
106
106
  PACKAGE_MANAGER: 'packageManager',
107
+ PACKAGE_BUNDLER: 'packageBundler',
107
108
  PROJECT_TYPE: 'projectType',
108
109
  PROJECT_TYPE_CHOICE: 'projectTypeChoice',
109
110
  SHOULD_BE_SCOPED: 'shouldBeScoped',
@@ -406,6 +407,10 @@ async function lift ({
406
407
  return enhancerResults;
407
408
  }
408
409
 
410
+ const packageBundlersSchema = joi__namespace.object().pattern(/^/, joi__namespace.object({
411
+ scaffolder: joi__namespace.func().arity(1).required()
412
+ })).default({});
413
+
409
414
  function validate(options) {
410
415
  const schema = joi__namespace.object().required().keys({
411
416
  projectRoot: joi__namespace.string().required(),
@@ -471,9 +476,10 @@ function validate(options) {
471
476
  scaffolder: joi__namespace.func().arity(1).required()
472
477
  }))
473
478
  }).keys({
474
- decisions: joi__namespace.object()
479
+ unitTestFrameworks: unitTestFrameworksSchema,
480
+ packageBundlers: packageBundlersSchema
475
481
  }).keys({
476
- unitTestFrameworks: unitTestFrameworksSchema
482
+ decisions: joi__namespace.object()
477
483
  }).keys({
478
484
  registries: joi__namespace.object().pattern(joi__namespace.string(), joi__namespace.string().uri()).default({})
479
485
  });
@@ -1038,6 +1044,20 @@ function defineBadges (packageName, visibility) {
1038
1044
  };
1039
1045
  }
1040
1046
 
1047
+ async function chooseBundler ({
1048
+ bundlers,
1049
+ decisions
1050
+ }) {
1051
+ if (!Object.keys(bundlers).length) return 'Other';
1052
+ const answers = await overridablePrompts.prompt([{
1053
+ name: questionNames$1.PACKAGE_BUNDLER,
1054
+ type: 'list',
1055
+ message: 'Which bundler should be used?',
1056
+ choices: [...Object.keys(bundlers), new inquirer.Separator(), 'Other']
1057
+ }], decisions);
1058
+ return answers[questionNames$1.PACKAGE_BUNDLER];
1059
+ }
1060
+
1041
1061
  function determinePathToTemplateFile (fileName) {
1042
1062
  return path.resolve(__dirname, '..', 'templates', fileName);
1043
1063
  }
@@ -1063,19 +1083,25 @@ async function buildDetails ({
1063
1083
  projectName,
1064
1084
  visibility,
1065
1085
  packageName,
1066
- dialect
1086
+ packageBundlers,
1087
+ dialect,
1088
+ decisions
1067
1089
  }) {
1068
1090
  if (javascriptCore.dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({
1069
1091
  projectRoot,
1070
1092
  projectName
1071
1093
  });
1094
+ const chosenBundler = await chooseBundler({
1095
+ bundlers: packageBundlers,
1096
+ decisions
1097
+ });
1072
1098
  const pathToCreatedSrcDirectory = await makeDir__default["default"](`${projectRoot}/src`);
1073
- const [rollupResults] = await Promise.all([rollup.scaffold({
1099
+ const [bundlerResults] = await Promise.all([javascriptCore.scaffoldChoice(packageBundlers, chosenBundler, {
1074
1100
  projectRoot,
1075
1101
  dialect,
1076
1102
  projectType: javascriptCore.projectTypes.PACKAGE
1077
1103
  }), await createExample(projectRoot, projectName), touch__default["default"](`${pathToCreatedSrcDirectory}/index.js`)]);
1078
- return deepmerge__default["default"](rollupResults, {
1104
+ return deepmerge__default["default"](bundlerResults, {
1079
1105
  devDependencies: ['rimraf'],
1080
1106
  scripts: {
1081
1107
  clean: `rimraf ./${defaultBuildDirectory$2}`,
@@ -1107,6 +1133,7 @@ async function scaffoldPackageType ({
1107
1133
  visibility,
1108
1134
  scope,
1109
1135
  packageTypes,
1136
+ packageBundlers,
1110
1137
  tests,
1111
1138
  decisions,
1112
1139
  dialect,
@@ -1116,9 +1143,11 @@ async function scaffoldPackageType ({
1116
1143
  const detailsForBuild = await buildDetails({
1117
1144
  projectRoot,
1118
1145
  projectName,
1146
+ packageBundlers,
1119
1147
  visibility,
1120
1148
  packageName,
1121
- dialect
1149
+ dialect,
1150
+ decisions
1122
1151
  });
1123
1152
 
1124
1153
  const details = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, javascriptCore.dialects.BABEL === dialect && _objectSpread2({
@@ -1312,6 +1341,7 @@ async function scaffoldProjectType ({
1312
1341
  visibility,
1313
1342
  applicationTypes,
1314
1343
  packageTypes,
1344
+ packageBundlers,
1315
1345
  monorepoTypes,
1316
1346
  scope,
1317
1347
  tests,
@@ -1330,6 +1360,7 @@ async function scaffoldProjectType ({
1330
1360
  visibility,
1331
1361
  scope,
1332
1362
  packageTypes,
1363
+ packageBundlers,
1333
1364
  tests,
1334
1365
  vcs,
1335
1366
  decisions,
@@ -1624,6 +1655,7 @@ async function scaffolder (options) {
1624
1655
  hosts,
1625
1656
  applicationTypes,
1626
1657
  packageTypes,
1658
+ packageBundlers,
1627
1659
  monorepoTypes,
1628
1660
  decisions,
1629
1661
  unitTestFrameworks,
@@ -1655,6 +1687,7 @@ async function scaffolder (options) {
1655
1687
  visibility,
1656
1688
  applicationTypes,
1657
1689
  packageTypes,
1690
+ packageBundlers,
1658
1691
  monorepoTypes,
1659
1692
  scope,
1660
1693
  tests,