@form8ion/javascript 8.4.0 → 8.7.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/README.md CHANGED
@@ -86,7 +86,8 @@ const {
86
86
  [questionNames.AUTHOR_EMAIL]: 'you@domain.tld',
87
87
  [questionNames.AUTHOR_URL]: 'https://your.website.tld',
88
88
  [questionNames.UNIT_TESTS]: true,
89
- [questionNames.INTEGRATION_TESTS]: true
89
+ [questionNames.INTEGRATION_TESTS]: true,
90
+ [questionNames.PROVIDE_EXAMPLE]: true
90
91
  }
91
92
  });
92
93
 
package/example.js CHANGED
@@ -56,7 +56,8 @@ const {
56
56
  [questionNames.AUTHOR_EMAIL]: 'you@domain.tld',
57
57
  [questionNames.AUTHOR_URL]: 'https://your.website.tld',
58
58
  [questionNames.UNIT_TESTS]: true,
59
- [questionNames.INTEGRATION_TESTS]: true
59
+ [questionNames.INTEGRATION_TESTS]: true,
60
+ [questionNames.PROVIDE_EXAMPLE]: true
60
61
  }
61
62
  });
62
63
 
package/lib/index.js CHANGED
@@ -80,6 +80,7 @@ const questionNames$1 = {
80
80
  AUTHOR_URL: 'authorUrl',
81
81
  HOST: 'host',
82
82
  CONFIGURE_LINTING: 'configureLint',
83
+ PROVIDE_EXAMPLE: 'provideExample',
83
84
  DIALECT: 'dialect'
84
85
  };
85
86
 
@@ -195,7 +196,7 @@ async function scaffoldUnitTesting ({projectRoot, frameworks, decisions, visibil
195
196
  ]);
196
197
  }
197
198
 
198
- async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect}) {
199
+ async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
199
200
  await configFile.write({
200
201
  format: core.fileTypes.JSON,
201
202
  path: projectRoot,
@@ -225,19 +226,13 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect})
225
226
  'generate:md': 'remark . --output'
226
227
  }
227
228
  },
228
- {
229
- ...javascriptCore.projectTypes.PACKAGE === projectType && {
230
- devDependencies: ['remark-usage'],
231
- ...javascriptCore.dialects.COMMON_JS !== dialect && {scripts: {'pregenerate:md': 'run-s build'}}
232
- }
233
- }
229
+ {...javascriptCore.projectTypes.PACKAGE === projectType && {devDependencies: ['remark-usage']}}
234
230
  );
235
231
  }
236
232
 
