@form8ion/javascript 8.4.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 +46 -23
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +46 -23
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -43,6 +43,7 @@ const questionNames$1 = {
|
|
|
43
43
|
AUTHOR_URL: 'authorUrl',
|
|
44
44
|
HOST: 'host',
|
|
45
45
|
CONFIGURE_LINTING: 'configureLint',
|
|
46
|
+
PROVIDE_EXAMPLE: 'provideExample',
|
|
46
47
|
DIALECT: 'dialect'
|
|
47
48
|
};
|
|
48
49
|
|
|
@@ -158,7 +159,7 @@ async function scaffoldUnitTesting ({projectRoot, frameworks, decisions, visibil
|
|
|
158
159
|
]);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
async function scaffoldRemark ({config, projectRoot, projectType, vcs
|
|
162
|
+
async function scaffoldRemark ({config, projectRoot, projectType, vcs}) {
|
|
162
163
|
await write$1({
|
|
163
164
|
format: fileTypes.JSON,
|
|
164
165
|
path: projectRoot,
|
|
@@ -188,19 +189,13 @@ async function scaffoldRemark ({config, projectRoot, projectType, vcs, dialect})
|
|
|
188
189
|
'generate:md': 'remark . --output'
|
|
189
190
|
}
|
|
190
191
|
},
|
|
191
|
-
{
|
|
192
|
-
...projectTypes.PACKAGE === projectType && {
|
|
193
|
-
devDependencies: ['remark-usage'],
|
|
194
|
-
...dialects$1.COMMON_JS !== dialect && {scripts: {'pregenerate:md': 'run-s build'}}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
192
|
+
{...projectTypes.PACKAGE === projectType && {devDependencies: ['remark-usage']}}
|
|
197
193
|
);
|
|
198
194
|
}
|
|
199
195
|
|
|
200
196
|
async function scaffoldCodeStyle ({
|
|
201
197
|
projectRoot,
|
|
202
198
|
projectType,
|
|
203
|
-
dialect,
|
|
204
199
|
configs,
|
|
205
200
|
vcs,
|
|
206
201
|
configureLinting
|
|
@@ -212,7 +207,6 @@ async function scaffoldCodeStyle ({
|
|
|
212
207
|
scaffoldRemark({
|
|
213
208
|
projectRoot,
|
|
214
209
|
projectType,
|
|
215
|
-
dialect,
|
|
216
210
|
vcs,
|
|
217
211
|
config: configs.remark || '@form8ion/remark-lint-preset'
|
|
218
212
|
}),
|
|
@@ -678,14 +672,14 @@ function buildDialectChoices ({babelPreset, typescript}) {
|
|
|
678
672
|
];
|
|
679
673
|
}
|
|
680
674
|
|
|
681
|
-
function projectIsPackage(answers) {
|
|
682
|
-
return projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
683
|
-
}
|
|
684
|
-
|
|
685
675
|
function projectIsCLI(answers) {
|
|
686
676
|
return projectTypes.CLI === answers[questionNames$1.PROJECT_TYPE];
|
|
687
677
|
}
|
|
688
678
|
|
|
679
|
+
function projectIsPackage(answers) {
|
|
680
|
+
return projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
681
|
+
}
|
|
682
|
+
|
|
689
683
|
function projectIsApplication(answers) {
|
|
690
684
|
return projectTypes.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
|
|
691
685
|
}
|
|
@@ -777,6 +771,7 @@ async function prompt(
|
|
|
777
771
|
[questionNames$1.AUTHOR_EMAIL]: authorEmail,
|
|
778
772
|
[questionNames$1.AUTHOR_URL]: authorUrl,
|
|
779
773
|
[questionNames$1.CONFIGURE_LINTING]: configureLinting,
|
|
774
|
+
[questionNames$1.PROVIDE_EXAMPLE]: provideExample,
|
|
780
775
|
[questionNames$1.PACKAGE_MANAGER]: packageManager,
|
|
781
776
|
[questionNames$1.DIALECT]: dialect
|
|
782
777
|
} = await prompt$1([
|
|
@@ -834,6 +829,12 @@ async function prompt(
|
|
|
834
829
|
type: 'confirm',
|
|
835
830
|
when: lintingPromptShouldBePresented
|
|
836
831
|
},
|
|
832
|
+
{
|
|
833
|
+
name: questionNames$1.PROVIDE_EXAMPLE,
|
|
834
|
+
message: 'Should an example be provided in the README?',
|
|
835
|
+
type: 'confirm',
|
|
836
|
+
when: projectIsPackage
|
|
837
|
+
},
|
|
837
838
|
{
|
|
838
839
|
name: questionNames$1.HOST,
|
|
839
840
|
type: 'list',
|
|
@@ -852,6 +853,7 @@ async function prompt(
|
|
|
852
853
|
nodeVersionCategory,
|
|
853
854
|
author: {name: authorName, email: authorEmail, url: authorUrl},
|
|
854
855
|
configureLinting: false !== configureLinting,
|
|
856
|
+
provideExample,
|
|
855
857
|
packageManager,
|
|
856
858
|
dialect
|
|
857
859
|
};
|
|
@@ -982,7 +984,7 @@ function getInstallationCommand(packageManager) {
|
|
|
982
984
|
);
|
|
983
985
|
}
|
|
984
986
|
|
|
985
|
-
function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility}) {
|
|
987
|
+
function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility, provideExample}) {
|
|
986
988
|
return {
|
|
987
989
|
usage: `### Installation
|
|
988
990
|
${'Private' === visibility ? `
|
|
@@ -992,11 +994,14 @@ access to private packages under \`@${scope}\`
|
|
|
992
994
|
}
|
|
993
995
|
\`\`\`sh
|
|
994
996
|
$ ${getInstallationCommand(packageManager)} ${packageName}
|
|
995
|
-
|
|
997
|
+
\`\`\`${provideExample
|
|
998
|
+
? `
|
|
996
999
|
|
|
997
1000
|
### Example
|
|
998
1001
|
|
|
999
1002
|
run \`${buildDocumentationCommand(packageManager)}\` to inject the usage example`
|
|
1003
|
+
: ''
|
|
1004
|
+
}`
|
|
1000
1005
|
};
|
|
1001
1006
|
}
|
|
1002
1007
|
|
|
@@ -1046,10 +1051,12 @@ async function createExample(projectRoot, projectName) {
|
|
|
1046
1051
|
);
|
|
1047
1052
|
}
|
|
1048
1053
|
|
|
1049
|
-
async function buildDetailsForCommonJsProject({projectRoot, projectName}) {
|
|
1054
|
+
async function buildDetailsForCommonJsProject({projectRoot, projectName, provideExample}) {
|
|
1050
1055
|
await Promise.all([
|
|
1051
1056
|
touch(`${projectRoot}/index.js`),
|
|
1052
|
-
|
|
1057
|
+
provideExample
|
|
1058
|
+
? promises.writeFile(`${projectRoot}/example.js`, `const ${camelcase(projectName)} = require('.');\n`)
|
|
1059
|
+
: Promise.resolve()
|
|
1053
1060
|
]);
|
|
1054
1061
|
|
|
1055
1062
|
return {};
|
|
@@ -1062,16 +1069,17 @@ async function buildDetails ({
|
|
|
1062
1069
|
packageName,
|
|
1063
1070
|
packageBundlers,
|
|
1064
1071
|
dialect,
|
|
1072
|
+
provideExample,
|
|
1065
1073
|
decisions
|
|
1066
1074
|
}) {
|
|
1067
|
-
if (dialects$1.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName});
|
|
1075
|
+
if (dialects$1.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName, provideExample});
|
|
1068
1076
|
|
|
1069
1077
|
const chosenBundler = await chooseBundler({bundlers: packageBundlers, decisions});
|
|
1070
1078
|
|
|
1071
1079
|
const pathToCreatedSrcDirectory = await makeDir(`${projectRoot}/src`);
|
|
1072
1080
|
const [bundlerResults] = await Promise.all([
|
|
1073
1081
|
scaffoldChoice(packageBundlers, chosenBundler, {projectRoot, dialect, projectType: projectTypes.PACKAGE}),
|
|
1074
|
-
await createExample(projectRoot, projectName),
|
|
1082
|
+
provideExample ? await createExample(projectRoot, projectName) : Promise.resolve,
|
|
1075
1083
|
touch(`${pathToCreatedSrcDirectory}/index.js`)
|
|
1076
1084
|
]);
|
|
1077
1085
|
|
|
@@ -1083,7 +1091,8 @@ async function buildDetails ({
|
|
|
1083
1091
|
clean: `rimraf ./${defaultBuildDirectory$2}`,
|
|
1084
1092
|
prebuild: 'run-s clean',
|
|
1085
1093
|
build: 'npm-run-all --print-label --parallel build:*',
|
|
1086
|
-
prepack: 'run-s build'
|
|
1094
|
+
prepack: 'run-s build',
|
|
1095
|
+
...provideExample && {'pregenerate:md': 'run-s build'}
|
|
1087
1096
|
},
|
|
1088
1097
|
vcsIgnore: {directories: [`/${defaultBuildDirectory$2}/`]},
|
|
1089
1098
|
buildDirectory: defaultBuildDirectory$2,
|
|
@@ -1112,12 +1121,22 @@ async function scaffoldPackageType ({
|
|
|
1112
1121
|
packageBundlers,
|
|
1113
1122
|
decisions,
|
|
1114
1123
|
dialect,
|
|
1124
|
+
provideExample,
|
|
1115
1125
|
publishRegistry
|
|
1116
1126
|
}) {
|
|
1117
1127
|
info('Scaffolding Package Details');
|
|
1118
1128
|
|
|
1119
1129
|
const [detailsForBuild] = await Promise.all([
|
|
1120
|
-
buildDetails({
|
|
1130
|
+
buildDetails({
|
|
1131
|
+
projectRoot,
|
|
1132
|
+
projectName,
|
|
1133
|
+
packageBundlers,
|
|
1134
|
+
visibility,
|
|
1135
|
+
packageName,
|
|
1136
|
+
dialect,
|
|
1137
|
+
provideExample,
|
|
1138
|
+
decisions
|
|
1139
|
+
}),
|
|
1121
1140
|
mergeIntoExistingPackageJson({
|
|
1122
1141
|
projectRoot,
|
|
1123
1142
|
config: {
|
|
@@ -1156,7 +1175,7 @@ async function scaffoldPackageType ({
|
|
|
1156
1175
|
|
|
1157
1176
|
return deepmerge.all([
|
|
1158
1177
|
{
|
|
1159
|
-
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager}),
|
|
1178
|
+
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager, provideExample}),
|
|
1160
1179
|
nextSteps: [
|
|
1161
1180
|
{summary: 'Add the appropriate `save` flag to the installation instructions in the README'},
|
|
1162
1181
|
{summary: 'Publish pre-release versions to npm until package is stable enough to publish v1.0.0'}
|
|
@@ -1254,6 +1273,7 @@ async function scaffoldProjectType ({
|
|
|
1254
1273
|
vcs,
|
|
1255
1274
|
decisions,
|
|
1256
1275
|
dialect,
|
|
1276
|
+
provideExample,
|
|
1257
1277
|
publishRegistry
|
|
1258
1278
|
}) {
|
|
1259
1279
|
switch (projectType) {
|
|
@@ -1269,6 +1289,7 @@ async function scaffoldProjectType ({
|
|
|
1269
1289
|
vcs,
|
|
1270
1290
|
decisions,
|
|
1271
1291
|
dialect,
|
|
1292
|
+
provideExample,
|
|
1272
1293
|
publishRegistry
|
|
1273
1294
|
});
|
|
1274
1295
|
case projectTypes.APPLICATION:
|
|
@@ -1471,6 +1492,7 @@ async function scaffolder (options) {
|
|
|
1471
1492
|
nodeVersionCategory,
|
|
1472
1493
|
author,
|
|
1473
1494
|
configureLinting,
|
|
1495
|
+
provideExample,
|
|
1474
1496
|
packageManager,
|
|
1475
1497
|
dialect
|
|
1476
1498
|
} = await prompt(overrides, ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent);
|
|
@@ -1505,6 +1527,7 @@ async function scaffolder (options) {
|
|
|
1505
1527
|
vcs,
|
|
1506
1528
|
decisions,
|
|
1507
1529
|
dialect,
|
|
1530
|
+
provideExample,
|
|
1508
1531
|
publishRegistry: registries.publish
|
|
1509
1532
|
});
|
|
1510
1533
|
const verificationResults = await scaffoldVerification({
|
|
@@ -1529,7 +1552,7 @@ async function scaffolder (options) {
|
|
|
1529
1552
|
projectType,
|
|
1530
1553
|
testFilenamePattern: verificationResults.testFilenamePattern
|
|
1531
1554
|
}),
|
|
1532
|
-
scaffoldCodeStyle({projectRoot, projectType,
|
|
1555
|
+
scaffoldCodeStyle({projectRoot, projectType, configs, vcs, configureLinting})
|
|
1533
1556
|
]);
|
|
1534
1557
|
const projectTypePluginResults = await scaffoldProjectTypePlugin({
|
|
1535
1558
|
projectRoot,
|