@ms-cloudpack/cli 0.72.55 → 0.72.57

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.
Files changed (61) hide show
  1. package/lib/commands/bundle/execute.js +7 -10
  2. package/lib/commands/bundle/execute.js.map +1 -1
  3. package/lib/commands/init/evaluatePath.js +10 -13
  4. package/lib/commands/init/evaluatePath.js.map +1 -1
  5. package/lib/commands/init/optimizeDependencies.d.ts +1 -2
  6. package/lib/commands/init/optimizeDependencies.d.ts.map +1 -1
  7. package/lib/commands/init/optimizeDependencies.js.map +1 -1
  8. package/lib/commands/init/verifyExports.d.ts +1 -2
  9. package/lib/commands/init/verifyExports.d.ts.map +1 -1
  10. package/lib/commands/init/verifyExports.js.map +1 -1
  11. package/lib/commands/link/formatLinkSummary.d.ts +1 -2
  12. package/lib/commands/link/formatLinkSummary.d.ts.map +1 -1
  13. package/lib/commands/link/formatLinkSummary.js.map +1 -1
  14. package/lib/commands/link/getActiveSessions.d.ts +1 -1
  15. package/lib/commands/link/getActiveSessions.d.ts.map +1 -1
  16. package/lib/commands/link/getActiveSessions.js.map +1 -1
  17. package/lib/commands/link/getSessionToLink.d.ts +1 -1
  18. package/lib/commands/link/getSessionToLink.d.ts.map +1 -1
  19. package/lib/commands/link/getSessionToLink.js.map +1 -1
  20. package/lib/commands/start/execute.d.ts.map +1 -1
  21. package/lib/commands/start/execute.js +2 -5
  22. package/lib/commands/start/execute.js.map +1 -1
  23. package/lib/commands/start/openBrowser.d.ts +4 -7
  24. package/lib/commands/start/openBrowser.d.ts.map +1 -1
  25. package/lib/commands/start/openBrowser.js +6 -3
  26. package/lib/commands/start/openBrowser.js.map +1 -1
  27. package/lib/commands/start/trackSession.d.ts +1 -1
  28. package/lib/commands/start/trackSession.d.ts.map +1 -1
  29. package/lib/commands/start/trackSession.js.map +1 -1
  30. package/lib/commands/sync/execute.d.ts.map +1 -1
  31. package/lib/commands/sync/execute.js +6 -10
  32. package/lib/commands/sync/execute.js.map +1 -1
  33. package/lib/types/AppPathDiscoveryMode.d.ts +2 -1
  34. package/lib/types/AppPathDiscoveryMode.d.ts.map +1 -1
  35. package/lib/types/AppPathDiscoveryMode.js.map +1 -1
  36. package/lib/utilities/CommandExecutor.d.ts.map +1 -1
  37. package/lib/utilities/CommandExecutor.js +18 -6
  38. package/lib/utilities/CommandExecutor.js.map +1 -1
  39. package/lib/utilities/{discoverAppPaths.d.ts → discoverLocalAppPaths.d.ts} +4 -4
  40. package/lib/utilities/discoverLocalAppPaths.d.ts.map +1 -0
  41. package/lib/utilities/{discoverAppPaths.js → discoverLocalAppPaths.js} +3 -3
  42. package/lib/utilities/discoverLocalAppPaths.js.map +1 -0
  43. package/lib/utilities/discoverRemoteAppPaths.d.ts +17 -0
  44. package/lib/utilities/discoverRemoteAppPaths.d.ts.map +1 -0
  45. package/lib/utilities/discoverRemoteAppPaths.js +53 -0
  46. package/lib/utilities/discoverRemoteAppPaths.js.map +1 -0
  47. package/lib/utilities/getDefaultLogin.d.ts +3 -0
  48. package/lib/utilities/getDefaultLogin.d.ts.map +1 -0
  49. package/lib/utilities/getDefaultLogin.js +5 -0
  50. package/lib/utilities/getDefaultLogin.js.map +1 -0
  51. package/lib/utilities/reusedOptions.d.ts +1 -0
  52. package/lib/utilities/reusedOptions.d.ts.map +1 -1
  53. package/lib/utilities/reusedOptions.js +1 -1
  54. package/lib/utilities/reusedOptions.js.map +1 -1
  55. package/lib/utilities/selectItemFromPaginatedResults.d.ts +20 -0
  56. package/lib/utilities/selectItemFromPaginatedResults.d.ts.map +1 -0
  57. package/lib/utilities/selectItemFromPaginatedResults.js +60 -0
  58. package/lib/utilities/selectItemFromPaginatedResults.js.map +1 -0
  59. package/package.json +5 -5
  60. package/lib/utilities/discoverAppPaths.d.ts.map +0 -1
  61. package/lib/utilities/discoverAppPaths.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMxD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAW5F"}
1
+ {"version":3,"file":"trackSession.d.ts","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAM1D;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAW5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,+EAA+E;YAC/E,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/api-server';\nimport { getActiveSessionsPath } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { rm } from 'fs/promises';\nimport path from 'path';\n\n/**\n * Tracks active sessions to disk as they are started. This gives us a way to enumerate\n * all active sessions for scenarios like better error messages when sessions are already\n * running for a given path, or for the link verb where we want to manipulate an active\n * running session.\n */\nexport async function trackSession(session: Session): Promise<{ close: () => Promise<void> }> {\n const activeSessionPath = path.join(getActiveSessionsPath(session.cachePath), `${session.id}.json`);\n\n await writeJson(activeSessionPath, session);\n\n return {\n async close() {\n // Don't error if something has already deleted the file (most likely in tests)\n await rm(activeSessionPath, { force: true });\n },\n };\n}\n"]}
1
+ {"version":3,"file":"trackSession.js","sourceRoot":"","sources":["../../../src/commands/start/trackSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB;IACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpG,MAAM,SAAS,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO;QACL,KAAK,CAAC,KAAK;YACT,+EAA+E;YAC/E,MAAM,EAAE,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Session } from '@ms-cloudpack/common-types';\nimport { getActiveSessionsPath } from '@ms-cloudpack/api-server';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport { rm } from 'fs/promises';\nimport path from 'path';\n\n/**\n * Tracks active sessions to disk as they are started. This gives us a way to enumerate\n * all active sessions for scenarios like better error messages when sessions are already\n * running for a given path, or for the link verb where we want to manipulate an active\n * running session.\n */\nexport async function trackSession(session: Session): Promise<{ close: () => Promise<void> }> {\n const activeSessionPath = path.join(getActiveSessionsPath(session.cachePath), `${session.id}.json`);\n\n await writeJson(activeSessionPath, session);\n\n return {\n async close() {\n // Don't error if something has already deleted the file (most likely in tests)\n await rm(activeSessionPath, { force: true });\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CA8E9C,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,aAAa,EAEnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAM1D,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,WAAW,CA2E9C,CAAC"}
@@ -25,21 +25,17 @@ export const execute = async (params) => {
25
25
  message: 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',
26
26
  };
27
27
  }
28
+ const ctx = await createPartialApiContext({
29
+ ...params,
30
+ remoteCacheClientLoginMethod: login,
31
+ });
28
32
  let syncResult;
