@form8ion/javascript 13.0.0-alpha.1 → 13.0.0-alpha.3
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 +8 -4
- package/example.js +8 -4
- package/lib/index.js +15 -42
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +15 -42
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { questionNames as questionNames$2, questions } from '@travi/language-sca
|
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
3
|
import { fileTypes, fileExists, optionsSchemas, validateOptions, applyEnhancers, writeConfigFile } from '@form8ion/core';
|
|
4
4
|
import { scaffoldChoice, projectTypes as projectTypes$1, packageManagers as packageManagers$1, mergeIntoExistingPackageJson, dialects as dialects$1, writePackageJson, DEV_DEPENDENCY_TYPE, PROD_DEPENDENCY_TYPE } from '@form8ion/javascript-core';
|
|
5
|
-
import joi from 'joi';
|
|
6
5
|
import { prompt as prompt$1, Separator } from '@form8ion/overridable-prompts';
|
|
6
|
+
import joi from 'joi';
|
|
7
7
|
import { scaffold, lift as lift$3 } from '@form8ion/codecov';
|
|
8
8
|
import { write as write$2 } from '@form8ion/config-file';
|
|
9
9
|
import { info, warn, error } from '@travi/cli-messages';
|
|
@@ -127,8 +127,6 @@ var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
|
127
127
|
test: tester$4
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
const unitTestFrameworksSchema = joi.object().required().pattern(/^/, optionsSchemas.form8ionPlugin);
|
|
131
|
-
|
|
132
130
|
async function chooseFramework ({frameworks, decisions}) {
|
|
133
131
|
if (!Object.keys(frameworks).length) return 'Other';
|
|
134
132
|
|
|
@@ -142,8 +140,10 @@ async function chooseFramework ({frameworks, decisions}) {
|
|
|
142
140
|
return answers[questionNames$1.UNIT_TEST_FRAMEWORK];
|
|
143
141
|
}
|
|
144
142
|
|
|
143
|
+
const pluginsSchema = joi.object().pattern(/^/, optionsSchemas.form8ionPlugin).default({});
|
|
144
|
+
|
|
145
145
|
async function scaffoldUnitTesting ({projectRoot, frameworks, decisions, visibility, vcs, pathWithinParent, dialect}) {
|
|
146
|
-
const validatedFrameworks = validateOptions(
|
|
146
|
+
const validatedFrameworks = validateOptions(pluginsSchema, frameworks);
|
|
147
147
|
const [framework, coverage] = await Promise.all([
|
|
148
148
|
chooseFramework({frameworks: validatedFrameworks, decisions})
|
|
149
149
|
.then(chosenFramework => scaffoldChoice(validatedFrameworks, chosenFramework, {projectRoot, dialect})),
|
|
@@ -1162,16 +1162,6 @@ async function lift ({projectRoot, vcs, results, pathWithinParent, enhancers = {
|
|
|
1162
1162
|
return enhancerResults;
|
|
1163
1163
|
}
|
|
1164
1164
|
|
|
1165
|
-
const pluginMapSchema = joi.object().pattern(joi.string(), optionsSchemas.form8ionPlugin);
|
|
1166
|
-
|
|
1167
|
-
const packageBundlersSchema = pluginMapSchema.default({});
|
|
1168
|
-
|
|
1169
|
-
const applicationTypesSchema = pluginMapSchema.default({});
|
|
1170
|
-
|
|
1171
|
-
const packageTypesSchema = pluginMapSchema.default({});
|
|
1172
|
-
|
|
1173
|
-
const monorepoTypesSchema = pluginMapSchema.default({});
|
|
1174
|
-
|
|
1175
1165
|
function validate(options) {
|
|
1176
1166
|
const schema = joi.object().required()
|
|
1177
1167
|
.keys({
|
|
@@ -1205,16 +1195,6 @@ function validate(options) {
|
|
|
1205
1195
|
remark: joi.string()
|
|
1206
1196
|
}).default({})
|
|
1207
1197
|
})
|
|
1208
|
-
.keys({
|
|
1209
|
-
overrides: joi.object({
|
|
1210
|
-
npmAccount: joi.string(),
|
|
1211
|
-
author: joi.object({
|
|
1212
|
-
name: joi.string().required(),
|
|
1213
|
-
email: joi.string().email(),
|
|
1214
|
-
url: joi.string().uri()
|
|
1215
|
-
})
|
|
1216
|
-
}).default({})
|
|
1217
|
-
})
|
|
1218
1198
|
.keys({
|
|
1219
1199
|
ciServices: joi.object().pattern(/^/, joi.object({
|
|
1220
1200
|
scaffolder: joi.func().arity(1).required(),
|
|
@@ -1222,19 +1202,14 @@ function validate(options) {
|
|
|
1222
1202
|
private: joi.boolean()
|
|
1223
1203
|
})).default({})
|
|
1224
1204
|
})
|
|
1225
|
-
.keys({
|
|
1226
|
-
hosts: joi.object().pattern(/^/, joi.object({
|
|
1227
|
-
scaffolder: joi.func().arity(1).required(),
|
|
1228
|
-
projectTypes: joi.array().items(joi.string().valid('static', 'node')).default([])
|
|
1229
|
-
})).default({})
|
|
1230
|
-
})
|
|
1231
1205
|
.keys({
|
|
1232
1206
|
plugins: {
|
|
1233
|
-
unitTestFrameworks:
|
|
1234
|
-
packageBundlers:
|
|
1235
|
-
applicationTypes:
|
|
1236
|
-
packageTypes:
|
|
1237
|
-
monorepoTypes:
|
|
1207
|
+
unitTestFrameworks: pluginsSchema,
|
|
1208
|
+
packageBundlers: pluginsSchema,
|
|
1209
|
+
applicationTypes: pluginsSchema,
|
|
1210
|
+
packageTypes: pluginsSchema,
|
|
1211
|
+
monorepoTypes: pluginsSchema,
|
|
1212
|
+
hosts: pluginsSchema
|
|
1238
1213
|
}
|
|
1239
1214
|
})
|
|
1240
1215
|
.keys({
|
|
@@ -1320,7 +1295,6 @@ function authorQuestions({name, email, url}) {
|
|
|
1320
1295
|
}
|
|
1321
1296
|
|
|
1322
1297
|
async function prompt(
|
|
1323
|
-
{npmAccount, author},
|
|
1324
1298
|
ciServices,
|
|
1325
1299
|
hosts,
|
|
1326
1300
|
visibility,
|
|
@@ -1397,9 +1371,9 @@ async function prompt(
|
|
|
1397
1371
|
message: 'What is the scope?',
|
|
1398
1372
|
when: scopePromptShouldBePresentedFactory(visibility),
|
|
1399
1373
|
validate: scope(visibility),
|
|
1400
|
-
default:
|
|
1374
|
+
default: maybeLoggedInNpmUsername
|
|
1401
1375
|
},
|
|
1402
|
-
...authorQuestions(
|
|
1376
|
+
...authorQuestions({
|
|
1403
1377
|
name: npmConf$1.get('init.author.name'),
|
|
1404
1378
|
email: npmConf$1.get('init.author.email'),
|
|
1405
1379
|
url: npmConf$1.get('init.author.url')
|
|
@@ -1670,9 +1644,7 @@ async function scaffolder (options) {
|
|
|
1670
1644
|
vcs,
|
|
1671
1645
|
description,
|
|
1672
1646
|
configs,
|
|
1673
|
-
overrides,
|
|
1674
1647
|
ciServices,
|
|
1675
|
-
hosts,
|
|
1676
1648
|
decisions,
|
|
1677
1649
|
pathWithinParent,
|
|
1678
1650
|
registries,
|
|
@@ -1681,7 +1653,8 @@ async function scaffolder (options) {
|
|
|
1681
1653
|
packageTypes,
|
|
1682
1654
|
monorepoTypes,
|
|
1683
1655
|
packageBundlers,
|
|
1684
|
-
unitTestFrameworks
|
|
1656
|
+
unitTestFrameworks,
|
|
1657
|
+
hosts
|
|
1685
1658
|
}
|
|
1686
1659
|
} = validate(options);
|
|
1687
1660
|
|
|
@@ -1697,7 +1670,7 @@ async function scaffolder (options) {
|
|
|
1697
1670
|
provideExample,
|
|
1698
1671
|
packageManager,
|
|
1699
1672
|
dialect
|
|
1700
|
-
} = await prompt(
|
|
1673
|
+
} = await prompt(ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent);
|
|
1701
1674
|
|
|
1702
1675
|
info('Writing project files', {level: 'secondary'});
|
|
1703
1676
|
|