@form8ion/javascript 3.0.1 → 3.1.0-alpha.4
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 +73 -30
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +72 -29
- package/lib/index.es.js.map +1 -1
- package/package.json +2 -2
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,62 @@ 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 deepmerge.all([c8Results, {
|
|
160
|
+
scripts: {
|
|
161
|
+
'test:unit': 'cross-env NODE_ENV=test c8 run-s test:unit:base'
|
|
162
|
+
}
|
|
163
|
+
}]);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return {};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var coveragePlugin = /*#__PURE__*/Object.freeze({
|
|
170
|
+
__proto__: null,
|
|
171
|
+
scaffold: scaffoldCoverage,
|
|
172
|
+
lift: lift$2,
|
|
173
|
+
test: nycIsConfigured
|
|
174
|
+
});
|
|
175
|
+
|
|
119
176
|
const unitTestFrameworksSchema = joi.object().required().pattern(/^/, joi.object({
|
|
120
177
|
scaffolder: joi.func().arity(1).required()
|
|
121
178
|
}));
|
|
@@ -164,18 +221,15 @@ async function scaffoldUnitTesting ({
|
|
|
164
221
|
async function applyEnhancers ({
|
|
165
222
|
results,
|
|
166
223
|
enhancers = {},
|
|
167
|
-
|
|
224
|
+
options
|
|
168
225
|
}) {
|
|
169
226
|
info('Applying Enhancers');
|
|
170
227
|
return Object.values(enhancers).reduce(async (acc, enhancer) => {
|
|
171
|
-
if (await enhancer.test({
|
|
172
|
-
projectRoot
|
|
173
|
-
})) {
|
|
228
|
+
if (await enhancer.test(options)) {
|
|
174
229
|
const previousResults = await acc;
|
|
175
|
-
return deepmerge(previousResults, await enhancer.lift({
|
|
176
|
-
results: previousResults
|
|
177
|
-
|
|
178
|
-
}));
|
|
230
|
+
return deepmerge(previousResults, await enhancer.lift(_objectSpread2({
|
|
231
|
+
results: previousResults
|
|
232
|
+
}, options)));
|
|
179
233
|
}
|
|
180
234
|
|
|
181
235
|
return acc;
|
|
@@ -261,20 +315,6 @@ async function resolvePackageManager ({
|
|
|
261
315
|
throw new Error('Package-manager could not be determined');
|
|
262
316
|
}
|
|
263
317
|
|
|
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
318
|
async function lift ({
|
|
279
319
|
projectRoot,
|
|
280
320
|
results
|
|
@@ -298,8 +338,11 @@ async function lift ({
|
|
|
298
338
|
});
|
|
299
339
|
const enhancerResults = await applyEnhancers({
|
|
300
340
|
results,
|
|
301
|
-
enhancers: [
|
|
302
|
-
|
|
341
|
+
enhancers: [huskyPlugin, enginesEnhancer, coveragePlugin],
|
|
342
|
+
options: {
|
|
343
|
+
packageManager,
|
|
344
|
+
projectRoot
|
|
345
|
+
}
|
|
303
346
|
});
|
|
304
347
|
await liftPackage(deepmerge.all([{
|
|
305
348
|
projectRoot,
|