@servicetitan/startup 34.0.0 → 34.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/dist/cli/commands/review/rules/require-tsconfig-references.d.ts +2 -0
- package/dist/cli/commands/review/rules/require-tsconfig-references.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-tsconfig-references.js +17 -7
- package/dist/cli/commands/review/rules/require-tsconfig-references.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +4 -6
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/run-task.test.js +4 -10
- package/dist/cli/commands/run-task.test.js.map +1 -1
- package/dist/cli/tasks/index.d.ts +4 -0
- package/dist/cli/tasks/index.d.ts.map +1 -0
- package/dist/cli/tasks/index.js +22 -0
- package/dist/cli/tasks/index.js.map +1 -0
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts +23 -0
- package/dist/cli/tasks/swc-compile-package/get-swc-options.d.ts.map +1 -0
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js +41 -0
- package/dist/cli/tasks/swc-compile-package/get-swc-options.js.map +1 -0
- package/dist/cli/tasks/swc-compile-package/index.d.ts +3 -0
- package/dist/cli/tasks/swc-compile-package/index.d.ts.map +1 -0
- package/dist/cli/tasks/swc-compile-package/index.js +21 -0
- package/dist/cli/tasks/swc-compile-package/index.js.map +1 -0
- package/dist/cli/tasks/{swc-compile-package.d.ts → swc-compile-package/swc-compile-package.d.ts} +1 -1
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.d.ts.map +1 -0
- package/dist/cli/tasks/{swc-compile-package.js → swc-compile-package/swc-compile-package.js} +35 -55
- package/dist/cli/tasks/swc-compile-package/swc-compile-package.js.map +1 -0
- package/dist/cli/tasks/tsc-compile/index.d.ts +2 -0
- package/dist/cli/tasks/tsc-compile/index.d.ts.map +1 -0
- package/dist/cli/tasks/tsc-compile/index.js +20 -0
- package/dist/cli/tasks/tsc-compile/index.js.map +1 -0
- package/dist/cli/tasks/{tsc-compile.d.ts → tsc-compile/tsc-compile.d.ts} +1 -1
- package/dist/cli/tasks/tsc-compile/tsc-compile.d.ts.map +1 -0
- package/dist/cli/tasks/{tsc-compile.js → tsc-compile/tsc-compile.js} +2 -2
- package/dist/cli/tasks/tsc-compile/tsc-compile.js.map +1 -0
- package/dist/cli/tasks/tsc-compile-package/index.d.ts +2 -0
- package/dist/cli/tasks/tsc-compile-package/index.d.ts.map +1 -0
- package/dist/cli/tasks/tsc-compile-package/index.js +20 -0
- package/dist/cli/tasks/tsc-compile-package/index.js.map +1 -0
- package/dist/cli/tasks/{tsc-compile-package.d.ts → tsc-compile-package/tsc-compile-package.d.ts} +1 -1
- package/dist/cli/tasks/tsc-compile-package/tsc-compile-package.d.ts.map +1 -0
- package/dist/cli/tasks/{tsc-compile-package.js → tsc-compile-package/tsc-compile-package.js} +2 -2
- package/dist/cli/tasks/tsc-compile-package/tsc-compile-package.js.map +1 -0
- package/dist/cli/utils/bundle.js +1 -1
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/storybook-config/index.d.ts +3 -0
- package/dist/storybook-config/index.d.ts.map +1 -0
- package/dist/storybook-config/index.js +21 -0
- package/dist/storybook-config/index.js.map +1 -0
- package/dist/storybook-config/swc.d.ts +28 -0
- package/dist/storybook-config/swc.d.ts.map +1 -0
- package/dist/storybook-config/swc.js +36 -0
- package/dist/storybook-config/swc.js.map +1 -0
- package/dist/storybook-config/webpack-final.d.ts +4 -0
- package/dist/storybook-config/webpack-final.d.ts.map +1 -0
- package/dist/storybook-config/webpack-final.js +96 -0
- package/dist/storybook-config/webpack-final.js.map +1 -0
- package/dist/webpack/configs/index.d.ts +1 -0
- package/dist/webpack/configs/index.d.ts.map +1 -1
- package/dist/webpack/configs/index.js +1 -0
- package/dist/webpack/configs/index.js.map +1 -1
- package/dist/webpack/configs/rules-config.d.ts +2 -3
- package/dist/webpack/configs/rules-config.d.ts.map +1 -1
- package/dist/webpack/configs/rules-config.js.map +1 -1
- package/dist/webpack/configs/types.d.ts +6 -6
- package/dist/webpack/configs/types.d.ts.map +1 -1
- package/dist/webpack/utils/testing/get-compiler.js.map +1 -1
- package/package.json +16 -14
- package/src/cli/commands/__tests__/build.test.ts +0 -3
- package/src/cli/commands/__tests__/bundle-package.test.ts +0 -2
- package/src/cli/commands/__tests__/get-command.test.ts +0 -3
- package/src/cli/commands/__tests__/kendo-ui-license.test.ts +0 -2
- package/src/cli/commands/__tests__/lint.test.ts +0 -2
- package/src/cli/commands/__tests__/mfe-list.test.ts +0 -2
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +0 -2
- package/src/cli/commands/__tests__/mfe-package-rollback.test.ts +0 -2
- package/src/cli/commands/__tests__/mfe-publish.test.ts +0 -2
- package/src/cli/commands/__tests__/prepare-package.test.ts +0 -3
- package/src/cli/commands/__tests__/start.test.ts +0 -3
- package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +0 -2
- package/src/cli/commands/review/rules/__tests__/require-tsconfig-references.test.ts +124 -246
- package/src/cli/commands/review/rules/require-tsconfig-references.ts +24 -8
- package/src/cli/commands/run-task.test.ts +1 -6
- package/src/cli/commands/run-task.ts +1 -3
- package/src/cli/commands/test/runners/__tests__/jest.test.ts +1 -1
- package/src/cli/tasks/index.ts +3 -0
- package/src/cli/tasks/swc-compile-package/__tests__/get-swc-options.test.ts +77 -0
- package/src/cli/tasks/{__tests__ → swc-compile-package/__tests__}/swc-compile-package.test.ts +14 -76
- package/src/cli/tasks/swc-compile-package/get-swc-options.ts +34 -0
- package/src/cli/tasks/swc-compile-package/index.ts +2 -0
- package/src/cli/tasks/swc-compile-package/swc-cli.d.ts +22 -0
- package/src/cli/tasks/{swc-compile-package.ts → swc-compile-package/swc-compile-package.ts} +33 -52
- package/src/cli/tasks/{__tests__ → tsc-compile/__tests__}/tsc-compile.test.ts +1 -3
- package/src/cli/tasks/tsc-compile/index.ts +1 -0
- package/src/cli/tasks/{tsc-compile.ts → tsc-compile/tsc-compile.ts} +9 -2
- package/src/cli/tasks/{__tests__ → tsc-compile-package/__tests__}/tsc-compile-package.test.ts +2 -4
- package/src/cli/tasks/tsc-compile-package/index.ts +1 -0
- package/src/cli/tasks/{tsc-compile-package.ts → tsc-compile-package/tsc-compile-package.ts} +2 -2
- package/src/cli/utils/bundle.ts +1 -1
- package/src/storybook-config/__tests__/swc.test.ts +37 -0
- package/src/storybook-config/__tests__/webpack-final.test.ts +133 -0
- package/src/storybook-config/index.ts +2 -0
- package/src/storybook-config/swc.ts +24 -0
- package/src/storybook-config/webpack-final.ts +72 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +0 -2
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +0 -2
- package/src/webpack/__tests__/create-webpack-config.test.ts +0 -2
- package/src/webpack/configs/index.ts +1 -0
- package/src/webpack/configs/rules-config.ts +5 -10
- package/src/webpack/configs/types.ts +6 -6
- package/src/webpack/utils/testing/get-compiler.ts +1 -1
- package/dist/cli/tasks/swc-compile-package.d.ts.map +0 -1
- package/dist/cli/tasks/swc-compile-package.js.map +0 -1
- package/dist/cli/tasks/tsc-compile-package.d.ts.map +0 -1
- package/dist/cli/tasks/tsc-compile-package.js.map +0 -1
- package/dist/cli/tasks/tsc-compile.d.ts.map +0 -1
- package/dist/cli/tasks/tsc-compile.js.map +0 -1
- package/src/cli/tasks/swc-cli.d.ts +0 -14
|
@@ -13,8 +13,6 @@ jest.mock('fs', () => require('memfs').fs);
|
|
|
13
13
|
jest.mock('readline/promises', () => ({
|
|
14
14
|
createInterface: jest.fn(),
|
|
15
15
|
}));
|
|
16
|
-
jest.mock('yargs', () => jest.fn());
|
|
17
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
18
16
|
|
|
19
17
|
jest.mock('../../utils', () => ({
|
|
20
18
|
...jest.requireActual('../../utils'),
|
|
@@ -15,8 +15,6 @@ import { MFEPackagePublish } from '../mfe-package-publish';
|
|
|
15
15
|
import { ROLLBACK_TAG_SUFFIX } from '../utils';
|
|
16
16
|
|
|
17
17
|
jest.mock('fs', () => fs);
|
|
18
|
-
jest.mock('yargs', () => jest.fn());
|
|
19
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
20
18
|
|
|
21
19
|
jest.mock('../../../utils', () => ({
|
|
22
20
|
...jest.requireActual('../../../utils'),
|
|
@@ -2,8 +2,6 @@ import { log, readJson } from '../../../utils';
|
|
|
2
2
|
import { npmTagVersion, npmView } from '../../utils';
|
|
3
3
|
import { MFEPackageRollback } from '../mfe-package-rollback';
|
|
4
4
|
|
|
5
|
-
jest.mock('yargs', () => jest.fn());
|
|
6
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
7
5
|
jest.mock('../../../utils', () => ({
|
|
8
6
|
...jest.requireActual('../../../utils'),
|
|
9
7
|
log: {
|
|
@@ -8,8 +8,6 @@ import { MFEPackageRollback } from '../mfe-package-rollback';
|
|
|
8
8
|
import { MFEPublish } from '../mfe-publish';
|
|
9
9
|
|
|
10
10
|
jest.mock('fs', () => fs);
|
|
11
|
-
jest.mock('yargs', () => jest.fn());
|
|
12
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
13
11
|
|
|
14
12
|
jest.mock('../../utils');
|
|
15
13
|
jest.mock('../../../utils', () => ({
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { copyFiles } from '../../utils';
|
|
2
2
|
import { PreparePackage } from '../prepare-package';
|
|
3
3
|
|
|
4
|
-
jest.mock('yargs', () => jest.fn());
|
|
5
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
6
|
-
|
|
7
4
|
jest.mock('../../utils', () => ({
|
|
8
5
|
...jest.requireActual('../../utils'),
|
|
9
6
|
copyFiles: jest.fn(),
|
|
@@ -3,9 +3,6 @@ import { Package, PackageType, getPackages, log } from '../../../utils';
|
|
|
3
3
|
import { compile, lernaExec, typeCheck, watchStdout } from '../../utils';
|
|
4
4
|
import { Start } from '../start';
|
|
5
5
|
|
|
6
|
-
jest.mock('yargs', () => jest.fn());
|
|
7
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
8
|
-
|
|
9
6
|
jest.mock('../../../utils', () => ({
|
|
10
7
|
...jest.requireActual('../../../utils'),
|
|
11
8
|
getPackages: jest.fn(),
|
|
@@ -9,8 +9,6 @@ import { UploadSourcemaps } from '../upload-sourcemaps';
|
|
|
9
9
|
jest.mock('@servicetitan/install');
|
|
10
10
|
jest.mock('fs', () => require('memfs').fs);
|
|
11
11
|
jest.mock('child_process', () => ({ execSync: jest.fn() }));
|
|
12
|
-
jest.mock('yargs', () => jest.fn());
|
|
13
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
14
12
|
|
|
15
13
|
jest.mock('../../../utils', () => ({
|
|
16
14
|
...jest.requireActual('../../../utils'),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { fs, vol } from 'memfs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import { mockProject } from '../__mocks__';
|
|
5
|
-
|
|
3
|
+
import { createPackage } from '../../../../../__mocks__';
|
|
6
4
|
import { prettifySync } from '../../../../../utils';
|
|
5
|
+
import { Package } from '../../types';
|
|
6
|
+
import { mockProject } from '../__mocks__';
|
|
7
7
|
import { RequireTsconfigReferences } from '../require-tsconfig-references';
|
|
8
8
|
|
|
9
9
|
jest.mock('node:fs', () => fs);
|
|
@@ -17,299 +17,177 @@ jest.mock('../../../../../utils', () => ({
|
|
|
17
17
|
|
|
18
18
|
describe(`[startup] Review ${RequireTsconfigReferences.name}`, () => {
|
|
19
19
|
let rule: RequireTsconfigReferences;
|
|
20
|
-
let config: ReviewConfiguration;
|
|
21
20
|
let packages: Package[];
|
|
22
21
|
|
|
23
22
|
beforeEach(() => {
|
|
24
23
|
rule = new RequireTsconfigReferences();
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
packages = [
|
|
25
|
+
// Note, tests assume the "app" that depends on local package(s) is first
|
|
26
|
+
createPackage({ name: 'app', dependencies: { utils: '1.0.0' } }),
|
|
27
|
+
createPackage({ name: 'utils' }),
|
|
28
|
+
];
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
afterEach(() => vol.reset());
|
|
30
32
|
|
|
31
|
-
const subject = () => rule.run(mockProject({
|
|
32
|
-
const fixSubject = () => {
|
|
33
|
-
const ruleErrors = subject();
|
|
33
|
+
const subject = () => rule.run(mockProject({ packages }));
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
function appTsConfig() {
|
|
36
|
+
return path.join(packages[0].location, 'tsconfig.json');
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
function
|
|
39
|
-
packages = pkgs;
|
|
39
|
+
function volFromJSON(json: Record<string, any>) {
|
|
40
40
|
vol.fromJSON(
|
|
41
41
|
Object.fromEntries(
|
|
42
|
-
Object.entries(
|
|
42
|
+
Object.entries(json).map(([filePath, content]) => [
|
|
43
43
|
filePath,
|
|
44
|
-
JSON.stringify(content
|
|
44
|
+
JSON.stringify(content),
|
|
45
45
|
])
|
|
46
46
|
)
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
setupPackages(
|
|
53
|
-
[
|
|
54
|
-
{
|
|
55
|
-
name: '@servicetitan/runtime',
|
|
56
|
-
location: path.normalize('packages/runtime'),
|
|
57
|
-
dependencies: {
|
|
58
|
-
'@servicetitan/log-service': '1.0.0',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: '@servicetitan/log-service',
|
|
63
|
-
location: path.normalize('packages/log-service'),
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
{
|
|
67
|
-
[path.normalize('packages/runtime/tsconfig.json')]: {
|
|
68
|
-
references: [{ path: '../log-service/tsconfig.json' }],
|
|
69
|
-
},
|
|
70
|
-
[path.normalize('packages/log-service/tsconfig.json')]: {},
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
|
|
50
|
+
function itReportsNoErrors() {
|
|
75
51
|
test('reports no errors', () => {
|
|
76
52
|
expect(subject()).toEqual([]);
|
|
77
53
|
});
|
|
78
|
-
}
|
|
54
|
+
}
|
|
79
55
|
|
|
80
|
-
describe('when
|
|
56
|
+
describe('when package has correct tsconfig reference', () => {
|
|
81
57
|
beforeEach(() => {
|
|
82
|
-
|
|
83
|
-
[
|
|
84
|
-
|
|
85
|
-
name: '@servicetitan/runtime',
|
|
86
|
-
location: path.normalize('packages/runtime'),
|
|
87
|
-
dependencies: {
|
|
88
|
-
'@servicetitan/log-service': '1.0.0',
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: '@servicetitan/log-service',
|
|
93
|
-
location: path.normalize('packages/log-service'),
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
{
|
|
97
|
-
[path.normalize('packages/runtime/tsconfig.json')]: {},
|
|
98
|
-
[path.normalize('packages/runtime/tsconfig.build.json')]: {},
|
|
99
|
-
[path.normalize('packages/log-service/tsconfig.json')]: {},
|
|
100
|
-
}
|
|
101
|
-
);
|
|
58
|
+
volFromJSON({
|
|
59
|
+
[appTsConfig()]: { references: [{ path: '../utils/tsconfig.json' }] },
|
|
60
|
+
});
|
|
102
61
|
});
|
|
103
62
|
|
|
104
|
-
|
|
105
|
-
expect(subject()).toEqual(
|
|
106
|
-
expect.arrayContaining([
|
|
107
|
-
{
|
|
108
|
-
id: 'require-tsconfig-references',
|
|
109
|
-
message: 'missing reference for dependency: @servicetitan/log-service',
|
|
110
|
-
location: path.normalize('packages/runtime/tsconfig.json'),
|
|
111
|
-
fixable: 'normal',
|
|
112
|
-
data: {
|
|
113
|
-
tsconfigPath: path.normalize('packages/runtime/tsconfig.json'),
|
|
114
|
-
missingReference: '@servicetitan/log-service',
|
|
115
|
-
expectedPath: '../log-service/tsconfig.json',
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
id: 'require-tsconfig-references',
|
|
120
|
-
message: 'missing reference for dependency: @servicetitan/log-service',
|
|
121
|
-
location: path.normalize('packages/runtime/tsconfig.build.json'),
|
|
122
|
-
fixable: 'normal',
|
|
123
|
-
data: {
|
|
124
|
-
tsconfigPath: path.normalize('packages/runtime/tsconfig.build.json'),
|
|
125
|
-
missingReference: '@servicetitan/log-service',
|
|
126
|
-
expectedPath: '../log-service/tsconfig.json',
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
])
|
|
130
|
-
);
|
|
131
|
-
});
|
|
63
|
+
itReportsNoErrors();
|
|
132
64
|
});
|
|
133
65
|
|
|
134
|
-
describe('when
|
|
66
|
+
describe('when reference is build config', () => {
|
|
135
67
|
beforeEach(() => {
|
|
136
|
-
|
|
137
|
-
[
|
|
138
|
-
|
|
139
|
-
name: '@servicetitan/runtime',
|
|
140
|
-
location: path.normalize('packages/runtime'),
|
|
141
|
-
devDependencies: { '@servicetitan/log-service': '1.0.0' },
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: '@servicetitan/examples',
|
|
145
|
-
location: path.normalize('packages/examples'),
|
|
146
|
-
peerDependencies: { '@servicetitan/log-service': '1.0.0' },
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: '@servicetitan/log-service',
|
|
150
|
-
location: path.normalize('packages/log-service'),
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
{
|
|
154
|
-
[path.normalize('packages/runtime/tsconfig.json')]: {},
|
|
155
|
-
[path.normalize('packages/examples/tsconfig.json')]: {},
|
|
156
|
-
[path.normalize('packages/log-service/tsconfig.json')]: {},
|
|
157
|
-
}
|
|
158
|
-
);
|
|
68
|
+
volFromJSON({
|
|
69
|
+
[appTsConfig()]: { references: [{ path: '../utils/tsconfig.build.json ' }] },
|
|
70
|
+
});
|
|
159
71
|
});
|
|
160
72
|
|
|
161
|
-
|
|
162
|
-
expect(subject()).toEqual([
|
|
163
|
-
{
|
|
164
|
-
id: 'require-tsconfig-references',
|
|
165
|
-
message: 'missing reference for dependency: @servicetitan/log-service',
|
|
166
|
-
location: path.normalize('packages/runtime/tsconfig.json'),
|
|
167
|
-
fixable: 'normal',
|
|
168
|
-
data: {
|
|
169
|
-
tsconfigPath: path.normalize('packages/runtime/tsconfig.json'),
|
|
170
|
-
missingReference: '@servicetitan/log-service',
|
|
171
|
-
expectedPath: '../log-service/tsconfig.json',
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
id: 'require-tsconfig-references',
|
|
176
|
-
message: 'missing reference for dependency: @servicetitan/log-service',
|
|
177
|
-
location: path.normalize('packages/examples/tsconfig.json'),
|
|
178
|
-
fixable: 'normal',
|
|
179
|
-
data: {
|
|
180
|
-
tsconfigPath: path.normalize('packages/examples/tsconfig.json'),
|
|
181
|
-
missingReference: '@servicetitan/log-service',
|
|
182
|
-
expectedPath: '../log-service/tsconfig.json',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
]);
|
|
186
|
-
});
|
|
73
|
+
itReportsNoErrors();
|
|
187
74
|
});
|
|
188
75
|
|
|
189
|
-
describe('when
|
|
190
|
-
const tsconfigPath = path.normalize('packages/nonexistent/tsconfig.json');
|
|
191
|
-
|
|
76
|
+
describe('when reference omits .json extension', () => {
|
|
192
77
|
beforeEach(() => {
|
|
193
|
-
|
|
194
|
-
[
|
|
195
|
-
|
|
196
|
-
name: '@servicetitan/runtime',
|
|
197
|
-
location: path.normalize('packages/runtime'),
|
|
198
|
-
devDependencies: { '@servicetitan/log-service': '1.0.0' },
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
name: '@servicetitan/log-service',
|
|
202
|
-
location: path.normalize('packages/log-service'),
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
{}
|
|
206
|
-
);
|
|
78
|
+
volFromJSON({
|
|
79
|
+
[appTsConfig()]: { references: [{ path: '../utils/tsconfig' }] },
|
|
80
|
+
});
|
|
207
81
|
});
|
|
208
82
|
|
|
209
|
-
|
|
210
|
-
|
|
83
|
+
itReportsNoErrors();
|
|
84
|
+
});
|
|
211
85
|
|
|
212
|
-
|
|
86
|
+
describe('when reference is directory', () => {
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
volFromJSON({
|
|
89
|
+
[appTsConfig()]: { references: [{ path: '../utils' }] },
|
|
90
|
+
'packages/utils/tsconfig.json': {}, // ensures directory exists
|
|
91
|
+
});
|
|
213
92
|
});
|
|
214
|
-
});
|
|
215
93
|
|
|
216
|
-
|
|
217
|
-
|
|
94
|
+
itReportsNoErrors();
|
|
95
|
+
});
|
|
218
96
|
|
|
97
|
+
describe('when package is missing reference', () => {
|
|
219
98
|
beforeEach(() => {
|
|
220
|
-
|
|
221
|
-
[
|
|
222
|
-
{
|
|
223
|
-
name: '@servicetitan/runtime',
|
|
224
|
-
location: path.normalize('packages/runtime'),
|
|
225
|
-
dependencies: {
|
|
226
|
-
'@servicetitan/log-service': '1.0.0',
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: '@servicetitan/log-service',
|
|
231
|
-
location: path.normalize('packages/log-service'),
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
{
|
|
235
|
-
[tsconfigFilePath]: {
|
|
236
|
-
references: [{ path: '../existing/tsconfig.json' }],
|
|
237
|
-
},
|
|
238
|
-
}
|
|
239
|
-
);
|
|
99
|
+
volFromJSON({ [appTsConfig()]: {} });
|
|
240
100
|
});
|
|
241
101
|
|
|
242
|
-
|
|
243
|
-
|
|
102
|
+
function itReportsError() {
|
|
103
|
+
test('reports error', () => {
|
|
104
|
+
expect(subject()).toEqual([
|
|
105
|
+
expect.objectContaining({
|
|
106
|
+
id: 'require-tsconfig-references',
|
|
107
|
+
message: 'missing reference for dependency: utils',
|
|
108
|
+
location: appTsConfig(),
|
|
109
|
+
fixable: 'normal',
|
|
110
|
+
}),
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
itReportsError();
|
|
116
|
+
|
|
117
|
+
describe.each(['devDependencies', 'peerDependencies'])(
|
|
118
|
+
'when dependency is in %s',
|
|
119
|
+
(key: keyof Package) => {
|
|
120
|
+
beforeEach(() => {
|
|
121
|
+
const appPackage = packages[0];
|
|
122
|
+
appPackage[key] = appPackage.dependencies;
|
|
123
|
+
delete appPackage.dependencies;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
itReportsError();
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
describe('when package is workspace root', () => {
|
|
131
|
+
beforeEach(() => (packages[0].location = '.'));
|
|
244
132
|
|
|
245
|
-
|
|
246
|
-
expect(content.references).toContainEqual({ path: '../existing/tsconfig.json' });
|
|
247
|
-
expect(content.references).toContainEqual({ path: '../log-service/tsconfig.json' });
|
|
133
|
+
itReportsNoErrors();
|
|
248
134
|
});
|
|
249
135
|
|
|
250
|
-
|
|
251
|
-
fixSubject()
|
|
136
|
+
describe('fix', () => {
|
|
137
|
+
const fixSubject = () => {
|
|
138
|
+
const ruleErrors = subject();
|
|
139
|
+
ruleErrors.forEach(rule.fix);
|
|
140
|
+
};
|
|
252
141
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
142
|
+
function expectReferences(references: Record<string, string>[]) {
|
|
143
|
+
const json = fs.readFileSync(appTsConfig(), { encoding: 'utf-8' }).toString();
|
|
144
|
+
expect(JSON.parse(json)).toEqual({ references });
|
|
145
|
+
}
|
|
256
146
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
setupPackages(
|
|
260
|
-
[
|
|
261
|
-
{
|
|
262
|
-
name: '@servicetitan/runtime',
|
|
263
|
-
location: path.normalize('packages/runtime'),
|
|
264
|
-
dependencies: {
|
|
265
|
-
'@servicetitan/log-service': '1.0.0',
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
name: '@servicetitan/log-service',
|
|
270
|
-
location: path.normalize('packages/log-service'),
|
|
271
|
-
},
|
|
272
|
-
],
|
|
273
|
-
{
|
|
274
|
-
[path.normalize('packages/runtime/tsconfig.json')]: {
|
|
275
|
-
references: [{ path: '../log-service/tsconfig' }],
|
|
276
|
-
},
|
|
277
|
-
[path.normalize('packages/log-service/tsconfig.json')]: {},
|
|
278
|
-
}
|
|
279
|
-
);
|
|
280
|
-
});
|
|
147
|
+
test('fixes error', () => {
|
|
148
|
+
fixSubject();
|
|
281
149
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
});
|
|
285
|
-
});
|
|
150
|
+
expectReferences([{ path: '../utils' }]);
|
|
151
|
+
});
|
|
286
152
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
setupPackages(
|
|
290
|
-
[
|
|
291
|
-
{
|
|
292
|
-
name: 'my-monorepo',
|
|
293
|
-
location: '.',
|
|
294
|
-
workspaces: ['packages/*'],
|
|
295
|
-
dependencies: {
|
|
296
|
-
'@servicetitan/log-service': '1.0.0',
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
name: '@servicetitan/log-service',
|
|
301
|
-
location: path.normalize('packages/log-service'),
|
|
302
|
-
},
|
|
303
|
-
],
|
|
304
|
-
{
|
|
305
|
-
'tsconfig.json': {},
|
|
306
|
-
[path.normalize('packages/log-service/tsconfig.json')]: {},
|
|
307
|
-
}
|
|
308
|
-
);
|
|
309
|
-
});
|
|
153
|
+
test('prettifies output', () => {
|
|
154
|
+
fixSubject();
|
|
310
155
|
|
|
311
|
-
|
|
312
|
-
|
|
156
|
+
expect(prettifySync).toHaveBeenCalledWith(appTsConfig());
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe('when reference is build config', () => {
|
|
160
|
+
beforeEach(() => {
|
|
161
|
+
volFromJSON({
|
|
162
|
+
[appTsConfig()]: {},
|
|
163
|
+
'packages/utils/tsconfig.build.json': {},
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('references build config', () => {
|
|
168
|
+
fixSubject();
|
|
169
|
+
|
|
170
|
+
expectReferences([{ path: '../utils/tsconfig.build.json' }]);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe('when package has other references', () => {
|
|
175
|
+
const references = [{ path: '../foo' }];
|
|
176
|
+
|
|
177
|
+
beforeEach(() => {
|
|
178
|
+
volFromJSON({ [appTsConfig()]: { references } });
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('preserves other references', () => {
|
|
182
|
+
fixSubject();
|
|
183
|
+
|
|
184
|
+
expectReferences([...references, { path: '../utils' }]);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('ignores invalid data', () => {
|
|
189
|
+
expect(() => rule.fix({} as any)).not.toThrow();
|
|
190
|
+
});
|
|
313
191
|
});
|
|
314
192
|
});
|
|
315
193
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { globSync } from 'glob';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { getTsConfig, prettifySync, readJsonSafe } from '../../../../utils';
|
|
4
|
+
import { getTsConfig, prettifySync, readJson, readJsonSafe } from '../../../../utils';
|
|
5
5
|
import { FixCategory, Package, PackageError, PackageRule, Project } from '../types';
|
|
6
6
|
import { checkPackages } from '../utils';
|
|
7
7
|
|
|
@@ -44,10 +44,7 @@ export class RequireTsconfigReferences implements PackageRule {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const { tsconfigPath, expectedPath } = data;
|
|
47
|
-
const tsconfig =
|
|
48
|
-
if (!tsconfig) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
47
|
+
const tsconfig = readJson<TsConfig>(tsconfigPath);
|
|
51
48
|
|
|
52
49
|
const references = tsconfig.references ?? [];
|
|
53
50
|
references.push({ path: expectedPath });
|
|
@@ -70,6 +67,9 @@ export class RequireTsconfigReferences implements PackageRule {
|
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
private normalizeTsConfigPath(filePath: string): string {
|
|
70
|
+
if (this.isDirectory(filePath)) {
|
|
71
|
+
return path.join(filePath, 'tsconfig.json');
|
|
72
|
+
}
|
|
73
73
|
return filePath.endsWith('.json') ? filePath : `${filePath}.json`;
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -83,8 +83,9 @@ export class RequireTsconfigReferences implements PackageRule {
|
|
|
83
83
|
const referencedPackages = new Set<string>();
|
|
84
84
|
|
|
85
85
|
for (const reference of config.references) {
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const resolvedRefPath = this.normalizeTsConfigPath(
|
|
87
|
+
path.resolve(tsconfigDir, reference.path)
|
|
88
|
+
);
|
|
88
89
|
const refDir = path.dirname(resolvedRefPath);
|
|
89
90
|
const packageName = this.locationToPackageName.get(refDir);
|
|
90
91
|
|
|
@@ -100,8 +101,11 @@ export class RequireTsconfigReferences implements PackageRule {
|
|
|
100
101
|
const relativePath = path.relative(fromLocation, toLocation);
|
|
101
102
|
const tsconfigFile = getTsConfig(toLocation);
|
|
102
103
|
const tsconfigName = path.basename(tsconfigFile);
|
|
104
|
+
const referencePath = this.isDefaultTsConfig(tsconfigName)
|
|
105
|
+
? relativePath
|
|
106
|
+
: path.join(relativePath, tsconfigName);
|
|
103
107
|
|
|
104
|
-
return
|
|
108
|
+
return referencePath.replaceAll('\\', '/');
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
private collectTsConfigFiles(location: string): string[] {
|
|
@@ -154,4 +158,16 @@ export class RequireTsconfigReferences implements PackageRule {
|
|
|
154
158
|
this.findMissingDependencyReferences(pkg, tsconfigPath, localDependencies)
|
|
155
159
|
);
|
|
156
160
|
};
|
|
161
|
+
|
|
162
|
+
private isDefaultTsConfig(name: string) {
|
|
163
|
+
return name === 'tsconfig.json';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private isDirectory(file: string) {
|
|
167
|
+
try {
|
|
168
|
+
return fs.statSync(file).isDirectory();
|
|
169
|
+
} catch {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
157
173
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { log } from '../../utils';
|
|
2
|
-
import { SwcCompilePackage } from '../tasks
|
|
3
|
-
import { TscCompile } from '../tasks/tsc-compile';
|
|
4
|
-
import { TscCompilePackage } from '../tasks/tsc-compile-package';
|
|
2
|
+
import { SwcCompilePackage, TscCompile, TscCompilePackage } from '../tasks';
|
|
5
3
|
import { RunTask } from './run-task';
|
|
6
4
|
|
|
7
|
-
jest.mock('yargs', () => jest.fn());
|
|
8
|
-
jest.mock('yargs/helpers', () => ({ hideBin: jest.fn() }));
|
|
9
|
-
|
|
10
5
|
jest.mock('../../utils', () => ({
|
|
11
6
|
...jest.requireActual('../../utils'),
|
|
12
7
|
log: { error: jest.fn(), text: jest.fn() },
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import { log, logErrors } from '../../utils';
|
|
3
|
-
import { SwcCompilePackage } from '../tasks
|
|
3
|
+
import { SwcCompilePackage, TscCompile, TscCompilePackage } from '../tasks';
|
|
4
4
|
import { Task } from '../tasks/task';
|
|
5
|
-
import { TscCompile } from '../tasks/tsc-compile';
|
|
6
|
-
import { TscCompilePackage } from '../tasks/tsc-compile-package';
|
|
7
5
|
import { Command, CommandOptions } from './types';
|
|
8
6
|
|
|
9
7
|
const options = {
|
|
@@ -13,7 +13,7 @@ type JestArgs = ConstructorParameters<typeof Jest>[0];
|
|
|
13
13
|
describe(`[startup] Test ${Jest.name}`, () => {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
15
|
const args: JestArgs = { _: ['foo'], $0: 'bar' };
|
|
16
|
-
const jestConfig: JestArgs = { ...args, setupFilesAfterEnv: ['./
|
|
16
|
+
const jestConfig: JestArgs = { ...args, setupFilesAfterEnv: ['./jest.setup.ts'] };
|
|
17
17
|
|
|
18
18
|
beforeAll(() => {
|
|
19
19
|
jest.mocked(getJestConfigCLI).mockReturnValue(jestConfig);
|