@servicetitan/startup 32.1.0 → 32.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/build.d.ts +36 -7
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +35 -10
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +9 -10
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js +6 -22
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/clean.d.ts +2 -2
- package/dist/cli/commands/clean.d.ts.map +1 -1
- package/dist/cli/commands/clean.js +16 -4
- package/dist/cli/commands/clean.js.map +1 -1
- package/dist/cli/commands/convert-eslint-config.d.ts +2 -2
- package/dist/cli/commands/convert-eslint-config.d.ts.map +1 -1
- package/dist/cli/commands/convert-eslint-config.js +3 -4
- package/dist/cli/commands/convert-eslint-config.js.map +1 -1
- package/dist/cli/commands/eslint.d.ts +3 -5
- package/dist/cli/commands/eslint.d.ts.map +1 -1
- package/dist/cli/commands/eslint.js +2 -18
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/get-command.d.ts.map +1 -1
- package/dist/cli/commands/get-command.js +2 -0
- package/dist/cli/commands/get-command.js.map +1 -1
- package/dist/cli/commands/index.d.ts +0 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +0 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +10 -6
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +9 -8
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.d.ts +21 -7
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +33 -11
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/kendo-ui-license.d.ts +3 -3
- package/dist/cli/commands/kendo-ui-license.d.ts.map +1 -1
- package/dist/cli/commands/kendo-ui-license.js +17 -5
- package/dist/cli/commands/kendo-ui-license.js.map +1 -1
- package/dist/cli/commands/lint.d.ts +31 -12
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js +34 -13
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-list.d.ts +46 -0
- package/dist/cli/commands/mfe-list.d.ts.map +1 -0
- package/dist/cli/commands/mfe-list.js +200 -0
- package/dist/cli/commands/mfe-list.js.map +1 -0
- package/dist/cli/commands/mfe-package-clean.d.ts +29 -5
- package/dist/cli/commands/mfe-package-clean.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +28 -5
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.d.ts +37 -5
- package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +36 -5
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +17 -4
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js +37 -7
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/prepare-package.d.ts +3 -5
- package/dist/cli/commands/prepare-package.d.ts.map +1 -1
- package/dist/cli/commands/prepare-package.js +2 -18
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/review/review.d.ts +14 -6
- package/dist/cli/commands/review/review.d.ts.map +1 -1
- package/dist/cli/commands/review/review.js +27 -23
- package/dist/cli/commands/review/review.js.map +1 -1
- package/dist/cli/commands/run-task.d.ts +10 -6
- package/dist/cli/commands/run-task.d.ts.map +1 -1
- package/dist/cli/commands/run-task.js +16 -13
- package/dist/cli/commands/run-task.js.map +1 -1
- package/dist/cli/commands/start.d.ts +28 -7
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +27 -10
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/styles-check.d.ts +2 -2
- package/dist/cli/commands/styles-check.d.ts.map +1 -1
- package/dist/cli/commands/styles-check.js +2 -1
- package/dist/cli/commands/styles-check.js.map +1 -1
- package/dist/cli/commands/test/runners/vitest.js +2 -1
- package/dist/cli/commands/test/runners/vitest.js.map +1 -1
- package/dist/cli/commands/test/tests.d.ts +14 -5
- package/dist/cli/commands/test/tests.d.ts.map +1 -1
- package/dist/cli/commands/test/tests.js +26 -13
- package/dist/cli/commands/test/tests.js.map +1 -1
- package/dist/cli/commands/types.d.ts +13 -4
- package/dist/cli/commands/types.d.ts.map +1 -1
- package/dist/cli/commands/types.js +28 -0
- package/dist/cli/commands/types.js.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.d.ts +3 -5
- package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +5 -20
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +48 -39
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/tasks/swc-compile-package.d.ts +2 -2
- package/dist/cli/tasks/swc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/swc-compile-package.js.map +1 -1
- package/dist/cli/tasks/tsc-compile-package.d.ts +2 -2
- package/dist/cli/tasks/tsc-compile-package.d.ts.map +1 -1
- package/dist/cli/tasks/tsc-compile-package.js +1 -1
- package/dist/cli/tasks/tsc-compile-package.js.map +1 -1
- package/dist/cli/tasks/tsc-compile.d.ts +2 -2
- package/dist/cli/tasks/tsc-compile.d.ts.map +1 -1
- package/dist/cli/tasks/tsc-compile.js.map +1 -1
- package/dist/cli/utils/bundle.js +2 -2
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/cli-npm.d.ts +14 -0
- package/dist/cli/utils/cli-npm.d.ts.map +1 -1
- package/dist/cli/utils/cli-npm.js +44 -0
- package/dist/cli/utils/cli-npm.js.map +1 -1
- package/dist/cli/utils/cli-os.d.ts +2 -2
- package/dist/cli/utils/cli-os.d.ts.map +1 -1
- package/dist/cli/utils/cli-os.js +13 -9
- package/dist/cli/utils/cli-os.js.map +1 -1
- package/dist/cli/utils/eslint.d.ts +2 -1
- package/dist/cli/utils/eslint.d.ts.map +1 -1
- package/dist/cli/utils/eslint.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/is-tty.d.ts +2 -0
- package/dist/cli/utils/is-tty.d.ts.map +1 -0
- package/dist/cli/utils/is-tty.js +15 -0
- package/dist/cli/utils/is-tty.js.map +1 -0
- package/dist/cli/utils/maybe-create-git-folder.d.ts +1 -1
- package/dist/cli/utils/maybe-create-git-folder.d.ts.map +1 -1
- package/dist/cli/utils/maybe-create-git-folder.js +12 -6
- package/dist/cli/utils/maybe-create-git-folder.js.map +1 -1
- package/dist/cli/utils/process-tree.d.ts.map +1 -1
- package/dist/cli/utils/process-tree.js +2 -2
- package/dist/cli/utils/process-tree.js.map +1 -1
- package/dist/cli/utils/set-node-options.d.ts.map +1 -1
- package/dist/cli/utils/set-node-options.js +2 -1
- package/dist/cli/utils/set-node-options.js.map +1 -1
- package/dist/utils/find-packages.d.ts +1 -0
- package/dist/utils/find-packages.d.ts.map +1 -1
- package/dist/utils/find-packages.js.map +1 -1
- package/dist/utils/format-relative-date.d.ts +2 -0
- package/dist/utils/format-relative-date.d.ts.map +1 -0
- package/dist/utils/format-relative-date.js +60 -0
- package/dist/utils/format-relative-date.js.map +1 -0
- package/dist/utils/get-configuration.d.ts +10 -3
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +1 -0
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-jest-config.d.ts.map +1 -1
- package/dist/utils/get-jest-config.js +20 -9
- package/dist/utils/get-jest-config.js.map +1 -1
- package/dist/utils/get-packages.d.ts +3 -5
- package/dist/utils/get-packages.d.ts.map +1 -1
- package/dist/utils/get-packages.js +1 -4
- package/dist/utils/get-packages.js.map +1 -1
- package/dist/utils/get-startup-version.d.ts.map +1 -1
- package/dist/utils/get-startup-version.js +1 -1
- package/dist/utils/get-startup-version.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/omit.d.ts +2 -0
- package/dist/utils/omit.d.ts.map +1 -0
- package/dist/utils/omit.js +28 -0
- package/dist/utils/omit.js.map +1 -0
- package/dist/webpack/configs/loaders/style-loader.d.ts +1 -1
- package/dist/webpack/configs/loaders/style-loader.d.ts.map +1 -1
- package/dist/webpack/configs/loaders/style-loader.js +2 -2
- package/dist/webpack/configs/loaders/style-loader.js.map +1 -1
- package/dist/webpack/configs/optimization-config.js +5 -5
- package/dist/webpack/configs/optimization-config.js.map +1 -1
- package/dist/webpack/configs/output-config.d.ts.map +1 -1
- package/dist/webpack/configs/output-config.js +14 -7
- package/dist/webpack/configs/output-config.js.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.d.ts.map +1 -1
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js +10 -3
- package/dist/webpack/configs/plugins/assets-manifest-plugin.js.map +1 -1
- package/package.json +26 -20
- package/src/cli/commands/__tests__/build.test.ts +1 -1
- package/src/cli/commands/__tests__/bundle-package.test.ts +22 -2
- package/src/cli/commands/__tests__/install.test.ts +42 -4
- package/src/cli/commands/__tests__/lint.test.ts +1 -1
- package/src/cli/commands/__tests__/mfe-list.test.ts +394 -0
- package/src/cli/commands/__tests__/mfe-publish.test.ts +25 -0
- package/src/cli/commands/__tests__/start.test.ts +1 -1
- package/src/cli/commands/build.ts +14 -10
- package/src/cli/commands/bundle-package.ts +19 -13
- package/src/cli/commands/clean.ts +2 -4
- package/src/cli/commands/convert-eslint-config.ts +3 -5
- package/src/cli/commands/eslint.ts +3 -5
- package/src/cli/commands/get-command.ts +2 -0
- package/src/cli/commands/index.ts +0 -1
- package/src/cli/commands/init.ts +7 -8
- package/src/cli/commands/install.ts +24 -11
- package/src/cli/commands/kendo-ui-license.ts +4 -6
- package/src/cli/commands/lint.ts +19 -19
- package/src/cli/commands/mfe-list.ts +173 -0
- package/src/cli/commands/mfe-package-clean.ts +25 -4
- package/src/cli/commands/mfe-package-publish.ts +33 -4
- package/src/cli/commands/mfe-publish.ts +37 -6
- package/src/cli/commands/prepare-package.ts +3 -5
- package/src/cli/commands/review/review.ts +9 -9
- package/src/cli/commands/run-task.ts +15 -11
- package/src/cli/commands/start.ts +12 -10
- package/src/cli/commands/styles-check.ts +2 -2
- package/src/cli/commands/test/__tests__/tests.test.ts +1 -1
- package/src/cli/commands/test/runners/__tests__/vitest.test.ts +82 -13
- package/src/cli/commands/test/runners/vitest.ts +4 -2
- package/src/cli/commands/test/tests.ts +20 -10
- package/src/cli/commands/types.ts +14 -4
- package/src/cli/commands/upload-sourcemaps.ts +3 -5
- package/src/cli/index.ts +59 -36
- package/src/cli/tasks/swc-compile-package.ts +2 -2
- package/src/cli/tasks/tsc-compile-package.ts +4 -3
- package/src/cli/tasks/tsc-compile.ts +2 -2
- package/src/cli/utils/__tests__/bundle.test.ts +13 -0
- package/src/cli/utils/__tests__/cli-npm.test.ts +89 -0
- package/src/cli/utils/__tests__/is-tty.test.ts +17 -0
- package/src/cli/utils/__tests__/maybe-create-git-folder.test.ts +10 -17
- package/src/cli/utils/__tests__/set-node-options.test.ts +10 -10
- package/src/cli/utils/bundle.ts +2 -2
- package/src/cli/utils/cli-npm.ts +34 -0
- package/src/cli/utils/cli-os.ts +12 -25
- package/src/cli/utils/eslint.ts +2 -1
- package/src/cli/utils/index.ts +1 -0
- package/src/cli/utils/is-tty.ts +3 -0
- package/src/cli/utils/maybe-create-git-folder.ts +10 -8
- package/src/cli/utils/process-tree.ts +4 -2
- package/src/cli/utils/set-node-options.ts +2 -1
- package/src/utils/__tests__/format-relative-date.test.ts +61 -0
- package/src/utils/__tests__/get-jest-config.test.ts +44 -0
- package/src/utils/__tests__/get-packages.test.ts +3 -0
- package/src/utils/find-packages.ts +1 -0
- package/src/utils/format-relative-date.ts +33 -0
- package/src/utils/get-configuration.ts +7 -2
- package/src/utils/get-jest-config.ts +36 -18
- package/src/utils/get-packages.ts +3 -9
- package/src/utils/get-startup-version.ts +1 -3
- package/src/utils/index.ts +2 -0
- package/src/utils/omit.ts +12 -0
- package/src/webpack/__mocks__/style-rules.ts +3 -3
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +6 -14
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +52 -29
- package/src/webpack/configs/loaders/style-loader.ts +5 -2
- package/src/webpack/configs/optimization-config.ts +5 -5
- package/src/webpack/configs/output-config.ts +10 -5
- package/src/webpack/configs/plugins/assets-manifest-plugin.ts +11 -4
- package/dist/cli/commands/get-user-commands.d.ts +0 -7
- package/dist/cli/commands/get-user-commands.d.ts.map +0 -1
- package/dist/cli/commands/get-user-commands.js +0 -27
- package/dist/cli/commands/get-user-commands.js.map +0 -1
- package/src/cli/commands/__tests__/get-user-commands.test.ts +0 -27
- package/src/cli/commands/get-user-commands.ts +0 -19
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import Table from 'cli-table3';
|
|
3
|
+
import { fs, vol } from 'memfs';
|
|
4
|
+
import { createInterface } from 'readline/promises';
|
|
5
|
+
import { formatRelativeDate, toArray } from '../../../utils';
|
|
6
|
+
import { isTTY, npmView, npmWhoAmI, runCommand } from '../../utils';
|
|
7
|
+
import { MFEList } from '../mfe-list';
|
|
8
|
+
|
|
9
|
+
jest.mock('cli-table3');
|
|
10
|
+
jest.mock('fs', () => fs);
|
|
11
|
+
jest.mock('readline/promises', () => ({
|
|
12
|
+
createInterface: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
jest.mock('../../utils', () => ({
|
|
15
|
+
...jest.requireActual('../../utils'),
|
|
16
|
+
isTTY: jest.fn(),
|
|
17
|
+
npmView: jest.fn(),
|
|
18
|
+
npmWhoAmI: jest.fn(),
|
|
19
|
+
runCommand: jest.fn(),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
describe(`[startup] ${MFEList.name}`, () => {
|
|
23
|
+
const DEFAULT_LIMIT = 20;
|
|
24
|
+
const TOTAL_VERSIONS = DEFAULT_LIMIT + 1;
|
|
25
|
+
const mfeName = 'foo';
|
|
26
|
+
let distTags: Record<string, string>;
|
|
27
|
+
let time: Record<string, string>;
|
|
28
|
+
let args: ConstructorParameters<typeof MFEList>[0];
|
|
29
|
+
|
|
30
|
+
function volFromJSON(overrides: Record<string, any> = {}) {
|
|
31
|
+
vol.fromJSON({
|
|
32
|
+
'package.json': JSON.stringify({ workspaces: ['packages/*'] }),
|
|
33
|
+
'packages/lib/package.json': JSON.stringify({ name: 'lib' }),
|
|
34
|
+
'packages/mfe/package.json': JSON.stringify({
|
|
35
|
+
name: mfeName,
|
|
36
|
+
cli: { 'web-component': true },
|
|
37
|
+
}),
|
|
38
|
+
...overrides,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
const versions = Array.from(new Array(TOTAL_VERSIONS), makeVersion);
|
|
44
|
+
time = versions.reduce<Record<string, string>>((result, version, index) => {
|
|
45
|
+
result[version] = hourAgo(index + 1).toISOString();
|
|
46
|
+
return result;
|
|
47
|
+
}, {});
|
|
48
|
+
distTags = {
|
|
49
|
+
dev: versions[0],
|
|
50
|
+
other: versions[0], // version with multiple tags
|
|
51
|
+
qa: versions[5],
|
|
52
|
+
stage: versions[10],
|
|
53
|
+
prod: versions[15],
|
|
54
|
+
latest: versions[DEFAULT_LIMIT],
|
|
55
|
+
};
|
|
56
|
+
args = { _: [] }; // eslint-disable-line @typescript-eslint/naming-convention
|
|
57
|
+
jest.clearAllMocks();
|
|
58
|
+
jest.spyOn(process.stdout, 'write').mockImplementation(jest.fn()); // suppress output
|
|
59
|
+
jest.mocked(npmWhoAmI).mockReturnValue('Foo');
|
|
60
|
+
jest.mocked(npmView).mockImplementation(({ packageName }) => ({
|
|
61
|
+
'name': packageName,
|
|
62
|
+
'version': distTags?.latest,
|
|
63
|
+
'dist-tags': distTags,
|
|
64
|
+
'time': {
|
|
65
|
+
created: hourAgo(24).toDateString(),
|
|
66
|
+
modified: new Date().toISOString(),
|
|
67
|
+
...time,
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
volFromJSON();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
afterEach(() => vol.reset());
|
|
74
|
+
|
|
75
|
+
const subject = () => new MFEList(args).execute();
|
|
76
|
+
|
|
77
|
+
function hourAgo(count: number) {
|
|
78
|
+
const date = new Date();
|
|
79
|
+
date.setHours(date.getHours() - count);
|
|
80
|
+
return date;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function makeVersion() {
|
|
84
|
+
const hash = Math.floor(Math.random() * 1e8).toString(16);
|
|
85
|
+
return `0.0.0-master.${hash}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface ExpectTableInfo {
|
|
89
|
+
name: string;
|
|
90
|
+
tags: Record<string, string>;
|
|
91
|
+
versions: [string, string][];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function expectCaption({
|
|
95
|
+
name,
|
|
96
|
+
version,
|
|
97
|
+
total,
|
|
98
|
+
}: {
|
|
99
|
+
name: string;
|
|
100
|
+
version?: string;
|
|
101
|
+
total: number;
|
|
102
|
+
}) {
|
|
103
|
+
const caption = [
|
|
104
|
+
chalk.bold.cyan(name),
|
|
105
|
+
version && `version: ${version}`,
|
|
106
|
+
`versions: ${total}`,
|
|
107
|
+
]
|
|
108
|
+
.filter(el => !!el)
|
|
109
|
+
.join(' | ');
|
|
110
|
+
|
|
111
|
+
expect(jest.mocked(process.stdout.write)).toHaveBeenCalledWith(caption + '\n');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function expectTable(info: ExpectTableInfo | ExpectTableInfo[]) {
|
|
115
|
+
if (Array.isArray(info) && info.length === 0) {
|
|
116
|
+
expect(jest.mocked(Table).mock.instances).toHaveLength(0);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
toArray(info).forEach(({ name, tags, versions }, index) => {
|
|
121
|
+
const table = jest.mocked(Table).mock.instances[index];
|
|
122
|
+
const pushes = jest.mocked(table.push).mock.calls.map((...args) => args[0][0]);
|
|
123
|
+
|
|
124
|
+
const versionTags = Object.entries(tags).reduce<Record<string, string[]>>(
|
|
125
|
+
(result, [tag, version]) => {
|
|
126
|
+
result[version] = [...(result[version] ?? []), tag];
|
|
127
|
+
return result;
|
|
128
|
+
},
|
|
129
|
+
{}
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
expectCaption({ name, version: tags.latest, total: TOTAL_VERSIONS });
|
|
133
|
+
|
|
134
|
+
expect(pushes).toEqual([
|
|
135
|
+
...versions.map(([version, when]) => [
|
|
136
|
+
version,
|
|
137
|
+
versionTags[version] ? chalk.bold.cyan(versionTags[version].join(', ')) : '',
|
|
138
|
+
formatRelativeDate(when),
|
|
139
|
+
]),
|
|
140
|
+
]);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function itOmitsTable() {
|
|
145
|
+
test('omits table', async () => {
|
|
146
|
+
await subject();
|
|
147
|
+
|
|
148
|
+
expectTable([]);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
test(`outputs table with last ${DEFAULT_LIMIT} published versions`, async () => {
|
|
153
|
+
await subject();
|
|
154
|
+
|
|
155
|
+
expect(Table).toHaveBeenCalledWith({
|
|
156
|
+
head: ['Version', 'Tag', 'When'].map(title => chalk.bold.cyan(title)),
|
|
157
|
+
style: { head: [] },
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expectTable({
|
|
161
|
+
name: mfeName,
|
|
162
|
+
tags: distTags,
|
|
163
|
+
versions: Object.entries(time).slice(0, DEFAULT_LIMIT),
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
describe('when MFE has no versions', () => {
|
|
168
|
+
beforeEach(() => {
|
|
169
|
+
jest.mocked(npmView).mockImplementation(
|
|
170
|
+
({ packageName }) => ({ name: packageName }) as any
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
itOmitsTable();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe('when MFE has no "latest" tag', () => {
|
|
178
|
+
beforeEach(() => delete distTags.latest);
|
|
179
|
+
|
|
180
|
+
test('outputs table', async () => {
|
|
181
|
+
await subject();
|
|
182
|
+
|
|
183
|
+
expectTable({
|
|
184
|
+
name: mfeName,
|
|
185
|
+
tags: distTags,
|
|
186
|
+
versions: Object.entries(time).slice(0, DEFAULT_LIMIT),
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe('with --tagged', () => {
|
|
192
|
+
beforeEach(() => (args.tagged = true));
|
|
193
|
+
|
|
194
|
+
test('outputs only tagged versions', async () => {
|
|
195
|
+
await subject();
|
|
196
|
+
|
|
197
|
+
expectTable({
|
|
198
|
+
name: mfeName,
|
|
199
|
+
tags: distTags,
|
|
200
|
+
versions: [...new Set(Object.values(distTags))].map(version => [
|
|
201
|
+
version,
|
|
202
|
+
time[version],
|
|
203
|
+
]),
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe('when MFE has no tags', () => {
|
|
208
|
+
beforeEach(() => ((distTags as any) = undefined));
|
|
209
|
+
|
|
210
|
+
itOmitsTable();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
describe('with --registry', () => {
|
|
215
|
+
beforeEach(() => (args.registry = 'https://verdaccio.st.dev'));
|
|
216
|
+
|
|
217
|
+
test('passes registry to npmView', async () => {
|
|
218
|
+
await subject();
|
|
219
|
+
|
|
220
|
+
expect(npmView).toHaveBeenCalledWith({
|
|
221
|
+
packageName: mfeName,
|
|
222
|
+
registry: args.registry,
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
describe('with --all', () => {
|
|
228
|
+
beforeEach(() => (args.all = true));
|
|
229
|
+
|
|
230
|
+
test('outputs all published versions', async () => {
|
|
231
|
+
await subject();
|
|
232
|
+
|
|
233
|
+
expectTable([
|
|
234
|
+
{
|
|
235
|
+
name: mfeName,
|
|
236
|
+
tags: distTags,
|
|
237
|
+
versions: Object.entries(time),
|
|
238
|
+
},
|
|
239
|
+
]);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe('with --limit', () => {
|
|
244
|
+
beforeEach(() => (args.limit = 5));
|
|
245
|
+
|
|
246
|
+
test('outputs specified number of versions', async () => {
|
|
247
|
+
await subject();
|
|
248
|
+
|
|
249
|
+
expectTable([
|
|
250
|
+
{
|
|
251
|
+
name: mfeName,
|
|
252
|
+
tags: distTags,
|
|
253
|
+
versions: Object.entries(time).slice(0, args.limit),
|
|
254
|
+
},
|
|
255
|
+
]);
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
describe('when workspace has no MFEs', () => {
|
|
260
|
+
beforeEach(() => vol.reset());
|
|
261
|
+
|
|
262
|
+
itOmitsTable();
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
describe('when workspace has multiple MFEs', () => {
|
|
266
|
+
const otherMfeName = `${mfeName}2`; // ensure sorts after first name
|
|
267
|
+
|
|
268
|
+
beforeEach(() => {
|
|
269
|
+
volFromJSON({
|
|
270
|
+
'packages/mfe2/package.json': JSON.stringify({
|
|
271
|
+
name: otherMfeName,
|
|
272
|
+
cli: { 'web-component': true },
|
|
273
|
+
}),
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
test('outputs published versions for all MFEs', async () => {
|
|
278
|
+
await subject();
|
|
279
|
+
|
|
280
|
+
expectTable([
|
|
281
|
+
{
|
|
282
|
+
name: mfeName,
|
|
283
|
+
tags: distTags,
|
|
284
|
+
versions: Object.entries(time).slice(0, DEFAULT_LIMIT),
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
name: otherMfeName,
|
|
288
|
+
tags: distTags,
|
|
289
|
+
versions: Object.entries(time).slice(0, DEFAULT_LIMIT),
|
|
290
|
+
},
|
|
291
|
+
]);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
describe('with MFE name', () => {
|
|
295
|
+
beforeEach(() => (args._ = [otherMfeName]));
|
|
296
|
+
|
|
297
|
+
test('outputs only specified MFE', async () => {
|
|
298
|
+
await subject();
|
|
299
|
+
|
|
300
|
+
expectTable({
|
|
301
|
+
name: otherMfeName,
|
|
302
|
+
tags: distTags,
|
|
303
|
+
versions: Object.entries(time).slice(0, DEFAULT_LIMIT),
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
describe('with --ignore', () => {
|
|
309
|
+
beforeEach(() => (args.ignore = mfeName));
|
|
310
|
+
|
|
311
|
+
test('omits specified MFE', async () => {
|
|
312
|
+
await subject();
|
|
313
|
+
|
|
314
|
+
expectTable({
|
|
315
|
+
name: otherMfeName,
|
|
316
|
+
tags: distTags,
|
|
317
|
+
versions: Object.entries(time).slice(0, DEFAULT_LIMIT),
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
describe('with non-existent MFE name', () => {
|
|
323
|
+
beforeEach(() => {
|
|
324
|
+
jest.mocked(npmView).mockReturnValue(undefined);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
itOmitsTable();
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe('when machine is not authorized', () => {
|
|
332
|
+
const readline = { question: jest.fn(), close: jest.fn() };
|
|
333
|
+
let answer: string;
|
|
334
|
+
|
|
335
|
+
beforeEach(() => {
|
|
336
|
+
answer = 'Y';
|
|
337
|
+
jest.mocked(readline.question).mockImplementation(() => Promise.resolve(answer));
|
|
338
|
+
jest.mocked(createInterface).mockReturnValue(readline as any);
|
|
339
|
+
jest.mocked(npmWhoAmI).mockReturnValue(undefined);
|
|
340
|
+
jest.mocked(isTTY).mockReturnValue(true);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test('prompts and authorizes machine', async () => {
|
|
344
|
+
await subject();
|
|
345
|
+
|
|
346
|
+
expect(readline.question).toHaveBeenCalledWith(
|
|
347
|
+
expect.stringMatching(/machine is not authorized.*Authorize\? \[Y\/n\]/)
|
|
348
|
+
);
|
|
349
|
+
expect(readline.close).toHaveBeenCalled();
|
|
350
|
+
expect(runCommand).toHaveBeenCalledWith(
|
|
351
|
+
'npx --yes verdaccio-okta-oauth@latest --registry=https://verdaccio.servicetitan.com',
|
|
352
|
+
{ quiet: true }
|
|
353
|
+
);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
describe('when user does not answer', () => {
|
|
357
|
+
beforeEach(() => (answer = ''));
|
|
358
|
+
|
|
359
|
+
test('authorizes machine', async () => {
|
|
360
|
+
await subject();
|
|
361
|
+
|
|
362
|
+
expect(runCommand).toHaveBeenCalled();
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
describe('when user declines', () => {
|
|
367
|
+
beforeEach(() => (answer = 'n'));
|
|
368
|
+
|
|
369
|
+
test('throws error', async () => {
|
|
370
|
+
await expect(subject()).rejects.toThrow(/Not authorized/);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
describe('when terminal is not interactive', () => {
|
|
375
|
+
beforeEach(() => jest.mocked(isTTY).mockReturnValue(false));
|
|
376
|
+
|
|
377
|
+
test('skips prompt and throws error', async () => {
|
|
378
|
+
await expect(subject()).rejects.toThrow(/machine is not authorized/);
|
|
379
|
+
|
|
380
|
+
expect(readline.question).not.toHaveBeenCalled();
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
describe('with --registry', () => {
|
|
385
|
+
beforeEach(() => (args.registry = 'https://verdaccio.st.dev'));
|
|
386
|
+
|
|
387
|
+
test('skips check whether machine is authorized', async () => {
|
|
388
|
+
await subject();
|
|
389
|
+
|
|
390
|
+
expect(npmWhoAmI).not.toHaveBeenCalled();
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
});
|
|
@@ -3,6 +3,8 @@ import { lernaExec } from '../../utils';
|
|
|
3
3
|
import { Package, PackageType, getPackages } from '../../../utils';
|
|
4
4
|
import { createPackage } from '../../../__mocks__';
|
|
5
5
|
|
|
6
|
+
import { MFEPackageClean } from '../mfe-package-clean';
|
|
7
|
+
import { MFEPackagePublish } from '../mfe-package-publish';
|
|
6
8
|
import { MFEPublish } from '../mfe-publish';
|
|
7
9
|
|
|
8
10
|
jest.mock('fs', () => fs);
|
|
@@ -209,4 +211,27 @@ describe(`[startup] ${MFEPublish.name}`, () => {
|
|
|
209
211
|
});
|
|
210
212
|
});
|
|
211
213
|
});
|
|
214
|
+
|
|
215
|
+
describe('options', () => {
|
|
216
|
+
const subject = () => MFEPublish.options;
|
|
217
|
+
|
|
218
|
+
test('groups publish and clean options', () => {
|
|
219
|
+
expect(subject()).toEqual(
|
|
220
|
+
expect.objectContaining({
|
|
221
|
+
...Object.fromEntries(
|
|
222
|
+
Object.entries(MFEPackagePublish.options).map(([key, value]) => [
|
|
223
|
+
key,
|
|
224
|
+
{ group: 'Publish Options:', ...value },
|
|
225
|
+
])
|
|
226
|
+
),
|
|
227
|
+
...Object.fromEntries(
|
|
228
|
+
Object.entries(MFEPackageClean.options).map(([key, value]) => [
|
|
229
|
+
Object.hasOwn(MFEPackagePublish.options, key) ? `${key}\u00A0` : key,
|
|
230
|
+
{ group: 'Clean Options:', ...value },
|
|
231
|
+
])
|
|
232
|
+
),
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
212
237
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getPackages, logErrors, PackageType } from '../../utils';
|
|
2
2
|
import { checkArgs, compile, lernaExec, typeCheck, ProcessTree } from '../utils';
|
|
3
3
|
import { kendoUILicense } from './kendo-ui-license';
|
|
4
|
-
import { Command } from './types';
|
|
4
|
+
import { Command, CommandArgs } from './types';
|
|
5
5
|
|
|
6
|
-
interface Args {
|
|
6
|
+
interface Args extends CommandArgs {
|
|
7
7
|
'cdn-path'?: string;
|
|
8
8
|
'code-coverage'?: boolean;
|
|
9
9
|
'config'?: string;
|
|
@@ -22,14 +22,18 @@ enum BuildProcesses {
|
|
|
22
22
|
BundlePackage,
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export class Build
|
|
26
|
-
readonly
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
export class Build extends Command<Args> {
|
|
26
|
+
static readonly description = 'Build project for production';
|
|
27
|
+
static readonly greedy = true;
|
|
28
|
+
static readonly options = {
|
|
29
|
+
'cdn-path': { string: true, description: 'Base url for application assets' },
|
|
30
|
+
'code-coverage': { boolean: true, description: 'Instrument code for coverage analysis?' },
|
|
31
|
+
'config': { string: true, hidden: true, description: 'Use specified configuration' },
|
|
32
|
+
'ignore': { array: true, description: 'Packages to skip' },
|
|
33
|
+
'scope': { array: true, description: 'Packages to build' },
|
|
34
|
+
'stat': { boolean: true, description: 'Generate bundle report?' },
|
|
35
|
+
'use-tsc': { boolean: true, description: 'Use tsc to compile packages?' },
|
|
36
|
+
};
|
|
33
37
|
|
|
34
38
|
@logErrors
|
|
35
39
|
async execute() {
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { getTsConfig, log, logErrors } from '../../utils';
|
|
2
2
|
import { bundle, getModuleType } from '../utils';
|
|
3
|
-
import { Command } from '
|
|
3
|
+
import { Command, CommandArgs } from './types';
|
|
4
4
|
|
|
5
|
-
interface Args {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
interface Args extends CommandArgs {
|
|
6
|
+
codeCoverage?: boolean;
|
|
7
|
+
config?: string;
|
|
8
|
+
exposedDependencies?: boolean;
|
|
9
|
+
stat?: boolean;
|
|
10
|
+
useWatchConfig?: boolean;
|
|
11
|
+
watch?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export class BundlePackage
|
|
14
|
-
constructor(private readonly args: Args) {}
|
|
15
|
-
|
|
14
|
+
export class BundlePackage extends Command<Args> {
|
|
16
15
|
@logErrors
|
|
17
16
|
async execute() {
|
|
18
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
config,
|
|
19
|
+
codeCoverage,
|
|
20
|
+
exposedDependencies: emitExposedDependencies,
|
|
21
|
+
stat = false,
|
|
22
|
+
useWatchConfig,
|
|
23
|
+
watch,
|
|
24
|
+
} = this.args;
|
|
19
25
|
|
|
20
26
|
if (getModuleType(getTsConfig()) !== 'esnext') {
|
|
21
27
|
log.warning(
|
|
@@ -23,11 +29,11 @@ export class BundlePackage implements Command {
|
|
|
23
29
|
);
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
const emitExposedDependencies = this.args['exposed-dependencies'];
|
|
27
32
|
const options: Parameters<typeof bundle>[0] = {
|
|
28
33
|
...(emitExposedDependencies ? {} : { config }),
|
|
29
|
-
codeCoverage
|
|
34
|
+
codeCoverage,
|
|
30
35
|
emitExposedDependencies,
|
|
36
|
+
useWatchConfig,
|
|
31
37
|
};
|
|
32
38
|
|
|
33
39
|
await bundle({ buildStat: stat, ...options, watch });
|
|
@@ -2,10 +2,8 @@ import { exec, execSync } from 'child_process';
|
|
|
2
2
|
import { log, logErrors } from '../../utils';
|
|
3
3
|
import { Command } from './types';
|
|
4
4
|
|
|
5
|
-
export class Clean
|
|
6
|
-
description
|
|
7
|
-
return 'reset project to fresh state';
|
|
8
|
-
}
|
|
5
|
+
export class Clean extends Command {
|
|
6
|
+
static readonly description = 'Reset project to fresh state';
|
|
9
7
|
|
|
10
8
|
@logErrors
|
|
11
9
|
async execute() {
|
|
@@ -40,7 +40,9 @@ interface Recipe {
|
|
|
40
40
|
import: { as: string; from?: string };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export class ConvertEslintConfig
|
|
43
|
+
export class ConvertEslintConfig extends Command {
|
|
44
|
+
static readonly description = 'Convert v8.x eslintrc.json to v9.x flat config';
|
|
45
|
+
|
|
44
46
|
private static readonly recipes: Record<string, Recipe | null> = {
|
|
45
47
|
'@servicetitan/eslint-config/mono': {
|
|
46
48
|
import: { as: 'mono' },
|
|
@@ -74,10 +76,6 @@ export class ConvertEslintConfig implements Command {
|
|
|
74
76
|
'prettier': null,
|
|
75
77
|
};
|
|
76
78
|
|
|
77
|
-
description() {
|
|
78
|
-
return 'convert v8.x eslintrc.json to v9.x flat config';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
79
|
@logErrors
|
|
82
80
|
async execute() {
|
|
83
81
|
if (!fs.existsSync(oldConfigFile)) {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { Command } from '.';
|
|
2
1
|
import { logErrors } from '../../utils';
|
|
3
2
|
import { eslint } from '../utils';
|
|
3
|
+
import { Command, CommandArgs } from './types';
|
|
4
4
|
|
|
5
|
-
interface Args {
|
|
5
|
+
interface Args extends CommandArgs {
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
7
|
_: string[];
|
|
8
8
|
fix?: boolean;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export class ESLintCommand
|
|
12
|
-
constructor(private readonly args: Args) {}
|
|
13
|
-
|
|
11
|
+
export class ESLintCommand extends Command<Args> {
|
|
14
12
|
@logErrors
|
|
15
13
|
async execute() {
|
|
16
14
|
const { _: paths, fix } = this.args;
|
|
@@ -9,6 +9,7 @@ import { Init } from './init';
|
|
|
9
9
|
import { Install } from './install';
|
|
10
10
|
import { KendoUILicense } from './kendo-ui-license';
|
|
11
11
|
import { Lint } from './lint';
|
|
12
|
+
import { MFEList } from './mfe-list';
|
|
12
13
|
import { MFEPackageClean } from './mfe-package-clean';
|
|
13
14
|
import { MFEPackagePublish } from './mfe-package-publish';
|
|
14
15
|
import { MFEPublish } from './mfe-publish';
|
|
@@ -31,6 +32,7 @@ const commands: Record<CommandName, Newable<Command>> = {
|
|
|
31
32
|
[CommandName.install]: Install,
|
|
32
33
|
[CommandName['kendo-ui-license']]: KendoUILicense,
|
|
33
34
|
[CommandName.lint]: Lint,
|
|
35
|
+
[CommandName['mfe-list']]: MFEList,
|
|
34
36
|
[CommandName['mfe-package-clean']]: MFEPackageClean,
|
|
35
37
|
[CommandName['mfe-package-publish']]: MFEPackagePublish,
|
|
36
38
|
[CommandName['mfe-publish']]: MFEPublish,
|
package/src/cli/commands/init.ts
CHANGED
|
@@ -3,20 +3,19 @@ import path from 'path';
|
|
|
3
3
|
|
|
4
4
|
import { log, logErrors } from '../../utils';
|
|
5
5
|
import { gitCloneRepo, gitIsReachable } from '../utils';
|
|
6
|
-
import { Command } from './types';
|
|
6
|
+
import { Command, CommandArgs } from './types';
|
|
7
7
|
|
|
8
|
-
interface Args {
|
|
8
|
+
interface Args extends CommandArgs {
|
|
9
9
|
output?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const REPO_NAME = 'frontend-example';
|
|
13
13
|
|
|
14
|
-
export class Init
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
export class Init extends Command<Args> {
|
|
15
|
+
static readonly description = 'Create example project';
|
|
16
|
+
static readonly options = {
|
|
17
|
+
output: { string: true, description: 'Output path' },
|
|
18
|
+
};
|
|
20
19
|
|
|
21
20
|
@logErrors
|
|
22
21
|
async execute() {
|