@servicetitan/startup 39.1.0 → 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.
- package/dist/cli/commands/mfe-list.d.ts +0 -2
- package/dist/cli/commands/mfe-list.d.ts.map +1 -1
- package/dist/cli/commands/mfe-list.js +4 -30
- package/dist/cli/commands/mfe-list.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +1 -2
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +7 -5
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-rollback.js +5 -3
- package/dist/cli/commands/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +1 -0
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +14 -12
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/registry/command-registry.d.ts +13 -4
- package/dist/cli/commands/registry/command-registry.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-list.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-list.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-list.js +3 -1
- package/dist/cli/commands/registry/mfe-list.js.map +1 -1
- package/dist/cli/commands/registry/mfe-package-clean.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-package-clean.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-package-clean.js +4 -2
- package/dist/cli/commands/registry/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/registry/mfe-package-publish.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-package-publish.js +4 -2
- package/dist/cli/commands/registry/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/registry/mfe-package-rollback.d.ts +2 -1
- package/dist/cli/commands/registry/mfe-package-rollback.d.ts.map +1 -1
- package/dist/cli/commands/registry/mfe-package-rollback.js +4 -2
- package/dist/cli/commands/registry/mfe-package-rollback.js.map +1 -1
- package/dist/cli/commands/registry/upload-sourcemaps.d.ts +5 -0
- package/dist/cli/commands/registry/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/registry/upload-sourcemaps.js +5 -0
- package/dist/cli/commands/registry/upload-sourcemaps.js.map +1 -1
- package/dist/cli/commands/review/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +4 -7
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/commands/utils/get-mfe-registry.d.ts +4 -0
- package/dist/cli/commands/utils/get-mfe-registry.d.ts.map +1 -0
- package/dist/cli/commands/utils/get-mfe-registry.js +28 -0
- package/dist/cli/commands/utils/get-mfe-registry.js.map +1 -0
- package/dist/cli/commands/utils/get-unpkg-host.d.ts +2 -0
- package/dist/cli/commands/utils/get-unpkg-host.d.ts.map +1 -0
- package/dist/cli/commands/utils/get-unpkg-host.js +18 -0
- package/dist/cli/commands/utils/get-unpkg-host.js.map +1 -0
- package/dist/cli/commands/utils/index.d.ts +3 -1
- package/dist/cli/commands/utils/index.d.ts.map +1 -1
- package/dist/cli/commands/utils/index.js +3 -1
- package/dist/cli/commands/utils/index.js.map +1 -1
- package/dist/cli/commands/utils/login.d.ts +2 -0
- package/dist/cli/commands/utils/login.d.ts.map +1 -0
- package/dist/cli/commands/utils/login.js +56 -0
- package/dist/cli/commands/utils/login.js.map +1 -0
- package/dist/cli/commands/utils/purge-cache.d.ts.map +1 -1
- package/dist/cli/commands/utils/purge-cache.js +2 -4
- package/dist/cli/commands/utils/purge-cache.js.map +1 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/index.js.map +1 -1
- package/package.json +15 -16
- package/src/cli/commands/__tests__/mfe-list.test.ts +25 -56
- package/src/cli/commands/__tests__/mfe-package-clean.test.ts +6 -0
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +52 -47
- package/src/cli/commands/__tests__/mfe-package-rollback.test.ts +4 -2
- package/src/cli/commands/__tests__/mfe-publish.test.ts +51 -14
- package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +27 -13
- package/src/cli/commands/mfe-list.ts +7 -36
- package/src/cli/commands/mfe-package-clean.ts +2 -2
- package/src/cli/commands/mfe-package-publish.ts +10 -8
- package/src/cli/commands/mfe-package-rollback.ts +6 -5
- package/src/cli/commands/mfe-publish.ts +17 -16
- package/src/cli/commands/registry/mfe-list.ts +6 -1
- package/src/cli/commands/registry/mfe-package-clean.ts +7 -1
- package/src/cli/commands/registry/mfe-package-publish.ts +7 -1
- package/src/cli/commands/registry/mfe-package-rollback.ts +4 -2
- package/src/cli/commands/registry/upload-sourcemaps.ts +1 -0
- package/src/cli/commands/upload-sourcemaps.ts +4 -7
- package/src/cli/commands/utils/__tests__/get-mfe-registry.test.ts +24 -0
- package/src/cli/commands/utils/__tests__/get-unpkg-host.test.ts +32 -0
- package/src/cli/commands/utils/__tests__/login.test.ts +122 -0
- package/src/cli/commands/utils/__tests__/purge-cache.test.ts +17 -15
- package/src/cli/commands/utils/get-mfe-registry.ts +6 -0
- package/src/cli/commands/utils/get-unpkg-host.ts +8 -0
- package/src/cli/commands/utils/index.ts +3 -1
- package/src/cli/commands/utils/login.ts +38 -0
- package/src/cli/commands/utils/purge-cache.ts +2 -5
- package/src/cli/index.ts +2 -1
- package/dist/cli/commands/utils/constants.d.ts +0 -2
- package/dist/cli/commands/utils/constants.d.ts.map +0 -1
- package/dist/cli/commands/utils/constants.js +0 -13
- package/dist/cli/commands/utils/constants.js.map +0 -1
- package/src/cli/commands/utils/constants.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/startup",
|
|
3
|
-
"version": "39.
|
|
3
|
+
"version": "39.2.0",
|
|
4
4
|
"description": "CLI to create multi-package Lerna projects with TypeScript and React",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/uikit/startup",
|
|
6
6
|
"repository": {
|
|
@@ -103,20 +103,20 @@
|
|
|
103
103
|
"@jest/core": "~30.4.2",
|
|
104
104
|
"@jest/types": "~30.4.1",
|
|
105
105
|
"@jsdevtools/coverage-istanbul-loader": "^3.0.5",
|
|
106
|
-
"@servicetitan/eslint-config": "39.
|
|
107
|
-
"@servicetitan/install": "39.
|
|
108
|
-
"@servicetitan/startup-utils": "39.
|
|
109
|
-
"@servicetitan/stylelint-config": "39.
|
|
106
|
+
"@servicetitan/eslint-config": "39.2.0",
|
|
107
|
+
"@servicetitan/install": "39.2.0",
|
|
108
|
+
"@servicetitan/startup-utils": "39.2.0",
|
|
109
|
+
"@servicetitan/stylelint-config": "39.2.0",
|
|
110
110
|
"@svgr/webpack": "^8.1.0",
|
|
111
111
|
"@swc/cli": "^0.8.1",
|
|
112
|
-
"@swc/core": "1.
|
|
112
|
+
"@swc/core": "1.16.1",
|
|
113
113
|
"@types/debug": "^4.1.12",
|
|
114
114
|
"@types/jest": "~30.0.0",
|
|
115
|
-
"@vitest/coverage-v8": "^4.1.
|
|
115
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
116
116
|
"chalk": "~4.1.2",
|
|
117
117
|
"cli-table3": "^0.6.5",
|
|
118
118
|
"cpx2": "9.0.0",
|
|
119
|
-
"css-loader": "~7.1.
|
|
119
|
+
"css-loader": "~7.1.5",
|
|
120
120
|
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
121
121
|
"debug": "^4.4.3",
|
|
122
122
|
"deepmerge": "~4.3.1",
|
|
@@ -132,15 +132,15 @@
|
|
|
132
132
|
"jest-circus": "~30.4.2",
|
|
133
133
|
"jest-environment-jsdom": "~30.4.1",
|
|
134
134
|
"jest-fetch-mock": "~4.2.0",
|
|
135
|
-
"js-yaml": "~5.
|
|
135
|
+
"js-yaml": "~5.4.1",
|
|
136
136
|
"json5": "^2.2.3",
|
|
137
137
|
"lerna": "~9.0.7",
|
|
138
|
-
"less": "~4.
|
|
138
|
+
"less": "~4.9.0",
|
|
139
139
|
"less-loader": "~13.0.0",
|
|
140
140
|
"less-plugin-npm-import": "~2.1.0",
|
|
141
141
|
"lodash.kebabcase": "^4.1.1",
|
|
142
142
|
"lodash.memoize": "^4.1.2",
|
|
143
|
-
"magic-string": "^1.
|
|
143
|
+
"magic-string": "^1.2.3",
|
|
144
144
|
"memfs": "~4.68.1",
|
|
145
145
|
"mini-css-extract-plugin": "~2.10.2",
|
|
146
146
|
"minimizer-webpack-plugin": "^5.6.1",
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
"multimatch": "~8.0.0",
|
|
149
149
|
"patch-package": "^8.0.1",
|
|
150
150
|
"portfinder": "~1.0.38",
|
|
151
|
-
"postcss": "~8.5.
|
|
151
|
+
"postcss": "~8.5.26",
|
|
152
152
|
"prettier": "~3.9.6",
|
|
153
153
|
"react-refresh": "^0.18.0",
|
|
154
154
|
"sass": "~1.102.0",
|
|
@@ -164,11 +164,11 @@
|
|
|
164
164
|
"ts-node": "~10.9.2",
|
|
165
165
|
"typed-css-modules": "~0.9.1",
|
|
166
166
|
"typescript": "6.0.3",
|
|
167
|
-
"vite": "^8.
|
|
167
|
+
"vite": "^8.2.2",
|
|
168
168
|
"vite-bundle-analyzer": "^1.3.9",
|
|
169
169
|
"vite-plugin-istanbul": "^9.0.1",
|
|
170
170
|
"vite-plugin-svgr": "^5.2.0",
|
|
171
|
-
"vitest": "^4.1.
|
|
171
|
+
"vitest": "^4.1.11",
|
|
172
172
|
"webpack": "~5.108.4",
|
|
173
173
|
"webpack-assets-manifest": "~6.5.2",
|
|
174
174
|
"webpack-bundle-analyzer": "^5.3.1",
|
|
@@ -202,6 +202,5 @@
|
|
|
202
202
|
},
|
|
203
203
|
"cli": {
|
|
204
204
|
"webpack": false
|
|
205
|
-
}
|
|
206
|
-
"gitHead": "a2471578a506e8c40e90956a5c70cc1638bbe9c1"
|
|
205
|
+
}
|
|
207
206
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { npmWhoAmI } from '@servicetitan/install';
|
|
1
|
+
import { isCI, npmWhoAmI } from '@servicetitan/install';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import Table from 'cli-table3';
|
|
4
4
|
import { vol } from 'memfs';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import { createInterface } from 'readline/promises';
|
|
7
6
|
import { formatRelativeDate, toArray } from '../../../utils';
|
|
8
|
-
import {
|
|
7
|
+
import { npmView } from '../../utils';
|
|
9
8
|
import { MFEList } from '../mfe-list';
|
|
10
9
|
import { entry } from '../registry/mfe-list';
|
|
10
|
+
import { DEV_MFE_REGISTRY, PROD_MFE_REGISTRY, login } from '../utils';
|
|
11
11
|
|
|
12
12
|
jest.mock('@servicetitan/install');
|
|
13
13
|
jest.mock('cli-table3');
|
|
14
|
+
jest.mock('../utils', () => ({
|
|
15
|
+
...jest.requireActual('../utils'),
|
|
16
|
+
login: jest.fn(),
|
|
17
|
+
}));
|
|
14
18
|
jest.mock('fs', () => require('memfs').fs);
|
|
15
19
|
jest.mock('readline/promises', () => ({
|
|
16
20
|
createInterface: jest.fn(),
|
|
@@ -30,6 +34,7 @@ describe(`[startup] ${MFEList.name}`, () => {
|
|
|
30
34
|
let distTags: Record<string, string>;
|
|
31
35
|
let time: Record<string, string>;
|
|
32
36
|
let args: ConstructorParameters<typeof MFEList>[0];
|
|
37
|
+
let ci: boolean;
|
|
33
38
|
|
|
34
39
|
function volFromJSON(overrides: Record<string, any> = {}) {
|
|
35
40
|
vol.fromJSON({
|
|
@@ -58,8 +63,10 @@ describe(`[startup] ${MFEList.name}`, () => {
|
|
|
58
63
|
latest: versions[DEFAULT_LIMIT],
|
|
59
64
|
};
|
|
60
65
|
args = { _: [] }; // eslint-disable-line @typescript-eslint/naming-convention
|
|
66
|
+
ci = false;
|
|
61
67
|
jest.clearAllMocks();
|
|
62
68
|
jest.spyOn(process.stdout, 'write').mockImplementation(jest.fn()); // suppress output
|
|
69
|
+
jest.mocked(isCI).mockImplementation(() => ci);
|
|
63
70
|
jest.mocked(npmWhoAmI).mockReturnValue('Foo');
|
|
64
71
|
jest.mocked(npmView).mockImplementation(({ packageName }) => ({
|
|
65
72
|
'name': packageName,
|
|
@@ -357,67 +364,29 @@ describe(`[startup] ${MFEList.name}`, () => {
|
|
|
357
364
|
});
|
|
358
365
|
});
|
|
359
366
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
let answer: string;
|
|
363
|
-
|
|
364
|
-
beforeEach(() => {
|
|
365
|
-
answer = 'Y';
|
|
366
|
-
jest.mocked(readline.question).mockImplementation(() => Promise.resolve(answer));
|
|
367
|
-
jest.mocked(createInterface).mockReturnValue(readline as any);
|
|
368
|
-
jest.mocked(npmWhoAmI).mockReturnValue(undefined);
|
|
369
|
-
jest.mocked(isTTY).mockReturnValue(true);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
test('prompts and authorizes machine', async () => {
|
|
373
|
-
await subject();
|
|
374
|
-
|
|
375
|
-
expect(readline.question).toHaveBeenCalledWith(
|
|
376
|
-
expect.stringMatching(/machine is not authorized.*Authorize\? \[Y\/n\]/)
|
|
377
|
-
);
|
|
378
|
-
expect(readline.close).toHaveBeenCalled();
|
|
379
|
-
expect(runCommand).toHaveBeenCalledWith(
|
|
380
|
-
'npx --yes verdaccio-okta-oauth@latest --registry=https://verdaccio.servicetitan.com',
|
|
381
|
-
{ quiet: true }
|
|
382
|
-
);
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
describe('when user does not answer', () => {
|
|
386
|
-
beforeEach(() => (answer = ''));
|
|
387
|
-
|
|
388
|
-
test('authorizes machine', async () => {
|
|
389
|
-
await subject();
|
|
390
|
-
|
|
391
|
-
expect(runCommand).toHaveBeenCalled();
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
describe('when user declines', () => {
|
|
396
|
-
beforeEach(() => (answer = 'n'));
|
|
367
|
+
test(`authorizes the machine for ${PROD_MFE_REGISTRY}`, async () => {
|
|
368
|
+
await subject();
|
|
397
369
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
});
|
|
401
|
-
});
|
|
370
|
+
expect(login).toHaveBeenCalledWith(PROD_MFE_REGISTRY);
|
|
371
|
+
});
|
|
402
372
|
|
|
403
|
-
|
|
404
|
-
|
|
373
|
+
describe('in CI environment', () => {
|
|
374
|
+
beforeEach(() => (ci = true));
|
|
405
375
|
|
|
406
|
-
|
|
407
|
-
|
|
376
|
+
test('skips authorization', async () => {
|
|
377
|
+
await subject();
|
|
408
378
|
|
|
409
|
-
|
|
410
|
-
});
|
|
379
|
+
expect(login).not.toHaveBeenCalled();
|
|
411
380
|
});
|
|
381
|
+
});
|
|
412
382
|
|
|
413
|
-
|
|
414
|
-
|
|
383
|
+
describe('with --registry', () => {
|
|
384
|
+
beforeEach(() => (args.registry = DEV_MFE_REGISTRY));
|
|
415
385
|
|
|
416
|
-
|
|
417
|
-
|
|
386
|
+
test('authorizes the machine for the specified registry', async () => {
|
|
387
|
+
await subject();
|
|
418
388
|
|
|
419
|
-
|
|
420
|
-
});
|
|
389
|
+
expect(login).toHaveBeenCalledWith(args.registry);
|
|
421
390
|
});
|
|
422
391
|
});
|
|
423
392
|
});
|
|
@@ -2,6 +2,7 @@ import { fs, vol } from 'memfs';
|
|
|
2
2
|
import { isWebComponent, log } from '../../../utils';
|
|
3
3
|
import { gitGetBranch, npmGetPackageVersionsDetails, npmUnpublish, Version } from '../../utils';
|
|
4
4
|
import { MFEPackageClean } from '../mfe-package-clean';
|
|
5
|
+
import { getMfeRegistry } from '../utils';
|
|
5
6
|
|
|
6
7
|
jest.mock('fs', () => fs);
|
|
7
8
|
jest.mock('../../../utils', () => ({
|
|
@@ -14,6 +15,10 @@ jest.mock('../../utils', () => ({
|
|
|
14
15
|
npmGetPackageVersionsDetails: jest.fn(),
|
|
15
16
|
npmUnpublish: jest.fn(),
|
|
16
17
|
}));
|
|
18
|
+
jest.mock('../utils', () => ({
|
|
19
|
+
...jest.requireActual('../utils'),
|
|
20
|
+
getMfeRegistry: jest.fn(),
|
|
21
|
+
}));
|
|
17
22
|
|
|
18
23
|
const DEFAULT_VERSIONS_TO_KEEP = 5;
|
|
19
24
|
|
|
@@ -37,6 +42,7 @@ describe(`[startup] ${MFEPackageClean.name}`, () => {
|
|
|
37
42
|
versions = getBranchVersions(gitBranch, 10);
|
|
38
43
|
|
|
39
44
|
jest.resetAllMocks();
|
|
45
|
+
jest.mocked(getMfeRegistry).mockImplementation(explicit => explicit ?? registry);
|
|
40
46
|
jest.mocked(isWebComponent).mockReturnValue(true);
|
|
41
47
|
jest.mocked(npmGetPackageVersionsDetails).mockImplementation(() => versions);
|
|
42
48
|
jest.mocked(gitGetBranch).mockImplementation(() => gitBranch);
|
|
@@ -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
|
|
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',
|
|
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
|
|
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
|
-
|
|
254
|
-
|
|
285
|
+
describe('with "uploadSourcemaps: true"', () => {
|
|
286
|
+
beforeEach(() => (args.uploadSourcemaps = true));
|
|
255
287
|
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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
|
-
|
|
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
|
|
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('
|
|
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({
|
|
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
|
-
'--':
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
'--':
|
|
165
|
-
? expected
|
|
166
|
-
|
|
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
|
-
'--':
|
|
216
|
-
|
|
217
|
-
|
|
250
|
+
'--': expect.arrayContaining(
|
|
251
|
+
Array.isArray(expected)
|
|
252
|
+
? expected
|
|
253
|
+
: [expected ?? `--${name} ${value}`]
|
|
254
|
+
),
|
|
218
255
|
})
|
|
219
256
|
);
|
|
220
257
|
});
|