29
33
  if (upload) {
30
34
  await runPrerequisites(params);
31
- const ctx = await createPartialApiContext({
32
- ...params,
33
- remoteCacheClientLoginMethod: login,
34
- });
35
- syncResult = await syncUpload({ input: undefined, ctx });
35
+ syncResult = await syncUpload({ login }, ctx);
36
36
  }
37
37
  else {
38
- const ctx = await createPartialApiContext({
39
- ...params,
40
- remoteCacheClientLoginMethod: login,
41
- });
42
- syncResult = await syncDownload({ input: undefined, ctx });
38
+ syncResult = await syncDownload(undefined, ctx);
43
39
  }
44
40
  return {
45
41
  message: `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, ` +
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAClD,OAAO,EACL,2BAA2B,EAC3B,oBAAoB,GAGrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGvE,SAAS,cAAc,CAAC,KAAc,EAAE,IAAY;IAClD,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC1E,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAE,MAAM,EAAE,EAAE;IAClE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAElC,IAAI,CAAC;QACH,gGAAgG;QAChG,OAAO,MAAM,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAA8B,EAAE;YAC7G,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;gBAClC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;YACzC,CAAC;YAED,IAAI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AAC,wBAAwB,CAAC,EAAE,CAAC;gBACrG,OAAO;oBACL,OAAO,EAAE,GAAG,CACV,0GAA0G;wBACxG,kGAAkG,CACrG;oBACD,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;YACD,IACE,KAAK,CAAC,IAAI,KAAK,6BAA6B;gBAC5C,CAAC,YAAY,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,EACrF,CAAC;gBACD,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,oEAAoE,CAAC;oBAClF,QAAQ,EAAE,2BAA2B;iBACtC,CAAC;YACJ,CAAC;YAED,IAAI,cAAc,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC;gBAChD,OAAO;oBACL,OAAO,EAAE,GAAG,CAAC,+DAA+D,CAAC;oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, syncDownload, syncUpload, type SyncResult } from '@ms-cloudpack/api-server';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { red } from '@ms-cloudpack/task-reporter';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\nfunction checkErrorCode(error: unknown, code: string): boolean {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, config, telemetryClient } = params;\n const { login, upload } = options;\n\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (!environmentInfo.cloudpack.isSyncEnabled) {\n span.setAttribute('syncDisabled', true);\n return { message: 'Sync is disabled by the user (CLOUDPACK_SYNC environment variable is set).' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n let syncResult: SyncResult;\n if (upload) {\n await runPrerequisites(params);\n\n const ctx = await createPartialApiContext({\n ...params,\n remoteCacheClientLoginMethod: login,\n });\n syncResult = await syncUpload({ input: undefined, ctx });\n } else {\n const ctx = await createPartialApiContext({\n ...params,\n remoteCacheClientLoginMethod: login,\n });\n syncResult = await syncDownload({ input: undefined, ctx });\n }\n\n return {\n message:\n `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, ` +\n `and ${syncResult['already-exist'] + syncResult['not-found']} items that did not require syncing.`,\n };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring the authentication lock. It seems \"cloudpack sync\" may already ` +\n `be running in another process. Please wait for the other process to complete and then try again.`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAmB,MAAM,0BAA0B,CAAC;AAC9G,OA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+DAA+D,CAAC;oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { createPartialApiContext, syncDownload, syncUpload, type SyncResult } from '@ms-cloudpack/api-server';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { red } from '@ms-cloudpack/task-reporter';\nimport {\n ExitCodeAuthenticationError,\n ExitCodeGenericError,\n type CommandAction,\n type CommandExitParams,\n} from '../../types/CommandAction.js';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport type { SyncOptions } from './types/SyncOptions.js';\n\nfunction checkErrorCode(error: unknown, code: string): boolean {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, config, telemetryClient } = params;\n const { login, upload } = options;\n\n try {\n // Await here to ensure that try-catch block catches any errors thrown inside the async function\n return await telemetryClient.tracer.startActiveSpan('SYNC_EXECUTE', async (span): Promise<CommandExitParams> => {\n if (!config.features?.syncBundles) {\n return { message: 'Sync is disabled' };\n }\n\n if (!environmentInfo.cloudpack.isSyncEnabled) {\n span.setAttribute('syncDisabled', true);\n return { message: 'Sync is disabled by the user (CLOUDPACK_SYNC environment variable is set).' };\n }\n\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return {\n message:\n 'Remote cache is not configured. Please add remoteCache to your cloudpack.config.json file to use this feature.',\n };\n }\n\n const ctx = await createPartialApiContext({\n ...params,\n remoteCacheClientLoginMethod: login,\n });\n\n let syncResult: SyncResult;\n if (upload) {\n await runPrerequisites(params);\n\n syncResult = await syncUpload({ login }, ctx);\n } else {\n syncResult = await syncDownload(undefined, ctx);\n }\n\n return {\n message:\n `Sync completed with ${syncResult.success} successes, ${syncResult.failed} failures, ` +\n `and ${syncResult['already-exist'] + syncResult['not-found']} items that did not require syncing.`,\n };\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return {\n message: red(\n `Cloudpack encountered an issue acquiring the authentication lock. It seems \"cloudpack sync\" may already ` +\n `be running in another process. Please wait for the other process to complete and then try again.`,\n ),\n exitCode: ExitCodeGenericError,\n };\n }\n if (\n error.name === 'AuthenticationRequiredError' ||\n ('statusCode' in error && (error.statusCode === '401' || error.statusCode === '403'))\n ) {\n return {\n message: red('Authentication error. Please check your credentials and try again.'),\n exitCode: ExitCodeAuthenticationError,\n };\n }\n\n if (checkErrorCode(error, 'REQUEST_SEND_ERROR')) {\n return {\n message: red('Connection error. Please check your connection and try again.'),\n exitCode: ExitCodeGenericError,\n };\n }\n }\n\n throw error;\n }\n};\n"]}
@@ -8,7 +8,8 @@
8
8
  * - If `discover: 'single'`:
9
9
  * - If a single app is found, return that.
10
10
  * - If multiple apps are found, prompt the user to choose one.
11
+ * - If `discover: 'remote'`, the app will be discovered from the cloud.
11
12
  * - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).
12
13
  */
13
- export type AppPathDiscoveryMode = 'single' | 'multi';
14
+ export type AppPathDiscoveryMode = 'single' | 'multi' | 'remote';
14
15
  //# sourceMappingURL=AppPathDiscoveryMode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppPathDiscoveryMode.d.ts","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"AppPathDiscoveryMode.d.ts","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AppPathDiscoveryMode.js","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * How to discover the app path(s).\n *\n * - If `cwd` contains a `cloudpack.config.json` (and `--app` is not set), that will be\n * the only app path.\n * - Otherwise, glob for `cloudpack.config.json` under `cwd` (filtering by `--app` if set), then:\n * - If `discover: 'multi'`, return all apps found.\n * - If `discover: 'single'`:\n * - If a single app is found, return that.\n * - If multiple apps are found, prompt the user to choose one.\n * - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).\n */\nexport type AppPathDiscoveryMode = 'single' | 'multi';\n"]}
