@servicetitan/startup 39.0.1 → 39.2.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 (122) hide show
  1. package/dist/cli/commands/mfe-list.d.ts +0 -2
  2. package/dist/cli/commands/mfe-list.d.ts.map +1 -1
  3. package/dist/cli/commands/mfe-list.js +4 -30
  4. package/dist/cli/commands/mfe-list.js.map +1 -1
  5. package/dist/cli/commands/mfe-package-clean.js +1 -2
  6. package/dist/cli/commands/mfe-package-clean.js.map +1 -1
  7. package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
  8. package/dist/cli/commands/mfe-package-publish.js +7 -5
  9. package/dist/cli/commands/mfe-package-publish.js.map +1 -1
  10. package/dist/cli/commands/mfe-package-rollback.d.ts.map +1 -1
  11. package/dist/cli/commands/mfe-package-rollback.js +5 -3
  12. package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
  13. package/dist/cli/commands/mfe-publish.d.ts +1 -0
  14. package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
  15. package/dist/cli/commands/mfe-publish.js +14 -12
  16. package/dist/cli/commands/mfe-publish.js.map +1 -1
  17. package/dist/cli/commands/registry/command-registry.d.ts +13 -4
  18. package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
  19. package/dist/cli/commands/registry/mfe-list.d.ts +2 -1
  20. package/dist/cli/commands/registry/mfe-list.d.ts.map +1 -1
  21. package/dist/cli/commands/registry/mfe-list.js +3 -1
  22. package/dist/cli/commands/registry/mfe-list.js.map +1 -1
  23. package/dist/cli/commands/registry/mfe-package-clean.d.ts +2 -1
  24. package/dist/cli/commands/registry/mfe-package-clean.d.ts.map +1 -1
  25. package/dist/cli/commands/registry/mfe-package-clean.js +4 -2
  26. package/dist/cli/commands/registry/mfe-package-clean.js.map +1 -1
  27. package/dist/cli/commands/registry/mfe-package-publish.d.ts +2 -1
  28. package/dist/cli/commands/registry/mfe-package-publish.d.ts.map +1 -1
  29. package/dist/cli/commands/registry/mfe-package-publish.js +4 -2
  30. package/dist/cli/commands/registry/mfe-package-publish.js.map +1 -1
  31. package/dist/cli/commands/registry/mfe-package-rollback.d.ts +2 -1
  32. package/dist/cli/commands/registry/mfe-package-rollback.d.ts.map +1 -1
  33. package/dist/cli/commands/registry/mfe-package-rollback.js +4 -2
  34. package/dist/cli/commands/registry/mfe-package-rollback.js.map +1 -1
  35. package/dist/cli/commands/registry/upload-sourcemaps.d.ts +5 -0
  36. package/dist/cli/commands/registry/upload-sourcemaps.d.ts.map +1 -1
  37. package/dist/cli/commands/registry/upload-sourcemaps.js +5 -0
  38. package/dist/cli/commands/registry/upload-sourcemaps.js.map +1 -1
  39. package/dist/cli/commands/review/types.js.map +1 -1
  40. package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
  41. package/dist/cli/commands/upload-sourcemaps.js +4 -7
  42. package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
  43. package/dist/cli/commands/utils/get-mfe-registry.d.ts +4 -0
  44. package/dist/cli/commands/utils/get-mfe-registry.d.ts.map +1 -0
  45. package/dist/cli/commands/utils/get-mfe-registry.js +28 -0
  46. package/dist/cli/commands/utils/get-mfe-registry.js.map +1 -0
  47. package/dist/cli/commands/utils/get-unpkg-host.d.ts +2 -0
  48. package/dist/cli/commands/utils/get-unpkg-host.d.ts.map +1 -0
  49. package/dist/cli/commands/utils/get-unpkg-host.js +18 -0
  50. package/dist/cli/commands/utils/get-unpkg-host.js.map +1 -0
  51. package/dist/cli/commands/utils/index.d.ts +3 -1
  52. package/dist/cli/commands/utils/index.d.ts.map +1 -1
  53. package/dist/cli/commands/utils/index.js +3 -1
  54. package/dist/cli/commands/utils/index.js.map +1 -1
  55. package/dist/cli/commands/utils/login.d.ts +2 -0
  56. package/dist/cli/commands/utils/login.d.ts.map +1 -0
  57. package/dist/cli/commands/utils/login.js +56 -0
  58. package/dist/cli/commands/utils/login.js.map +1 -0
  59. package/dist/cli/commands/utils/purge-cache.d.ts.map +1 -1
  60. package/dist/cli/commands/utils/purge-cache.js +2 -4
  61. package/dist/cli/commands/utils/purge-cache.js.map +1 -1
  62. package/dist/cli/index.js +4 -1
  63. package/dist/cli/index.js.map +1 -1
  64. package/dist/vite/build-escaped-reg-exp.d.ts +2 -0
  65. package/dist/vite/build-escaped-reg-exp.d.ts.map +1 -0
  66. package/dist/vite/build-escaped-reg-exp.js +16 -0
  67. package/dist/vite/build-escaped-reg-exp.js.map +1 -0
  68. package/dist/vite/config/base-config.d.ts.map +1 -1
  69. package/dist/vite/config/base-config.js +7 -2
  70. package/dist/vite/config/base-config.js.map +1 -1
  71. package/dist/vite/config/create-resolve-config.d.ts +6 -0
  72. package/dist/vite/config/create-resolve-config.d.ts.map +1 -0
  73. package/dist/vite/config/create-resolve-config.js +52 -0
  74. package/dist/vite/config/create-resolve-config.js.map +1 -0
  75. package/dist/vite/plugins/css-injector-plugin.d.ts.map +1 -1
  76. package/dist/vite/plugins/css-injector-plugin.js +5 -1
  77. package/dist/vite/plugins/css-injector-plugin.js.map +1 -1
  78. package/dist/vite/plugins/externals-plugin.d.ts.map +1 -1
  79. package/dist/vite/plugins/externals-plugin.js +3 -3
  80. package/dist/vite/plugins/externals-plugin.js.map +1 -1
  81. package/package.json +15 -16
  82. package/src/cli/commands/__tests__/mfe-list.test.ts +25 -56
  83. package/src/cli/commands/__tests__/mfe-package-clean.test.ts +6 -0
  84. package/src/cli/commands/__tests__/mfe-package-publish.test.ts +52 -47
  85. package/src/cli/commands/__tests__/mfe-package-rollback.test.ts +4 -2
  86. package/src/cli/commands/__tests__/mfe-publish.test.ts +51 -14
  87. package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +27 -13
  88. package/src/cli/commands/mfe-list.ts +7 -36
  89. package/src/cli/commands/mfe-package-clean.ts +2 -2
  90. package/src/cli/commands/mfe-package-publish.ts +10 -8
  91. package/src/cli/commands/mfe-package-rollback.ts +6 -5
  92. package/src/cli/commands/mfe-publish.ts +17 -16
  93. package/src/cli/commands/registry/mfe-list.ts +6 -1
  94. package/src/cli/commands/registry/mfe-package-clean.ts +7 -1
  95. package/src/cli/commands/registry/mfe-package-publish.ts +7 -1
  96. package/src/cli/commands/registry/mfe-package-rollback.ts +4 -2
  97. package/src/cli/commands/registry/upload-sourcemaps.ts +1 -0
  98. package/src/cli/commands/upload-sourcemaps.ts +4 -7
  99. package/src/cli/commands/utils/__tests__/get-mfe-registry.test.ts +24 -0
  100. package/src/cli/commands/utils/__tests__/get-unpkg-host.test.ts +32 -0
  101. package/src/cli/commands/utils/__tests__/login.test.ts +122 -0
  102. package/src/cli/commands/utils/__tests__/purge-cache.test.ts +17 -15
  103. package/src/cli/commands/utils/get-mfe-registry.ts +6 -0
  104. package/src/cli/commands/utils/get-unpkg-host.ts +8 -0
  105. package/src/cli/commands/utils/index.ts +3 -1
  106. package/src/cli/commands/utils/login.ts +38 -0
  107. package/src/cli/commands/utils/purge-cache.ts +2 -5
  108. package/src/cli/index.ts +2 -1
  109. package/src/vite/__tests__/build-escaped-reg-exp.test.ts +25 -0
  110. package/src/vite/build-escaped-reg-exp.ts +6 -0
  111. package/src/vite/config/__tests__/base-config.test.ts +1 -1
  112. package/src/vite/config/__tests__/create-resolve-config.test.ts +85 -0
  113. package/src/vite/config/base-config.ts +4 -2
  114. package/src/vite/config/create-resolve-config.ts +43 -0
  115. package/src/vite/plugins/__tests__/css-injector-plugin.test.ts +1 -1
  116. package/src/vite/plugins/css-injector-plugin.ts +6 -1
  117. package/src/vite/plugins/externals-plugin.ts +1 -4
  118. package/dist/cli/commands/utils/constants.d.ts +0 -2
  119. package/dist/cli/commands/utils/constants.d.ts.map +0 -1
  120. package/dist/cli/commands/utils/constants.js +0 -13
  121. package/dist/cli/commands/utils/constants.js.map +0 -1
  122. package/src/cli/commands/utils/constants.ts +0 -1
