@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.
Files changed (97) hide show
  1. package/lib/__fixtures__/commandTestSetup.d.ts +18 -0
  2. package/lib/__fixtures__/commandTestSetup.d.ts.map +1 -0
  3. package/lib/__fixtures__/commandTestSetup.js +61 -0
  4. package/lib/__fixtures__/commandTestSetup.js.map +1 -0
  5. package/lib/__fixtures__/getPortArgsForStart.d.ts +21 -0
  6. package/lib/__fixtures__/getPortArgsForStart.d.ts.map +1 -0
  7. package/lib/__fixtures__/getPortArgsForStart.js +36 -0
  8. package/lib/__fixtures__/getPortArgsForStart.js.map +1 -0
  9. package/lib/__fixtures__/mainWrapper.d.ts +9 -0
  10. package/lib/__fixtures__/mainWrapper.d.ts.map +1 -0
  11. package/lib/__fixtures__/mainWrapper.js +17 -0
  12. package/lib/__fixtures__/mainWrapper.js.map +1 -0
  13. package/lib/__fixtures__/mockActiveSessions.d.ts +15 -0
  14. package/lib/__fixtures__/mockActiveSessions.d.ts.map +1 -0
  15. package/lib/__fixtures__/mockActiveSessions.js +38 -0
  16. package/lib/__fixtures__/mockActiveSessions.js.map +1 -0
  17. package/lib/commands/bundle/execute.d.ts.map +1 -1
  18. package/lib/commands/bundle/execute.js +2 -5
  19. package/lib/commands/bundle/execute.js.map +1 -1
  20. package/lib/commands/cache/clean.d.ts.map +1 -1
  21. package/lib/commands/cache/clean.js +3 -2
  22. package/lib/commands/cache/clean.js.map +1 -1
  23. package/lib/commands/config/delete.d.ts +9 -0
  24. package/lib/commands/config/delete.d.ts.map +1 -0
  25. package/lib/commands/config/delete.js +22 -0
  26. package/lib/commands/config/delete.js.map +1 -0
  27. package/lib/commands/config/get.d.ts +9 -0
  28. package/lib/commands/config/get.d.ts.map +1 -0
  29. package/lib/commands/config/get.js +24 -0
  30. package/lib/commands/config/get.js.map +1 -0
  31. package/lib/commands/config/index.d.ts +3 -0
  32. package/lib/commands/config/index.d.ts.map +1 -0
  33. package/lib/commands/config/index.js +48 -0
  34. package/lib/commands/config/index.js.map +1 -0
  35. package/lib/commands/config/list.d.ts +6 -0
  36. package/lib/commands/config/list.d.ts.map +1 -0
  37. package/lib/commands/config/list.js +21 -0
  38. package/lib/commands/config/list.js.map +1 -0
  39. package/lib/commands/config/set.d.ts +10 -0
  40. package/lib/commands/config/set.d.ts.map +1 -0
  41. package/lib/commands/config/set.js +21 -0
  42. package/lib/commands/config/set.js.map +1 -0
  43. package/lib/commands/info/index.d.ts.map +1 -1
  44. package/lib/commands/info/index.js +3 -0
  45. package/lib/commands/info/index.js.map +1 -1
  46. package/lib/commands/init/execute.js +2 -2
  47. package/lib/commands/init/execute.js.map +1 -1
  48. package/lib/commands/init/init.d.ts +0 -2
  49. package/lib/commands/init/init.d.ts.map +1 -1
  50. package/lib/commands/init/init.js +4 -8
  51. package/lib/commands/init/init.js.map +1 -1
  52. package/lib/commands/link/execute.d.ts.map +1 -1
  53. package/lib/commands/link/execute.js +5 -7
  54. package/lib/commands/link/execute.js.map +1 -1
  55. package/lib/commands/link/getSessionToLink.d.ts +2 -0
  56. package/lib/commands/link/getSessionToLink.d.ts.map +1 -1
  57. package/lib/commands/link/getSessionToLink.js +1 -1
  58. package/lib/commands/link/getSessionToLink.js.map +1 -1
  59. package/lib/commands/setup/index.js +1 -1
  60. package/lib/commands/setup/index.js.map +1 -1
  61. package/lib/commands/start/execute.d.ts +0 -2
  62. package/lib/commands/start/execute.d.ts.map +1 -1
  63. package/lib/commands/start/execute.js +10 -18
  64. package/lib/commands/start/execute.js.map +1 -1
  65. package/lib/commands/start/index.d.ts.map +1 -1
  66. package/lib/commands/start/index.js +28 -1
  67. package/lib/commands/start/index.js.map +1 -1
  68. package/lib/commands/start/types/StartOptions.d.ts +6 -0
  69. package/lib/commands/start/types/StartOptions.d.ts.map +1 -1
  70. package/lib/commands/start/types/StartOptions.js.map +1 -1
  71. package/lib/commands/sync/execute.js +4 -4
  72. package/lib/commands/sync/execute.js.map +1 -1
  73. package/lib/commands/unlink/execute.d.ts.map +1 -1
  74. package/lib/commands/unlink/execute.js +5 -6
  75. package/lib/commands/unlink/execute.js.map +1 -1
  76. package/lib/types/CommandAction.d.ts +7 -8
  77. package/lib/types/CommandAction.d.ts.map +1 -1
  78. package/lib/types/CommandAction.js.map +1 -1
  79. package/lib/types/SharedOptions.d.ts +4 -0
  80. package/lib/types/SharedOptions.d.ts.map +1 -1
  81. package/lib/types/SharedOptions.js.map +1 -1
  82. package/lib/utilities/CloudpackCommand.d.ts +7 -1
  83. package/lib/utilities/CloudpackCommand.d.ts.map +1 -1
  84. package/lib/utilities/CloudpackCommand.js +6 -3
  85. package/lib/utilities/CloudpackCommand.js.map +1 -1
  86. package/lib/utilities/CommandExecutor.d.ts.map +1 -1
  87. package/lib/utilities/CommandExecutor.js +4 -2
  88. package/lib/utilities/CommandExecutor.js.map +1 -1
  89. package/lib/utilities/runPrerequisites.d.ts +1 -1
  90. package/lib/utilities/runPrerequisites.d.ts.map +1 -1
  91. package/lib/utilities/runPrerequisites.js +2 -2
  92. package/lib/utilities/runPrerequisites.js.map +1 -1
  93. package/lib/utilities/stopServers.d.ts +13 -0
  94. package/lib/utilities/stopServers.d.ts.map +1 -0
  95. package/lib/utilities/stopServers.js +18 -0
  96. package/lib/utilities/stopServers.js.map +1 -0
  97. package/package.json +7 -6
@@ -7,9 +7,10 @@ function checkErrorCode(error, code) {
7
7
  return error instanceof Error && 'code' in error && error.code === code;
8
8
  }
