@form8ion/javascript 15.6.1 → 15.7.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@form8ion/javascript",
3
3
  "description": "JavaScript language plugin for the @form8ion toolset",
4
4
  "license": "MIT",
5
- "version": "15.6.1",
5
+ "version": "15.7.0",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": "^20.19.0 || >=22.14.0"
@@ -94,7 +94,7 @@
94
94
  "@form8ion/remark-lint-preset": "6.0.7",
95
95
  "@rollup/plugin-node-resolve": "16.0.3",
96
96
  "@travi/any": "3.1.3",
97
- "@vitest/coverage-v8": "4.1.0",
97
+ "@vitest/coverage-v8": "4.1.1",
98
98
  "ban-sensitive-files": "1.10.11",
99
99
  "chai": "6.2.2",
100
100
  "cz-conventional-changelog": "3.3.0",
@@ -110,10 +110,10 @@
110
110
  "remark-toc": "9.0.0",
111
111
  "remark-usage": "11.0.1",
112
112
  "rimraf": "6.1.3",
113
- "rollup": "4.59.0",
113
+ "rollup": "4.60.0",
114
114
  "rollup-plugin-auto-external": "2.0.0",
115
115
  "testdouble": "3.20.2",
116
- "vitest": "4.1.0",
116
+ "vitest": "4.1.1",
117
117
  "vitest-when": "0.10.0"
118
118
  }
119
119
  }
@@ -2,6 +2,6 @@ import deepmerge from 'deepmerge';
2
2
  import {scaffold as scaffoldCodecov} from '@form8ion/codecov';
3
3
  import {scaffold as scaffoldC8} from '@form8ion/c8';
4
4
 
