@form8ion/javascript 4.7.0 → 5.0.0

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',
@@ -408,7 +409,7 @@ async function lift ({
408
409
 
409
410
  const packageBundlersSchema = joi__namespace.object().pattern(/^/, joi__namespace.object({
410
411
  scaffolder: joi__namespace.func().arity(1).required()
411
- }));
412
+ })).default({});
412
413
 
413
414
  function validate(options) {
414
415
  const schema = joi__namespace.object().required().keys({
@@ -1043,6 +1044,20 @@ function defineBadges (packageName, visibility) {
1043
1044
  };
1044
1045
  }
1045
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
+
1046
1061
  function determinePathToTemplateFile (fileName) {
1047
1062
  return path.resolve(__dirname, '..', 'templates', fileName);
1048
1063
  }
@@ -1068,19 +1083,25 @@ async function buildDetails ({
1068
1083
  projectName,
1069
1084
  visibility,
1070
1085
  packageName,
1071
- dialect
1086
+ packageBundlers,
1087
+ dialect,
1088
+ decisions
1072
1089
  }) {
1073
1090
  if (javascriptCore.dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({
1074
1091
  projectRoot,
1075
1092
  projectName
1076
1093
  });
1094
+ const chosenBundler = await chooseBundler({
1095
+ bundlers: packageBundlers,
1096
+ decisions
1097
+ });
1077
1098
  const pathToCreatedSrcDirectory = await makeDir__default["default"](`${projectRoot}/src`);
1078
- const [rollupResults] = await Promise.all([rollup.scaffold({
1099
+ const [bundlerResults] = await Promise.all([javascriptCore.scaffoldChoice(packageBundlers, chosenBundler, {
1079
1100
  projectRoot,
1080
1101
  dialect,
1081
1102
  projectType: javascriptCore.projectTypes.PACKAGE
1082
1103
  }), await createExample(projectRoot, projectName), touch__default["default"](`${pathToCreatedSrcDirectory}/index.js`)]);
1083
- return deepmerge__default["default"](rollupResults, {
1104
+ return deepmerge__default["default"](bundlerResults, {
1084
1105
  devDependencies: ['rimraf'],
1085
1106
  scripts: {
1086
1107
  clean: `rimraf ./${defaultBuildDirectory$2}`,
@@ -1112,6 +1133,7 @@ async function scaffoldPackageType ({
1112
1133
  visibility,
1113
1134
  scope,
1114
1135
  packageTypes,
1136
+ packageBundlers,
1115
1137
  tests,
1116
1138
  decisions,
1117
1139
  dialect,
@@ -1121,9 +1143,11 @@ async function scaffoldPackageType ({
1121
1143
  const detailsForBuild = await buildDetails({
1122
1144
  projectRoot,
1123
1145
  projectName,
1146
+ packageBundlers,
1124
1147
  visibility,
1125
1148
  packageName,
1126
- dialect
1149
+ dialect,
1150
+ decisions
1127
1151
  });
1128
1152
 
1129
1153
  const details = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, javascriptCore.dialects.BABEL === dialect && _objectSpread2({
@@ -1317,6 +1341,7 @@ async function scaffoldProjectType ({
1317
1341
  visibility,
1318
1342
  applicationTypes,
1319
1343
  packageTypes,
1344
+ packageBundlers,
1320
1345
  monorepoTypes,
1321
1346
  scope,
1322
1347
  tests,
@@ -1335,6 +1360,7 @@ async function scaffoldProjectType ({
1335
1360
  visibility,
1336
1361
  scope,
1337
1362
  packageTypes,
1363
+ packageBundlers,
1338
1364
  tests,
1339
1365
  vcs,
1340
1366
  decisions,
@@ -1629,6 +1655,7 @@ async function scaffolder (options) {
1629
1655
  hosts,
1630
1656
  applicationTypes,
1631
1657
  packageTypes,
1658
+ packageBundlers,
1632
1659
  monorepoTypes,
1633
1660
  decisions,
1634
1661
  unitTestFrameworks,
@@ -1660,6 +1687,7 @@ async function scaffolder (options) {
1660
1687
  visibility,
1661
1688
  applicationTypes,
1662
1689
  packageTypes,
1690
+ packageBundlers,
1663
1691
  monorepoTypes,
1664
1692
  scope,
1665
1693
  tests,