@servicetitan/startup 39.1.0 → 39.3.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/dist/vite/config/base-config.js +1 -1
- package/dist/vite/config/base-config.js.map +1 -1
- package/dist/vite/config/create-resolve-config.d.ts +1 -2
- package/dist/vite/config/create-resolve-config.d.ts.map +1 -1
- package/dist/vite/config/create-resolve-config.js +2 -21
- package/dist/vite/config/create-resolve-config.js.map +1 -1
- package/package.json +21 -22
- 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/src/vite/config/__tests__/create-resolve-config.test.ts +6 -37
- package/src/vite/config/base-config.ts +1 -1
- package/src/vite/config/create-resolve-config.ts +8 -22
- 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
|
@@ -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
|
});
|
|
@@ -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(
|
|
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
|
|
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
|
-
|
|
109
|
+
test('logs warning', async () => {
|
|
110
|
+
await subject();
|
|
96
111
|
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
expect(log.warning).toHaveBeenCalledWith(
|
|
113
|
+
'DATADOG_API_KEY environment variable is not set; skipping sourcemaps'
|
|
114
|
+
);
|
|
115
|
+
});
|
|
99
116
|
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
test('does not run datadog-ci', async () => {
|
|
118
|
+
await subject();
|
|
102
119
|
|
|
103
|
-
|
|
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 {
|
|
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 {
|
|
13
|
+
import { NPMPackageInfo, npmView } from '../utils';
|
|
15
14
|
import type { entry } from './registry/mfe-list';
|
|
16
15
|
import { Command } from './types';
|
|
17
|
-
import {
|
|
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
|
-
|
|
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 ??
|
|
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 {
|
|
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
|
|
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 {
|
|
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 = [
|
|
153
|
-
|
|
154
|
-
|
|
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
|
|
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 {
|
|
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
|
|
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,
|
|
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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isCI } from '@servicetitan/install';
|
|
1
2
|
import { getPackages, isWebComponent, logErrors, PackageType } from '../../utils';
|
|
2
3
|
import { lernaExec } from '../utils';
|
|
3
4
|
import { entry as mfePackageClean } from './registry/mfe-package-clean';
|
|
@@ -5,6 +6,7 @@ import { entry as mfePackagePublish } from './registry/mfe-package-publish';
|
|
|
5
6
|
import { entry as mfePackageRollback } from './registry/mfe-package-rollback';
|
|
6
7
|
import type { entry } from './registry/mfe-publish';
|
|
7
8
|
import { Command } from './types';
|
|
9
|
+
import { getMfeRegistry, login } from './utils';
|
|
8
10
|
|
|
9
11
|
type MFEPublishOptions = (typeof entry)['options'] &
|
|
10
12
|
(typeof mfePackagePublish)['options'] &
|
|
@@ -25,6 +27,10 @@ export class MFEPublish extends Command<{ options: MFEPublishOptions }> {
|
|
|
25
27
|
throw new Error('no packages found for publication');
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
if (!isCI()) {
|
|
31
|
+
await login(this.registry);
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
const isRollback = !!this.args.rollback;
|
|
29
35
|
const isClean = !!this.args.clean;
|
|
30
36
|
|
|
@@ -48,26 +54,21 @@ export class MFEPublish extends Command<{ options: MFEPublishOptions }> {
|
|
|
48
54
|
});
|
|
49
55
|
}
|
|
50
56
|
|
|
57
|
+
private get registry() {
|
|
58
|
+
return getMfeRegistry(this.args.registry);
|
|
59
|
+
}
|
|
60
|
+
|
|
51
61
|
getPublishOptions() {
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
branch,
|
|
55
|
-
dry,
|
|
56
|
-
force,
|
|
57
|
-
purgeCache,
|
|
58
|
-
registry,
|
|
59
|
-
tag,
|
|
60
|
-
uploadSourcemaps,
|
|
61
|
-
trackHistory,
|
|
62
|
-
} = this.args;
|
|
62
|
+
const { build, branch, dry, force, purgeCache, tag, uploadSourcemaps, trackHistory } =
|
|
63
|
+
this.args;
|
|
63
64
|
return [
|
|
65
|
+
`--registry ${this.registry}`,
|
|
64
66
|
...[branch && `--branch ${branch}`],
|
|
65
67
|
...[build && `--build ${build}`],
|
|
66
68
|
...[dry && '--dry'],
|
|
67
69
|
...[force && '--force'],
|
|
68
70
|
...[purgeCache === true && '--purge-cache'],
|
|
69
71
|
...[purgeCache === false && '--no-purge-cache'],
|
|
70
|
-
...[registry && `--registry ${registry}`],
|
|
71
72
|
...[typeof tag === 'string' && `--tag ${tag}`],
|
|
72
73
|
...[trackHistory === true && '--track-history'],
|
|
73
74
|
...[trackHistory === false && '--no-track-history'],
|
|
@@ -77,22 +78,22 @@ export class MFEPublish extends Command<{ options: MFEPublishOptions }> {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
getRollbackOptions() {
|
|
80
|
-
const { dry,
|
|
81
|
+
const { dry, tag } = this.args;
|
|
81
82
|
return [
|
|
83
|
+
`--registry ${this.registry}`,
|
|
82
84
|
...[dry && '--dry'],
|
|
83
|
-
...[registry && `--registry ${registry}`],
|
|
84
85
|
...[typeof tag === 'string' && `--tag ${tag}`],
|
|
85
86
|
].filter(item => !!item) as string[];
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
getCleanOptions() {
|
|
89
|
-
const { all, branch, count, dry
|
|
90
|
+
const { all, branch, count, dry } = this.args;
|
|
90
91
|
return [
|
|
92
|
+
`--registry ${this.registry}`,
|
|
91
93
|
...[all && '--all'],
|
|
92
94
|
...[typeof branch === 'string' && `--branch ${branch}`],
|
|
93
95
|
...[count && `--count ${count}`],
|
|
94
96
|
...[dry && '--dry'],
|
|
95
|
-
...[registry && `--registry ${registry}`],
|
|
96
97
|
].filter(item => !!item) as string[];
|
|
97
98
|
}
|
|
98
99
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandEntry } from '../types';
|
|
2
|
+
import { PROD_MFE_REGISTRY } from '../utils/get-mfe-registry';
|
|
2
3
|
import { defineEntry } from './define-entry';
|
|
3
4
|
|
|
4
5
|
export const entry = defineEntry({
|
|
@@ -19,7 +20,11 @@ export const entry = defineEntry({
|
|
|
19
20
|
description: 'List only the specified number of published versions',
|
|
20
21
|
},
|
|
21
22
|
packageNames: { array: true, string: true, hidden: true },
|
|
22
|
-
registry: {
|
|
23
|
+
registry: {
|
|
24
|
+
string: true,
|
|
25
|
+
description: 'List packages published to the specified registry',
|
|
26
|
+
defaultDescription: PROD_MFE_REGISTRY,
|
|
27
|
+
},
|
|
23
28
|
tagged: { boolean: true, description: 'List only tagged versions' },
|
|
24
29
|
},
|
|
25
30
|
} satisfies CommandEntry);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandEntry } from '../types';
|
|
2
|
+
import { getMfeRegistry } from '../utils/get-mfe-registry';
|
|
2
3
|
import { defineEntry } from './define-entry';
|
|
3
4
|
|
|
4
5
|
export const entry = defineEntry({
|
|
@@ -22,6 +23,11 @@ export const entry = defineEntry({
|
|
|
22
23
|
boolean: true,
|
|
23
24
|
description: 'Take no action and only log what would be unpublished',
|
|
24
25
|
},
|
|
25
|
-
registry: {
|
|
26
|
+
registry: {
|
|
27
|
+
string: true,
|
|
28
|
+
hidden: false,
|
|
29
|
+
description: 'Registry to remove old versions from',
|
|
30
|
+
defaultDescription: getMfeRegistry(),
|
|
31
|
+
},
|
|
26
32
|
},
|
|
27
33
|
} satisfies CommandEntry);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandEntry } from '../types';
|
|
2
|
+
import { getMfeRegistry } from '../utils/get-mfe-registry';
|
|
2
3
|
import { defineEntry } from './define-entry';
|
|
3
4
|
|
|
4
5
|
export const entry = defineEntry({
|
|
@@ -21,7 +22,12 @@ export const entry = defineEntry({
|
|
|
21
22
|
boolean: true,
|
|
22
23
|
description: 'Force publishing from an unrecognized branch',
|
|
23
24
|
},
|
|
24
|
-
registry: {
|
|
25
|
+
registry: {
|
|
26
|
+
string: true,
|
|
27
|
+
hidden: false,
|
|
28
|
+
description: 'Registry to publish to',
|
|
29
|
+
defaultDescription: getMfeRegistry(),
|
|
30
|
+
},
|
|
25
31
|
trackHistory: {
|
|
26
32
|
boolean: true,
|
|
27
33
|
description: 'Tag the previous release, to support rollbacks',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandEntry } from '../types';
|
|
2
|
+
import { getMfeRegistry } from '../utils/get-mfe-registry';
|
|
2
3
|
import { defineEntry } from './define-entry';
|
|
3
4
|
|
|
4
5
|
export const entry = defineEntry({
|
|
@@ -9,8 +10,9 @@ export const entry = defineEntry({
|
|
|
9
10
|
},
|
|
10
11
|
registry: {
|
|
11
12
|
string: true,
|
|
12
|
-
hidden:
|
|
13
|
-
description: 'Registry
|
|
13
|
+
hidden: false,
|
|
14
|
+
description: 'Registry to roll back within',
|
|
15
|
+
defaultDescription: getMfeRegistry(),
|
|
14
16
|
},
|
|
15
17
|
tag: {
|
|
16
18
|
string: true,
|
|
@@ -4,6 +4,7 @@ import { defineEntry } from './define-entry';
|
|
|
4
4
|
export const entry = defineEntry({
|
|
5
5
|
options: {
|
|
6
6
|
dry: { boolean: true, description: 'Dry run mode' },
|
|
7
|
+
registry: { string: true, hidden: true, description: 'Registry url' },
|
|
7
8
|
releaseVersion: {
|
|
8
9
|
string: true,
|
|
9
10
|
demandOption: true,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isCI } from '@servicetitan/install';
|
|
2
1
|
import { execSync } from 'child_process';
|
|
3
2
|
import path from 'path';
|
|
4
3
|
import { getTsConfig, isWebComponent, log, logErrors, readJson } from '../../utils';
|
|
5
4
|
import { TSConfig } from '../utils';
|
|
6
5
|
import type { entry } from './registry/upload-sourcemaps';
|
|
7
6
|
import { Command } from './types';
|
|
7
|
+
import { getUnpkgHost } from './utils';
|
|
8
8
|
|
|
9
9
|
interface PackageJson {
|
|
10
10
|
name: string;
|
|
@@ -29,11 +29,7 @@ export class UploadSourcemaps extends Command<typeof entry> {
|
|
|
29
29
|
|
|
30
30
|
private checkArgs() {
|
|
31
31
|
if (!process.env.DATADOG_API_KEY) {
|
|
32
|
-
|
|
33
|
-
if (!isCI()) {
|
|
34
|
-
throw new Error(message);
|
|
35
|
-
}
|
|
36
|
-
log.warning(`${message}; skipping sourcemaps`);
|
|
32
|
+
log.warning('DATADOG_API_KEY environment variable is not set; skipping sourcemaps');
|
|
37
33
|
return false;
|
|
38
34
|
}
|
|
39
35
|
|
|
@@ -52,7 +48,8 @@ export class UploadSourcemaps extends Command<typeof entry> {
|
|
|
52
48
|
|
|
53
49
|
private getMinifiedPrefixPath() {
|
|
54
50
|
const { name } = this.getPackageJson();
|
|
55
|
-
const
|
|
51
|
+
const host = getUnpkgHost(this.args.registry);
|
|
52
|
+
const baseUrl = `${host}/${name}@${this.args.releaseVersion}`;
|
|
56
53
|
return `${baseUrl}/${this.getBundleDir().replace(/\\/g, '/')}`;
|
|
57
54
|
}
|
|
58
55
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PROD_MFE_REGISTRY, getMfeRegistry } from '../get-mfe-registry';
|
|
2
|
+
|
|
3
|
+
describe(`[startup] ${getMfeRegistry.name}`, () => {
|
|
4
|
+
let registry: string | undefined;
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.clearAllMocks();
|
|
8
|
+
registry = undefined;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const subject = () => getMfeRegistry(registry);
|
|
12
|
+
|
|
13
|
+
test('returns the production registry', () => {
|
|
14
|
+
expect(subject()).toBe(PROD_MFE_REGISTRY);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('with an explicit registry', () => {
|
|
18
|
+
beforeEach(() => (registry = 'https://foo.com'));
|
|
19
|
+
|
|
20
|
+
test('returns the specified registry', () => {
|
|
21
|
+
expect(subject()).toBe(registry);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DEV_MFE_REGISTRY, getMfeRegistry, PROD_MFE_REGISTRY } from '../get-mfe-registry';
|
|
2
|
+
import { getUnpkgHost } from '../get-unpkg-host';
|
|
3
|
+
|
|
4
|
+
jest.mock('../get-mfe-registry', () => ({
|
|
5
|
+
...jest.requireActual('../get-mfe-registry'),
|
|
6
|
+
getMfeRegistry: jest.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
describe(`[startup] ${getUnpkgHost.name}`, () => {
|
|
10
|
+
const registry = 'http://foo.com';
|
|
11
|
+
|
|
12
|
+
const subject = () => getUnpkgHost(registry);
|
|
13
|
+
|
|
14
|
+
test('fetches MFE registry', () => {
|
|
15
|
+
subject();
|
|
16
|
+
|
|
17
|
+
expect(getMfeRegistry).toHaveBeenCalledWith(registry);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe.each([
|
|
21
|
+
[DEV_MFE_REGISTRY, 'https://unpkg.st.dev'],
|
|
22
|
+
[PROD_MFE_REGISTRY, 'https://unpkg.servicetitan.com'],
|
|
23
|
+
])('when the MFE registry is %s', (mfeRegistry, expected) => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
jest.mocked(getMfeRegistry).mockImplementation(() => mfeRegistry);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test(`returns ${expected}`, () => {
|
|
29
|
+
expect(subject()).toBe(expected);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|