@form8ion/javascript 8.2.0 → 8.5.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 +2 -1
- package/example.js +2 -1
- package/lib/index.js +52 -25
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +52 -25
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
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
|
|
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
|
}),
|
|
@@ -469,6 +463,7 @@ function sortPackageProperties (packageContents) {
|
|
|
469
463
|
'description',
|
|
470
464
|
'license',
|
|
471
465
|
'version',
|
|
466
|
+
'type',
|
|
472
467
|
'engines',
|
|
473
468
|
'author',
|
|
474
469
|
'repository',
|
|
@@ -477,12 +472,15 @@ function sortPackageProperties (packageContents) {
|
|
|
477
472
|
'keywords',
|
|
478
473
|
'runkitExampleFilename',
|
|
479
474
|
'exports',
|
|
475
|
+
'bin',
|
|
480
476
|
'main',
|
|
481
477
|
'module',
|
|
482
|
-
'
|
|
483
|
-
'publishConfig',
|
|
478
|
+
'types',
|
|
484
479
|
'sideEffects',
|
|
485
480
|
'scripts',
|
|
481
|
+
'files',
|
|
482
|
+
'publishConfig',
|
|
483
|
+
'config',
|
|
486
484
|
'dependencies',
|
|
487
485
|
'devDependencies',
|
|
488
486
|
'peerDependencies'
|
|
@@ -711,14 +709,14 @@ function buildDialectChoices ({babelPreset, typescript}) {
|
|
|
711
709
|
];
|
|
712
710
|
}
|
|
713
711
|
|
|
714
|
-
function projectIsPackage(answers) {
|
|
715
|
-
return javascriptCore.projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
716
|
-
}
|
|
717
|
-
|
|
718
712
|
function projectIsCLI(answers) {
|
|
719
713
|
return javascriptCore.projectTypes.CLI === answers[questionNames$1.PROJECT_TYPE];
|
|
720
714
|
}
|
|
721
715
|
|
|
716
|
+
function projectIsPackage(answers) {
|
|
717
|
+
return javascriptCore.projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
718
|
+
}
|
|
719
|
+
|
|
722
720
|
function projectIsApplication(answers) {
|
|
723
721
|
return javascriptCore.projectTypes.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
|
|
724
722
|
}
|
|
@@ -810,6 +808,7 @@ async function prompt(
|
|
|
810
808
|
[questionNames$1.AUTHOR_EMAIL]: authorEmail,
|
|
811
809
|
[questionNames$1.AUTHOR_URL]: authorUrl,
|
|
812
810
|
[questionNames$1.CONFIGURE_LINTING]: configureLinting,
|
|
811
|
+
[questionNames$1.PROVIDE_EXAMPLE]: provideExample,
|
|
813
812
|
[questionNames$1.PACKAGE_MANAGER]: packageManager,
|
|
814
813
|
[questionNames$1.DIALECT]: dialect
|
|
815
814
|
} = await overridablePrompts.prompt([
|
|
@@ -867,6 +866,12 @@ async function prompt(
|
|
|
867
866
|
type: 'confirm',
|
|
868
867
|
when: lintingPromptShouldBePresented
|
|
869
868
|
},
|
|
869
|
+
{
|
|
870
|
+
name: questionNames$1.PROVIDE_EXAMPLE,
|
|
871
|
+
message: 'Should an example be provided in the README?',
|
|
872
|
+
type: 'confirm',
|
|
873
|
+
when: projectIsPackage
|
|
874
|
+
},
|
|
870
875
|
{
|
|
871
876
|
name: questionNames$1.HOST,
|
|
872
877
|
type: 'list',
|
|
@@ -885,6 +890,7 @@ async function prompt(
|
|
|
885
890
|
nodeVersionCategory,
|
|
886
891
|
author: {name: authorName, email: authorEmail, url: authorUrl},
|
|
887
892
|
configureLinting: false !== configureLinting,
|
|
893
|
+
provideExample,
|
|
888
894
|
packageManager,
|
|
889
895
|
dialect
|
|
890
896
|
};
|
|
@@ -1015,7 +1021,7 @@ function getInstallationCommand(packageManager) {
|
|
|
1015
1021
|
);
|
|
1016
1022
|
}
|
|
1017
1023
|
|
|
1018
|
-
function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility}) {
|
|
1024
|
+
function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility, provideExample}) {
|
|
1019
1025
|
return {
|
|
1020
1026
|
usage: `### Installation
|
|
1021
1027
|
${'Private' === visibility ? `
|
|
@@ -1025,11 +1031,14 @@ access to private packages under \`@${scope}\`
|
|
|
1025
1031
|
}
|
|
1026
1032
|
\`\`\`sh
|
|
1027
1033
|
$ ${getInstallationCommand(packageManager)} ${packageName}
|
|
1028
|
-
|
|
1034
|
+
\`\`\`${provideExample
|
|
1035
|
+
? `
|
|
1029
1036
|
|
|
1030
1037
|
### Example
|
|
1031
1038
|
|
|
1032
1039
|
run \`${buildDocumentationCommand(packageManager)}\` to inject the usage example`
|
|
1040
|
+
: ''
|
|
1041
|
+
}`
|
|
1033
1042
|
};
|
|
1034
1043
|
}
|
|
1035
1044
|
|
|
@@ -1079,10 +1088,12 @@ async function createExample(projectRoot, projectName) {
|
|
|
1079
1088
|
);
|
|
1080
1089
|
}
|
|
1081
1090
|
|
|
1082
|
-
async function buildDetailsForCommonJsProject({projectRoot, projectName}) {
|
|
1091
|
+
async function buildDetailsForCommonJsProject({projectRoot, projectName, provideExample}) {
|
|
1083
1092
|
await Promise.all([
|
|
1084
1093
|
touch__default["default"](`${projectRoot}/index.js`),
|
|
1085
|
-
|
|
1094
|
+
provideExample
|
|
1095
|
+
? fs.promises.writeFile(`${projectRoot}/example.js`, `const ${camelcase__default["default"](projectName)} = require('.');\n`)
|
|
1096
|
+
: Promise.resolve()
|
|
1086
1097
|
]);
|
|
1087
1098
|
|
|
1088
1099
|
return {};
|
|
@@ -1095,16 +1106,17 @@ async function buildDetails ({
|
|
|
1095
1106
|
packageName,
|
|
1096
1107
|
packageBundlers,
|
|
1097
1108
|
dialect,
|
|
1109
|
+
provideExample,
|
|
1098
1110
|
decisions
|
|
1099
1111
|
}) {
|
|
1100
|
-
if (javascriptCore.dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName});
|
|
1112
|
+
if (javascriptCore.dialects.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName, provideExample});
|
|
1101
1113
|
|
|
1102
1114
|
const chosenBundler = await chooseBundler({bundlers: packageBundlers, decisions});
|
|
1103
1115
|
|
|
1104
1116
|
const pathToCreatedSrcDirectory = await makeDir__default["default"](`${projectRoot}/src`);
|
|
1105
1117
|
const [bundlerResults] = await Promise.all([
|
|
1106
1118
|
javascriptCore.scaffoldChoice(packageBundlers, chosenBundler, {projectRoot, dialect, projectType: javascriptCore.projectTypes.PACKAGE}),
|
|
1107
|
-
await createExample(projectRoot, projectName),
|
|
1119
|
+
provideExample ? await createExample(projectRoot, projectName) : Promise.resolve,
|
|
1108
1120
|
touch__default["default"](`${pathToCreatedSrcDirectory}/index.js`)
|
|
1109
1121
|
]);
|
|
1110
1122
|
|
|
@@ -1116,7 +1128,8 @@ async function buildDetails ({
|
|
|
1116
1128
|
clean: `rimraf ./${defaultBuildDirectory$2}`,
|
|
1117
1129
|
prebuild: 'run-s clean',
|
|
1118
1130
|
build: 'npm-run-all --print-label --parallel build:*',
|
|
1119
|
-
prepack: 'run-s build'
|
|
1131
|
+
prepack: 'run-s build',
|
|
1132
|
+
...provideExample && {'pregenerate:md': 'run-s build'}
|
|
1120
1133
|
},
|
|
1121
1134
|
vcsIgnore: {directories: [`/${defaultBuildDirectory$2}/`]},
|
|
1122
1135
|
buildDirectory: defaultBuildDirectory$2,
|
|
@@ -1145,12 +1158,22 @@ async function scaffoldPackageType ({
|
|
|
1145
1158
|
packageBundlers,
|
|
1146
1159
|
decisions,
|
|
1147
1160
|
dialect,
|
|
1161
|
+
provideExample,
|
|
1148
1162
|
publishRegistry
|
|
1149
1163
|
}) {
|
|
1150
1164
|
cliMessages.info('Scaffolding Package Details');
|
|
1151
1165
|
|
|
1152
1166
|
const [detailsForBuild] = await Promise.all([
|
|
1153
|
-
buildDetails({
|
|
1167
|
+
buildDetails({
|
|
1168
|
+
projectRoot,
|
|
1169
|
+
projectName,
|
|
1170
|
+
packageBundlers,
|
|
1171
|
+
visibility,
|
|
1172
|
+
packageName,
|
|
1173
|
+
dialect,
|
|
1174
|
+
provideExample,
|
|
1175
|
+
decisions
|
|
1176
|
+
}),
|
|
1154
1177
|
javascriptCore.mergeIntoExistingPackageJson({
|
|
1155
1178
|
projectRoot,
|
|
1156
1179
|
config: {
|
|
@@ -1189,7 +1212,7 @@ async function scaffoldPackageType ({
|
|
|
1189
1212
|
|
|
1190
1213
|
return deepmerge__default["default"].all([
|
|
1191
1214
|
{
|
|
1192
|
-
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager}),
|
|
1215
|
+
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager, provideExample}),
|
|
1193
1216
|
nextSteps: [
|
|
1194
1217
|
{summary: 'Add the appropriate `save` flag to the installation instructions in the README'},
|
|
1195
1218
|
{summary: 'Publish pre-release versions to npm until package is stable enough to publish v1.0.0'}
|
|
@@ -1287,6 +1310,7 @@ async function scaffoldProjectType ({
|
|
|
1287
1310
|
vcs,
|
|
1288
1311
|
decisions,
|
|
1289
1312
|
dialect,
|
|
1313
|
+
provideExample,
|
|
1290
1314
|
publishRegistry
|
|
1291
1315
|
}) {
|
|
1292
1316
|
switch (projectType) {
|
|
@@ -1302,6 +1326,7 @@ async function scaffoldProjectType ({
|
|
|
1302
1326
|
vcs,
|
|
1303
1327
|
decisions,
|
|
1304
1328
|
dialect,
|
|
1329
|
+
provideExample,
|
|
1305
1330
|
publishRegistry
|
|
1306
1331
|
});
|
|
1307
1332
|
case javascriptCore.projectTypes.APPLICATION:
|
|
@@ -1504,6 +1529,7 @@ async function scaffolder (options) {
|
|
|
1504
1529
|
nodeVersionCategory,
|
|
1505
1530
|
author,
|
|
1506
1531
|
configureLinting,
|
|
1532
|
+
provideExample,
|
|
1507
1533
|
packageManager,
|
|
1508
1534
|
dialect
|
|
1509
1535
|
} = await prompt(overrides, ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent);
|
|
@@ -1538,6 +1564,7 @@ async function scaffolder (options) {
|
|
|
1538
1564
|
vcs,
|
|
1539
1565
|
decisions,
|
|
1540
1566
|
dialect,
|
|
1567
|
+
provideExample,
|
|
1541
1568
|
publishRegistry: registries.publish
|
|
1542
1569
|
});
|
|
1543
1570
|
const verificationResults = await scaffoldVerification({
|
|
@@ -1562,7 +1589,7 @@ async function scaffolder (options) {
|
|
|
1562
1589
|
projectType,
|
|
1563
1590
|
testFilenamePattern: verificationResults.testFilenamePattern
|
|
1564
1591
|
}),
|
|
1565
|
-
scaffoldCodeStyle({projectRoot, projectType,
|
|
1592
|
+
scaffoldCodeStyle({projectRoot, projectType, configs, vcs, configureLinting})
|
|
1566
1593
|
]);
|
|
1567
1594
|
const projectTypePluginResults = await scaffoldProjectTypePlugin({
|
|
1568
1595
|
projectRoot,
|