@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
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import { runCommandOutput } from '../../../utils';
|
|
2
|
+
import { getUnpkgHost } from '../get-unpkg-host';
|
|
2
3
|
import { purgeCache } from '../purge-cache';
|
|
3
4
|
|
|
5
|
+
jest.mock('@servicetitan/install', () => ({ isCI: jest.fn() }));
|
|
4
6
|
jest.mock('../../../utils', () => ({
|
|
5
7
|
...jest.requireActual('../../../utils'),
|
|
6
8
|
runCommandOutput: jest.fn(),
|
|
7
9
|
}));
|
|
10
|
+
jest.mock('../get-unpkg-host', () => ({
|
|
11
|
+
getUnpkgHost: jest.fn(),
|
|
12
|
+
}));
|
|
8
13
|
|
|
9
14
|
describe(purgeCache.name, () => {
|
|
10
|
-
|
|
15
|
+
const unpkgHost = 'https://foo.com';
|
|
11
16
|
const packageName = '@servicetitan/foo';
|
|
17
|
+
const registry = 'https://bar.com';
|
|
12
18
|
const tag = 'prod';
|
|
19
|
+
let args: Parameters<typeof purgeCache>[0];
|
|
13
20
|
|
|
14
21
|
beforeEach(() => {
|
|
15
22
|
jest.clearAllMocks();
|
|
16
|
-
|
|
23
|
+
jest.mocked(getUnpkgHost).mockReturnValue(unpkgHost);
|
|
24
|
+
args = { packageName, registry, tag };
|
|
17
25
|
});
|
|
18
26
|
|
|
19
27
|
const subject = () => purgeCache(args);
|
|
20
28
|
|
|
21
|
-
test('
|
|
29
|
+
test('fetches host for registry', () => {
|
|
22
30
|
subject();
|
|
23
31
|
|
|
24
|
-
expect(
|
|
25
|
-
`npx startup mfe-purge-cache --host https://unpkg.servicetitan.com --package-name ${packageName} --tag ${tag}`
|
|
26
|
-
);
|
|
32
|
+
expect(getUnpkgHost).toHaveBeenCalledWith(registry);
|
|
27
33
|
});
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
test('runs mfe-purge-cache with host "https://unpkg.st.dev"', () => {
|
|
33
|
-
subject();
|
|
35
|
+
test('runs mfe-purge-cache', () => {
|
|
36
|
+
subject();
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
38
|
+
expect(runCommandOutput).toHaveBeenCalledWith(
|
|
39
|
+
`npx startup mfe-purge-cache --host ${unpkgHost} --package-name ${packageName} --tag ${tag}`
|
|
40
|
+
);
|
|
39
41
|
});
|
|
40
42
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DEV_MFE_REGISTRY, getMfeRegistry } from './get-mfe-registry';
|
|
2
|
+
|
|
3
|
+
const PROD_UNPKG_HOST = 'https://unpkg.servicetitan.com';
|
|
4
|
+
const DEV_UNPKG_HOST = 'https://unpkg.st.dev';
|
|
5
|
+
|
|
6
|
+
export function getUnpkgHost(registry?: string): string {
|
|
7
|
+
return getMfeRegistry(registry) === DEV_MFE_REGISTRY ? DEV_UNPKG_HOST : PROD_UNPKG_HOST;
|
|
8
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { npmWhoAmI } from '@servicetitan/install';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import readline from 'readline/promises';
|
|
4
|
+
import { isTTY, runCommand } from '../../utils';
|
|
5
|
+
import { DEV_MFE_REGISTRY, PROD_MFE_REGISTRY } from './get-mfe-registry';
|
|
6
|
+
|
|
7
|
+
const OKTA_REGISTRIES: string[] = [PROD_MFE_REGISTRY, DEV_MFE_REGISTRY];
|
|
8
|
+
|
|
9
|
+
export async function login(registry: string) {
|
|
10
|
+
if (npmWhoAmI({ registry }) !== undefined) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!OKTA_REGISTRIES.includes(registry)) {
|
|
15
|
+
throw new Error(`Registry ${registry} is not recognized. Please log in manually.`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const message = `This machine is not authorized to access ${registry}.`;
|
|
19
|
+
if (!isTTY()) {
|
|
20
|
+
throw new Error(message);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const answer = await ask(chalk.bold.cyan(`${message} Authorize? [Y/n] `));
|
|
24
|
+
if (answer && answer !== 'y') {
|
|
25
|
+
throw new Error('Not authorized');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await runCommand(`npx --yes verdaccio-okta-oauth@latest --registry=${registry}`, {
|
|
29
|
+
quiet: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function ask(question: string) {
|
|
34
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
35
|
+
const answer = await rl.question(question);
|
|
36
|
+
rl.close();
|
|
37
|
+
return answer.trim().toLowerCase();
|
|
38
|
+
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { runCommandOutput } from '../../utils';
|
|
2
|
-
|
|
3
|
-
const DEV_MFE_REGISTRY = 'https://verdaccio.st.dev';
|
|
4
|
-
const DEFAULT_UNPKG_HOST = 'https://unpkg.servicetitan.com';
|
|
5
|
-
const DEV_UNPKG_HOST = 'https://unpkg.st.dev';
|
|
2
|
+
import { getUnpkgHost } from './get-unpkg-host';
|
|
6
3
|
|
|
7
4
|
export function purgeCache(options: { packageName: string; registry?: string; tag: string }) {
|
|
8
5
|
const { packageName, registry, tag } = options;
|
|
9
|
-
const host = registry
|
|
6
|
+
const host = getUnpkgHost(registry);
|
|
10
7
|
runCommandOutput(
|
|
11
8
|
`npx startup mfe-purge-cache --host ${host} --package-name ${packageName} --tag ${tag}`
|
|
12
9
|
);
|
package/src/cli/index.ts
CHANGED
|
@@ -40,7 +40,8 @@ function addCommand(name: CommandName, y: typeof yargs) {
|
|
|
40
40
|
const { description, options: { _, ...options } = {} } = entry;
|
|
41
41
|
const nameWithArgs = name + (_?.description ? ` ${_.description}` : '');
|
|
42
42
|
const groupedOptions = Object.entries(options).reduce((result, [key, value]) => {
|
|
43
|
-
|
|
43
|
+
const suffix = /\W+$/.exec(key)?.[0] ?? ''; // fix for kebabCase dropping `\u00A0` suffixes
|
|
44
|
+
result[kebabCase(key) + suffix] = { group: 'Command Options:', ...value };
|
|
44
45
|
return result;
|
|
45
46
|
}, {} as CommandOptions);
|
|
46
47
|
const handler = (argv: any) => handleCommand(name, argv);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,uCAAuC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "DEFAULT_MFE_REGISTRY", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return DEFAULT_MFE_REGISTRY;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const DEFAULT_MFE_REGISTRY = 'https://verdaccio.servicetitan.com';
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/commands/utils/constants.ts"],"sourcesContent":["export const DEFAULT_MFE_REGISTRY = 'https://verdaccio.servicetitan.com';\n"],"names":["DEFAULT_MFE_REGISTRY"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,uBAAuB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_MFE_REGISTRY = 'https://verdaccio.servicetitan.com';
|