@servicetitan/startup 28.3.0 → 28.3.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/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +4 -1
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/tcm.d.ts.map +1 -1
- package/dist/cli/utils/tcm.js +18 -10
- package/dist/cli/utils/tcm.js.map +1 -1
- package/package.json +7 -9
- package/src/cli/utils/__tests__/cli-os.test.ts +7 -3
- package/src/cli/utils/__tests__/tcm.test.ts +56 -10
- package/src/cli/utils/cli-os.ts +4 -1
- package/src/cli/utils/tcm.ts +21 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-os.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/cli-os.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,iCAAiC,EAEjC,wBAAwB,EAC3B,MAAM,eAAe,CAAC;AAGvB,KAAK,iBAAiB,GAAG,wBAAwB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAExE,eAAO,MAAM,UAAU,YACV,MAAM,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,+BACR,iBAAiB,KAC9C,OAAO,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"cli-os.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/cli-os.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,iCAAiC,EAEjC,wBAAwB,EAC3B,MAAM,eAAe,CAAC;AAGvB,KAAK,iBAAiB,GAAG,wBAAwB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAExE,eAAO,MAAM,UAAU,YACV,MAAM,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,+BACR,iBAAiB,KAC9C,OAAO,CAAC,IAAI,CA2Cd,CAAC;AAEF,KAAK,uBAAuB,GAAG,iCAAiC,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvF,eAAO,MAAM,gBAAgB,YAChB,MAAM,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,kCACL,uBAAuB,KACvD,MA2BF,CAAC"}
|
package/dist/cli/utils/cli-os.js
CHANGED
|
@@ -21,7 +21,10 @@ const runCommand = (command, { quiet, ...spawnOptions } = {}) => {
|
|
|
21
21
|
if (!quiet) {
|
|
22
22
|
utils_1.log.info(`run command ${fullCommand}`);
|
|
23
23
|
}
|
|
24
|
-
const proc = (0, child_process_1.spawn)(commandName, commandArray,
|
|
24
|
+
const proc = (0, child_process_1.spawn)(commandName, commandArray, {
|
|
25
|
+
shell: process.platform === 'win32',
|
|
26
|
+
...spawnOptions,
|
|
27
|
+
});
|
|
25
28
|
proc.stdout.pipe(process.stdout);
|
|
26
29
|
proc.stderr.pipe(process.stderr);
|
|
27
30
|
proc.on('exit', function (code) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-os.js","sourceRoot":"","sources":["../../../src/cli/utils/cli-os.ts"],"names":[],"mappings":";;;AAAA,iDAKuB;AACvB,uCAAkC;AAI3B,MAAM,UAAU,GAAG,CACtB,OAAoC,EACpC,EAAE,KAAK,EAAE,GAAG,YAAY,KAAwB,EAAE,EACrC,EAAE;IACf,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,YAAY,GAAa,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YACjD,CAAC,CAAC,OAAO;iBACF,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;iBAChB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;iBACtB,IAAI,CAAC,GAAG,CAAC;iBACT,KAAK,CAAC,GAAG,CAAC;YACjB,CAAC,CAAC,OAAO,CAAC,KAAK,CAA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,CAAC,CAAC;IACzB,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE3C,MAAM,WAAW,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC;IAEzC,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,WAAG,CAAC,IAAI,CAAC,eAAe,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC;IAEjE,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,WAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AA9BW,QAAA,gBAAgB,oBA8B3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcm.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/tcm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tcm.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/tcm.ts"],"names":[],"mappings":"AAmEA,wBAAsB,GAAG,kBAIxB;AAED,wBAAsB,QAAQ,kBAE7B"}
|
package/dist/cli/utils/tcm.js
CHANGED
|
@@ -19,8 +19,8 @@ async function compile(filePath) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
async function run({ watch } = {}) {
|
|
22
|
-
const
|
|
23
|
-
const filesPattern = `${source}/**/*.module.{${_1.styleExtensions.join()}}
|
|
22
|
+
const source = (0, utils_1.getFolders)().source.replace(/\\/g, '/');
|
|
23
|
+
const filesPattern = `${source}/**/*.module.{${_1.styleExtensions.join()}}`;
|
|
24
24
|
const creator = new typed_css_modules_1.default({
|
|
25
25
|
camelCase: true,
|
|
26
26
|
namedExports: true,
|
|
@@ -38,15 +38,23 @@ async function run({ watch } = {}) {
|
|
|
38
38
|
if (!watch) {
|
|
39
39
|
const files = await (0, glob_1.glob)(filesPattern);
|
|
40
40
|
await Promise.all(files.map(writeFile));
|
|
41
|
+
return;
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
43
|
+
utils_1.log.info('Watch ' + filesPattern + '...');
|
|
44
|
+
const stylesRegex = new RegExp(`\\.module\\.(${_1.styleExtensions.join('|')})$`);
|
|
45
|
+
const watcher = chokidar_1.default.watch(source, {
|
|
46
|
+
ignored: (path, stats) => !!(stats === null || stats === void 0 ? void 0 : stats.isFile()) && !stylesRegex.test(path),
|
|
47
|
+
ignoreInitial: true,
|
|
48
|
+
});
|
|
49
|
+
const callback = async (path) => {
|
|
50
|
+
utils_1.log.debug('tcm', `Compiling ${path}`);
|
|
51
|
+
await writeFile(path);
|
|
52
|
+
};
|
|
53
|
+
watcher.on('add', callback);
|
|
54
|
+
watcher.on('change', callback);
|
|
55
|
+
/* istanbul ignore next: not executed in test environment */
|
|
56
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
57
|
+
await new Promise(() => { });
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
async function tcm() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcm.js","sourceRoot":"","sources":["../../../src/cli/utils/tcm.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"tcm.js","sourceRoot":"","sources":["../../../src/cli/utils/tcm.ts"],"names":[],"mappings":";;;;;AAmEA,kBAIC;AAED,4BAEC;AA3ED,+BAA4B;AAC5B,wDAAgC;AAEhC,0EAA2C;AAE3C,uCAA8C;AAC9C,wBAA8D;AAM9D,KAAK,UAAU,OAAO,CAAC,QAAgB;IACnC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAA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|
-
"version": "28.3.
|
|
3
|
+
"version": "28.3.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/startup",
|
|
6
6
|
"repository": {
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@jest/core": "~29.7.0",
|
|
33
33
|
"@jest/types": "~29.6.3",
|
|
34
34
|
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
35
|
-
"@servicetitan/eslint-config": "28.3.
|
|
36
|
-
"@servicetitan/stylelint-config": "28.3.
|
|
35
|
+
"@servicetitan/eslint-config": "28.3.2",
|
|
36
|
+
"@servicetitan/stylelint-config": "28.3.2",
|
|
37
37
|
"@svgr/webpack": "^8.1.0",
|
|
38
|
-
"@swc/core": "1.10.
|
|
38
|
+
"@swc/core": "1.10.4",
|
|
39
39
|
"@types/debug": "^4.1.12",
|
|
40
40
|
"@types/jest": "~29.5.12",
|
|
41
41
|
"chalk": "~4.1.2",
|
|
42
|
-
"chokidar": "~
|
|
42
|
+
"chokidar": "~4.0.3",
|
|
43
43
|
"cpx2": "7.0.1",
|
|
44
44
|
"css-loader": "~7.1.2",
|
|
45
45
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"less-loader": "~12.2.0",
|
|
62
62
|
"less-plugin-npm-import": "~2.1.0",
|
|
63
63
|
"lodash.memoize": "^4.1.2",
|
|
64
|
-
"memfs": "~4.15.
|
|
64
|
+
"memfs": "~4.15.3",
|
|
65
65
|
"mini-css-extract-plugin": "~2.9.2",
|
|
66
66
|
"moment": "^2.30.1",
|
|
67
67
|
"moment-locales-webpack-plugin": "~1.2.0",
|
|
@@ -72,7 +72,6 @@
|
|
|
72
72
|
"sass": "~1.83.0",
|
|
73
73
|
"sass-loader": "~16.0.4",
|
|
74
74
|
"source-map-loader": "~5.0.0",
|
|
75
|
-
"string-width": "<5.0.0",
|
|
76
75
|
"style-loader": "~4.0.0",
|
|
77
76
|
"stylelint": "~16.12.0",
|
|
78
77
|
"swc-loader": "0.2.6",
|
|
@@ -95,7 +94,6 @@
|
|
|
95
94
|
"yargs": "~17.7.2"
|
|
96
95
|
},
|
|
97
96
|
"DEVELOPER_NOTES": {
|
|
98
|
-
"string-width": "Fixes lerna issue when running build. Can be removed when lerna adds string-width as a direct dependency.",
|
|
99
97
|
"cpx2": "Must use 7.0.1 because later versions require glob 11.x which does not support Node 18"
|
|
100
98
|
},
|
|
101
99
|
"publishConfig": {
|
|
@@ -104,5 +102,5 @@
|
|
|
104
102
|
"cli": {
|
|
105
103
|
"webpack": false
|
|
106
104
|
},
|
|
107
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "5d08d5e03bad6ad8aed0a1b0c92952b3b29a930b"
|
|
108
106
|
}
|
|
@@ -8,6 +8,7 @@ jest.mock('../../../utils', () => ({ log: { info: jest.fn() } })); // suppress l
|
|
|
8
8
|
|
|
9
9
|
describe('[startup] Cli Utils (OS)', () => {
|
|
10
10
|
describe(`${runCommand.name}`, () => {
|
|
11
|
+
const defaultSpawnOptions = { shell: process.platform === 'win32' };
|
|
11
12
|
let exitCode: number;
|
|
12
13
|
let childProcess: ReturnType<typeof spawn>;
|
|
13
14
|
|
|
@@ -27,19 +28,22 @@ describe('[startup] Cli Utils (OS)', () => {
|
|
|
27
28
|
test('runs command', () => {
|
|
28
29
|
expect(subject('foo bar')).resolves.toBe(undefined);
|
|
29
30
|
|
|
30
|
-
expect(spawn).toHaveBeenCalledWith('foo', ['bar'],
|
|
31
|
+
expect(spawn).toHaveBeenCalledWith('foo', ['bar'], defaultSpawnOptions);
|
|
31
32
|
});
|
|
32
33
|
|
|
33
34
|
test('runs command with options', async () => {
|
|
34
35
|
await subject('foo', { timeout: 10000 });
|
|
35
36
|
|
|
36
|
-
expect(spawn).toHaveBeenCalledWith('foo', [], {
|
|
37
|
+
expect(spawn).toHaveBeenCalledWith('foo', [], {
|
|
38
|
+
...defaultSpawnOptions,
|
|
39
|
+
timeout: 10000,
|
|
40
|
+
});
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
test('runs command array', async () => {
|
|
40
44
|
await subject(['foo', 'bar', '--baz']);
|
|
41
45
|
|
|
42
|
-
expect(spawn).toHaveBeenCalledWith('foo', ['bar', '--baz'],
|
|
46
|
+
expect(spawn).toHaveBeenCalledWith('foo', ['bar', '--baz'], defaultSpawnOptions);
|
|
43
47
|
});
|
|
44
48
|
|
|
45
49
|
test("pipes stdout and stderr to parent's streams", async () => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @jest-environment node
|
|
3
3
|
*/
|
|
4
4
|
import chokidar from 'chokidar';
|
|
5
|
-
import fs from 'fs';
|
|
5
|
+
import fs, { Stats } from 'fs';
|
|
6
6
|
|
|
7
7
|
import { getFolders, log } from '../../../utils';
|
|
8
8
|
import * as sassModule from '../compile-sass';
|
|
@@ -13,7 +13,7 @@ import { tcm, tcmWatch } from '../tcm';
|
|
|
13
13
|
jest.mock('../../../utils', () => ({
|
|
14
14
|
...jest.requireActual('../../../utils'),
|
|
15
15
|
getFolders: jest.fn(),
|
|
16
|
-
log: { error: jest.fn(), info: jest.fn() }, // suppress test output
|
|
16
|
+
log: { debug: jest.fn(), error: jest.fn(), info: jest.fn() }, // suppress test output
|
|
17
17
|
}));
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -80,10 +80,6 @@ describe('[startup] Cli Utils', () => {
|
|
|
80
80
|
let watchSpy: jest.SpyInstance;
|
|
81
81
|
let fsWatcher: Partial<ReturnType<typeof chokidar.watch>>;
|
|
82
82
|
|
|
83
|
-
beforeAll(() => {
|
|
84
|
-
process.env.NODE_ENV ??= 'test'; // workaround issue with Jest not setting NODE_ENV=test
|
|
85
|
-
});
|
|
86
|
-
|
|
87
83
|
beforeEach(() => {
|
|
88
84
|
fsWatcher = { on: jest.fn() };
|
|
89
85
|
watchSpy = jest.spyOn(chokidar, 'watch').mockReturnValue(fsWatcher as any);
|
|
@@ -95,10 +91,10 @@ describe('[startup] Cli Utils', () => {
|
|
|
95
91
|
test('watches for new and changed style modules', async () => {
|
|
96
92
|
await subject();
|
|
97
93
|
|
|
98
|
-
expect(watchSpy).toHaveBeenCalledWith(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
94
|
+
expect(watchSpy).toHaveBeenCalledWith(source, {
|
|
95
|
+
ignored: expect.any(Function),
|
|
96
|
+
ignoreInitial: true,
|
|
97
|
+
});
|
|
102
98
|
expect(fsWatcher.on).toHaveBeenCalledWith('add', expect.any(Function));
|
|
103
99
|
expect(fsWatcher.on).toHaveBeenCalledWith('change', expect.any(Function));
|
|
104
100
|
});
|
|
@@ -108,6 +104,56 @@ describe('[startup] Cli Utils', () => {
|
|
|
108
104
|
return calls.find(([event]) => event === name)![1] as Listener;
|
|
109
105
|
}
|
|
110
106
|
|
|
107
|
+
describe('"ignored" filter', () => {
|
|
108
|
+
const styleExtensions = ['.module.css', '.module.scss', '.module.less'];
|
|
109
|
+
let ignored: (path: string, stats?: Partial<Stats>) => boolean;
|
|
110
|
+
let filePath: string;
|
|
111
|
+
let stats: Partial<Stats> | undefined;
|
|
112
|
+
|
|
113
|
+
beforeEach(async () => {
|
|
114
|
+
await tcmWatch();
|
|
115
|
+
const { calls } = watchSpy.mock;
|
|
116
|
+
ignored = calls[0][1].ignored;
|
|
117
|
+
stats = { isFile: () => true };
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const subject = () => ignored(filePath, stats);
|
|
121
|
+
|
|
122
|
+
function itReturns(value: boolean) {
|
|
123
|
+
test(`returns ${value}`, () => expect(subject()).toBe(value));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
describe.each(styleExtensions)('when path ends with %s', ext => {
|
|
127
|
+
beforeEach(() => (filePath = `foo${ext}`));
|
|
128
|
+
|
|
129
|
+
itReturns(false);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe.each(styleExtensions)('when path contains %s', ext => {
|
|
133
|
+
beforeEach(() => (filePath = `foo${ext}.d.ts`));
|
|
134
|
+
|
|
135
|
+
itReturns(true);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe.each(['', '.scss', '.tsx'])('when path ends with "%s"', ext => {
|
|
139
|
+
beforeEach(() => (filePath = `foo${ext}`));
|
|
140
|
+
|
|
141
|
+
itReturns(true);
|
|
142
|
+
|
|
143
|
+
describe('when stats is undefined', () => {
|
|
144
|
+
beforeEach(() => (stats = undefined));
|
|
145
|
+
|
|
146
|
+
itReturns(false);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe('when stats.isFile returns false', () => {
|
|
150
|
+
beforeEach(() => (stats = { isFile: () => false }));
|
|
151
|
+
|
|
152
|
+
itReturns(false);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
111
157
|
describe('when module is added', () => {
|
|
112
158
|
const module = 'bar.module.scss';
|
|
113
159
|
|
package/src/cli/utils/cli-os.ts
CHANGED
|
@@ -34,7 +34,10 @@ export const runCommand = (
|
|
|
34
34
|
log.info(`run command ${fullCommand}`);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const proc = spawn(commandName, commandArray,
|
|
37
|
+
const proc = spawn(commandName, commandArray, {
|
|
38
|
+
shell: process.platform === 'win32',
|
|
39
|
+
...spawnOptions,
|
|
40
|
+
});
|
|
38
41
|
|
|
39
42
|
proc.stdout.pipe(process.stdout);
|
|
40
43
|
proc.stderr.pipe(process.stderr);
|
package/src/cli/utils/tcm.ts
CHANGED
|
@@ -20,9 +20,8 @@ async function compile(filePath: string) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async function run({ watch }: RunOptions = {}) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const filesPattern = `${source}/**/*.module.{${styleExtensions.join()}}`.replace(/\\/g, '/');
|
|
23
|
+
const source = getFolders().source.replace(/\\/g, '/');
|
|
24
|
+
const filesPattern = `${source}/**/*.module.{${styleExtensions.join()}}`;
|
|
26
25
|
|
|
27
26
|
const creator = new DtsCreator({
|
|
28
27
|
camelCase: true,
|
|
@@ -41,18 +40,28 @@ async function run({ watch }: RunOptions = {}) {
|
|
|
41
40
|
|
|
42
41
|
if (!watch) {
|
|
43
42
|
const files = await glob(filesPattern);
|
|
44
|
-
|
|
45
43
|
await Promise.all(files.map(writeFile));
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
watcher.on('add', writeFile);
|
|
51
|
-
watcher.on('change', writeFile);
|
|
47
|
+
log.info('Watch ' + filesPattern + '...');
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
const stylesRegex = new RegExp(`\\.module\\.(${styleExtensions.join('|')})$`);
|
|
50
|
+
const watcher = chokidar.watch(source, {
|
|
51
|
+
ignored: (path, stats) => !!stats?.isFile() && !stylesRegex.test(path),
|
|
52
|
+
ignoreInitial: true,
|
|
53
|
+
});
|
|
54
|
+
const callback = async (path: string) => {
|
|
55
|
+
log.debug('tcm', `Compiling ${path}`);
|
|
56
|
+
await writeFile(path);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
watcher.on('add', callback);
|
|
60
|
+
watcher.on('change', callback);
|
|
61
|
+
|
|
62
|
+
/* istanbul ignore next: not executed in test environment */
|
|
63
|
+
if (process.env.NODE_ENV !== 'test') {
|
|
64
|
+
await new Promise<void>(() => {});
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
|