5
- export default async function scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent}) {
6
- return deepmerge(await scaffoldC8({projectRoot}), await scaffoldCodecov({vcs, visibility, pathWithinParent}));
5
+ export default async function scaffoldCoverage({projectRoot}) {
6
+ return deepmerge(await scaffoldC8({projectRoot}), await scaffoldCodecov({projectRoot}));
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import {scaffold as scaffoldCodecov} from '@form8ion/codecov';
2
2
  import {scaffold as scaffoldC8} from '@form8ion/c8';
3
3
 
4
- import {describe, vi, it, expect, afterEach} from 'vitest';
4
+ import {describe, expect, it, vi} from 'vitest';
5
5
  import any from '@travi/any';
6
6
  import {when} from 'vitest-when';
7
7
 
@@ -11,21 +11,14 @@ vi.mock('@form8ion/codecov');
11
11
  vi.mock('@form8ion/c8');
12
12
 
13
13
  describe('coverage scaffolder', () => {
14
- afterEach(() => {
15
- vi.clearAllMocks();
16
- });
17
-
18
14
  it('should scaffold coverage measurement and reporting', async () => {
19
- const vcs = any.simpleObject();
20
- const visibility = any.word();
21
15
  const projectRoot = any.string();
22
16
  const c8Results = any.simpleObject();
23
17
  const codecovResults = any.simpleObject();
24
- const pathWithinParent = any.string();
25
18
  when(scaffoldC8).calledWith({projectRoot}).thenResolve(c8Results);
26
- when(scaffoldCodecov).calledWith({vcs, visibility, pathWithinParent}).thenResolve(codecovResults);
19
+ when(scaffoldCodecov).calledWith({projectRoot}).thenResolve(codecovResults);
27
20
 
28
- const results = await scaffold({vcs, visibility, projectRoot, pathWithinParent});
21
+ const results = await scaffold({projectRoot});
29
22
 
30
23
  expect(results).toEqual({...c8Results, ...codecovResults});
31
24
  });
@@ -32,6 +32,7 @@ export function validate(options) {
32
32
  }).default({registries: {}}),
33
33
  plugins: {
34
34
  unitTestFrameworks: pluginsSchema,
35
+ integrationTestFrameworks: pluginsSchema,
35
36
  packageBundlers: pluginsSchema,
36
37
  applicationTypes: pluginsSchema,
37
38
  packageTypes: pluginsSchema,
@@ -62,6 +62,7 @@ describe('options validator', () => {
62
62
  configs,
63
63
  plugins: {
64
64
  unitTestFrameworks: pluginsSchema,
65
+ integrationTestFrameworks: pluginsSchema,
65
66
  packageBundlers: pluginsSchema,
66
67
  applicationTypes: pluginsSchema,
67
68
  packageTypes: pluginsSchema,
package/src/scaffolder.js CHANGED
@@ -37,6 +37,7 @@ export default async function scaffoldJavascript(options) {
37
37
  monorepoTypes,
38
38
  packageBundlers,
39
39
  unitTestFrameworks,
40
+ integrationTestFrameworks,
40
41
  hosts,
41
42
  ciServices
42
43
  }
@@ -89,12 +90,12 @@ export default async function scaffoldJavascript(options) {
89
90
  const verificationResults = await scaffoldVerification({
90
91
  projectRoot,
91
92
  dialect,
92
- visibility,
93
93
  packageManager,
94
94
  vcs,
95
95
  registries: configs.registries,
96
96
  tests,
97
97
  unitTestFrameworks,
98
+ integrationTestFrameworks,
98
99
  decisions,
99
100
  pathWithinParent
100
101
  });
@@ -82,6 +82,7 @@ describe('javascript project scaffolder', () => {
82
82
  const monorepoTypes = any.simpleObject();
83
83
  const packageBundlers = any.simpleObject();
84
84
  const unitTestFrameworks = any.simpleObject();
85
+ const integrationTestFrameworks = any.simpleObject();
85
86
  const testFilenamePattern = any.string();
86
87
  const buildDirectory = any.string();
87
88
  const packageResults = {...any.simpleObject(), packageName};
@@ -108,7 +109,16 @@ describe('javascript project scaffolder', () => {
108
109
  visibility,
109
110
  license,
110
111
  decisions,
111
- plugins: {ciServices, hosts, applicationTypes, packageTypes, monorepoTypes, packageBundlers, unitTestFrameworks}
112
+ plugins: {
113
+ ciServices,
114
+ hosts,
115
+ applicationTypes,
116
+ packageTypes,
117
+ monorepoTypes,
118
+ packageBundlers,
119
+ unitTestFrameworks,
120
+ integrationTestFrameworks
121
+ }
112
122
  });
113
123
  when(prompt)
114
124
  .calledWith(ciServices, hosts, visibility, vcs, decisions, configs, pathWithinParent)
@@ -155,14 +165,14 @@ describe('javascript project scaffolder', () => {
155
165
  .calledWith({
156
166
  projectRoot,
157
167
  dialect,
158
- visibility,
159
168
  packageManager,
160
169
  vcs,
161
170
  registries,
162
171
  tests,
163
172
  decisions,
164
173
  pathWithinParent,
165
- unitTestFrameworks
174
+ unitTestFrameworks,
175
+ integrationTestFrameworks
166
176
  })
167
177
  .thenResolve(verificationResults);
168
178
  when(scaffoldNodeVersion).calledWith({projectRoot, nodeVersionCategory}).thenResolve(nodeVersionResults);
@@ -0,0 +1 @@
1
+ export {default as scaffold} from './scaffolder.js';
@@ -0,0 +1,3 @@
1
+ export default function scaffoldIntegrationTesting() {
2
+ return {};
3
+ }
@@ -0,0 +1,9 @@
1
+ import {describe, it, expect} from 'vitest';
2
+
3
+ import scaffoldIntegrationTesting from './scaffolder.js';
4
+
5
+ describe('integration testing scaffolder', () => {
6
+ it('should scaffold the chosen framework', async () => {
7
+ expect(scaffoldIntegrationTesting()).toEqual({});
8
+ });
9
+ });
@@ -1,31 +1,26 @@
1
1
  import deepmerge from 'deepmerge';
2
2
 
3
3
  import {scaffold as scaffoldUnitTesting} from './unit/index.js';
4
+ import {scaffold as scaffoldIntegrationTesting} from './integration/index.js';
4
5
 
5
6
  export default async function scaffoldTesting({
6
7
  projectRoot,
7
- visibility,
8
8
  tests: {unit, integration},
9
- vcs,
10
9
  unitTestFrameworks,
10
+ integrationTestFrameworks,
11
11
  decisions,
12
- dialect,
13
- pathWithinParent
12
+ dialect
14
13
  }) {
15
- const unitResults = unit
16
- ? await scaffoldUnitTesting({
17
- projectRoot,
18
- visibility,
19
- vcs,
20
- frameworks: unitTestFrameworks,
21
- decisions,
22
- dialect,
23
- pathWithinParent
24
- })
25
- : {};
14
+ const [unitResults, integrationResults] = await Promise.all([
15
+ unit ? scaffoldUnitTesting({projectRoot, frameworks: unitTestFrameworks, decisions, dialect}) : {},
16
+ integration
17
+ ? scaffoldIntegrationTesting({projectRoot, frameworks: integrationTestFrameworks, decisions, dialect})
18
+ : {}
19
+ ]);
26
20
 
27
- return deepmerge(
21
+ return deepmerge.all([
28
22
  {dependencies: {javascript: {development: [...(unit || integration) ? ['@travi/any'] : []]}}, eslint: {}},
29
- unitResults
30
- );
23
+ unitResults,
24
+ integrationResults
25
+ ]);
31
26
  }
@@ -1,63 +1,99 @@
1
+ import deepmerge from 'deepmerge';
2
+
1
3
  import any from '@travi/any';
2
4
  import {it, expect, describe, vi, beforeEach} from 'vitest';
3
5
  import {when} from 'vitest-when';
4
6
 
5
7
  import {scaffold as scaffoldUnitTesting} from './unit/index.js';
8
+ import {scaffold as scaffoldIntegrationTesting} from './integration/index.js';
6
9
  import scaffoldTesting from './scaffolder.js';
7
10
 
11
+ vi.mock('deepmerge');
8
12
  vi.mock('./unit/index.js');
13
+ vi.mock('./integration/index.js');
9
14
 
10
15
  describe('testing scaffolder', () => {
11
16
  const projectRoot = any.string();
12
- const visibility = any.word();
13
17
  const dialect = any.word();
14
- const unitTestingDevDependencies = any.listOf(any.string);
15
- const unitTestNextSteps = any.listOf(any.simpleObject);
16
- const unitTestScripts = any.simpleObject();
17
- const unitTestFilesToIgnoreFromVcs = any.listOf(any.string);
18
- const unitTestDirectoriesToIgnoreFromVcs = any.listOf(any.string);
19
- const vcs = any.simpleObject();
20
18
  const unitTestFrameworks = any.simpleObject();
19
+ const integrationTestFrameworks = any.simpleObject();
21
20
  const decisions = any.simpleObject();
22
- const pathWithinParent = any.string();
21
+ const unitTestScaffoldResults = any.simpleObject();
22
+ const integrationTestScaffoldResults = any.simpleObject();
23
+ const mergedResults = any.simpleObject();
23
24
 
24
25
  beforeEach(() => {
25
26
  when(scaffoldUnitTesting)
26
- .calledWith({projectRoot, visibility, vcs, frameworks: unitTestFrameworks, decisions, dialect, pathWithinParent})
27
- .thenResolve({
28
- dependencies: {javascript: {development: unitTestingDevDependencies}},
29
- scripts: unitTestScripts,
30
- vcsIgnore: {files: unitTestFilesToIgnoreFromVcs, directories: unitTestDirectoriesToIgnoreFromVcs},
31
- nextSteps: unitTestNextSteps
32
- });
27
+ .calledWith({projectRoot, frameworks: unitTestFrameworks, decisions, dialect})
28
+ .thenResolve(unitTestScaffoldResults);
29
+ when(scaffoldIntegrationTesting)
30
+ .calledWith({projectRoot, frameworks: integrationTestFrameworks, decisions, dialect})
31
+ .thenResolve(integrationTestScaffoldResults);
33
32
  });
34
33
 
35
34
  it('should scaffold unit testing if the project will be unit test', async () => {
35
+ when(deepmerge.all)
36
+ .calledWith([
37
+ {dependencies: {javascript: {development: ['@travi/any']}}, eslint: {}},
38
+ unitTestScaffoldResults,
39
+ {}
40
+ ])
41
+ .thenReturn(mergedResults);
42
+
36
43
  expect(await scaffoldTesting({
37
44
  projectRoot,
38
- visibility,
39
- tests: {unit: true},
40
- vcs,
45
+ tests: {unit: true, integration: false},
41
46
  unitTestFrameworks,
47
+ integrationTestFrameworks,
42
48
  decisions,
43
- dialect,
44
- pathWithinParent
45
- })).toEqual({
46
- dependencies: {javascript: {development: ['@travi/any', ...unitTestingDevDependencies]}},
47
- scripts: unitTestScripts,
48
- vcsIgnore: {files: unitTestFilesToIgnoreFromVcs, directories: unitTestDirectoriesToIgnoreFromVcs},
49
- eslint: {},
50
- nextSteps: unitTestNextSteps
51
- });
49
+ dialect
50
+ })).toEqual(mergedResults);
52
51
  });
53
52
 
54
- it('should not scaffold unit testing if the project will not be unit tested', async () => {
55
- expect(await scaffoldTesting({projectRoot, visibility, tests: {unit: false, integration: true}, pathWithinParent}))
56
- .toEqual({dependencies: {javascript: {development: ['@travi/any']}}, eslint: {}});
53
+ it('should scaffold integration testing if the project will be integration tested', async () => {
54
+ when(deepmerge.all)
55
+ .calledWith([
56
+ {dependencies: {javascript: {development: ['@travi/any']}}, eslint: {}},
57
+ {},
58
+ integrationTestScaffoldResults
59
+ ])
60
+ .thenReturn(mergedResults);
61
+
62
+ expect(await scaffoldTesting({
63
+ projectRoot,
64
+ tests: {unit: false, integration: true},
65
+ unitTestFrameworks,
66
+ integrationTestFrameworks,
67
+ decisions,
68
+ dialect
69
+ })).toEqual(mergedResults);
70
+ });
71
+
72
+ it('should scaffold both unit testing and integration testing if both layers are planned', async () => {
73
+ when(deepmerge.all)
74
+ .calledWith([
75
+ {dependencies: {javascript: {development: ['@travi/any']}}, eslint: {}},
76
+ unitTestScaffoldResults,
77
+ integrationTestScaffoldResults
78
+ ])
79
+ .thenReturn(mergedResults);
80
+
81
+ expect(await scaffoldTesting({
82
+ projectRoot,
83
+ tests: {unit: true, integration: true},
84
+ unitTestFrameworks,
85
+ integrationTestFrameworks,
86
+ decisions,
87
+ dialect
88
+ })).toEqual(mergedResults);
57
89
  });
58
90
 
59
91
  it('should not scaffold testing if the project will not be tested', async () => {
60
- expect(await scaffoldTesting({projectRoot, visibility, tests: {unit: false, integration: false}, pathWithinParent}))
61
- .toEqual({dependencies: {javascript: {development: []}}, eslint: {}});
92
+ when(deepmerge.all)
93
+ .calledWith([{dependencies: {javascript: {development: []}}, eslint: {}}, {}, {}])
94
+ .thenReturn(mergedResults);
95
+
96
+ expect(await scaffoldTesting({projectRoot, tests: {unit: false, integration: false}}))
97
+ .toEqual(mergedResults);
62
98
  });
63
99
  });
@@ -6,20 +6,12 @@ import {scaffold as scaffoldCoverage} from '../../coverage/index.js';
6
6
  import chooseFramework from './prompt.js';
7
7
  import {pluginsSchema} from '../../plugins-schemas.js';
8
8
 
9
- export default async function scaffoldUnitTesting({
10
- projectRoot,
11
- frameworks,
12
- decisions,
13
- visibility,
14
- vcs,
15
- pathWithinParent,
16
- dialect
17
- }) {
9
+ export default async function scaffoldUnitTesting({projectRoot, frameworks, decisions, dialect}) {
18
10
  const validatedFrameworks = validateOptions(pluginsSchema, frameworks);
19
11
  const [framework, coverage] = await Promise.all([
20
12
  chooseFramework({frameworks: validatedFrameworks, decisions})
21
13
  .then(chosenFramework => scaffoldFrameworkChoice(validatedFrameworks, chosenFramework, {projectRoot, dialect})),
22
- scaffoldCoverage({projectRoot, vcs, visibility, pathWithinParent})
14
+ scaffoldCoverage({projectRoot})
23
15
  ]);
24
16
 
25
17
  return deepmerge.all([
@@ -19,27 +19,22 @@ vi.mock('./prompt.js');
19
19
 
20
20
  describe('unit testing scaffolder', () => {
21
21
  const projectRoot = any.string();
22
- const vcs = any.simpleObject();
23
22
  const frameworks = any.simpleObject();
24
23
  const decisions = any.simpleObject();
25
24
  const chosenFramework = any.word();
26
25
  const dialect = any.word();
27
- const pathWithinParent = any.string();
28
26
  const coverageResults = any.simpleObject();
29
27
  const unitTestFrameworkResults = any.simpleObject();
30
28
  const mergedResults = any.simpleObject();
31
29
 
32
30
  it('should scaffold the chosen framework', async () => {
33
- const visibility = any.word();
34
31
  const validatedFrameworks = any.simpleObject();
35
32
  when(validateOptions).calledWith(pluginsSchema, frameworks).thenReturn(validatedFrameworks);
36
33
  when(prompt).calledWith({frameworks: validatedFrameworks, decisions}).thenResolve(chosenFramework);
37
34
  when(scaffoldChoice)
38
35
  .calledWith(validatedFrameworks, chosenFramework, {projectRoot, dialect})
39
36
  .thenResolve(unitTestFrameworkResults);
40
- when(scaffoldCoverage)
41
- .calledWith({projectRoot, vcs, visibility, pathWithinParent})
42
- .thenResolve(coverageResults);
37
+ when(scaffoldCoverage).calledWith({projectRoot}).thenResolve(coverageResults);
43
38
  when(deepmerge.all)
44
39
  .calledWith([
45
40
  {scripts: {'test:unit': 'cross-env NODE_ENV=test c8 run-s test:unit:base'}},
@@ -48,7 +43,6 @@ describe('unit testing scaffolder', () => {
48
43
  ])
49
44
  .thenReturn(mergedResults);
50
45
 
51
- expect(await scaffoldUnitTesting({projectRoot, frameworks, decisions, vcs, visibility, pathWithinParent, dialect}))
52
- .toEqual(mergedResults);
46
+ expect(await scaffoldUnitTesting({projectRoot, frameworks, decisions, dialect})).toEqual(mergedResults);
53
47
  });
54
48
  });
@@ -7,26 +7,17 @@ import {scaffold as scaffoldLinting} from '../linting/index.js';
7
7
  export async function scaffoldVerification({
8
8
  projectRoot,
9
9
  dialect,
10
- visibility,
11
10
  packageManager,
12
11
  vcs,
13
12
  registries,
14
13
  tests,
15
14
  unitTestFrameworks,
15
+ integrationTestFrameworks,
16
16
  decisions,
17
17
  pathWithinParent
18
18
  }) {
19
19
  const [testingResults, lintingResults, huskyResults] = await Promise.all([
20
- scaffoldTesting({
21
- projectRoot,
22
- tests,
23
- visibility,
24
- vcs,
25
- unitTestFrameworks,
26
- decisions,
27
- dialect,
28
- pathWithinParent
29
- }),
20
+ scaffoldTesting({projectRoot, tests, unitTestFrameworks, integrationTestFrameworks, decisions, dialect}),
30
21
  scaffoldLinting({projectRoot, packageManager, registries, vcs, pathWithinParent}),
31
22
  scaffoldHusky({projectRoot, packageManager, pathWithinParent})
32
23
  ]);
@@ -17,12 +17,12 @@ vi.mock('../linting/index.js');
17
17
  describe('verification scaffolder', () => {
18
18
  it('should scaffold linting and testing', async () => {
19
19
  const projectRoot = any.string();
20
- const visibility = any.string();
21
20
  const packageManager = any.string();
22
21
  const dialect = any.word();
23
22
  const vcs = any.simpleObject();
24
23
  const tests = any.simpleObject();
25
24
  const unitTestFrameworks = any.simpleObject();
25
+ const integrationTestFrameworks = any.simpleObject();
26
26
  const decisions = any.simpleObject();
27
27
  const lintingResults = any.simpleObject();
28
28
  const huskyResults = any.simpleObject();
@@ -35,7 +35,7 @@ describe('verification scaffolder', () => {
35
35
  .calledWith({projectRoot, vcs, packageManager, registries, pathWithinParent})
36
36
  .thenResolve(lintingResults);
37
37
  when(scaffoldTesting)
38
- .calledWith({projectRoot, tests, visibility, vcs, unitTestFrameworks, decisions, dialect, pathWithinParent})
38
+ .calledWith({projectRoot, tests, unitTestFrameworks, integrationTestFrameworks, decisions, dialect})
39
39
  .thenResolve(testingResults);
40
40
  when(scaffoldHusky).calledWith({projectRoot, packageManager, pathWithinParent}).thenResolve(huskyResults);
41
41
  when(deepmerge.all).calledWith([testingResults, lintingResults, huskyResults]).thenReturn(mergedResults);
@@ -45,9 +45,9 @@ describe('verification scaffolder', () => {
45
45
  vcs,
46
46
  dialect,
47
47
  tests,
48
- visibility,
49
48
  decisions,
50
49
  unitTestFrameworks,
50
+ integrationTestFrameworks,
51
51
  packageManager,
52
52
  registries,
53
53
  pathWithinParent