@servicetitan/startup 28.3.0 → 28.3.1
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/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 +6 -6
- package/src/cli/utils/__tests__/tcm.test.ts +56 -10
- package/src/cli/utils/tcm.ts +21 -12
|
@@ -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,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAA,cAAW,EAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAA,cAAW,EAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,GAAG,CAAC,EAAE,KAAK,KAAiB,EAAE;IACzC,MAAM,MAAM,GAAG,IAAA,kBAAU,GAAE,CAAC,MAAM,CAA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,EAAE,CAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;QACtE,aAAa,EAAE,IAAI;KACtB,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;QACpC,WAAG,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,IAAI,EAAE,CAAC,CAAC;QACtC,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE/B,4DAA4D;IAC5D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QAClC,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACtC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,GAAG;IACrB,WAAG,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;IAExE,MAAM,GAAG,EAAE,CAAC;AAChB,CAAC;AAEM,KAAK,UAAU,QAAQ;IAC1B,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "28.3.
|
|
3
|
+
"version": "28.3.1",
|
|
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.1",
|
|
36
|
+
"@servicetitan/stylelint-config": "28.3.1",
|
|
37
37
|
"@svgr/webpack": "^8.1.0",
|
|
38
38
|
"@swc/core": "1.10.1",
|
|
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.1",
|
|
65
65
|
"mini-css-extract-plugin": "~2.9.2",
|
|
66
66
|
"moment": "^2.30.1",
|
|
67
67
|
"moment-locales-webpack-plugin": "~1.2.0",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"cli": {
|
|
105
105
|
"webpack": false
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "475386c1ac1891c3e585a2ce694472ad3a1353e8"
|
|
108
108
|
}
|
|
@@ -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/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
|
|