@servicetitan/startup 23.6.0 → 24.0.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.
Files changed (157) hide show
  1. package/dist/cli/commands/build.d.ts.map +1 -1
  2. package/dist/cli/commands/build.js +4 -5
  3. package/dist/cli/commands/build.js.map +1 -1
  4. package/dist/cli/commands/bundle-package.js +1 -1
  5. package/dist/cli/commands/bundle-package.js.map +1 -1
  6. package/dist/cli/commands/eslint.js +1 -1
  7. package/dist/cli/commands/eslint.js.map +1 -1
  8. package/dist/cli/commands/init.js +2 -2
  9. package/dist/cli/commands/init.js.map +1 -1
  10. package/dist/cli/commands/install.js +1 -1
  11. package/dist/cli/commands/install.js.map +1 -1
  12. package/dist/cli/commands/kendo-ui-license.js +1 -1
  13. package/dist/cli/commands/kendo-ui-license.js.map +1 -1
  14. package/dist/cli/commands/lint.d.ts +1 -1
  15. package/dist/cli/commands/lint.d.ts.map +1 -1
  16. package/dist/cli/commands/lint.js +9 -11
  17. package/dist/cli/commands/lint.js.map +1 -1
  18. package/dist/cli/commands/mfe-publish.js +12 -9
  19. package/dist/cli/commands/mfe-publish.js.map +1 -1
  20. package/dist/cli/commands/prepare-package.js +1 -1
  21. package/dist/cli/commands/prepare-package.js.map +1 -1
  22. package/dist/cli/commands/start.d.ts.map +1 -1
  23. package/dist/cli/commands/start.js +5 -6
  24. package/dist/cli/commands/start.js.map +1 -1
  25. package/dist/cli/commands/styles-check.js.map +1 -1
  26. package/dist/cli/commands/tests.js +1 -1
  27. package/dist/cli/commands/tests.js.map +1 -1
  28. package/dist/cli/index.js.map +1 -1
  29. package/dist/cli/utils/bundle.js +7 -6
  30. package/dist/cli/utils/bundle.js.map +1 -1
  31. package/dist/cli/utils/cli-npm.js.map +1 -1
  32. package/dist/cli/utils/cli-os.d.ts +1 -0
  33. package/dist/cli/utils/cli-os.d.ts.map +1 -1
  34. package/dist/cli/utils/cli-os.js.map +1 -1
  35. package/dist/cli/utils/eslint.js +3 -3
  36. package/dist/cli/utils/eslint.js.map +1 -1
  37. package/dist/cli/utils/get-module-type.js.map +1 -1
  38. package/dist/cli/utils/index.d.ts +1 -0
  39. package/dist/cli/utils/index.d.ts.map +1 -1
  40. package/dist/cli/utils/index.js +1 -0
  41. package/dist/cli/utils/index.js.map +1 -1
  42. package/dist/cli/utils/is-module-installed.js.map +1 -1
  43. package/dist/cli/utils/lerna-exec.d.ts +11 -0
  44. package/dist/cli/utils/lerna-exec.d.ts.map +1 -0
  45. package/dist/cli/utils/lerna-exec.js +47 -0
  46. package/dist/cli/utils/lerna-exec.js.map +1 -0
  47. package/dist/cli/utils/publish.js.map +1 -1
  48. package/dist/cli/utils/set-node-options.js.map +1 -1
  49. package/dist/cli/utils/tcm.js +2 -2
  50. package/dist/cli/utils/tcm.js.map +1 -1
  51. package/dist/cli/utils/tsc.js +2 -2
  52. package/dist/cli/utils/tsc.js.map +1 -1
  53. package/dist/utils/get-configuration.d.ts +3 -3
  54. package/dist/utils/get-configuration.d.ts.map +1 -1
  55. package/dist/utils/get-configuration.js +1 -1
  56. package/dist/utils/get-configuration.js.map +1 -1
  57. package/dist/utils/get-destination-folders.js.map +1 -1
  58. package/dist/utils/get-folders.js.map +1 -1
  59. package/dist/utils/get-package-data.js.map +1 -1
  60. package/dist/utils/get-packages.js +1 -1
  61. package/dist/utils/get-packages.js.map +1 -1
  62. package/dist/utils/load-shared-dependencies.js.map +1 -1
  63. package/dist/utils/log.js.map +1 -1
  64. package/dist/utils/read-json.js.map +1 -1
  65. package/dist/utils/to-array.js.map +1 -1
  66. package/dist/webpack/__mocks__/style-rules.d.ts +1 -1
  67. package/dist/webpack/__mocks__/style-rules.d.ts.map +1 -1
  68. package/dist/webpack/__mocks__/style-rules.js.map +1 -1
  69. package/dist/webpack/configs/amd-config.d.ts +1 -1
  70. package/dist/webpack/configs/amd-config.d.ts.map +1 -1
  71. package/dist/webpack/configs/cache-config.d.ts +1 -1
  72. package/dist/webpack/configs/cache-config.d.ts.map +1 -1
  73. package/dist/webpack/configs/cache-config.js.map +1 -1
  74. package/dist/webpack/configs/dev-server-config.d.ts +1 -1
  75. package/dist/webpack/configs/dev-server-config.d.ts.map +1 -1
  76. package/dist/webpack/configs/dev-server-config.js.map +1 -1
  77. package/dist/webpack/configs/devtool-config.d.ts +1 -1
  78. package/dist/webpack/configs/devtool-config.d.ts.map +1 -1
  79. package/dist/webpack/configs/devtool-config.js.map +1 -1
  80. package/dist/webpack/configs/entry.config.d.ts +1 -1
  81. package/dist/webpack/configs/entry.config.d.ts.map +1 -1
  82. package/dist/webpack/configs/entry.config.js.map +1 -1
  83. package/dist/webpack/configs/externals-config.d.ts +1 -1
  84. package/dist/webpack/configs/externals-config.d.ts.map +1 -1
  85. package/dist/webpack/configs/externals-config.js.map +1 -1
  86. package/dist/webpack/configs/module-config.d.ts +1 -1
  87. package/dist/webpack/configs/module-config.d.ts.map +1 -1
  88. package/dist/webpack/configs/optimization-config.d.ts +1 -1
  89. package/dist/webpack/configs/optimization-config.d.ts.map +1 -1
  90. package/dist/webpack/configs/optimization-config.js.map +1 -1
  91. package/dist/webpack/configs/output-config.d.ts +1 -1
  92. package/dist/webpack/configs/output-config.d.ts.map +1 -1
  93. package/dist/webpack/configs/output-config.js.map +1 -1
  94. package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
  95. package/dist/webpack/configs/plugins/bundle-analyser-plugin.js.map +1 -1
  96. package/dist/webpack/configs/plugins/define-exposed-dependencies-plugin.js.map +1 -1
  97. package/dist/webpack/configs/plugins/define-web-component-name-plugin.js.map +1 -1
  98. package/dist/webpack/configs/plugins/filter-warnings-plugin.js.map +1 -1
  99. package/dist/webpack/configs/plugins/html-plugin.js.map +1 -1
  100. package/dist/webpack/configs/plugins/ignore-plugin/check-resource.js.map +1 -1
  101. package/dist/webpack/configs/plugins/mini-css-extract-plugin.js.map +1 -1
  102. package/dist/webpack/configs/plugins/provide-react-plugin.js.map +1 -1
  103. package/dist/webpack/configs/plugins/ts-checker-plugin.js.map +1 -1
  104. package/dist/webpack/configs/plugins/virtual-modules-plugin.js.map +1 -1
  105. package/dist/webpack/configs/plugins-config.d.ts +1 -1
  106. package/dist/webpack/configs/plugins-config.d.ts.map +1 -1
  107. package/dist/webpack/configs/resolve-config.d.ts +1 -1
  108. package/dist/webpack/configs/resolve-config.d.ts.map +1 -1
  109. package/dist/webpack/configs/rules/css-rules.js.map +1 -1
  110. package/dist/webpack/configs/rules/svg-rules.js +4 -4
  111. package/dist/webpack/configs/rules/svg-rules.js.map +1 -1
  112. package/dist/webpack/configs/rules/tsx-rules.js.map +1 -1
  113. package/dist/webpack/configs/rules-config.d.ts +1 -1
  114. package/dist/webpack/configs/rules-config.d.ts.map +1 -1
  115. package/dist/webpack/configs/rules-config.js.map +1 -1
  116. package/dist/webpack/configs/stats-config.d.ts +1 -1
  117. package/dist/webpack/configs/stats-config.d.ts.map +1 -1
  118. package/dist/webpack/configs/utils/generate-metadata.js.map +1 -1
  119. package/dist/webpack/create-webpack-config.js.map +1 -1
  120. package/dist/webpack/loaders/expose-loader/index.js.map +1 -1
  121. package/dist/webpack/loaders/expose-loader/runtime/get-global-this.js.map +1 -1
  122. package/dist/webpack/loaders/expose-loader/utils/contextify-request.js.map +1 -1
  123. package/dist/webpack/loaders/expose-loader/utils/stringify-request.js.map +1 -1
  124. package/dist/webpack/utils/bundle.js.map +1 -1
  125. package/dist/webpack/utils/feature-cohort.js.map +1 -1
  126. package/dist/webpack/utils/get-caller-filename.js.map +1 -1
  127. package/dist/webpack/utils/split-by-entry.js.map +1 -1
  128. package/dist/webpack/utils/testing/compile.js.map +1 -1
  129. package/dist/webpack/utils/testing/get-compiler.js.map +1 -1
  130. package/dist/webpack/utils/testing/get-module-source.js.map +1 -1
  131. package/dist/webpack/utils/testing/normalize-errors.js.map +1 -1
  132. package/dist/webpack/utils/testing/read-asset.js.map +1 -1
  133. package/package.json +19 -20
  134. package/src/cli/commands/__tests__/build.test.ts +10 -12
  135. package/src/cli/commands/__tests__/init.test.ts +1 -1
  136. package/src/cli/commands/__tests__/kendo-ui-license.test.ts +1 -3
  137. package/src/cli/commands/__tests__/lint.test.ts +5 -7
  138. package/src/cli/commands/__tests__/mfe-publish.test.ts +8 -8
  139. package/src/cli/commands/__tests__/start.test.ts +9 -11
  140. package/src/cli/commands/build.ts +4 -6
  141. package/src/cli/commands/lint.ts +10 -15
  142. package/src/cli/commands/mfe-publish.ts +4 -4
  143. package/src/cli/commands/start.ts +5 -7
  144. package/src/cli/utils/__tests__/bundle.test.ts +4 -4
  145. package/src/cli/utils/__tests__/cli-os.test.ts +1 -1
  146. package/src/cli/utils/__tests__/lerna-exec.test.ts +64 -0
  147. package/src/cli/utils/index.ts +1 -0
  148. package/src/cli/utils/lerna-exec.ts +37 -0
  149. package/src/utils/__tests__/get-configuration.test.ts +1 -1
  150. package/src/utils/__tests__/log.test.ts +3 -3
  151. package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +1 -1
  152. package/src/webpack/utils/testing/get-compiler.ts +1 -1
  153. package/template-react18/packages/application/package.json +3 -3
  154. package/template-react18/packages/feature-a/package.json +3 -3
  155. package/template-react18/packages/feature-b/package.json +3 -3
  156. package/template-react18/packages/feature-c/package.json +3 -3
  157. package/tsconfig/base.json +3 -1
