@form8ion/javascript 3.0.0-alpha.1 → 3.1.0-alpha.2

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.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 { info, warn } from '@travi/cli-messages';
10
- import { lift as lift$3, scaffold as scaffold$2 } from '@form8ion/eslint';
7
+ import { scaffold } from '@form8ion/codecov';
8
+ import { promises } from 'fs';
11
9
  import { fileExists } from '@form8ion/core';
12
- import { test as test$2, lift as lift$2, scaffold as scaffold$3 } from '@form8ion/husky';
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,8 @@ 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 { test as test$2, lift as lift$3, scaffold as scaffold$3 } from '@form8ion/husky';
24
+ import { lift as lift$4, scaffold as scaffold$2 } from '@form8ion/eslint';
25
25
 
26
26
  function ownKeys(object, enumerableOnly) {
27
27
  var keys = Object.keys(object);
@@ -116,6 +116,45 @@ async function scaffoldCoverage ({
116
116
  }));
117
117
  }
118
118
 
119
+ function nycIsConfigured ({
120
+ projectRoot
121
+ }) {
122
+ return fileExists(`${projectRoot}/.nycrc`);
123
+ }
124
+
125
+ async function removeNyc ({
126
+ projectRoot
127
+ }) {
128
+ await Promise.all([promises.unlink(`${projectRoot}/.nycrc`), promises.rmdir(`${projectRoot}/.nyc_output`, {
129
+ recursive: true,
130
+ force: true
131
+ })]);
132
+ }
133
+
134
+ async function lift$2({
135
+ projectRoot
136
+ }) {
137
+ if (await nycIsConfigured({
138
+ projectRoot
139
+ })) {
140
+ const [c8Results] = await Promise.all([scaffoldC8({
141
+ projectRoot
142
+ }), removeNyc({
143
+ projectRoot
144
+ })]);
145
+ return c8Results;
146
+ }
147
+
148
+ return {};
149
+ }
150
+
151
+ var coveragePlugin = /*#__PURE__*/Object.freeze({
152
+ __proto__: null,
153
+ scaffold: scaffoldCoverage,
154
+ lift: lift$2,
155
+ test: nycIsConfigured
156
+ });
157
+
119
158
  const unitTestFrameworksSchema = joi.object().required().pattern(/^/, joi.object({
120
159
  scaffolder: joi.func().arity(1).required()
121
160
  }));
@@ -218,6 +257,20 @@ var enginesEnhancer = /*#__PURE__*/Object.freeze({
218
257
  lift: lift$1
219
258
  });
220
259
 
260
+ function enhanceHuskyEnhancer(packageManager) {
261
+ return {
262
+ test: test$2,
263
+ lift: ({
264
+ projectRoot,
265
+ results
266
+ }) => lift$3({
267
+ projectRoot,
268
+ results,
269
+ packageManager
270
+ })
271
+ };
272
+ }
273
+
221
274
  async function liftPackage ({
222
275
  projectRoot,
223
276
  scripts,
@@ -261,20 +314,6 @@ async function resolvePackageManager ({
261
314
  throw new Error('Package-manager could not be determined');
262
315
  }
263
316
 
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
317
  async function lift ({
279
318
  projectRoot,
280
319
  results
@@ -292,13 +331,13 @@ async function lift ({
292
331
  projectRoot,
293
332
  packageManager: manager
294
333
  });
295
- const eslintResults = await lift$3({
334
+ const eslintResults = await lift$4({
296
335
  projectRoot,
297
336
  configs: eslintConfigs
298
337
  });
299
338
  const enhancerResults = await applyEnhancers({
300
339
  results,
301
- enhancers: [enhanceHuskyEnhancer(packageManager), enginesEnhancer],
340
+ enhancers: [enhanceHuskyEnhancer(packageManager), enginesEnhancer, coveragePlugin],
302
341
  projectRoot
303
342
  });
304
343
  await liftPackage(deepmerge.all([{
@@ -1621,13 +1660,7 @@ async function scaffolder (options) {
1621
1660
  async function test ({
1622
1661
  projectRoot
1623
1662
  }) {
1624
- try {
1625
- const stats = await promises.stat(`${projectRoot}/.nvmrc`);
1626
- return stats.isFile();
1627
- } catch (e) {
1628
- if ('ENOENT' === e.code) return false;
1629
- throw e;
1630
- }
1663
+ return fileExists(`${projectRoot}/.nvmrc`);
1631
1664
  }
1632
1665
 
1633
1666
  const questionNames = _objectSpread2(_objectSpread2({}, questionNames$2), questionNames$1);