237
233
  async function scaffoldCodeStyle ({
238
234
  projectRoot,
239
235
  projectType,
240
- dialect,
241
236
  configs,
242
237
  vcs,
243
238
  configureLinting
@@ -249,7 +244,6 @@ async function scaffoldCodeStyle ({
249
244
  scaffoldRemark({
250
245
  projectRoot,
251
246
  projectType,
252
- dialect,
253
247
  vcs,
254
248
  config: configs.remark || '@form8ion/remark-lint-preset'
255
249
  }),
@@ -472,9 +466,11 @@ function sortPackageProperties (packageContents) {
472
466
  'type',
473
467
  'engines',
474
468
  'author',
469
+ 'contributors',
475
470
  'repository',
476
471
  'bugs',
477
472
  'homepage',
473
+ 'funding',
478
474
  'keywords',
479
475
  'runkitExampleFilename',
480
476
  'exports',
@@ -715,14 +711,14 @@ function buildDialectChoices ({babelPreset, typescript}) {
715
711
  ];
716
712
  }
717
713
 
718
- function projectIsPackage(answers) {
719
- return javascriptCore.projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
720
- }
721
-
722
714
  function projectIsCLI(answers) {
723
715
  return javascriptCore.projectTypes.CLI === answers[questionNames$1.PROJECT_TYPE];
724
716
  }
725
717
 
718
+ function projectIsPackage(answers) {
719
+ return javascriptCore.projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
720
+ }
721
+
726
722
  function projectIsApplication(answers) {
727
723
  return javascriptCore.projectTypes.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
728
724
  }
@@ -814,6 +810,7 @@ async function prompt(
814
810
  [questionNames$1.AUTHOR_EMAIL]: authorEmail,
815
811
  [questionNames$1.AUTHOR_URL]: authorUrl,
816
812
  [questionNames$1.CONFIGURE_LINTING]: configureLinting,
813
+ [questionNames$1.PROVIDE_EXAMPLE]: provideExample,
817
814
  [questionNames$1.PACKAGE_MANAGER]: packageManager,
818
815
  [questionNames$1.DIALECT]: dialect
819
816
  } = await overridablePrompts.prompt([
@@ -871,6 +868,12 @@ async function prompt(
871
868
  type: 'confirm',
872
869
  when: lintingPromptShouldBePresented
873
870
  },
871
+ {
872
+ name: questionNames$1.PROVIDE_EXAMPLE,
873
+ message: 'Should an example be provided in the README?',
874
+ type: 'confirm',
875
+ when: projectIsPackage
876
+ },
874
877
  {
875
878
  name: questionNames$1.HOST,
876
879
  type: 'list',
@@ -889,6 +892,7 @@ async function prompt(
889
892
  nodeVersionCategory,
890
893
  author: {name: authorName, email: authorEmail, url: authorUrl},
891
894
  configureLinting: false !== configureLinting,
895
+ provideExample,
892
896
  packageManager,
893
897
  dialect
894
898
  };
@@ -1019,7 +1023,7 @@ function getInstallationCommand(packageManager) {
1019
1023
  );
1020
1024
  }
1021
1025
 
1022
- function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility}) {
1026
+ function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility, provideExample}) {
1023
1027
  return {
1024
1028
  usage: `### Installation
1025
1029
  ${'Private' === visibility ? `
@@ -1029,11 +1033,14 @@ access to private packages under \`@${scope}\`
1029
1033
  }
1030
1034
  \`\`\`sh
1031
1035
  $ ${getInstallationCommand(packageManager)} ${packageName}
1032
- \`\`\`
1036
+ \`\`\`${provideExample
1037
+ ? `
1033
1038
 
1034
1039
  ### Example
1035
1040
 
1036
1041
  run \`${buildDocumentationCommand(packageManager)}\` to inject the usage example`
1042
+ : ''
1043
+ }`
1037
1044
  };
1038
1045
  }
1039
1046
 
@@ -1083,10 +1090,12 @@ async function createExample(projectRoot, projectName) {
1083
1090
  );
1084
1091
  }
1085
1092
 
1086
- async function buildDetailsForCommonJsProject({projectRoot, projectName}) {
1093
+ async function buildDetailsForCommonJsProject({projectRoot, projectName, provideExample}) {
1087
1094
  await Promise.all([
1088
1095
  touch__default["default"](`${projectRoot}/index.js`),
1089
- fs.promises.writeFile(`${projectRoot}/example.js`, `const ${camelcase__default["default"](projectName)} = require('.');\n`)
1096
+ provideExample
1097
+ ? fs.promises.writeFile(`${projectRoot}/example.js`, `const ${camelcase__default["default"](projectName)} = require('.');\n`)
1098
+ : Promise.resolve()
1090
1099
  ]);
1091
1100
 
1092
1101
  return {};
@@ -1099,16 +1108,17 @@ async function buildDetails ({
1099
1108
  packageName,
1100
1109
  packageBundlers,
1101
1110
  dialect,
1111
+ provideExample,
1102
1112
  decisions
1103
1113
  }) {
1104
- if (javascriptCore.dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName});
1114
+ if (javascriptCore.dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName, provideExample});
1105
1115
 
1106
1116
  const chosenBundler = await chooseBundler({bundlers: packageBundlers, decisions});
1107
1117
 
1108
1118
  const pathToCreatedSrcDirectory = await makeDir__default["default"](`${projectRoot}/src`);
1109
1119
  const [bundlerResults] = await Promise.all([
1110
1120
  javascriptCore.scaffoldChoice(packageBundlers, chosenBundler, {projectRoot, dialect, projectType: javascriptCore.projectTypes.PACKAGE}),
1111
- await createExample(projectRoot, projectName),
1121
+ provideExample ? await createExample(projectRoot, projectName) : Promise.resolve,
1112
1122
  touch__default["default"](`${pathToCreatedSrcDirectory}/index.js`)
1113
1123
  ]);
1114
1124
 
@@ -1120,7 +1130,8 @@ async function buildDetails ({
1120
1130
  clean: `rimraf ./${defaultBuildDirectory$2}`,
1121
1131
  prebuild: 'run-s clean',
1122
1132
  build: 'npm-run-all --print-label --parallel build:*',
1123
- prepack: 'run-s build'
1133
+ prepack: 'run-s build',
1134
+ ...provideExample && {'pregenerate:md': 'run-s build'}
1124
1135
  },
1125
1136
  vcsIgnore: {directories: [`/${defaultBuildDirectory$2}/`]},
1126
1137
  buildDirectory: defaultBuildDirectory$2,
@@ -1149,12 +1160,22 @@ async function scaffoldPackageType ({
1149
1160
  packageBundlers,
1150
1161
  decisions,
1151
1162
  dialect,
1163
+ provideExample,
1152
1164
  publishRegistry
1153
1165
  }) {
1154
1166
  cliMessages.info('Scaffolding Package Details');
1155
1167
 
1156
1168
  const [detailsForBuild] = await Promise.all([
1157
- buildDetails({projectRoot, projectName, packageBundlers, visibility, packageName, dialect, decisions}),
1169
+ buildDetails({
1170
+ projectRoot,
1171
+ projectName,
1172
+ packageBundlers,
1173
+ visibility,
1174
+ packageName,
1175
+ dialect,
1176
+ provideExample,
1177
+ decisions
1178
+ }),
1158
1179
  javascriptCore.mergeIntoExistingPackageJson({
1159
1180
  projectRoot,
1160
1181
  config: {
@@ -1193,7 +1214,7 @@ async function scaffoldPackageType ({
1193
1214
 
1194
1215
  return deepmerge__default["default"].all([
1195
1216
  {
1196
- documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager}),
1217
+ documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager, provideExample}),
1197
1218
  nextSteps: [
1198
1219
  {summary: 'Add the appropriate `save` flag to the installation instructions in the README'},
1199
1220
  {summary: 'Publish pre-release versions to npm until package is stable enough to publish v1.0.0'}
@@ -1291,6 +1312,7 @@ async function scaffoldProjectType ({
1291
1312
  vcs,
1292
1313
  decisions,
1293
1314
  dialect,
1315
+ provideExample,
1294
1316
  publishRegistry
1295
1317
  }) {
1296
1318
  switch (projectType) {
@@ -1306,6 +1328,7 @@ async function scaffoldProjectType ({
1306
1328
  vcs,
1307
1329
  decisions,
1308
1330
  dialect,
1331
+ provideExample,
1309
1332
  publishRegistry
1310
1333
  });
1311
1334
  case javascriptCore.projectTypes.APPLICATION:
@@ -1508,6 +1531,7 @@ async function scaffolder (options) {
1508
1531
  nodeVersionCategory,
1509
1532
  author,
1510
1533
  configureLinting,
1534
+ provideExample,
1511
1535
  packageManager,
1512
1536
  dialect
1513
1537
  } = await prompt(overrides, ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent);
@@ -1542,6 +1566,7 @@ async function scaffolder (options) {
1542
1566
  vcs,
1543
1567
  decisions,
1544
1568
  dialect,
1569
+ provideExample,
1545
1570
  publishRegistry: registries.publish
1546
1571
  });
1547
1572
  const verificationResults = await scaffoldVerification({
@@ -1566,7 +1591,7 @@ async function scaffolder (options) {
1566
1591
  projectType,
1567
1592
  testFilenamePattern: verificationResults.testFilenamePattern
1568
1593
  }),
1569
- scaffoldCodeStyle({projectRoot, projectType, dialect, configs, vcs, configureLinting})
1594
+ scaffoldCodeStyle({projectRoot, projectType, configs, vcs, configureLinting})
1570
1595
  ]);
1571
1596
  const projectTypePluginResults = await scaffoldProjectTypePlugin({
1572
1597
  projectRoot,
@@ -1595,11 +1620,11 @@ async function scaffolder (options) {
1595
1620
  commitConventionPlugin.scaffold({projectRoot, projectType, configs, pathWithinParent})
1596
1621
  ])),
1597
1622
  projectTypeResults,
1598
- projectTypePluginResults,
1599
1623
  verificationResults,
1600
1624
  codeStyleResults,
1601
1625
  npmResults,
1602
- dialectResults
1626
+ dialectResults,
1627
+ projectTypePluginResults
1603
1628
  ]);
1604
1629
 
1605
1630
  const liftResults = await lift({