@form8ion/javascript 3.0.0 → 3.1.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/lib/index.cjs.js +69 -30
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +68 -29
- package/lib/index.es.js.map +1 -1
- package/package.json +4 -4
package/lib/index.es.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { questionNames as questionNames$2, questions } from '@travi/language-scaffolder-prompts';
|
|
2
2
|
import deepmerge from 'deepmerge';
|
|
3
3
|
import { validateOptions, scaffoldChoice, installDependencies, PROD_DEPENDENCY_TYPE, DEV_DEPENDENCY_TYPE, packageManagers, dialects, projectTypes } from '@form8ion/javascript-core';
|
|
4
|
-
import { scaffold } from '@form8ion/codecov';
|
|
5
|
-
import { promises } from 'fs';
|
|
6
4
|
import * as joi from 'joi';
|
|
7
5
|
import { Separator } from 'inquirer';
|
|
8
6
|
import { prompt as prompt$1 } from '@form8ion/overridable-prompts';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { scaffold } from '@form8ion/codecov';
|
|
8
|
+
import { promises } from 'fs';
|
|
11
9
|
import { fileExists } from '@form8ion/core';
|
|
12
|
-
import {
|
|
10
|
+
import { info, warn } from '@travi/cli-messages';
|
|
13
11
|
import { scaffold as scaffold$4 } from '@form8ion/commit-convention';
|
|
14
12
|
import hoek from '@hapi/hoek';
|
|
15
13
|
import execa from 'execa';
|
|
@@ -22,6 +20,9 @@ import camelcase from 'camelcase';
|
|
|
22
20
|
import makeDir from 'make-dir';
|
|
23
21
|
import touch from 'touch';
|
|
24
22
|
import { resolve } from 'path';
|
|
23
|
+
import * as huskyPlugin from '@form8ion/husky';
|
|
24
|
+
import { scaffold as scaffold$3 } from '@form8ion/husky';
|
|
25
|
+
import { lift as lift$3, scaffold as scaffold$2 } from '@form8ion/eslint';
|
|
25
26
|
|
|
26
27
|
function ownKeys(object, enumerableOnly) {
|
|
27
28
|
var keys = Object.keys(object);
|
|
@@ -116,6 +117,58 @@ async function scaffoldCoverage ({
|
|
|
116
117
|
}));
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
function nycIsConfigured ({
|
|
121
|
+
projectRoot
|
|
122
|
+
}) {
|
|
123
|
+
return fileExists(`${projectRoot}/.nycrc`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async function removeDependencies ({
|
|
127
|
+
packageManager,
|
|
128
|
+
dependencies
|
|
129
|
+
}) {
|
|
130
|
+
await execa(packageManager, ['remove', ...dependencies]);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function removeNyc ({
|
|
134
|
+
projectRoot,
|
|
135
|
+
packageManager
|
|
136
|
+
}) {
|
|
137
|
+
await Promise.all([promises.unlink(`${projectRoot}/.nycrc`), promises.rmdir(`${projectRoot}/.nyc_output`, {
|
|
138
|
+
recursive: true,
|
|
139
|
+
force: true
|
|
140
|
+
}), removeDependencies({
|
|
141
|
+
packageManager,
|
|
142
|
+
dependencies: ['nyc', '@istanbuljs/nyc-config-babel']
|
|
143
|
+
})]);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function lift$2({
|
|
147
|
+
projectRoot,
|
|
148
|
+
packageManager
|
|
149
|
+
}) {
|
|
150
|
+
if (await nycIsConfigured({
|
|
151
|
+
projectRoot
|
|
152
|
+
})) {
|
|
153
|
+
const [c8Results] = await Promise.all([scaffoldC8({
|
|
154
|
+
projectRoot
|
|
155
|
+
}), removeNyc({
|
|
156
|
+
projectRoot,
|
|
157
|
+
packageManager
|
|
158
|
+
})]);
|
|
159
|
+
return c8Results;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
166
|
+
__proto__: null,
|
|
167
|
+
scaffold: scaffoldCoverage,
|
|
168
|
+
lift: lift$2,
|
|
169
|
+
test: nycIsConfigured
|
|
170
|
+
});
|
|
171
|
+
|
|
119
172
|
const unitTestFrameworksSchema = joi.object().required().pattern(/^/, joi.object({
|
|
120
173
|
scaffolder: joi.func().arity(1).required()
|
|
121
174
|
}));
|
|
@@ -164,18 +217,15 @@ async function scaffoldUnitTesting ({
|
|
|
164
217
|
async function applyEnhancers ({
|
|
165
218
|
results,
|
|
166
219
|
enhancers = {},
|
|
167
|
-
|
|
220
|
+
options
|
|
168
221
|
}) {
|
|
169
222
|
info('Applying Enhancers');
|
|
170
223
|
return Object.values(enhancers).reduce(async (acc, enhancer) => {
|
|
171
|
-
if (await enhancer.test({
|
|
172
|
-
projectRoot
|
|
173
|
-
})) {
|
|
224
|
+
if (await enhancer.test(options)) {
|
|
174
225
|
const previousResults = await acc;
|
|
175
|
-
return deepmerge(previousResults, await enhancer.lift({
|
|
176
|
-
results: previousResults
|
|
177
|
-
|
|
178
|
-
}));
|
|
226
|
+
return deepmerge(previousResults, await enhancer.lift(_objectSpread2({
|
|
227
|
+
results: previousResults
|
|
228
|
+
}, options)));
|
|
179
229
|
}
|
|
180
230
|
|
|
181
231
|
return acc;
|
|
@@ -261,20 +311,6 @@ async function resolvePackageManager ({
|
|
|
261
311
|
throw new Error('Package-manager could not be determined');
|
|
262
312
|
}
|
|
263
313
|
|
|
264
|
-
function enhanceHuskyEnhancer(packageManager) {
|
|
265
|
-
return {
|
|
266
|
-
test: test$2,
|
|
267
|
-
lift: ({
|
|
268
|
-
projectRoot,
|
|
269
|
-
results
|
|
270
|
-
}) => lift$2({
|
|
271
|
-
projectRoot,
|
|
272
|
-
results,
|
|
273
|
-
packageManager
|
|
274
|
-
})
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
314
|
async function lift ({
|
|
279
315
|
projectRoot,
|
|
280
316
|
results
|
|
@@ -298,8 +334,11 @@ async function lift ({
|
|
|
298
334
|
});
|
|
299
335
|
const enhancerResults = await applyEnhancers({
|
|
300
336
|
results,
|
|
301
|
-
enhancers: [
|
|
302
|
-
|
|
337
|
+
enhancers: [huskyPlugin, enginesEnhancer, coveragePlugin],
|
|
338
|
+
options: {
|
|
339
|
+
packageManager,
|
|
340
|
+
projectRoot
|
|
341
|
+
}
|
|
303
342
|
});
|
|
304
343
|
await liftPackage(deepmerge.all([{
|
|
305
344
|
projectRoot,
|