9
9
  export const execute = async (params) => {
10
- const { options, cwd, reporter, initialize, exit, autoDispose } = params;
10
+ const { options, cwd, initialize, exit, autoDispose } = params;
11
11
  const { login, upload } = options;
12
- const { config, telemetryClient } = await initialize({ appPath: cwd });
12
+ const apiContextOptions = await initialize({ appPath: cwd });
13
+ const { config, telemetryClient } = apiContextOptions;
13
14
  if (!config.features?.syncBundles) {
14
15
  await exit({ message: 'Sync is disabled' });
15
16
  return;
@@ -28,9 +29,8 @@ export const execute = async (params) => {
28
29
  const input = {
29
30
  loginMethod: login,
30
31
  };
31
- const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };
32
32
  if (upload) {
33
- runPrerequisites({ config, cwd, telemetryClient });
33
+ runPrerequisites(apiContextOptions);
34
34
  const [ctx] = autoDispose(await createPartialApiContext({
35
35
  ...apiContextOptions,
36
36
  items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/sync/execute.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAsB,MAAM,8BAA8B,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,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,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAEvE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,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ACF,MAAM,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAEhD,IAAI,KAAK,CAAC,IAAI,KAAK,6BAA6B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBACrG,OAAO,IAAI,CAAC;oBACV,OAAO,EAAE,GAAG,CACV,oMAAoM,CACrM;oBACD,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC,CAAC;YACL,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,IAAI,CAAC;oBACV,OAAO,EAAE,GAAG,CAAC,oEAAoE,CAAC;oBAClF,QAAQ,EAAE,2BAA2B;iBACtC,CAAC,CAAC;YACL,CAAC;YAED,IAAI,cAAc,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC;gBAChD,OAAO,IAAI,CAAC;oBACV,OAAO,EAAE,GAAG,CAAC,+DAA+D,CAAC;oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport { ExitCodeAuthenticationError, ExitCodeGenericError, type CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\nimport { red } from '@ms-cloudpack/task-reporter';\n\nfunction checkErrorCode(error: unknown, code: string) {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, reporter, initialize, exit, autoDispose } = params;\n const { login, upload } = options;\n const { config, telemetryClient } = await initialize({ appPath: cwd });\n\n if (!config.features?.syncBundles) {\n await exit({ message: 'Sync is disabled' });\n return;\n }\n\n if (isSyncDisabledByUser()) {\n telemetryClient.rootSpan.setAttribute('syncDisabled', true);\n return exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return exit({\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 input = {\n loginMethod: login,\n };\n\n const apiContextOptions = { appPath: cwd, config, reporter, telemetryClient };\n if (upload) {\n runPrerequisites({ config, cwd, telemetryClient });\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n return exit({ message: 'Sync complete' });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return exit({\n message: red(\n `Cloudpack encountered an issue acquiring authentication lock. It seems Cloudpack Sync may already be active in another process. Please wait for the current 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 exit({\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 exit({\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":"AACA,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAsB,MAAM,8BAA8B,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAElD,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,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAC/D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,iBAAiB,GAAG,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAAC;IAEtD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;QAClC,MAAM,IAAI,CA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AAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,eAAe,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAEhD,IAAI,KAAK,CAAC,IAAI,KAAK,6BAA6B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBACrG,OAAO,IAAI,CAAC;oBACV,OAAO,EAAE,GAAG,CACV,oMAAoM,CACrM;oBACD,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC,CAAC;YACL,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,IAAI,CAAC;oBACV,OAAO,EAAE,GAAG,CAAC,oEAAoE,CAAC;oBAClF,QAAQ,EAAE,2BAA2B;iBACtC,CAAC,CAAC;YACL,CAAC;YAED,IAAI,cAAc,CAAC,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC;gBAChD,OAAO,IAAI,CAAC;oBACV,OAAO,EAAE,GAAG,CAAC,+DAA+D,CAAC;oBAC7E,QAAQ,EAAE,oBAAoB;iBAC/B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { SyncOptions } from './types/SyncOptions.js';\nimport { ExitCodeAuthenticationError, ExitCodeGenericError, type CommandAction } from '../../types/CommandAction.js';\nimport { createPartialApiContext, syncDownload, syncUpload } from '@ms-cloudpack/api-server';\nimport { runPrerequisites } from '../../utilities/runPrerequisites.js';\nimport { isSyncDisabledByUser } from './isSyncDisabledByUser.js';\nimport { red } from '@ms-cloudpack/task-reporter';\n\nfunction checkErrorCode(error: unknown, code: string) {\n return error instanceof Error && 'code' in error && error.code === code;\n}\n\nexport const execute: CommandAction<SyncOptions> = async (params) => {\n const { options, cwd, initialize, exit, autoDispose } = params;\n const { login, upload } = options;\n const apiContextOptions = await initialize({ appPath: cwd });\n const { config, telemetryClient } = apiContextOptions;\n\n if (!config.features?.syncBundles) {\n await exit({ message: 'Sync is disabled' });\n return;\n }\n\n if (isSyncDisabledByUser()) {\n telemetryClient.rootSpan.setAttribute('syncDisabled', true);\n return exit({ message: 'CLOUDPACK_SYNC environment variable is set. Sync is disabled by the user.' });\n }\n\n try {\n const remoteCacheConfig = config.remoteCache;\n if (!remoteCacheConfig) {\n return exit({\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 input = {\n loginMethod: login,\n };\n\n if (upload) {\n runPrerequisites(apiContextOptions);\n\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['bus', 'taskRunner', 'watcher', 'packages', 'session', 'packageImportPaths', 'packageHashes'],\n }),\n );\n await syncUpload({ input, ctx });\n } else {\n const [ctx] = autoDispose(\n await createPartialApiContext({\n ...apiContextOptions,\n items: ['packages', 'session', 'packageHashes'],\n }),\n );\n await syncDownload({ input, ctx });\n }\n\n return exit({ message: 'Sync complete' });\n } catch (error) {\n if (error instanceof Error) {\n telemetryClient.rootSpan.recordException(error);\n\n if (error.name === 'AuthenticationRequiredError' && error.message.includes('CrossPlatformLockError')) {\n return exit({\n message: red(\n `Cloudpack encountered an issue acquiring authentication lock. It seems Cloudpack Sync may already be active in another process. Please wait for the current 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 exit({\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 exit({\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 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/unlink/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO9D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CAwChD,CAAC"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/commands/unlink/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO9D;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,aAAa,CAsChD,CAAC"}
@@ -9,20 +9,19 @@ 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 { logResolveMap } = options;
12
+ const { logResolveMap, cachePath } = options;
13
13
  await initialize({ appPath });
14
14
  console.debug('Unlinking packages...');
15
- const session = await getSessionToLink({ reporter, exit });
15
+ const session = await getSessionToLink({ reporter, exit, cachePath });
16
16
  const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });
17
17
  const message = `Unlinking paths for ${session.projectName} at "${appPath}"`;
18
18
  const task = reporter.addTask(message);
19
- const data = {
19
+ // Send request to api server to link paths.
20
+ const { resolveMap, linkedPaths } = await client.unlinkPath.query({
20
21
  linkedPath: {
21
22
  path: appPath,
22
23
  },
23
- };
24
- // Send request to api server to link paths.
25
- const { resolveMap, linkedPaths } = await client.unlinkPath.query(data);
24
+ });
26
25
  await client.close();
27
26
  if (linkedPaths.some((p) => p.path === appPath)) {
28
27
  // Close down with an error.
@@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C,IAAI,CAAC,CAAC;IACxE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,CAAC;QAChD,4BAA4B;QAC5B,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvF,MAAM,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,0CAA0C;QAC1C,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,2BAA2B,CAAC,EAAE,UAAU,CAAC,CAAC;IAC/E,CAAC;IAED,2BAA2B;IAC3B,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClF,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IAE5E,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 { UnlinkOptions } from './types/UnlinkOptions.js';\nimport { getSessionToLink } from '../link/getSessionToLink.js';\nimport { createCloudpackClient } from '@ms-cloudpack/api-server';\nimport { formatLinkSummary } from '../link/formatLinkSummary.js';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\n/**\n * Defines the \"unlink\" verb entry point.\n */\nexport const execute: CommandAction<UnlinkOptions> = async (params) => {\n // Use the current directory as the default package path.\n const { options, cwd: appPath, reporter, initialize, exit } = params;\n\n const { logResolveMap } = options;\n await initialize({ appPath });\n\n console.debug('Unlinking packages...');\n\n const session = await getSessionToLink({ reporter, exit });\n const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });\n\n const message = `Unlinking paths for ${session.projectName} at \"${appPath}\"`;\n const task = reporter.addTask(message);\n const data = {\n linkedPath: {\n path: appPath,\n },\n };\n\n // Send request to api server to link paths.\n const { resolveMap, linkedPaths } = await client.unlinkPath.query(data);\n await client.close();\n\n if (linkedPaths.some((p) => p.path === appPath)) {\n // Close down with an error.\n task.complete({ status: 'fail', message: `Failed to unlink paths.`, forceShow: true });\n await exit({ exitCode: 1, message: 'Failed to unlink paths.' });\n }\n\n if (logResolveMap) {\n // Write the unlinked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-unlinked.json'), resolveMap);\n }\n\n // Close down successfully.\n task.complete({ status: 'complete', message: `Unlinked paths`, forceShow: true });\n const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths });\n\n await exit({ exitCode: 0, message: linkSummary });\n};\n"]}
1
+ {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../src/commands/unlink/execute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAiC,KAAK,EAAE,MAAM,EAAE,EAAE;IACpE,yDAAyD;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACrE,MAAM,EAAE,aAAa,EAAE,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C;IAED,2BAA2B;IAC3B,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClF,MAAM,WAAW,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IAE5E,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 { UnlinkOptions } from './types/UnlinkOptions.js';\nimport { getSessionToLink } from '../link/getSessionToLink.js';\nimport { createCloudpackClient } from '@ms-cloudpack/api-server';\nimport { formatLinkSummary } from '../link/formatLinkSummary.js';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport path from 'path';\n\n/**\n * Defines the \"unlink\" verb entry point.\n */\nexport const execute: CommandAction<UnlinkOptions> = async (params) => {\n // Use the current directory as the default package path.\n const { options, cwd: appPath, reporter, initialize, exit } = params;\n const { logResolveMap, cachePath } = options;\n await initialize({ appPath });\n\n console.debug('Unlinking packages...');\n\n const session = await getSessionToLink({ reporter, exit, cachePath });\n const client = await createCloudpackClient({ url: session.urls.apiServer, reporter });\n\n const message = `Unlinking paths for ${session.projectName} at \"${appPath}\"`;\n const task = reporter.addTask(message);\n\n // Send request to api server to link paths.\n const { resolveMap, linkedPaths } = await client.unlinkPath.query({\n linkedPath: {\n path: appPath,\n },\n });\n await client.close();\n\n if (linkedPaths.some((p) => p.path === appPath)) {\n // Close down with an error.\n task.complete({ status: 'fail', message: `Failed to unlink paths.`, forceShow: true });\n await exit({ exitCode: 1, message: 'Failed to unlink paths.' });\n }\n\n if (logResolveMap) {\n // Write the unlinked resolve map to disk.\n await writeJson(path.join(appPath, 'resolve-map-unlinked.json'), resolveMap);\n }\n\n // Close down successfully.\n task.complete({ status: 'complete', message: `Unlinked paths`, forceShow: true });\n const linkSummary = formatLinkSummary({ session, resolveMap, linkedPaths });\n\n await exit({ exitCode: 0, message: linkSummary });\n};\n"]}
@@ -1,14 +1,13 @@
1
1
  import type { TaskReporter } from '@ms-cloudpack/task-reporter';
2
- import type { BundleMode, CloudpackConfig } from '@ms-cloudpack/common-types';
3
- import type { TelemetryClient } from '@ms-cloudpack/telemetry';
2
+ import type { BundleMode } from '@ms-cloudpack/common-types';
4
3
  import type { AutoDispose } from './AutoDispose.js';
5
4
  import type { SharedOptions } from './SharedOptions.js';
6
- /** Context for running a command in a specific app (after initialization). */
7
- export type AppCommandContext = {
8
- appPath: string;
9
- telemetryClient: TelemetryClient;
10
- config: CloudpackConfig;
11
- };
5
+ import type { LazyApiContextOptions } from '@ms-cloudpack/api-server';
6
+ /**
7
+ * Context for running a command in a specific app (after initialization).
8
+ * For convenience, this can be passed/spread directly to `createPartialApiContext`.
9
+ */
10
+ export type AppCommandContext = Pick<LazyApiContextOptions, 'appPath' | 'cachePath' | 'config' | 'reporter' | 'telemetryClient'>;
12
11
  export declare const ExitCodeSuccessful = 0;
13
12
  export declare const ExitCodeGenericError = 1;
14
13
  export declare const ExitCodeAuthenticationError = 2;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandAction.d.ts","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,E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../src/types/CommandAction.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { BundleMode, CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\n\n/** Context for running a command in a specific app (after initialization). */\nexport type AppCommandContext = {\n appPath: string;\n telemetryClient: TelemetryClient;\n config: CloudpackConfig;\n};\n\nexport const ExitCodeSuccessful = 0;\nexport const ExitCodeGenericError = 1;\nexport const ExitCodeAuthenticationError = 2;\nexport type ExitCode = typeof ExitCodeSuccessful | typeof ExitCodeGenericError | typeof ExitCodeAuthenticationError;\n\nexport interface CommandExitParams {\n message: string;\n hasErrors?: boolean;\n exitCode?: ExitCode;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n *\n * If it is called with a single string, it returns `Promise<AppCommandContext>`\n * If it is called with a string[], it returns `Promise<AppCommandContext[]>`\n */\n initialize: {\n (initializeOptions: {\n appPath: string;\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext>;\n (initializeOptions: {\n appPaths: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `CommandExecutor._exit` for implementation.)\n */\n exit: (result: CommandExitParams) => Promise<void>;\n\n /**\n * Set a callback to get the message to display if ctrl+C is pressed.\n */\n setInterruptMessageHandler: (getMessage: () => string) => void;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
1
+ {"version":3,"file":"CommandAction.js","sourceRoot":"","sources":["../../src/types/CommandAction.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC","sourcesContent":["import type { TaskReporter } from '@ms-cloudpack/task-reporter';\nimport type { BundleMode } from '@ms-cloudpack/common-types';\nimport type { AutoDispose } from './AutoDispose.js';\nimport type { SharedOptions } from './SharedOptions.js';\nimport type { LazyApiContextOptions } from '@ms-cloudpack/api-server';\n\n/**\n * Context for running a command in a specific app (after initialization).\n * For convenience, this can be passed/spread directly to `createPartialApiContext`.\n */\nexport type AppCommandContext = Pick<\n LazyApiContextOptions,\n 'appPath' | 'cachePath' | 'config' | 'reporter' | 'telemetryClient'\n>;\n\nexport const ExitCodeSuccessful = 0;\nexport const ExitCodeGenericError = 1;\nexport const ExitCodeAuthenticationError = 2;\nexport type ExitCode = typeof ExitCodeSuccessful | typeof ExitCodeGenericError | typeof ExitCodeAuthenticationError;\n\nexport interface CommandExitParams {\n message: string;\n hasErrors?: boolean;\n exitCode?: ExitCode;\n}\n\nexport interface CommandActionParams<TOptions extends object> {\n /**\n * Initial working directory (usually `process.cwd()` except in tests).\n * Note that this may differ from the `appPath` used by individual commands.\n */\n cwd: string;\n\n /**\n * Command-specific options, parsed from `process.argv`.\n * Types are generally defined in each command's `src/commands/<name>/types/<Name>Types.ts` module.\n * The command line options are defined in each command's `src/commands/<name>/index.ts` module.\n */\n options: TOptions;\n\n /**\n * Command-specific arguments. Arguments in commander are positional arguments that are not options.\n * For example, in `echo somestring`, `somestring` is an argument.\n */\n args: string[];\n\n reporter: TaskReporter;\n\n abortSignal: AbortSignal;\n\n /**\n * Function that can be called with any `Disposable`s that should be cleaned up automatically\n * when the program exits. (See `AutoDisposableList.add` for implementation.)\n */\n autoDispose: AutoDispose;\n\n /**\n * This should be called at or near the beginning of the action to initialize the config,\n * telemetry, and reporting. (See `CommandExecutor._initialize` for implementation.)\n * `initialize` can be called with either a single string, `appPath` or an a string[], `appPaths`.\n *\n * If it is called with a single string, it returns `Promise<AppCommandContext>`\n * If it is called with a string[], it returns `Promise<AppCommandContext[]>`\n */\n initialize: {\n (initializeOptions: {\n appPath: string;\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext>;\n (initializeOptions: {\n appPaths: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext[]>;\n };\n\n /**\n * This should be called at the end of the action to dispose resources, log completion,\n * and exit the program. (See `CommandExecutor._exit` for implementation.)\n */\n exit: (result: CommandExitParams) => Promise<void>;\n\n /**\n * Set a callback to get the message to display if ctrl+C is pressed.\n */\n setInterruptMessageHandler: (getMessage: () => string) => void;\n}\n\n/**\n * Command action function. This is the type of the `execute` function which should be exported\n * from each command's `src/commands/<name>/execute.ts` module.\n */\nexport type CommandAction<TOptions> = (params: CommandActionParams<TOptions & SharedOptions>) => Promise<void>;\n\nexport type CommandActionModule<TOptions> = {\n execute: CommandAction<TOptions>;\n};\n"]}
@@ -22,5 +22,9 @@ export interface SharedOptions {
22
22
  * Experimental feature names to enable.
23
23
  */
24
24
  features?: string[];
25
+ /**
26
+ * Custom cache folder to use for this run of the command.
27
+ */
28
+ cachePath?: string;
25
29
  }
26
30
  //# sourceMappingURL=SharedOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB"}
1
+ {"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Shared CLI options for all commands.\n */\nexport interface SharedOptions {\n /**\n * Whether to enable debug logging (superset of --verbose).\n */\n debug?: boolean;\n\n /**\n * Whether to enable verbose logging.\n */\n verbose?: boolean;\n\n /**\n * Whether to enable colors. Available on the command line as `--no-color`.\n */\n color?: boolean;\n\n /**\n * Whether to disable non-essential logging.\n */\n quiet?: boolean;\n\n /**\n * Experimental feature names to enable.\n */\n features?: string[];\n}\n"]}
1
+ {"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../src/types/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Shared CLI options for all commands.\n */\nexport interface SharedOptions {\n /**\n * Whether to enable debug logging (superset of --verbose).\n */\n debug?: boolean;\n\n /**\n * Whether to enable verbose logging.\n */\n verbose?: boolean;\n\n /**\n * Whether to enable colors. Available on the command line as `--no-color`.\n */\n color?: boolean;\n\n /**\n * Whether to disable non-essential logging.\n */\n quiet?: boolean;\n\n /**\n * Experimental feature names to enable.\n */\n features?: string[];\n\n /**\n * Custom cache folder to use for this run of the command.\n */\n cachePath?: string;\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Command, Option, type Argument, type OutputConfiguration } from 'commander';
2
2
  import type { CommandActionModule } from '../types/CommandAction.js';
3
3
  import type { ProgramOptions } from '../types/ProgramOptions.js';
4
+ import type { SharedOptions } from '../types/SharedOptions.js';
4
5
  /**
5
6
  * Parameters for creating a command.
6
7
  * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.
@@ -12,7 +13,7 @@ interface CloudpackCommandParams<TOptions extends object, TArguments extends obj
12
13
  description: string;
13
14
  /** Options specific to this command. The record ensures that all options are available in the CLI. */
14
15
  options?: Record<keyof TOptions, Option>;
15
- /** Arguments specific to this command. */
16
+ /** Arguments specific to this command. Key order determines the arg order. */
16
17
  args?: Record<keyof TArguments, Argument>;
17
18
  /**
18
19
  * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.
@@ -28,6 +29,11 @@ interface CloudpackCommandParams<TOptions extends object, TArguments extends obj
28
29
  alias?: string;
29
30
  /** Output options override (mainly for testing) */
30
31
  outputOptions?: OutputConfiguration;
32
+ /**
33
+ * Skip these shared options. The shared options are relevant for most commands, but this allows
34
+ * omitting them where they're not relevant (and none of the options are required, so it's fine).
35
+ */
36
+ skipSharedOptions?: Array<keyof SharedOptions>;
31
37
  }
32
38
  /**
33
39
  * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with
@@ -1 +1 @@
1
- {"version":3,"file":"CloudpackCommand.d.ts","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKjE;;;GAGG;AACH,UAAU,sBAAsB,CAAC,QAAQ,SAAS,MAAM,EAAE,UAAU,SAAS,MAAM;IACjF,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IAEpB,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEzC,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE1C;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3D,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,aAAa,CAAC,EAAE,mBAAmB,CAA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44
44
  // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)
45
45
  new Option('-n, --no-color', 'Disable colors in the output.').default(!process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild()),
46
46
  features: new Option('--features <featureNames...>', 'Enable experimental features.'),
47
+ cachePath: new Option('--cache-path <path>', 'Custom cache folder.'),
47
48
  });
48
49
  }
49
50
  /** Create a child command. */
@@ -71,9 +72,11 @@ export class CloudpackCommand {
71
72
  }
72
73
  }
73
74
  /** Add options. The generic enforces that option objects are included for all keys of a type. */
74
- _addOptions(options) {
75
- for (const option of Object.values(options)) {
76
- this._command.addOption(option); // not sure why this isn't being inferred
75
+ _addOptions(options, skipOptions = []) {
76
+ for (const [name, option] of Object.entries(options)) {
77
+ if (!skipOptions.includes(name)) {
78
+ this._command.addOption(option);
79
+ }
77
80
  }
78
81
  }
79
82
  _addAction(getExecutor) {
@@ -1 +1 @@
1
- {"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAA2C,MAAM,WAAW,CAAC;AAIrF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAsCvD;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,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,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;YACxB,iEAAiE;YACjE,iEAAiE;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAyB,CAAC;YAExD,kEAAkE;YAClE,kGAAkG;YAClG,gGAAgG;YAChG,6EAA6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;aACL,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>({\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild(),\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n });\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(options: Record<keyof TAddOptions, Option>): void {\n for (const option of Object.values(options)) {\n this._command.addOption(option as Option); // not sure why this isn't being inferred\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
1
+ {"version":3,"file":"CloudpackCommand.js","sourceRoot":"","sources":["../../src/utilities/CloudpackCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAA2C,MAAM,WAAW,CAAC;AAIrF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA4CvD;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAgB;IAI3B;;;OAGG;IACH;IACE,4EAA4E;IAC5E,MAIC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC;QAE7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC/C,OAAO,CAAC,W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AM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,WAAqF;QACtG,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,0FAA0F;QAC1F,iGAAiG;QACjG,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;YACxB,iEAAiE;YACjE,iEAAiE;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAyB,CAAC;YAExD,kEAAkE;YAClE,kGAAkG;YAClG,gGAAgG;YAChG,6EAA6E;YAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,EAA4B,CAAC;YAEpE,kGAAkG;YAClG,wBAAwB;YACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAEpG,0CAA0C;YAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,WAAW,EAAE,CAAC;YACxC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBAClC,2EAA2E;gBAC3E,MAAM,IAAI,KAAK,CAAC,gEAAgE,IAAI,GAAG,CAAC,CAAC;YAC3F,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,eAAe,CAA2B;gBACpE,IAAI,EAAE,aAAa;gBACnB,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,IAAI,CAAC,eAAe;gBACpC,IAAI;aACL,CAAC,CAAC;YACH,MAAM,eAAe,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Command, Option, type Argument, type OutputConfiguration } from 'commander';\nimport type { CommandActionModule } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { CommandExecutor } from './CommandExecutor.js';\n\n/**\n * Parameters for creating a command.\n * `TOptions` should be the command-specific options (if any), e.g. `StartOptions`.\n */\ninterface CloudpackCommandParams<TOptions extends object, TArguments extends object> {\n /** Command name */\n name: string;\n\n /** Command description */\n description: string;\n\n /** Options specific to this command. The record ensures that all options are available in the CLI. */\n options?: Record<keyof TOptions, Option>;\n\n /** Arguments specific to this command. Key order determines the arg order. */\n args?: Record<keyof TArguments, Argument>;\n\n /**\n * Function returning an async import of the command's `src/commands/<name>/execute.ts` module.\n * Importing only on demand makes Cloudpack start up faster since it doesn't have to parse\n * every command's dependencies (many of which may be unrelated to the command being run).\n *\n * This can be undefined for a command that only has sub-commands.\n */\n getExecutor?: () => Promise<CommandActionModule<TOptions>>;\n\n /** Usage message override */\n usage?: string;\n\n /** Alternative name for the command */\n alias?: string;\n\n /** Output options override (mainly for testing) */\n outputOptions?: OutputConfiguration;\n\n /**\n * Skip these shared options. The shared options are relevant for most commands, but this allows\n * omitting them where they're not relevant (and none of the options are required, so it's fine).\n */\n skipSharedOptions?: Array<keyof SharedOptions>;\n}\n\n/**\n * This wraps the `Command` class from [`commander`](https://www.npmjs.com/package/commander) with\n * Cloudpack-specific functionality and simpler APIs.\n *\n * Similar to the pattern from `commander`, this class represents both the program and its sub-commands.\n * - The top-level \"program\" command should be created with `new CloudpackCommand()`.\n * - Sub-commands should be created with the `.addSubCommand` method on the parent.\n */\nexport class CloudpackCommand<TOptions extends object, TArguments extends object> {\n private _command: Command;\n private _programOptions: ProgramOptions;\n\n /**\n * This should only be used directly (outside this class) to create the top-level `program` command.\n * To add sub-commands, use `.addSubCommand` instead.\n */\n constructor(\n // The extra options here shouldn't be exposed to the `createSubCommand` API\n params: CloudpackCommandParams<TOptions, TArguments> & {\n programOptions: ProgramOptions;\n /** This must be undefined for the top-level program command */\n parent?: Command;\n },\n ) {\n this._programOptions = params.programOptions;\n\n const command = params.parent?.command(params.name) || new Command(params.name);\n this._command = command;\n\n command.version(params.programOptions.version);\n command.description(params.description);\n command.allowExcessArguments(false);\n\n params.usage && command.usage(params.usage);\n params.alias && command.alias(params.alias);\n params.outputOptions && command.configureOutput(params.outputOptions);\n params.getExecutor && this._addAction(params.getExecutor);\n\n if (params.args) {\n this._addArguemnts<TArguments>(params.args);\n }\n\n if (params.options) {\n // Add the command-specific options first so they show up first in help\n this._addOptions<TOptions>(params.options);\n }\n\n // Add shared options. These must be manually added to the program command and each sub-command\n // because commander doesn't natively support inheriting options.\n this._addOptions<SharedOptions>({\n verbose: new Option('-v, --verbose', 'Show additional details about the running tasks.'),\n debug: new Option('-d, --debug', 'Show debug information (superset of --verbose).').conflicts('verbose'),\n quiet: new Option('-q, --quiet', 'Disable non-essential logging.').conflicts('verbose').conflicts('debug'),\n color:\n // In the parsed options, this will be a boolean `color` with default value true (except in tests and CI)\n new Option('-n, --no-color', 'Disable colors in the output.').default(\n !process.env.JEST_WORKER_ID && !process.env.LAGE_PACKAGE_NAME && !isCIBuild(),\n ),\n features: new Option('--features <featureNames...>', 'Enable experimental features.'),\n cachePath: new Option('--cache-path <path>', 'Custom cache folder.'),\n });\n }\n\n /** Create a child command. */\n public addSubCommand<TChildOptions extends object, TChildArguments extends object = never>(\n params: CloudpackCommandParams<TChildOptions, TChildArguments>,\n ): CloudpackCommand<TChildOptions, TChildArguments> {\n return new CloudpackCommand<TChildOptions, TChildArguments>({\n ...params,\n programOptions: this._programOptions,\n parent: this._command,\n });\n }\n\n /** Run the program (only works on the top-level program command). */\n public async run(): Promise<void> {\n if (this._command.parent) {\n throw new Error('Only the top-level program command can be run directly.');\n }\n\n await this._command.parseAsync(this._programOptions.argv);\n if (this._command.args.length === 0) {\n this._command.help();\n }\n }\n\n /** Add arguments. The generic enforces that argument objects are included for all keys of a type. */\n private _addArguemnts<TAddArguments extends object>(args: Record<keyof TAddArguments, Argument>) {\n for (const argument of Object.values(args)) {\n this._command.addArgument(argument as Argument);\n }\n }\n\n /** Add options. The generic enforces that option objects are included for all keys of a type. */\n private _addOptions<TAddOptions extends object>(\n options: Record<keyof TAddOptions, Option>,\n skipOptions: Array<keyof TAddOptions> = [],\n ): void {\n for (const [name, option] of Object.entries(options) as [keyof TAddOptions, Option][]) {\n if (!skipOptions.includes(name)) {\n this._command.addOption(option);\n }\n }\n }\n\n private _addAction(getExecutor: NonNullable<CloudpackCommandParams<TOptions, TArguments>['getExecutor']>) {\n const command = this._command;\n // The action function receives parsed options as its first parameter, but we ignore those\n // because they only contain options *specific to this command*, not shared options like `debug`.\n command.action(async () => {\n // Commander has support for custom parsers that parse arguments.\n // Use processedArgs instead of args to get the parsed arguments.\n const processedArgs = command.processedArgs as string[];\n\n // Get the shared options too, not just the ones for this command.\n // (In `cloudpackCommand`, we added the shared options to each command object so that they show up\n // in help, but commander still seems to respect options only at the first command where they're\n // encountered, which for shared options will always be the program command.)\n const options = command.optsWithGlobals<TOptions & SharedOptions>();\n\n // Usually `command` will be a sub-command (e.g. \"bundle\"), but it could also be a sub-sub-command\n // (e.g. \"cache clean\").\n const verb = command.parent?.parent ? `${command.parent.name()} ${command.name()}` : command.name();\n\n // Dynamically import the execute function\n const { execute } = await getExecutor();\n if (typeof execute !== 'function') {\n // throw instead of exiting politely, since this is a major developer error\n throw new Error(`No execute function was exported from the command module for ${verb}.`);\n }\n\n const commandExecutor = new CommandExecutor<TOptions & SharedOptions>({\n args: processedArgs,\n options,\n execute,\n programOptions: this._programOptions,\n verb,\n });\n await commandExecutor.execute();\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.d.ts","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAwC,MAAM,2BAA2B,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ/D;;G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SAAS,CAAe;IAChC,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,sBAAsB,CAA+B;gBAEjD,MAAM,EAAE;QAClB,iCAAiC;QACjC,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,2CAA2C;QAC3C,OAAO,EAAE,QAAQ,CAAC;QAClB,uCAAuC;QACvC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjC,0CAA0C;QAC1C,cAAc,EAAE,cAAc,CAAC;QAC/B,sDAAsD;QACtD,IAAI,EAAE,MAAM,CAAC;KACd;IAWD,uBAAuB;IAEV,OAAO;IA4CpB;;;;;OAKG;YACW,WAAW;YAsHX,cAAc;IA0D5B;;;OAGG;IACH,OAAO,CAAC,KAAK,CA4BX;CACH"}
@@ -172,9 +172,11 @@ export class CommandExecutor {
172
172
  console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);
173
173
  }
174
174
  contexts.push({
175
- appPath: appPath,
176
- telemetryClient,
175
+ appPath,
176
+ cachePath: this._options.cachePath,
177
177
  config,
178
+ reporter: this._reporter,
179
+ telemetryClient,
178
180
  });
179
181
  }
180
182
  return singleAppPath ? contexts[0] : contexts;
@@ -1 +1 @@
1
- {"version":3,"file":"CommandExecutor.js","sourceRoot":"","sources":["../../src/utilities/CommandExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,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;A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CAAC;QAC7G,eAAe,CAAC,sBAAsB,CAAC,SAAS,EAAE,OAAO,IAAI,WAAW,CAAC,CAAC;QAC1E,eAAe,CAAC,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS,CAAC,CAAC;QAEzE,IAAI,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,CAAC;YAC5D,eAAe,CAAC,sBAAsB,CACpC,uBAAuB,EACvB,OAAO,CAAC,GAAG,CAAC,2CAA2C,CACxD,CAAC;QACJ,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,YAAY,GAAG;gBACnB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAClC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;gBAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;gBACrC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC;aAC5D,CAAC;YAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxD,IAAI,KAAK,EAAE,CAAC;oBACV,eAAe,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;QACH,CAAC;QAED,qFAAqF;QACrF,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAE9C,OAAO,eAAe,CAAC;IACzB,CAAC;CAmCF","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { BundleMode, 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 { registerPerformanceObservers } from '../performance/registerPerformanceObservers.js';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\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._reporter = new TaskReporter();\n this._abortController = new AbortController();\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() {\n try {\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', () => {\n sigintCount++;\n if (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 process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ message: this._getMessageOnInterrupt() });\n });\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n exit: this._exit,\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\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 instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(initializeParams: {\n appPath: string;\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext>;\n private async _initialize(initializeParams: {\n appPaths: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext[]>;\n private async _initialize(initializeParams: {\n appPath?: string;\n appPaths?: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, mode } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const actionOptions: SharedOptions = {\n ...this._options,\n ...initializeParams.overrideOptions,\n };\n\n const helpMessages = new Set<string>();\n\n const configs = new Map<string, CloudpackConfig>();\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, mode);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // 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.set(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: !actionOptions.color,\n ...(actionOptions.debug\n ? debugLoggingConfig\n : actionOptions.verbose\n ? verboseLoggingConfig\n : actionOptions.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs.get(appPath) as CloudpackConfig;\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 // Merge in any additional features from the command line and remote feature flags.\n config.features = await getMergedFeatureFlags({ config, actionOptions, appPath, appName: name });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n contexts.push({\n appPath: appPath,\n telemetryClient,\n config,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\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 rootSpanName: 'CLI',\n });\n\n const isCI = isCIBuild();\n\n telemetryClient.setSharedSpanAttribute('verb', this._verb);\n telemetryClient.setSharedSpanAttribute('arguments', programOptions.argv.slice(3).join(' '));\n telemetryClient.setSharedSpanAttribute('environment', isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local');\n telemetryClient.setSharedSpanAttribute('appName', appName || '<unknown>');\n telemetryClient.setSharedSpanAttribute('mode', config.mode || 'library');\n\n if (process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID) {\n telemetryClient.setSharedSpanAttribute(\n 'externalCorrelationId',\n process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID,\n );\n }\n\n if (isCI) {\n const ciAttributes = {\n buildId: process.env.BUILD_BUILDID,\n definitionId: process.env.SYSTEM_DEFINITIONID,\n buildReason: process.env.BUILD_REASON,\n pullRequestId: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,\n };\n\n for (const [key, value] of Object.entries(ciAttributes)) {\n if (value) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\n }\n }\n\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(telemetryClient);\n\n return telemetryClient;\n }\n\n /**\n * This is the `exit` function passed to the command's execute function.\n * (It must be an arrow function to ensure the correct `this` context.)\n */\n private _exit = async (params: CommandExitParams) => {\n const { message, hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\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 (!process.env.JEST_WORKER_ID) {\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 // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\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,EAAE,MAAM,sBAAsB,CAAC;AAElD,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;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAI9F,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,eAAe;IAY1B,YAAY,MAWX;QAfO,mBAAc,GAAG,KAAK,CAAC;QAEvB,2BAAsB,GAAG,GAAG,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C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;gBAC7C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;gBACrC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC;aAC5D,CAAC;YAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxD,IAAI,KAAK,EAAE,CAAC;oBACV,eAAe,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,CAAC;YACH,CAAC;QACH,CAAC;QAED,qFAAqF;QACrF,4BAA4B,CAAC,eAAe,CAAC,CAAC;QAE9C,OAAO,eAAe,CAAC;IACzB,CAAC;CAmCF","sourcesContent":["import { readConfig } from '@ms-cloudpack/config';\nimport type { BundleMode, 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 { registerPerformanceObservers } from '../performance/registerPerformanceObservers.js';\nimport type { CommandAction, CommandExitParams, AppCommandContext } from '../types/CommandAction.js';\nimport type { ProgramOptions } from '../types/ProgramOptions.js';\nimport type { SharedOptions } from '../types/SharedOptions.js';\nimport { isCIBuild } from '../utilities/isCIBuild.js';\nimport { AutoDisposableList } from './AutoDisposableList.js';\nimport { checkFeatures } from './checkFeatures.js';\nimport { getMergedFeatureFlags } from './getMergedFeatureFlags.js';\nimport { isCodespaces } from '../utilities/isCodespaces.js';\nimport { getVersion } from '@ms-cloudpack/package-utilities';\n\n/**\n * This class manages orchestration and shared state while executing a command.\n */\nexport class CommandExecutor<TOptions extends SharedOptions> {\n private _options: TOptions;\n private _execute: CommandAction<TOptions>;\n private _programOptions: ProgramOptions;\n private _verb: string;\n private _reporter: TaskReporter;\n private _autoDisposableList: AutoDisposableList;\n private _abortController: AbortController;\n private _hasCalledExit = false;\n private _args: string[];\n private _getMessageOnInterrupt = () => `Interrupted by user`;\n\n constructor(params: {\n /** Command-specific arguments */\n args: string[];\n /** Command-specific and shared options. */\n options: TOptions;\n /** Function to execute the command. */\n execute: CommandAction<TOptions>;\n /** Shared program-level configuration. */\n programOptions: ProgramOptions;\n /** Verb being run, e.g. `bundle` or `cache clean`. */\n verb: string;\n }) {\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._reporter = new TaskReporter();\n this._abortController = new AbortController();\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() {\n try {\n // Setup cleanup and close things on completion.\n let sigintCount = 0;\n\n // Handle SIGINT (Ctrl+C) gracefully.\n process.on('SIGINT', () => {\n sigintCount++;\n if (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 process.exit(1);\n }\n\n // We are trying to exit gracefully.\n void this._exit({ message: this._getMessageOnInterrupt() });\n });\n\n // Call the execute function which is the real command logic\n // (ie: real init command logic, real start command logic, etc.)\n await this._execute({\n args: this._args,\n options: this._options,\n cwd: this._programOptions.cwd,\n reporter: this._reporter,\n initialize: this._initialize.bind(this),\n abortSignal: this._abortController.signal,\n autoDispose: (disposable) => this._autoDisposableList.add(disposable),\n exit: this._exit,\n setInterruptMessageHandler: (getMessage) => {\n this._getMessageOnInterrupt = getMessage;\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 instanceof Error ? error.stack || error.message : String(error),\n });\n }\n }\n\n /**\n * This is the `initialize` function passed to the command's execute function.\n * This function uses `this` to references several class members, which is why\n * the `execute` method must use `.bind(this)`.\n * (An arrow function isn't possible here due to the overloaded method signature).\n */\n private async _initialize(initializeParams: {\n appPath: string;\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext>;\n private async _initialize(initializeParams: {\n appPaths: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext[]>;\n private async _initialize(initializeParams: {\n appPath?: string;\n appPaths?: string[];\n mode?: BundleMode;\n overrideOptions?: Partial<SharedOptions>;\n }): Promise<AppCommandContext | AppCommandContext[]> {\n const { appPath: singleAppPath, mode } = initializeParams;\n let { appPaths } = initializeParams;\n\n if (singleAppPath && appPaths) {\n throw Error('appPath and appPaths cannot both be specified at the same time');\n }\n if (!singleAppPath && !appPaths) {\n throw Error('one of appPath or appPaths must be specified');\n }\n\n if (!appPaths || appPaths.length === 0) {\n appPaths = singleAppPath ? [singleAppPath] : [];\n }\n\n const contexts: AppCommandContext[] = [];\n\n const actionOptions: SharedOptions = {\n ...this._options,\n ...initializeParams.overrideOptions,\n };\n\n const helpMessages = new Set<string>();\n\n const configs = new Map<string, CloudpackConfig>();\n for (const appPath of appPaths) {\n let config: CloudpackConfig;\n\n try {\n config = await readConfig(appPath, mode);\n } catch (err) {\n await this._exit({\n message: `Invalid cloudpack config: ${(err as Error).message || err}`,\n hasErrors: true,\n });\n // 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.set(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: !actionOptions.color,\n ...(actionOptions.debug\n ? debugLoggingConfig\n : actionOptions.verbose\n ? verboseLoggingConfig\n : actionOptions.quiet\n ? noLoggingConfig\n : defaultLoggingConfig),\n });\n\n for (const appPath of appPaths) {\n const config = configs.get(appPath) as CloudpackConfig;\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 // Merge in any additional features from the command line and remote feature flags.\n config.features = await getMergedFeatureFlags({ config, actionOptions, appPath, appName: name });\n\n const featureErrors = checkFeatures({ configFeatures: config.features });\n\n // If there are any invalid features, warn the user and continue.\n if (featureErrors.length) {\n featureErrors.forEach((warning) => console.warn(warning));\n }\n\n const enabledFeatureNames = Object.entries(config.features)\n .filter(([, value]) => value)\n .map(([key]) => key);\n\n if (enabledFeatureNames.length) {\n telemetryClient.setSharedSpanAttribute('features', enabledFeatureNames);\n console.log(`Enabled features: ${enabledFeatureNames.map((f) => yellow(f)).join(', ')}`);\n }\n\n contexts.push({\n appPath,\n cachePath: this._options.cachePath,\n config,\n reporter: this._reporter,\n telemetryClient,\n });\n }\n\n return singleAppPath ? contexts[0] : contexts;\n }\n\n private async _initTelemetry(appName: string | undefined, config: CloudpackConfig): Promise<TelemetryClient> {\n const programOptions = this._programOptions;\n const options = this._options;\n\n const connectionString = programOptions.disableTelemetry\n ? undefined\n : config.telemetry?.connectionString || process.env.CLOUDPACK_TELEMETRY_CONNECTION_STRING;\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 rootSpanName: 'CLI',\n });\n\n const isCI = isCIBuild();\n\n telemetryClient.setSharedSpanAttribute('verb', this._verb);\n telemetryClient.setSharedSpanAttribute('arguments', programOptions.argv.slice(3).join(' '));\n telemetryClient.setSharedSpanAttribute('environment', isCI ? 'ci' : isCodespaces() ? 'codespaces' : 'local');\n telemetryClient.setSharedSpanAttribute('appName', appName || '<unknown>');\n telemetryClient.setSharedSpanAttribute('mode', config.mode || 'library');\n\n if (process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID) {\n telemetryClient.setSharedSpanAttribute(\n 'externalCorrelationId',\n process.env.CLOUDPACK_TELEMETRY_EXTERNAL_CORRELATION_ID,\n );\n }\n\n if (isCI) {\n const ciAttributes = {\n buildId: process.env.BUILD_BUILDID,\n definitionId: process.env.SYSTEM_DEFINITIONID,\n buildReason: process.env.BUILD_REASON,\n pullRequestId: process.env.SYSTEM_PULLREQUEST_PULLREQUESTID,\n };\n\n for (const [key, value] of Object.entries(ciAttributes)) {\n if (value) {\n telemetryClient.setSharedSpanAttribute(key, value);\n }\n }\n }\n\n // Register performance observers to track performance metrics as events of CLI span.\n registerPerformanceObservers(telemetryClient);\n\n return telemetryClient;\n }\n\n /**\n * This is the `exit` function passed to the command's execute function.\n * (It must be an arrow function to ensure the correct `this` context.)\n */\n private _exit = async (params: CommandExitParams) => {\n const { message, hasErrors = this._reporter.hasErrors(), exitCode = hasErrors ? 1 : 0 } = params;\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 (!process.env.JEST_WORKER_ID) {\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 // Let the execute function know that we are exiting.\n this._abortController.abort();\n\n // Dispose all registered disposables.\n await this._autoDisposableList.dispose();\n\n const exitWithError = exitCode !== 0;\n\n // Show the summary message (this will throw if called twice).\n this._reporter.complete(hasErrors ? red(message) : message, exitWithError);\n }\n\n process.exit(exitCode);\n };\n}\n"]}
@@ -6,7 +6,7 @@ import type { TelemetryClient } from '@ms-cloudpack/telemetry';
6
6
  */
7
7
  export declare function runPrerequisites(options: {
8
8
  config: CloudpackConfig | undefined;
9
- cwd: string;
9
+ appPath: string;
10
10
  telemetryClient: TelemetryClient;
11
11
  }): void;
12
12
  //# sourceMappingURL=runPrerequisites.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runPrerequisites.d.ts","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,eAAe,CAAC;CAClC,QAWA"}
1
+ {"version":3,"file":"runPrerequisites.d.ts","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;CAClC,QAWA"}
@@ -4,12 +4,12 @@ import spawn from 'cross-spawn';
4
4
  * @param config - The Cloudpack config of containing a list of prerequisites to run
5
5
  */
6
6
  export function runPrerequisites(options) {
7
- const { config, cwd, telemetryClient } = options;
7
+ const { config, appPath, telemetryClient } = options;
8
8
  telemetryClient.performance.track('RUN_PREREQUISITES', () => {
9
9
  const dependsOn = config?.dependsOn;
10
10
  if (dependsOn) {
11
11
  for (const [command, args] of dependsOn) {
12
- spawn.sync(command, args, { stdio: 'inherit', cwd, shell: true });
12
+ spawn.sync(command, args, { stdio: 'inherit', cwd: appPath, shell: true });
13
13
  }
14
14
  }
15
15
  });
@@ -1 +1 @@
1
- {"version":3,"file":"runPrerequisites.js","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAIhC;IACC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEjD,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC1D,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;QACpC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport spawn from 'cross-spawn';\n\n/**\n * Runs the pre-requisites specified in the given Cloudpack config\n * @param config - The Cloudpack config of containing a list of prerequisites to run\n */\nexport function runPrerequisites(options: {\n config: CloudpackConfig | undefined;\n cwd: string;\n telemetryClient: TelemetryClient;\n}) {\n const { config, cwd, telemetryClient } = options;\n\n telemetryClient.performance.track('RUN_PREREQUISITES', () => {\n const dependsOn = config?.dependsOn;\n if (dependsOn) {\n for (const [command, args] of dependsOn) {\n spawn.sync(command, args, { stdio: 'inherit', cwd, shell: true });\n }\n }\n });\n}\n"]}
1
+ {"version":3,"file":"runPrerequisites.js","sourceRoot":"","sources":["../../src/utilities/runPrerequisites.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAIhC;IACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAErD,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC1D,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAC;QACpC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,SAAS,EAAE,CAAC;gBACxC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { CloudpackConfig } from '@ms-cloudpack/common-types';\nimport type { TelemetryClient } from '@ms-cloudpack/telemetry';\nimport spawn from 'cross-spawn';\n\n/**\n * Runs the pre-requisites specified in the given Cloudpack config\n * @param config - The Cloudpack config of containing a list of prerequisites to run\n */\nexport function runPrerequisites(options: {\n config: CloudpackConfig | undefined;\n appPath: string;\n telemetryClient: TelemetryClient;\n}) {\n const { config, appPath, telemetryClient } = options;\n\n telemetryClient.performance.track('RUN_PREREQUISITES', () => {\n const dependsOn = config?.dependsOn;\n if (dependsOn) {\n for (const [command, args] of dependsOn) {\n spawn.sync(command, args, { stdio: 'inherit', cwd: appPath, shell: true });\n }\n }\n });\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { CommandActionParams } from '../types/CommandAction.ts';
2
+ type ExitFunction = CommandActionParams<object>['exit'];
3
+ /**
4
+ * Set the exit function to be used for `stopServers` (see that function for more details).
5
+ * Called by `start`'s executor.
6
+ */
7
+ export declare function setStopServersFunction(exit: ExitFunction): void;
8
+ /**
9
+ * Emulate the user pressing ctrl+C for the start command (no-op for other commands).
10
+ */
11
+ export declare function stopServers(): Promise<void>;
12
+ export {};
13
+ //# sourceMappingURL=stopServers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopServers.d.ts","sourceRoot":"","sources":["../../src/utilities/stopServers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrE,KAAK,YAAY,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAGxD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,QAExD;AAED;;GAEG;AACH,wBAAsB,WAAW,kBAKhC"}
@@ -0,0 +1,18 @@
1
+ let exitFunction;
2
+ /**
3
+ * Set the exit function to be used for `stopServers` (see that function for more details).
4
+ * Called by `start`'s executor.
5
+ */
6
+ export function setStopServersFunction(exit) {
7
+ exitFunction = exit;
8
+ }
9
+ /**
10
+ * Emulate the user pressing ctrl+C for the start command (no-op for other commands).
11
+ */
12
+ export async function stopServers() {
13
+ if (exitFunction) {
14
+ await exitFunction({ exitCode: 0, message: 'stopServers called' });
15
+ exitFunction = undefined;
16
+ }
17
+ }
18
+ //# sourceMappingURL=stopServers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stopServers.js","sourceRoot":"","sources":["../../src/utilities/stopServers.ts"],"names":[],"mappings":"AAKA,IAAI,YAAsC,CAAC;AAE3C;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAkB;IACvD,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAC;QACnE,YAAY,GAAG,SAAS,CAAC;IAC3B,CAAC;AACH,CAAC","sourcesContent":["import type { CommandActionParams } from '../types/CommandAction.ts';\n\n// This is in a separate file so that unrelated tests don't have to import the `start` executor.\n\ntype ExitFunction = CommandActionParams<object>['exit'];\nlet exitFunction: ExitFunction | undefined;\n\n/**\n * Set the exit function to be used for `stopServers` (see that function for more details).\n * Called by `start`'s executor.\n */\nexport function setStopServersFunction(exit: ExitFunction) {\n exitFunction = exit;\n}\n\n/**\n * Emulate the user pressing ctrl+C for the start command (no-op for other commands).\n */\nexport async function stopServers() {\n if (exitFunction) {\n await exitFunction({ exitCode: 0, message: 'stopServers called' });\n exitFunction = undefined;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/cli",
3
- "version": "0.68.3",
3
+ "version": "0.69.1",
4
4
  "description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,24 +10,25 @@
10
10
  "cloudpack": "./bin/cloudpack.js"
11
11
  },
12
12
  "dependencies": {
13
- "@ms-cloudpack/api-server": "^0.50.0",
14
- "@ms-cloudpack/app-server": "^0.15.3",
13
+ "@ms-cloudpack/api-server": "^0.51.1",
14
+ "@ms-cloudpack/app-server": "^0.15.5",
15
15
  "@ms-cloudpack/common-types": "^0.19.1",
16
- "@ms-cloudpack/config": "^0.27.2",
16
+ "@ms-cloudpack/config": "^0.28.0",
17
17
  "@ms-cloudpack/feature-flags": "^0.1.1",
18
18
  "@ms-cloudpack/json-utilities": "^0.1.7",
19
- "@ms-cloudpack/overlay": "^0.17.56",
19
+ "@ms-cloudpack/overlay": "^0.17.58",
20
20
  "@ms-cloudpack/package-utilities": "^10.0.1",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.4",
22
22
  "@ms-cloudpack/path-utilities": "^2.7.38",
23
23
  "@ms-cloudpack/remote-cache": "^0.8.6",
24
- "@ms-cloudpack/setup-utilities": "^0.2.0",
24
+ "@ms-cloudpack/setup-utilities": "^0.3.0",
25
25
  "@ms-cloudpack/task-reporter": "^0.14.4",
26
26
  "@ms-cloudpack/telemetry": "^0.6.1",
27
27
  "@yarnpkg/lockfile": "^1.1.0",
28
28
  "commander": "^11.1.0",
29
29
  "cross-spawn": "^7.0.3",
30
30
  "didyoumean": "^1.2.2",
31
+ "get-port": "^7.0.0",
31
32
  "glob-hasher": "^1.4.2",
32
33
  "open": "^9.0.0",
33
34
  "prompts": "^2.4.2",