@shopify/cli-kit 3.61.2 → 3.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/private/node/api/headers.js +1 -0
  2. package/dist/private/node/api/headers.js.map +1 -1
  3. package/dist/private/node/conf-store.d.ts +2 -0
  4. package/dist/private/node/conf-store.js.map +1 -1
  5. package/dist/private/node/content-tokens.d.ts +2 -1
  6. package/dist/private/node/content-tokens.js +3 -2
  7. package/dist/private/node/content-tokens.js.map +1 -1
  8. package/dist/private/node/context/utilities.js +9 -0
  9. package/dist/private/node/context/utilities.js.map +1 -1
  10. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -1
  11. package/dist/private/node/ui/components/ConcurrentOutput.js +5 -4
  12. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  13. package/dist/private/node/ui/components/ConcurrentOutput.test.js +48 -3
  14. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  15. package/dist/public/common/lang.d.ts +0 -1
  16. package/dist/public/common/lang.js +0 -1
  17. package/dist/public/common/lang.js.map +1 -1
  18. package/dist/public/common/retry.d.ts +1 -0
  19. package/dist/public/common/retry.js +1 -0
  20. package/dist/public/common/retry.js.map +1 -1
  21. package/dist/public/common/ts/deep-required.d.ts +1 -1
  22. package/dist/public/common/ts/deep-required.js.map +1 -1
  23. package/dist/public/common/ts/pick-by-prefix.d.ts +1 -1
  24. package/dist/public/common/ts/pick-by-prefix.js.map +1 -1
  25. package/dist/public/common/version.d.ts +1 -1
  26. package/dist/public/common/version.js +1 -1
  27. package/dist/public/common/version.js.map +1 -1
  28. package/dist/public/node/api/business-platform.d.ts +11 -0
  29. package/dist/public/node/api/business-platform.js +33 -8
  30. package/dist/public/node/api/business-platform.js.map +1 -1
  31. package/dist/public/node/api/graphql.d.ts +19 -4
  32. package/dist/public/node/api/graphql.js +30 -7
  33. package/dist/public/node/api/graphql.js.map +1 -1
  34. package/dist/public/node/api/partners.d.ts +11 -0
  35. package/dist/public/node/api/partners.js +36 -8
  36. package/dist/public/node/api/partners.js.map +1 -1
  37. package/dist/public/node/base-command.d.ts +3 -2
  38. package/dist/public/node/base-command.js +3 -0
  39. package/dist/public/node/base-command.js.map +1 -1
  40. package/dist/public/node/cli.js +1 -1
  41. package/dist/public/node/cli.js.map +1 -1
  42. package/dist/public/node/context/local.js +3 -0
  43. package/dist/public/node/context/local.js.map +1 -1
  44. package/dist/public/node/custom-oclif-loader.d.ts +0 -6
  45. package/dist/public/node/custom-oclif-loader.js +1 -15
  46. package/dist/public/node/custom-oclif-loader.js.map +1 -1
  47. package/dist/public/node/dot-env.js.map +1 -1
  48. package/dist/public/node/fs.d.ts +0 -1
  49. package/dist/public/node/git.d.ts +2 -0
  50. package/dist/public/node/git.js +2 -0
  51. package/dist/public/node/git.js.map +1 -1
  52. package/dist/public/node/is-global.d.ts +3 -5
  53. package/dist/public/node/is-global.js +22 -8
  54. package/dist/public/node/is-global.js.map +1 -1
  55. package/dist/public/node/json-schema.d.ts +27 -0
  56. package/dist/public/node/json-schema.js +197 -0
  57. package/dist/public/node/json-schema.js.map +1 -0
  58. package/dist/public/node/logs.d.ts +1 -1
  59. package/dist/public/node/logs.js +3 -1
  60. package/dist/public/node/logs.js.map +1 -1
  61. package/dist/public/node/monorail.d.ts +1 -1
  62. package/dist/public/node/monorail.js.map +1 -1
  63. package/dist/public/node/node-package-manager.d.ts +12 -1
  64. package/dist/public/node/node-package-manager.js +32 -15
  65. package/dist/public/node/node-package-manager.js.map +1 -1
  66. package/dist/public/node/output.d.ts +2 -1
  67. package/dist/public/node/output.js +5 -2
  68. package/dist/public/node/output.js.map +1 -1
  69. package/dist/public/node/path.d.ts +14 -0
  70. package/dist/public/node/path.js +27 -0
  71. package/dist/public/node/path.js.map +1 -1
  72. package/dist/public/node/ruby.d.ts +2 -0
  73. package/dist/public/node/ruby.js +2 -0
  74. package/dist/public/node/ruby.js.map +1 -1
  75. package/dist/public/node/schema.d.ts +20 -1
  76. package/dist/public/node/schema.js.map +1 -1
  77. package/dist/public/node/system.d.ts +4 -1
  78. package/dist/public/node/system.js +7 -1
  79. package/dist/public/node/system.js.map +1 -1
  80. package/dist/public/node/tcp.d.ts +1 -1
  81. package/dist/public/node/tcp.js +1 -1
  82. package/dist/public/node/tcp.js.map +1 -1
  83. package/dist/public/node/tree-kill.js +0 -1
  84. package/dist/public/node/tree-kill.js.map +1 -1
  85. package/dist/public/node/ui.d.ts +8 -3
  86. package/dist/public/node/ui.js +7 -4
  87. package/dist/public/node/ui.js.map +1 -1
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +6 -3
@@ -14,6 +14,7 @@ export class GraphQLClientError extends RequestClientError {
14
14
  constructor(message, statusCode, errors) {
15
15
  super(message, statusCode);
16
16
  this.errors = errors;
17
+ this.stack = undefined;
17
18
  }
18
19
  }
