@ms-cloudpack/cli 0.68.3 → 0.69.1
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__/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 +3 -2
- 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/getSessionToLink.d.ts +2 -0
- package/lib/commands/link/getSessionToLink.d.ts.map +1 -1
- package/lib/commands/link/getSessionToLink.js +1 -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/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 +4 -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 +7 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/commands/config/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAW5D,gDAAgD;AAChD,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,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IAE7B,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEnC,IAAI,CAAC;QACH,qFAAqF;QACrF,yCAAyC;QACzC,MAAM,oBAAoB,CAAC,EAAE,GAAG,EAAE,GAA4B,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5E,6EAA6E;QAC7E,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,kBAAkB,GAAG,MAAO,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE;SACpE,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { updateUserPreference } from '@ms-cloudpack/config';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport type { UserPreferences } from '@ms-cloudpack/common-types';\n\nexport interface SetOptions {}\n\nexport interface SetArguments {\n key: string;\n value: string;\n}\n\n/** Delete a Cloudpack user preference value. */\nexport const execute: CommandAction<SetOptions> = async (params) => {\n const { cwd, args, initialize, exit } = params;\n const [key, newValue] = args;\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: key as keyof UserPreferences, newValue });\n // Following the pattern of other tools, we don't output anything on success.\n await exit({ message: '' });\n } catch (err) {\n await exit({\n hasErrors: true,\n message: `Failed to set \"${key}\": ${(err as Error).message || err}`,\n });\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;
|
|
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,mBAwBlB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Option } from 'commander';
|
|
2
|
+
const skipSharedOptions = ['cachePath', 'features'];
|
|
2
3
|
/** Defines the "info" verb. */
|
|
3
4
|
export const init = (program) => {
|
|
4
5
|
const infoCommand = program.addSubCommand({
|
|
@@ -10,12 +11,14 @@ export const init = (program) => {
|
|
|
10
11
|
name: 'lock-file',
|
|
11
12
|
alias: 'lockfile',
|
|
12
13
|
description: 'Get info about potentially problematic deps from the lock file (yarn v1 only).',
|
|
14
|
+
skipSharedOptions,
|
|
13
15
|
getExecutor: () => import('./lockFile/execute.js'),
|
|
14
16
|
});
|
|
15
17
|
infoCommand.addSubCommand({
|
|
16
18
|
name: 'non-semver-deps',
|
|
17
19
|
description: 'Get a list of non-semver deps from local packages.',
|
|
18
20
|
getExecutor: () => import('./nonSemverDeps/execute.js'),
|
|
21
|
+
skipSharedOptions,
|
|
19
22
|
options: {
|
|
20
23
|
prod: new Option('--prod', 'Only get production deps'),
|
|
21
24
|
},
|
|
@@ -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;
|
|
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;KACnB,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 skipSharedOptions: 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 });\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 skipSharedOptions,\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 skipSharedOptions,\n options: {\n prod: new Option('--prod', 'Only get production deps'),\n },\n });\n};\n"]}
|
|
@@ -4,7 +4,7 @@ import { findCloudpackAppPaths } from '../../utilities/findCloudpackAppPaths.js'
|
|
|
4
4
|
import { InitSummaryData } from './InitSummaryData.js';
|
|
5
5
|
/** Given the path, updates the Cloudpack config with overrides and project settings. */
|
|
6
6
|
export const execute = async (params) => {
|
|
7
|
-
const { options, cwd, initialize,
|
|
7
|
+
const { options, cwd, initialize, exit, autoDispose, setInterruptMessageHandler } = params;
|
|
8
8
|
const appPaths = findCloudpackAppPaths(cwd);
|
|
9
9
|
// `findCloudpackAppPaths` will only return an array of paths in which cloudpack.config.json was found.
|
|
10
10
|
// To ensure initialize can be run even if no cloudpack.config.json was found, we use the cwd directory as a fallback.
|
|
@@ -15,7 +15,7 @@ export const execute = async (params) => {
|
|
|
15
15
|
options,
|
|
16
16
|
isInterrupted: true,
|
|
17
17
|
}));
|
|
18
|
-
const summaries = await init({ appSummaries, options, contexts,
|
|
18
|
+
const summaries = await init({ appSummaries, options, contexts, autoDispose });
|
|
19
19
|
await exit({
|
|
20
20
|
exitCode: summaries.some((summary) => summary.failed) ? 1 : 0,
|
|
21
21
|
message: formatInitSummary({ summaries, options }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/init/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/init/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,GAAG,MAAM,CAAC;IAE3F,MAAM,QAAQ,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAE5C,uGAAuG;IACvG,sHAAsH;IACtH,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAExF,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CACrC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CACnF,CAAC;IAEF,0BAA0B,CAAC,GAAG,EAAE,CAC9B,iBAAiB,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACvE,OAAO;QACP,aAAa,EAAE,IAAI;KACpB,CAAC,CACH,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;IAE/E,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,OAAO,EAAE,iBAAiB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;KACnD,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { InitOptions } from './types/InitOptions.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { init } from './init.js';\nimport { formatInitSummary } from './formatInitSummary.js';\nimport { findCloudpackAppPaths } from '../../utilities/findCloudpackAppPaths.js';\nimport { InitSummaryData } from './InitSummaryData.js';\n\n/** Given the path, updates the Cloudpack config with overrides and project settings. */\nexport const execute: CommandAction<InitOptions> = async (params) => {\n const { options, cwd, initialize, exit, autoDispose, setInterruptMessageHandler } = params;\n\n const appPaths = findCloudpackAppPaths(cwd);\n\n // `findCloudpackAppPaths` will only return an array of paths in which cloudpack.config.json was found.\n // To ensure initialize can be run even if no cloudpack.config.json was found, we use the cwd directory as a fallback.\n const contexts = await initialize({ appPaths: appPaths.length > 0 ? appPaths : [cwd] });\n\n const appSummaries = Object.fromEntries(\n contexts.map((context) => [context.appPath, new InitSummaryData(context.appPath)]),\n );\n\n setInterruptMessageHandler(() =>\n formatInitSummary({\n summaries: Object.values(appSummaries).map((s) => s.summarize(options)),\n options,\n isInterrupted: true,\n }),\n );\n\n const summaries = await init({ appSummaries, options, contexts, autoDispose });\n\n await exit({\n exitCode: summaries.some((summary) => summary.failed) ? 1 : 0,\n message: formatInitSummary({ summaries, options }),\n });\n};\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
2
1
|
import type { AutoDispose } from '../../types/AutoDispose.js';
|
|
3
2
|
import type { InitOptions } from './types/InitOptions.js';
|
|
4
3
|
import type { InitSummary } from './types/InitSummary.js';
|
|
@@ -11,7 +10,6 @@ export declare function init(parameters: {
|
|
|
11
10
|
options: InitOptions;
|
|
12
11
|
contexts: AppCommandContext[];
|
|
13
12
|
autoDispose: AutoDispose;
|
|
14
|
-
reporter: TaskReporter;
|
|
15
13
|
/**
|
|
16
14
|
* App summary objects, created ahead of time so that a partial summary can be generated
|
|
17
15
|
* if the process is interrupted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOtE;;GAEG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE;IACrC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CAC/C,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAoBzB"}
|
|
@@ -12,14 +12,13 @@ import { optimizeDependencies } from './optimizeDependencies.js';
|
|
|
12
12
|
* Init execution function.
|
|
13
13
|
*/
|
|
14
14
|
export async function init(parameters) {
|
|
15
|
-
const { options, contexts,
|
|
15
|
+
const { options, contexts, autoDispose, appSummaries } = parameters;
|
|
16
16
|
const summaries = [];
|
|
17
17
|
const taskRunner = new TaskRunner();
|
|
18
18
|
for (const appContext of contexts) {
|
|
19
19
|
const summary = await initApp({
|
|
20
20
|
appContext,
|
|
21
21
|
options,
|
|
22
|
-
reporter,
|
|
23
22
|
autoDispose,
|
|
24
23
|
summaryData: appSummaries[appContext.appPath],
|
|
25
24
|
taskRunner,
|
|
@@ -30,19 +29,16 @@ export async function init(parameters) {
|
|
|
30
29
|
return summaries;
|
|
31
30
|
}
|
|
32
31
|
async function initApp(params) {
|
|
33
|
-
const { appContext, options,
|
|
32
|
+
const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;
|
|
34
33
|
const { appPath, config, telemetryClient } = appContext;
|
|
35
34
|
// Run prerequisites for the app.
|
|
36
|
-
runPrerequisites(
|
|
35
|
+
runPrerequisites(appContext);
|
|
37
36
|
// If --reset is specified, reset the generated config.
|
|
38
37
|
if (options.reset) {
|
|
39
38
|
config.generated = {};
|
|
40
39
|
}
|
|
41
40
|
const apiContext = await createPartialApiContext({
|
|
42
|
-
|
|
43
|
-
config,
|
|
44
|
-
reporter,
|
|
45
|
-
telemetryClient,
|
|
41
|
+
...appContext,
|
|
46
42
|
items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],
|
|
47
43
|
taskRunner,
|
|
48
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAOpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,UAU1B;IACC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IA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AAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { AppCommandContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n reporter: TaskReporter;\n /**\n * App summary objects, created ahead of time so that a partial summary can be generated\n * if the process is interrupted.\n */\n appSummaries: Record<string, InitSummaryData>;\n}): Promise<InitSummary[]> {\n const { options, contexts, reporter, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n const taskRunner = new TaskRunner();\n\n for (const appContext of contexts) {\n const summary = await initApp({\n appContext,\n options,\n reporter,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n isMultiApp: contexts.length > 1,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n reporter: TaskReporter;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, reporter, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n\n // Run prerequisites for the app.\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const apiContext: Context = await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Log the resolve map to a file if requested.\n if (options.logResolveMap) {\n console.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n const priorityMap = new Map<string, number>();\n\n // Start with the app path or requested matches\n const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];\n if (!initialPaths.length) {\n reject(); // getFilteredPackages will log an error\n }\n\n enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>) {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n // Get the priority value for this package path, defaults to 0.\n const priority = priorityMap.get(packagePath) ?? 0;\n // Lower priority of this package path by 1.\n priorityMap.set(packagePath, priority - 1);\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n appPath,\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n // No need to force if we're in a multi-app scenario\n // as we'll re-evaluate packages if they are different since we use a different task id.\n shouldForce: !isMultiApp && shouldForce,\n isMultiApp,\n priority,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them\n // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through\n // on single app runs.\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n reject(error);\n });\n }\n }\n });\n\n if (config.features?.optimizeDependencies) {\n // Conditionally scan dependency usage so that we can populate\n // include/excludeDependencies automatically, ensuring the dep list\n // is both minimal (remove unused deps) and complete (include\n // specific devDeps.)\n const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n for (const [packagePath, errors] of Object.entries(packageResults)) {\n summaryData.addErrors(packagePath, errors);\n }\n }\n\n const summary = summaryData.summarize(options);\n\n // The feature \"removeUnusedExports\" doesn't (yet) write summary changes, but we still\n // want to write the generated config if that featureFlag is on.\n const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;\n\n if (!options.check && hasSummaryChanges) {\n // Update the generated config: either write it if there are settings, or delete it if it\n // previously existed but is no longer needed.\n const generatedResult = await writeGeneratedConfig(config.generated, appPath);\n if (generatedResult === 'deleted') {\n summary.deletedGeneratedConfig = true;\n }\n }\n\n return summary;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot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AAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;YACnE,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAE/C,sFAAsF;IACtF,gEAAgE;IAChE,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,EAAE,mBAAmB,IAAI,OAAO,CAAC,YAAY,CAAC;IAEvF,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,iBAAiB,EAAE,CAAC;QACxC,yFAAyF;QACzF,8CAA8C;QAC9C,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9E,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { type Context, TaskRunner } from '@ms-cloudpack/api-server';\nimport type { PackageImporterContext } from '@ms-cloudpack/common-types';\nimport type { AutoDispose } from '../../types/AutoDispose.js';\nimport type { InitOptions } from './types/InitOptions.js';\nimport type { InitSummary } from './types/InitSummary.js';\n\nimport { createPartialApiContext } from '@ms-cloudpack/api-server';\nimport { writeGeneratedConfig } from '@ms-cloudpack/config';\nimport type { InitSummaryData } from './InitSummaryData.js';\nimport { evaluatePath } from './evaluatePath.js';\nimport { verifyExports } from './verifyExports.js';\nimport type { AppCommandContext } from '../../types/CommandAction.js';\nimport path from 'path';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getFilteredPackages } from '../../utilities/getFilteredPackages.js';\nimport { optimizeDependencies } from './optimizeDependencies.js';\n\n/**\n * Init execution function.\n */\nexport async function init(parameters: {\n options: InitOptions;\n contexts: AppCommandContext[];\n autoDispose: AutoDispose;\n /**\n * App summary objects, created ahead of time so that a partial summary can be generated\n * if the process is interrupted.\n */\n appSummaries: Record<string, InitSummaryData>;\n}): Promise<InitSummary[]> {\n const { options, contexts, autoDispose, appSummaries } = parameters;\n\n const summaries: InitSummary[] = [];\n\n const taskRunner = new TaskRunner();\n\n for (const appContext of contexts) {\n const summary = await initApp({\n appContext,\n options,\n autoDispose,\n summaryData: appSummaries[appContext.appPath],\n taskRunner,\n isMultiApp: contexts.length > 1,\n });\n summaries.push(summary);\n }\n\n return summaries;\n}\n\nasync function initApp(params: {\n appContext: AppCommandContext;\n options: InitOptions;\n autoDispose: AutoDispose;\n summaryData: InitSummaryData;\n taskRunner: TaskRunner;\n isMultiApp: boolean;\n}): Promise<InitSummary> {\n const { appContext, options, autoDispose, summaryData, taskRunner, isMultiApp } = params;\n const { appPath, config, telemetryClient } = appContext;\n\n // Run prerequisites for the app.\n runPrerequisites(appContext);\n\n // If --reset is specified, reset the generated config.\n if (options.reset) {\n config.generated = {};\n }\n\n const apiContext: Context = await createPartialApiContext({\n ...appContext,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n taskRunner,\n });\n autoDispose(apiContext);\n const resolveMap = apiContext.session.resolveMap;\n\n // Log the resolve map to a file if requested.\n if (options.logResolveMap) {\n console.log('\\nWriting resolve map to `resolve-map.json`.');\n await writeJson(path.join(appPath, 'resolve-map.json'), resolveMap);\n }\n\n // Ensure config.generated.packageSettings is initialized.\n config.generated.packageSettings ??= [];\n\n await new Promise<void>((resolve, reject) => {\n let pending = 0;\n let isExitingPrematurely = false;\n const visitedSet = new Set<string>();\n const refreshPaths = new Set<string>();\n const priorityMap = new Map<string, number>();\n\n // Start with the app path or requested matches\n const initialPaths = options.match ? getFilteredPackages(resolveMap, options.match) : [appPath];\n if (!initialPaths.length) {\n reject(); // getFilteredPackages will log an error\n }\n\n enqueuePaths(new Map(initialPaths.map((packagePath) => [packagePath, undefined])));\n\n /**\n * Enqueue more paths.\n * @param newPaths Mapping from package path to importer context.\n */\n function enqueuePaths(newPaths: Map<string, PackageImporterContext | undefined>) {\n if (isExitingPrematurely) {\n return;\n }\n\n // Iterate through the given paths.\n for (const [packagePath, importerContext] of newPaths) {\n if (visitedSet.has(packagePath)) {\n continue;\n }\n\n visitedSet.add(packagePath);\n pending++;\n\n const shouldForce = refreshPaths.delete(packagePath);\n\n // Get the priority value for this package path, defaults to 0.\n const priority = priorityMap.get(packagePath) ?? 0;\n // Lower priority of this package path by 1.\n priorityMap.set(packagePath, priority - 1);\n\n // Evaluate this path, but don't await - when we're done, we'll re-enqueue newly discovered paths.\n evaluatePath({\n appPath,\n packagePath,\n importerContext,\n config,\n telemetryClient,\n resolveMap,\n initOptions: options,\n summaryData,\n ctx: apiContext,\n // No need to force if we're in a multi-app scenario\n // as we'll re-evaluate packages if they are different since we use a different task id.\n shouldForce: !isMultiApp && shouldForce,\n isMultiApp,\n priority,\n })\n .then(({ pathsToEvaluate, pathsToRefresh, shouldExit }) => {\n pending--;\n\n if (shouldExit) {\n isExitingPrematurely = true;\n } else if (pathsToEvaluate?.size) {\n // If there are packages that need to be rebuilt, delete them from the visited set to re-enqueue them\n // and add them to the refresh set so that on re-enqueuing we pass the `shouldRerun` flag through\n // on single app runs.\n pathsToRefresh?.forEach((refreshPath) => {\n refreshPaths.add(refreshPath);\n visitedSet.delete(refreshPath);\n });\n\n // Try to enqueue the new paths.\n enqueuePaths(pathsToEvaluate);\n }\n\n // If nothing is pending after this call, we're complete.\n if (!pending) {\n resolve();\n }\n })\n .catch((error) => {\n reject(error);\n });\n }\n }\n });\n\n if (config.features?.optimizeDependencies) {\n // Conditionally scan dependency usage so that we can populate\n // include/excludeDependencies automatically, ensuring the dep list\n // is both minimal (remove unused deps) and complete (include\n // specific devDeps.)\n const excludedDependenciesChanges = await optimizeDependencies(summaryData.getResults(), apiContext);\n summaryData.recordGeneratedChanges(excludedDependenciesChanges);\n }\n\n if (config.features?.verifyExports) {\n const packageResults = await verifyExports(summaryData.getResults(), apiContext);\n for (const [packagePath, errors] of Object.entries(packageResults)) {\n summaryData.addErrors(packagePath, errors);\n }\n }\n\n const summary = summaryData.summarize(options);\n\n // The feature \"removeUnusedExports\" doesn't (yet) write summary changes, but we still\n // want to write the generated config if that featureFlag is on.\n const hasSummaryChanges = config.features?.removeUnusedExports || summary.totalChanges;\n\n if (!options.check && hasSummaryChanges) {\n // Update the generated config: either write it if there are settings, or delete it if it\n // previously existed but is no longer needed.\n const generatedResult = await writeGeneratedConfig(config.generated, appPath);\n if (generatedResult === 'deleted') {\n summary.deletedGeneratedConfig = true;\n }\n }\n\n return summary;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAO1D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CAuD9C,CAAC"}
|
|
@@ -9,20 +9,20 @@ import path from 'path';
|
|
|
9
9
|
export const execute = async (params) => {
|
|
10
10
|
// Use the current directory as the default package path.
|
|
11
11
|
const { options, cwd: appPath, reporter, initialize, exit } = params;
|
|
12
|
-
const { ignore: ignoredPackages, all: includeAll, ignoreResolutions, resolveStrategy, logResolveMap } = options;
|
|
12
|
+
const { ignore: ignoredPackages, all: includeAll, ignoreResolutions, resolveStrategy, logResolveMap, cachePath, } = options;
|
|
13
13
|
await initialize({ appPath });
|
|
14
14
|
console.debug('Linking packages...');
|
|
15
15
|
console.debug('Include all:', !!includeAll);
|
|
16
16
|
console.debug('Ignored packages:', ignoredPackages?.join(', ') || 'none');
|
|
17
17
|
console.debug('Apply host resolutions:', !ignoreResolutions);
|
|
18
18
|
console.debug('Resolve strategy:', resolveStrategy);
|
|
19
|
-
const session = await getSessionToLink({ reporter, exit });
|
|
19
|
+
const session = await getSessionToLink({ reporter, exit, cachePath });
|
|
20
20
|
const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });
|
|
21
21
|
const includeMessage = includeAll ? ' including all internal paths' : '';
|
|
22
22
|
const message = `Linking paths for ${session.projectName} at "${appPath}"${includeMessage}`;
|
|
23
23
|
const task = reporter.addTask(message);
|
|
24
|
-
//
|
|
25
|
-
const
|
|
24
|
+
// Send request to api server to link paths.
|
|
25
|
+
const { resolveMap, linkedPaths } = await client.linkPath.query({
|
|
26
26
|
linkedPath: {
|
|
27
27
|
path: appPath,
|
|
28
28
|
ignoredPackages,
|
|
@@ -30,9 +30,7 @@ export const execute = async (params) => {
|
|
|
30
30
|
ignoreResolutions,
|
|
31
31
|
resolveStrategy,
|
|
32
32
|
},
|
|
33
|
-
};
|
|
34
|
-
// Send request to api server to link paths.
|
|
35
|
-
const { resolveMap, linkedPaths } = await client.linkPath.query(data);
|
|
33
|
+
});
|
|
36
34
|
await client.close();
|
|
37
35
|
if (linkedPaths.find((p) => p.path === appPath) === undefined) {
|
|
38
36
|
// Close down with an error.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/link/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,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E,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,wCAAwC;QACxC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,yBAAyB,CAAC,EAAE,UAAU,CAAC,CAAC;IAC7E,CAAC;IAED,2BAA2B;IAC3B,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;IAE7F,MAAM,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { CommandAction } from '../../types/CommandAction.js';\nimport type { LinkOptions } from './types/LinkOptions.js';\nimport { getSessionToLink } from './getSessionToLink.js';\nimport { createCloudpackClient } from '@ms-cloudpack/api-server';\nimport { formatLinkSummary } from './formatLinkSummary.js';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\n/**\n * Defines the \"link\" verb entry point.\n */\nexport const execute: CommandAction<LinkOptions> = async (params) => {\n // Use the current directory as the default package path.\n const { options, cwd: appPath, reporter, initialize, exit } = params;\n const {\n ignore: ignoredPackages,\n all: includeAll,\n ignoreResolutions,\n resolveStrategy,\n logResolveMap,\n cachePath,\n } = options;\n\n await initialize({ appPath });\n\n console.debug('Linking packages...');\n console.debug('Include all:', !!includeAll);\n console.debug('Ignored packages:', ignoredPackages?.join(', ') || 'none');\n console.debug('Apply host resolutions:', !ignoreResolutions);\n console.debug('Resolve strategy:', resolveStrategy);\n\n const session = await getSessionToLink({ reporter, exit, cachePath });\n const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });\n\n const includeMessage = includeAll ? ' including all internal paths' : '';\n const message = `Linking paths for ${session.projectName} at \"${appPath}\"${includeMessage}`;\n const task = reporter.addTask(message);\n\n // Send request to api server to link paths.\n const { resolveMap, linkedPaths } = await client.linkPath.query({\n linkedPath: {\n path: appPath,\n ignoredPackages,\n includeAll,\n ignoreResolutions,\n resolveStrategy,\n },\n });\n await client.close();\n\n if (linkedPaths.find((p) => p.path === appPath) === undefined) {\n // Close down with an error.\n task.complete({ status: 'fail', message: `Failed to link paths.`, forceShow: true });\n await exit({ exitCode: 1, message: 'Failed to link paths.' });\n }\n\n if (logResolveMap) {\n // Write the linked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-linked.json'), resolveMap);\n }\n\n // Close down successfully.\n task.complete({ status: 'complete', message: `Linked paths`, forceShow: true });\n const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths, resolveStrategy });\n\n await exit({ exitCode: 0, message: linkSummary });\n};\n"]}
|
|
@@ -13,6 +13,8 @@ type SessionWithRequiredApiServer = Session & {
|
|
|
13
13
|
export declare function getSessionToLink(options: {
|
|
14
14
|
reporter: TaskReporter;
|
|
15
15
|
exit: CommandActionParams<object>['exit'];
|
|
16
|
+
/** Cache path from CLI options */
|
|
17
|
+
cachePath: string | undefined;
|
|
16
18
|
}): Promise<SessionWithRequiredApiServer>;
|
|
17
19
|
export {};
|
|
18
20
|
//# sourceMappingURL=getSessionToLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSessionToLink.d.ts","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGxD,KAAK,4BAA4B,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getSessionToLink.d.ts","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGxD,KAAK,4BAA4B,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE9E;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1C,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAwCxC"}
|
|
@@ -8,7 +8,7 @@ import { getCachePath } from '@ms-cloudpack/config';
|
|
|
8
8
|
export async function getSessionToLink(options) {
|
|
9
9
|
const { reporter, exit } = options;
|
|
10
10
|
// Find the list of running sessions.
|
|
11
|
-
const cachePath = getCachePath();
|
|
11
|
+
const cachePath = await getCachePath(options.cachePath);
|
|
12
12
|
const runningSessions = await getActiveSessions({ reporter, cachePath });
|
|
13
13
|
if (runningSessions.length === 0) {
|
|
14
14
|
await exit({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSessionToLink.js","sourceRoot":"","sources":["../../../src/commands/link/getSessionToLink.ts"],"names":[],"mappings":"AACA,OAAO,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,CAAC,WAAW;YAC1B,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC,EAAE;YACtD,KAAK,EAAE,OAAO;SACf;KACF,CAAC,CACH,CAAC;IAEF,qCAAqC;IACrC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IAC7D,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAE/C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,8CAA8C;QAC9C,MAAM,IAAI,CAAC;YACT,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,uDAAuD;SACjE,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAuC,CAAC;AACjD,CAAC","sourcesContent":["import type { CommandActionParams } from '../../types/CommandAction.js';\nimport { getActiveSessions } from './getActiveSessions.js';\nimport { getSessionFromUser } from './getSessionFromUser.js';\nimport type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { Session } from '@ms-cloudpack/api-server';\nimport { getCachePath } from '@ms-cloudpack/config';\n\ntype SessionWithRequiredApiServer = Session & { urls: { apiServer: string } };\n\n/**\n * Get a single active session to link packages.\n * The session must have an API server URL.\n */\nexport async function getSessionToLink(options: {\n reporter: TaskReporter;\n exit: CommandActionParams<object>['exit'];\n /** Cache path from CLI options */\n cachePath: string | undefined;\n}): Promise<SessionWithRequiredApiServer> {\n const { reporter, exit } = options;\n\n // Find the list of running sessions.\n const cachePath = await getCachePath(options.cachePath);\n const runningSessions = await getActiveSessions({ reporter, cachePath });\n\n if (runningSessions.length === 0) {\n await exit({\n exitCode: 1,\n message: 'No running sessions found. Please start a session using `cloudpack start` first.',\n });\n }\n\n console.debug(`Running sessions: ${runningSessions.map((session) => session.id).join(', ')}`);\n\n const runningSessionsMap = new Map(\n runningSessions.map((session) => [\n session.id,\n {\n title: session.projectName,\n description: session.config.appPath + ' ' + session.id,\n value: session,\n },\n ]),\n );\n\n // Select a session to link packages.\n const session = await getSessionFromUser(runningSessionsMap);\n console.debug('Selected session:', session.id);\n\n if (!session.urls.apiServer) {\n // We should never get here, but just in case.\n await exit({\n exitCode: 1,\n message: 'The selected session does not have an API server URL.',\n });\n }\n\n return session as SessionWithRequiredApiServer;\n}\n"]}
|
|
@@ -4,10 +4,10 @@ export const init = (program) => {
|
|
|
4
4
|
program.addSubCommand({
|
|
5
5
|
name: 'setup',
|
|
6
6
|
description: 'Sets up cert and hosts file settings for the relevant inner loop domain and https preferences.',
|
|
7
|
-
usage: '<command>',
|
|
8
7
|
options: {
|
|
9
8
|
force: new Option('--force', 'Forces execution of setup steps.'),
|
|
10
9
|
},
|
|
10
|
+
skipSharedOptions: ['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,
|
|
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 skipSharedOptions: ['cachePath', 'features'],\n getExecutor: () => import('./execute.js'),\n });\n};\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { CommandAction } from '../../types/CommandAction.js';
|
|
2
2
|
import type { StartOptions } from './types/StartOptions.js';
|
|
3
|
-
/** Stop all started cloudpack instances, for testing */
|
|
4
|
-
export declare function stopServers(): Promise<void>;
|
|
5
3
|
/**
|
|
6
4
|
* Defines the "start" verb entry point.
|
|
7
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAKlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,YAAY,CA+I/C,CAAC"}
|
|
@@ -11,24 +11,19 @@ import { getStartingAppPath } from './getStartingAppPath.js';
|
|
|
11
11
|
import { openBrowser } from './openBrowser.js';
|
|
12
12
|
import { trackSession } from './trackSession.js';
|
|
13
13
|
import { getCertificate } from '@ms-cloudpack/setup-utilities';
|
|
14
|
-
|
|
15
|
-
/** Stop all started cloudpack instances, for testing */
|
|
16
|
-
export async function stopServers() {
|
|
17
|
-
if (exitFunction) {
|
|
18
|
-
await exitFunction({ exitCode: 0, message: 'stopServers called' });
|
|
19
|
-
exitFunction = undefined;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
14
|
+
import { setStopServersFunction } from '../../utilities/stopServers.js';
|
|
22
15
|
/**
|
|
23
16
|
* Defines the "start" verb entry point.
|
|
24
17
|
*/
|
|
25
18
|
export const execute = async (params) => {
|
|
26
|
-
const { options, cwd, initialize,
|
|
19
|
+
const { options, cwd, initialize, autoDispose, exit } = params;
|
|
20
|
+
setStopServersFunction(exit);
|
|
27
21
|
const appPath = await getStartingAppPath(cwd, options.app);
|
|
28
|
-
const
|
|
22
|
+
const apiContextOptions = await initialize({ appPath, mode: options.mode });
|
|
23
|
+
const { config, telemetryClient } = apiContextOptions;
|
|
29
24
|
console.log('App path:', yellow(appPath));
|
|
30
25
|
console.log('Bundle mode:', yellow(options.mode));
|
|
31
|
-
runPrerequisites(
|
|
26
|
+
runPrerequisites(apiContextOptions);
|
|
32
27
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
33
28
|
let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);
|
|
34
29
|
// If overlay is an internal package, resolve the overlay from the current package's linked node modules
|
|
@@ -38,10 +33,7 @@ export const execute = async (params) => {
|
|
|
38
33
|
overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;
|
|
39
34
|
}
|
|
40
35
|
const [apiContext] = autoDispose(await createPartialApiContext({
|
|
41
|
-
|
|
42
|
-
config,
|
|
43
|
-
reporter,
|
|
44
|
-
telemetryClient,
|
|
36
|
+
...apiContextOptions,
|
|
45
37
|
items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],
|
|
46
38
|
overlayPath,
|
|
47
39
|
}));
|
|
@@ -70,7 +62,7 @@ export const execute = async (params) => {
|
|
|
70
62
|
let apiServer;
|
|
71
63
|
// Start api server for tracking status and handling remote requests.
|
|
72
64
|
try {
|
|
73
|
-
apiServer = await createCloudpackServer(apiContext);
|
|
65
|
+
apiServer = await createCloudpackServer({ port: options.apiServerPort }, apiContext);
|
|
74
66
|
}
|
|
75
67
|
catch (err) {
|
|
76
68
|
const error = err;
|
|
@@ -97,7 +89,8 @@ export const execute = async (params) => {
|
|
|
97
89
|
const { startServers } = await import('@ms-cloudpack/app-server');
|
|
98
90
|
const servers = await startServers({
|
|
99
91
|
definition,
|
|
100
|
-
bundleServerOptions: { disableCache: !options.cache },
|
|
92
|
+
bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },
|
|
93
|
+
port: options.appServerPort,
|
|
101
94
|
}, apiContext);
|
|
102
95
|
// Save the session to active sessions.
|
|
103
96
|
const sessionTracker = await trackSession(session);
|
|
@@ -119,7 +112,6 @@ export const execute = async (params) => {
|
|
|
119
112
|
}));
|
|
120
113
|
};
|
|
121
114
|
autoDispose({ dispose: cleanup });
|
|
122
|
-
exitFunction = exit;
|
|
123
115
|
const defaultUrl = makeUrl(config.devServer?.defaultPath || '', session.urls.appServer).href;
|
|
124
116
|
performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);
|
|
125
117
|
// Open the browser.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE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AAC;gBACH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YACjC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,iBAAiB,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAClC,YAAY,GAAG,IAAI,CAAC;IAEpB,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;IAE7F,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;IAEpE,oBAAoB;IACpB,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACpC,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport type { CommandAction, CommandActionParams } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCertificate } from '@ms-cloudpack/setup-utilities';\n\nlet exitFunction: CommandActionParams<StartOptions>['exit'] | undefined;\n\n/** Stop all started cloudpack instances, for testing */\nexport async function stopServers() {\n if (exitFunction) {\n await exitFunction({ exitCode: 0, message: 'stopServers called' });\n exitFunction = undefined;\n }\n}\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, reporter, autoDispose, exit } = params;\n const appPath = await getStartingAppPath(cwd, options.app);\n const { config, telemetryClient } = await initialize({ appPath, mode: options.mode });\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n runPrerequisites({ config, cwd: appPath, telemetryClient });\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);\n\n // If overlay is an internal package, resolve the overlay from the current package's linked node modules\n // to \"externalize\" it, so that we always use the bundled version of the overlay instead of the source.\n if (overlayPath && !isExternalPackage(overlayPath)) {\n const cliPath = await resolve('@ms-cloudpack/cli', currentDir);\n overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;\n }\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n appPath,\n config,\n reporter,\n telemetryClient,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath,\n }),\n );\n const { packages, session } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // If a cert is needed, check that it exists.\n if (config.devServer?.https === true && !(await getCertificate({ domain: config.devServer?.domain, cwd: appPath }))) {\n await exit({\n exitCode: 1,\n message: `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\nRun \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.\\n`,\n });\n return;\n }\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n let apiServer: Awaited<ReturnType<typeof createCloudpackServer>> | undefined;\n\n // Start api server for tracking status and handling remote requests.\n try {\n apiServer = await createCloudpackServer(apiContext);\n } catch (err) {\n const error = err as { code: string };\n\n if (error.code === 'EADDRNOTAVAIL' && config.devServer?.domain) {\n const primaryDomain: string =\n (Array.isArray(config.devServer.domain) ? config.devServer.domain[0] : config.devServer.domain) ||\n '<unspecified>';\n\n await exit({\n exitCode: 1,\n message:\n `The domain \"${cyan(bold(primaryDomain))}\" in cloudpack.config.json is not resolvable.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to add the appropriate entries to your hosts file and ` +\n `try start again.\\n`,\n });\n\n return;\n }\n\n console.error('Error creating api server:', err);\n\n throw err;\n }\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache },\n },\n apiContext,\n );\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n exitFunction = exit;\n\n const defaultUrl = makeUrl(config.devServer?.defaultPath || '', session.urls.appServer).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n// cspell:ignore Prereqs\n"]}
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/start/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,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,WAAW,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC;IAE7F,WAAW,CAAC,OAAO,CAAC,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;IAEpE,oBAAoB;IACpB,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACpC,sEAAsE;YACtE,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;YAC1D,OAAO,CAAC,IAAI,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;AACH,CAAC,CAAC;AAEF,wBAAwB","sourcesContent":["import { createPartialApiContext, ensurePackageBundled } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { isExternalPackage, resolve } from '@ms-cloudpack/package-utilities';\nimport { makeUrl } from '@ms-cloudpack/path-string-parsing';\nimport { cyan, yellow, bold } from '@ms-cloudpack/task-reporter';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport { PerfMarkerCliEntry, PerfMeasurementOpenBrowser } from '../../performance/markers.js';\nimport type { CommandAction } from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { getStartingAppPath } from './getStartingAppPath.js';\nimport { openBrowser } from './openBrowser.js';\nimport { trackSession } from './trackSession.js';\nimport type { StartOptions } from './types/StartOptions.js';\nimport { getCertificate } from '@ms-cloudpack/setup-utilities';\nimport { setStopServersFunction } from '../../utilities/stopServers.js';\n\n/**\n * Defines the \"start\" verb entry point.\n */\nexport const execute: CommandAction<StartOptions> = async (params) => {\n const { options, cwd, initialize, autoDispose, exit } = params;\n setStopServersFunction(exit);\n\n const appPath = await getStartingAppPath(cwd, options.app);\n const apiContextOptions = await initialize({ appPath, mode: options.mode });\n const { config, telemetryClient } = apiContextOptions;\n\n console.log('App path:', yellow(appPath));\n console.log('Bundle mode:', yellow(options.mode));\n\n runPrerequisites(apiContextOptions);\n\n const currentDir = path.dirname(fileURLToPath(import.meta.url));\n let overlayPath = await resolve('@ms-cloudpack/overlay', currentDir);\n\n // If overlay is an internal package, resolve the overlay from the current package's linked node modules\n // to \"externalize\" it, so that we always use the bundled version of the overlay instead of the source.\n if (overlayPath && !isExternalPackage(overlayPath)) {\n const cliPath = await resolve('@ms-cloudpack/cli', currentDir);\n overlayPath = cliPath ? path.join(cliPath, 'node_modules', '@ms-cloudpack/overlay') : undefined;\n }\n\n const [apiContext] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'watcher', 'taskRunner', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n overlayPath,\n }),\n );\n const { packages, session } = apiContext;\n\n // Increment the session version if caching is disabled.\n if (options.cache === false) {\n session.incrementSessionVersion();\n }\n\n // Make sure the package has a valid definition.\n const definition = await packages.get(appPath);\n\n // Set shared telemetry attributes which will be sent with all telemetry events.\n telemetryClient.setSharedSpanAttribute('sessionId', session.id);\n\n if (options.logResolveMap) {\n // Write the resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map.json'), session.resolveMap);\n }\n\n // If a cert is needed, check that it exists.\n if (config.devServer?.https === true && !(await getCertificate({ domain: config.devServer?.domain, cwd: appPath }))) {\n await exit({\n exitCode: 1,\n message: `The local site is configured to use https in cloudpack.config.json, but is missing a cert.\\n\\nRun \"${cyan(bold('cloudpack setup'))}\" to create the required certificate and try start again.\\n`,\n });\n return;\n }\n\n const { createCloudpackServer } = await import('@ms-cloudpack/api-server');\n let apiServer: Awaited<ReturnType<typeof createCloudpackServer>> | undefined;\n\n // Start api server for tracking status and handling remote requests.\n try {\n apiServer = await createCloudpackServer({ port: options.apiServerPort }, apiContext);\n } catch (err) {\n const error = err as { code: string };\n\n if (error.code === 'EADDRNOTAVAIL' && config.devServer?.domain) {\n const primaryDomain: string =\n (Array.isArray(config.devServer.domain) ? config.devServer.domain[0] : config.devServer.domain) ||\n '<unspecified>';\n\n await exit({\n exitCode: 1,\n message:\n `The domain \"${cyan(bold(primaryDomain))}\" in cloudpack.config.json is not resolvable.\\n\\n` +\n `Run \"${cyan(bold('cloudpack setup'))}\" to add the appropriate entries to your hosts file and ` +\n `try start again.\\n`,\n });\n\n return;\n }\n\n console.error('Error creating api server:', err);\n\n throw err;\n }\n\n // Kick off bundling app package as soon as api server is ready.\n void ensurePackageBundled({\n input: { name: definition.name, version: definition.version },\n ctx: apiContext,\n });\n\n // Then start bundle and app servers for hosting the app.\n const { startServers } = await import('@ms-cloudpack/app-server');\n const servers = await startServers(\n {\n definition,\n bundleServerOptions: { disableCache: !options.cache, port: options.bundleServerPort },\n port: options.appServerPort,\n },\n apiContext,\n );\n\n // Save the session to active sessions.\n const sessionTracker = await trackSession(session);\n\n const cleanup = async () => {\n // Stop tracking the session.\n await sessionTracker.close();\n\n await Promise.all(\n Object.entries({ apiServer, ...servers }).map(async ([name, server]) => {\n if (!server) return;\n\n const desc = `${name} (${server.url})`;\n console.info(`Closing ${desc}`);\n try {\n await server.close();\n console.info(`Closed ${desc}`);\n } catch (err) {\n console.warn(`Error closing ${desc}:`, err);\n }\n }),\n );\n };\n\n autoDispose({ dispose: cleanup });\n\n const defaultUrl = makeUrl(config.devServer?.defaultPath || '', session.urls.appServer).href;\n\n performance.measure(PerfMeasurementOpenBrowser, PerfMarkerCliEntry);\n\n // Open the browser.\n if (options.open !== false) {\n openBrowser(defaultUrl).catch((err) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.warn('Error opening browser:', err?.stack || err);\n console.warn('Please open the browser manually to:', defaultUrl);\n });\n } else {\n console.log('Please open the browser manually to:', defaultUrl);\n }\n};\n\n// cspell:ignore Prereqs\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;AAK9E,gCAAgC;AAChC,eAAO,MAAM,IAAI,EAAE,mBAqBlB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Option } from 'commander';
|
|
1
|
+
import { InvalidArgumentError, Option } from 'commander';
|
|
2
2
|
import { parseBundleMode } from '../../utilities/parseBundleMode.js';
|
|
3
|
+
import { portNumbers } from 'get-port';
|
|
3
4
|
/** Defines the "start" verb. */
|
|
4
5
|
export const init = (program) => {
|
|
5
6
|
program.addSubCommand({
|
|
@@ -13,8 +14,34 @@ export const init = (program) => {
|
|
|
13
14
|
app: new Option('--app <appPackageName>', 'Run Cloudpack targeting a specific app.'),
|
|
14
15
|
open: new Option('--no-open', 'Do not open the browser.'),
|
|
15
16
|
cache: new Option('--no-cache', 'Ensures Cloudpack rebuilds all packages when requested, rather than utilizing cached assets.'),
|
|
17
|
+
apiServerPort: getPortOption('--api-server-port <port>', 'API'),
|
|
18
|
+
appServerPort: getPortOption('--app-server-port <port>', 'app'),
|
|
19
|
+
bundleServerPort: getPortOption('--bundle-server-port <port>', 'bundle'),
|
|
16
20
|
},
|
|
17
21
|
getExecutor: () => import('./execute.js'),
|
|
18
22
|
});
|
|
19
23
|
};
|
|
24
|
+
function getPortOption(flags, name) {
|
|
25
|
+
return new Option(flags, `Port to use for the ${name} server (single, comma-separated, or range with dash).`)
|
|
26
|
+
.argParser(parsePorts)
|
|
27
|
+
.hideHelp();
|
|
28
|
+
}
|
|
29
|
+
function parsePorts(value) {
|
|
30
|
+
if (value.includes('-')) {
|
|
31
|
+
const split = value.split('-');
|
|
32
|
+
if (split.length !== 2) {
|
|
33
|
+
throw new InvalidArgumentError(`Invalid port range: "${value}"`);
|
|
34
|
+
}
|
|
35
|
+
return [...portNumbers(parseNumber(split[0]), parseNumber(split[1]))];
|
|
36
|
+
}
|
|
37
|
+
return value.split(',').map(parseNumber);
|
|
38
|
+
}
|
|
39
|
+
function parseNumber(value) {
|
|
40
|
+
value = value.trim();
|
|
41
|
+
const parsed = parseInt(value, 10);
|
|
42
|
+
if (isNaN(parsed)) {
|
|
43
|
+
throw new InvalidArgumentError(`Port must be a number; received: "${value}"`);
|
|
44
|
+
}
|
|
45
|
+
return parsed;
|
|
46
|
+
}
|
|
20
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/start/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,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;AAEvC,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,IAAI,MAAM,CAAC,mBAAmB,EAAE,6DAA6D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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';\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: new Option('--log-resolve-map', 'Logs the resolve map to \"resolve-map.json\" for diagnostics.'),\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: new Option(\n '--no-cache',\n 'Ensures Cloudpack rebuilds all packages when requested, rather than utilizing cached assets.',\n ),\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"]}
|
|
@@ -10,5 +10,11 @@ export interface StartOptions {
|
|
|
10
10
|
open?: boolean;
|
|
11
11
|
/** Whether to use the cache on first request (default true) */
|
|
12
12
|
cache?: boolean;
|
|
13
|
+
/** Mostly for testing: custom port for the API server */
|
|
14
|
+
apiServerPort?: number | number[];
|
|
15
|
+
/** Mostly for testing: custom port for the app server (also set in config via `devServer.port`) */
|
|
16
|
+
appServerPort?: number | number[];
|
|
17
|
+
/** Mostly for testing: custom port for the bundle server */
|
|
18
|
+
bundleServerPort?: number | number[];
|
|
13
19
|
}
|
|
14
20
|
//# sourceMappingURL=StartOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,6DAA6D;IAC7D,IAAI,EAAE,UAAU,CAAC;IAEjB,wGAAwG;IACxG,GAAG,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"StartOptions.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,6DAA6D;IAC7D,IAAI,EAAE,UAAU,CAAC;IAEjB,wGAAwG;IACxG,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,iDAAiD;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,mGAAmG;IACnG,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAElC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartOptions.js","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMode } from '@ms-cloudpack/common-types';\n\nexport interface StartOptions {\n /** Writes the resolve map to `resolve-map.json`. */\n logResolveMap?: boolean;\n\n /** The mode to start in (library/development/production). */\n mode: BundleMode;\n\n /** Specifies which specific app to run, in the case of running `init` at a higher level in the repo. */\n app?: string;\n /** Whether to open the browser (default true) */\n open?: boolean;\n /** Whether to use the cache on first request (default true) */\n cache?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StartOptions.js","sourceRoot":"","sources":["../../../../src/commands/start/types/StartOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { BundleMode } from '@ms-cloudpack/common-types';\n\nexport interface StartOptions {\n /** Writes the resolve map to `resolve-map.json`. */\n logResolveMap?: boolean;\n\n /** The mode to start in (library/development/production). */\n mode: BundleMode;\n\n /** Specifies which specific app to run, in the case of running `init` at a higher level in the repo. */\n app?: string;\n\n /** Whether to open the browser (default true) */\n open?: boolean;\n\n /** Whether to use the cache on first request (default true) */\n cache?: boolean;\n\n /** Mostly for testing: custom port for the API server */\n apiServerPort?: number | number[];\n\n /** Mostly for testing: custom port for the app server (also set in config via `devServer.port`) */\n appServerPort?: number | number[];\n\n /** Mostly for testing: custom port for the bundle server */\n bundleServerPort?: number | number[];\n}\n"]}
|