@@ -1,18 +1,16 @@
1
- const exec = require('@lerna/exec');
2
1
  import { Package, PackageType, getPackages } from '../../../utils';
3
2
  import { createPackage } from '../../../__mocks__';
4
- import { tsc } from '../../utils';
3
+ import { lernaExec, tsc } from '../../utils';
5
4
  import { kendoUILicense } from '../kendo-ui-license';
6
5
 
7
6
  import { Build } from '../build';
8
7
 
9
- jest.mock('@lerna/exec', () => jest.fn());
10
8
  jest.mock('../../../utils', () => ({
11
9
  ...jest.requireActual('../../../utils'),
12
10
  getPackages: jest.fn(),
13
11
  }));
14
- jest.mock('../../utils', () => ({ tsc: jest.fn() }));
15
- jest.mock('../kendo-ui-license', () => ({ kendoUILicense: jest.fn() }));
12
+ jest.mock('../../utils');
13
+ jest.mock('../kendo-ui-license');
16
14
 
17
15
  describe(`[startup] ${Build.name}`, () => {
18
16
  let args: ConstructorParameters<typeof Build>[0];
@@ -31,7 +29,7 @@ describe(`[startup] ${Build.name}`, () => {
31
29
  test('prepares the package', async () => {
32
30
  await subject();
33
31
 
34
- expect(exec).toHaveBeenCalledWith({
32
+ expect(lernaExec).toHaveBeenCalledWith({
35
33
  cmd: 'startup prepare-package',
36
34
  scope: packages.map(({ name }) => name),
37
35
  stream: true,
@@ -65,7 +63,7 @@ describe(`[startup] ${Build.name}`, () => {
65
63
  test('bundles the package', async () => {
66
64
  await subject();
67
65
 
68
- expect(exec).toHaveBeenCalledWith({
66
+ expect(lernaExec).toHaveBeenCalledWith({
69
67
  'cmd': 'startup bundle-package',
70
68
  'scope': packages.map(({ name }) => name),
71
69
  'stream': true,
@@ -79,7 +77,7 @@ describe(`[startup] ${Build.name}`, () => {
79
77
  test('enables code-coverage', async () => {
80
78
  await subject();
81
79
 
82
- expect(exec).toHaveBeenCalledWith(
80
+ expect(lernaExec).toHaveBeenCalledWith(
83
81
  expect.objectContaining({
84
82
  '--': ['--code-coverage'],
85
83
  })
@@ -93,7 +91,7 @@ describe(`[startup] ${Build.name}`, () => {
93
91
  test('enables esbuild loader', async () => {
94
92
  await subject();
95
93
 
96
- expect(exec).toHaveBeenCalledWith(
94
+ expect(lernaExec).toHaveBeenCalledWith(
97
95
  expect.objectContaining({
98
96
  '--': ['--esbuild'],
99
97
  })
@@ -107,7 +105,7 @@ describe(`[startup] ${Build.name}`, () => {
107
105
  test('enables swc-loader', async () => {
108
106
  await subject();
109
107
 
110
- expect(exec).toHaveBeenCalledWith(
108
+ expect(lernaExec).toHaveBeenCalledWith(
111
109
  expect.objectContaining({
112
110
  '--': ['--experimental-bundlers'],
113
111
  })
@@ -121,7 +119,7 @@ describe(`[startup] ${Build.name}`, () => {
121
119
  test('generates build report', async () => {
122
120
  await subject();
123
121
 
124
- expect(exec).toHaveBeenCalledWith(
122
+ expect(lernaExec).toHaveBeenCalledWith(
125
123
  expect.objectContaining({
126
124
  '--': ['--stat'],
127
125
  })
@@ -135,7 +133,7 @@ describe(`[startup] ${Build.name}`, () => {
135
133
  test('uses specified config file', async () => {
136
134
  await subject();
137
135
 
138
- expect(exec).toHaveBeenCalledWith(
136
+ expect(lernaExec).toHaveBeenCalledWith(
139
137
  expect.objectContaining({ '--': [`--config "${args.config}"`] })
140
138
  );
141
139
  });
@@ -68,7 +68,7 @@ describe(`[startup] ${Init.name}`, () => {
68
68
  beforeEach(() => vol.fromJSON({ [args.output!]: '' }));
69
69
 
70
70
  test('raises error', async () => {
71
- await expect(subject()).rejects.toThrowError(/is not a directory/);
71
+ await expect(subject()).rejects.toThrow(/is not a directory/);
72
72
  });
73
73
  });
74
74
  });
@@ -75,9 +75,7 @@ describe(`${kendoUILicense.name}`, () => {
75
75
  beforeEach(() => (execa as any).mockRejectedValue({ exitCode }));
76
76
 
77
77
  test('throws error', async () => {
78
- await expect(subject()).rejects.toThrowError(
79
- `command failed with exit code ${exitCode}`
80
- );
78
+ await expect(subject()).rejects.toThrow(`command failed with exit code ${exitCode}`);
81
79
  });
82
80
  });
83
81
  });
@@ -1,13 +1,11 @@
1
- const lernaExec = require('@lerna/exec');
2
1
  import { Lint } from '../lint';
3
- import { eslint } from '../../utils';
2
+ import { eslint, lernaExec } from '../../utils';
4
3
  import { getPackages } from '../../../utils';
5
4
 
6
- jest.mock('@lerna/exec', () => jest.fn());
7
- jest.mock('execa', () => jest.fn());
5
+ jest.mock('execa');
8
6
  jest.mock('stylelint', () => ({ lint: jest.fn(() => ({ output: '' })) }));
9
7
 
10
- jest.mock('../../utils', () => ({ eslint: jest.fn() }));
8
+ jest.mock('../../utils');
11
9
  jest.mock('../../../utils', () => ({
12
10
  log: { info: jest.fn() },
13
11
  getConfiguration: jest.fn(() => ({})),
@@ -57,7 +55,7 @@ describe(`[startup] ${Lint.name}`, () => {
57
55
  });
58
56
 
59
57
  function itRunsLernaExec() {
60
- test('runs @lerna/exec instead of eslint', async () => {
58
+ test('runs lernaExec instead of eslint', async () => {
61
59
  await subject();
62
60
 
63
61
  expect(eslint).not.toHaveBeenCalled();
@@ -82,7 +80,7 @@ describe(`[startup] ${Lint.name}`, () => {
82
80
  await subject();
83
81
 
84
82
  expect(lernaExec).toHaveBeenCalledWith(
85
- expect.objectContaining({ args: ['--fix'] })
83
+ expect.objectContaining({ '--': ['--fix'] })
86
84
  );
87
85
  });
88
86
  });
@@ -1,12 +1,12 @@
1
- const exec = require('@lerna/exec');
2
1
  import { fs, vol } from 'memfs';
2
+ import { lernaExec } from '../../utils';
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
8
  jest.mock('fs', () => fs);
9
- jest.mock('@lerna/exec', () => jest.fn());
9
+ jest.mock('../../utils');
10
10
  jest.mock('../../../utils', () => ({
11
11
  ...jest.requireActual('../../../utils'),
12
12
  getPackages: jest.fn(),
@@ -69,7 +69,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
69
69
  test('publishes the package', async () => {
70
70
  await subject();
71
71
 
72
- expect(exec).toHaveBeenCalledWith({
72
+ expect(lernaExec).toHaveBeenCalledWith({
73
73
  'cmd': 'startup mfe-package-publish',
74
74
  'scope': packages.map(({ name }) => name),
75
75
  'stream': true,
@@ -89,7 +89,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
89
89
  test('cleans the package', async () => {
90
90
  await subject();
91
91
 
92
- expect(exec).toHaveBeenCalledWith(
92
+ expect(lernaExec).toHaveBeenCalledWith(
93
93
  expect.objectContaining({ cmd: 'startup mfe-package-clean' })
94
94
  );
95
95
  });
@@ -113,7 +113,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
113
113
  test(`runs publish with "${expected ?? `--${name} ${value}`}"`, async () => {
114
114
  await subject();
115
115
 
116
- expect(exec).toHaveBeenCalledWith(
116
+ expect(lernaExec).toHaveBeenCalledWith(
117
117
  expect.objectContaining({ '--': [expected ?? `--${name} ${value}`] })
118
118
  );
119
119
  });
@@ -139,7 +139,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
139
139
  test('publishes the packages', async () => {
140
140
  await subject();
141
141
 
142
- expect(exec).toHaveBeenCalledWith(
142
+ expect(lernaExec).toHaveBeenCalledWith(
143
143
  expect.objectContaining({ scope: packages.map(({ name }) => name) })
144
144
  );
145
145
  });
@@ -150,7 +150,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
150
150
  test('publishes specified packages', async () => {
151
151
  await subject();
152
152
 
153
- expect(exec).toHaveBeenCalledWith(
153
+ expect(lernaExec).toHaveBeenCalledWith(
154
154
  expect.objectContaining({ scope: [packages[0].name] })
155
155
  );
156
156
  });
@@ -162,7 +162,7 @@ describe(`[startup] ${MFEPublish.name}`, () => {
162
162
  test('publishes the specified packages', async () => {
163
163
  await subject();
164
164
 
165
- expect(exec).toHaveBeenCalledWith(
165
+ expect(lernaExec).toHaveBeenCalledWith(
166
166
  expect.objectContaining({
167
167
  scope: packages.slice(1).map(({ name }) => name),
168
168
  })
@@ -1,16 +1,14 @@
1
- const exec = require('@lerna/exec');
2
1
  import { Package, PackageType, getPackages } from '../../../utils';
3
2
  import { createPackage } from '../../../__mocks__';
4
- import { tsc, tscWatch } from '../../utils';
3
+ import { lernaExec, tsc, tscWatch } from '../../utils';
5
4
 
6
5
  import { Start } from '../start';
7
6
 
8
- jest.mock('@lerna/exec', () => jest.fn());
9
7
  jest.mock('../../../utils', () => ({
10
8
  ...jest.requireActual('../../../utils'),
11
9
  getPackages: jest.fn(),
12
10
  }));
13
- jest.mock('../../utils', () => ({ tsc: jest.fn(), tscWatch: jest.fn() }));
11
+ jest.mock('../../utils');
14
12
 
15
13
  describe(`[startup] ${Start.name}`, () => {
16
14
  let args: ConstructorParameters<typeof Start>[0];
@@ -29,13 +27,13 @@ describe(`[startup] ${Start.name}`, () => {
29
27
  test('prepares the package, then again in watch mode', async () => {
30
28
  await subject();
31
29
 
32
- expect(exec).toHaveBeenCalledWith({
30
+ expect(lernaExec).toHaveBeenCalledWith({
33
31
  cmd: 'startup prepare-package',
34
32
  scope: packages.map(({ name }) => name),
35
33
  stream: true,
36
34
  });
37
35
 
38
- expect(exec).toHaveBeenCalledWith({
36
+ expect(lernaExec).toHaveBeenCalledWith({
39
37
  'cmd': 'startup prepare-package',
40
38
  'scope': packages.map(({ name }) => name),
41
39
  'parallel': true,
@@ -66,7 +64,7 @@ describe(`[startup] ${Start.name}`, () => {
66
64
  test('bundles the package in watch mode', async () => {
67
65
  await subject();
68
66
 
69
- expect(exec).toHaveBeenCalledWith({
67
+ expect(lernaExec).toHaveBeenCalledWith({
70
68
  'cmd': 'startup bundle-package',
71
69
  'scope': packages.map(({ name }) => name),
72
70
  'parallel': true,
@@ -81,7 +79,7 @@ describe(`[startup] ${Start.name}`, () => {
81
79
  test('enables code-coverage', async () => {
82
80
  await subject();
83
81
 
84
- expect(exec).toHaveBeenCalledWith(
82
+ expect(lernaExec).toHaveBeenCalledWith(
85
83
  expect.objectContaining({
86
84
  '--': ['--watch', '--code-coverage'],
87
85
  })
@@ -95,7 +93,7 @@ describe(`[startup] ${Start.name}`, () => {
95
93
  test('enables esbuild loader', async () => {
96
94
  await subject();
97
95
 
98
- expect(exec).toHaveBeenCalledWith(
96
+ expect(lernaExec).toHaveBeenCalledWith(
99
97
  expect.objectContaining({
100
98
  '--': ['--watch', '--esbuild'],
101
99
  })
@@ -109,7 +107,7 @@ describe(`[startup] ${Start.name}`, () => {
109
107
  test('enables swc-loader', async () => {
110
108
  await subject();
111
109
 
112
- expect(exec).toHaveBeenCalledWith(
110
+ expect(lernaExec).toHaveBeenCalledWith(
113
111
  expect.objectContaining({
114
112
  '--': ['--watch', '--experimental-bundlers'],
115
113
  })
@@ -123,7 +121,7 @@ describe(`[startup] ${Start.name}`, () => {
123
121
  test('uses specified config', async () => {
124
122
  await subject();
125
123
 
126
- expect(exec).toHaveBeenCalledWith(
124
+ expect(lernaExec).toHaveBeenCalledWith(
127
125
  expect.objectContaining({
128
126
  '--': ['--watch', `--config "${args.config}"`],
129
127
  })
@@ -1,7 +1,5 @@
1
- const exec = require('@lerna/exec');
2
-
3
1
  import { getPackages, logErrors, PackageType, splitPackagesByType } from '../../utils';
4
- import { tsc } from '../utils';
2
+ import { lernaExec, tsc } from '../utils';
5
3
  import { Command, kendoUILicense } from '.';
6
4
 
7
5
  interface Args {
@@ -33,7 +31,7 @@ export class Build implements Command {
33
31
  }
34
32
 
35
33
  if (packagesWithPreparation.length) {
36
- await exec({
34
+ await lernaExec({
37
35
  cmd: 'startup prepare-package',
38
36
  scope: packagesWithPreparation.map(({ name }) => name),
39
37
  stream: true,
@@ -46,7 +44,7 @@ export class Build implements Command {
46
44
 
47
45
  if (packages[PackageType.Webpack].length) {
48
46
  await kendoUILicense();
49
- await exec({
47
+ await lernaExec({
50
48
  'cmd': 'startup bundle-package',
51
49
  'scope': packages[PackageType.Webpack].map(({ name }) => name),
52
50
  'stream': true,
@@ -56,7 +54,7 @@ export class Build implements Command {
56
54
  ...[this.args.esbuild ? '--esbuild' : undefined],
57
55
  ...[this.args['experimental-bundlers'] ? '--experimental-bundlers' : undefined],
58
56
  ...[this.args.stat ? '--stat' : undefined],
59
- ].filter(item => item),
57
+ ].filter(item => !!item) as string[],
60
58
  });
61
59
  }
62
60
  }
@@ -10,9 +10,7 @@ import {
10
10
  logErrors,
11
11
  } from '../../utils';
12
12
  import { Command } from '.';
13
- import { eslint } from '../utils';
14
-
15
- const exec = require('@lerna/exec');
13
+ import { eslint, lernaExec } from '../utils';
16
14
 
17
15
  interface Args {
18
16
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -23,7 +21,7 @@ interface Args {
23
21
  scope?: string | string[];
24
22
  /** Packages to skip */
25
23
  ignore?: string | string[];
26
- /** Use \@lerna/exec to run eslint separately for each package? */
24
+ /** Run eslint separately for each package? */
27
25
  isolated?: boolean;
28
26
  }
29
27
 
@@ -45,10 +43,9 @@ export class Lint implements Command {
45
43
  const { fix, ignore, isolated, scope } = this.args;
46
44
  const { paths } = this;
47
45
 
48
- log.info('Running the eslint...');
49
-
50
46
  const useESLint = !isolated && !scope?.length && !ignore?.length;
51
47
  if (this.paths.length || useESLint) {
48
+ log.info('Running eslint...');
52
49
  await eslint({ fix, paths });
53
50
  return;
54
51
  }
@@ -56,11 +53,11 @@ export class Lint implements Command {
56
53
  const packages = getPackages({ scope, ignore });
57
54
  const args = fix ? ['--fix'] : [];
58
55
 
59
- await exec({
60
- cmd: 'startup eslint',
61
- scope: packages.map(({ name }) => name),
62
- bail: false,
63
- args,
56
+ await lernaExec({
57
+ 'cmd': 'startup eslint',
58
+ 'scope': packages.map(({ name }) => name),
59
+ 'bail': false,
60
+ '--': args,
64
61
  });
65
62
  }
66
63
 
@@ -74,7 +71,7 @@ export class Lint implements Command {
74
71
  const { fix } = this.args;
75
72
  const { paths } = this;
76
73
 
77
- log.info('Running the stylelint...');
74
+ log.info('Running stylelint...');
78
75
  const allowedExtensions = ['css', 'scss', 'less'];
79
76
  const glob = `**/*.{${allowedExtensions.join(',')}}`;
80
77
  let files = paths.reduce((result, path) => {
@@ -112,11 +109,9 @@ export class Lint implements Command {
112
109
  private async checkStyles() {
113
110
  const { ignore, scope } = this.args;
114
111
 
115
- log.info('Running the style check...');
116
-
117
112
  const packages = getPackages({ ignore, scope });
118
113
 
119
- await exec({
114
+ await lernaExec({
120
115
  cmd: 'startup styles-check',
121
116
  scope: packages.map(({ name }) => name),
122
117
  stream: true,
@@ -1,5 +1,4 @@
1
- const exec = require('@lerna/exec');
2
- const path = require('path');
1
+ import path from 'path';
3
2
 
4
3
  import {
5
4
  getPackages,
@@ -10,6 +9,7 @@ import {
10
9
  isWebComponent,
11
10
  log,
12
11
  } from '../../utils';
12
+ import { lernaExec } from '../utils';
13
13
  import { gitGetBranch, gitGetCommitHash } from '../utils/cli-git';
14
14
  import {
15
15
  npmGetPackageVersionDates,
@@ -65,7 +65,7 @@ export class MFEPublish implements Command {
65
65
  throw new Error('no packages found for publication');
66
66
  }
67
67
 
68
- await exec({
68
+ await lernaExec({
69
69
  'cmd': `startup mfe-package-${this.args.clean ? 'clean' : 'publish'}`,
70
70
  'scope': packages.map(({ name }) => name),
71
71
  'stream': true,
@@ -78,7 +78,7 @@ export class MFEPublish implements Command {
78
78
  ...[this.args.force ? '--force' : undefined],
79
79
  ...[this.args.count ? `--count ${this.args.count}` : undefined],
80
80
  ...[this.args.registry ? `--registry ${this.args.registry}` : undefined],
81
- ].filter(item => item),
81
+ ].filter(item => !!item) as string[],
82
82
  });
83
83
  }
84
84
  }
@@ -1,7 +1,5 @@
1
- const exec = require('@lerna/exec');
2
-
3
1
  import { getPackages, logErrors, PackageType, splitPackagesByType } from '../../utils';
4
- import { tsc, tscWatch } from '../utils';
2
+ import { lernaExec, tsc, tscWatch } from '../utils';
5
3
  import { Command } from '.';
6
4
 
7
5
  interface Args {
@@ -27,7 +25,7 @@ export class Start implements Command {
27
25
  ];
28
26
 
29
27
  if (packagesWithPreparation.length) {
30
- await exec({
28
+ await lernaExec({
31
29
  cmd: 'startup prepare-package',
32
30
  scope: packagesWithPreparation.map(({ name }) => name),
33
31
  stream: true,
@@ -41,7 +39,7 @@ export class Start implements Command {
41
39
  await Promise.all([
42
40
  ...(packagesWithPreparation.length
43
41
  ? [
44
- exec({
42
+ lernaExec({
45
43
  'cmd': 'startup prepare-package',
46
44
  'scope': packagesWithPreparation.map(({ name }) => name),
47
45
  'parallel': true,
@@ -53,7 +51,7 @@ export class Start implements Command {
53
51
  ...(packages[PackageType.TSC].length ? [tscWatch(packages[PackageType.TSC])] : []),
54
52
  ...(packages[PackageType.Webpack].length
55
53
  ? [
56
- exec({
54
+ lernaExec({
57
55
  'cmd': 'startup bundle-package',
58
56
  'scope': packages[PackageType.Webpack].map(({ name }) => name),
59
57
  'parallel': true,
@@ -66,7 +64,7 @@ export class Start implements Command {
66
64
  this.args['experimental-bundlers']
67
65
  ? '--experimental-bundlers'
68
66
  : undefined,
69
- ].filter(item => item),
67
+ ].filter(item => !!item) as string[],
70
68
  }),
71
69
  ]
72
70
  : []),
@@ -34,7 +34,7 @@ describe('[startup] Cli Utils', () => {
34
34
  jest.resetAllMocks();
35
35
  jest.mocked(createWebpackConfig).mockReturnValue(createWebpackResult);
36
36
  jest.mocked(webpack).mockImplementation((): any => compiler);
37
- compiler = { close: jest.fn(callback => callback()) };
37
+ compiler = { close: jest.fn(callback => callback(null)) };
38
38
  });
39
39
 
40
40
  afterEach(() => vol.reset());
@@ -120,11 +120,11 @@ describe('[startup] Cli Utils', () => {
120
120
 
121
121
  describe('when webpack reports unexpected results', () => {
122
122
  beforeEach(() => {
123
- jest.mocked(compiler.run)!.mockImplementation(callback => callback());
123
+ jest.mocked(compiler.run)!.mockImplementation(callback => callback(null));
124
124
  });
125
125
 
126
126
  test('returns error', () => {
127
- expect(subject).rejects.toThrowError(/something went wrong/i);
127
+ expect(subject).rejects.toThrow(/something went wrong/i);
128
128
  });
129
129
  });
130
130
 
@@ -270,7 +270,7 @@ describe('[startup] Cli Utils', () => {
270
270
  });
271
271
 
272
272
  const subject = async () => {
273
- await expect(bundleWatch(options)).rejects.toThrowError('stopped');
273
+ await expect(bundleWatch(options)).rejects.toThrow('stopped');
274
274
  };
275
275
 
276
276
  test('runs webpack development server', async () => {
@@ -96,7 +96,7 @@ describe('[startup] Cli Utils (OS)', () => {
96
96
 
97
97
  ['', [], ['']].forEach(command =>
98
98
  test(`throws error when called with ${JSON.stringify(command)}`, () => {
99
- expect(() => subject(command)).toThrowError();
99
+ expect(() => subject(command)).toThrow();
100
100
  })
101
101
  );
102
102
  });
@@ -0,0 +1,64 @@
1
+ import execa from 'execa';
2
+
3
+ import { log } from '../../../utils';
4
+ import { lernaExec } from '../lerna-exec';
5
+
6
+ jest.mock('execa');
7
+
8
+ describe(`${lernaExec.name}`, () => {
9
+ let args: Parameters<typeof lernaExec>[0];
10
+
11
+ beforeEach(() => {
12
+ jest.clearAllMocks();
13
+ jest.spyOn(log, 'info').mockImplementation(jest.fn()); // suppress log output
14
+ args = { cmd: 'foo' };
15
+ });
16
+
17
+ const subject = () => lernaExec(args);
18
+
19
+ function expectExecaCalledWith(commandLine: string) {
20
+ const [cmd, ...args] = commandLine.split(' ');
21
+ expect(execa).toHaveBeenCalledWith(cmd, args, { stdio: 'inherit' });
22
+ }
23
+
24
+ test('runs "lerna exec -- {cmd}" command', () => {
25
+ subject();
26
+
27
+ expectExecaCalledWith(`lerna exec -- ${args.cmd}`);
28
+ });
29
+
30
+ describe.each([
31
+ { arg: { parallel: true }, option: '--parallel' },
32
+ { arg: { stream: true }, option: '--stream' },
33
+ { arg: { bail: false }, option: '--no-bail' },
34
+ ] as { arg: Partial<typeof args>; option: string }[])('with $arg', ({ arg, option }) => {
35
+ beforeEach(() => Object.assign(args, arg));
36
+
37
+ test(`runs "lerna exec ${option} -- {cmd}"`, () => {
38
+ subject();
39
+
40
+ expectExecaCalledWith(`lerna exec ${option} -- ${args.cmd}`);
41
+ });
42
+ });
43
+
44
+ describe('with scope', () => {
45
+ beforeEach(() => (args.scope = ['foo', 'bar']));
46
+
47
+ test('runs "lerna exec --scope={scope-1} ... --scope={scope-N} -- {cmd}', () => {
48
+ subject();
49
+
50
+ const scopes = args.scope!.map(name => `--scope=${name}`).join(' ');
51
+ expectExecaCalledWith(`lerna exec ${scopes} -- ${args.cmd}`);
52
+ });
53
+ });
54
+
55
+ describe('with pass-thru arguments', () => {
56
+ beforeEach(() => (args['--'] = ['--foo bar', '--bax=qux']));
57
+
58
+ test('runs "lerna exec -- {cmd} {arguments}', () => {
59
+ subject();
60
+
61
+ expectExecaCalledWith(`lerna exec -- ${args.cmd} ${args['--']!.join(' ')}`);
62
+ });
63
+ });
64
+ });
@@ -8,6 +8,7 @@ export * from './compile-sass';
8
8
  export * from './eslint';
9
9
  export * from './get-module-type';
10
10
  export * from './is-module-installed';
11
+ export * from './lerna-exec';
11
12
  export * from './set-node-options';
12
13
  export * from './styles-copy';
13
14
  export * from './tcm';
@@ -0,0 +1,37 @@
1
+ import execa from 'execa';
2
+ import { log } from '../../utils';
3
+
4
+ interface Args {
5
+ 'bail'?: boolean;
6
+ 'cmd': string;
7
+ 'scope'?: string[];
8
+ 'stream'?: boolean;
9
+ 'parallel'?: boolean;
10
+ '--'?: string[];
11
+ }
12
+
13
+ export async function lernaExec(args: Args) {
14
+ const lernaArguments = [
15
+ 'exec',
16
+ ...getOptions(args),
17
+ '--',
18
+ ...args.cmd.split(' '),
19
+ ...(args['--'] ?? []).flatMap(arg => arg.split(' ')),
20
+ ];
21
+ log.info(`Running ${[args.cmd, ...(args['--'] ?? [])].join(' ')}`);
22
+ await execa('lerna', lernaArguments, { stdio: 'inherit' });
23
+ }
24
+
25
+ function getOptions(args: Args) {
26
+ const result = (args.scope ?? []).map(name => `--scope=${name}`);
27
+ if (args.bail === false) {
28
+ result.push('--no-bail');
29
+ }
30
+ if (args.parallel) {
31
+ result.push('--parallel');
32
+ }
33
+ if (args.stream) {
34
+ result.push('--stream');
35
+ }
36
+ return result;
37
+ }
@@ -73,7 +73,7 @@ describe('[startup] Utils', () => {
73
73
  beforeEach(() => vol.reset());
74
74
 
75
75
  test('throws error', () => {
76
- expect(subject).toThrowError();
76
+ expect(subject).toThrow();
77
77
  });
78
78
  });
79
79
  });
@@ -133,7 +133,7 @@ describe(`[startup] Utils`, () => {
133
133
  });
134
134
 
135
135
  test('logs error', () => {
136
- expect(subject).toThrowError(error);
136
+ expect(subject).toThrow(error);
137
137
 
138
138
  expect(log.error).toHaveBeenCalledWith(String(error));
139
139
  });
@@ -146,7 +146,7 @@ describe(`[startup] Utils`, () => {
146
146
  });
147
147
 
148
148
  test('logs error', async () => {
149
- await expect(subject).rejects.toThrowError(error);
149
+ await expect(subject).rejects.toThrow(error);
150
150
 
151
151
  expect(log.error).toHaveBeenCalledWith(String(error));
152
152
  });
@@ -156,7 +156,7 @@ describe(`[startup] Utils`, () => {
156
156
  const subject = () => instance.foo;
157
157
 
158
158
  test('logs nothing', () => {
159
- expect(subject).toThrowError(error);
159
+ expect(subject).toThrow(error);
160
160
 
161
161
  expect(log.error).not.toHaveBeenCalled();
162
162
  });