@form8ion/javascript 3.1.0-alpha.1 → 3.1.0-alpha.5

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 CHANGED
@@ -24,7 +24,7 @@ var camelcase = require('camelcase');
24
24
  var makeDir = require('make-dir');
25
25
  var touch = require('touch');
26
26
  var path = require('path');
27
- var husky = require('@form8ion/husky');
27
+ var huskyPlugin = require('@form8ion/husky');
28
28
  var eslint = require('@form8ion/eslint');
29
29
 
30
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -56,6 +56,7 @@ var mustache__default = /*#__PURE__*/_interopDefaultLegacy(mustache);
56
56
  var camelcase__default = /*#__PURE__*/_interopDefaultLegacy(camelcase);
57
57
  var makeDir__default = /*#__PURE__*/_interopDefaultLegacy(makeDir);
58
58
  var touch__default = /*#__PURE__*/_interopDefaultLegacy(touch);
59
+ var huskyPlugin__namespace = /*#__PURE__*/_interopNamespace(huskyPlugin);
59
60
 
60
61
  function ownKeys(object, enumerableOnly) {
61
62
  var keys = Object.keys(object);
@@ -156,14 +157,29 @@ function nycIsConfigured ({
156
157
  return core.fileExists(`${projectRoot}/.nycrc`);
157
158
  }
158
159
 
160
+ async function removeDependencies ({
161
+ packageManager,
162
+ dependencies
163
+ }) {
164
+ await execa__default["default"](packageManager, ['remove', ...dependencies]);
165
+ }
166
+
159
167
  async function removeNyc ({
160
- projectRoot
168
+ projectRoot,
169
+ packageManager
161
170
  }) {
162
- await fs.promises.unlink(`${projectRoot}/.nycrc`);
171
+ await Promise.all([fs.promises.unlink(`${projectRoot}/.nycrc`), fs.promises.rmdir(`${projectRoot}/.nyc_output`, {
172
+ recursive: true,
173
+ force: true
174
+ }), removeDependencies({
175
+ packageManager,
176
+ dependencies: ['nyc', '@istanbuljs/nyc-config-babel']
177
+ })]);
163
178
  }
164
179
 
165
180
  async function lift$2({
166
- projectRoot
181
+ projectRoot,
182
+ packageManager
167
183
  }) {
168
184
  if (await nycIsConfigured({
169
185
  projectRoot
@@ -171,9 +187,17 @@ async function lift$2({
171
187
  const [c8Results] = await Promise.all([scaffoldC8({
172
188
  projectRoot
173
189
  }), removeNyc({
174
- projectRoot
190
+ projectRoot,
191
+ packageManager
175
192
  })]);
176
- return c8Results;
193
+ return deepmerge__default["default"].all([c8Results, {
194
+ scripts: {
195
+ 'test:unit': 'cross-env NODE_ENV=test c8 run-s test:unit:base'
196
+ },
197
+ nextSteps: [{
198
+ summary: 'Remove use of `@istanbuljs/nyc-config-babel` from your babel config, if present,' + ' after the migration away from `nyc`'
199
+ }]
200
+ }]);
177
201
  }
178
202
 
179
203
  return {};
@@ -234,18 +258,15 @@ async function scaffoldUnitTesting ({
234
258
  async function applyEnhancers ({
235
259
  results,
236
260
  enhancers = {},
237
- projectRoot
261
+ options
238
262
  }) {
239
263
  cliMessages.info('Applying Enhancers');
240
264
  return Object.values(enhancers).reduce(async (acc, enhancer) => {
241
- if (await enhancer.test({
242
- projectRoot
243
- })) {
265
+ if (await enhancer.test(options)) {
244
266
  const previousResults = await acc;
245
- return deepmerge__default["default"](previousResults, await enhancer.lift({
246
- results: previousResults,
247
- projectRoot
248
- }));
267
+ return deepmerge__default["default"](previousResults, await enhancer.lift(_objectSpread2({
268
+ results: previousResults
269
+ }, options)));
249
270
  }
250
271
 
251
272
  return acc;
@@ -288,20 +309,6 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
288
309
  lift: lift$1
289
310
  });
290
311
 
291
- function enhanceHuskyEnhancer(packageManager) {
292
- return {
293
- test: husky.test,
294
- lift: ({
295
- projectRoot,
296
- results
297
- }) => husky.lift({
298
- projectRoot,
299
- results,
300
- packageManager
301
- })
302
- };
303
- }
304
-
305
312
  async function liftPackage ({
306
313
  projectRoot,
307
314
  scripts,
@@ -368,8 +375,11 @@ async function lift ({
368
375
  });
369
376
  const enhancerResults = await applyEnhancers({
370
377
  results,
371
- enhancers: [enhanceHuskyEnhancer(packageManager), enginesEnhancer, coveragePlugin],
372
- projectRoot
378
+ enhancers: [huskyPlugin__namespace, enginesEnhancer, coveragePlugin],
379
+ options: {
380
+ packageManager,
381
+ projectRoot
382
+ }
373
383
  });
374
384
  await liftPackage(deepmerge__default["default"].all([{
375
385
  projectRoot,
@@ -1521,7 +1531,7 @@ async function scaffoldVerification({
1521
1531
  decisions,
1522
1532
  dialect,
1523
1533
  pathWithinParent
1524
- }), husky.scaffold({
1534
+ }), huskyPlugin.scaffold({
1525
1535
  projectRoot,
1526
1536
  packageManager
1527
1537
  })]);