@ms-cloudpack/cli 0.69.2 → 0.69.4
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/commands/config/index.d.ts.map +1 -1
- package/lib/commands/config/index.js +13 -7
- package/lib/commands/config/index.js.map +1 -1
- package/lib/commands/info/index.d.ts.map +1 -1
- package/lib/commands/info/index.js +4 -3
- package/lib/commands/info/index.js.map +1 -1
- package/lib/commands/init/index.d.ts.map +1 -1
- package/lib/commands/init/index.js +3 -2
- package/lib/commands/init/index.js.map +1 -1
- package/lib/commands/link/index.d.ts.map +1 -1
- package/lib/commands/link/index.js +2 -1
- package/lib/commands/link/index.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/index.d.ts.map +1 -1
- package/lib/commands/start/index.js +3 -2
- package/lib/commands/start/index.js.map +1 -1
- package/lib/commands/unlink/index.d.ts.map +1 -1
- package/lib/commands/unlink/index.js +2 -2
- package/lib/commands/unlink/index.js.map +1 -1
- package/lib/utilities/CloudpackCommand.d.ts +13 -4
- package/lib/utilities/CloudpackCommand.d.ts.map +1 -1
- package/lib/utilities/CloudpackCommand.js +19 -6
- package/lib/utilities/CloudpackCommand.js.map +1 -1
- package/lib/utilities/reusedOptions.d.ts +9 -0
- package/lib/utilities/reusedOptions.d.ts.map +1 -0
- package/lib/utilities/reusedOptions.js +9 -0
- package/lib/utilities/reusedOptions.js.map +1 -0
- package/package.json +11 -10
- package/lib/__fixtures__/commandTestSetup.d.ts +0 -18
- package/lib/__fixtures__/commandTestSetup.d.ts.map +0 -1
- package/lib/__fixtures__/commandTestSetup.js +0 -61
- package/lib/__fixtures__/commandTestSetup.js.map +0 -1
- package/lib/__fixtures__/createMockSession.d.ts +0 -6
- package/lib/__fixtures__/createMockSession.d.ts.map +0 -1
- package/lib/__fixtures__/createMockSession.js +0 -19
- package/lib/__fixtures__/createMockSession.js.map +0 -1
- package/lib/__fixtures__/getPortArgsForStart.d.ts +0 -21
- package/lib/__fixtures__/getPortArgsForStart.d.ts.map +0 -1
- package/lib/__fixtures__/getPortArgsForStart.js +0 -36
- package/lib/__fixtures__/getPortArgsForStart.js.map +0 -1
- package/lib/__fixtures__/mainWrapper.d.ts +0 -9
- package/lib/__fixtures__/mainWrapper.d.ts.map +0 -1
- package/lib/__fixtures__/mainWrapper.js +0 -17
- package/lib/__fixtures__/mainWrapper.js.map +0 -1
- package/lib/__fixtures__/mockActiveSessions.d.ts +0 -15
- package/lib/__fixtures__/mockActiveSessions.d.ts.map +0 -1
- package/lib/__fixtures__/mockActiveSessions.js +0 -38
- package/lib/__fixtures__/mockActiveSessions.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAM9E,eAAO,MAAM,IAAI,EAAE,mBAwDlB,CAAC"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { Argument } from 'commander';
|
|
2
1
|
import { allUserPreferences } from '@ms-cloudpack/config';
|
|
3
|
-
|
|
4
|
-
const skipSharedOptions = ['cachePath', 'features'];
|
|
2
|
+
import { Argument } from 'commander';
|
|
5
3
|
export const init = (program) => {
|
|
4
|
+
const userPreferencesKeys = Object.keys(allUserPreferences);
|
|
5
|
+
const keyWidth = Math.max(20, ...userPreferencesKeys.map((key) => key.length + 1));
|
|
6
6
|
const configCommand = program.addSubCommand({
|
|
7
7
|
name: 'config',
|
|
8
8
|
description: 'Manage Cloudpack user preferences (requires a sub-command).',
|
|
9
9
|
usage: '<command>',
|
|
10
|
+
hideSharedOptions: true,
|
|
11
|
+
addHelpText: {
|
|
12
|
+
position: 'afterAll',
|
|
13
|
+
text: '\nAvailable preferences:\n' +
|
|
14
|
+
userPreferencesKeys.map((key) => ` ${key.padEnd(keyWidth)}${allUserPreferences[key]}`).join('\n'),
|
|
15
|
+
},
|
|
10
16
|
});
|
|
11
17
|
configCommand.addSubCommand({
|
|
12
18
|
name: 'set',
|
|
@@ -16,7 +22,7 @@ export const init = (program) => {
|
|
|
16
22
|
key: new Argument('<key>', 'The key to set.').choices(userPreferencesKeys).argRequired(),
|
|
17
23
|
value: new Argument('<value>', 'The value to set.').argRequired(),
|
|
18
24
|
},
|
|
19
|
-
|
|
25
|
+
hideSharedOptions: true,
|
|
20
26
|
getExecutor: () => import('./set.js'),
|
|
21
27
|
});
|
|
22
28
|
configCommand.addSubCommand({
|
|
@@ -25,13 +31,13 @@ export const init = (program) => {
|
|
|
25
31
|
args: {
|
|
26
32
|
key: new Argument('<key>', 'The key to get.').choices(userPreferencesKeys).argRequired(),
|
|
27
33
|
},
|
|
28
|
-
|
|
34
|
+
hideSharedOptions: true,
|
|
29
35
|
getExecutor: () => import('./get.js'),
|
|
30
36
|
});
|
|
31
37
|
configCommand.addSubCommand({
|
|
32
38
|
name: 'list',
|
|
33
39
|
description: 'List the current user preferences.',
|
|
34
|
-
|
|
40
|
+
hideSharedOptions: true,
|
|
35
41
|
getExecutor: () => import('./list.js'),
|
|
36
42
|
});
|
|
37
43
|
configCommand.addSubCommand({
|
|
@@ -41,7 +47,7 @@ export const init = (program) => {
|
|
|
41
47
|
args: {
|
|
42
48
|
key: new Argument('<key>', 'The key to delete.').choices(userPreferencesKeys).argRequired(),
|
|
43
49
|
},
|
|
44
|
-
|
|
50
|
+
hideSharedOptions: true,
|
|
45
51
|
getExecutor: () => import('./delete.js'),
|
|
46
52
|
});
|
|
47
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","s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AW,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,EAAE,IAAI;QACvB,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,EAAE,IAAI;QACvB,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,EAAE,IAAI;QACvB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;KACzC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { allUserPreferences } from '@ms-cloudpack/config';\nimport { Argument } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { DeleteArguments, DeleteOptions } from './delete.js';\nimport type { GetArguments, GetOptions } from './get.js';\nimport type { ListOptions } from './list.js';\nimport type { SetArguments, SetOptions } from './set.js';\n\nexport const init: CommandInitFunction = (program) => {\n const userPreferencesKeys = Object.keys(allUserPreferences) as (keyof typeof allUserPreferences)[];\n const keyWidth = Math.max(20, ...userPreferencesKeys.map((key) => key.length + 1));\n\n const configCommand = program.addSubCommand({\n name: 'config',\n description: 'Manage Cloudpack user preferences (requires a sub-command).',\n usage: '<command>',\n hideSharedOptions: true,\n addHelpText: {\n position: 'afterAll',\n text:\n '\\nAvailable preferences:\\n' +\n userPreferencesKeys.map((key) => ` ${key.padEnd(keyWidth)}${allUserPreferences[key]}`).join('\\n'),\n },\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 hideSharedOptions: true,\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 hideSharedOptions: true,\n getExecutor: () => import('./get.js'),\n });\n\n configCommand.addSubCommand<ListOptions>({\n name: 'list',\n description: 'List the current user preferences.',\n hideSharedOptions: true,\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 hideSharedOptions: true,\n getExecutor: () => import('./delete.js'),\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAyBlB,CAAC"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
|
-
const
|
|
2
|
+
const hideSharedOptions = ['cachePath', 'features'];
|
|
3
3
|
/** Defines the "info" verb. */
|
|
4
4
|
export const init = (program) => {
|
|
5
5
|
const infoCommand = program.addSubCommand({
|
|
6
6
|
name: 'info',
|
|
7
7
|
description: 'Get repo info relevant to cloudpack (requires a sub-command).',
|
|
8
8
|
usage: '<command>',
|
|
9
|
+
hideSharedOptions,
|
|
9
10
|
});
|
|
10
11
|
infoCommand.addSubCommand({
|
|
11
12
|
name: 'lock-file',
|
|
12
13
|
alias: 'lockfile',
|
|
13
14
|
description: 'Get info about potentially problematic deps from the lock file (yarn v1 only).',
|
|
14
|
-
|
|
15
|
+
hideSharedOptions,
|
|
15
16
|
getExecutor: () => import('./lockFile/execute.js'),
|
|
16
17
|
});
|
|
17
18
|
infoCommand.addSubCommand({
|
|
18
19
|
name: 'non-semver-deps',
|
|
19
20
|
description: 'Get a list of non-semver deps from local packages.',
|
|
20
21
|
getExecutor: () => import('./nonSemverDeps/execute.js'),
|
|
21
|
-
|
|
22
|
+
hideSharedOptions,
|
|
22
23
|
options: {
|
|
23
24
|
prod: new Option('--prod', 'Only get production deps'),
|
|
24
25
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAEhF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;QACxC,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,+DAA+D;QAC5E,KAAK,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAInC,MAAM,iBAAiB,GAA+B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAEhF,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;QACxC,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,+DAA+D;QAC5E,KAAK,EAAE,WAAW;QAClB,iBAAiB;KAClB,CAAC,CAAC;IAEH,WAAW,CAAC,aAAa,CAAC;QACxB,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,gFAAgF;QAC7F,iBAAiB;QACjB,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC;KACnD,CAAC,CAAC;IAEH,WAAW,CAAC,aAAa,CAAC;QACxB,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,4BAA4B,CAAC;QACvD,iBAAiB;QACjB,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,MAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC;SACvD;KACF,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { SharedOptions } from '../../types/SharedOptions.js';\n\nconst hideSharedOptions: Array<keyof SharedOptions> = ['cachePath', 'features'];\n\n/** Defines the \"info\" verb. */\nexport const init: CommandInitFunction = (program) => {\n const infoCommand = program.addSubCommand({\n name: 'info',\n description: 'Get repo info relevant to cloudpack (requires a sub-command).',\n usage: '<command>',\n hideSharedOptions,\n });\n\n infoCommand.addSubCommand({\n name: 'lock-file',\n alias: 'lockfile',\n description: 'Get info about potentially problematic deps from the lock file (yarn v1 only).',\n hideSharedOptions,\n getExecutor: () => import('./lockFile/execute.js'),\n });\n\n infoCommand.addSubCommand({\n name: 'non-semver-deps',\n description: 'Get a list of non-semver deps from local packages.',\n getExecutor: () => import('./nonSemverDeps/execute.js'),\n hideSharedOptions,\n options: {\n prod: new Option('--prod', 'Only get production deps'),\n },\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAK9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBAmBlB,CAAC"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
2
|
import { parseMatch } from '../../utilities/parseMatch.js';
|
|
3
|
+
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
3
4
|
/** Defines the "init" verb. */
|
|
4
5
|
export const init = (program) => {
|
|
5
6
|
program.addSubCommand({
|
|
6
7
|
name: 'init',
|
|
7
8
|
description: 'Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.',
|
|
8
9
|
options: {
|
|
9
|
-
logResolveMap:
|
|
10
|
+
logResolveMap: reusedOptions.logResolveMap(),
|
|
10
11
|
reset: new Option('--reset', 'Ignores existing overrides when determining all entries.').conflicts('check'),
|
|
11
12
|
check: new Option('--check', 'Fails if any package exports are missing.').conflicts('reset'),
|
|
12
13
|
match: new Option('--match <match...>', 'Only evaluate specific package(s), optionally with a version: e.g. "foo", "@foo/*", "foo@1.2.3"')
|
|
13
14
|
.conflicts('reset')
|
|
14
15
|
.argParser(parseMatch),
|
|
15
|
-
cache:
|
|
16
|
+
cache: reusedOptions.noCache(),
|
|
16
17
|
},
|
|
17
18
|
getExecutor: () => import('./execute.js'),
|
|
18
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/init/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAc;QACjC,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,sIAAsI;QACxI,OAAO,EAAE;YACP,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;YAC5C,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,0DAA0D,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;YAC3G,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,2CAA2C,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5F,KAAK,EAAE,IAAI,MAAM,CACf,oBAAoB,EACpB,iGAAiG,CAClG;iBACE,SAAS,CAAC,OAAO,CAAC;iBAClB,SAAS,CAAC,UAAU,CAAC;YACxB,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE;SAC/B;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport { parseMatch } from '../../utilities/parseMatch.js';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"init\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<InitOptions>({\n name: 'init',\n description:\n 'Initializes a given app project and defines the necessary configuration overrides to make an existing app compatible with Cloudpack.',\n options: {\n logResolveMap: reusedOptions.logResolveMap(),\n reset: new Option('--reset', 'Ignores existing overrides when determining all entries.').conflicts('check'),\n check: new Option('--check', 'Fails if any package exports are missing.').conflicts('reset'),\n match: new Option(\n '--match <match...>',\n 'Only evaluate specific package(s), optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"',\n )\n .conflicts('reset')\n .argParser(parseMatch),\n cache: reusedOptions.noCache(),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/link/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/link/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,+BAA+B;AAC/B,eAAO,MAAM,IAAI,EAAE,mBA4BlB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
|
+
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
2
3
|
/** Defines the "link" verb. */
|
|
3
4
|
export const init = (program) => {
|
|
4
5
|
program.addSubCommand({
|
|
@@ -11,7 +12,7 @@ export const init = (program) => {
|
|
|
11
12
|
resolveStrategy: new Option('--resolve-strategy <strategy>', 'The strategy to use when resolving linked packages. Options are "dedupe" or "duplicate". Defaults to "dedupe".')
|
|
12
13
|
.choices(['dedupe', 'duplicate'])
|
|
13
14
|
.default('dedupe'),
|
|
14
|
-
logResolveMap:
|
|
15
|
+
logResolveMap: reusedOptions.logResolveMap(),
|
|
15
16
|
},
|
|
16
17
|
getExecutor: () => import('./execute.js'),
|
|
17
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/link/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/link/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAc;QACjC,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,yGAAyG;QAC3G,OAAO,EAAE;YACP,MAAM,EAAE,IAAI,MAAM,CAChB,wBAAwB,EACxB,+IAA+I,CAChJ;YACD,GAAG,EAAE,IAAI,MAAM,CACb,OAAO,EACP,wFAAwF,CACzF;YACD,iBAAiB,EAAE,IAAI,MAAM,CAC3B,sBAAsB,EACtB,yFAAyF,CAC1F;YACD,eAAe,EAAE,IAAI,MAAM,CACzB,+BAA+B,EAC/B,gHAAgH,CACjH;iBACE,OAAO,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;iBAChC,OAAO,CAAC,QAAQ,CAAC;YACpB,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;SAC7C;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { LinkOptions } from './types/LinkOptions.js';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"link\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<LinkOptions>({\n name: 'link',\n description:\n 'Links the package or packages found within the current folder from an existing Cloudpack start session.',\n options: {\n ignore: new Option(\n '--ignore [packages...]',\n 'Ignores the given packages when linking. This can be used to ignore packages that are part of the current repo but have issues being bundled.',\n ),\n all: new Option(\n '--all',\n 'If specified, will link all internal packages discovered within the linked repo graph.',\n ),\n ignoreResolutions: new Option(\n '--ignore-resolutions',\n 'If specified, ignores resolutions from the host repo definition to the linked packages.',\n ),\n resolveStrategy: new Option(\n '--resolve-strategy <strategy>',\n 'The strategy to use when resolving linked packages. Options are \"dedupe\" or \"duplicate\". Defaults to \"dedupe\".',\n )\n .choices(['dedupe', 'duplicate'])\n .default('dedupe'),\n logResolveMap: reusedOptions.logResolveMap(),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -7,7 +7,7 @@ export const init = (program) => {
|
|
|
7
7
|
options: {
|
|
8
8
|
force: new Option('--force', 'Forces execution of setup steps.'),
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
hideSharedOptions: ['cachePath', 'features'],
|
|
11
11
|
getExecutor: () => import('./execute.js'),
|
|
12
12
|
});
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAC;QACpB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,gGAAgG;QAC7G,OAAO,EAAE;YACP,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,kCAAkC,CAAC;SACjE;QACD,iBAAiB,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;QAC5C,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\n\n/** Defines the \"info\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand({\n name: 'setup',\n description: 'Sets up cert and hosts file settings for the relevant inner loop domain and https preferences.',\n options: {\n force: new Option('--force', 'Forces execution of setup steps.'),\n },\n
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/setup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,+BAA+B;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAC;QACpB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,gGAAgG;QAC7G,OAAO,EAAE;YACP,KAAK,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,kCAAkC,CAAC;SACjE;QACD,iBAAiB,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;QAC5C,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\n\n/** Defines the \"info\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand({\n name: 'setup',\n description: 'Sets up cert and hosts file settings for the relevant inner loop domain and https preferences.',\n options: {\n force: new Option('--force', 'Forces execution of setup steps.'),\n },\n hideSharedOptions: ['cachePath', 'features'],\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAM9E,gCAAgC;AAChC,eAAO,MAAM,IAAI,EAAE,mBAkBlB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InvalidArgumentError, Option } from 'commander';
|
|
2
2
|
import { parseBundleMode } from '../../utilities/parseBundleMode.js';
|
|
3
3
|
import { portNumbers } from 'get-port';
|
|
4
|
+
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
4
5
|
/** Defines the "start" verb. */
|
|
5
6
|
export const init = (program) => {
|
|
6
7
|
program.addSubCommand({
|
|
@@ -10,10 +11,10 @@ export const init = (program) => {
|
|
|
10
11
|
mode: new Option('--mode <mode>', 'The mode to run the app in. (library | development | production)')
|
|
11
12
|
.argParser(parseBundleMode)
|
|
12
13
|
.default('library'),
|
|
13
|
-
logResolveMap:
|
|
14
|
+
logResolveMap: reusedOptions.logResolveMap(),
|
|
14
15
|
app: new Option('--app <appPackageName>', 'Run Cloudpack targeting a specific app.'),
|
|
15
16
|
open: new Option('--no-open', 'Do not open the browser.'),
|
|
16
|
-
cache:
|
|
17
|
+
cache: reusedOptions.noCache(),
|
|
17
18
|
apiServerPort: getPortOption('--api-server-port <port>', 'API'),
|
|
18
19
|
appServerPort: getPortOption('--app-server-port <port>', 'app'),
|
|
19
20
|
bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,gCAAgC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAe;QAClC,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE;YACP,IAAI,EAAE,IAAI,MAAM,CAAC,eAAe,EAAE,kEAAkE,CAAC;iBAClG,SAAS,CAAC,eAAe,CAAC;iBAC1B,OAAO,CAAC,SAAS,CAAC;YACrB,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;YAC5C,GAAG,EAAE,IAAI,MAAM,CAAC,wBAAwB,EAAE,yCAAyC,CAAC;YACpF,IAAI,EAAE,IAAI,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC;YACzD,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE;YAC9B,aAAa,EAAE,aAAa,CAAC,0BAA0B,EAAE,KAAK,CAAC;YAC/D,aAAa,EAAE,aAAa,CAAC,0BAA0B,EAAE,KAAK,CAAC;YAC/D,gBAAgB,EAAE,aAAa,CAAC,6BAA6B,EAAE,QAAQ,CAAC;SACzE;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,SAAS,aAAa,CAAC,KAAa,EAAE,IAAY;IAChD,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,uBAAuB,IAAI,wDAAwD,CAAC;SAC1G,SAAS,CAAC,UAAU,CAAC;SACrB,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,KAAK,GAAG,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACrB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,oBAAoB,CAAC,qCAAqC,KAAK,GAAG,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { InvalidArgumentError, Option } from 'commander';\nimport type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { parseBundleMode } from '../../utilities/parseBundleMode.js';\nimport { portNumbers } from 'get-port';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"start\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<StartOptions>({\n name: 'start',\n description: 'Starts a web inner-loop from the current package folder.',\n options: {\n mode: new Option('--mode <mode>', 'The mode to run the app in. (library | development | production)')\n .argParser(parseBundleMode)\n .default('library'),\n logResolveMap: reusedOptions.logResolveMap(),\n app: new Option('--app <appPackageName>', 'Run Cloudpack targeting a specific app.'),\n open: new Option('--no-open', 'Do not open the browser.'),\n cache: reusedOptions.noCache(),\n apiServerPort: getPortOption('--api-server-port <port>', 'API'),\n appServerPort: getPortOption('--app-server-port <port>', 'app'),\n bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n\nfunction getPortOption(flags: string, name: string) {\n return new Option(flags, `Port to use for the ${name} server (single, comma-separated, or range with dash).`)\n .argParser(parsePorts)\n .hideHelp();\n}\n\nfunction parsePorts(value: string): number[] {\n if (value.includes('-')) {\n const split = value.split('-');\n if (split.length !== 2) {\n throw new InvalidArgumentError(`Invalid port range: \"${value}\"`);\n }\n return [...portNumbers(parseNumber(split[0]), parseNumber(split[1]))];\n }\n\n return value.split(',').map(parseNumber);\n}\n\nfunction parseNumber(value: string) {\n value = value.trim();\n const parsed = parseInt(value, 10);\n if (isNaN(parsed)) {\n throw new InvalidArgumentError(`Port must be a number; received: \"${value}\"`);\n }\n return parsed;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/unlink/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/unlink/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAI9E,iCAAiC;AACjC,eAAO,MAAM,IAAI,EAAE,mBAUlB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reusedOptions } from '../../utilities/reusedOptions.js';
|
|
2
2
|
/** Defines the "unlink" verb. */
|
|
3
3
|
export const init = (program) => {
|
|
4
4
|
program.addSubCommand({
|
|
5
5
|
name: 'unlink',
|
|
6
6
|
description: 'Unlinks the package or packages found within the current folder from an existing Cloudpack start session.',
|
|
7
7
|
options: {
|
|
8
|
-
logResolveMap:
|
|
8
|
+
logResolveMap: reusedOptions.logResolveMap(),
|
|
9
9
|
},
|
|
10
10
|
getExecutor: () => import('./execute.js'),
|
|
11
11
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/unlink/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/unlink/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,iCAAiC;AACjC,MAAM,CAAC,MAAM,IAAI,GAAwB,CAAC,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,aAAa,CAAgB;QACnC,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,2GAA2G;QAC7G,OAAO,EAAE;YACP,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE;SAC7C;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { CommandInitFunction } from '../../types/CommandInitFunction.js';\nimport type { UnlinkOptions } from './types/UnlinkOptions.js';\nimport { reusedOptions } from '../../utilities/reusedOptions.js';\n\n/** Defines the \"unlink\" verb. */\nexport const init: CommandInitFunction = (program) => {\n program.addSubCommand<UnlinkOptions>({\n name: 'unlink',\n description:\n 'Unlinks the package or packages found within the current folder from an existing Cloudpack start session.',\n options: {\n logResolveMap: reusedOptions.logResolveMap(),\n },\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command, Option, type Argument, type OutputConfiguration } from 'commander';
|
|
1
|
+
import { Command, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';
|
|
2
2
|
import type { CommandActionModule } from '../types/CommandAction.js';
|
|
3
3
|
import type { ProgramOptions } from '../types/ProgramOptions.js';
|
|
4
4
|
import type { SharedOptions } from '../types/SharedOptions.js';
|
|
@@ -27,13 +27,22 @@ interface CloudpackCommandParams<TOptions extends object, TArguments extends obj
|
|
|
27
27
|
usage?: string;
|
|
28
28
|
/** Alternative name for the command */
|
|
29
29
|
alias?: string;
|
|
30
|
+
/** Extra text to be displayed with the built-in help. */
|
|
31
|
+
addHelpText?: {
|
|
32
|
+
/**
|
|
33
|
+
* `'before'` or `'after'` to affect just this command.
|
|
34
|
+
* `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.
|
|
35
|
+
*/
|
|
36
|
+
position: AddHelpTextPosition;
|
|
37
|
+
text: string;
|
|
38
|
+
};
|
|
30
39
|
/** Output options override (mainly for testing) */
|
|
31
40
|
outputOptions?: OutputConfiguration;
|
|
32
41
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
42
|
+
* The shared options are relevant for most commands, but this allows omitting them from help
|
|
43
|
+
* where they're not relevant. `true` hides all shared options, or an array hides specific ones.
|
|
35
44
|
*/
|
|
36
|
-
|
|
45
|
+
hideSharedOptions?: Array<keyof SharedOptions> | true;
|
|
37
46
|
}
|
|
38
47
|
/**
|
|
39
48
|
* This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudpackCommand.d.ts","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
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AACH,qBAAa,gBAAgB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IAC9E,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,eAAe,CAAiB;IAExC;;;OAGG;gBAGD,MAAM,EAAE,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG;QACrD,cAAc,EAAE,cAAc,CAAC;QAC/B,+DAA+D;QAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB;IAiDH,8BAA8B;IACvB,aAAa,CAAC,aAAa,SAAS,MAAM,EAAE,eAAe,SAAS,MAAM,GAAG,KAAK,EACvF,MAAM,EAAE,sBAAsB,CAAC,aAAa,EAAE,eAAe,CAAC,GAC7D,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC;IAQnD,qEAAqE;IACxD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC,qGAAqG;IACrG,OAAO,CAAC,aAAa;IAMrB,iGAAiG;IACjG,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,UAAU;CAoCnB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command, Option } from 'commander';
|
|
1
|
+
import { Command, Help, Option } from 'commander';
|
|
2
2
|
import { isCIBuild } from '../utilities/isCIBuild.js';
|
|
3
3
|
import { CommandExecutor } from './CommandExecutor.js';
|
|
4
4
|
/**
|
|
@@ -23,8 +23,10 @@ export class CloudpackCommand {
|
|
|
23
23
|
command.version(params.programOptions.version);
|
|
24
24
|
command.description(params.description);
|
|
25
25
|
command.allowExcessArguments(false);
|
|
26
|
+
command.createHelp = () => new CloudpackHelp();
|
|
26
27
|
params.usage && command.usage(params.usage);
|
|
27
28
|
params.alias && command.alias(params.alias);
|
|
29
|
+
params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);
|
|
28
30
|
params.outputOptions && command.configureOutput(params.outputOptions);
|
|
29
31
|
params.getExecutor && this._addAction(params.getExecutor);
|
|
30
32
|
if (params.args) {
|
|
@@ -44,8 +46,8 @@ export class CloudpackCommand {
|
|
|
44
46
|
// In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)
|
|
45
47
|
new Option('-n, --no-color', 'Disable colors in the output.').default(!process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild()),
|
|
46
48
|
features: new Option('--features <featureNames...>', 'Enable experimental features.'),
|
|
47
|
-
cachePath: new Option('--cache-path <path>', 'Custom cache folder.'),
|
|
48
|
-
});
|
|
49
|
+
cachePath: new Option('--cache-path <path>', 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.'),
|
|
50
|
+
}, params.hideSharedOptions);
|
|
49
51
|
}
|
|
50
52
|
/** Create a child command. */
|
|
51
53
|
addSubCommand(params) {
|
|
@@ -72,11 +74,12 @@ export class CloudpackCommand {
|
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
/** Add options. The generic enforces that option objects are included for all keys of a type. */
|
|
75
|
-
_addOptions(options,
|
|
77
|
+
_addOptions(options, hideOptions) {
|
|
76
78
|
for (const [name, option] of Object.entries(options)) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
+
if (hideOptions === true || hideOptions?.includes(name)) {
|
|
80
|
+
option.hideHelp();
|
|
79
81
|
}
|
|
82
|
+
this._command.addOption(option);
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
_addAction(getExecutor) {
|
|
@@ -112,4 +115,14 @@ export class CloudpackCommand {
|
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
117
|
}
|
|
118
|
+
class CloudpackHelp extends Help {
|
|
119
|
+
visibleOptions(cmd) {
|
|
120
|
+
const options = super.visibleOptions(cmd);
|
|
121
|
+
if (cmd.name() !== 'cloudpack') {
|
|
122
|
+
// Remove --version from help except at the top level (it's not very useful)
|
|
123
|
+
return options.filter((option) => option.name() !== 'version');
|
|
124
|
+
}
|
|
125
|
+
return options;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
115
128
|
//# s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O,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;aACL,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * Skip these shared options. The shared options are relevant for most commands, but this allows\n * omitting them where they're not relevant (and none of the options are required, so it's fine).\n */\n skipSharedOptions?: Array<keyof SharedOptions>;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>({\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild(),\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option('--cache-path <path>', 'Custom cache folder.'),\n });\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n skipOptions: Array<keyof TAddOptions> = [],\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (!skipOptions.includes(name)) {\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAqE,MAAM,WAAW,CAAC;AAIrH,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAsDvD;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QACpC,OA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CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,aAAc,SAAQ,IAAI;IAC9B,cAAc,CAAC,GAAY;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE1C,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;YAC/B,4EAA4E;YAC5E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,SAAS,CAAC,CAAC;QACjE,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { Command, Help, Option, type AddHelpTextPosition, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Extra text to be displayed with the built-in help. */\n addHelpText?: {\n /**\n * `'before'` or `'after'` to affect just this command.\n * `'beforeAll'` or `'afterAll'` to affect this command and all its subcommands.\n */\n position: AddHelpTextPosition;\n text: string;\n };\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * The shared options are relevant for most commands, but this allows omitting them from help\n * where they're not relevant. `true` hides all shared options, or an array hides specific ones.\n */\n hideSharedOptions?: Array<keyof SharedOptions> | true;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n command.createHelp = () => new CloudpackHelp();\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.addHelpText && command.addHelpText(params.addHelpText.position, params.addHelpText.text);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>(\n {\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild(),\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option(\n '--cache-path <path>',\n 'Custom cache folder. To change the default, run `cloudpack config set cachePath <path>`.',\n ),\n },\n params.hideSharedOptions,\n );\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n hideOptions?: Array<keyof TAddOptions> | true,\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (hideOptions === true || hideOptions?.includes(name)) {\n option.hideHelp();\n }\n this._command.addOption(option);\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n\nclass CloudpackHelp extends Help {\n visibleOptions(cmd: Command): Option[] {\n const options = super.visibleOptions(cmd);\n\n if (cmd.name() !== 'cloudpack') {\n // Remove --version from help except at the top level (it's not very useful)\n return options.filter((option) => option.name() !== 'version');\n }\n\n return options;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* These options are used by multiple commands, but should be manually added.
|
|
4
|
+
*/
|
|
5
|
+
export declare const reusedOptions: {
|
|
6
|
+
logResolveMap: () => Option;
|
|
7
|
+
noCache: () => Option;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=reusedOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,aAAa;;;CAIzB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Option } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* These options are used by multiple commands, but should be manually added.
|
|
4
|
+
*/
|
|
5
|
+
export const reusedOptions = {
|
|
6
|
+
logResolveMap: () => new Option('--log-resolve-map', 'Logs the resolve map to "resolve-map.json" for diagnostics.'),
|
|
7
|
+
noCache: () => new Option('--no-cache', 'Ensures Cloudpack rebuilds all packages, rather than utilizing cached assets.'),
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=reusedOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,EAAE,6DAA6D,CAAC;IACnH,OAAO,EAAE,GAAG,EAAE,CACZ,IAAI,MAAM,CAAC,YAAY,EAAE,+EAA+E,CAAC;CAC5G,CAAC","sourcesContent":["import { Option } from 'commander';\n\n/**\n * These options are used by multiple commands, but should be manually added.\n */\nexport const reusedOptions = {\n logResolveMap: () => new Option('--log-resolve-map', 'Logs the resolve map to \"resolve-map.json\" for diagnostics.'),\n noCache: () =>\n new Option('--no-cache', 'Ensures Cloudpack rebuilds all packages, rather than utilizing cached assets.'),\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.69.
|
|
3
|
+
"version": "0.69.4",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
"cloudpack": "./bin/cloudpack.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@ms-cloudpack/api-server": "^0.51.
|
|
14
|
-
"@ms-cloudpack/app-server": "^0.15.
|
|
15
|
-
"@ms-cloudpack/common-types": "^0.19.
|
|
16
|
-
"@ms-cloudpack/config": "^0.28.
|
|
13
|
+
"@ms-cloudpack/api-server": "^0.51.4",
|
|
14
|
+
"@ms-cloudpack/app-server": "^0.15.8",
|
|
15
|
+
"@ms-cloudpack/common-types": "^0.19.2",
|
|
16
|
+
"@ms-cloudpack/config": "^0.28.2",
|
|
17
17
|
"@ms-cloudpack/feature-flags": "^0.1.1",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.7",
|
|
19
|
-
"@ms-cloudpack/overlay": "^0.17.
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^10.0.
|
|
19
|
+
"@ms-cloudpack/overlay": "^0.17.61",
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^10.0.2",
|
|
21
21
|
"@ms-cloudpack/path-string-parsing": "^1.2.4",
|
|
22
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
22
|
+
"@ms-cloudpack/path-utilities": "^2.7.39",
|
|
23
23
|
"@ms-cloudpack/remote-cache": "^0.8.7",
|
|
24
|
-
"@ms-cloudpack/setup-utilities": "^0.3.
|
|
24
|
+
"@ms-cloudpack/setup-utilities": "^0.3.1",
|
|
25
25
|
"@ms-cloudpack/task-reporter": "^0.14.4",
|
|
26
26
|
"@ms-cloudpack/telemetry": "^0.6.2",
|
|
27
27
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"workspace-tools": "^0.36.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@ms-cloudpack/common-types": "^0.19.
|
|
39
|
+
"@ms-cloudpack/common-types": "^0.19.2",
|
|
40
40
|
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
41
41
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
42
42
|
"@ms-cloudpack/test-utilities": "^0.5.0",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"build": "cloudpack-scripts build",
|
|
51
51
|
"lint:update": "cloudpack-scripts lint-update",
|
|
52
52
|
"lint": "cloudpack-scripts lint",
|
|
53
|
+
"prepack": "cp .npmignore lib/.npmignore",
|
|
53
54
|
"test:update": "cloudpack-scripts test-update",
|
|
54
55
|
"test:watch": "cloudpack-scripts test-watch",
|
|
55
56
|
"test": "cloudpack-scripts test"
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandTestSetup.js","sourceRoot":"","sources":["../../src/__fixtures__/commandTestSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,oDAAoD;AACpD,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AAIjE;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACtE,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACxE,MAAM,sBAAsB,GAAG,IAAI,CAAC,EAAE,EAA6B,CAAC;IACpE,iBAAiB,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAElE,4DAA4D;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,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M,GAAG,CAAC,CAAC;IACpD,IAAI,CAAC,aAAa,EAAE,CAAC;IAErB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,oCAAoC;QACpC,MAAM,CACJ,yGAAyG,CAC1G,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC","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 +0,0 @@
|
|
|
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,19 +0,0 @@
|
|
|
1
|
-
export function createMockSession(params) {
|
|
2
|
-
return {
|
|
3
|
-
...params,
|
|
4
|
-
config: { appPath: '/path/to/app', mode: 'library', generated: {} },
|
|
5
|
-
projectName: 'app',
|
|
6
|
-
resolveMap: {},
|
|
7
|
-
sequence: 0,
|
|
8
|
-
urls: {},
|
|
9
|
-
targetVersions: {},
|
|
10
|
-
sessionVersion: 1,
|
|
11
|
-
incrementSessionVersion: () => { },
|
|
12
|
-
incrementTargetVersion: () => { },
|
|
13
|
-
importMap: { imports: {} },
|
|
14
|
-
linkedPaths: [],
|
|
15
|
-
addLinkedPath: () => Promise.resolve({ resolveMap: {}, linkedPaths: [] }),
|
|
16
|
-
removeLinkedPath: () => Promise.resolve({ resolveMap: {}, linkedPaths: [] }),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=createMockSession.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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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,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"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
//# source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,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"]}
|