@servicetitan/startup 28.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"tcm.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/tcm.ts"],"names":[],"mappings":"AA0DA,wBAAsB,GAAG,kBAIxB;AAED,wBAAsB,QAAQ,kBAE7B"}
1
+ {"version":3,"file":"tcm.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/tcm.ts"],"names":[],"mappings":"AAmEA,wBAAsB,GAAG,kBAIxB;AAED,wBAAsB,QAAQ,kBAE7B"}
@@ -19,8 +19,8 @@ async function compile(filePath) {
19
19
  }
20
20
  }
21
21
  async function run({ watch } = {}) {
22
- const { source } = (0, utils_1.getFolders)();
23
- const filesPattern = `${source}/**/*.module.{${_1.styleExtensions.join()}}`.replace(/\\/g, '/');
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
- else {
43
- utils_1.log.info('Watch ' + filesPattern + '...');
44
- const watcher = chokidar_1.default.watch([filesPattern], { ignoreInitial: true });
45
- watcher.on('add', writeFile);
46
- watcher.on('change', writeFile);
47
- if (process.env.NODE_ENV !== 'test') {
48
- await new Promise(() => { });
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":";;;;;AA0DA,kBAIC;AAED,4BAEC;AAlED,+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,EAAE,MAAM,EAAE,GAAG,IAAA,kBAAU,GAAE,CAAC;IAEhC,MAAM,YAAY,GAAG,GAAG,MAAM,iBAAiB,kBAAe,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE7F,MAAM,OAAO,GAAG,IAAI,2BAAU,CAAC;QAC3B,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;KACrB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,KAAK,EAAE,QAAgB,EAAE,EAAE;QACzC,IAAI,CAAC;YACD,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChD,MAAM,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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.2.0",
3
+ "version": "28.3.1",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/startup",
6
6
  "repository": {
@@ -32,18 +32,18 @@
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.2.0",
36
- "@servicetitan/stylelint-config": "28.2.0",
35
+ "@servicetitan/eslint-config": "28.3.1",
36
+ "@servicetitan/stylelint-config": "28.3.1",
37
37
  "@svgr/webpack": "^8.1.0",
38
- "@swc/core": "1.9.3",
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": "~3.6.0",
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",
46
- "debug": "^4.3.7",
46
+ "debug": "^4.4.0",
47
47
  "deepmerge": "~4.3.1",
48
48
  "esbuild-loader": "~4.2.2",
49
49
  "eslint": "~8.57.0",
@@ -61,32 +61,32 @@
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.14.0",
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",
68
68
  "multimatch": "~5.0.0",
69
69
  "portfinder": "~1.0.32",
70
70
  "postcss": "~8.4.49",
71
- "prettier": "~3.4.1",
72
- "sass": "~1.81.0",
73
- "sass-loader": "~16.0.3",
71
+ "prettier": "~3.4.2",
72
+ "sass": "~1.83.0",
73
+ "sass-loader": "~16.0.4",
74
74
  "source-map-loader": "~5.0.0",
75
75
  "string-width": "<5.0.0",
76
76
  "style-loader": "~4.0.0",
77
- "stylelint": "~16.11.0",
77
+ "stylelint": "~16.12.0",
78
78
  "swc-loader": "0.2.6",
79
- "terser-webpack-plugin": "^5.3.10",
79
+ "terser-webpack-plugin": "^5.3.11",
80
80
  "ts-jest": "29.2.5",
81
81
  "ts-loader": "~9.5.1",
82
82
  "ts-node": "~10.9.2",
83
83
  "typed-css-modules": "~0.9.1",
84
84
  "typescript": "5.7.2",
85
85
  "username": "~5.1.0",
86
- "webpack": "~5.96.1",
86
+ "webpack": "~5.97.1",
87
87
  "webpack-assets-manifest": "~5.2.1",
88
88
  "webpack-bundle-analyzer": "^4.10.2",
89
- "webpack-dev-server": "~5.1.0",
89
+ "webpack-dev-server": "~5.2.0",
90
90
  "webpack-filter-warnings-plugin": "~1.2.1",
91
91
  "webpack-merge": "~6.0.1",
92
92
  "webpack-virtual-modules": "~0.6.2",
@@ -104,5 +104,5 @@
104
104
  "cli": {
105
105
  "webpack": false
106
106
  },
107
- "gitHead": "df48bdf4994bce3971c7e4f099eeb11ebb4945e6"
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
- [`${source}/**/*.module.{${styleExtensions.join()}}`],
100
- { ignoreInitial: true }
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
 
@@ -20,9 +20,8 @@ async function compile(filePath: string) {
20
20
  }
21
21
 
22
22
  async function run({ watch }: RunOptions = {}) {
23
- const { source } = getFolders();
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
- } else {
47
- log.info('Watch ' + filesPattern + '...');
44
+ return;
45
+ }
48
46
 
49
- const watcher = chokidar.watch([filesPattern], { ignoreInitial: true });
50
- watcher.on('add', writeFile);
51
- watcher.on('change', writeFile);
47
+ log.info('Watch ' + filesPattern + '...');
52
48
 
53
- if (process.env.NODE_ENV !== 'test') {
54
- await new Promise<void>(() => {});
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