19
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAC,aAAa,EAAC,MAAM,uCAAuC,CAAA;AACnE,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAErD,YAAmB,OAAe,EAAE,UAAkB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AACD,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IAIxD,8DAA8D;IAC9D,YAAmB,OAAe,EAAE,UAAkB,EAAE,MAAc;QACpE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC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U,KAAK,EAAE,CAAA;QAC5E,wCAAwC;QACxC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAA;QACrC,OAAO,CAAC,wBAAwB,CAAC,GAAG,UAAU,CAAA;KAC/C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC;QACrB,kBAAkB,EAAE,MAAM,gCAAgC,EAAE;QAC5D,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,gCAAgC;IAC7C,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AAC1D,CAAC","sourcesContent":["import {CLI_KIT_VERSION} from '../../../public/common/version.js'\nimport {firstPartyDev} from '../../../public/node/context/local.js'\nimport {Environment, serviceEnvironment} from '../context/service.js'\nimport {ExtendableError} from '../../../public/node/error.js'\nimport https from 'https'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\nexport class GraphQLClientError extends RequestClientError {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errors?: any[]\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(message: string, statusCode: number, errors?: any[]) {\n super(message, statusCode)\n this.errors = errors\n }\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization', 'subject_token']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport function buildHeaders(token?: string): {[key: string]: string} {\n const userAgent = `Shopify CLI; v=${CLI_KIT_VERSION}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n 'Keep-Alive': 'timeout=30',\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n const authString = token.match(/^shp(at|ua|ca)/) ? token : `Bearer ${token}`\n // eslint-disable-next-line dot-notation\n headers['authorization'] = authString\n headers['X-Shopify-Access-Token'] = authString\n }\n\n return headers\n}\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent(): Promise<https.Agent> {\n return new https.Agent({\n rejectUnauthorized: await shouldRejectUnauthorizedRequests(),\n keepAlive: true,\n })\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nasync function shouldRejectUnauthorizedRequests(): Promise<boolean> {\n return (await serviceEnvironment()) !== Environment.Spin\n}\n"]}
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAC,aAAa,EAAC,MAAM,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,CAAA;IAC7C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,MAAM,SAAS,GAAG,kBAAkB,eAAe,EAAE,CAAA;IAErD,MAAM,OAAO,GAA+B;QAC1C,YAAY,EAAE,SAAS;QACvB,YAAY,EAAE,YAAY;QAC1B,0DAA0D;QAC1D,oBAAoB,EAAE,OAAO,CAAC,QAAQ;QACtC,cAAc,EAAE,kBAAkB;QAClC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAC,wBAAwB,EAAE,GAAG,EAAC,CAAC;KACxD,CAAA;IACD,IAAI,KAAK,EAAE;QACT,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAA;QAC5E,wCAAwC;QACxC,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,CAAA;QACrC,OAAO,CAAC,wBAAwB,CAAC,GAAG,UAAU,CAAA;KAC/C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC;QACrB,kBAAkB,EAAE,MAAM,gCAAgC,EAAE;QAC5D,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,gCAAgC;IAC7C,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AAC1D,CAAC","sourcesContent":["import {CLI_KIT_VERSION} from '../../../public/common/version.js'\nimport {firstPartyDev} from '../../../public/node/context/local.js'\nimport {Environment, serviceEnvironment} from '../context/service.js'\nimport {ExtendableError} from '../../../public/node/error.js'\nimport https from 'https'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\nexport class GraphQLClientError extends RequestClientError {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errors?: any[]\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(message: string, statusCode: number, errors?: any[]) {\n super(message, statusCode)\n this.errors = errors\n this.stack = undefined\n }\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization', 'subject_token']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport function buildHeaders(token?: string): {[key: string]: string} {\n const userAgent = `Shopify CLI; v=${CLI_KIT_VERSION}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n 'Keep-Alive': 'timeout=30',\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n const authString = token.match(/^shp(at|ua|ca)/) ? token : `Bearer ${token}`\n // eslint-disable-next-line dot-notation\n headers['authorization'] = authString\n headers['X-Shopify-Access-Token'] = authString\n }\n\n return headers\n}\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent(): Promise<https.Agent> {\n return new https.Agent({\n rejectUnauthorized: await shouldRejectUnauthorizedRequests(),\n keepAlive: true,\n })\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nasync function shouldRejectUnauthorizedRequests(): Promise<boolean> {\n return (await serviceEnvironment()) !== Environment.Spin\n}\n"]}
@@ -4,8 +4,10 @@ interface CacheValue<T> {
4
4
  timestamp: number;
5
5
  }
6
6
  export type IntrospectionUrlKey = `identity-introspection-url-${string}`;
7
+ export type PackageVersionKey = `npm-package-${string}`;
7
8
  interface Cache {
8
9
  [introspectionUrlKey: IntrospectionUrlKey]: CacheValue<string>;
10
+ [packageVersionKey: PackageVersionKey]: CacheValue<string>;
9
11
  }
10
12
  export interface ConfSchema {
11
13
  sessionStore: string;
@@ -1 +1 @@
1
- {"version":3,"file":"conf-store.js","sourceRoot":"","sources":["../../../src/private/node/conf-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,8BAA8B,CAAA;AAkBvE,IAAI,SAA+C,CAAA;AAEnD;;;;GAIG;AACH,SAAS,WAAW;IAClB,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,IAAI,YAAY,CAAa,EAAC,WAAW,EAAE,iBAAiB,EAAC,CAAC,CAAA;KAC3E;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,SAAmC,WAAW,EAAE;IACzE,WAAW,CAAC,aAAa,CAAA,0BAA0B,CAAC,CAAA;IACpD,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,SAAmC,WAAW,EAAE;IAC1F,WAAW,CAAC,aAAa,CAAA,0BAA0B,CAAC,CAAA;IACpD,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,SAAmC,WAAW,EAAE;IAC5E,WAAW,CAAC,aAAa,CAAA,2BAA2B,CAAC,CAAA;IACrD,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;AAC/B,CAAC;AAGD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,GAAgB,EAChB,EAA+C,EAC/C,OAAgB,EAChB,MAAM,GAAG,WAAW,EAAE;IAEtB,MAAM,KAAK,GAAU,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAA;IAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;IAEzB,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE;QACrG,OAAO,MAAM,CAAC,KAAK,CAAA;KACpB;IAED,MAAM,KAAK,GAAG,MAAM,EAAE,EAAE,CAAA;IACxB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAC,CAAA;IAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC1B,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {LocalStorage} from '../../public/node/local-storage.js'\nimport {outputContent, outputDebug} from '@shopify/cli-kit/node/output'\n\ninterface CacheValue<T> {\n value: T\n timestamp: number\n}\n\nexport type IntrospectionUrlKey = `identity-introspection-url-${string}`\n\ninterface Cache {\n [introspectionUrlKey: IntrospectionUrlKey]: CacheValue<string>\n}\n\nexport interface ConfSchema {\n sessionStore: string\n cache?: Cache\n}\n\nlet _instance: LocalStorage<ConfSchema> | undefined\n\n/**\n * CLIKIT Store.\n *\n * @returns CLIKitStore.\n */\nfunction cliKitStore() {\n if (!_instance) {\n _instance = new LocalStorage<ConfSchema>({projectName: 'shopify-cli-kit'})\n }\n return _instance\n}\n\n/**\n * Get session.\n *\n * @returns Session.\n */\nexport function getSession(config: LocalStorage<ConfSchema> = cliKitStore()): string | undefined {\n outputDebug(outputContent`Getting session store...`)\n return config.get('sessionStore')\n}\n\n/**\n * Set session.\n *\n * @param session - Session.\n */\nexport function setSession(session: string, config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Setting session store...`)\n config.set('sessionStore', session)\n}\n\n/**\n * Remove session.\n */\nexport function removeSession(config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Removing session store...`)\n config.delete('sessionStore')\n}\n\ntype CacheValueForKey<TKey extends keyof Cache> = NonNullable<Cache[TKey]>['value']\n/**\n * Fetch from cache, or run the provided function to get the value, and cache it\n * before returning it.\n * @param key - The key to use for the cache.\n * @param fn - The function to run to get the value to cache, if a cache miss occurs.\n * @param timeout - The maximum valid age of a cached value, in milliseconds.\n * If the cached value is older than this, it will be refreshed.\n * @returns The value from the cache or the result of the function.\n */\nexport async function cacheRetrieveOrRepopulate(\n key: keyof Cache,\n fn: () => Promise<CacheValueForKey<typeof key>>,\n timeout?: number,\n config = cliKitStore(),\n): Promise<CacheValueForKey<typeof key>> {\n const cache: Cache = config.get('cache') || {}\n const cached = cache[key]\n\n if (cached?.value !== undefined && (timeout === undefined || Date.now() - cached.timestamp < timeout)) {\n return cached.value\n }\n\n const value = await fn()\n cache[key] = {value, timestamp: Date.now()}\n config.set('cache', cache)\n return value\n}\n"]}
1
+ {"version":3,"file":"conf-store.js","sourceR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IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE;QACrG,OAAO,MAAM,CAAC,KAAK,CAAA;KACpB;IAED,MAAM,KAAK,GAAG,MAAM,EAAE,EAAE,CAAA;IACxB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAC,CAAA;IAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC1B,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {LocalStorage} from '../../public/node/local-storage.js'\nimport {outputContent, outputDebug} from '@shopify/cli-kit/node/output'\n\ninterface CacheValue<T> {\n value: T\n timestamp: number\n}\n\nexport type IntrospectionUrlKey = `identity-introspection-url-${string}`\nexport type PackageVersionKey = `npm-package-${string}`\n\ninterface Cache {\n [introspectionUrlKey: IntrospectionUrlKey]: CacheValue<string>\n [packageVersionKey: PackageVersionKey]: CacheValue<string>\n}\n\nexport interface ConfSchema {\n sessionStore: string\n cache?: Cache\n}\n\nlet _instance: LocalStorage<ConfSchema> | undefined\n\n/**\n * CLIKIT Store.\n *\n * @returns CLIKitStore.\n */\nfunction cliKitStore() {\n if (!_instance) {\n _instance = new LocalStorage<ConfSchema>({projectName: 'shopify-cli-kit'})\n }\n return _instance\n}\n\n/**\n * Get session.\n *\n * @returns Session.\n */\nexport function getSession(config: LocalStorage<ConfSchema> = cliKitStore()): string | undefined {\n outputDebug(outputContent`Getting session store...`)\n return config.get('sessionStore')\n}\n\n/**\n * Set session.\n *\n * @param session - Session.\n */\nexport function setSession(session: string, config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Setting session store...`)\n config.set('sessionStore', session)\n}\n\n/**\n * Remove session.\n */\nexport function removeSession(config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Removing session store...`)\n config.delete('sessionStore')\n}\n\ntype CacheValueForKey<TKey extends keyof Cache> = NonNullable<Cache[TKey]>['value']\n/**\n * Fetch from cache, or run the provided function to get the value, and cache it\n * before returning it.\n * @param key - The key to use for the cache.\n * @param fn - The function to run to get the value to cache, if a cache miss occurs.\n * @param timeout - The maximum valid age of a cached value, in milliseconds.\n * If the cached value is older than this, it will be refreshed.\n * @returns The value from the cache or the result of the function.\n */\nexport async function cacheRetrieveOrRepopulate(\n key: keyof Cache,\n fn: () => Promise<CacheValueForKey<typeof key>>,\n timeout?: number,\n config = cliKitStore(),\n): Promise<CacheValueForKey<typeof key>> {\n const cache: Cache = config.get('cache') || {}\n const cached = cache[key]\n\n if (cached?.value !== undefined && (timeout === undefined || Date.now() - cached.timestamp < timeout)) {\n return cached.value\n }\n\n const value = await fn()\n cache[key] = {value, timestamp: Date.now()}\n config.set('cache', cache)\n return value\n}\n"]}
@@ -10,7 +10,8 @@ export declare class RawContentToken extends ContentToken<string> {
10
10
  }
11
11
  export declare class LinkContentToken extends ContentToken<OutputMessage> {
12
12
  link: string;
13
- constructor(value: OutputMessage, link: string);
13
+ fallback: string | undefined;
14
+ constructor(value: OutputMessage, link: string, fallback?: string);
14
15
  output(): string;
15
16
  }
16
17
  export declare class CommandContentToken extends ContentToken<OutputMessage> {
@@ -14,14 +14,15 @@ export class RawContentToken extends ContentToken {
14
14
  }
15
15
  }
16
16
  export class LinkContentToken extends ContentToken {
17
- constructor(value, link) {
17
+ constructor(value, link, fallback) {
18
18
  super(value);
19
19
  this.link = link;
20
+ this.fallback = fallback;
20
21
  }
21
22
  output() {
22
23
  const text = colors.green(stringifyMessage(this.value));
23
24
  const url = this.link ?? '';
24
- return terminalLink(text, url, { fallback: () => `${text} ( ${url} )` });
25
+ return terminalLink(text, url, { fallback: () => this.fallback ?? `${text} ( ${url} )` });
25
26
  }
26
27
  }
27
28
  export class CommandContentToken extends ContentToken {
@@ -1 +1 @@
1
- {"version":3,"file":"content-tokens.js","sourceRoot":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AAG,KAAK,CAAA;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACjD,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,YAA2B;IAChE,MAAM;QACJ,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAA2B;IAC/D,MAAM;QACJ,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,YAA2B;IAClE,MAAM;QACJ,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAA2B;IACrE,MAAM;QACJ,OAAO,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAA2B;IACjE,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import colors from '../../public/node/colors.js'\nimport {OutputMessage, stringifyMessage} from '../../public/node/output.js'\nimport {relativizePath} from '../../public/node/path.js'\nimport terminalLink from 'terminal-link'\nimport cjs from 'color-json'\nimport type {Change} from 'diff'\n\nexport abstract class ContentToken<T> {\n value: T\n\n constructor(value: T) {\n this.value = value\n }\n\n abstract output(): string | string[]\n}\n\nexport class RawContentToken extends ContentToken<string> {\n output(): string {\n return this.value\n }\n}\n\nexport class LinkContentToken extends ContentToken<OutputMessage> {\n link: string\n\n constructor(value: OutputMessage, link: string) {\n super(value)\n this.link = link\n }\n\n output() {\n const text = colors.green(stringifyMessage(this.value))\n const url = this.link ?? ''\n return terminalLink(text, url, {fallback: () => `${text} ( ${url} )`})\n }\n}\n\nexport class CommandContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return `\\`${colors.magentaBright(stringifyMessage(this.value))}\\``\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class JsonContentToken extends ContentToken<any> {\n output(): string {\n try {\n return cjs(stringifyMessage(this.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n return JSON.stringify(stringifyMessage(this.value) ?? {}, null, 2)\n }\n }\n}\n\nexport class LinesDiffContentToken extends ContentToken<Change[]> {\n output(): string[] {\n return this.value\n .map((part) => {\n if (part.added) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.green(`+ ${line}\\n`)\n })\n } else if (part.removed) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.magenta(`- ${line}\\n`)\n })\n } else {\n return part.value\n }\n })\n .flat()\n }\n}\n\nexport class ColorContentToken extends ContentToken<OutputMessage> {\n color: (text: string) => string\n\n constructor(value: OutputMessage, color: (text: string) => string) {\n super(value)\n this.color = color\n }\n\n output(): string {\n return this.color(stringifyMessage(this.value))\n }\n}\n\nexport class ErrorContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold.redBright(stringifyMessage(this.value))\n }\n}\n\nexport class PathContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return relativizePath(stringifyMessage(this.value))\n }\n}\n\nexport class HeadingContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold.underline(stringifyMessage(this.value))\n }\n}\n\nexport class SubHeadingContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.underline(stringifyMessage(this.value))\n }\n}\n\nexport class ItalicContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.italic(stringifyMessage(this.value))\n }\n}\n"]}
1
+ {"version":3,"file":"content-tokens.js","sourceRoot":"","sources":["../../../src/private/node/content-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,6BAA6B,CAAA;AAChD,OAAO,EAAgB,gBAAgB,EAAC,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAA;AACxD,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,GAAG,MAAM,YAAY,CAAA;AAG5B,MAAM,OAAgB,YAAY;IAGhC,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CAGF;AAED,MAAM,OAAO,eAAgB,SAAQ,YAAoB;IACvD,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAA2B;IAI/D,YAAY,KAAoB,EAAE,IAAY,EAAE,QAAiB;QAC/D,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;QACvD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAA;QAC3B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,EAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAI,MAAM,GAAG,IAAI,EAAC,CAAC,CAAA;IACzF,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,YAA2B;IAClE,MAAM;QACJ,OAAO,KAAK,MAAM,CAAC,aAAa,CAAC,gBAA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AC;aACD,IAAI,EAAE,CAAA;IACX,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,YAA2B;IAGhE,YAAY,KAAoB,EAAE,KAA+B;QAC/D,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACjD,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,YAA2B;IAChE,MAAM;QACJ,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAA2B;IAC/D,MAAM;QACJ,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,YAA2B;IAClE,MAAM;QACJ,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAA2B;IACrE,MAAM;QACJ,OAAO,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,YAA2B;IACjE,MAAM;QACJ,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import colors from '../../public/node/colors.js'\nimport {OutputMessage, stringifyMessage} from '../../public/node/output.js'\nimport {relativizePath} from '../../public/node/path.js'\nimport terminalLink from 'terminal-link'\nimport cjs from 'color-json'\nimport type {Change} from 'diff'\n\nexport abstract class ContentToken<T> {\n value: T\n\n constructor(value: T) {\n this.value = value\n }\n\n abstract output(): string | string[]\n}\n\nexport class RawContentToken extends ContentToken<string> {\n output(): string {\n return this.value\n }\n}\n\nexport class LinkContentToken extends ContentToken<OutputMessage> {\n link: string\n fallback: string | undefined\n\n constructor(value: OutputMessage, link: string, fallback?: string) {\n super(value)\n this.link = link\n this.fallback = fallback\n }\n\n output() {\n const text = colors.green(stringifyMessage(this.value))\n const url = this.link ?? ''\n return terminalLink(text, url, {fallback: () => this.fallback ?? `${text} ( ${url} )`})\n }\n}\n\nexport class CommandContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return `\\`${colors.magentaBright(stringifyMessage(this.value))}\\``\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class JsonContentToken extends ContentToken<any> {\n output(): string {\n try {\n return cjs(stringifyMessage(this.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n return JSON.stringify(stringifyMessage(this.value) ?? {}, null, 2)\n }\n }\n}\n\nexport class LinesDiffContentToken extends ContentToken<Change[]> {\n output(): string[] {\n return this.value\n .map((part) => {\n if (part.added) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.green(`+ ${line}\\n`)\n })\n } else if (part.removed) {\n return part.value\n .split(/\\n/)\n .filter((line) => line !== '')\n .map((line) => {\n return colors.magenta(`- ${line}\\n`)\n })\n } else {\n return part.value\n }\n })\n .flat()\n }\n}\n\nexport class ColorContentToken extends ContentToken<OutputMessage> {\n color: (text: string) => string\n\n constructor(value: OutputMessage, color: (text: string) => string) {\n super(value)\n this.color = color\n }\n\n output(): string {\n return this.color(stringifyMessage(this.value))\n }\n}\n\nexport class ErrorContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold.redBright(stringifyMessage(this.value))\n }\n}\n\nexport class PathContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return relativizePath(stringifyMessage(this.value))\n }\n}\n\nexport class HeadingContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.bold.underline(stringifyMessage(this.value))\n }\n}\n\nexport class SubHeadingContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.underline(stringifyMessage(this.value))\n }\n}\n\nexport class ItalicContentToken extends ContentToken<OutputMessage> {\n output(): string {\n return colors.italic(stringifyMessage(this.value))\n }\n}\n"]}
@@ -50,6 +50,15 @@ export function getCIMetadata(envName, envs) {
50
50
  run: envs.CI_RUNNER_ID,
51
51
  url: envs.CI_PIPELINE_URL,
52
52
  };
