@ms-cloudpack/cli 0.68.2 → 0.69.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/lib/__fixtures__/commandTestSetup.d.ts +18 -0
- package/lib/__fixtures__/commandTestSetup.d.ts.map +1 -0
- package/lib/__fixtures__/commandTestSetup.js +61 -0
- package/lib/__fixtures__/commandTestSetup.js.map +1 -0
- package/lib/__fixtures__/createMockSession.d.ts +5 -2
- package/lib/__fixtures__/createMockSession.d.ts.map +1 -1
- package/lib/__fixtures__/createMockSession.js +2 -2
- package/lib/__fixtures__/createMockSession.js.map +1 -1
- package/lib/__fixtures__/getPortArgsForStart.d.ts +21 -0
- package/lib/__fixtures__/getPortArgsForStart.d.ts.map +1 -0
- package/lib/__fixtures__/getPortArgsForStart.js +36 -0
- package/lib/__fixtures__/getPortArgsForStart.js.map +1 -0
- package/lib/__fixtures__/mainWrapper.d.ts +9 -0
- package/lib/__fixtures__/mainWrapper.d.ts.map +1 -0
- package/lib/__fixtures__/mainWrapper.js +17 -0
- package/lib/__fixtures__/mainWrapper.js.map +1 -0
- package/lib/__fixtures__/mockActiveSessions.d.ts +15 -0
- package/lib/__fixtures__/mockActiveSessions.d.ts.map +1 -0
- package/lib/__fixtures__/mockActiveSessions.js +38 -0
- package/lib/__fixtures__/mockActiveSessions.js.map +1 -0
- package/lib/commands/bundle/execute.d.ts.map +1 -1
- package/lib/commands/bundle/execute.js +2 -5
- package/lib/commands/bundle/execute.js.map +1 -1
- package/lib/commands/cache/clean.d.ts.map +1 -1
- package/lib/commands/cache/clean.js +4 -3
- package/lib/commands/cache/clean.js.map +1 -1
- package/lib/commands/config/delete.d.ts +9 -0
- package/lib/commands/config/delete.d.ts.map +1 -0
- package/lib/commands/config/delete.js +22 -0
- package/lib/commands/config/delete.js.map +1 -0
- package/lib/commands/config/get.d.ts +9 -0
- package/lib/commands/config/get.d.ts.map +1 -0
- package/lib/commands/config/get.js +24 -0
- package/lib/commands/config/get.js.map +1 -0
- package/lib/commands/config/index.d.ts +3 -0
- package/lib/commands/config/index.d.ts.map +1 -0
- package/lib/commands/config/index.js +48 -0
- package/lib/commands/config/index.js.map +1 -0
- package/lib/commands/config/list.d.ts +6 -0
- package/lib/commands/config/list.d.ts.map +1 -0
- package/lib/commands/config/list.js +21 -0
- package/lib/commands/config/list.js.map +1 -0
- package/lib/commands/config/set.d.ts +10 -0
- package/lib/commands/config/set.d.ts.map +1 -0
- package/lib/commands/config/set.js +21 -0
- package/lib/commands/config/set.js.map +1 -0
- package/lib/commands/info/index.d.ts.map +1 -1
- package/lib/commands/info/index.js +3 -0
- package/lib/commands/info/index.js.map +1 -1
- package/lib/commands/init/execute.js +2 -2
- package/lib/commands/init/execute.js.map +1 -1
- package/lib/commands/init/init.d.ts +0 -2
- package/lib/commands/init/init.d.ts.map +1 -1
- package/lib/commands/init/init.js +4 -8
- package/lib/commands/init/init.js.map +1 -1
- package/lib/commands/link/execute.d.ts.map +1 -1
- package/lib/commands/link/execute.js +5 -7
- package/lib/commands/link/execute.js.map +1 -1
- package/lib/commands/link/getActiveSessions.d.ts +4 -1
- package/lib/commands/link/getActiveSessions.d.ts.map +1 -1
- package/lib/commands/link/getActiveSessions.js +3 -2
- package/lib/commands/link/getActiveSessions.js.map +1 -1
- package/lib/commands/link/getSessionToLink.d.ts +2 -0
- package/lib/commands/link/getSessionToLink.d.ts.map +1 -1
- package/lib/commands/link/getSessionToLink.js +3 -1
- package/lib/commands/link/getSessionToLink.js.map +1 -1
- package/lib/commands/setup/index.js +1 -1
- package/lib/commands/setup/index.js.map +1 -1
- package/lib/commands/start/execute.d.ts +0 -2
- package/lib/commands/start/execute.d.ts.map +1 -1
- package/lib/commands/start/execute.js +10 -18
- package/lib/commands/start/execute.js.map +1 -1
- package/lib/commands/start/index.d.ts.map +1 -1
- package/lib/commands/start/index.js +28 -1
- package/lib/commands/start/index.js.map +1 -1
- package/lib/commands/start/trackSession.d.ts.map +1 -1
- package/lib/commands/start/trackSession.js +3 -2
- package/lib/commands/start/trackSession.js.map +1 -1
- package/lib/commands/start/types/StartOptions.d.ts +6 -0
- package/lib/commands/start/types/StartOptions.d.ts.map +1 -1
- package/lib/commands/start/types/StartOptions.js.map +1 -1
- package/lib/commands/sync/execute.js +4 -4
- package/lib/commands/sync/execute.js.map +1 -1
- package/lib/commands/unlink/execute.d.ts.map +1 -1
- package/lib/commands/unlink/execute.js +5 -6
- package/lib/commands/unlink/execute.js.map +1 -1
- package/lib/types/CommandAction.d.ts +7 -8
- package/lib/types/CommandAction.d.ts.map +1 -1
- package/lib/types/CommandAction.js.map +1 -1
- package/lib/types/SharedOptions.d.ts +4 -0
- package/lib/types/SharedOptions.d.ts.map +1 -1
- package/lib/types/SharedOptions.js.map +1 -1
- package/lib/utilities/CloudpackCommand.d.ts +7 -1
- package/lib/utilities/CloudpackCommand.d.ts.map +1 -1
- package/lib/utilities/CloudpackCommand.js +6 -3
- package/lib/utilities/CloudpackCommand.js.map +1 -1
- package/lib/utilities/CommandExecutor.d.ts.map +1 -1
- package/lib/utilities/CommandExecutor.js +7 -2
- package/lib/utilities/CommandExecutor.js.map +1 -1
- package/lib/utilities/runPrerequisites.d.ts +1 -1
- package/lib/utilities/runPrerequisites.d.ts.map +1 -1
- package/lib/utilities/runPrerequisites.js +2 -2
- package/lib/utilities/runPrerequisites.js.map +1 -1
- package/lib/utilities/stopServers.d.ts +13 -0
- package/lib/utilities/stopServers.d.ts.map +1 -0
- package/lib/utilities/stopServers.js +18 -0
- package/lib/utilities/stopServers.js.map +1 -0
- package/package.json +11 -10
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const cliRoot: string;
|
|
2
|
+
export type CommandSpies = ReturnType<typeof commandBeforeAll>;
|
|
3
|
+
/**
|
|
4
|
+
* Shared setup for command tests: mock process.exit, spy on TaskReporter methods, override stdout
|
|
5
|
+
* for TaskReporter, etc. Returns an object with potentially-useful spies.
|
|
6
|
+
*/
|
|
7
|
+
export declare function commandBeforeAll(): {
|
|
8
|
+
exit: import(".store/jest-mock-npm-30.0.0-alpha.6-d61fbc299a/package").SpiedFunction<(code?: number) => never>;
|
|
9
|
+
reporterAddTask: import(".store/jest-mock-npm-30.0.0-alpha.6-d61fbc299a/package").SpiedFunction<(name: string, pending?: boolean) => import("@ms-cloudpack/task-reporter").TaskReporterTask>;
|
|
10
|
+
reporterComplete: import(".store/jest-mock-npm-30.0.0-alpha.6-d61fbc299a/package").SpiedFunction<(completeReason?: string, completedWithError?: boolean) => void>;
|
|
11
|
+
reporterStdoutOverride: import(".store/jest-mock-npm-30.0.0-alpha.6-d61fbc299a/package").Mock<(message: string) => void>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Shared `afterEach` for command tests:
|
|
15
|
+
* Stop servers if relevant, verify that exit was called, and clear mocks.
|
|
16
|
+
*/
|
|
17
|
+
export declare function commandAfterEach(spies: Pick<CommandSpies, 'exit'>): Promise<void>;
|
|
18
|
+
//# sourceMappingURL=commandTestSetup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandTestSetup.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/commandTestSetup.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,OAAO,QAA4C,CAAC;AAEjE,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,gBAAgB;;;;4GAGmB,MAAM,KAAK,IAAI;EAgCjE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,iBAavE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { expect, jest } from '@jest/globals';
|
|
2
|
+
import { setStdoutOverride, TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
3
|
+
import { disableOpenBrowser } from '../commands/start/openBrowser.js';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { findPackageRoot } from 'workspace-tools';
|
|
7
|
+
import { stopServers } from '../utilities/stopServers.js';
|
|
8
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
// eslint-disable-next-line no-restricted-properties
|
|
10
|
+
export const cliRoot = findPackageRoot(dirname) || process.cwd();
|
|
11
|
+
/**
|
|
12
|
+
* Shared setup for command tests: mock process.exit, spy on TaskReporter methods, override stdout
|
|
13
|
+
* for TaskReporter, etc. Returns an object with potentially-useful spies.
|
|
14
|
+
*/
|
|
15
|
+
export function commandBeforeAll() {
|
|
16
|
+
const reporterAddTask = jest.spyOn(TaskReporter.prototype, 'addTask');
|
|
17
|
+
const reporterComplete = jest.spyOn(TaskReporter.prototype, 'complete');
|
|
18
|
+
const reporterStdoutOverride = jest.fn();
|
|
19
|
+
setStdoutOverride({ write: reporterStdoutOverride, columns: 80 });
|
|
20
|
+
// throw if anything calls process.exit() with non-zero code
|
|
21
|
+
const exit = jest.spyOn(process, 'exit').mockImplementation(((code) => {
|
|
22
|
+
if (code && code !== 0) {
|
|
23
|
+
// If reporter.complete() was called with a reason, include it in the error message
|
|
24
|
+
// to make debugging easier (since reporter logs are hidden from the console)
|
|
25
|
+
const completeReason = reporterComplete.mock.calls[0]?.[0];
|
|
26
|
+
throw new Error(`Process exited with code ${code}${completeReason ? `. Reason:\n${completeReason}` : ''}`);
|
|
27
|
+
}
|
|
28
|
+
})); // process.exit() returns `never`
|
|
29
|
+
// only for start, but doesn't hurt for other commands
|
|
30
|
+
disableOpenBrowser();
|
|
31
|
+
// We don't want to accidentally call these utilities during a test...
|
|
32
|
+
// NOTE: for this to work, the test must not synchronously import something referencing this package
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
34
|
+
jest.unstable_mockModule('@ms-cloudpack/setup-utilities', () => ({
|
|
35
|
+
__esModule: true,
|
|
36
|
+
createCertificate: jest.fn(() => Promise.reject('not implemented')),
|
|
37
|
+
updateHostsEntry: jest.fn(() => Promise.reject('not implemented')),
|
|
38
|
+
getCertificate: jest.fn(() => Promise.reject('not implemented')),
|
|
39
|
+
}));
|
|
40
|
+
return {
|
|
41
|
+
exit,
|
|
42
|
+
reporterAddTask,
|
|
43
|
+
reporterComplete,
|
|
44
|
+
reporterStdoutOverride,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Shared `afterEach` for command tests:
|
|
49
|
+
* Stop servers if relevant, verify that exit was called, and clear mocks.
|
|
50
|
+
*/
|
|
51
|
+
export async function commandAfterEach(spies) {
|
|
52
|
+
// This is for tests that use start, and must be done before the spies.exit check
|
|
53
|
+
await stopServers();
|
|
54
|
+
const exitCalled = spies.exit.mock.calls.length > 0;
|
|
55
|
+
jest.clearAllMocks();
|
|
56
|
+
if (!exitCalled) {
|
|
57
|
+
// Give a clearer error message here
|
|
58
|
+
expect('Test did not call process.exit(). If there was an earlier failure in the test, you can ignore this one.').toEqual('Test called process.exit()');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=commandTestSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandTestSetup.js","sourceRoot":"","sources":["../../src/__fixtures__/commandTestSetup.ts"],"names":[],"mappings":"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","sourcesContent":["import { expect, jest } from '@jest/globals';\nimport { setStdoutOverride, TaskReporter } from '@ms-cloudpack/task-reporter';\nimport { disableOpenBrowser } from '../commands/start/openBrowser.js';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { findPackageRoot } from 'workspace-tools';\nimport { stopServers } from '../utilities/stopServers.js';\n\nconst dirname = path.dirname(fileURLToPath(import.meta.url));\n// eslint-disable-next-line no-restricted-properties\nexport const cliRoot = findPackageRoot(dirname) || process.cwd();\n\nexport type CommandSpies = ReturnType<typeof commandBeforeAll>;\n\n/**\n * Shared setup for command tests: mock process.exit, spy on TaskReporter methods, override stdout\n * for TaskReporter, etc. Returns an object with potentially-useful spies.\n */\nexport function commandBeforeAll() {\n const reporterAddTask = jest.spyOn(TaskReporter.prototype, 'addTask');\n const reporterComplete = jest.spyOn(TaskReporter.prototype, 'complete');\n const reporterStdoutOverride = jest.fn<(message: string) => void>();\n setStdoutOverride({ write: reporterStdoutOverride, columns: 80 });\n\n // throw if anything calls process.exit() with non-zero code\n const exit = jest.spyOn(process, 'exit').mockImplementation(((code) => {\n if (code && code !== 0) {\n // If reporter.complete() was called with a reason, include it in the error message\n // to make debugging easier (since reporter logs are hidden from the console)\n const completeReason = reporterComplete.mock.calls[0]?.[0];\n throw new Error(`Process exited with code ${code}${completeReason ? `. Reason:\\n${completeReason}` : ''}`);\n }\n }) as typeof process.exit); // process.exit() returns `never`\n\n // only for start, but doesn't hurt for other commands\n disableOpenBrowser();\n\n // We don't want to accidentally call these utilities during a test...\n // NOTE: for this to work, the test must not synchronously import something referencing this package\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n jest.unstable_mockModule<typeof import('@ms-cloudpack/setup-utilities')>('@ms-cloudpack/setup-utilities', () => ({\n __esModule: true,\n createCertificate: jest.fn(() => Promise.reject('not implemented')),\n updateHostsEntry: jest.fn(() => Promise.reject('not implemented')),\n getCertificate: jest.fn(() => Promise.reject('not implemented')),\n }));\n\n return {\n exit,\n reporterAddTask,\n reporterComplete,\n reporterStdoutOverride,\n };\n}\n\n/**\n * Shared `afterEach` for command tests:\n * Stop servers if relevant, verify that exit was called, and clear mocks.\n */\nexport async function commandAfterEach(spies: Pick<CommandSpies, 'exit'>) {\n // This is for tests that use start, and must be done before the spies.exit check\n await stopServers();\n\n const exitCalled = spies.exit.mock.calls.length > 0;\n jest.clearAllMocks();\n\n if (!exitCalled) {\n // Give a clearer error message here\n expect(\n 'Test did not call process.exit(). If there was an earlier failure in the test, you can ignore this one.',\n ).toEqual('Test called process.exit()');\n }\n}\n"]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare function createMockSession(
|
|
1
|
+
import { type Session } from '@ms-cloudpack/api-server';
|
|
2
|
+
export declare function createMockSession(params: {
|
|
3
|
+
id: string;
|
|
4
|
+
cachePath: string;
|
|
5
|
+
}): Session;
|
|
3
6
|
//# sourceMappingURL=createMockSession.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMockSession.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/createMockSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createMockSession.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/createMockSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAiBpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMockSession.js","sourceRoot":"","sources":["../../src/__fixtures__/createMockSession.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"createMockSession.js","sourceRoot":"","sources":["../../src/__fixtures__/createMockSession.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,MAAyC;IACzE,OAAO;QACL,GAAG,MAAM;QACT,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE;QACnE,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,CAAC;QACX,IAAI,EAAE,EAAE;QACR,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,CAAC;QACjB,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;QACjC,sBAAsB,EAAE,GAAG,EAAE,GAAE,CAAC;QAChC,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1B,WAAW,EAAE,EAAE;QACf,aAAa,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;QACzE,gBAAgB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;KAC7E,CAAC;AACJ,CAAC","sourcesContent":["import { type Session } from '@ms-cloudpack/api-server';\n\nexport function createMockSession(params: { id: string; cachePath: string }): Session {\n return {\n ...params,\n config: { appPath: '/path/to/app', mode: 'library', generated: {} },\n projectName: 'app',\n resolveMap: {},\n sequence: 0,\n urls: {},\n targetVersions: {},\n sessionVersion: 1,\n incrementSessionVersion: () => {},\n incrementTargetVersion: () => {},\n importMap: { imports: {} },\n linkedPaths: [],\n addLinkedPath: () => Promise.resolve({ resolveMap: {}, linkedPaths: [] }),\n removeLinkedPath: () => Promise.resolve({ resolveMap: {}, linkedPaths: [] }),\n };\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const ranges: {
|
|
2
|
+
apiServer: {
|
|
3
|
+
[k: string]: number[];
|
|
4
|
+
};
|
|
5
|
+
appServer: {
|
|
6
|
+
[k: string]: number[];
|
|
7
|
+
};
|
|
8
|
+
bundleServer: {
|
|
9
|
+
[k: string]: number[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Get the designated range of ports for a given file.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getPortsForFile(importMetaUrl: string, type: keyof typeof ranges): number[];
|
|
16
|
+
/**
|
|
17
|
+
* Get port args for the start command, with a non-overlapping ports based on the current file.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPortArgsForStart(importMetaUrl: string): string[];
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=getPortArgsForStart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPortArgsForStart.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/getPortArgsForStart.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,MAAM;;;;;;;;;;CAIX,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,MAAM,GAAG,MAAM,EAAE,CAO1F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,YASxD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { portNumbers } from 'get-port';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// New files can be added to this list to get a port range.
|
|
4
|
+
const files = ['start.e2e.test.ts', 'link.e2e.test.ts', 'unlink.e2e.test.ts', 'getActiveSessions.test.ts'];
|
|
5
|
+
const makePortNumbers = (startPort) => Object.fromEntries(files.map((file) => [file, [...portNumbers(startPort + 1, (startPort += 10))]]));
|
|
6
|
+
// These start numbers are somewhat arbitrary: currently a bit above the default ranges.
|
|
7
|
+
const ranges = {
|
|
8
|
+
apiServer: makePortNumbers(9900),
|
|
9
|
+
appServer: makePortNumbers(5010),
|
|
10
|
+
bundleServer: makePortNumbers(5510),
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Get the designated range of ports for a given file.
|
|
14
|
+
*/
|
|
15
|
+
export function getPortsForFile(importMetaUrl, type) {
|
|
16
|
+
const filename = path.basename(importMetaUrl);
|
|
17
|
+
const range = ranges[type][filename];
|
|
18
|
+
if (!range) {
|
|
19
|
+
throw new Error(`Please add ${filename} to the list of files with port ranges`);
|
|
20
|
+
}
|
|
21
|
+
return range;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get port args for the start command, with a non-overlapping ports based on the current file.
|
|
25
|
+
*/
|
|
26
|
+
export function getPortArgsForStart(importMetaUrl) {
|
|
27
|
+
return [
|
|
28
|
+
'--api-server-port',
|
|
29
|
+
`${getPortsForFile(importMetaUrl, 'apiServer').join(',')}`,
|
|
30
|
+
'--app-server-port',
|
|
31
|
+
`${getPortsForFile(importMetaUrl, 'appServer').join(',')}`,
|
|
32
|
+
'--bundle-server-port',
|
|
33
|
+
`${getPortsForFile(importMetaUrl, 'bundleServer').join(',')}`,
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=getPortArgsForStart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPortArgsForStart.js","sourceRoot":"","sources":["../../src/__fixtures__/getPortArgsForStart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,2DAA2D;AAC3D,MAAM,KAAK,GAAG,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,2BAA2B,CAAC,CAAC;AAE3G,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAE,EAAE,CAC5C,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtG,wFAAwF;AACxF,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC;IAChC,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC;IAChC,YAAY,EAAE,eAAe,CAAC,IAAI,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,aAAqB,EAAE,IAAyB;IAC9E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,wCAAwC,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,aAAqB;IACvD,OAAO;QACL,mBAAmB;QACnB,GAAG,eAAe,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC1D,mBAAmB;QACnB,GAAG,eAAe,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QAC1D,sBAAsB;QACtB,GAAG,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["import { portNumbers } from 'get-port';\nimport path from 'path';\n\n// New files can be added to this list to get a port range.\nconst files = ['start.e2e.test.ts', 'link.e2e.test.ts', 'unlink.e2e.test.ts', 'getActiveSessions.test.ts'];\n\nconst makePortNumbers = (startPort: number) =>\n Object.fromEntries(files.map((file) => [file, [...portNumbers(startPort + 1, (startPort += 10))]]));\n\n// These start numbers are somewhat arbitrary: currently a bit above the default ranges.\nconst ranges = {\n apiServer: makePortNumbers(9900),\n appServer: makePortNumbers(5010),\n bundleServer: makePortNumbers(5510),\n};\n\n/**\n * Get the designated range of ports for a given file.\n */\nexport function getPortsForFile(importMetaUrl: string, type: keyof typeof ranges): number[] {\n const filename = path.basename(importMetaUrl);\n const range = ranges[type][filename];\n if (!range) {\n throw new Error(`Please add ${filename} to the list of files with port ranges`);\n }\n return range;\n}\n\n/**\n * Get port args for the start command, with a non-overlapping ports based on the current file.\n */\nexport function getPortArgsForStart(importMetaUrl: string) {\n return [\n '--api-server-port',\n `${getPortsForFile(importMetaUrl, 'apiServer').join(',')}`,\n '--app-server-port',\n `${getPortsForFile(importMetaUrl, 'appServer').join(',')}`,\n '--bundle-server-port',\n `${getPortsForFile(importMetaUrl, 'bundleServer').join(',')}`,\n ];\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MainOptions } from '../main.js';
|
|
2
|
+
/**
|
|
3
|
+
* Call `main` with a cwd and appropriate args.
|
|
4
|
+
* Note that for the test, `options.argv` only needs to contain the verb and its args.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mainWrapper(options: Omit<MainOptions, 'cwd'> & {
|
|
7
|
+
cwd: string;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=mainWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mainWrapper.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/mainWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,iBAW9E"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { main } from '../main.js';
|
|
2
|
+
/**
|
|
3
|
+
* Call `main` with a cwd and appropriate args.
|
|
4
|
+
* Note that for the test, `options.argv` only needs to contain the verb and its args.
|
|
5
|
+
*/
|
|
6
|
+
export function mainWrapper(options) {
|
|
7
|
+
// Simulate running `cloudpack` from the command line (the first two args aren't used).
|
|
8
|
+
// Always run in quiet mode to avoid cluttering the test output with logs.
|
|
9
|
+
const argv = ['node', 'cloudpack', ...(options.argv || []), '--quiet'];
|
|
10
|
+
return main({
|
|
11
|
+
...options,
|
|
12
|
+
argv,
|
|
13
|
+
// Ensure no telemetry is sent during tests
|
|
14
|
+
disableTelemetry: true,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=mainWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mainWrapper.js","sourceRoot":"","sources":["../../src/__fixtures__/mainWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAmD;IAC7E,uFAAuF;IACvF,0EAA0E;IAC1E,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;IAEvE,OAAO,IAAI,CAAC;QACV,GAAG,OAAO;QACV,IAAI;QACJ,2CAA2C;QAC3C,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { main, type MainOptions } from '../main.js';\n\n/**\n * Call `main` with a cwd and appropriate args.\n * Note that for the test, `options.argv` only needs to contain the verb and its args.\n */\nexport function mainWrapper(options: Omit<MainOptions, 'cwd'> & { cwd: string }) {\n // Simulate running `cloudpack` from the command line (the first two args aren't used).\n // Always run in quiet mode to avoid cluttering the test output with logs.\n const argv = ['node', 'cloudpack', ...(options.argv || []), '--quiet'];\n\n return main({\n ...options,\n argv,\n // Ensure no telemetry is sent during tests\n disableTelemetry: true,\n });\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Session } from '@ms-cloudpack/common-types';
|
|
2
|
+
import type { trackSession as trackSessionType } from '../commands/start/trackSession.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mock `getActiveSessions` to return a custom list of sessions, and mock `trackSession` to add
|
|
5
|
+
* sessions to the list.
|
|
6
|
+
*
|
|
7
|
+
* This ensures that for link tests, there's not a prompt to choose a session.
|
|
8
|
+
*
|
|
9
|
+
* @param fromImportMetaUrl The import.meta.url of the test file calling this function.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mockActiveSessions(fromImportMetaUrl: string): {
|
|
12
|
+
activeSessions: Session[];
|
|
13
|
+
trackSession: import(".store/jest-mock-npm-30.0.0-alpha.6-d61fbc299a/package").Mock<typeof trackSessionType>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=mockActiveSessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockActiveSessions.d.ts","sourceRoot":"","sources":["../../src/__fixtures__/mockActiveSessions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAO1F;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,iBAAiB,EAAE,MAAM;oBAElC,OAAO,EAAE;;EAmBlC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';
|
|
5
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
/**
|
|
7
|
+
* Mock `getActiveSessions` to return a custom list of sessions, and mock `trackSession` to add
|
|
8
|
+
* sessions to the list.
|
|
9
|
+
*
|
|
10
|
+
* This ensures that for link tests, there's not a prompt to choose a session.
|
|
11
|
+
*
|
|
12
|
+
* @param fromImportMetaUrl The import.meta.url of the test file calling this function.
|
|
13
|
+
*/
|
|
14
|
+
export function mockActiveSessions(fromImportMetaUrl) {
|
|
15
|
+
const mocks = {
|
|
16
|
+
activeSessions: [],
|
|
17
|
+
trackSession: jest.fn((session) => {
|
|
18
|
+
mocks.activeSessions.push(session);
|
|
19
|
+
return Promise.resolve({ close: () => Promise.resolve() });
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
// These paths need to be relative to the test file, not the current file
|
|
23
|
+
jest.unstable_mockModule(getRelativePath(fromImportMetaUrl, '../commands/link/getActiveSessions.js'), () => ({
|
|
24
|
+
__esModule: true,
|
|
25
|
+
getActiveSessions: () => Promise.resolve(mocks.activeSessions),
|
|
26
|
+
}));
|
|
27
|
+
jest.unstable_mockModule(getRelativePath(fromImportMetaUrl, '../commands/start/trackSession.js'), () => ({
|
|
28
|
+
__esModule: true,
|
|
29
|
+
trackSession: mocks.trackSession,
|
|
30
|
+
}));
|
|
31
|
+
return mocks;
|
|
32
|
+
}
|
|
33
|
+
function getRelativePath(fromImportMetaUrl, toRelativePath) {
|
|
34
|
+
const fromAbsDir = path.dirname(fileURLToPath(fromImportMetaUrl));
|
|
35
|
+
const toAbsFile = path.resolve(currentDir, toRelativePath);
|
|
36
|
+
return normalizedPathRelativeTo(fromAbsDir, toAbsFile);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=mockActiveSessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockActiveSessions.js","sourceRoot":"","sources":["../../src/__fixtures__/mockActiveSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,iBAAyB;IAC1D,MAAM,KAAK,GAAG;QACZ,cAAc,EAAE,EAAe;QAC/B,YAAY,EAAE,IAAI,CAAC,EAAE,CAA0B,CAAC,OAAO,EAAE,EAAE;YACzD,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC;KACH,CAAC;IAEF,yEAAyE;IACzE,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,iBAAiB,EAAE,uCAAuC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3G,UAAU,EAAE,IAAI;QAChB,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC;KAC/D,CAAC,CAAC,CAAC;IAEJ,IAAI,CAAC,mBAAmB,CAAC,eAAe,CAAC,iBAAiB,EAAE,mCAAmC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;QACvG,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC,CAAC,CAAC;IAEJ,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,iBAAyB,EAAE,cAAsB;IACxE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAClE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC3D,OAAO,wBAAwB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import { jest } from '@jest/globals';\nimport type { Session } from '@ms-cloudpack/common-types';\nimport type { trackSession as trackSessionType } from '../commands/start/trackSession.js';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\n\nconst currentDir = path.dirname(fileURLToPath(import.meta.url));\n\n/**\n * Mock `getActiveSessions` to return a custom list of sessions, and mock `trackSession` to add\n * sessions to the list.\n *\n * This ensures that for link tests, there's not a prompt to choose a session.\n *\n * @param fromImportMetaUrl The import.meta.url of the test file calling this function.\n */\nexport function mockActiveSessions(fromImportMetaUrl: string) {\n const mocks = {\n activeSessions: [] as Session[],\n trackSession: jest.fn<typeof trackSessionType>((session) => {\n mocks.activeSessions.push(session);\n return Promise.resolve({ close: () => Promise.resolve() });\n }),\n };\n\n // These paths need to be relative to the test file, not the current file\n jest.unstable_mockModule(getRelativePath(fromImportMetaUrl, '../commands/link/getActiveSessions.js'), () => ({\n __esModule: true,\n getActiveSessions: () => Promise.resolve(mocks.activeSessions),\n }));\n\n jest.unstable_mockModule(getRelativePath(fromImportMetaUrl, '../commands/start/trackSession.js'), () => ({\n __esModule: true,\n trackSession: mocks.trackSession,\n }));\n\n return mocks;\n}\n\nfunction getRelativePath(fromImportMetaUrl: string, toRelativePath: string) {\n const fromAbsDir = path.dirname(fileURLToPath(fromImportMetaUrl));\n const toAbsFile = path.resolve(currentDir, toRelativePath);\n return normalizedPathRelativeTo(fromAbsDir, toAbsFile);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG9D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CA0EhD,CAAC"}
|
|
@@ -4,13 +4,10 @@ import path from 'path';
|
|
|
4
4
|
import { getFilteredPackages } from '../../utilities/getFilteredPackages.js';
|
|
5
5
|
export const execute = async (params) => {
|
|
6
6
|
const { cwd: appPath, options, reporter, initialize, exit, autoDispose } = params;
|
|
7
|
-
const
|
|
7
|
+
const apiContextOptions = await initialize({ appPath, mode: options.mode });
|
|
8
8
|
console.log('Bundle mode:', yellow(options.mode));
|
|
9
9
|
const [ctx] = autoDispose(await createPartialApiContext({
|
|
10
|
-
|
|
11
|
-
config,
|
|
12
|
-
reporter,
|
|
13
|
-
telemetryClient,
|
|
10
|
+
...apiContextOptions,
|
|
14
11
|
items: ['packages', 'watcher', 'session', 'taskRunner', 'bus', 'packageImportPaths', 'packageHashes'],
|
|
15
12
|
}));
|
|
16
13
|
const pathsToBundle = options.match ? getFilteredPackages(ctx.session.resolveMap, options.match) : [appPath];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E,MAAM,CAAC,MAAM,OAAO,GAAiC,KAAK,EAAE,MAAM,EAAE,EAAE;IACpE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAClF,MAAM,
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/bundle/execute.ts"],"names":[],"mappings":"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","sourcesContent":["import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { plural, red, yellow } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport type { BundleOptions } from './types/BundleOptions.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\n\nexport const execute: CommandAction<BundleOptions> = async (params) => {\n const { cwd: appPath, options, reporter, initialize, exit, autoDispose } = params;\n const apiContextOptions = await initialize({ appPath, mode: options.mode });\n\n console.log('Bundle mode:', yellow(options.mode));\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'watcher', 'session', 'taskRunner', 'bus', 'packageImportPaths', 'packageHashes'],\n }),\n );\n\n const pathsToBundle = options.match ? getFilteredPackages(ctx.session.resolveMap, options.match) : [appPath];\n\n if (!pathsToBundle.length) {\n await exit({\n message: 'No matching packages found to bundle.',\n exitCode: 1,\n });\n return;\n }\n\n // Show completed bundle tasks so the user knows what's happening.\n reporter.setOptions({ ...reporter.getOptions(), showCompleted: true });\n\n let warnPackagesCount = 0;\n let errorPackagesCount = 0;\n let successPackagesCount = 0;\n\n for (const packagePath of pathsToBundle) {\n // If outdir is set, resolve relative to the package/app path.\n // Otherwise, use the default path under the cloudpack cache to stay consistent with init and start,\n // and to avoid potentially messing with the package's original output.\n const outputPath = options.outdir ? path.resolve(packagePath, options.outdir) : undefined;\n\n const definition = await ctx.packages.get(packagePath);\n\n const { result } = await ensurePackageBundled({\n input: {\n name: definition.name,\n version: definition.version,\n outputPath,\n bundler: options.bundler,\n disableSourceMaps: options.disableSourceMaps,\n shouldForce: true,\n isIncremental: false,\n },\n ctx,\n });\n\n console.log('Output:', result.outputPath, '\\n');\n\n if (result.errors?.length) {\n errorPackagesCount++;\n } else if (result.warnings?.length) {\n warnPackagesCount++;\n } else {\n successPackagesCount++;\n }\n }\n\n const status = [\n errorPackagesCount && red(plural(errorPackagesCount, 'package$s failed')),\n warnPackagesCount && yellow(plural(warnPackagesCount, 'package$s succeeded with warnings')),\n successPackagesCount && plural(successPackagesCount, 'package$s succeeded'),\n ]\n .filter(Boolean)\n .join(', ');\n\n await exit({\n message: `Bundling ${status}\\n`,\n exitCode: errorPackagesCount ? 1 : 0,\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/clean.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,UAAU,YAAY;CAAG;AAEzB,iCAAiC;AACjC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/clean.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,UAAU,YAAY;CAAG;AAEzB,iCAAiC;AACjC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CAwB/C,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { getCachePath } from '@ms-cloudpack/
|
|
1
|
+
import { getCachePath } from '@ms-cloudpack/config';
|
|
2
2
|
import fsPromises from 'fs/promises';
|
|
3
3
|
/** Clear the Cloudpack cache. */
|
|
4
4
|
export const execute = async (params) => {
|
|
5
|
-
const { cwd, initialize, exit } = params;
|
|
5
|
+
const { cwd, initialize, exit, options } = params;
|
|
6
6
|
await initialize({ appPath: cwd });
|
|
7
|
-
const cachePath = getCachePath();
|
|
7
|
+
const cachePath = await getCachePath(options.cachePath);
|
|
8
8
|
const cacheDescription = `the Cloudpack cache (${cachePath})`;
|
|
9
9
|
let message;
|
|
10
10
|
let hasErrors = false;
|
|
11
11
|
try {
|
|
12
|
+
// NOTE: if the method used here changes, be sure to update what cache.e2e.test.ts spies on
|
|
12
13
|
await fsPromises.rm(cachePath, { recursive: true, force: true });
|
|
13
14
|
message = `Successfully cleared ${cacheDescription}`;
|
|
14
15
|
hasErrors = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../../src/commands/cache/clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../../src/commands/cache/clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,UAAU,MAAM,aAAa,CAAC;AAKrC,iCAAiC;AACjC,MAAM,CAAC,MAAM,OAAO,GAAgC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAElD,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,gBAAgB,GAAG,wBAAwB,SAAS,GAAG,CAAC;IAC9D,IAAI,OAAe,CAAC;IACpB,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,IAAI,CAAC;QACH,2FAA2F;QAC3F,MAAM,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,OAAO,GAAG,wBAAwB,gBAAgB,EAAE,CAAC;QACrD,SAAS,GAAG,KAAK,CAAC;IACpB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,GAAG,mBAAmB,gBAAgB,KAAM,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;QAClF,SAAS,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { getCachePath } from '@ms-cloudpack/config';\nimport fsPromises from 'fs/promises';\nimport type { CommandAction } from '../../types/CommandAction.js';\n\ninterface CleanOptions {}\n\n/** Clear the Cloudpack cache. */\nexport const execute: CommandAction<CleanOptions> = async (params) => {\n const { cwd, initialize, exit, options } = params;\n\n await initialize({ appPath: cwd });\n\n const cachePath = await getCachePath(options.cachePath);\n const cacheDescription = `the Cloudpack cache (${cachePath})`;\n let message: string;\n let hasErrors = false;\n\n try {\n // NOTE: if the method used here changes, be sure to update what cache.e2e.test.ts spies on\n await fsPromises.rm(cachePath, { recursive: true, force: true });\n message = `Successfully cleared ${cacheDescription}`;\n hasErrors = false;\n } catch (err) {\n message = `Failed to clear ${cacheDescription}: ${(err as Error).message || err}`;\n hasErrors = true;\n }\n\n await exit({\n exitCode: hasErrors ? 1 : 0,\n message,\n });\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandAction } from '../../types/CommandAction.js';
|
|
2
|
+
export interface DeleteOptions {
|
|
3
|
+
}
|
|
4
|
+
export interface DeleteArguments {
|
|
5
|
+
key: string;
|
|
6
|
+
}
|
|
7
|
+
/** Delete a Cloudpack user preference value. */
|
|
8
|
+
export declare const execute: CommandAction<DeleteOptions>;
|
|
9
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/commands/config/delete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,MAAM,WAAW,aAAa;CAAG;AAEjC,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gDAAgD;AAChD,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CAmBhD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { updateUserPreference } from '@ms-cloudpack/config';
|
|
2
|
+
/** Delete a Cloudpack user preference value. */
|
|
3
|
+
export const execute = async (params) => {
|
|
4
|
+
const { cwd, args, initialize, exit } = params;
|
|
5
|
+
const key = args[0];
|
|
6
|
+
await initialize({ appPath: cwd });
|
|
7
|
+
try {
|
|
8
|
+
// Commander should have validated the key based on the given choices, and the update
|
|
9
|
+
// function will also validate its input.
|
|
10
|
+
await updateUserPreference({ key, deleteValue: true });
|
|
11
|
+
// Following the pattern of other tools, we don't output anything on success,
|
|
12
|
+
// or if the key was valid but didn't exist.
|
|
13
|
+
await exit({ message: '' });
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
await exit({
|
|
17
|
+
hasErrors: true,
|
|
18
|
+
message: `Failed to delete "${key}": ${err.message || err}`,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../src/commands/config/delete.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQ5D,gDAAgD;AAChD,MAAM,CAAC,MAAM,OAAO,GAAiC,KAAK,EAAE,MAAM,EAAE,EAAE;IACpE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAA0B,CAAC;IAE7C,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,IAAI,CAAC;QACH,qFAAqF;QACrF,yCAAyC;QACzC,MAAM,oBAAoB,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,6EAA6E;QAC7E,4CAA4C;QAC5C,MAAM,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,CAAC;YACT,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,qBAAqB,GAAG,MAAO,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE;SACvE,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UserPreferences } from '@ms-cloudpack/common-types';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { updateUserPreference } from '@ms-cloudpack/config';\n\nexport interface DeleteOptions {}\n\nexport interface DeleteArguments {\n key: string;\n}\n\n/** Delete a Cloudpack user preference value. */\nexport const execute: CommandAction<DeleteOptions> = async (params) => {\n const { cwd, args, initialize, exit } = params;\n const key = args[0] as keyof UserPreferences;\n\n await initialize({ appPath: cwd });\n\n try {\n // Commander should have validated the key based on the given choices, and the update\n // function will also validate its input.\n await updateUserPreference({ key, deleteValue: true });\n // Following the pattern of other tools, we don't output anything on success,\n // or if the key was valid but didn't exist.\n await exit({ message: '' });\n } catch (err) {\n await exit({\n hasErrors: true,\n message: `Failed to delete \"${key}\": ${(err as Error).message || err}`,\n });\n }\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandAction } from '../../types/CommandAction.js';
|
|
2
|
+
export interface GetOptions {
|
|
3
|
+
}
|
|
4
|
+
export interface GetArguments {
|
|
5
|
+
key: string;
|
|
6
|
+
}
|
|
7
|
+
/** Get a Cloudpack user preference value. */
|
|
8
|
+
export declare const execute: CommandAction<GetOptions>;
|
|
9
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/commands/config/get.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,MAAM,WAAW,UAAU;CAAG;AAE9B,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,6CAA6C;AAC7C,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,UAAU,CAsB7C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { allUserPreferences, readUserPreferences } from '@ms-cloudpack/config';
|
|
2
|
+
/** Get a Cloudpack user preference value. */
|
|
3
|
+
export const execute = async (params) => {
|
|
4
|
+
const { cwd, args, initialize, exit } = params;
|
|
5
|
+
// Commander should have validated the key based on the given choices.
|
|
6
|
+
const key = args[0];
|
|
7
|
+
await initialize({ appPath: cwd });
|
|
8
|
+
try {
|
|
9
|
+
if (!allUserPreferences[key]) {
|
|
10
|
+
throw new Error(`Invalid key name`);
|
|
11
|
+
}
|
|
12
|
+
const userPreferences = await readUserPreferences();
|
|
13
|
+
await exit({
|
|
14
|
+
message: `${userPreferences[key] || ''}`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
await exit({
|
|
19
|
+
hasErrors: true,
|
|
20
|
+
message: `Failed to get "${key}": ${err.message || err}`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/commands/config/get.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAQ/E,6CAA6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAA8B,KAAK,EAAE,MAAM,EAAE,EAAE;IACjE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAC/C,sEAAsE;IACtE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAA0B,CAAC;IAE7C,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,IAAI,CAAC;QACH,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,mBAAmB,EAAE,CAAC;QACpD,MAAM,IAAI,CAAC;YACT,OAAO,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,CAAC;YACT,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,kBAAkB,GAAG,MAAO,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE;SACpE,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { UserPreferences } from '@ms-cloudpack/common-types';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { allUserPreferences, readUserPreferences } from '@ms-cloudpack/config';\n\nexport interface GetOptions {}\n\nexport interface GetArguments {\n key: string;\n}\n\n/** Get a Cloudpack user preference value. */\nexport const execute: CommandAction<GetOptions> = async (params) => {\n const { cwd, args, initialize, exit } = params;\n // Commander should have validated the key based on the given choices.\n const key = args[0] as keyof UserPreferences;\n\n await initialize({ appPath: cwd });\n\n try {\n if (!allUserPreferences[key]) {\n throw new Error(`Invalid key name`);\n }\n\n const userPreferences = await readUserPreferences();\n await exit({\n message: `${userPreferences[key] || ''}`,\n });\n } catch (err) {\n await exit({\n hasErrors: true,\n message: `Failed to get \"${key}\": ${(err as Error).message || err}`,\n });\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAY9E,eAAO,MAAM,IAAI,EAAE,mBA8ClB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Argument } from 'commander';
|
|
2
|
+
import { allUserPreferences } from '@ms-cloudpack/config';
|
|
3
|
+
const userPreferencesKeys = Object.keys(allUserPreferences);
|
|
4
|
+
const skipSharedOptions = ['cachePath', 'features'];
|
|
5
|
+
export const init = (program) => {
|
|
6
|
+
const configCommand = program.addSubCommand({
|
|
7
|
+
name: 'config',
|
|
8
|
+
description: 'Manage Cloudpack user preferences (requires a sub-command).',
|
|
9
|
+
usage: '<command>',
|
|
10
|
+
});
|
|
11
|
+
configCommand.addSubCommand({
|
|
12
|
+
name: 'set',
|
|
13
|
+
description: 'Set a user preference.',
|
|
14
|
+
args: {
|
|
15
|
+
// commander will throw if key is not one of these values, so we don't need manual validation later.
|
|
16
|
+
key: new Argument('<key>', 'The key to set.').choices(userPreferencesKeys).argRequired(),
|
|
17
|
+
value: new Argument('<value>', 'The value to set.').argRequired(),
|
|
18
|
+
},
|
|
19
|
+
skipSharedOptions,
|
|
20
|
+
getExecutor: () => import('./set.js'),
|
|
21
|
+
});
|
|
22
|
+
configCommand.addSubCommand({
|
|
23
|
+
name: 'get',
|
|
24
|
+
description: 'Get a user preference.',
|
|
25
|
+
args: {
|
|
26
|
+
key: new Argument('<key>', 'The key to get.').choices(userPreferencesKeys).argRequired(),
|
|
27
|
+
},
|
|
28
|
+
skipSharedOptions,
|
|
29
|
+
getExecutor: () => import('./get.js'),
|
|
30
|
+
});
|
|
31
|
+
configCommand.addSubCommand({
|
|
32
|
+
name: 'list',
|
|
33
|
+
description: 'List the current user preferences.',
|
|
34
|
+
skipSharedOptions,
|
|
35
|
+
getExecutor: () => import('./list.js'),
|
|
36
|
+
});
|
|
37
|
+
configCommand.addSubCommand({
|
|
38
|
+
name: 'delete',
|
|
39
|
+
description: 'Delete a user preference.',
|
|
40
|
+
alias: 'unset', // git uses this name
|
|
41
|
+
args: {
|
|
42
|
+
key: new Argument('<key>', 'The key to delete.').choices(userPreferencesKeys).argRequired(),
|
|
43
|
+
},
|
|
44
|
+
skipSharedOptions,
|
|
45
|
+
getExecutor: () => import('./delete.js'),
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM1D,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAE5D,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC1C,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,6DAA6D;QAC1E,KAAK,EAAE,WAAW;KACnB,CAAC,CAAC;IAEH,aAAa,CAAC,aAAa,CAA2B;QACpD,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE;YACJ,oGAAoG;YACpG,GAAG,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE;YACxF,KAAK,EAAE,IAAI,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,WAAW,EAAE;SAClE;QACD,iBAAiB;QACjB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;KACtC,CAAC,CAAC;IAEH,aAAa,CAAC,aAAa,CAA2B;QACpD,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE;YACJ,GAAG,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE;SACzF;QACD,iBAAiB;QACjB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;KACtC,CAAC,CAAC;IAEH,aAAa,CAAC,aAAa,CAAc;QACvC,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,oCAAoC;QACjD,iBAAiB;QACjB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;KACvC,CAAC,CAAC;IAEH,aAAa,CAAC,aAAa,CAAiC;QAC1D,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,2BAA2B;QACxC,KAAK,EAAE,OAAO,EAAE,qBAAqB;QACrC,IAAI,EAAE;YACJ,GAAG,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,WAAW,EAAE;SAC5F;QACD,iBAAiB;QACjB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;KACzC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Argument } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { SetArguments, SetOptions } from './set.js';\nimport { allUserPreferences } from '@ms-cloudpack/config';\nimport type { ListOptions } from './list.js';\nimport type { GetArguments, GetOptions } from './get.js';\nimport type { DeleteArguments, DeleteOptions } from './delete.js';\nimport type { SharedOptions } from '../../types/SharedOptions.js';\n\nconst userPreferencesKeys = Object.keys(allUserPreferences);\n\nconst skipSharedOptions: Array<keyof SharedOptions> = ['cachePath', 'features'];\n\nexport const init: CommandInitFunction = (program) => {\n const configCommand = program.addSubCommand({\n name: 'config',\n description: 'Manage Cloudpack user preferences (requires a sub-command).',\n usage: '<command>',\n });\n\n configCommand.addSubCommand<SetOptions, SetArguments>({\n name: 'set',\n description: 'Set a user preference.',\n args: {\n // commander will throw if key is not one of these values, so we don't need manual validation later.\n key: new Argument('<key>', 'The key to set.').choices(userPreferencesKeys).argRequired(),\n value: new Argument('<value>', 'The value to set.').argRequired(),\n },\n skipSharedOptions,\n getExecutor: () => import('./set.js'),\n });\n\n configCommand.addSubCommand<GetOptions, GetArguments>({\n name: 'get',\n description: 'Get a user preference.',\n args: {\n key: new Argument('<key>', 'The key to get.').choices(userPreferencesKeys).argRequired(),\n },\n skipSharedOptions,\n getExecutor: () => import('./get.js'),\n });\n\n configCommand.addSubCommand<ListOptions>({\n name: 'list',\n description: 'List the current user preferences.',\n skipSharedOptions,\n getExecutor: () => import('./list.js'),\n });\n\n configCommand.addSubCommand<DeleteOptions, DeleteArguments>({\n name: 'delete',\n description: 'Delete a user preference.',\n alias: 'unset', // git uses this name\n args: {\n key: new Argument('<key>', 'The key to delete.').choices(userPreferencesKeys).argRequired(),\n },\n skipSharedOptions,\n getExecutor: () => import('./delete.js'),\n });\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/config/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,MAAM,WAAW,WAAW;CAAG;AAE/B,uCAAuC;AACvC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAiB9C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { readUserPreferences } from '@ms-cloudpack/config';
|
|
2
|
+
/** List Cloudpack user preferences. */
|
|
3
|
+
export const execute = async (params) => {
|
|
4
|
+
const { cwd, initialize, exit } = params;
|
|
5
|
+
await initialize({ appPath: cwd });
|
|
6
|
+
try {
|
|
7
|
+
const userPreferences = await readUserPreferences();
|
|
8
|
+
await exit({
|
|
9
|
+
message: Object.entries(userPreferences)
|
|
10
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
11
|
+
.join('\n'),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
await exit({
|
|
16
|
+
hasErrors: true,
|
|
17
|
+
message: `Failed to list preferences: ${err.message || err}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/config/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAI3D,uCAAuC;AACvC,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACzC,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,mBAAmB,EAAE,CAAC;QACpD,MAAM,IAAI,CAAC;YACT,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;iBACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,KAAK,EAAE,CAAC;iBACzC,IAAI,CAAC,IAAI,CAAC;SACd,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,CAAC;YACT,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,+BAAgC,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE;SACxE,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { CommandAction } from '../../types/CommandAction.js';\nimport { readUserPreferences } from '@ms-cloudpack/config';\n\nexport interface ListOptions {}\n\n/** List Cloudpack user preferences. */\nexport const execute: CommandAction<ListOptions> = async (params) => {\n const { cwd, initialize, exit } = params;\n await initialize({ appPath: cwd });\n\n try {\n const userPreferences = await readUserPreferences();\n await exit({\n message: Object.entries(userPreferences)\n .map(([key, value]) => `${key}: ${value}`)\n .join('\\n'),\n });\n } catch (err) {\n await exit({\n hasErrors: true,\n message: `Failed to list preferences: ${(err as Error).message || err}`,\n });\n }\n};\n"]}
|