@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.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',
@@ -374,7 +375,7 @@ async function lift ({
374
375
 
375
376
  const packageBundlersSchema = joi.object().pattern(/^/, joi.object({
376
377
  scaffolder: joi.func().arity(1).required()
377
- }));
378
+ })).default({});
378
379
 
379
380
  function validate(options) {
380
381
  const schema = joi.object().required().keys({
@@ -1009,6 +1010,20 @@ function defineBadges (packageName, visibility) {
1009
1010
  };
1010
1011
  }
1011
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
+
1012
1027
  function determinePathToTemplateFile (fileName) {
1013
1028
  return resolve(__dirname, '..', 'templates', fileName);
1014
1029
  }
@@ -1034,19 +1049,25 @@ async function buildDetails ({
1034
1049
  projectName,
1035
1050
  visibility,
1036
1051
  packageName,
1037
- dialect
1052
+ packageBundlers,
1053
+ dialect,
1054
+ decisions
1038
1055
  }) {
1039
1056
  if (dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({
1040
1057
  projectRoot,
1041
1058
  projectName
1042
1059
  });
1060
+ const chosenBundler = await chooseBundler({
1061
+ bundlers: packageBundlers,
1062
+ decisions
1063
+ });
1043
1064
  const pathToCreatedSrcDirectory = await makeDir(`${projectRoot}/src`);
1044
- const [rollupResults] = await Promise.all([scaffold$1({
1065
+ const [bundlerResults] = await Promise.all([scaffoldChoice(packageBundlers, chosenBundler, {
1045
1066
  projectRoot,
1046
1067
  dialect,
1047
1068
  projectType: projectTypes.PACKAGE
1048
1069
  }), await createExample(projectRoot, projectName), touch(`${pathToCreatedSrcDirectory}/index.js`)]);
1049
- return deepmerge(rollupResults, {
1070
+ return deepmerge(bundlerResults, {
1050
1071
  devDependencies: ['rimraf'],
1051
1072
  scripts: {
1052
1073
  clean: `rimraf ./${defaultBuildDirectory$2}`,
@@ -1078,6 +1099,7 @@ async function scaffoldPackageType ({
1078
1099
  visibility,
1079
1100
  scope,
1080
1101
  packageTypes,
1102
+ packageBundlers,
1081
1103
  tests,
1082
1104
  decisions,
1083
1105
  dialect,
@@ -1087,9 +1109,11 @@ async function scaffoldPackageType ({
1087
1109
  const detailsForBuild = await buildDetails({
1088
1110
  projectRoot,
1089
1111
  projectName,
1112
+ packageBundlers,
1090
1113
  visibility,
1091
1114
  packageName,
1092
- dialect
1115
+ dialect,
1116
+ decisions
1093
1117
  });
1094
1118
 
1095
1119
  const details = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, dialects.BABEL === dialect && _objectSpread2({
@@ -1283,6 +1307,7 @@ async function scaffoldProjectType ({
1283
1307
  visibility,
1284
1308
  applicationTypes,
1285
1309
  packageTypes,
1310
+ packageBundlers,
1286
1311
  monorepoTypes,
1287
1312
  scope,
1288
1313
  tests,
@@ -1301,6 +1326,7 @@ async function scaffoldProjectType ({
1301
1326
  visibility,
1302
1327
  scope,
1303
1328
  packageTypes,
1329
+ packageBundlers,
1304
1330
  tests,
1305
1331
  vcs,
1306
1332
  decisions,
@@ -1595,6 +1621,7 @@ async function scaffolder (options) {
1595
1621
  hosts,
1596
1622
  applicationTypes,
1597
1623
  packageTypes,
1624
+ packageBundlers,
1598
1625
  monorepoTypes,
1599
1626
  decisions,
1600
1627
  unitTestFrameworks,
@@ -1626,6 +1653,7 @@ async function scaffolder (options) {
1626
1653
  visibility,
1627
1654
  applicationTypes,
1628
1655
  packageTypes,
1656
+ packageBundlers,
1629
1657
  monorepoTypes,
1630
1658
  scope,
1631
1659
  tests,