53
+ case 'buildkite':
54
+ return {
55
+ branch: envs.BUILDKITE_BRANCH,
56
+ build: envs.BUILDKITE_BUILD_NUMBER,
57
+ commitSha: envs.BUILDKITE_COMMIT,
58
+ commitMessage: envs.BUILDKITE_MESSAGE,
59
+ run: envs.BUILDKITE_BUILD_NUMBER,
60
+ url: envs.BUILDKITE_BUILD_URL,
61
+ };
53
62
  default:
54
63
  return {};
55
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/private/node/context/utilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,QAA4B;IAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,IAAuB;IACpE,QAAQ,OAAO,EAAE;QACf,KAAK,WAAW;YACd,OAAO;gBACL,MAAM,EAAE,IAAI,CAAC,gBAAgB;gBAC7B,KAAK,EAAE,IAAI,CAAC,sBAAsB;gBAClC,SAAS,EAAE,IAAI,CAAC,gBAAgB;gBAChC,GAAG,EAAE,IAAI,CAAC,sBAAsB;gBAChC,GAAG,EAAE,yBAAyB,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,mBAAmB,sBAAsB,IAAI,CAAC,sBAAsB,EAAE;aACtI,CAAA;QACH,KAAK,UAAU;YACb,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,eAAe;gBAC3B,MAAM,EAAE,IAAI,CAAC,aAAa;gBAC1B,KAAK,EAAE,IAAI,CAAC,gBAAgB;gBAC5B,SAAS,EAAE,IAAI,CAAC,WAAW;gBAC3B,GAAG,EAAE,IAAI,CAAC,kBAAkB;gBAC5B,GAAG,EAAE,IAAI,CAAC,gBAAgB;aAC3B,CAAA;QACH,KAAK,QAAQ;YACX,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,YAAY;gBACxB,OAAO,EAAE,IAAI,CAAC,kBAAkB;gBAChC,MAAM,EAAE,IAAI,CAAC,eAAe;gBAC5B,KAAK,EAAE,IAAI,CAAC,aAAa;gBACzB,SAAS,EAAE,IAAI,CAAC,UAAU;gBAC1B,GAAG,EAAE,IAAI,CAAC,aAAa;gBACvB,SAAS,EAAE,IAAI,CAAC,iBAAiB;gBACjC,GAAG,EAAE,GAAG,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,iBAAiB,IAAI,CAAC,aAAa,EAAE;aAC9F,CAAA;QACH,KAAK,QAAQ;YACX,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,iBAAiB;gBAC7B,MAAM,EAAE,IAAI,CAAC,kBAAkB;gBAC/B,KAAK,EAAE,IAAI,CAAC,cAAc;gBAC1B,SAAS,EAAE,IAAI,CAAC,aAAa;gBAC7B,aAAa,EAAE,IAAI,CAAC,iBAAiB;gBACrC,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,GAAG,EAAE,IAAI,CAAC,eAAe;aAC1B,CAAA;QACH;YACE,OAAO,EAAE,CAAA;KACZ;AACH,CAAC","sourcesContent":["/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n\n/**\n * Returns an object with environment variables from the specified CI environment.\n */\nexport function getCIMetadata(envName: string, envs: NodeJS.ProcessEnv): Metadata {\n switch (envName) {\n case 'bitbucket':\n return {\n branch: envs.BITBUCKET_BRANCH,\n build: envs.BITBUCKET_BUILD_NUMBER,\n commitSha: envs.BITBUCKET_COMMIT,\n run: envs.BITBUCKET_BUILD_NUMBER,\n url: `https://bitbucket.org/${envs.BITBUCKET_WORKSPACE}/${envs.BITBUCKET_REPO_SLUG}/pipelines/results/${envs.BITBUCKET_BUILD_NUMBER}`,\n }\n case 'circleci':\n return {\n actor: envs.CIRCLE_USERNAME,\n branch: envs.CIRCLE_BRANCH,\n build: envs.CIRCLE_BUILD_NUM,\n commitSha: envs.CIRCLE_SHA1,\n run: envs.CIRCLE_WORKFLOW_ID,\n url: envs.CIRCLE_BUILD_URL,\n }\n case 'github':\n return {\n actor: envs.GITHUB_ACTOR,\n attempt: envs.GITHUB_RUN_ATTEMPT,\n branch: envs.GITHUB_REF_NAME,\n build: envs.GITHUB_RUN_ID,\n commitSha: envs.GITHUB_SHA,\n run: envs.GITHUB_RUN_ID,\n runNumber: envs.GITHUB_RUN_NUMBER,\n url: `${envs.GITHUB_SERVER_URL}/${envs.GITHUB_REPOSITORY}/actions/runs/${envs.GITHUB_RUN_ID}`,\n }\n case 'gitlab':\n return {\n actor: envs.GITLAB_USER_LOGIN,\n branch: envs.CI_COMMIT_REF_NAME,\n build: envs.CI_PIPELINE_ID,\n commitSha: envs.CI_COMMIT_SHA,\n commitMessage: envs.CI_COMMIT_MESSAGE,\n run: envs.CI_RUNNER_ID,\n url: envs.CI_PIPELINE_URL,\n }\n default:\n return {}\n }\n}\n\nexport interface Metadata {\n actor?: string\n attempt?: string\n branch?: string\n build?: string\n commitMessage?: string\n commitSha?: string\n run?: string\n runNumber?: string\n url?: string\n}\n"]}
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/private/node/context/utilities.ts"],"names":[],"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AiB,iBAAiB,IAAI,CAAC,aAAa,EAAE;aAC9F,CAAA;QACH,KAAK,QAAQ;YACX,OAAO;gBACL,KAAK,EAAE,IAAI,CAAC,iBAAiB;gBAC7B,MAAM,EAAE,IAAI,CAAC,kBAAkB;gBAC/B,KAAK,EAAE,IAAI,CAAC,cAAc;gBAC1B,SAAS,EAAE,IAAI,CAAC,aAAa;gBAC7B,aAAa,EAAE,IAAI,CAAC,iBAAiB;gBACrC,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,GAAG,EAAE,IAAI,CAAC,eAAe;aAC1B,CAAA;QACH,KAAK,WAAW;YACd,OAAO;gBACL,MAAM,EAAE,IAAI,CAAC,gBAAgB;gBAC7B,KAAK,EAAE,IAAI,CAAC,sBAAsB;gBAClC,SAAS,EAAE,IAAI,CAAC,gBAAgB;gBAChC,aAAa,EAAE,IAAI,CAAC,iBAAiB;gBACrC,GAAG,EAAE,IAAI,CAAC,sBAAsB;gBAChC,GAAG,EAAE,IAAI,CAAC,mBAAmB;aAC9B,CAAA;QACH;YACE,OAAO,EAAE,CAAA;KACZ;AACH,CAAC","sourcesContent":["/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n\n/**\n * Returns an object with environment variables from the specified CI environment.\n */\nexport function getCIMetadata(envName: string, envs: NodeJS.ProcessEnv): Metadata {\n switch (envName) {\n case 'bitbucket':\n return {\n branch: envs.BITBUCKET_BRANCH,\n build: envs.BITBUCKET_BUILD_NUMBER,\n commitSha: envs.BITBUCKET_COMMIT,\n run: envs.BITBUCKET_BUILD_NUMBER,\n url: `https://bitbucket.org/${envs.BITBUCKET_WORKSPACE}/${envs.BITBUCKET_REPO_SLUG}/pipelines/results/${envs.BITBUCKET_BUILD_NUMBER}`,\n }\n case 'circleci':\n return {\n actor: envs.CIRCLE_USERNAME,\n branch: envs.CIRCLE_BRANCH,\n build: envs.CIRCLE_BUILD_NUM,\n commitSha: envs.CIRCLE_SHA1,\n run: envs.CIRCLE_WORKFLOW_ID,\n url: envs.CIRCLE_BUILD_URL,\n }\n case 'github':\n return {\n actor: envs.GITHUB_ACTOR,\n attempt: envs.GITHUB_RUN_ATTEMPT,\n branch: envs.GITHUB_REF_NAME,\n build: envs.GITHUB_RUN_ID,\n commitSha: envs.GITHUB_SHA,\n run: envs.GITHUB_RUN_ID,\n runNumber: envs.GITHUB_RUN_NUMBER,\n url: `${envs.GITHUB_SERVER_URL}/${envs.GITHUB_REPOSITORY}/actions/runs/${envs.GITHUB_RUN_ID}`,\n }\n case 'gitlab':\n return {\n actor: envs.GITLAB_USER_LOGIN,\n branch: envs.CI_COMMIT_REF_NAME,\n build: envs.CI_PIPELINE_ID,\n commitSha: envs.CI_COMMIT_SHA,\n commitMessage: envs.CI_COMMIT_MESSAGE,\n run: envs.CI_RUNNER_ID,\n url: envs.CI_PIPELINE_URL,\n }\n case 'buildkite':\n return {\n branch: envs.BUILDKITE_BRANCH,\n build: envs.BUILDKITE_BUILD_NUMBER,\n commitSha: envs.BUILDKITE_COMMIT,\n commitMessage: envs.BUILDKITE_MESSAGE,\n run: envs.BUILDKITE_BUILD_NUMBER,\n url: envs.BUILDKITE_BUILD_URL,\n }\n default:\n return {}\n }\n}\n\nexport interface Metadata {\n actor?: string\n attempt?: string\n branch?: string\n build?: string\n commitMessage?: string\n commitSha?: string\n run?: string\n runNumber?: string\n url?: string\n}\n"]}
@@ -9,7 +9,8 @@ export interface ConcurrentOutputProps {
9
9
  keepRunningAfterProcessesResolve?: boolean;
10
10
  }