1
+ {"version":3,"file":"AppPathDiscoveryMode.js","sourceRoot":"","sources":["../../src/types/AppPathDiscoveryMode.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * How to discover the app path(s).\n *\n * - If `cwd` contains a `cloudpack.config.json` (and `--app` is not set), that will be\n * the only app path.\n * - Otherwise, glob for `cloudpack.config.json` under `cwd` (filtering by `--app` if set), then:\n * - If `discover: 'multi'`, return all apps found.\n * - If `discover: 'single'`:\n * - If a single app is found, return that.\n * - If multiple apps are found, prompt the user to choose one.\n * - If `discover: 'remote'`, the app will be discovered from the cloud.\n * - If nothing is found, use `cwd` (unless `--app` is set and the name doesn't match).\n */\nexport type AppPathDiscoveryMode = 'single' | 'multi' | 'remote';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAqB,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAK/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAI7E,MAAM,MAAM,0BAA0B,GAAG,aA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CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,YAAY,CAAC,CAAa;IAClC,OAAO,CAAC,sBAAsB,CAAC,CAAe;IAE9C,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAmC;WAE9C,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;gBASzD,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC;IAWnD,uBAAuB;IAEV,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAsErC;;;OAGG;YACW,mBAAmB;IAyGjC,qEAAqE;IACrE,OAAO,CAAC,+BAA+B;YAYzB,cAAc;IAyE5B,SAAS,CAAC,cAAc,QAAO,IAAI,CAgBjC;IAEF;;;OAGG;cACa,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;CAgCjE"}
@@ -7,7 +7,8 @@ import { AutoDisposableList } from './AutoDisposableList.js';
7
7
  import { getVersion } from '@ms-cloudpack/package-utilities';
8
8
  import { environmentInfo } from '@ms-cloudpack/environment';
9
9
  import { getCliStartTime } from './getCliStartTime.js';
10
- import { discoverAppPaths } from './discoverAppPaths.js';
10
+ import { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';
11
+ import { discoverLocalAppPaths } from './discoverLocalAppPaths.js';
11
12
  import { TaskRunner } from '@ms-cloudpack/api-server';
12
13
  /**
13
14
  * This class manages orchestration and shared state while executing a command.
@@ -122,11 +123,22 @@ export class CommandExecutor {
122
123
  let appPaths;
123
124
  if (this._discoverAppPaths) {
124
125
  // Search for cloudpack configs to determine the app path(s)
125
- const appPathsResult = await discoverAppPaths({
126
- cwd: this._programOptions.cwd,
127
- discover: this._discoverAppPaths,
128
- desiredApp: this._options.app,
129
- });
126
+ const appPathsResult = this._discoverAppPaths === 'remote'
127
+ ? await discoverRemoteAppPaths({
128
+ options: {
129
+ login: this._options.login,
130
+ cachePath: this._options.cachePath,
131
+ desiredApp: this._options.app,
132
+ },
133
+ context: {
134
+ reporter: this._reporter,
135
+ },
136
+ })
137
+ : await discoverLocalAppPaths({
138
+ cwd: this._programOptions.cwd,
139
+ discover: this._discoverAppPaths,
140
+ desiredApp: this._options.app,
141
+ });
130
142
  if (!Array.isArray(appPathsResult)) {
131
143
  // This means there was an error (or the user cancelled) while getting app paths.
132
144
  return appPathsResult;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,yBAAyB,CAAC;AACtF,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AA6BtD;;GAEG;AACH,qCAAqC;AACrC,MAAM,OAAO,eAAe;IAgBnB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAyB;QACnD,4FAA4F;QAC5F,KAAK,MAAM,QAAQ,IAAI,eAAe,CAAC,gBAAgB,EAAE,C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E,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AA3UD,yFAAyF;AAC1E,gCAAgB,GAAG,IAAI,GAAG,EAAwB,AAAlC,CAAmC","sourcesContent":["import { readConfig, type ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { getCliStartTime } from './getCliStartTime.js';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverAppPaths } from './discoverAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: (error as Error).stack || (error as Error).message || String(error),\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult = await discoverAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, {\n ...configOptions,\n extraFeatures: this._options.features,\n });\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n void telemetryClient.tracer.startActiveSpan('CLI_ENTRY', { startTime: getCliStartTime() }, () => {\n // Retrieve the current telemetry context\n const activeContext = telemetryClient.context.active();\n\n /**\n * Sets the current context as the root context. This ensures that all spans created during this CLI execution\n * will be children of this root span, even though the root span is closed immediately. This helps group all\n * spans under a single root span for better traceability.\n *\n * Typically, the root span should remain open until the CLI exits. However, in environments like Codespaces,\n * the CLI might run indefinitely, which could leave the root span open indefinitely.\n *\n * To prevent this, the root span is closed immediately after it is set as the root context.\n */\n telemetryClient.setRootContext(activeContext);\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
1
+ {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,IAAI,EACJ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,GAAG,EACH,oBAAoB,EACpB,MAAM,GACP,MAAM,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sBAAsB,EAAE,EAAE,IAAI,qBAAqB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QAEjH,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,mEAAmE;YACnE,8FAA8F;YAC9F,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;gBAC5B,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;qBACxC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,KAAK,GAAG,CAAC;qBAC1C,IAAI,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,0DAA0D,YAAY,GAAG,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;YAE3B,sCAAsC;YACtC,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;YAEzC,8DAA8D;YAC9D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;gBACtB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;gBAC3C,QAAQ,EAAE,QAAQ,KAAK,CAAC;aACzB,CAAC,CAAC;QACL,CAAC;QAED,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAE3C,yEAAyE;QACzE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;;AAvVD,yFAAyF;AAC1E,gCAAgB,GAAG,IAAI,GAAG,EAAwB,AAAlC,CAAmC","sourcesContent":["import { readConfig, type ReadConfigOptions } from '@ms-cloudpack/config';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport {\n TaskReporter,\n bold,\n debugLoggingConfig,\n defaultLoggingConfig,\n noLoggingConfig,\n red,\n verboseLoggingConfig,\n yellow,\n} from '@ms-cloudpack/task-reporter';\nimport { createTelemetryClient, type TelemetryClient } from '@ms-cloudpack/telemetry';\nimport path from 'path';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport { getCliStartTime } from './getCliStartTime.js';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport { discoverRemoteAppPaths } from './discoverRemoteAppPaths.js';\nimport { discoverLocalAppPaths } from './discoverLocalAppPaths.js';\nimport { TaskRunner } from '@ms-cloudpack/api-server';\n\nexport type BaseCommandExecutorOptions = SharedOptions & Pick<ReusedOptions, 'app'>;\n\nexport interface CommandExecutorParams<TOptions extends BaseCommandExecutorOptions = BaseCommandExecutorOptions> {\n /** Command-specific arguments */\n args: string[];\n\n /** Command-specific and shared options. */\n options: TOptions;\n\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n\n /**\n * By default, the command will run against `cwd` (usually `process.cwd()`).\n * If this option is set, attempt to discover app path(s) instead.\n * (`cwd` will still be preferred if it has a `cloudpack.config.json`.)\n * See {@link AppPathDiscoveryMode} for details.\n */\n discoverAppPaths?: AppPathDiscoveryMode;\n}\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\n// 'app' is an optional reused option\nexport class CommandExecutor<TOptions extends BaseCommandExecutorOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _discoverAppPaths: AppPathDiscoveryMode | undefined;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _hasCalledExit = false;\n private _args: string[];\n private _sigintCount = 0;\n private _onInterrupt?: () => void;\n private _getMessageOnInterrupt?: () => string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- options type isn't used\n private static _activeInstances = new Set<CommandExecutor<any>>();\n\n public static async exitAll(params: CommandExitParams): Promise<void> {\n // There should only be one instance at a time, but we assume multiple instances for safety.\n for (const instance of CommandExecutor._activeInstances) {\n await instance._exit(params);\n process.off('SIGINT', instance._sigintHandler);\n }\n CommandExecutor._activeInstances = new Set();\n }\n\n constructor(params: CommandExecutorParams<TOptions>) {\n this._args = params.args;\n this._options = params.options;\n this._execute = params.execute;\n this._programOptions = params.programOptions;\n this._verb = params.verb;\n this._discoverAppPaths = params.discoverAppPaths;\n this._reporter = new TaskReporter();\n this._autoDisposableList = new AutoDisposableList();\n }\n\n /** Run the command. */\n // This has to be a separate method because constructors can't be async.\n public async execute(): Promise<void> {\n CommandExecutor._activeInstances.add(this);\n try {\n // Handle SIGINT (Ctrl+C) gracefully.\n if (!environmentInfo.isJest) {\n process.on('SIGINT', this._sigintHandler);\n }\n\n const contexts = await this._initializeContexts();\n\n if (!Array.isArray(contexts)) {\n await this._exit(contexts);\n return;\n }\n\n const spanName = `${this._verb.toUpperCase().replace(/ /g, '_')}_EXECUTE`;\n const results: CommandExitParams[] = [];\n\n for (const context of contexts) {\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n const result = await context.telemetryClient.tracer.startActiveSpan(spanName, async (span) => {\n this._onInterrupt = () => {\n span.setAttribute('isInterrupted', true);\n span.end();\n };\n\n return this._execute({\n ...context,\n span,\n isMultiApp: contexts.length > 1,\n args: this._args,\n options: this._options,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\n },\n });\n });\n if (result?.isInterrupted) {\n return await this._exit(result);\n }\n if (result) {\n results.push(result);\n } else if ((result as unknown) !== null) {\n // If the command returned null, this means it should keep running (e.g. start).\n // We disallow returning undefined to avoid accidents.\n throw new Error('Command executor must return exit options or null');\n }\n this._onInterrupt = undefined;\n }\n\n if (results.length) {\n // If one or more apps returned a result, exit.\n await this._exit({\n message: results.map((r) => r.message).join('\\n'),\n hasErrors: results.some((r) => r.hasErrors),\n // If any app returned a non-zero exit code, use that.\n exitCode: results.find(({ exitCode }) => !!exitCode)?.exitCode,\n });\n }\n } catch (error) {\n // If an error occurs, exit the process with a non-zero exit code.\n await this._exit({\n hasErrors: true,\n message: (error as Error).stack || (error as Error).message || String(error),\n });\n }\n }\n\n /**\n * Determine the app paths and initialize the context for each app.\n * @returns Context(s), or an exit options object if there was an error. (might also throw on error)\n */\n private async _initializeContexts(): Promise<AppCommandContext[] | CommandExitParams> {\n let appPaths: string[];\n\n if (this._discoverAppPaths) {\n // Search for cloudpack configs to determine the app path(s)\n const appPathsResult =\n this._discoverAppPaths === 'remote'\n ? await discoverRemoteAppPaths({\n options: {\n login: (this._options as unknown as Pick<ReusedOptions, 'login'>).login,\n cachePath: this._options.cachePath,\n desiredApp: this._options.app,\n },\n context: {\n reporter: this._reporter,\n },\n })\n : await discoverLocalAppPaths({\n cwd: this._programOptions.cwd,\n discover: this._discoverAppPaths,\n desiredApp: this._options.app,\n });\n if (!Array.isArray(appPathsResult)) {\n // This means there was an error (or the user cancelled) while getting app paths.\n return appPathsResult;\n }\n appPaths = appPathsResult;\n } else {\n // Just use the cwd\n appPaths = [this._programOptions.cwd];\n }\n\n const configOptions = this._getConfigOptionsFromCliOptions();\n\n // The task runner is shared between all apps so that task results can potentially be reused.\n const taskRunner = new TaskRunner();\n\n const contexts: AppCommandContext[] = [];\n\n const helpMessages = new Set<string>();\n\n const configs: Record<string, CloudpackConfig> = {};\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, {\n ...configOptions,\n extraFeatures: this._options.features,\n });\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // eslint-disable-next-line no-restricted-properties -- this will never be reached, but TypeScript doesn't know that\n process.exit(1);\n }\n if (config.helpMessage) {\n helpMessages.add(config.helpMessage);\n }\n\n configs[appPath] = config;\n }\n\n // Set reporter options and print the product info header\n this._reporter.setOptions({\n productName: 'Cloudpack',\n version: this._programOptions.version,\n description: () => `Running \"${bold(this._programOptions.argv.slice(2).join(' '))}\"`,\n helpMessage: [...helpMessages].join('\\n'),\n plainTextMode: !this._options.color,\n ...(this._options.debug\n ? debugLoggingConfig\n : this._options.verbose\n ? verboseLoggingConfig\n : this._options.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs[appPath];\n const definition = await readJson<PackageJson>(path.join(appPath, 'package.json'));\n const { name = path.basename(appPath) } = definition || {};\n\n const telemetryClient = await this._initTelemetry(name, config);\n // Dispose the telemetry client when the app is closing\n this._autoDisposableList.add({\n dispose: () => telemetryClient.shutdown(),\n });\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n taskRunner,\n });\n }\n\n return contexts;\n }\n\n /** Translate certain CLI options into options for `readConfig()`. */\n private _getConfigOptionsFromCliOptions(): ReadConfigOptions {\n // These options don't exist for all commands, but that's fine.\n const options = this._options as Partial<ReusedOptions & SharedOptions>;\n return {\n mode: options.mode,\n logBundleInfo: options.logBundleInfo,\n // Handle --bundler by passing it as a universal package override, which will be appended\n // to any user-provided packageSettings so that it takes precedence.\n extraPackageSettings: options.bundler ? [{ match: '*', bundler: options.bundler }] : undefined,\n };\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n // Mark the start time for telemetry.\n const startTime = performance.now();\n\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString =\n programOptions.disableTelemetry || environmentInfo.isJest\n ? undefined\n : config.telemetry?.connectionString || environmentInfo.cloudpack.telemetryConnectionString;\n\n const logLevel = options.verbose ? 'VERBOSE' : options.debug ? 'DEBUG' : undefined;\n if (!options.debug) {\n this._reporter.ignoreLogMessage('ApplicationInsights:');\n }\n\n const telemetryClient = await createTelemetryClient({\n productVersion: getVersion(import.meta.url),\n connectionString,\n logLevel,\n serviceNamespace: 'cloudpack',\n serviceName: 'cli',\n });\n\n void telemetryClient.tracer.startActiveSpan('CLI_ENTRY', { startTime: getCliStartTime() }, () => {\n // Retrieve the current telemetry context\n const activeContext = telemetryClient.context.active();\n\n /**\n * Sets the current context as the root context. This ensures that all spans created during this CLI execution\n * will be children of this root span, even though the root span is closed immediately. This helps group all\n * spans under a single root span for better traceability.\n *\n * Typically, the root span should remain open until the CLI exits. However, in environments like Codespaces,\n * the CLI might run indefinitely, which could leave the root span open indefinitely.\n *\n * To prevent this, the root span is closed immediately after it is set as the root context.\n */\n telemetryClient.setRootContext(activeContext);\n });\n\n await telemetryClient.tracer.startActiveSpan('INIT_TELEMETRY', { startTime }, (span) => {\n const enabledFeatureNames = Object.entries(config.features || {})\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n const telemetryAttributes = {\n verb: this._verb,\n arguments: programOptions.argv.slice(3).join(' '),\n environment: environmentInfo.isCI ? 'ci' : environmentInfo.isCodespaces ? 'codespaces' : 'local',\n appName: appName || '<unknown>',\n mode: config.mode,\n features: enabledFeatureNames,\n externalCorrelationId: environmentInfo.cloudpack.telemetryExternalCorrelationId,\n // Azure DevOps build attributes\n ...environmentInfo.ado,\n };\n\n for (const [key, value] of Object.entries(telemetryAttributes)) {\n if (value) {\n span.setAttribute(key, value);\n }\n }\n });\n\n return telemetryClient;\n }\n\n protected _sigintHandler = (): void => {\n this._sigintCount++;\n\n if (this._sigintCount > 1) {\n console.debug('Forcing exit');\n\n // We are forcing the process to exit.\n // No clean-up is needed because user pressed Ctrl+C twice.\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(1);\n }\n\n this._onInterrupt?.();\n\n // We are trying to exit gracefully.\n void this._exit({ isInterrupted: true, message: '' });\n };\n\n /**\n * Exit function called with the result returned by the command's execute function,\n * or manually via `CommandExecutor.exitAll()` in tests.\n */\n protected async _exit(params: CommandExitParams): Promise<never> {\n const { hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\n const message = params.isInterrupted ? this._getMessageOnInterrupt?.() || 'Interrupted by user' : params.message;\n\n if (this._hasCalledExit) {\n // Skip most of the operations if exit() was called multiple times.\n // But only use the error message if not in a test, due to the way we're mocking process.exit.\n if (!environmentInfo.isJest) {\n const prettyParams = Object.entries(params)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(', ');\n console.warn(`exit() was called multiple times. This call's options: ${prettyParams}.`);\n }\n } else {\n this._hasCalledExit = true;\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete({\n summary: hasErrors ? red(message) : message,\n showHelp: exitCode !== 0,\n });\n }\n\n CommandExecutor._activeInstances.delete(this);\n process.off('SIGINT', this._sigintHandler);\n\n // eslint-disable-next-line no-restricted-properties -- top-level cleanup\n process.exit(exitCode);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { CommandExitParams } from '../types/CommandAction.js';
2
1
  import type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';
2
+ import type { CommandExitParams } from '../types/CommandAction.js';
3
3
  export type _AppPromptQuestionName = 'app';
4
4
  /**
5
5
  * Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,
@@ -9,14 +9,14 @@ export type _AppPromptQuestionName = 'app';
9
9
  * @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if
10
10
  * there was an error.
11
11
  */
12
- export declare function discoverAppPaths(params: {
12
+ export declare function discoverLocalAppPaths(params: {
13
13
  /** Working directory to start from. */
14
14
  cwd: string;
15
15
  /**
16
16
  * How to determine the app path(s). (`--app` in the docs refers to `desiredApp` here.)
17
17
  * @default 'single'
18
18
  */
19
- discover?: AppPathDiscoveryMode;
19
+ discover?: Exclude<AppPathDiscoveryMode, 'remote'>;
20
20
  /**
21
21
  * Desired app name or substring, from the `--app` option.
22
22
  * - If there's an exact match, only that app will be returned.
@@ -25,4 +25,4 @@ export declare function discoverAppPaths(params: {
25
25
  */
26
26
  desiredApp?: string;
27
27
  }): Promise<string[] | CommandExitParams>;
28
- //# sourceMappingURL=discoverAppPaths.d.ts.map
28
+ //# sourceMappingURL=discoverLocalAppPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discoverLocalAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/discoverLocalAppPaths.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE3C;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CAiFxC"}
@@ -1,9 +1,9 @@
1
+ import { appConfigFileName } from '@ms-cloudpack/config';
1
2
  import { PackageDefinitions } from '@ms-cloudpack/package-utilities';
2
3
  import glob from 'fast-glob';
3
4
  import fs from 'fs';
4
5
  import path from 'path';
5
6
  import prompts from 'prompts';
6
- import { appConfigFileName } from '@ms-cloudpack/config';
7
7
  /**
8
8
  * Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,
9
9
  * we'll use that; otherwise, we'll scan for Cloudpack-enabled app and present the user
@@ -12,7 +12,7 @@ import { appConfigFileName } from '@ms-cloudpack/config';
12
12
  * @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if
13
13
  * there was an error.
14
14
  */
15
- export async function discoverAppPaths(params) {
15
+ export async function discoverLocalAppPaths(params) {
16
16
  const { cwd, desiredApp, discover } = params;
17
17
  const multiApp = discover === 'multi';
18
18
  if (!desiredApp && fs.existsSync(path.join(cwd, appConfigFileName))) {
@@ -77,4 +77,4 @@ export async function discoverAppPaths(params) {
77
77
  }
78
78
  return [response.app];
79
79
  }
80
- //# sourceMappingURL=discoverAppPaths.js.map
80
+ //# sourceMappingURL=discoverLocalAppPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discoverLocalAppPaths.js","sourceRoot":"","sources":["../../src/utilities/discoverLocalAppPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAO9B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAiB3C;IACC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC7C,MAAM,QAAQ,GAAG,QAAQ,KAAK,OAAO,CAAC;IAEtC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC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loudpack/config';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport glob from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\nimport prompts from 'prompts';\nimport type { Choice } from 'prompts';\nimport type { AppPathDiscoveryMode } from '../types/AppPathDiscoveryMode.js';\nimport type { CommandExitParams } from '../types/CommandAction.js';\n\nexport type _AppPromptQuestionName = 'app';\n\n/**\n * Gets the appPath from which Cloudpack will run. If the CWD is a Cloudpack-enabled app,\n * we'll use that; otherwise, we'll scan for Cloudpack-enabled app and present the user\n * with a menu. If no apps are found, Cloudpack will just try to run in the CWD anyway.\n *\n * @returns App path(s) (just one unless `discover: 'multi'`), or an exit options object if\n * there was an error.\n */\nexport async function discoverLocalAppPaths(params: {\n /** Working directory to start from. */\n cwd: string;\n\n /**\n * How to determine the app path(s). (`--app` in the docs refers to `desiredApp` here.)\n * @default 'single'\n */\n discover?: Exclude<AppPathDiscoveryMode, 'remote'>;\n\n /**\n * Desired app name or substring, from the `--app` option.\n * - If there's an exact match, only that app will be returned.\n * - If multiple apps match a substring, see `discover` for behavior.\n * - If no match, it's an error.\n */\n desiredApp?: string;\n}): Promise<string[] | CommandExitParams> {\n const { cwd, desiredApp, discover } = params;\n const multiApp = discover === 'multi';\n\n if (!desiredApp && fs.existsSync(path.join(cwd, appConfigFileName))) {\n // If no specific app was requested, and the cwd is a cloudpack app, just use that.\n return [cwd];\n }\n\n // Get all cloudpack app paths based on the presence of cloudpack.config.json\n const cloudpackAppPaths = (glob.sync([`**/${appConfigFileName}`], { cwd, ignore: ['**/node_modules/**'] }) ?? []).map(\n (file) => path.join(cwd, path.dirname(file)),\n );\n\n if (!cloudpackAppPaths.length) {\n // Include the cwd if there are no configs found, since it's possible to run start or init\n // without a config.\n cloudpackAppPaths.push(cwd);\n }\n\n if (!desiredApp && (multiApp || cloudpackAppPaths.length === 1)) {\n // Return all apps found if we're in multi-app mode or only one app was found\n // (and no specific app was requested).\n return cloudpackAppPaths;\n }\n\n // Get each app's name and description, filtered by `desiredApp` if specified.\n // (These use Choice format in case they're later used in a prompt.)\n const packages = new PackageDefinitions();\n const appChoices = (\n await Promise.all<Omit<Choice, 'value'> & { value: string }>(\n cloudpackAppPaths.map(async (dir) => {\n const pkg = await packages.get(dir);\n return {\n title: pkg.name,\n description: pkg?.description ?? 'An awesome app that would be even more awesome with a proper description',\n value: dir,\n };\n }),\n )\n )\n .filter((choice) => !desiredApp || choice.title.includes(desiredApp))\n .sort((c1, c2) => c1.title.localeCompare(c2.title));\n\n // Figure out if there are any matches for `desiredApp`\n if (desiredApp) {\n if (!appChoices.length) {\n return {\n message: `No Cloudpack apps found matching the name \"${desiredApp}\".`,\n hasErrors: true,\n };\n }\n\n // Prefer an exact match\n const exactMatch = appChoices.find((choice) => choice.title === desiredApp);\n if (exactMatch) {\n return [exactMatch.value];\n }\n\n // If there's no exact match, it means at least one substring match was found\n if (multiApp || appChoices.length === 1) {\n // Return them all if we're in multi-app mode or only one match was found\n return appChoices.map((choice) => choice.value);\n }\n }\n\n // There are multiple candidates, so prompt the user to choose one\n // (implicitly, we're in single-app mode if we reach here)\n const response = await prompts<_AppPromptQuestionName>({\n type: 'select',\n name: 'app',\n message: 'Select the app you want to start',\n choices: appChoices,\n });\n\n // This will be undefined if the user cancels the prompt\n if (!response.app) {\n return { isInterrupted: true, message: '' };\n }\n\n return [response.app as string];\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { CommandExitParams } from '../types/CommandAction.js';
2
+ import type { SharedOptions } from '../types/SharedOptions.js';
3
+ import type { ReusedOptions } from '../types/ReusedOptions.js';
4
+ import type { Context } from '@ms-cloudpack/api-server';
5
+ export declare function discoverRemoteAppPaths(params: {
6
+ context: Pick<Context, 'reporter'>;
7
+ options: {
8
+ /**
9
+ * Desired app name or substring, from the `--app` option.
10
+ * - If there's an exact match, only that app will be returned.
11
+ * - If multiple apps match a substring, see `discover` for behavior.
12
+ * - If no match, it's an error.
13
+ */
14
+ desiredApp?: string;
15
+ } & Pick<SharedOptions, 'cachePath'> & Pick<ReusedOptions, 'login'>;
16
+ }): Promise<string[] | CommandExitParams>;
17
+ //# sourceMappingURL=discoverRemoteAppPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discoverRemoteAppPaths.d.ts","sourceRoot":"","sources":["../../src/utilities/discoverRemoteAppPaths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACnC,OAAO,EAAE;QACP;;;;;WAKG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAClC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,CA2DxC"}
@@ -0,0 +1,53 @@
1
+ import { getCachePath } from '@ms-cloudpack/config';
2
+ import { selectItemFromPaginatedResults } from './selectItemFromPaginatedResults.js';
3
+ import { createNoOpTelemetryClient } from '@ms-cloudpack/telemetry';
4
+ export async function discoverRemoteAppPaths(params) {
5
+ const { options } = params;
6
+ const { desiredApp, login } = options;
7
+ const { createRemoteCacheClient, createAppRegistryClient } = await import('@ms-cloudpack/remote-cache');
8
+ const cachePath = await getCachePath(options.cachePath);
9
+ const context = {
10
+ ...params.context,
11
+ telemetryClient: createNoOpTelemetryClient(),
12
+ };
13
+ const client = await createAppRegistryClient({
14
+ options: {
15
+ cachePath,
16
+ loginMethod: login,
17
+ },
18
+ context,
19
+ });
20
+ const app = await selectItemFromPaginatedResults({
21
+ message: 'Select the app you want to start',
22
+ getPage: (pageSettings) => client.getApps(desiredApp, pageSettings),
23
+ getTitle: (item) => item.name,
24
+ });
25
+ if (!app) {
26
+ return { isInterrupted: true, message: '' };
27
+ }
28
+ const version = await selectItemFromPaginatedResults({
29
+ message: `Select the version of ${app.name} you want to start`,
30
+ getPage: (pageSettings) => client.getVersions(app.name, pageSettings),
31
+ getTitle: (item) => item.version,
32
+ });
33
+ if (!version) {
34
+ return { isInterrupted: true, message: '' };
35
+ }
36
+ const remoteCacheClient = await createRemoteCacheClient({
37
+ context,
38
+ options: {
39
+ cachePath,
40
+ loginMethod: login,
41
+ storageAccount: version.storageAccount,
42
+ tenantId: version.tenantId,
43
+ container: version.container,
44
+ },
45
+ });
46
+ const downloadedAppPath = await remoteCacheClient.downloadFolder({
47
+ friendlyName: `${app.name}-${version.version}`,
48
+ id: version.resourceId,
49
+ path: version.localBundleFolderName,
50
+ });
51
+ return [downloadedAppPath];
52
+ }
53
+ //# sourceMappingURL=discoverRemoteAppPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discoverRemoteAppPaths.js","sourceRoot":"","sources":["../../src/utilities/discoverRemoteAppPaths.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAGrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAY5C;IACC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEtC,MAAM,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;IAExG,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,O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YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B;KACF,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,MAAM,iBAAiB,CAAC,cAAc,CAAC;QAC/D,YAAY,EAAE,GAAG,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE;QAC9C,EAAE,EAAE,OAAO,CAAC,UAAU;QACtB,IAAI,EAAE,OAAO,CAAC,qBAAqB;KACpC,CAAC,CAAC;IAEH,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import type { AppRegistration, AppRegistrationVersion } from '@ms-cloudpack/remote-cache';\nimport type { CommandExitParams } from '../types/CommandAction.js';\nimport { getCachePath } from '@ms-cloudpack/config';\nimport { selectItemFromPaginatedResults } from './selectItemFromPaginatedResults.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\nimport { createNoOpTelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { Context } from '@ms-cloudpack/api-server';\n\nexport async function discoverRemoteAppPaths(params: {\n context: Pick<Context, 'reporter'>;\n options: {\n /**\n * Desired app name or substring, from the `--app` option.\n * - If there's an exact match, only that app will be returned.\n * - If multiple apps match a substring, see `discover` for behavior.\n * - If no match, it's an error.\n */\n desiredApp?: string;\n } & Pick<SharedOptions, 'cachePath'> &\n Pick<ReusedOptions, 'login'>;\n}): Promise<string[] | CommandExitParams> {\n const { options } = params;\n const { desiredApp, login } = options;\n\n const { createRemoteCacheClient, createAppRegistryClient } = await import('@ms-cloudpack/remote-cache');\n\n const cachePath = await getCachePath(options.cachePath);\n\n const context = {\n ...params.context,\n telemetryClient: createNoOpTelemetryClient(),\n };\n\n const client = await createAppRegistryClient({\n options: {\n cachePath,\n loginMethod: login,\n },\n context,\n });\n\n const app = await selectItemFromPaginatedResults<AppRegistration>({\n message: 'Select the app you want to start',\n getPage: (pageSettings) => client.getApps(desiredApp, pageSettings),\n getTitle: (item) => item.name,\n });\n\n if (!app) {\n return { isInterrupted: true, message: '' };\n }\n\n const version = await selectItemFromPaginatedResults<AppRegistrationVersion>({\n message: `Select the version of ${app.name} you want to start`,\n getPage: (pageSettings) => client.getVersions(app.name, pageSettings),\n getTitle: (item) => item.version,\n });\n\n if (!version) {\n return { isInterrupted: true, message: '' };\n }\n\n const remoteCacheClient = await createRemoteCacheClient({\n context,\n options: {\n cachePath,\n loginMethod: login,\n storageAccount: version.storageAccount,\n tenantId: version.tenantId,\n container: version.container,\n },\n });\n\n const downloadedAppPath = await remoteCacheClient.downloadFolder({\n friendlyName: `${app.name}-${version.version}`,\n id: version.resourceId,\n path: version.localBundleFolderName,\n });\n\n return [downloadedAppPath];\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { LoginMethod } from '@ms-cloudpack/remote-cache';
2
+ export declare function getDefaultLogin(): LoginMethod;
3
+ //# sourceMappingURL=getDefaultLogin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultLogin.d.ts","sourceRoot":"","sources":["../../src/utilities/getDefaultLogin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,wBAAgB,eAAe,IAAI,WAAW,CAE7C"}
@@ -0,0 +1,5 @@
1
+ import { environmentInfo } from '@ms-cloudpack/environment';
2
+ export function getDefaultLogin() {
3
+ return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';
4
+ }
5
+ //# sourceMappingURL=getDefaultLogin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultLogin.js","sourceRoot":"","sources":["../../src/utilities/getDefaultLogin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC3G,CAAC","sourcesContent":["import { environmentInfo } from '@ms-cloudpack/environment';\nimport type { LoginMethod } from '@ms-cloudpack/remote-cache';\n\nexport function getDefaultLogin(): LoginMethod {\n return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';\n}\n"]}
@@ -27,4 +27,5 @@ export declare const reusedOptions: {
27
27
  readonly cache: () => Option;
28
28
  readonly login: () => Option;
29
29
  };
30
+ export declare function getDefaultLogin(): string;
30
31
  //# sourceMappingURL=reusedOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAKzD;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;;OAGG;6BACa;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;;uCAOT;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE;;IAOvD;;;OAGG;uCACuB,MAAM;6BAKhB;QAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;IAO5C,0BAA0B;;;CAQgD,CAAC"}
1
+ {"version":3,"file":"reusedOptions.d.ts","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,MAAM,EAAE,MAAM,WAAW,CAAC;AAKzD;;GAEG;AACH,eAAO,MAAM,aAAa;IACxB;;;OAGG;6BACa;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;;uCAOT;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE;;IAOvD;;;OAGG;uCACuB,MAAM;6BAKhB;QAAE,MAAM,EAAE,QAAQ,GAAG,KAAK,CAAA;KAAE;IAO5C,0BAA0B;;;CAQgD,CAAC;AAmB7E,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
@@ -48,7 +48,7 @@ function parseBundleMode(mode) {
48
48
  throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);
49
49
  }
50
50
  }
51
- function getDefaultLogin() {
51
+ export function getDefaultLogin() {
52
52
  return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';
53
53
  }
54
54
  //# sourceMappingURL=reusedOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;;OAGG;IACH,GAAG,EAAE,CAAC,OAA6B,EAAE,EAAE,CACrC,IAAI,MAAM,CACR,wBAAwB,EACxB,2BAA2B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,GAAG;QACjF,wDAAwD,CAC3D;IACH,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACtG,aAAa,EAAE,CAAC,OAAuC,EAAE,EAAE,CACzD,IAAI,MAAM,CACR,mBAAmB,EACnB,sGAAsG;QACpG,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,sEAAsE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC3G;IACH,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,mBAAmB,EAAE,4DAA4D,CAAC;IAClH;;;OAGG;IACH,KAAK,EAA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CAAC;AAC3G,CAAC","sourcesContent":["import { bundlerNames } from '@ms-cloudpack/bundler';\nimport type { BundleMode } from '@ms-cloudpack/common-types';\nimport { InvalidArgumentError, Option } from 'commander';\nimport { parseMatch } from './parseMatch.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\n\n/**\n * These options are used by multiple commands, but should be manually added.\n */\nexport const reusedOptions = {\n /**\n * Specific app(s) to target. NOTE: This will only be respected if the `program.addSubCommand` call\n * also sets `discoverAppPaths`.\n */\n app: (options?: { multi?: boolean }) =>\n new Option(\n '--app <appPackageName>',\n `Run Cloudpack targeting ${options?.multi ? 'specific app(s)' : 'a specific app'} ` +\n '(prefers an exact match, or falls back to substrings).',\n ),\n bundler: () => new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),\n logBundleInfo: (options?: { requiresNoCache?: boolean }) =>\n new Option(\n '--log-bundle-info',\n 'For each package, write log files in its output folder with bundle input, output, and analyzed info.' +\n (options?.requiresNoCache ? ' (Note: requires --no-cache option if bundle output already exists.)' : ''),\n ),\n logResolveMap: () => new Option('--log-resolve-map', 'Log the resolve map to \"resolve-map.json\" for diagnostics.'),\n /**\n * @param descriptionStart Start of description for this command, e.g. \"Bundle specific package(s)\"\n * (it will automatically include an optional version note and examples)\n */\n match: (descriptionStart: string) =>\n new Option(\n '--match <match...>',\n `${descriptionStart}, optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"`,\n ).argParser(parseMatch),\n mode: (options: { action: 'bundle' | 'run' }) =>\n new Option(\n '--mode <mode>',\n `The mode to ${options.action === 'bundle' ? 'bundle the package' : 'run the app'} in. (library | production)`,\n )\n .argParser(parseBundleMode)\n .default('library'),\n /** `--no-cache` option */\n cache: () => new Option('--no-cache', 'Rebuild all packages, rather than using cached assets.'),\n login: () =>\n new Option('--login <method>', 'How to authenticate against the remote cache.')\n .choices(['interactive', 'azure-cli', 'device-code'])\n .default(getDefaultLogin(), '\"azure-cli\" in CI, \"device-code\" in Github Codespaces, \"interactive\" otherwise'),\n // Verify the type with `satisfies` to preserve individual function signatures.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as const satisfies Record<keyof ReusedOptions, (...args: any[]) => Option>;\n\n/** Parse the session mode based on user input (e.g. --mode argument in start.) */\nfunction parseBundleMode(mode: string): BundleMode {\n switch (mode.toLowerCase()) {\n case 'lib':\n case 'library':\n return 'library';\n case 'dev':\n case 'development':\n return 'development';\n case 'prod':\n case 'production':\n return 'production';\n default:\n throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);\n }\n}\n\nfunction getDefaultLogin(): string {\n return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';\n}\n"]}
1
+ {"version":3,"file":"reusedOptions.js","sourceRoot":"","sources":["../../src/utilities/reusedOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;;OAGG;IACH,GAAG,EAAE,CAAC,OAA6B,EAAE,EAAE,CACrC,IAAI,MAAM,CACR,wBAAwB,EACxB,2BAA2B,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,GAAG;QACjF,wDAAwD,CAC3D;IACH,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC;IACtG,aAAa,EAAE,CAAC,OAAuC,EAAE,EAAE,CACzD,IAAI,MAAM,CACR,mBAAmB,EACnB,sGAAsG;QAC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AC,4CAA4C,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAC3G,CAAC","sourcesContent":["import { bundlerNames } from '@ms-cloudpack/bundler';\nimport type { BundleMode } from '@ms-cloudpack/common-types';\nimport { InvalidArgumentError, Option } from 'commander';\nimport { parseMatch } from './parseMatch.js';\nimport { environmentInfo } from '@ms-cloudpack/environment';\nimport type { ReusedOptions } from '../types/ReusedOptions.js';\n\n/**\n * These options are used by multiple commands, but should be manually added.\n */\nexport const reusedOptions = {\n /**\n * Specific app(s) to target. NOTE: This will only be respected if the `program.addSubCommand` call\n * also sets `discoverAppPaths`.\n */\n app: (options?: { multi?: boolean }) =>\n new Option(\n '--app <appPackageName>',\n `Run Cloudpack targeting ${options?.multi ? 'specific app(s)' : 'a specific app'} ` +\n '(prefers an exact match, or falls back to substrings).',\n ),\n bundler: () => new Option('--bundler <name>', 'Force using a specific bundler.').choices(bundlerNames),\n logBundleInfo: (options?: { requiresNoCache?: boolean }) =>\n new Option(\n '--log-bundle-info',\n 'For each package, write log files in its output folder with bundle input, output, and analyzed info.' +\n (options?.requiresNoCache ? ' (Note: requires --no-cache option if bundle output already exists.)' : ''),\n ),\n logResolveMap: () => new Option('--log-resolve-map', 'Log the resolve map to \"resolve-map.json\" for diagnostics.'),\n /**\n * @param descriptionStart Start of description for this command, e.g. \"Bundle specific package(s)\"\n * (it will automatically include an optional version note and examples)\n */\n match: (descriptionStart: string) =>\n new Option(\n '--match <match...>',\n `${descriptionStart}, optionally with a version: e.g. \"foo\", \"@foo/*\", \"foo@1.2.3\"`,\n ).argParser(parseMatch),\n mode: (options: { action: 'bundle' | 'run' }) =>\n new Option(\n '--mode <mode>',\n `The mode to ${options.action === 'bundle' ? 'bundle the package' : 'run the app'} in. (library | production)`,\n )\n .argParser(parseBundleMode)\n .default('library'),\n /** `--no-cache` option */\n cache: () => new Option('--no-cache', 'Rebuild all packages, rather than using cached assets.'),\n login: () =>\n new Option('--login <method>', 'How to authenticate against the remote cache.')\n .choices(['interactive', 'azure-cli', 'device-code'])\n .default(getDefaultLogin(), '\"azure-cli\" in CI, \"device-code\" in Github Codespaces, \"interactive\" otherwise'),\n // Verify the type with `satisfies` to preserve individual function signatures.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n} as const satisfies Record<keyof ReusedOptions, (...args: any[]) => Option>;\n\n/** Parse the session mode based on user input (e.g. --mode argument in start.) */\nfunction parseBundleMode(mode: string): BundleMode {\n switch (mode.toLowerCase()) {\n case 'lib':\n case 'library':\n return 'library';\n case 'dev':\n case 'development':\n return 'development';\n case 'prod':\n case 'production':\n return 'production';\n default:\n throw new InvalidArgumentError(`Valid options are 'lib', 'dev', or 'prod'.`);\n }\n}\n\nexport function getDefaultLogin(): string {\n return environmentInfo.isCI ? 'azure-cli' : environmentInfo.isCodespaces ? 'device-code' : 'interactive';\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { PageSettings, PagedResult } from '@ms-cloudpack/remote-cache';
2
+ interface SelectItemsFromPaginatedResultsParams<T> {
3
+ /** The message to display to the user when selecting an item. */
4
+ message: string;
5
+ /** A function that fetches a page of items. */
6
+ getPage: (pageSettings: PageSettings) => Promise<PagedResult<T>>;
7
+ /** A function that returns a string to display for each item in the list. */
8
+ getTitle: (item: T) => string;
9
+ /** The default page size to use when fetching items. @default 10. */
10
+ defaultPageSize?: number;
11
+ }
12
+ /**
13
+ * Presents an interactive prompt that lists accumulated items plus a "Load More" option.
14
+ * When "Load More" is selected, it fetches the next page and updates the list.
15
+ *
16
+ * @returns The entity selected by the user or null if nothing is chosen.
17
+ */
18
+ export declare function selectItemFromPaginatedResults<T>(params: SelectItemsFromPaginatedResultsParams<T>): Promise<T | null>;
19
+ export {};
20
+ //# sourceMappingURL=selectItemFromPaginatedResults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectItemFromPaginatedResults.d.ts","sourceRoot":"","sources":["../../src/utilities/selectItemFromPaginatedResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAM5E,UAAU,qCAAqC,CAAC,CAAC;IAC/C,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAEhB,+CAA+C;IAC/C,OAAO,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjE,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAE9B,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,CAAC,EACpD,MAAM,EAAE,qCAAqC,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAsDnB"}