@form8ion/javascript 3.1.0-alpha.2 → 3.1.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/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,17 +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
171
  await Promise.all([fs.promises.unlink(`${projectRoot}/.nycrc`), fs.promises.rmdir(`${projectRoot}/.nyc_output`, {
163
172
  recursive: true,
164
173
  force: true
174
+ }), removeDependencies({
175
+ packageManager,
176
+ dependencies: ['nyc', '@istanbuljs/nyc-config-babel']
165
177
  })]);
166
178
  }
167
179
 
168
180
  async function lift$2({
169
- projectRoot
181
+ projectRoot,
182
+ packageManager
170
183
  }) {
171
184
  if (await nycIsConfigured({
172
185
  projectRoot
@@ -174,9 +187,17 @@ async function lift$2({
174
187
  const [c8Results] = await Promise.all([scaffoldC8({
175
188
  projectRoot
176
189
  }), removeNyc({
177
- projectRoot
190
+ projectRoot,
191
+ packageManager
178
192
  })]);
179
- 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
+ }]);
180
201
  }
181
202
 
182
203
  return {};
@@ -237,18 +258,15 @@ async function scaffoldUnitTesting ({
237
258
  async function applyEnhancers ({
238
259
  results,
239
260
  enhancers = {},
240
- projectRoot
261
+ options
241
262
  }) {
242
263
  cliMessages.info('Applying Enhancers');
243
264
  return Object.values(enhancers).reduce(async (acc, enhancer) => {
244
- if (await enhancer.test({
245
- projectRoot
246
- })) {
265
+ if (await enhancer.test(options)) {
247
266
  const previousResults = await acc;
248
- return deepmerge__default["default"](previousResults, await enhancer.lift({
249
- results: previousResults,
250
- projectRoot
251
- }));
267
+ return deepmerge__default["default"](previousResults, await enhancer.lift(_objectSpread2({
268
+ results: previousResults
269
+ }, options)));
252
270
  }
253
271
 
254
272
  return acc;
@@ -291,20 +309,6 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
291
309
  lift: lift$1
292
310
  });
293
311
 
294
- function enhanceHuskyEnhancer(packageManager) {
295
- return {
296
- test: husky.test,
297
- lift: ({
298
- projectRoot,
299
- results
300
- }) => husky.lift({
301
- projectRoot,
302
- results,
303
- packageManager
304
- })
305
- };
306
- }
307
-
308
312
  async function liftPackage ({
309
313
  projectRoot,
310
314
  scripts,
@@ -371,8 +375,11 @@ async function lift ({
371
375
  });
372
376
  const enhancerResults = await applyEnhancers({
373
377
  results,
374
- enhancers: [enhanceHuskyEnhancer(packageManager), enginesEnhancer, coveragePlugin],
375
- projectRoot
378
+ enhancers: [huskyPlugin__namespace, enginesEnhancer, coveragePlugin],
379
+ options: {
380
+ packageManager,
381
+ projectRoot
382
+ }
376
383
  });
377
384
  await liftPackage(deepmerge__default["default"].all([{
378
385
  projectRoot,
@@ -1524,7 +1531,7 @@ async function scaffoldVerification({
1524
1531
  decisions,
1525
1532
  dialect,
1526
1533
  pathWithinParent
1527
- }), husky.scaffold({
1534
+ }), huskyPlugin.scaffold({
1528
1535
  projectRoot,
1529
1536
  packageManager
1530
1537
  })]);