@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/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
|
}),
|
|
@@ -432,6 +426,7 @@ function sortPackageProperties (packageContents) {
|
|
|
432
426
|
'description',
|
|
433
427
|
'license',
|
|
434
428
|
'version',
|
|
429
|
+
'type',
|
|
435
430
|
'engines',
|
|
436
431
|
'author',
|
|
437
432
|
'repository',
|
|
@@ -440,12 +435,15 @@ function sortPackageProperties (packageContents) {
|
|
|
440
435
|
'keywords',
|
|
441
436
|
'runkitExampleFilename',
|
|
442
437
|
'exports',
|
|
438
|
+
'bin',
|
|
443
439
|
'main',
|
|
444
440
|
'module',
|
|
445
|
-
'
|
|
446
|
-
'publishConfig',
|
|
441
|
+
'types',
|
|
447
442
|
'sideEffects',
|
|
448
443
|
'scripts',
|
|
444
|
+
'files',
|
|
445
|
+
'publishConfig',
|
|
446
|
+
'config',
|
|
449
447
|
'dependencies',
|
|
450
448
|
'devDependencies',
|
|
451
449
|
'peerDependencies'
|
|
@@ -674,14 +672,14 @@ function buildDialectChoices ({babelPreset, typescript}) {
|
|
|
674
672
|
];
|
|
675
673
|
}
|
|
676
674
|
|
|
677
|
-
function projectIsPackage(answers) {
|
|
678
|
-
return projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
679
|
-
}
|
|
680
|
-
|
|
681
675
|
function projectIsCLI(answers) {
|
|
682
676
|
return projectTypes.CLI === answers[questionNames$1.PROJECT_TYPE];
|
|
683
677
|
}
|
|
684
678
|
|
|
679
|
+
function projectIsPackage(answers) {
|
|
680
|
+
return projectTypes.PACKAGE === answers[questionNames$1.PROJECT_TYPE];
|
|
681
|
+
}
|
|
682
|
+
|
|
685
683
|
function projectIsApplication(answers) {
|
|
686
684
|
return projectTypes.APPLICATION === answers[questionNames$1.PROJECT_TYPE];
|
|
687
685
|
}
|
|
@@ -773,6 +771,7 @@ async function prompt(
|
|
|
773
771
|
[questionNames$1.AUTHOR_EMAIL]: authorEmail,
|
|
774
772
|
[questionNames$1.AUTHOR_URL]: authorUrl,
|
|
775
773
|
[questionNames$1.CONFIGURE_LINTING]: configureLinting,
|
|
774
|
+
[questionNames$1.PROVIDE_EXAMPLE]: provideExample,
|
|
776
775
|
[questionNames$1.PACKAGE_MANAGER]: packageManager,
|
|
777
776
|
[questionNames$1.DIALECT]: dialect
|
|
778
777
|
} = await prompt$1([
|
|
@@ -830,6 +829,12 @@ async function prompt(
|
|
|
830
829
|
type: 'confirm',
|
|
831
830
|
when: lintingPromptShouldBePresented
|
|
832
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
|
+
},
|
|
833
838
|
{
|
|
834
839
|
name: questionNames$1.HOST,
|
|
835
840
|
type: 'list',
|
|
@@ -848,6 +853,7 @@ async function prompt(
|
|
|
848
853
|
nodeVersionCategory,
|
|
849
854
|
author: {name: authorName, email: authorEmail, url: authorUrl},
|
|
850
855
|
configureLinting: false !== configureLinting,
|
|
856
|
+
provideExample,
|
|
851
857
|
packageManager,
|
|
852
858
|
dialect
|
|
853
859
|
};
|
|
@@ -978,7 +984,7 @@ function getInstallationCommand(packageManager) {
|
|
|
978
984
|
);
|
|
979
985
|
}
|
|
980
986
|
|
|
981
|
-
function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility}) {
|
|
987
|
+
function scaffoldPackageDocumentation ({scope, packageName, packageManager, visibility, provideExample}) {
|
|
982
988
|
return {
|
|
983
989
|
usage: `### Installation
|
|
984
990
|
${'Private' === visibility ? `
|
|
@@ -988,11 +994,14 @@ access to private packages under \`@${scope}\`
|
|
|
988
994
|
}
|
|
989
995
|
\`\`\`sh
|
|
990
996
|
$ ${getInstallationCommand(packageManager)} ${packageName}
|
|
991
|
-
|
|
997
|
+
\`\`\`${provideExample
|
|
998
|
+
? `
|
|
992
999
|
|
|
993
1000
|
### Example
|
|
994
1001
|
|
|
995
1002
|
run \`${buildDocumentationCommand(packageManager)}\` to inject the usage example`
|
|
1003
|
+
: ''
|
|
1004
|
+
}`
|
|
996
1005
|
};
|
|
997
1006
|
}
|
|
998
1007
|
|
|
@@ -1042,10 +1051,12 @@ async function createExample(projectRoot, projectName) {
|
|
|
1042
1051
|
);
|
|
1043
1052
|
}
|
|
1044
1053
|
|
|
1045
|
-
async function buildDetailsForCommonJsProject({projectRoot, projectName}) {
|
|
1054
|
+
async function buildDetailsForCommonJsProject({projectRoot, projectName, provideExample}) {
|
|
1046
1055
|
await Promise.all([
|
|
1047
1056
|
touch(`${projectRoot}/index.js`),
|
|
1048
|
-
|
|
1057
|
+
provideExample
|
|
1058
|
+
? promises.writeFile(`${projectRoot}/example.js`, `const ${camelcase(projectName)} = require('.');\n`)
|
|
1059
|
+
: Promise.resolve()
|
|
1049
1060
|
]);
|
|
1050
1061
|
|
|
1051
1062
|
return {};
|
|
@@ -1058,16 +1069,17 @@ async function buildDetails ({
|
|
|
1058
1069
|
packageName,
|
|
1059
1070
|
packageBundlers,
|
|
1060
1071
|
dialect,
|
|
1072
|
+
provideExample,
|
|
1061
1073
|
decisions
|
|
1062
1074
|
}) {
|
|
1063
|
-
if (dialects$1.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName});
|
|
1075
|
+
if (dialects$1.COMMON_JS === dialect) return buildDetailsForCommonJsProject({projectRoot, projectName, provideExample});
|
|
1064
1076
|
|
|
1065
1077
|
const chosenBundler = await chooseBundler({bundlers: packageBundlers, decisions});
|
|
1066
1078
|
|
|
1067
1079
|
const pathToCreatedSrcDirectory = await makeDir(`${projectRoot}/src`);
|
|
1068
1080
|
const [bundlerResults] = await Promise.all([
|
|
1069
1081
|
scaffoldChoice(packageBundlers, chosenBundler, {projectRoot, dialect, projectType: projectTypes.PACKAGE}),
|
|
1070
|
-
await createExample(projectRoot, projectName),
|
|
1082
|
+
provideExample ? await createExample(projectRoot, projectName) : Promise.resolve,
|
|
1071
1083
|
touch(`${pathToCreatedSrcDirectory}/index.js`)
|
|
1072
1084
|
]);
|
|
1073
1085
|
|
|
@@ -1079,7 +1091,8 @@ async function buildDetails ({
|
|
|
1079
1091
|
clean: `rimraf ./${defaultBuildDirectory$2}`,
|
|
1080
1092
|
prebuild: 'run-s clean',
|
|
1081
1093
|
build: 'npm-run-all --print-label --parallel build:*',
|
|
1082
|
-
prepack: 'run-s build'
|
|
1094
|
+
prepack: 'run-s build',
|
|
1095
|
+
...provideExample && {'pregenerate:md': 'run-s build'}
|
|
1083
1096
|
},
|
|
1084
1097
|
vcsIgnore: {directories: [`/${defaultBuildDirectory$2}/`]},
|
|
1085
1098
|
buildDirectory: defaultBuildDirectory$2,
|
|
@@ -1108,12 +1121,22 @@ async function scaffoldPackageType ({
|
|
|
1108
1121
|
packageBundlers,
|
|
1109
1122
|
decisions,
|
|
1110
1123
|
dialect,
|
|
1124
|
+
provideExample,
|
|
1111
1125
|
publishRegistry
|
|
1112
1126
|
}) {
|
|
1113
1127
|
info('Scaffolding Package Details');
|
|
1114
1128
|
|
|
1115
1129
|
const [detailsForBuild] = await Promise.all([
|
|
1116
|
-
buildDetails({
|
|
1130
|
+
buildDetails({
|
|
1131
|
+
projectRoot,
|
|
1132
|
+
projectName,
|
|
1133
|
+
packageBundlers,
|
|
1134
|
+
visibility,
|
|
1135
|
+
packageName,
|
|
1136
|
+
dialect,
|
|
1137
|
+
provideExample,
|
|
1138
|
+
decisions
|
|
1139
|
+
}),
|
|
1117
1140
|
mergeIntoExistingPackageJson({
|
|
1118
1141
|
projectRoot,
|
|
1119
1142
|
config: {
|
|
@@ -1152,7 +1175,7 @@ async function scaffoldPackageType ({
|
|
|
1152
1175
|
|
|
1153
1176
|
return deepmerge.all([
|
|
1154
1177
|
{
|
|
1155
|
-
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager}),
|
|
1178
|
+
documentation: scaffoldPackageDocumentation({packageName, visibility, scope, packageManager, provideExample}),
|
|
1156
1179
|
nextSteps: [
|
|
1157
1180
|
{summary: 'Add the appropriate `save` flag to the installation instructions in the README'},
|
|
1158
1181
|
{summary: 'Publish pre-release versions to npm until package is stable enough to publish v1.0.0'}
|
|
@@ -1250,6 +1273,7 @@ async function scaffoldProjectType ({
|
|
|
1250
1273
|
vcs,
|
|
1251
1274
|
decisions,
|
|
1252
1275
|
dialect,
|
|
1276
|
+
provideExample,
|
|
1253
1277
|
publishRegistry
|
|
1254
1278
|
}) {
|
|
1255
1279
|
switch (projectType) {
|
|
@@ -1265,6 +1289,7 @@ async function scaffoldProjectType ({
|
|
|
1265
1289
|
vcs,
|
|
1266
1290
|
decisions,
|
|
1267
1291
|
dialect,
|
|
1292
|
+
provideExample,
|
|
1268
1293
|
publishRegistry
|
|
1269
1294
|
});
|
|
1270
1295
|
case projectTypes.APPLICATION:
|
|
@@ -1467,6 +1492,7 @@ async function scaffolder (options) {
|
|
|
1467
1492
|
nodeVersionCategory,
|
|
1468
1493
|
author,
|
|
1469
1494
|
configureLinting,
|
|
1495
|
+
provideExample,
|
|
1470
1496
|
packageManager,
|
|
1471
1497
|
dialect
|
|
1472
1498
|
} = await prompt(overrides, ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent);
|
|
@@ -1501,6 +1527,7 @@ async function scaffolder (options) {
|
|
|
1501
1527
|
vcs,
|
|
1502
1528
|
decisions,
|
|
1503
1529
|
dialect,
|
|
1530
|
+
provideExample,
|
|
1504
1531
|
publishRegistry: registries.publish
|
|
1505
1532
|
});
|
|
1506
1533
|
const verificationResults = await scaffoldVerification({
|
|
@@ -1525,7 +1552,7 @@ async function scaffolder (options) {
|
|
|
1525
1552
|
projectType,
|
|
1526
1553
|
testFilenamePattern: verificationResults.testFilenamePattern
|
|
1527
1554
|
}),
|
|
1528
|
-
scaffoldCodeStyle({projectRoot, projectType,
|
|
1555
|
+
scaffoldCodeStyle({projectRoot, projectType, configs, vcs, configureLinting})
|
|
1529
1556
|
]);
|
|
1530
1557
|
const projectTypePluginResults = await scaffoldProjectTypePlugin({
|
|
1531
1558
|
projectRoot,
|