11
11
  interface ConcurrentOutputContext {
12
- outputPrefix: string;
12
+ outputPrefix?: string;
13
+ stripAnsi?: boolean;
13
14
  }
14
15
  declare function useConcurrentOutputContext<T>(context: ConcurrentOutputContext, callback: () => T): T;
15
16
  /**
@@ -1,8 +1,8 @@
1
1
  import { addOrUpdateConcurrentUIEventOutput } from '../../demo-recorder.js';
2
2
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import { Box, Static, Text, useApp } from 'ink';
4
- import stripAnsi from 'strip-ansi';
5
4
  import figures from 'figures';
5
+ import stripAnsi from 'strip-ansi';
6
6
  import { Writable } from 'stream';
7
7
  import { AsyncLocalStorage } from 'node:async_hooks';
8
8
  function addLeadingZero(number) {
@@ -86,9 +86,10 @@ const ConcurrentOutput = ({ processes, prefixColumnSize, abortSignal, showTimest
86
86
  write(chunk, _encoding, next) {
87
87
  const context = outputContextStore.getStore();
88
88
  const prefix = context?.outputPrefix ?? process.prefix;
89
- const log = chunk.toString('utf8');
89
+ const shouldStripAnsi = context?.stripAnsi ?? true;
90
+ const log = chunk.toString('utf8').replace(/(\n)$/, '');
90
91
  const index = addPrefix(prefix, prefixes);
91
- const lines = stripAnsi(log.replace(/(\n)$/, '')).split(/\n/);
92
+ const lines = shouldStripAnsi ? stripAnsi(log).split(/\n/) : log.split(/\n/);
92
93
  addOrUpdateConcurrentUIEventOutput({ prefix, index, output: lines.join('\n') });
93
94
  setProcessOutput((previousProcessOutput) => [
94
95
  ...previousProcessOutput,
@@ -107,7 +108,7 @@ const ConcurrentOutput = ({ processes, prefixColumnSize, abortSignal, showTimest
107
108
  if (prefix.length > calculatedPrefixColumnSize) {
108
109
  return prefix.substring(0, calculatedPrefixColumnSize);
109
110
  }
110
- return `${prefix}${' '.repeat(calculatedPrefixColumnSize - prefix.length)}`;
111
+ return `${' '.repeat(calculatedPrefixColumnSize - prefix.length)}${prefix}`;
111
112
  };
112
113
  useEffect(() => {
113
114
  const runProcesses = async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,kCAAkC,EAAC,MAAM,wBAAwB,CAAA;AACzE,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AACzF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C,CAChB,oBAAC,IAAI;oBACF,WAAW,EAAE;;oBAAG,YAAY;oBAAE,GAAG,CAC7B,CACR,CAAC,CAAC,CAAC,IAAI;gBACR,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAQ;gBAC7D,oBAAC,IAAI;oBACF,GAAG;oBACH,YAAY;;oBAAG,IAAI,CACf,CACF,CACH,CACP,CAAC,CACE,CACP,CAAA;IACH,CAAC,CACM,CACV,CAAA;AACH,CAAC,CAAA;AACD,OAAO,EAAC,gBAAgB,EAA2B,0BAA0B,EAAC,CAAA","sourcesContent":["import {OutputProcess} from '../../../../public/node/output.js'\nimport {AbortSignal} from '../../../../public/node/abort.js'\nimport {addOrUpdateConcurrentUIEventOutput} from '../../demo-recorder.js'\nimport React, {FunctionComponent, useCallback, useEffect, useMemo, useState} from 'react'\nimport {Box, Static, Text, TextProps, useApp} from 'ink'\nimport stripAnsi from 'strip-ansi'\nimport figures from 'figures'\nimport {Writable} from 'stream'\nimport {AsyncLocalStorage} from 'node:async_hooks'\n\nexport interface ConcurrentOutputProps {\n processes: OutputProcess[]\n prefixColumnSize?: number\n abortSignal: AbortSignal\n showTimestamps?: boolean\n keepRunningAfterProcessesResolve?: boolean\n}\n\ninterface Chunk {\n color: TextProps['color']\n prefix: string\n lines: string[]\n}\n\nfunction addLeadingZero(number: number) {\n if (number < 10) {\n return `0${number}`\n } else {\n return number.toString()\n }\n}\n\nfunction currentTime() {\n const currentDateTime = new Date()\n const hours = addLeadingZero(currentDateTime.getHours())\n const minutes = addLeadingZero(currentDateTime.getMinutes())\n const seconds = addLeadingZero(currentDateTime.getSeconds())\n return `${hours}:${minutes}:${seconds}`\n}\n\ninterface ConcurrentOutputContext {\n outputPrefix: string\n}\n\nconst outputContextStore = new AsyncLocalStorage<ConcurrentOutputContext>()\n\nfunction useConcurrentOutputContext<T>(context: ConcurrentOutputContext, callback: () => T): T {\n return outputContextStore.run(context, callback)\n}\n\n/**\n * Renders output from concurrent processes to the terminal.\n * Output will be divided in a three column layout\n * with the left column containing the timestamp,\n * the right column containing the output,\n * and the middle column containing the process prefix.\n * Every process will be rendered with a different color, up to 4 colors.\n *\n * For example running `shopify app dev`:\n *\n * ```shell\n * 2022-10-10 13:11:03 | backend | npm\n * 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev\n * 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev\n * 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`\n * 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/\n * 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json\n * 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`\n * 2022-10-10 13:11:03 | backend |\n *\n * ```\n */\nconst ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({\n processes,\n prefixColumnSize,\n abortSignal,\n showTimestamps = true,\n keepRunningAfterProcessesResolve = false,\n}) => {\n const [processOutput, setProcessOutput] = useState<Chunk[]>([])\n const {exit: unmountInk} = useApp()\n const concurrentColors: TextProps['color'][] = useMemo(() => ['yellow', 'cyan', 'magenta', 'green', 'blue'], [])\n\n const calculatedPrefixColumnSize = useMemo(() => {\n const maxColumnSize = 25\n\n // If the prefixColumnSize is not provided, we calculate it based on the longest process prefix\n const columnSize =\n prefixColumnSize ??\n processes.reduce((maxPrefixLength, process) => Math.max(maxPrefixLength, process.prefix.length), 0)\n\n // Apply overall limit to the prefix column size\n return Math.min(columnSize, maxColumnSize)\n }, [processes, prefixColumnSize])\n\n const addPrefix = (prefix: string, prefixes: string[]) => {\n const index = prefixes.indexOf(prefix)\n if (index !== -1) {\n return index\n }\n prefixes.push(prefix)\n return prefixes.length - 1\n }\n\n const lineColor = useCallback(\n (index: number) => {\n const colorIndex = index % concurrentColors.length\n return concurrentColors[colorIndex]\n },\n [concurrentColors],\n )\n\n const writableStream = useCallback(\n (process: OutputProcess, prefixes: string[]) => {\n return new Writable({\n write(chunk, _encoding, next) {\n const context = outputContextStore.getStore()\n const prefix = context?.outputPrefix ?? process.prefix\n const log = chunk.toString('utf8')\n\n const index = addPrefix(prefix, prefixes)\n const lines = stripAnsi(log.replace(/(\\n)$/, '')).split(/\\n/)\n addOrUpdateConcurrentUIEventOutput({prefix, index, output: lines.join('\\n')})\n setProcessOutput((previousProcessOutput) => [\n ...previousProcessOutput,\n {\n color: lineColor(index),\n prefix,\n lines,\n },\n ])\n next()\n },\n })\n },\n [lineColor],\n )\n\n const formatPrefix = (prefix: string) => {\n // Truncate prefix if needed\n if (prefix.length > calculatedPrefixColumnSize) {\n return prefix.substring(0, calculatedPrefixColumnSize)\n }\n\n return `${prefix}${' '.repeat(calculatedPrefixColumnSize - prefix.length)}`\n }\n\n useEffect(() => {\n const runProcesses = async () => {\n const prefixes: string[] = []\n\n try {\n await Promise.all(\n processes.map(async (process) => {\n const stdout = writableStream(process, prefixes)\n const stderr = writableStream(process, prefixes)\n await process.action(stdout, stderr, abortSignal)\n }),\n )\n if (!keepRunningAfterProcessesResolve) {\n unmountInk()\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error: unknown) {\n if (!keepRunningAfterProcessesResolve) {\n unmountInk(error as Error | undefined)\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n runProcesses()\n }, [abortSignal, processes, writableStream, unmountInk, keepRunningAfterProcessesResolve])\n\n const {lineVertical} = figures\n\n return (\n <Static items={processOutput}>\n {(chunk, index) => {\n return (\n <Box flexDirection=\"column\" key={index}>\n {chunk.lines.map((line, index) => (\n <Box key={index} flexDirection=\"row\">\n <Text>\n {showTimestamps ? (\n <Text>\n {currentTime()} {lineVertical}{' '}\n </Text>\n ) : null}\n <Text color={chunk.color}>{formatPrefix(chunk.prefix)}</Text>\n <Text>\n {' '}\n {lineVertical} {line}\n </Text>\n </Text>\n </Box>\n ))}\n </Box>\n )\n }}\n </Static>\n )\n}\nexport {ConcurrentOutput, ConcurrentOutputContext, useConcurrentOutputContext}\n"]}
1
+ {"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,kCAAkC,EAAC,MAAM,wBAAwB,CAAA;AACzE,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AACzF,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAa,MAAM,EAAC,MAAM,KAAK,CAAA;AACxD,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAA;AAgBlD,SAAS,cAAc,CAAC,MAAc;IACpC,IAAI,MAAM,GAAG,EAAE,EAAE;QACf,OAAO,IAAI,MAAM,EAAE,CAAA;KACpB;SAAM;QACL,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAA;KACzB;AACH,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,eAAe,GAAG,IAAI,IAAI,EAAE,CAAA;IAClC,MAAM,KAAK,GAAG,cAAc,CAAC,eAAe,CAAC,QAAQ,EA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":["import {OutputProcess} from '../../../../public/node/output.js'\nimport {AbortSignal} from '../../../../public/node/abort.js'\nimport {addOrUpdateConcurrentUIEventOutput} from '../../demo-recorder.js'\nimport React, {FunctionComponent, useCallback, useEffect, useMemo, useState} from 'react'\nimport {Box, Static, Text, TextProps, useApp} from 'ink'\nimport figures from 'figures'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'stream'\nimport {AsyncLocalStorage} from 'node:async_hooks'\n\nexport interface ConcurrentOutputProps {\n processes: OutputProcess[]\n prefixColumnSize?: number\n abortSignal: AbortSignal\n showTimestamps?: boolean\n keepRunningAfterProcessesResolve?: boolean\n}\n\ninterface Chunk {\n color: TextProps['color']\n prefix: string\n lines: string[]\n}\n\nfunction addLeadingZero(number: number) {\n if (number < 10) {\n return `0${number}`\n } else {\n return number.toString()\n }\n}\n\nfunction currentTime() {\n const currentDateTime = new Date()\n const hours = addLeadingZero(currentDateTime.getHours())\n const minutes = addLeadingZero(currentDateTime.getMinutes())\n const seconds = addLeadingZero(currentDateTime.getSeconds())\n return `${hours}:${minutes}:${seconds}`\n}\n\ninterface ConcurrentOutputContext {\n outputPrefix?: string\n stripAnsi?: boolean\n}\n\nconst outputContextStore = new AsyncLocalStorage<ConcurrentOutputContext>()\n\nfunction useConcurrentOutputContext<T>(context: ConcurrentOutputContext, callback: () => T): T {\n return outputContextStore.run(context, callback)\n}\n\n/**\n * Renders output from concurrent processes to the terminal.\n * Output will be divided in a three column layout\n * with the left column containing the timestamp,\n * the right column containing the output,\n * and the middle column containing the process prefix.\n * Every process will be rendered with a different color, up to 4 colors.\n *\n * For example running `shopify app dev`:\n *\n * ```shell\n * 2022-10-10 13:11:03 | backend | npm\n * 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev\n * 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev\n * 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`\n * 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/\n * 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json\n * 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`\n * 2022-10-10 13:11:03 | backend |\n *\n * ```\n */\nconst ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({\n processes,\n prefixColumnSize,\n abortSignal,\n showTimestamps = true,\n keepRunningAfterProcessesResolve = false,\n}) => {\n const [processOutput, setProcessOutput] = useState<Chunk[]>([])\n const {exit: unmountInk} = useApp()\n const concurrentColors: TextProps['color'][] = useMemo(() => ['yellow', 'cyan', 'magenta', 'green', 'blue'], [])\n\n const calculatedPrefixColumnSize = useMemo(() => {\n const maxColumnSize = 25\n\n // If the prefixColumnSize is not provided, we calculate it based on the longest process prefix\n const columnSize =\n prefixColumnSize ??\n processes.reduce((maxPrefixLength, process) => Math.max(maxPrefixLength, process.prefix.length), 0)\n\n // Apply overall limit to the prefix column size\n return Math.min(columnSize, maxColumnSize)\n }, [processes, prefixColumnSize])\n\n const addPrefix = (prefix: string, prefixes: string[]) => {\n const index = prefixes.indexOf(prefix)\n if (index !== -1) {\n return index\n }\n prefixes.push(prefix)\n return prefixes.length - 1\n }\n\n const lineColor = useCallback(\n (index: number) => {\n const colorIndex = index % concurrentColors.length\n return concurrentColors[colorIndex]\n },\n [concurrentColors],\n )\n\n const writableStream = useCallback(\n (process: OutputProcess, prefixes: string[]) => {\n return new Writable({\n write(chunk, _encoding, next) {\n const context = outputContextStore.getStore()\n const prefix = context?.outputPrefix ?? process.prefix\n const shouldStripAnsi = context?.stripAnsi ?? true\n const log = chunk.toString('utf8').replace(/(\\n)$/, '')\n\n const index = addPrefix(prefix, prefixes)\n\n const lines = shouldStripAnsi ? stripAnsi(log).split(/\\n/) : log.split(/\\n/)\n addOrUpdateConcurrentUIEventOutput({prefix, index, output: lines.join('\\n')})\n setProcessOutput((previousProcessOutput) => [\n ...previousProcessOutput,\n {\n color: lineColor(index),\n prefix,\n lines,\n },\n ])\n next()\n },\n })\n },\n [lineColor],\n )\n\n const formatPrefix = (prefix: string) => {\n // Truncate prefix if needed\n if (prefix.length > calculatedPrefixColumnSize) {\n return prefix.substring(0, calculatedPrefixColumnSize)\n }\n\n return `${' '.repeat(calculatedPrefixColumnSize - prefix.length)}${prefix}`\n }\n\n useEffect(() => {\n const runProcesses = async () => {\n const prefixes: string[] = []\n\n try {\n await Promise.all(\n processes.map(async (process) => {\n const stdout = writableStream(process, prefixes)\n const stderr = writableStream(process, prefixes)\n await process.action(stdout, stderr, abortSignal)\n }),\n )\n if (!keepRunningAfterProcessesResolve) {\n unmountInk()\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error: unknown) {\n if (!keepRunningAfterProcessesResolve) {\n unmountInk(error as Error | undefined)\n }\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n runProcesses()\n }, [abortSignal, processes, writableStream, unmountInk, keepRunningAfterProcessesResolve])\n\n const {lineVertical} = figures\n\n return (\n <Static items={processOutput}>\n {(chunk, index) => {\n return (\n <Box flexDirection=\"column\" key={index}>\n {chunk.lines.map((line, index) => (\n <Box key={index} flexDirection=\"row\">\n <Text>\n {showTimestamps ? (\n <Text>\n {currentTime()} {lineVertical}{' '}\n </Text>\n ) : null}\n <Text color={chunk.color}>{formatPrefix(chunk.prefix)}</Text>\n <Text>\n {' '}\n {lineVertical} {line}\n </Text>\n </Text>\n </Box>\n ))}\n </Box>\n )\n }}\n </Static>\n )\n}\nexport {ConcurrentOutput, ConcurrentOutputContext, useConcurrentOutputContext}\n"]}
@@ -44,15 +44,60 @@ describe('ConcurrentOutput', () => {
44
44
  await frontendSync.promise;
45
45
  // Then
46
46
  expect(unstyled(renderInstance.lastFrame().replace(/\d/g, '0'))).toMatchInlineSnapshot(`
47
- "00:00:00 │ backend │ first backend message
48
- 00:00:00 │ backend │ second backend message
49
- 00:00:00 │ backend │ third backend message
47
+ "00:00:00 │ backend │ first backend message
48
+ 00:00:00 │ backend │ second backend message
49
+ 00:00:00 │ backend │ third backend message
50
50
  00:00:00 │ frontend │ first frontend message
51
51
  00:00:00 │ frontend │ second frontend message
52
52
  00:00:00 │ frontend │ third frontend message
53
53
  "
54
54
  `);
55
55
  });
56
+ test('strips ansi codes from the output by default', async () => {
57
+ const output = 'foo';
58
+ // Given
59
+ const processSync = new Synchronizer();
60
+ const processes = [
61
+ {
62
+ prefix: '1',
63
+ action: async (stdout, _stderr, _signal) => {
64
+ stdout.write(`\u001b[32m${output}\u001b[39m`);
65
+ processSync.resolve();
66
+ },
67
+ },
68
+ ];
69
+ // When
70
+ const renderInstance = render(React.createElement(ConcurrentOutput, { processes: processes, abortSignal: new AbortController().signal }));
71
+ await processSync.promise;
72
+ // Then
73
+ const logColumns = renderInstance.lastFrame().split('│');
74
+ expect(logColumns?.length).toBe(3);
75
+ expect(logColumns[2]?.trim()).toEqual(output);
76
+ });
77
+ test('does not strip ansi codes from the output when stripAnsi is false', async () => {
78
+ const output = '\u001b[32mfoo\u001b[39m';
79
+ // Given
80
+ const processSync = new Synchronizer();
81
+ const processes = [
82
+ {
83
+ prefix: '1',
84
+ action: async (stdout, _stderr, _signal) => {
85
+ // eslint-disable-next-line react-hooks/rules-of-hooks
86
+ useConcurrentOutputContext({ stripAnsi: false }, () => {
87
+ stdout.write(output);
88
+ });
89
+ processSync.resolve();
90
+ },
91
+ },
92
+ ];
93
+ // When
94
+ const renderInstance = render(React.createElement(ConcurrentOutput, { processes: processes, abortSignal: new AbortController().signal }));
95
+ await processSync.promise;
96
+ // Then
97
+ const logColumns = renderInstance.lastFrame().split('│');
98
+ expect(logColumns?.length).toBe(3);
99
+ expect(logColumns[2]?.trim()).toEqual(output);
100
+ });
56
101
  test('renders custom prefixes on log lines', async () => {
57
102
  // Given
58
103
  const processSync = new Synchronizer();
@@ -1 +1 @@
1
- {"version":3,"file":"ConcurrentOutput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,0BAA0B,EAAC,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAC,eAAe,EAAc,MAAM,kCAAkC,CAAA;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAG7C;;GAEG;AACH,MAAM,YAAY;IAIhB;QACE,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;YACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QAC3E,QAAQ;QACR,MAAM,WAAW,GAAG,IAAI,YAAY,EAAE,CAAA;QACtC,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA;QAEvC,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK,EAAE,MA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,EAAE,CAAC,cAAc,CAAC,EAC3B,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM,GACzC,CACH,CAAA;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QAExD,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {ConcurrentOutput, useConcurrentOutputContext} from './ConcurrentOutput.js'\nimport {render} from '../../testing/ui.js'\nimport {AbortController, AbortSignal} from '../../../../public/node/abort.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test} from 'vitest'\nimport {Writable} from 'stream'\n\n/**\n * ConcurrentOutput tests are unreliable unless we await a promise that resolves after the process has written to stdout.\n */\nclass Synchronizer {\n resolve: () => void\n promise: Promise<void>\n\n constructor() {\n this.resolve = () => {}\n this.promise = new Promise<void>((resolve, _reject) => {\n this.resolve = resolve\n })\n }\n}\n\ndescribe('ConcurrentOutput', () => {\n test('renders a stream of concurrent outputs from sub-processes', async () => {\n // Given\n const backendSync = new Synchronizer()\n const frontendSync = new Synchronizer()\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendSync.resolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendSync.promise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n\n frontendSync.resolve()\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess, frontendProcess]} abortSignal={new AbortController().signal} />,\n )\n\n await frontendSync.promise\n\n // Then\n expect(unstyled(renderInstance.lastFrame()!.replace(/\\d/g, '0'))).toMatchInlineSnapshot(`\n \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n 00:00:00 │ frontend │ first frontend message\n 00:00:00 │ frontend │ second frontend message\n 00:00:00 │ frontend │ third frontend message\n \"\n `)\n })\n\n test('renders custom prefixes on log lines', async () => {\n // Given\n const processSync = new Synchronizer()\n const extensionName = 'my-extension'\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useConcurrentOutputContext({outputPrefix: extensionName}, () => {\n stdout.write('foo bar')\n })\n processSync.resolve()\n },\n },\n ]\n\n // When\n const renderInstance = render(\n <ConcurrentOutput\n processes={processes}\n // Ensure it's not truncated\n prefixColumnSize={extensionName.length}\n abortSignal={new AbortController().signal}\n />,\n )\n\n await processSync.promise\n\n // Then\n const logColumns = unstyled(renderInstance.lastFrame()!).split('│')\n expect(logColumns?.length).toBe(3)\n expect(logColumns[1]?.trim()).toEqual(extensionName)\n })\n\n test('renders prefix column width based on prefixColumnSize', async () => {\n // Given\n const processSync1 = new Synchronizer()\n const processSync2 = new Synchronizer()\n\n const columnSize = 5\n const processes = [\n {\n prefix: '1234567890',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('foo')\n processSync1.resolve()\n },\n },\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('bar')\n processSync2.resolve()\n },\n },\n ]\n\n // When\n const renderInstance = render(\n <ConcurrentOutput\n processes={processes}\n prefixColumnSize={columnSize}\n abortSignal={new AbortController().signal}\n />,\n )\n await Promise.all([processSync1.promise, processSync2.promise])\n\n // Then\n const logLines = unstyled(renderInstance.lastFrame()!).split('\\n').filter(Boolean)\n expect(logLines?.length).toBe(2)\n logLines.forEach((line) => {\n const logColumns = line.split('│')\n expect(logColumns?.length).toBe(3)\n // Including spacing\n expect(logColumns[1]?.length).toBe(columnSize + 2)\n })\n })\n\n test('renders prefix column width based on processes by default', async () => {\n // Given\n const processSync = new Synchronizer()\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('foo')\n processSync.resolve()\n },\n },\n {prefix: '12', action: async () => {}},\n {prefix: '123', action: async () => {}},\n {prefix: '1234', action: async () => {}},\n ]\n\n // When\n const renderInstance = render(<ConcurrentOutput processes={processes} abortSignal={new AbortController().signal} />)\n await processSync.promise\n\n // Then\n const logColumns = unstyled(renderInstance.lastFrame()!).split('│')\n expect(logColumns?.length).toBe(3)\n // 4 is largest prefix, plus spacing\n expect(logColumns[1]?.length).toBe(4 + 2)\n })\n\n test('does not render prefix column larger than max', async () => {\n // Given\n const processSync = new Synchronizer()\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('foo')\n processSync.resolve()\n },\n },\n {prefix: new Array(26).join('0'), action: async () => {}},\n ]\n\n // When\n const renderInstance = render(<ConcurrentOutput processes={processes} abortSignal={new AbortController().signal} />)\n await processSync.promise\n\n // Then\n const logColumns = unstyled(renderInstance.lastFrame()!).split('│')\n expect(logColumns?.length).toBe(3)\n // 25 is largest column allowed, plus spacing\n expect(logColumns[1]?.length).toBe(25 + 2)\n })\n\n test('rejects with the error thrown inside one of the processes', async () => {\n // Given\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n throw new Error('something went wrong')\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess]} abortSignal={new AbortController().signal} />,\n )\n\n const renderPromise = renderInstance.waitUntilExit()\n\n await expect(renderPromise).rejects.toThrowError('something went wrong')\n expect(renderPromise.isRejected()).toBe(true)\n })\n\n test(\"doesn't reject when an error is thrown inside one of the processes and keepRunningAfterProcessesResolve is true\", async () => {\n // Given\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n throw new Error('something went wrong')\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess]}\n abortSignal={new AbortController().signal}\n keepRunningAfterProcessesResolve\n />,\n )\n\n await new Promise((resolve) => setTimeout(resolve, 500))\n expect(renderInstance.waitUntilExit().isRejected()).toBe(false)\n })\n\n test('render promise resolves when all processes resolve by default', async () => {\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n },\n }\n\n // When\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess]} abortSignal={new AbortController().signal} />,\n )\n\n const renderPromise = renderInstance.waitUntilExit()\n\n await renderPromise\n expect(renderPromise.isFulfilled()).toBe(true)\n })\n\n test(\"render promise doesn't resolve when all processes resolve and keepRunningAfterProcessesResolve is true\", async () => {\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n },\n }\n\n // When\n const renderInstance = render(\n <ConcurrentOutput\n keepRunningAfterProcessesResolve\n processes={[backendProcess]}\n abortSignal={new AbortController().signal}\n />,\n )\n\n await new Promise((resolve) => setTimeout(resolve, 500))\n\n expect(renderInstance.waitUntilExit().isFulfilled()).toBe(false)\n })\n})\n"]}
1
+ {"version":3,"file":"ConcurrentOutput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,0BAA0B,EAAC,MAAM,uBAAuB,CAAA;AA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KAAK,CAAC,uBAAuB,CAAC,CAAA;gBACrC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;gBACtC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;YACvC,CAAC;SACF,CAAA;QAED,OAAO;QACP,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,gBAAgB,IACf,gCAAgC,QAChC,SAAS,EAAE,CAAC,cAAc,CAAC,EAC3B,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM,GACzC,CACH,CAAA;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QAExD,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {ConcurrentOutput, useConcurrentOutputContext} from './ConcurrentOutput.js'\nimport {render} from '../../testing/ui.js'\nimport {AbortController, AbortSignal} from '../../../../public/node/abort.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test} from 'vitest'\nimport {Writable} from 'stream'\n\n/**\n * ConcurrentOutput tests are unreliable unless we await a promise that resolves after the process has written to stdout.\n */\nclass Synchronizer {\n resolve: () => void\n promise: Promise<void>\n\n constructor() {\n this.resolve = () => {}\n this.promise = new Promise<void>((resolve, _reject) => {\n this.resolve = resolve\n })\n }\n}\n\ndescribe('ConcurrentOutput', () => {\n test('renders a stream of concurrent outputs from sub-processes', async () => {\n // Given\n const backendSync = new Synchronizer()\n const frontendSync = new Synchronizer()\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendSync.resolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendSync.promise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n\n frontendSync.resolve()\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess, frontendProcess]} abortSignal={new AbortController().signal} />,\n )\n\n await frontendSync.promise\n\n // Then\n expect(unstyled(renderInstance.lastFrame()!.replace(/\\d/g, '0'))).toMatchInlineSnapshot(`\n \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n 00:00:00 │ frontend │ first frontend message\n 00:00:00 │ frontend │ second frontend message\n 00:00:00 │ frontend │ third frontend message\n \"\n `)\n })\n\n test('strips ansi codes from the output by default', async () => {\n const output = 'foo'\n\n // Given\n const processSync = new Synchronizer()\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write(`\\u001b[32m${output}\\u001b[39m`)\n processSync.resolve()\n },\n },\n ]\n\n // When\n const renderInstance = render(<ConcurrentOutput processes={processes} abortSignal={new AbortController().signal} />)\n await processSync.promise\n\n // Then\n const logColumns = renderInstance.lastFrame()!.split('│')\n expect(logColumns?.length).toBe(3)\n expect(logColumns[2]?.trim()).toEqual(output)\n })\n\n test('does not strip ansi codes from the output when stripAnsi is false', async () => {\n const output = '\\u001b[32mfoo\\u001b[39m'\n\n // Given\n const processSync = new Synchronizer()\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useConcurrentOutputContext({stripAnsi: false}, () => {\n stdout.write(output)\n })\n processSync.resolve()\n },\n },\n ]\n\n // When\n const renderInstance = render(<ConcurrentOutput processes={processes} abortSignal={new AbortController().signal} />)\n await processSync.promise\n\n // Then\n const logColumns = renderInstance.lastFrame()!.split('│')\n expect(logColumns?.length).toBe(3)\n expect(logColumns[2]?.trim()).toEqual(output)\n })\n\n test('renders custom prefixes on log lines', async () => {\n // Given\n const processSync = new Synchronizer()\n const extensionName = 'my-extension'\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useConcurrentOutputContext({outputPrefix: extensionName}, () => {\n stdout.write('foo bar')\n })\n processSync.resolve()\n },\n },\n ]\n\n // When\n const renderInstance = render(\n <ConcurrentOutput\n processes={processes}\n // Ensure it's not truncated\n prefixColumnSize={extensionName.length}\n abortSignal={new AbortController().signal}\n />,\n )\n\n await processSync.promise\n\n // Then\n const logColumns = unstyled(renderInstance.lastFrame()!).split('│')\n expect(logColumns?.length).toBe(3)\n expect(logColumns[1]?.trim()).toEqual(extensionName)\n })\n\n test('renders prefix column width based on prefixColumnSize', async () => {\n // Given\n const processSync1 = new Synchronizer()\n const processSync2 = new Synchronizer()\n\n const columnSize = 5\n const processes = [\n {\n prefix: '1234567890',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('foo')\n processSync1.resolve()\n },\n },\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('bar')\n processSync2.resolve()\n },\n },\n ]\n\n // When\n const renderInstance = render(\n <ConcurrentOutput\n processes={processes}\n prefixColumnSize={columnSize}\n abortSignal={new AbortController().signal}\n />,\n )\n await Promise.all([processSync1.promise, processSync2.promise])\n\n // Then\n const logLines = unstyled(renderInstance.lastFrame()!).split('\\n').filter(Boolean)\n expect(logLines?.length).toBe(2)\n logLines.forEach((line) => {\n const logColumns = line.split('│')\n expect(logColumns?.length).toBe(3)\n // Including spacing\n expect(logColumns[1]?.length).toBe(columnSize + 2)\n })\n })\n\n test('renders prefix column width based on processes by default', async () => {\n // Given\n const processSync = new Synchronizer()\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('foo')\n processSync.resolve()\n },\n },\n {prefix: '12', action: async () => {}},\n {prefix: '123', action: async () => {}},\n {prefix: '1234', action: async () => {}},\n ]\n\n // When\n const renderInstance = render(<ConcurrentOutput processes={processes} abortSignal={new AbortController().signal} />)\n await processSync.promise\n\n // Then\n const logColumns = unstyled(renderInstance.lastFrame()!).split('│')\n expect(logColumns?.length).toBe(3)\n // 4 is largest prefix, plus spacing\n expect(logColumns[1]?.length).toBe(4 + 2)\n })\n\n test('does not render prefix column larger than max', async () => {\n // Given\n const processSync = new Synchronizer()\n const processes = [\n {\n prefix: '1',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('foo')\n processSync.resolve()\n },\n },\n {prefix: new Array(26).join('0'), action: async () => {}},\n ]\n\n // When\n const renderInstance = render(<ConcurrentOutput processes={processes} abortSignal={new AbortController().signal} />)\n await processSync.promise\n\n // Then\n const logColumns = unstyled(renderInstance.lastFrame()!).split('│')\n expect(logColumns?.length).toBe(3)\n // 25 is largest column allowed, plus spacing\n expect(logColumns[1]?.length).toBe(25 + 2)\n })\n\n test('rejects with the error thrown inside one of the processes', async () => {\n // Given\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n throw new Error('something went wrong')\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess]} abortSignal={new AbortController().signal} />,\n )\n\n const renderPromise = renderInstance.waitUntilExit()\n\n await expect(renderPromise).rejects.toThrowError('something went wrong')\n expect(renderPromise.isRejected()).toBe(true)\n })\n\n test(\"doesn't reject when an error is thrown inside one of the processes and keepRunningAfterProcessesResolve is true\", async () => {\n // Given\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n throw new Error('something went wrong')\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess]}\n abortSignal={new AbortController().signal}\n keepRunningAfterProcessesResolve\n />,\n )\n\n await new Promise((resolve) => setTimeout(resolve, 500))\n expect(renderInstance.waitUntilExit().isRejected()).toBe(false)\n })\n\n test('render promise resolves when all processes resolve by default', async () => {\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n },\n }\n\n // When\n const renderInstance = render(\n <ConcurrentOutput processes={[backendProcess]} abortSignal={new AbortController().signal} />,\n )\n\n const renderPromise = renderInstance.waitUntilExit()\n\n await renderPromise\n expect(renderPromise.isFulfilled()).toBe(true)\n })\n\n test(\"render promise doesn't resolve when all processes resolve and keepRunningAfterProcessesResolve is true\", async () => {\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n },\n }\n\n // When\n const renderInstance = render(\n <ConcurrentOutput\n keepRunningAfterProcessesResolve\n processes={[backendProcess]}\n abortSignal={new AbortController().signal}\n />,\n )\n\n await new Promise((resolve) => setTimeout(resolve, 500))\n\n expect(renderInstance.waitUntilExit().isFulfilled()).toBe(false)\n })\n})\n"]}
@@ -11,6 +11,5 @@
11
11
  * @param value - The value to compare.
12
12
  * @param other - The other value to compare.
13
13
  * @returns Returns `true` if the values are equivalent, else `false`.
14
- * @example
15
14
  */
16
15
  export declare function isEqual(value: unknown, other: unknown): boolean;
@@ -12,7 +12,6 @@ import lodashIsEqual from 'lodash/isEqual.js';
12
12
  * @param value - The value to compare.
13
13
  * @param other - The other value to compare.
14
14
  * @returns Returns `true` if the values are equivalent, else `false`.
15
- * @example
16
15
  */
17
16
  export function isEqual(value, other) {
18
17
  return lodashIsEqual(value, other);
@@ -1 +1 @@
1
- {"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/public/common/lang.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,KAAc;IACpD,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import lodashIsEqual from 'lodash/isEqual.js'\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are **not** supported.\n *\n * @param value - The value to compare.\n * @param other - The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n * @example\n */\nexport function isEqual(value: unknown, other: unknown): boolean {\n return lodashIsEqual(value, other)\n}\n"]}
1
+ {"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/public/common/lang.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,KAAc;IACpD,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import lodashIsEqual from 'lodash/isEqual.js'\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are **not** supported.\n *\n * @param value - The value to compare.\n * @param other - The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n */\nexport function isEqual(value: unknown, other: unknown): boolean {\n return lodashIsEqual(value, other)\n}\n"]}
@@ -10,5 +10,6 @@
10
10
  * @param performAction - The action to perform.
11
11
  * @param recoveryProcedure - The recovery procedure to perform if the action
12
12
  * fails the first time.
13
+ * @returns The result of the action.
13
14
  */
14
15
  export declare function performActionWithRetryAfterRecovery<T>(performAction: () => Promise<T>, recoveryProcedure: () => Promise<unknown>): Promise<T>;
@@ -10,6 +10,7 @@
10
10
  * @param performAction - The action to perform.
11
11
  * @param recoveryProcedure - The recovery procedure to perform if the action
12
12
  * fails the first time.
13
+ * @returns The result of the action.
13
14
  */
14
15
  export async function performActionWithRetryAfterRecovery(performAction, recoveryProcedure) {
15
16
  let returnVal;
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/public/common/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,aAA+B,EAC/B,iBAAyC;IAEzC,IAAI,SAAwB,CAAA;IAC5B,IAAI;QACF,SAAS,GAAG,MAAM,aAAa,EAAE,CAAA;QACjC,OAAO,SAAS,CAAA;QAChB,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,6DAA6D;QAC7D,MAAM,iBAAiB,EAAE,CAAA;QACzB,OAAO,aAAa,EAAE,CAAA;KACvB;AACH,CAAC","sourcesContent":["/**\n * Perform an action optimistically. If it fails the first time, first initiate\n * a provided recovery procedure, then retry the action. If it fails again,\n * throw the error.\n *\n * This is useful for actions that may fail due to recoverable errors, such as\n * an expired token that can be refreshed. In this case, the recovery procedure\n * would refresh the token.\n *\n * @param performAction - The action to perform.\n * @param recoveryProcedure - The recovery procedure to perform if the action\n * fails the first time.\n */\nexport async function performActionWithRetryAfterRecovery<T>(\n performAction: () => Promise<T>,\n recoveryProcedure: () => Promise<unknown>,\n): Promise<T> {\n let returnVal: T | undefined\n try {\n returnVal = await performAction()\n return returnVal\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n // Run the provided recovery procedure, then retry the action\n await recoveryProcedure()\n return performAction()\n }\n}\n"]}
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/public/common/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,aAA+B,EAC/B,iBAAyC;IAEzC,IAAI,SAAwB,CAAA;IAC5B,IAAI;QACF,SAAS,GAAG,MAAM,aAAa,EAAE,CAAA;QACjC,OAAO,SAAS,CAAA;QAChB,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,6DAA6D;QAC7D,MAAM,iBAAiB,EAAE,CAAA;QACzB,OAAO,aAAa,EAAE,CAAA;KACvB;AACH,CAAC","sourcesContent":["/**\n * Perform an action optimistically. If it fails the first time, first initiate\n * a provided recovery procedure, then retry the action. If it fails again,\n * throw the error.\n *\n * This is useful for actions that may fail due to recoverable errors, such as\n * an expired token that can be refreshed. In this case, the recovery procedure\n * would refresh the token.\n *\n * @param performAction - The action to perform.\n * @param recoveryProcedure - The recovery procedure to perform if the action\n * fails the first time.\n * @returns The result of the action.\n */\nexport async function performActionWithRetryAfterRecovery<T>(\n performAction: () => Promise<T>,\n recoveryProcedure: () => Promise<unknown>,\n): Promise<T> {\n let returnVal: T | undefined\n try {\n returnVal = await performAction()\n return returnVal\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n // Run the provided recovery procedure, then retry the action\n await recoveryProcedure()\n return performAction()\n }\n}\n"]}
@@ -5,7 +5,7 @@
5
5
  * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>
6
6
  * T = {optionalKey: string, nullableValue: string, undefinableValue: string}
7
7
  * ```
8
- *.
8
+ *
9
9
  */
10
10
  export type DeepRequired<T> = {
11
11
  [TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>;
@@ -1 +1 @@
1
- {"version":3,"file":"deep-required.js","sourceRoot":"","sources":["../../../../src/public/common/ts/deep-required.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Converts a mapping type to be non-optional.\n *\n * ```ts\n * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>\n * T = {optionalKey: string, nullableValue: string, undefinableValue: string}\n * ```\n *.\n */\nexport type DeepRequired<T> = {\n [TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>\n}\n"]}
1
+ {"version":3,"file":"deep-required.js","sourceRoot":"","sources":["../../../../src/public/common/ts/deep-required.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Converts a mapping type to be non-optional.\n *\n * ```ts\n * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>\n * T = {optionalKey: string, nullableValue: string, undefinableValue: string}\n * ```\n *\n */\nexport type DeepRequired<T> = {\n [TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>\n}\n"]}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * T = {foo_1: number, foo_2: number, included: string, also: number}
8
8
  * ```
9
- * .
9
+ *
10
10
  */
11
11
  export type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {
12
12
  [TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey];
@@ -1 +1 @@
1
- {"version":3,"file":"pick-by-prefix.js","sourceRoot":"","sources":["../../../../src/public/common/ts/pick-by-prefix.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches.\n *\n * ```ts\n * type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>.\n *\n * T = {foo_1: number, foo_2: number, included: string, also: number}\n * ```\n * .\n */\nexport type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {\n [TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey]\n}\n"]}
1
+ {"version":3,"file":"pick-by-prefix.js","sourceRoot":"","sources":["../../../../src/public/common/ts/pick-by-prefix.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches.\n *\n * ```ts\n * type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>.\n *\n * T = {foo_1: number, foo_2: number, included: string, also: number}\n * ```\n *\n */\nexport type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {\n [TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey]\n}\n"]}
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.61.2";
1
+ export declare const CLI_KIT_VERSION = "3.63.0";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.61.2';
1
+ export const CLI_KIT_VERSION = '3.63.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.61.2'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.63.0'\n"]}
@@ -1,4 +1,6 @@
1
1
  import { GraphQLVariables } from './graphql.js';
2
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import { Variables } from 'graphql-request';
2
4
  /**
3
5
  * Executes a GraphQL query against the Business Platform Destinations API.
4
6
  *
@@ -8,3 +10,12 @@ import { GraphQLVariables } from './graphql.js';
8
10
  * @returns The response of the query of generic type <T>.
9
11
  */
10
12
  export declare function businessPlatformRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T>;
13
+ /**
14
+ * Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
15
+ *
16
+ * @param query - GraphQL query to execute.
17
+ * @param token - Business Platform token.
18
+ * @param variables - GraphQL variables to pass to the query.
19
+ * @returns The response of the query of generic type <TResult>.
20
+ */
21
+ export declare function businessPlatformRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables): Promise<TResult>;