@servicetitan/startup 22.19.0 → 22.21.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/build.d.ts +1 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +1 -0
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +5 -3
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +7 -2
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/start.d.ts +5 -4
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +3 -0
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/utils/bundle.d.ts +2 -0
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +14 -7
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/tsc.js +4 -2
- package/dist/cli/utils/tsc.js.map +1 -1
- package/dist/utils/get-jest-config.js +1 -1
- package/dist/utils/get-jest-config.js.map +1 -1
- package/dist/webpack/configs/amd-config.d.ts +6 -0
- package/dist/webpack/configs/amd-config.d.ts.map +1 -0
- package/dist/webpack/configs/amd-config.js +8 -0
- package/dist/webpack/configs/amd-config.js.map +1 -0
- package/dist/webpack/configs/dev-server-config.d.ts.map +1 -1
- package/dist/webpack/configs/dev-server-config.js +1 -5
- package/dist/webpack/configs/dev-server-config.js.map +1 -1
- 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/plugins/provide-react-plugin.d.ts +1 -1
- package/dist/webpack/configs/plugins/provide-react-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/provide-react-plugin.js +2 -2
- package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -1
- package/dist/webpack/configs/rules/tsx-rules.d.ts +1 -1
- package/dist/webpack/configs/rules/tsx-rules.d.ts.map +1 -1
- package/dist/webpack/configs/rules/tsx-rules.js +27 -7
- package/dist/webpack/configs/rules/tsx-rules.js.map +1 -1
- package/dist/webpack/configs/types.d.ts +1 -0
- package/dist/webpack/configs/types.d.ts.map +1 -1
- package/dist/webpack/configs/utils/generate-metadata.d.ts.map +1 -1
- package/dist/webpack/configs/utils/generate-metadata.js +5 -1
- package/dist/webpack/configs/utils/generate-metadata.js.map +1 -1
- package/dist/webpack/configs/utils/get-web-components-version.d.ts +2 -0
- package/dist/webpack/configs/utils/get-web-components-version.d.ts.map +1 -0
- package/dist/webpack/configs/utils/get-web-components-version.js +13 -0
- package/dist/webpack/configs/utils/get-web-components-version.js.map +1 -0
- package/dist/webpack/create-webpack-config.d.ts.map +1 -1
- package/dist/webpack/create-webpack-config.js +3 -1
- package/dist/webpack/create-webpack-config.js.map +1 -1
- package/dist/webpack/types.d.ts +2 -0
- package/dist/webpack/types.d.ts.map +1 -1
- package/package.json +8 -6
- package/src/cli/commands/__tests__/build.test.ts +14 -0
- package/src/cli/commands/__tests__/bundle-package.test.ts +8 -4
- package/src/cli/commands/__tests__/init.test.ts +5 -4
- package/src/cli/commands/__tests__/mfe-package-clean.test.ts +4 -3
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +5 -4
- package/src/cli/commands/__tests__/mfe-publish.test.ts +4 -3
- package/src/cli/commands/__tests__/start.test.ts +14 -0
- package/src/cli/commands/__tests__/styles-check.test.ts +12 -11
- package/src/cli/commands/build.ts +2 -0
- package/src/cli/commands/bundle-package.ts +13 -5
- package/src/cli/commands/start.ts +8 -4
- package/src/cli/utils/__tests__/bundle.test.ts +15 -14
- package/src/cli/utils/__tests__/eslint.test.ts +11 -4
- package/src/cli/utils/__tests__/get-module-type.test.ts +10 -15
- package/src/cli/utils/__tests__/is-module-installed.test.ts +6 -7
- package/src/cli/utils/__tests__/tcm.test.ts +6 -5
- package/src/cli/utils/__tests__/tsc.test.ts +7 -8
- package/src/cli/utils/bundle.ts +25 -7
- package/src/cli/utils/tsc.ts +7 -9
- package/src/utils/__tests__/get-configuration.test.ts +20 -14
- package/src/utils/__tests__/get-destination-folders.test.ts +11 -13
- package/src/utils/__tests__/get-folders.test.ts +8 -6
- package/src/utils/__tests__/get-jest-config.test.ts +1 -1
- package/src/utils/__tests__/get-tsconfig.test.ts +6 -4
- package/src/utils/__tests__/read-json.test.ts +12 -16
- package/src/utils/get-jest-config.ts +1 -1
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +6 -5
- package/src/webpack/__tests__/create-webpack-config.test.ts +53 -10
- package/src/webpack/configs/amd-config.ts +8 -0
- package/src/webpack/configs/dev-server-config.ts +2 -9
- package/src/webpack/configs/index.ts +1 -0
- package/src/webpack/configs/plugins/provide-react-plugin.ts +2 -2
- package/src/webpack/configs/rules/tsx-rules.ts +32 -10
- package/src/webpack/configs/types.ts +1 -0
- package/src/webpack/configs/utils/__tests__/generate-metadata.test.ts +17 -13
- package/src/webpack/configs/utils/__tests__/get-startup-version.test.ts +6 -10
- package/src/webpack/configs/utils/__tests__/get-web-components-version.test.ts +25 -0
- package/src/webpack/configs/utils/generate-metadata.ts +5 -1
- package/src/webpack/configs/utils/get-web-components-version.ts +8 -0
- package/src/webpack/create-webpack-config.ts +5 -1
- package/src/webpack/types.ts +2 -0
- package/template/.gitignore +7 -0
- package/template/.stylelintignore +1 -0
package/dist/webpack/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webpack/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AACtG,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,aAAa,IAAI,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,OAAO;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webpack/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AACtG,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,aAAa,IAAI,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,OAAO;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,SAAS;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE;QACN,0BAA0B,CAAC,EAAE,iCAAiC,CAAC;QAC/D,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;QAC7C,oBAAoB,CAAC,EAAE,2BAA2B,CAAC;KACtD,CAAC;CACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.21.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/startup",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,9 @@
|
|
|
38
38
|
"@jest/core": "~27.5.1",
|
|
39
39
|
"@jest/types": "~27.5.1",
|
|
40
40
|
"@lerna/exec": "~5.6.2",
|
|
41
|
-
"@servicetitan/eslint-config": "22.
|
|
42
|
-
"@servicetitan/stylelint-config": "22.
|
|
41
|
+
"@servicetitan/eslint-config": "22.21.0",
|
|
42
|
+
"@servicetitan/stylelint-config": "22.21.0",
|
|
43
|
+
"@swc/core": "1.3.100",
|
|
43
44
|
"@types/jest": "~27.4.0",
|
|
44
45
|
"chalk": "~4.1.2",
|
|
45
46
|
"chokidar": "~3.5.3",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"css-loader": "~6.8.1",
|
|
48
49
|
"debug": "^4.3.4",
|
|
49
50
|
"deepmerge": "~4.3.1",
|
|
50
|
-
"esbuild-loader": "~
|
|
51
|
+
"esbuild-loader": "~4.0.2",
|
|
51
52
|
"eslint": "~8.48.0",
|
|
52
53
|
"execa": "~5.1.1",
|
|
53
54
|
"fork-ts-checker-webpack-plugin": "~7.3.0",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"less": "~4.2.0",
|
|
62
63
|
"less-loader": "~10.2.0",
|
|
63
64
|
"less-plugin-npm-import": "~2.1.0",
|
|
64
|
-
"memfs": "~
|
|
65
|
+
"memfs": "~4.6.0",
|
|
65
66
|
"mini-css-extract-plugin": "~2.7.6",
|
|
66
67
|
"moment": "^2.29.4",
|
|
67
68
|
"moment-locales-webpack-plugin": "~1.2.0",
|
|
@@ -72,6 +73,7 @@
|
|
|
72
73
|
"source-map-loader": "~3.0.1",
|
|
73
74
|
"style-loader": "~3.3.3",
|
|
74
75
|
"stylelint": "~14.16.1",
|
|
76
|
+
"swc-loader": "0.2.3",
|
|
75
77
|
"ts-jest": "~27.1.4",
|
|
76
78
|
"ts-loader": "~9.4.4",
|
|
77
79
|
"ts-node": "~10.9.1",
|
|
@@ -95,5 +97,5 @@
|
|
|
95
97
|
"cli": {
|
|
96
98
|
"webpack": false
|
|
97
99
|
},
|
|
98
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "729b7ca4eb38c323ac538a73573cadd54a4ff839"
|
|
99
101
|
}
|
|
@@ -87,6 +87,20 @@ describe(`[startup] ${Build.name}`, () => {
|
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
+
describe('with "experimental-bundlers"', () => {
|
|
91
|
+
beforeEach(() => (args['experimental-bundlers'] = true));
|
|
92
|
+
|
|
93
|
+
test('enables swc-loader', async () => {
|
|
94
|
+
await subject();
|
|
95
|
+
|
|
96
|
+
expect(exec).toHaveBeenCalledWith(
|
|
97
|
+
expect.objectContaining({
|
|
98
|
+
'--': ['--experimental-bundlers'],
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
90
104
|
describe('with "stat"', () => {
|
|
91
105
|
beforeEach(() => (args.stat = true));
|
|
92
106
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import { log } from '../../../utils';
|
|
3
3
|
import { bundle, bundleWatch } from '../../utils';
|
|
4
4
|
|
|
5
5
|
import { BundlePackage } from '../bundle-package';
|
|
6
6
|
|
|
7
|
+
jest.mock('fs', () => fs);
|
|
8
|
+
|
|
7
9
|
jest.mock('../../../utils', () => ({
|
|
8
10
|
...jest.requireActual('../../../utils'),
|
|
9
11
|
log: { warning: jest.fn() },
|
|
@@ -20,10 +22,12 @@ describe(`[startup] ${BundlePackage.name}`, () => {
|
|
|
20
22
|
beforeEach(() => {
|
|
21
23
|
args = {};
|
|
22
24
|
jest.resetAllMocks();
|
|
23
|
-
|
|
25
|
+
vol.fromJSON({
|
|
26
|
+
'tsconfig.json': JSON.stringify({ compilerOptions: { module: 'esnext' } }),
|
|
27
|
+
});
|
|
24
28
|
});
|
|
25
29
|
|
|
26
|
-
afterEach(() =>
|
|
30
|
+
afterEach(() => vol.reset());
|
|
27
31
|
|
|
28
32
|
const subject = async () => new BundlePackage(args).execute();
|
|
29
33
|
|
|
@@ -77,7 +81,7 @@ describe(`[startup] ${BundlePackage.name}`, () => {
|
|
|
77
81
|
|
|
78
82
|
describe('when tsconfig\'s compilerOptions.module is not "esnext"', () => {
|
|
79
83
|
beforeEach(() => {
|
|
80
|
-
|
|
84
|
+
vol.fromJSON({
|
|
81
85
|
'tsconfig.json': JSON.stringify({ compilerOptions: { module: 'none' } }),
|
|
82
86
|
});
|
|
83
87
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import cpx from 'cpx';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import mockFS from 'mock-fs';
|
|
4
2
|
import path from 'path';
|
|
3
|
+
import { fs, vol } from 'memfs';
|
|
5
4
|
|
|
6
5
|
import { Init } from '../init';
|
|
7
6
|
|
|
7
|
+
jest.mock('fs', () => fs);
|
|
8
|
+
|
|
8
9
|
jest.mock('cpx', () => ({
|
|
9
10
|
copy: jest.fn().mockImplementation((...args: any[]) => {
|
|
10
11
|
const callback = args[args.length - 1];
|
|
@@ -29,9 +30,9 @@ describe(`[startup] ${Init.name}`, () => {
|
|
|
29
30
|
describe(`when ${gitIgnoreAlias} is present`, () => {
|
|
30
31
|
const gitIgnoreContent = ['foo', 'bar', 'baz'].join('\r\n');
|
|
31
32
|
|
|
32
|
-
beforeEach(() =>
|
|
33
|
+
beforeEach(() => vol.fromJSON({ [gitIgnoreAlias]: gitIgnoreContent }));
|
|
33
34
|
|
|
34
|
-
afterEach(() =>
|
|
35
|
+
afterEach(() => vol.reset());
|
|
35
36
|
|
|
36
37
|
test(`moves ${gitIgnoreAlias} -> .gitignore`, async () => {
|
|
37
38
|
await subject();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import { isWebComponent, log } from '../../../utils';
|
|
3
3
|
import { npmGetPackageVersionDates, npmUnpublish } from '../../utils/cli-npm';
|
|
4
4
|
|
|
5
5
|
import { MFEPackageClean } from '../mfe-publish';
|
|
6
6
|
|
|
7
|
+
jest.mock('fs', () => fs);
|
|
7
8
|
jest.mock('../../../utils', () => ({
|
|
8
9
|
...jest.requireActual('../../../utils'),
|
|
9
10
|
isWebComponent: jest.fn(),
|
|
@@ -34,10 +35,10 @@ describe(`[startup] ${MFEPackageClean.name}`, () => {
|
|
|
34
35
|
jest.resetAllMocks();
|
|
35
36
|
jest.mocked(isWebComponent).mockReturnValue(true);
|
|
36
37
|
jest.mocked(npmGetPackageVersionDates).mockImplementation(() => Object.entries(versions));
|
|
37
|
-
|
|
38
|
+
vol.fromJSON({ 'package.json': JSON.stringify({ name: packageName }) });
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
afterEach(() =>
|
|
41
|
+
afterEach(() => vol.reset());
|
|
41
42
|
|
|
42
43
|
const subject = async () => new MFEPackageClean(args).execute();
|
|
43
44
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import { isWebComponent, log } from '../../../utils';
|
|
3
3
|
import { gitGetBranch, gitGetCommitHash } from '../../utils/cli-git';
|
|
4
4
|
import {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from '../../utils/cli-npm';
|
|
10
10
|
import { MFEPackagePublish } from '../mfe-publish';
|
|
11
11
|
|
|
12
|
+
jest.mock('fs', () => fs);
|
|
12
13
|
jest.mock('../../../utils', () => ({
|
|
13
14
|
...jest.requireActual('../../../utils'),
|
|
14
15
|
isWebComponent: jest.fn(),
|
|
@@ -40,10 +41,10 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
|
|
|
40
41
|
jest.mocked(gitGetBranch).mockReturnValue(branch);
|
|
41
42
|
jest.mocked(gitGetCommitHash).mockReturnValue(commitHash);
|
|
42
43
|
jest.mocked(npmGetPackageVersions).mockReturnValue([]);
|
|
43
|
-
|
|
44
|
+
vol.fromJSON({ 'package.json': JSON.stringify({ name: packageName, files: [] }) });
|
|
44
45
|
});
|
|
45
46
|
|
|
46
|
-
afterEach(() =>
|
|
47
|
+
afterEach(() => vol.reset());
|
|
47
48
|
|
|
48
49
|
const subject = async () => new MFEPackagePublish(args).execute();
|
|
49
50
|
|
|
@@ -143,7 +144,7 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
|
|
|
143
144
|
});
|
|
144
145
|
|
|
145
146
|
describe('when package has no files', () => {
|
|
146
|
-
beforeEach(() =>
|
|
147
|
+
beforeEach(() => vol.fromJSON({ 'package.json': JSON.stringify({ name: packageName }) }));
|
|
147
148
|
|
|
148
149
|
test('sets package files to "package.json"', async () => {
|
|
149
150
|
await subject();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const exec = require('@lerna/exec');
|
|
2
|
-
import
|
|
2
|
+
import { fs, vol } from 'memfs';
|
|
3
3
|
import { Package, PackageType, getPackages } from '../../../utils';
|
|
4
4
|
import { createPackage } from '../../../__mocks__';
|
|
5
5
|
|
|
6
6
|
import { MFEPublish } from '../mfe-publish';
|
|
7
7
|
|
|
8
|
+
jest.mock('fs', () => fs);
|
|
8
9
|
jest.mock('@lerna/exec', () => jest.fn());
|
|
9
10
|
jest.mock('../../../utils', () => ({
|
|
10
11
|
...jest.requireActual('../../../utils'),
|
|
@@ -22,7 +23,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
|
|
|
22
23
|
jest.mocked(getPackages).mockReturnValue(packages);
|
|
23
24
|
});
|
|
24
25
|
|
|
25
|
-
afterEach(() =>
|
|
26
|
+
afterEach(() => vol.reset());
|
|
26
27
|
|
|
27
28
|
const subject = async () => new MFEPublish(args).execute();
|
|
28
29
|
|
|
@@ -49,7 +50,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
|
|
|
49
50
|
packages: Package[],
|
|
50
51
|
json: Record<string, any> = { cli: { 'web-component': true } }
|
|
51
52
|
) {
|
|
52
|
-
|
|
53
|
+
vol.fromJSON(
|
|
53
54
|
packages.reduce(
|
|
54
55
|
(result, { location }) => ({
|
|
55
56
|
...result,
|
|
@@ -89,6 +89,20 @@ describe(`[startup] ${Start.name}`, () => {
|
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
+
describe('with "experimental-bundlers"', () => {
|
|
93
|
+
beforeEach(() => (args['experimental-bundlers'] = true));
|
|
94
|
+
|
|
95
|
+
test('enables swc-loader', async () => {
|
|
96
|
+
await subject();
|
|
97
|
+
|
|
98
|
+
expect(exec).toHaveBeenCalledWith(
|
|
99
|
+
expect.objectContaining({
|
|
100
|
+
'--': ['--watch', '--experimental-bundlers'],
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
92
106
|
describe('with "config"', () => {
|
|
93
107
|
beforeEach(() => (args.config = 'foo.config.js'));
|
|
94
108
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import {
|
|
4
4
|
getFolders,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { StylesCheck } from '../styles-check';
|
|
13
13
|
|
|
14
|
+
jest.mock('fs', () => fs);
|
|
14
15
|
jest.mock('../../../utils', () => ({
|
|
15
16
|
...jest.requireActual('../../../utils'),
|
|
16
17
|
getFolders: jest.fn(),
|
|
@@ -30,7 +31,7 @@ describe(`[startup] ${StylesCheck.name}`, () => {
|
|
|
30
31
|
jest.mocked(getFolders).mockReturnValue({ source: 'src', destination: 'dist' });
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
afterEach(() =>
|
|
34
|
+
afterEach(() => vol.reset());
|
|
34
35
|
|
|
35
36
|
test("warns that application doesn't have design-system.css", async () => {
|
|
36
37
|
await subject();
|
|
@@ -70,13 +71,11 @@ describe(`[startup] ${StylesCheck.name}`, () => {
|
|
|
70
71
|
const systemMinCss = "@import '~@servicetitan/design-system/dist/system.min.css';";
|
|
71
72
|
|
|
72
73
|
beforeEach(() => {
|
|
73
|
-
|
|
74
|
-
src:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'styles': { 'baz.css': `${systemMinCss}\r\n` },
|
|
79
|
-
},
|
|
74
|
+
vol.fromJSON({
|
|
75
|
+
'src/design-system.css': [tokenCss, anvilFontsCss, systemMinCss].join('\r\n'),
|
|
76
|
+
'src/foo.css': `${tokenCss}\r\n`,
|
|
77
|
+
'src/bar.less': `${anvilFontsCss}\r\n`,
|
|
78
|
+
'src/styles/baz.css': `${systemMinCss}\r\n`,
|
|
80
79
|
});
|
|
81
80
|
});
|
|
82
81
|
|
|
@@ -89,13 +88,15 @@ describe(`[startup] ${StylesCheck.name}`, () => {
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
const errors = jest.mocked(log.error).mock.calls[0][0].split('\n');
|
|
92
|
-
|
|
91
|
+
const expectedErrors = [
|
|
93
92
|
expect.stringMatching(/style check error/i),
|
|
94
93
|
expect.stringMatching(/style check failed/i),
|
|
95
94
|
`file bar.less contains link to "${anvilFontsCss}"`,
|
|
96
95
|
`file foo.css contains link to "${tokenCss}"`,
|
|
97
96
|
`file ${path.join('styles', 'baz.css')} contains link to "${systemMinCss}"`,
|
|
98
|
-
]
|
|
97
|
+
];
|
|
98
|
+
expect(errors).toEqual(expect.arrayContaining(expectedErrors));
|
|
99
|
+
expect(errors.length).toEqual(expectedErrors.length);
|
|
99
100
|
});
|
|
100
101
|
}
|
|
101
102
|
|
|
@@ -8,6 +8,7 @@ interface Args {
|
|
|
8
8
|
'cdn-path'?: string;
|
|
9
9
|
'config'?: string;
|
|
10
10
|
'esbuild'?: boolean;
|
|
11
|
+
'experimental-bundlers'?: boolean;
|
|
11
12
|
'ignore'?: string | string[];
|
|
12
13
|
'scope'?: string | string[];
|
|
13
14
|
'stat'?: boolean;
|
|
@@ -51,6 +52,7 @@ export class Build implements Command {
|
|
|
51
52
|
'--': [
|
|
52
53
|
...[this.args.config ? `--config "${this.args.config}"` : undefined],
|
|
53
54
|
...[this.args.esbuild ? '--esbuild' : undefined],
|
|
55
|
+
...[this.args['experimental-bundlers'] ? '--experimental-bundlers' : undefined],
|
|
54
56
|
...[this.args.stat ? '--stat' : undefined],
|
|
55
57
|
].filter(item => item),
|
|
56
58
|
});
|
|
@@ -5,9 +5,11 @@ import { bundle, bundleWatch, getModuleType } from '../utils';
|
|
|
5
5
|
import { Command } from '.';
|
|
6
6
|
|
|
7
7
|
interface Args {
|
|
8
|
-
config?: string;
|
|
9
|
-
stat?: boolean;
|
|
10
|
-
watch?: boolean;
|
|
8
|
+
'config'?: string;
|
|
9
|
+
'stat'?: boolean;
|
|
10
|
+
'watch'?: boolean;
|
|
11
|
+
'esbuild'?: boolean;
|
|
12
|
+
'experimental-bundlers'?: boolean;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export class BundlePackage implements Command {
|
|
@@ -25,10 +27,16 @@ export class BundlePackage implements Command {
|
|
|
25
27
|
);
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
const options = {
|
|
31
|
+
config,
|
|
32
|
+
esbuild: this.args.esbuild,
|
|
33
|
+
experimentalBundlers: this.args['experimental-bundlers'],
|
|
34
|
+
};
|
|
35
|
+
|
|
28
36
|
if (!watch) {
|
|
29
|
-
await bundle({ buildStat: stat,
|
|
37
|
+
await bundle({ buildStat: stat, ...options });
|
|
30
38
|
} else {
|
|
31
|
-
await bundleWatch(
|
|
39
|
+
await bundleWatch(options);
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -5,10 +5,11 @@ import { tsc, tscWatch } from '../utils';
|
|
|
5
5
|
import { Command } from '.';
|
|
6
6
|
|
|
7
7
|
interface Args {
|
|
8
|
-
config?: string;
|
|
9
|
-
esbuild?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
'config'?: string;
|
|
9
|
+
'esbuild'?: boolean;
|
|
10
|
+
'experimental-bundlers'?: boolean;
|
|
11
|
+
'ignore'?: string | string[];
|
|
12
|
+
'scope'?: string | string[];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export class Start implements Command {
|
|
@@ -60,6 +61,9 @@ export class Start implements Command {
|
|
|
60
61
|
'--watch',
|
|
61
62
|
this.args.config ? `--config "${this.args.config}"` : undefined,
|
|
62
63
|
this.args.esbuild ? '--esbuild' : undefined,
|
|
64
|
+
this.args['experimental-bundlers']
|
|
65
|
+
? '--experimental-bundlers'
|
|
66
|
+
: undefined,
|
|
63
67
|
].filter(item => item),
|
|
64
68
|
}),
|
|
65
69
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import webpack from 'webpack';
|
|
4
4
|
import WebpackDevServer from 'webpack-dev-server';
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
webpackProdConfigFileName,
|
|
14
14
|
} from '../bundle';
|
|
15
15
|
|
|
16
|
+
jest.mock('fs', () => fs);
|
|
16
17
|
jest.mock('webpack', () => jest.fn());
|
|
17
18
|
jest.mock('webpack-dev-server');
|
|
18
19
|
jest.mock('../../../utils', () => ({
|
|
@@ -36,7 +37,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
36
37
|
compiler = { close: jest.fn(callback => callback()) };
|
|
37
38
|
});
|
|
38
39
|
|
|
39
|
-
afterEach(() =>
|
|
40
|
+
afterEach(() => vol.reset());
|
|
40
41
|
|
|
41
42
|
function expectPackageName() {
|
|
42
43
|
const name = pkg.name.replace(/\//g, '-').replace(/[^\w-]/g, '');
|
|
@@ -61,7 +62,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
61
62
|
let stdoutSpy: jest.SpyInstance;
|
|
62
63
|
|
|
63
64
|
beforeEach(() => {
|
|
64
|
-
|
|
65
|
+
vol.fromJSON(packageFS());
|
|
65
66
|
options = { buildStat: false };
|
|
66
67
|
stdoutSpy = jest.spyOn(process.stdout, 'write').mockImplementation(jest.fn());
|
|
67
68
|
compiler.run = jest.fn(callback => callback(null, stats as any));
|
|
@@ -138,14 +139,14 @@ describe('[startup] Cli Utils', () => {
|
|
|
138
139
|
describe(`with ${webpackProdConfigFileName} config`, () => {
|
|
139
140
|
const FS = { ...packageFS(), [webpackProdConfigFileName]: '' };
|
|
140
141
|
|
|
141
|
-
beforeEach(() =>
|
|
142
|
+
beforeEach(() => vol.fromJSON(FS));
|
|
142
143
|
|
|
143
144
|
itUsesConfig({ name: webpackProdConfigFileName, config: () => prodConfig });
|
|
144
145
|
|
|
145
146
|
describe('with custom config', () => {
|
|
146
147
|
beforeEach(() => {
|
|
147
148
|
options = { config: customConfigFileName };
|
|
148
|
-
|
|
149
|
+
vol.fromJSON({ ...FS, [customConfigFileName]: '' });
|
|
149
150
|
});
|
|
150
151
|
|
|
151
152
|
itUsesConfig({ name: 'custom config', config: () => customConfig });
|
|
@@ -165,7 +166,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
165
166
|
const sharedDependencies = { react: 'SharedDependencies.React' };
|
|
166
167
|
|
|
167
168
|
beforeEach(() => {
|
|
168
|
-
|
|
169
|
+
vol.fromJSON(webComponentFS());
|
|
169
170
|
jest.mocked(getFolders).mockReturnValue({ source, destination });
|
|
170
171
|
jest.mocked(getPackageData).mockReturnValue({ dependencies });
|
|
171
172
|
jest.mocked(loadSharedDependencies).mockReturnValue(sharedDependencies);
|
|
@@ -210,14 +211,14 @@ describe('[startup] Cli Utils', () => {
|
|
|
210
211
|
describe(`with ${webpackProdConfigFileName} config`, () => {
|
|
211
212
|
const FS = { ...webComponentFS(), [webpackProdConfigFileName]: '' };
|
|
212
213
|
|
|
213
|
-
beforeEach(() =>
|
|
214
|
+
beforeEach(() => vol.fromJSON(FS));
|
|
214
215
|
|
|
215
216
|
itUsesConfig({ name: webpackProdConfigFileName, config: () => prodConfig });
|
|
216
217
|
|
|
217
218
|
describe('with custom config', () => {
|
|
218
219
|
beforeEach(() => {
|
|
219
220
|
options = { config: customConfigFileName };
|
|
220
|
-
|
|
221
|
+
vol.fromJSON({ ...FS, [customConfigFileName]: '' });
|
|
221
222
|
});
|
|
222
223
|
|
|
223
224
|
itUsesConfig({ name: 'custom config', config: () => customConfig });
|
|
@@ -252,7 +253,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
252
253
|
|
|
253
254
|
beforeEach(() => {
|
|
254
255
|
options = undefined;
|
|
255
|
-
|
|
256
|
+
vol.fromJSON(packageFS());
|
|
256
257
|
jest.mocked(WebpackDevServer).mockImplementation((): any => ({
|
|
257
258
|
listen: jest.fn((_0: number, _1: string, callback?: (error?: Error) => void) =>
|
|
258
259
|
stopWatching(callback)
|
|
@@ -297,14 +298,14 @@ describe('[startup] Cli Utils', () => {
|
|
|
297
298
|
describe(`with ${webpackDevConfigFileName} config`, () => {
|
|
298
299
|
const FS = { ...packageFS(), [webpackDevConfigFileName]: '' };
|
|
299
300
|
|
|
300
|
-
beforeEach(() =>
|
|
301
|
+
beforeEach(() => vol.fromJSON(FS));
|
|
301
302
|
|
|
302
303
|
itUsesConfig({ name: webpackDevConfigFileName, config: () => devConfig });
|
|
303
304
|
|
|
304
305
|
describe('with custom config', () => {
|
|
305
306
|
beforeEach(() => {
|
|
306
307
|
options = { config: customConfigFileName };
|
|
307
|
-
|
|
308
|
+
vol.fromJSON({ ...FS, [customConfigFileName]: '' });
|
|
308
309
|
});
|
|
309
310
|
|
|
310
311
|
itUsesConfig({ name: 'custom config', config: () => customConfig });
|
|
@@ -324,7 +325,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
324
325
|
const sharedDependencies = { react: 'SharedDependencies.React' };
|
|
325
326
|
|
|
326
327
|
beforeEach(() => {
|
|
327
|
-
|
|
328
|
+
vol.fromJSON(webComponentFS());
|
|
328
329
|
jest.mocked(getFolders).mockReturnValue({ source, destination });
|
|
329
330
|
jest.mocked(getPackageData).mockReturnValue({ dependencies });
|
|
330
331
|
jest.mocked(loadSharedDependencies).mockReturnValue(sharedDependencies);
|
|
@@ -368,14 +369,14 @@ describe('[startup] Cli Utils', () => {
|
|
|
368
369
|
describe(`with ${webpackDevConfigFileName} config`, () => {
|
|
369
370
|
const FS = { ...webComponentFS(), [webpackDevConfigFileName]: '' };
|
|
370
371
|
|
|
371
|
-
beforeEach(() =>
|
|
372
|
+
beforeEach(() => vol.fromJSON(FS));
|
|
372
373
|
|
|
373
374
|
itUsesConfig({ name: webpackDevConfigFileName, config: () => devConfig });
|
|
374
375
|
|
|
375
376
|
describe('with custom config', () => {
|
|
376
377
|
beforeEach(() => {
|
|
377
378
|
options = { config: customConfigFileName };
|
|
378
|
-
|
|
379
|
+
vol.fromJSON({ ...FS, [customConfigFileName]: '' });
|
|
379
380
|
});
|
|
380
381
|
|
|
381
382
|
itUsesConfig({ name: 'custom config', config: () => customConfig });
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import { ESLint } from 'eslint';
|
|
3
3
|
|
|
4
4
|
import { eslint } from '../eslint';
|
|
5
5
|
|
|
6
|
+
jest.mock('fs', () => fs);
|
|
6
7
|
jest.mock('eslint');
|
|
8
|
+
jest.mock('../../../utils/get-destination-folders', () => ({
|
|
9
|
+
getDestinationFolders: () => [],
|
|
10
|
+
}));
|
|
7
11
|
|
|
8
12
|
describe(`[startup] utils:${eslint.name}`, () => {
|
|
9
13
|
const mockResult = { filePath: 'foo' } as ESLint.LintResult;
|
|
@@ -13,7 +17,11 @@ describe(`[startup] utils:${eslint.name}`, () => {
|
|
|
13
17
|
let eslintResults: ESLint.LintResult[];
|
|
14
18
|
let eslintErrors: ESLint.LintResult[];
|
|
15
19
|
|
|
16
|
-
beforeEach(() =>
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.resetAllMocks();
|
|
22
|
+
vol.fromJSON({ 'package.json': JSON.stringify({}) });
|
|
23
|
+
});
|
|
24
|
+
afterEach(() => vol.reset());
|
|
17
25
|
|
|
18
26
|
beforeEach(() => {
|
|
19
27
|
mockESLint = {
|
|
@@ -79,8 +87,7 @@ describe(`[startup] utils:${eslint.name}`, () => {
|
|
|
79
87
|
cli: { lint: { eslint: { disabled: true } } },
|
|
80
88
|
});
|
|
81
89
|
|
|
82
|
-
beforeEach(() =>
|
|
83
|
-
afterEach(() => mockFS.restore());
|
|
90
|
+
beforeEach(() => vol.fromJSON({ 'package.json': config }));
|
|
84
91
|
|
|
85
92
|
test('does nothing', async () => {
|
|
86
93
|
await subject();
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fs, vol } from 'memfs';
|
|
2
2
|
import { getModuleType } from '../get-module-type';
|
|
3
3
|
|
|
4
|
+
jest.mock('fs', () => fs);
|
|
5
|
+
|
|
4
6
|
describe('[startup] Cli Utils', () => {
|
|
5
7
|
describe(`${getModuleType.name}`, () => {
|
|
6
8
|
const tsconfig = 'tsconfig.json';
|
|
7
9
|
|
|
8
|
-
beforeEach(() =>
|
|
10
|
+
beforeEach(() => vol.fromJSON({ [tsconfig]: JSON.stringify({}) }));
|
|
9
11
|
|
|
10
|
-
afterEach(() =>
|
|
12
|
+
afterEach(() => vol.reset());
|
|
11
13
|
|
|
12
14
|
const subject = (configPath?: string) => getModuleType(configPath ?? `./${tsconfig}`);
|
|
13
15
|
|
|
@@ -19,7 +21,7 @@ describe('[startup] Cli Utils', () => {
|
|
|
19
21
|
const module = 'foo';
|
|
20
22
|
|
|
21
23
|
beforeEach(() => {
|
|
22
|
-
|
|
24
|
+
vol.fromJSON({ [tsconfig]: JSON.stringify({ compilerOptions: { module } }) });
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
test('returns configured module', () => {
|
|
@@ -31,20 +33,13 @@ describe('[startup] Cli Utils', () => {
|
|
|
31
33
|
const module = 'bar';
|
|
32
34
|
|
|
33
35
|
beforeEach(() => {
|
|
34
|
-
|
|
36
|
+
vol.fromJSON({
|
|
35
37
|
'tsconfig.json': JSON.stringify({
|
|
36
38
|
extends: '@servicetitan/startup/tsconfig/base',
|
|
37
39
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
startup: {
|
|
42
|
-
tsconfig: {
|
|
43
|
-
'base.json': JSON.stringify({ compilerOptions: { module } }),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
40
|
+
'packages/startup/tsconfig/base.json': JSON.stringify({
|
|
41
|
+
compilerOptions: { module },
|
|
42
|
+
}),
|
|
48
43
|
});
|
|
49
44
|
});
|
|
50
45
|
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import mockFS from 'mock-fs';
|
|
2
|
-
|
|
3
1
|
import { isModuleInstalled } from '../is-module-installed';
|
|
4
2
|
|
|
5
3
|
describe(`[startup] Cli Utils`, () => {
|
|
6
4
|
describe(`${isModuleInstalled.name}`, () => {
|
|
7
|
-
afterEach(() => mockFS.restore());
|
|
8
|
-
|
|
9
5
|
const subject = (name: string) => isModuleInstalled(name);
|
|
10
6
|
|
|
11
7
|
test('returns false', () => {
|
|
@@ -13,11 +9,14 @@ describe(`[startup] Cli Utils`, () => {
|
|
|
13
9
|
});
|
|
14
10
|
|
|
15
11
|
describe('when module exists', () => {
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
/*
|
|
13
|
+
* Have to choose a module that really exists, because we are unable
|
|
14
|
+
* to mock require.resolve()
|
|
15
|
+
*/
|
|
16
|
+
const moduleName = 'fs';
|
|
18
17
|
|
|
19
18
|
test('returns true', () => {
|
|
20
|
-
expect(subject(
|
|
19
|
+
expect(subject(moduleName)).toBe(true);
|
|
21
20
|
});
|
|
22
21
|
});
|
|
23
22
|
});
|