@@ -12,7 +12,7 @@ import {
12
12
  runCommand,
13
13
  } from '../../utils';
14
14
  import { MFEPackagePublish } from '../mfe-package-publish';
15
- import { purgeCache, ROLLBACK_TAG_SUFFIX } from '../utils';
15
+ import { getMfeRegistry, purgeCache, ROLLBACK_TAG_SUFFIX } from '../utils';
16
16
 
17
17
  jest.mock('fs', () => fs);
18
18
 
@@ -34,11 +34,12 @@ jest.mock('../../utils', () => ({
34
34
  }));
35
35
  jest.mock('../utils', () => ({
36
36
  ...jest.requireActual('../utils'),
37
+ getMfeRegistry: jest.fn(),
37
38
  purgeCache: jest.fn(),
38
39
  }));
39
40
 
40
41
  describe(`[startup] ${MFEPackagePublish.name}`, () => {
41
- const defaultRegistry = 'https://verdaccio.servicetitan.com';
42
+ const registry = 'https://foo.com';
42
43
  const branch = 'master';
43
44
  const tag = 'prod';
44
45
  const rollbackTag = `${tag}${ROLLBACK_TAG_SUFFIX}`;
@@ -53,6 +54,7 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
53
54
  beforeEach(() => {
54
55
  args = {};
55
56
  jest.clearAllMocks();
57
+ jest.mocked(getMfeRegistry).mockImplementation(explicit => explicit ?? registry);
56
58
  jest.mocked(isWebComponent).mockReturnValue(true);
57
59
  jest.mocked(gitGetBranch).mockReturnValue(branch);
58
60
  jest.mocked(gitGetCommitHash).mockReturnValue(commitHash);
@@ -103,7 +105,7 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
103
105
  test('sets package registry', async () => {
104
106
  await subject();
105
107
 
106
- expect(npmPackageSet).toHaveBeenCalledWith('publishConfig.registry', defaultRegistry);
108
+ expect(npmPackageSet).toHaveBeenCalledWith('publishConfig.registry', registry);
107
109
  });
108
110
 
109
111
  test('adds package version to metadata.json', async () => {
@@ -127,23 +129,53 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
127
129
  await subject();
128
130
 
129
131
  expect(runCommand).toHaveBeenCalledWith(
130
- `npx startup upload-sourcemaps --releaseVersion=${buildPackageVersion()}`
132
+ `npx startup upload-sourcemaps --releaseVersion=${buildPackageVersion()} --registry=${registry}`
131
133
  );
132
134
  });
133
135
 
136
+ function itDoesNotUploadSourcemaps() {
137
+ test('does not upload sourcemaps', async () => {
138
+ await subject();
139
+
140
+ expect(runCommand).not.toHaveBeenCalledWith(
141
+ expect.stringContaining('upload-sourcemaps')
142
+ );
143
+ });
144
+ }
145
+
146
+ describe('with "uploadSourcemaps: false"', () => {
147
+ beforeEach(() => (args.uploadSourcemaps = false));
148
+
149
+ itDoesNotUploadSourcemaps();
150
+ });
151
+
152
+ describe('when branch configuration includes "uploadSourcemaps: false"', () => {
153
+ beforeEach(() =>
154
+ vol.fromJSON({
155
+ 'package.json': JSON.stringify({
156
+ name: packageName,
157
+ cli: {
158
+ 'web-component': {
159
+ branches: { [branch]: { uploadSourcemaps: false } },
160
+ },
161
+ },
162
+ }),
163
+ })
164
+ );
165
+
166
+ itDoesNotUploadSourcemaps();
167
+ });
168
+
134
169
  test('purges cache after publishing', async () => {
135
170
  await subject();
136
171
 
137
- expect(purgeCache).toHaveBeenCalledWith({ packageName, tag });
172
+ expect(purgeCache).toHaveBeenCalledWith({ packageName, registry, tag });
138
173
  });
139
174
 
140
175
  test('gets current tagged versions before publishing', async () => {
141
176
  await subject();
142
177
 
143
- expect(npmView).toHaveBeenCalledWith({
144
- packageName,
145
- registry: defaultRegistry,
146
- });
178
+ expect(npmView).toHaveBeenCalledWith({ packageName, registry });
147
179
  });
148
180
 
149
181
  test(`tags previous version with {tag}${ROLLBACK_TAG_SUFFIX}`, async () => {
@@ -151,7 +183,7 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
151
183
  expect(npmTagVersion).toHaveBeenCalledWith({
152
184
  packageName,
153
185
  packageVersion: previousVersion,
154
- registry: defaultRegistry,
186
+ registry,
155
187
  tag: rollbackTag,
156
188
  });
157
189
 
@@ -250,31 +282,19 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
250
282
  expect(npmTagVersion).not.toHaveBeenCalled();
251
283
  });
252
284
 
253
- test('uploads sourcemaps with "--dry" option', async () => {
254
- await subject();
285
+ describe('with "uploadSourcemaps: true"', () => {
286
+ beforeEach(() => (args.uploadSourcemaps = true));
255
287
 
256
- expect(runCommand).toHaveBeenCalledWith(
257
- `npx startup upload-sourcemaps --dry --releaseVersion=${buildPackageVersion()}`
258
- );
259
- });
260
-
261
- itDoesNotPurgeCache();
262
- });
263
-
264
- function itDoesNotUploadSourcemaps() {
265
- test('does not upload sourcemaps', async () => {
266
- await subject();
288
+ test('uploads sourcemaps with "--dry" option', async () => {
289
+ await subject();
267
290
 
268
- expect(runCommand).not.toHaveBeenCalledWith(
269
- expect.stringContaining('upload-sourcemaps')
270
- );
291
+ expect(runCommand).toHaveBeenCalledWith(
292
+ `npx startup upload-sourcemaps --dry --releaseVersion=${buildPackageVersion()} --registry=${registry}`
293
+ );
294
+ });
271
295
  });
272
- }
273
-
274
- describe('with "uploadSourcemaps: false"', () => {
275
- beforeEach(() => (args.uploadSourcemaps = false));
276
296
 
277
- itDoesNotUploadSourcemaps();
297
+ itDoesNotPurgeCache();
278
298
  });
279
299
 
280
300
  describe('with "purgeCache: false"', () => {
@@ -283,21 +303,6 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
283
303
  itDoesNotPurgeCache();
284
304
  });
285
305
 
286
- describe('when branch configuration includes "uploadSourcemaps: false"', () => {
287
- beforeEach(() =>
288
- vol.fromJSON({
289
- 'package.json': JSON.stringify({
290
- name: packageName,
291
- cli: {
292
- 'web-component': { branches: { [branch]: { uploadSourcemaps: false } } },
293
- },
294
- }),
295
- })
296
- );
297
-
298
- itDoesNotUploadSourcemaps();
299
- });
300
-
301
306
  describe('with "trackHistory: false"', () => {
302
307
  beforeEach(() => {
303
308
  args.trackHistory = false;
@@ -484,7 +489,7 @@ describe(`[startup] ${MFEPackagePublish.name}`, () => {
484
489
  expect(npmTagVersion).toHaveBeenCalledWith({
485
490
  packageName,
486
491
  packageVersion: buildPackageVersion(),
487
- registry: defaultRegistry,
492
+ registry,
488
493
  tag,
489
494
  });
490
495
  expect(log.info).toHaveBeenCalledWith(
@@ -1,7 +1,7 @@
1
1
  import { log, readJson } from '../../../utils';
2
2
  import { npmTagVersion, npmView } from '../../utils';
3
3
  import { MFEPackageRollback } from '../mfe-package-rollback';
4
- import { purgeCache } from '../utils';
4
+ import { getMfeRegistry, purgeCache } from '../utils';
5
5
 
6
6
  jest.mock('../../../utils', () => ({
7
7
  ...jest.requireActual('../../../utils'),
@@ -19,6 +19,7 @@ jest.mock('../../utils', () => ({
19
19
  }));
20
20
  jest.mock('../utils', () => ({
21
21
  ...jest.requireActual('../utils'),
22
+ getMfeRegistry: jest.fn(),
22
23
  purgeCache: jest.fn(),
23
24
  }));
24
25
 
@@ -43,6 +44,7 @@ describe(`[startup] ${MFEPackageRollback.name}`, () => {
43
44
  };
44
45
 
45
46
  jest.resetAllMocks();
47
+ jest.mocked(getMfeRegistry).mockImplementation(explicit => explicit ?? registry);
46
48
  jest.mocked(readJson).mockReturnValue({ name: packageName });
47
49
  jest.mocked(npmView).mockReturnValue(packageInfo);
48
50
  jest.mocked(npmTagVersion).mockResolvedValue(undefined);
@@ -106,7 +108,7 @@ describe(`[startup] ${MFEPackageRollback.name}`, () => {
106
108
  test('purges cache after rollback', async () => {
107
109
  await subject();
108
110
 
109
- expect(purgeCache).toHaveBeenCalledWith({ packageName, tag });
111
+ expect(purgeCache).toHaveBeenCalledWith({ packageName, registry, tag });
110
112
  });
111
113
 
112
114
  describe('when package is not found in registry', () => {
@@ -1,3 +1,4 @@
1
+ import { isCI } from '@servicetitan/install';
1
2
  import { fs, vol } from 'memfs';
2
3
  import { createPackage } from '../../../__mocks__';
3
4
  import { Package, PackageType, getPackages } from '../../../utils';
@@ -7,6 +8,7 @@ import { entry as mfePackageClean } from '../registry/mfe-package-clean';
7
8
  import { entry as mfePackagePublish } from '../registry/mfe-package-publish';
8
9
  import { entry as mfePackageRollback } from '../registry/mfe-package-rollback';
9
10
  import { entry as mfePublish } from '../registry/mfe-publish';
11
+ import { getMfeRegistry, login } from '../utils';
10
12
 
11
13
  jest.mock('fs', () => fs);
12
14
 
@@ -15,16 +17,27 @@ jest.mock('../../../utils', () => ({
15
17
  ...jest.requireActual('../../../utils'),
16
18
  getPackages: jest.fn(),
17
19
  }));
20
+ jest.mock('@servicetitan/install', () => ({ isCI: jest.fn() }));
21
+ jest.mock('../utils', () => ({
22
+ ...jest.requireActual('../utils'),
23
+ getMfeRegistry: jest.fn(),
24
+ login: jest.fn(),
25
+ }));
18
26
 
19
27
  describe(`[startup] ${MFEPublish.name}`, () => {
28
+ const registry = 'https://foo.com';
20
29
  let args: ConstructorParameters<typeof MFEPublish>[0];
30
+ let ci: boolean;
21
31
  let packages: Package[];
22
32
 
23
33
  beforeEach(() => {
24
34
  args = {};
35
+ ci = false;
25
36
  packages = [];
26
37
  jest.resetAllMocks();
27
38
  jest.mocked(getPackages).mockReturnValue(packages);
39
+ jest.mocked(getMfeRegistry).mockImplementation(explicit => explicit ?? registry);
40
+ jest.mocked(isCI).mockImplementation(() => ci);
28
41
  });
29
42
 
30
43
  afterEach(() => vol.reset());
@@ -80,7 +93,13 @@ describe(`[startup] ${MFEPublish.name}`, () => {
80
93
  mockPackageJson(packages);
81
94
  });
82
95
 
83
- test('publishes the package', async () => {
96
+ test('authorizes the machine for the registry', async () => {
97
+ await subject();
98
+
99
+ expect(login).toHaveBeenCalledWith(registry);
100
+ });
101
+
102
+ test('publishes to registry', async () => {
84
103
  await subject();
85
104
 
86
105
  expect(lernaExec).toHaveBeenCalledWith({
@@ -88,7 +107,17 @@ describe(`[startup] ${MFEPublish.name}`, () => {
88
107
  'scope': packages.map(({ name }) => name),
89
108
  'stream': true,
90
109
  'parallel': 1,
91
- '--': [],
110
+ '--': [`--registry ${registry}`],
111
+ });
112
+ });
113
+
114
+ describe('in CI environment', () => {
115
+ beforeEach(() => (ci = true));
116
+
117
+ test('skips authorization', async () => {
118
+ await subject();
119
+
120
+ expect(login).not.toHaveBeenCalled();
92
121
  });
93
122
  });
94
123
 
@@ -105,7 +134,10 @@ describe(`[startup] ${MFEPublish.name}`, () => {
105
134
  await subject();
106
135
 
107
136
  expect(lernaExec).toHaveBeenCalledWith(
108
- expect.objectContaining({ cmd: 'startup mfe-package-clean' })
137
+ expect.objectContaining({
138
+ 'cmd': 'startup mfe-package-clean',
139
+ '--': [`--registry ${registry}`],
140
+ })
109
141
  );
110
142
  });
111
143
 
@@ -127,9 +159,11 @@ describe(`[startup] ${MFEPublish.name}`, () => {
127
159
 
128
160
  expect(lernaExec).toHaveBeenCalledWith(
129
161
  expect.objectContaining({
130
- '--': Array.isArray(expected)
131
- ? expected
132
- : [expected ?? `--${name} ${value}`],
162
+ '--': expect.arrayContaining(
163
+ Array.isArray(expected)
164
+ ? expected
165
+ : [expected ?? `--${name} ${value}`]
166
+ ),
133
167
  })
134
168
  );
135
169
  });
@@ -161,9 +195,9 @@ describe(`[startup] ${MFEPublish.name}`, () => {
161
195
 
162
196
  expect(lernaExec).toHaveBeenCalledWith(
163
197
  expect.objectContaining({
164
- '--': Array.isArray(expected)
165
- ? expected
166
- : [expected ?? `--${name} ${value}`],
198
+ '--': expect.arrayContaining(
199
+ Array.isArray(expected) ? expected : [expected ?? `--${name} ${value}`]
200
+ ),
167
201
  })
168
202
  );
169
203
  });
@@ -190,8 +224,9 @@ describe(`[startup] ${MFEPublish.name}`, () => {
190
224
 
191
225
  expect(lernaExec).toHaveBeenCalledWith(
192
226
  expect.objectContaining({
193
- cmd: 'startup mfe-package-rollback',
194
- scope: [packages[0].name],
227
+ 'cmd': 'startup mfe-package-rollback',
228
+ 'scope': [packages[0].name],
229
+ '--': [`--registry ${registry}`],
195
230
  })
196
231
  );
197
232
  });
@@ -212,9 +247,11 @@ describe(`[startup] ${MFEPublish.name}`, () => {
212
247
 
213
248
  expect(lernaExec).toHaveBeenCalledWith(
214
249
  expect.objectContaining({
215
- '--': Array.isArray(expected)
216
- ? expected
217
- : [expected ?? `--${name} ${value}`],
250
+ '--': expect.arrayContaining(
251
+ Array.isArray(expected)
252
+ ? expected
253
+ : [expected ?? `--${name} ${value}`]
254
+ ),
218
255
  })
219
256
  );
220
257
  });
@@ -1,12 +1,11 @@
1
- import { isCI } from '@servicetitan/install';
2
1
  import { execSync } from 'child_process';
3
2
  import { vol } from 'memfs';
4
3
  import { inspect } from 'node:util';
5
4
  import path from 'path';
6
5
  import { log } from '../../../utils';
7
6
  import { UploadSourcemaps } from '../upload-sourcemaps';
7
+ import { getUnpkgHost } from '../utils';
8
8
 
9
- jest.mock('@servicetitan/install');
10
9
  jest.mock('fs', () => require('memfs').fs);
11
10
  jest.mock('child_process', () => ({ execSync: jest.fn() }));
12
11
 
@@ -14,9 +13,14 @@ jest.mock('../../../utils', () => ({
14
13
  ...jest.requireActual('../../../utils'),
15
14
  log: { info: jest.fn(), warning: jest.fn() },
16
15
  }));
16
+ jest.mock('../utils', () => ({
17
+ ...jest.requireActual('../utils'),
18
+ getUnpkgHost: jest.fn(),
19
+ }));
17
20
 
18
21
  describe(`[startup] ${UploadSourcemaps.name}`, () => {
19
22
  const OLD_ENV = process.env;
23
+ const unpkgHost = 'https://foo.com';
20
24
  const packageJSON = { name: '@servicetitan/example-mfe', cli: { 'web-component': true } };
21
25
  const tsconfigJSON = { compilerOptions: { outDir: 'dist' } };
22
26
  const metadataJSON = { name: `${packageJSON.name}-hash` };
@@ -36,7 +40,7 @@ describe(`[startup] ${UploadSourcemaps.name}`, () => {
36
40
 
37
41
  beforeEach(() => {
38
42
  jest.clearAllMocks();
39
- jest.mocked(isCI).mockReturnValue(false);
43
+ jest.mocked(getUnpkgHost).mockReturnValue(unpkgHost);
40
44
 
41
45
  // eslint-disable-next-line @typescript-eslint/naming-convention
42
46
  process.env = { DATADOG_API_KEY: 'datadog-api-key' };
@@ -62,13 +66,23 @@ describe(`[startup] ${UploadSourcemaps.name}`, () => {
62
66
  path.join(outDir, 'bundle'),
63
67
  `--service=${packageJSON.name.replace('@servicetitan/', '')}`,
64
68
  `--release-version=${args.releaseVersion}`,
65
- `--minified-path-prefix=https://unpkg.servicetitan.com/${packageJSON.name}@${args.releaseVersion}/${outDir}/bundle`,
69
+ `--minified-path-prefix=${unpkgHost}/${packageJSON.name}@${args.releaseVersion}/${outDir}/bundle`,
66
70
  `--project-path=${metadataJSON.name}/`,
67
71
  ].join(' '),
68
72
  { stdio: 'inherit' }
69
73
  );
70
74
  });
71
75
 
76
+ describe('with --registry', () => {
77
+ beforeEach(() => (args.registry = 'https://verdaccio.st.dev'));
78
+
79
+ test('uses host associated with registry', async () => {
80
+ await subject();
81
+
82
+ expect(getUnpkgHost).toHaveBeenCalledWith(args.registry);
83
+ });
84
+ });
85
+
72
86
  describe('with "--dry"', () => {
73
87
  beforeEach(() => (args.dry = true));
74
88
 
@@ -92,18 +106,18 @@ describe(`[startup] ${UploadSourcemaps.name}`, () => {
92
106
  describe('when DATADOG_API_KEY is not set', () => {
93
107
  beforeEach(() => delete process.env.DATADOG_API_KEY);
94
108
 
95
- itThrowsError('DATADOG_API_KEY environment variable is not set');
109
+ test('logs warning', async () => {
110
+ await subject();
96
111
 
97
- describe('when in CI environment', () => {
98
- beforeEach(() => jest.mocked(isCI).mockReturnValue(true));
112
+ expect(log.warning).toHaveBeenCalledWith(
113
+ 'DATADOG_API_KEY environment variable is not set; skipping sourcemaps'
114
+ );
115
+ });
99
116
 
100
- test('logs warning', async () => {
101
- await subject();
117
+ test('does not run datadog-ci', async () => {
118
+ await subject();
102
119
 
103
- expect(log.warning).toHaveBeenCalledWith(
104
- 'DATADOG_API_KEY environment variable is not set; skipping sourcemaps'
105
- );
106
- });
120
+ expect(execSync).not.toHaveBeenCalled();
107
121
  });
108
122
  });
109
123
 
@@ -1,8 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import { npmWhoAmI } from '@servicetitan/install';
2
+ import { isCI } from '@servicetitan/install';
3
3
  import chalk from 'chalk';
4
4
  import Table from 'cli-table3';
5
- import readline from 'readline/promises';
6
5
  import {
7
6
  formatRelativeDate,
8
7
  getPackages,
@@ -11,17 +10,19 @@ import {
11
10
  logErrors,
12
11
  PackageType,
13
12
  } from '../../utils';
14
- import { isTTY, NPMPackageInfo, npmView, runCommand } from '../utils';
13
+ import { NPMPackageInfo, npmView } from '../utils';
15
14
  import type { entry } from './registry/mfe-list';
16
15
  import { Command } from './types';
17
- import { DEFAULT_MFE_REGISTRY } from './utils';
16
+ import { login, PROD_MFE_REGISTRY } from './utils';
18
17
 
19
18
  const collator = new Intl.Collator();
20
19
 
21
20
  export class MFEList extends Command<typeof entry> {
22
21
  @logErrors
23
22
  async execute() {
24
- await this.login();
23
+ if (!isCI()) {
24
+ await login(this.registry);
25
+ }
25
26
 
26
27
  this.packageNames.forEach((name, index) => {
27
28
  const info = npmView({ packageName: name, registry: this.registry });
@@ -97,36 +98,6 @@ export class MFEList extends Command<typeof entry> {
97
98
  );
98
99
  }
99
100
 
100
- private async ask(question: string) {
101
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
102
- const answer = await rl.question(question);
103
- rl.close();
104
- return answer.trim().toLowerCase();
105
- }
106
-
107
- private async login() {
108
- if (
109
- this.registry !== DEFAULT_MFE_REGISTRY ||
110
- npmWhoAmI({ registry: this.registry }) !== undefined
111
- ) {
112
- return;
113
- }
114
-
115
- const message = `This machine is not authorized to access ${this.registry}.`;
116
- if (!isTTY()) {
117
- throw new Error(message);
118
- }
119
-
120
- const answer = await this.ask(chalk.bold.cyan(`${message} Authorize? [Y/n] `));
121
- if (answer && answer !== 'y') {
122
- throw new Error('Not authorized');
123
- }
124
-
125
- await runCommand(`npx --yes verdaccio-okta-oauth@latest --registry=${this.registry}`, {
126
- quiet: true,
127
- });
128
- }
129
-
130
101
  private get limit() {
131
102
  if (this.args.all) {
132
103
  return Number.MAX_SAFE_INTEGER;
@@ -147,6 +118,6 @@ export class MFEList extends Command<typeof entry> {
147
118
  }
148
119
 
149
120
  private get registry() {
150
- return this.args.registry ?? DEFAULT_MFE_REGISTRY;
121
+ return this.args.registry ?? PROD_MFE_REGISTRY;
151
122
  }
152
123
  }
@@ -2,7 +2,7 @@ import { getBranchesConfigs, isWebComponent, log, logErrors, readJson } from '..
2
2
  import { gitGetBranch, npmGetPackageVersionsDetails, npmUnpublish, Version } from '../utils';
3
3
  import type { entry } from './registry/mfe-package-clean';
4
4
  import { Command } from './types';
5
- import { DEFAULT_MFE_REGISTRY } from './utils';
5
+ import { getMfeRegistry } from './utils';
6
6
 
7
7
  export class MFEPackageClean extends Command<typeof entry> {
8
8
  @logErrors
@@ -80,7 +80,7 @@ export class MFEPackageClean extends Command<typeof entry> {
80
80
  branches = [gitGetBranch()];
81
81
  }
82
82
 
83
- const registry = this.args.registry ?? DEFAULT_MFE_REGISTRY;
83
+ const registry = getMfeRegistry(this.args.registry);
84
84
 
85
85
  return { count, registry, branches };
86
86
  }
@@ -23,7 +23,7 @@ import {
23
23
  } from '../utils';
24
24
  import type { entry } from './registry/mfe-package-publish';
25
25
  import { Command } from './types';
26
- import { DEFAULT_MFE_REGISTRY, buildRollbackTag, purgeCache } from './utils';
26
+ import { buildRollbackTag, getMfeRegistry, purgeCache } from './utils';
27
27
 
28
28
  interface PublishData {
29
29
  branch: string;
@@ -63,9 +63,9 @@ export class MFEPackagePublish extends Command<typeof entry> {
63
63
 
64
64
  await this.maybePublishPackage(packageJson, data);
65
65
 
66
- const { dry, tag } = data;
66
+ const { dry, registry, tag } = data;
67
67
  if (this.args.purgeCache !== false && !dry) {
68
- purgeCache({ packageName: packageJson.name, tag });
68
+ purgeCache({ packageName: packageJson.name, registry, tag });
69
69
  }
70
70
 
71
71
  if (data.uploadSourcemaps) {
@@ -148,10 +148,12 @@ export class MFEPackagePublish extends Command<typeof entry> {
148
148
  }
149
149
  }
150
150
 
151
- private uploadSourcemaps({ dry, version }: PublishData) {
152
- const options = [...[dry && '--dry'], `--releaseVersion=${version}`].filter(
153
- option => !!option
154
- ) as string[];
151
+ private uploadSourcemaps({ dry, registry, version }: PublishData) {
152
+ const options = [
153
+ ...[dry && '--dry'],
154
+ `--releaseVersion=${version}`,
155
+ `--registry=${registry}`,
156
+ ].filter(option => !!option) as string[];
155
157
 
156
158
  runCommand(`npx startup upload-sourcemaps ${options.join(' ')}`);
157
159
  }
@@ -163,7 +165,7 @@ export class MFEPackagePublish extends Command<typeof entry> {
163
165
 
164
166
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
165
167
  const buildVersion = cli.build || getDefaultBuildVersion(branch, gitGetCommitHash());
166
- const registry = cli.registry ?? DEFAULT_MFE_REGISTRY;
168
+ const registry = getMfeRegistry(cli.registry);
167
169
  const tag = cli.tag ?? branchConfig?.publishTag ?? '';
168
170
  const uploadSourcemaps = cli.uploadSourcemaps ?? branchConfig?.uploadSourcemaps ?? true;
169
171
  const version = '0.0.0-' + buildVersion;
@@ -2,7 +2,7 @@ import { log, logErrors, readJson } from '../../utils';
2
2
  import { DRY_RUN_PREFIX, npmTagVersion, npmView } from '../utils';
3
3
  import type { entry } from './registry/mfe-package-rollback';
4
4
  import { Command } from './types';
5
- import { DEFAULT_MFE_REGISTRY, buildRollbackTag, purgeCache } from './utils';
5
+ import { buildRollbackTag, getMfeRegistry, purgeCache } from './utils';
6
6
 
7
7
  interface PackageJson {
8
8
  name: string;
@@ -20,15 +20,16 @@ export class MFEPackageRollback extends Command<typeof entry> {
20
20
  log.warning('DRY-RUN MODE ENABLED, WILL NOT PERFORM ROLLBACK');
21
21
  }
22
22
 
23
- const packageName = await this.handleRollback();
23
+ const registry = getMfeRegistry(this.args.registry);
24
+ const packageName = await this.handleRollback(registry);
24
25
 
25
26
  if (packageName && this.args.purgeCache !== false && !dry) {
26
- purgeCache({ packageName, tag });
27
+ purgeCache({ packageName, registry, tag });
27
28
  }
28
29
  }
29
30
 
30
- private async handleRollback() {
31
- const { tag, registry = DEFAULT_MFE_REGISTRY, dry } = this.args;
31
+ private async handleRollback(registry: string) {
32
+ const { tag, dry } = this.args;
32
33
 
33
34
  const packageJson = readJson<PackageJson>('package.json');
34
35
  const packageName = packageJson.name;