@shopify/cli-kit 3.68.1 → 3.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 (162) hide show
  1. package/dist/cli/api/graphql/admin/generated/public_api_versions.d.ts +14 -0
  2. package/dist/cli/api/graphql/admin/generated/public_api_versions.js +28 -0
  3. package/dist/cli/api/graphql/admin/generated/public_api_versions.js.map +1 -0
  4. package/dist/private/node/api/graphql.d.ts +1 -1
  5. package/dist/private/node/api/graphql.js +1 -0
  6. package/dist/private/node/api/graphql.js.map +1 -1
  7. package/dist/private/node/api/headers.js +2 -2
  8. package/dist/private/node/api/headers.js.map +1 -1
  9. package/dist/private/node/api/rest.js +3 -1
  10. package/dist/private/node/api/rest.js.map +1 -1
  11. package/dist/private/node/api.d.ts +2 -2
  12. package/dist/private/node/api.js +8 -6
  13. package/dist/private/node/api.js.map +1 -1
  14. package/dist/private/node/constants.d.ts +0 -1
  15. package/dist/private/node/constants.js +0 -1
  16. package/dist/private/node/constants.js.map +1 -1
  17. package/dist/private/node/demo-recorder.js +1 -0
  18. package/dist/private/node/demo-recorder.js.map +1 -1
  19. package/dist/private/node/session/device-authorization.js +15 -7
  20. package/dist/private/node/session/device-authorization.js.map +1 -1
  21. package/dist/private/node/session/exchange.d.ts +0 -8
  22. package/dist/private/node/session/exchange.js +2 -19
  23. package/dist/private/node/session/exchange.js.map +1 -1
  24. package/dist/private/node/session/validate.js +1 -0
  25. package/dist/private/node/session/validate.js.map +1 -1
  26. package/dist/private/node/session.d.ts +5 -5
  27. package/dist/private/node/session.js +4 -12
  28. package/dist/private/node/session.js.map +1 -1
  29. package/dist/private/node/testing/ui.js +0 -3
  30. package/dist/private/node/testing/ui.js.map +1 -1
  31. package/dist/private/node/themes/generate-theme-name.js +1 -0
  32. package/dist/private/node/themes/generate-theme-name.js.map +1 -1
  33. package/dist/private/node/ui/components/AutocompletePrompt.test.js +0 -3
  34. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  35. package/dist/private/node/ui/components/Banner.js +1 -0
  36. package/dist/private/node/ui/components/Banner.js.map +1 -1
  37. package/dist/private/node/ui/components/ConcurrentOutput.test.js +7 -7
  38. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  39. package/dist/private/node/ui/components/FatalError.js +1 -0
  40. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  41. package/dist/private/node/ui/components/List.js +1 -1
  42. package/dist/private/node/ui/components/List.js.map +1 -1
  43. package/dist/private/node/ui/components/Prompts/InfoTable.js +1 -0
  44. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
  45. package/dist/private/node/ui/components/SelectInput.js +1 -1
  46. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  47. package/dist/private/node/ui/components/SelectPrompt.test.js +0 -4
  48. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  49. package/dist/private/node/ui/components/Table/Row.js.map +1 -1
  50. package/dist/private/node/ui/components/Tasks.js +2 -1
  51. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  52. package/dist/private/node/ui/components/TextPrompt.d.ts +1 -1
  53. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  54. package/dist/private/node/ui/components/TokenizedText.js +1 -0
  55. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  56. package/dist/private/node/ui/hooks/use-abort-signal.js +1 -1
  57. package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -1
  58. package/dist/private/node/ui.js +3 -1
  59. package/dist/private/node/ui.js.map +1 -1
  60. package/dist/public/common/array.js +1 -0
  61. package/dist/public/common/array.js.map +1 -1
  62. package/dist/public/common/string.js +3 -0
  63. package/dist/public/common/string.js.map +1 -1
  64. package/dist/public/common/version.d.ts +1 -1
  65. package/dist/public/common/version.js +1 -1
  66. package/dist/public/common/version.js.map +1 -1
  67. package/dist/public/node/api/admin.d.ts +14 -1
  68. package/dist/public/node/api/admin.js +40 -31
  69. package/dist/public/node/api/admin.js.map +1 -1
  70. package/dist/public/node/api/app-management.d.ts +5 -3
  71. package/dist/public/node/api/app-management.js +16 -11
  72. package/dist/public/node/api/app-management.js.map +1 -1
  73. package/dist/public/node/api/graphql.js +13 -1
  74. package/dist/public/node/api/graphql.js.map +1 -1
  75. package/dist/public/node/api/rest-api-throttler.js +10 -3
  76. package/dist/public/node/api/rest-api-throttler.js.map +1 -1
  77. package/dist/public/node/archiver.js +6 -2
  78. package/dist/public/node/archiver.js.map +1 -1
  79. package/dist/public/node/base-command.js +1 -1
  80. package/dist/public/node/base-command.js.map +1 -1
  81. package/dist/public/node/context/local.d.ts +0 -9
  82. package/dist/public/node/context/local.js +0 -13
  83. package/dist/public/node/context/local.js.map +1 -1
  84. package/dist/public/node/context/spin.js +1 -1
  85. package/dist/public/node/context/spin.js.map +1 -1
  86. package/dist/public/node/custom-oclif-loader.js +5 -4
  87. package/dist/public/node/custom-oclif-loader.js.map +1 -1
  88. package/dist/public/node/dot-env.js +2 -1
  89. package/dist/public/node/dot-env.js.map +1 -1
  90. package/dist/public/node/environments.js +1 -1
  91. package/dist/public/node/environments.js.map +1 -1
  92. package/dist/public/node/error-handler.js +3 -3
  93. package/dist/public/node/error-handler.js.map +1 -1
  94. package/dist/public/node/error.d.ts +3 -3
  95. package/dist/public/node/error.js +29 -3
  96. package/dist/public/node/error.js.map +1 -1
  97. package/dist/public/node/framework.js +5 -4
  98. package/dist/public/node/framework.js.map +1 -1
  99. package/dist/public/node/fs.d.ts +1 -1
  100. package/dist/public/node/fs.js +1 -1
  101. package/dist/public/node/fs.js.map +1 -1
  102. package/dist/public/node/git.js +2 -0
  103. package/dist/public/node/git.js.map +1 -1
  104. package/dist/public/node/github.js +2 -0
  105. package/dist/public/node/github.js.map +1 -1
  106. package/dist/public/node/hooks/deprecations.js +1 -1
  107. package/dist/public/node/hooks/deprecations.js.map +1 -1
  108. package/dist/public/node/hooks/postrun.js +2 -1
  109. package/dist/public/node/hooks/postrun.js.map +1 -1
  110. package/dist/public/node/hooks/prerun.js +1 -1
  111. package/dist/public/node/hooks/prerun.js.map +1 -1
  112. package/dist/public/node/http.js +2 -1
  113. package/dist/public/node/http.js.map +1 -1
  114. package/dist/public/node/json-schema.d.ts +1 -1
  115. package/dist/public/node/json-schema.js.map +1 -1
  116. package/dist/public/node/liquid.js +12 -2
  117. package/dist/public/node/liquid.js.map +1 -1
  118. package/dist/public/node/metadata.js +1 -0
  119. package/dist/public/node/metadata.js.map +1 -1
  120. package/dist/public/node/monorail.d.ts +2 -1
  121. package/dist/public/node/monorail.js +1 -1
  122. package/dist/public/node/monorail.js.map +1 -1
  123. package/dist/public/node/output.js +2 -1
  124. package/dist/public/node/output.js.map +1 -1
  125. package/dist/public/node/ruby.js +1 -0
  126. package/dist/public/node/ruby.js.map +1 -1
  127. package/dist/public/node/session.d.ts +7 -6
  128. package/dist/public/node/session.js +2 -1
  129. package/dist/public/node/session.js.map +1 -1
  130. package/dist/public/node/system.js +1 -1
  131. package/dist/public/node/system.js.map +1 -1
  132. package/dist/public/node/themes/api.js +34 -4
  133. package/dist/public/node/themes/api.js.map +1 -1
  134. package/dist/public/node/themes/factories.js +1 -0
  135. package/dist/public/node/themes/factories.js.map +1 -1
  136. package/dist/public/node/themes/types.d.ts +2 -3
  137. package/dist/public/node/themes/types.js.map +1 -1
  138. package/dist/public/node/themes/urls.d.ts +1 -0
  139. package/dist/public/node/themes/urls.js +3 -0
  140. package/dist/public/node/themes/urls.js.map +1 -1
  141. package/dist/public/node/tree-kill.js +8 -4
  142. package/dist/public/node/tree-kill.js.map +1 -1
  143. package/dist/public/node/ui.js +5 -2
  144. package/dist/public/node/ui.js.map +1 -1
  145. package/dist/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +1 -5
  147. package/assets/auth-error.html +0 -23
  148. package/assets/empty-url.html +0 -23
  149. package/assets/favicon.svg +0 -26
  150. package/assets/missing-code.html +0 -23
  151. package/assets/missing-state.html +0 -23
  152. package/assets/style.css +0 -58
  153. package/assets/success.html +0 -20
  154. package/dist/private/node/session/authorize.d.ts +0 -5
  155. package/dist/private/node/session/authorize.js +0 -69
  156. package/dist/private/node/session/authorize.js.map +0 -1
  157. package/dist/private/node/session/post-auth.d.ts +0 -10
  158. package/dist/private/node/session/post-auth.js +0 -61
  159. package/dist/private/node/session/post-auth.js.map +0 -1
  160. package/dist/private/node/session/redirect-listener.d.ts +0 -34
  161. package/dist/private/node/session/redirect-listener.js +0 -105
  162. package/dist/private/node/session/redirect-listener.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AACjD,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,aAAa,CAAA;AAQ3C,MAAe,WAAY,SAAQ,OAAO;IAIxC,gEAAgE;IACzD,MAAM,CAAC,0BAA0B;QACtC,8DAA8D;QAC9D,OAAO,CAAE,IAAY,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,6BAA6B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IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;iBACxB;qBAAM;oBACL,MAAM,IAAI,UAAU,CAClB,aAAa,CAAA,0EAA0E,WAAW,CAAC,MAAM,CACvG,KAAK,CACN,YAAY,CACd,CAAA;iBACF;aACF;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadEnvironment} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {renderInfo, renderWarning} from './ui.js'\nimport {outputContent, outputInfo, outputToken} from './output.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Errors} from '@oclif/core'\nimport {FlagOutput, Input, ParserOutput, FlagInput, ArgOutput} from '@oclif/core/lib/interfaces/parser.js'\n\ninterface EnvironmentFlags {\n environment?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n // eslint-disable-next-line @typescript-eslint/ban-types\n static baseFlags: FlagInput<{}> = {}\n\n // Replace markdown links to plain text like: \"link label\" (url)\n public static descriptionWithoutMarkdown(): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ((this as any).descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n this.showNpmFlagWarning()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputInfo(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n if (terminalSupportsPrompting()) return\n\n requiredFlags.forEach((name: string) => {\n if (!(name in flags)) {\n throw new AbortError(\n outputContent`Flag not specified:\n\n${outputToken.cyan(name)}\n\nThis flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n })\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no environment is specified, don't modify the results\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n if (!flags.environment || !environmentsFileName) return originalResult\n\n // If the specified environment isn't found, don't modify the results\n const environment = await loadEnvironment(flags.environment, environmentsFileName, {from: flags.path})\n if (!environment) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv || this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n flags.environment,\n environment,\n )\n\n return result\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
1
+ {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB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AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadEnvironment} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {renderInfo, renderWarning} from './ui.js'\nimport {outputContent, outputInfo, outputToken} from './output.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Errors} from '@oclif/core'\nimport {FlagOutput, Input, ParserOutput, FlagInput, ArgOutput} from '@oclif/core/lib/interfaces/parser.js'\n\ninterface EnvironmentFlags {\n environment?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n // eslint-disable-next-line @typescript-eslint/ban-types\n static baseFlags: FlagInput<{}> = {}\n\n // Replace markdown links to plain text like: \"link label\" (url)\n public static descriptionWithoutMarkdown(): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ((this as any).descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n this.showNpmFlagWarning()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputInfo(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n if (terminalSupportsPrompting()) return\n\n requiredFlags.forEach((name: string) => {\n if (!(name in flags)) {\n throw new AbortError(\n outputContent`Flag not specified:\n\n${outputToken.cyan(name)}\n\nThis flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n })\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no environment is specified, don't modify the results\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n if (!flags.environment || !environmentsFileName) return originalResult\n\n // If the specified environment isn't found, don't modify the results\n const environment = await loadEnvironment(flags.environment, environmentsFileName, {from: flags.path})\n if (!environment) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv || this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n flags.environment,\n environment,\n )\n\n return result\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
@@ -71,15 +71,6 @@ export declare function alwaysLogMetrics(env?: NodeJS.ProcessEnv): boolean;
71
71
  * @returns True if SHOPIFY_CLI_1P is truthy.
72
72
  */
73
73
  export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
74
- /**
75
- * Returns true if the CLI should use device auth.
76
- *
77
- * Device auth can be opted out by using SHOPIFY_CLI_ACCESS_CODE_AUTH.
78
- *
79
- * @param env - The environment variables from the environment of the current process.
80
- * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.
81
- */
82
- export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
83
74
  /**
84
75
  * Returns true if the CLI should use theme bundling.
85
76
  *
@@ -102,19 +102,6 @@ export function alwaysLogMetrics(env = process.env) {
102
102
  export function firstPartyDev(env = process.env) {
103
103
  return isTruthy(env[environmentVariables.firstPartyDev]);
104
104
  }
105
- /**
106
- * Returns true if the CLI should use device auth.
107
- *
108
- * Device auth can be opted out by using SHOPIFY_CLI_ACCESS_CODE_AUTH.
109
- *
110
- * @param env - The environment variables from the environment of the current process.
111
- * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.
112
- */
113
- export function useDeviceAuth(env = process.env) {
114
- return (!isTruthy(env[environmentVariables.accessCodeAuth]) ||
115
- isTruthy(env[environmentVariables.deviceAuth]) ||
116
- isCloudEnvironment(env));
117
- }
118
105
  /**
119
106
  * Returns true if the CLI should use theme bundling.
120
107
  *
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACtF,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAA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GAKG;AACH,MAAM,UAAU,UAAU,CACxB,GAAG,GAAG,OAAO,CAAC,GAAG;IAEjB,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE;YACrC,IAAI,GAAG,WAAW,CAAA;SACnB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACjC,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/B,IAAI,GAAG,WAAW,CAAA;SACnB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;YACJ,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE;QAC5C,OAAO,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KACzC;IACD,OAAO,iDAAiD,CAAA;AAC1D,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use device auth.\n *\n * Device auth can be opted out by using SHOPIFY_CLI_ACCESS_CODE_AUTH.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.\n */\nexport function useDeviceAuth(env = process.env): boolean {\n return (\n !isTruthy(env[environmentVariables.accessCodeAuth]) ||\n isTruthy(env[environmentVariables.deviceAuth]) ||\n isCloudEnvironment(env)\n )\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.noThemeBundling])\n}\n\n/**\n * Returns true if the embedded CLI will be used for theme commands.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_BUNDLED_THEME_CLI is truthy.\n */\nexport function useEmbeddedThemeCLI(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.bundledThemeCLI])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string | undefined {\n if (isSet(env[environmentVariables.otelURL])) {\n return env[environmentVariables.otelURL]\n }\n return 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACtF,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC1F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC/C,IAAI,MAAM,CAAC,SAAS,CAAC,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G,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC/B,IAAI,GAAG,WAAW,CAAA;SACnB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;YACJ,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE;QAC5C,OAAO,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KACzC;IACD,OAAO,iDAAiD,CAAA;AAC1D,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.noThemeBundling])\n}\n\n/**\n * Returns true if the embedded CLI will be used for theme commands.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_BUNDLED_THEME_CLI is truthy.\n */\nexport function useEmbeddedThemeCLI(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.bundledThemeCLI])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string | undefined {\n if (isSet(env[environmentVariables.otelURL])) {\n return env[environmentVariables.otelURL]\n }\n return 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
@@ -143,7 +143,7 @@ export async function fetchSpinPort(service, portEnvName, basePath = '/run') {
143
143
  continue;
144
144
  }
145
145
  const match = config.contentPattern.exec(fileContent);
146
- if (match && match[1] && !isNaN(parseInt(match[1], 10))) {
146
+ if (match?.[1] && !isNaN(parseInt(match[1], 10))) {
147
147
  return parseInt(match[1], 10);
148
148
  }
149
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"spin.js","sourceRoot":"","sources":["../../../../src/public/node/context/spin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,cAAc,CAAA;AACvD,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,6CAA6C,CAAA;AAChG,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA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ED,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {fileExists, readFile, readFileSync} from '../fs.js'\nimport {environmentVariables} from '../../../private/node/constants.js'\nimport {captureOutput} from '../system.js'\nimport {outputContent, outputToken} from '../output.js'\nimport {getCachedSpinFqdn, setCachedSpinFqdn} from '../../../private/node/context/spin-cache.js'\nimport {AbortError} from '../error.js'\nimport {Environment, serviceEnvironment} from '../../../private/node/context/service.js'\nimport {joinPath} from '../path.js'\n\nconst SpinInstanceNotFoundMessages = (spinInstance: string | undefined, error: string) => {\n const errorMessage = outputContent`${outputToken.genericShellCommand(\n `spin`,\n )} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:\n${error}\n `\n let nextSteps: string | undefined\n if (spinInstance) {\n nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`\n }\n return {errorMessage, nextSteps}\n}\n\nconst spinFqdnFilePath = '/etc/spin/machine/fqdn'\n\n/**\n * When ran in a Spin environment, it returns the fqdn of the instance.\n *\n * Will cache the value of the Spin FQDN during the execution of the CLI.\n * To avoid multiple calls to `readSync` or `show`.\n *\n * @param env - Environment variables.\n * @returns Fqdn of the Spin environment.\n */\nexport async function spinFqdn(env = process.env): Promise<string> {\n let spinFqdn = getCachedSpinFqdn()\n if (spinFqdn) return spinFqdn\n\n if (await fileExists(spinFqdnFilePath)) {\n spinFqdn = await readFileSync(spinFqdnFilePath).toString()\n } else {\n const spinInstance = await instance(env)\n const showResponse = await show(spinInstance, env)\n\n spinFqdn = showResponse.fqdn\n }\n setCachedSpinFqdn(spinFqdn)\n return spinFqdn\n}\n\n/**\n * Runs \"spin show\" and returns the JSON-parsed output.\n *\n * @param spinInstance - When it's undefined, we'll fetch the latest one.\n * @param env - Environment variables.\n * @returns The JSON-parsed output of the Spin CLI.\n * @throws Any error raised from the underlying Spin CLI.\n */\nexport async function show(spinInstance: string | undefined, env = process.env): Promise<{fqdn: string}> {\n const latest = spinInstance === undefined\n const args = latest ? ['show', '--latest', '--json'] : ['show', '--json']\n const output = await captureOutput('spin', args, {env})\n const json = JSON.parse(output)\n if (json.error) {\n const {errorMessage, nextSteps} = SpinInstanceNotFoundMessages(spinInstance, json.error)\n throw new AbortError(errorMessage, nextSteps)\n } else {\n return json\n }\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n *\n * @param env - Environment variables.\n * @returns True if the CLI is running in a Spin environment.\n */\nexport function isSpin(env = process.env): boolean {\n return isTruthy(env[environmentVariables.spin])\n}\n\n/**\n * Returns the value of the SPIN_INSTANCE environment variable.\n *\n * @param env - Environment variables.\n * @returns The value of the SPIN_INSTANCE environment variable.\n */\nexport function instance(env = process.env): string | undefined {\n return env[environmentVariables.spinInstance]\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n *\n * @param env - Environment variables.\n * @returns True if the CLI is running in a Spin environment.\n */\nexport function isSpinEnvironment(env = process.env): boolean {\n return serviceEnvironment(env) === Environment.Spin\n}\n\n/**\n * Returns the value of the SERVER_PORT environment variable.\n *\n * @param env - Environment variables.\n * @returns The value of the SERVER_PORT environment variable.\n */\nexport function appPort(env = process.env): number | undefined {\n const port = Number(env[environmentVariables.spinAppPort])\n return (!isNaN(port) && port) || undefined\n}\n\n/**\n * Returns the value of the SPIN_APP_HOST environment variable.\n *\n * @param env - Environment variables.\n * @returns The value of the SPIN_APP_HOST environment variable.\n */\nexport function appHost(env = process.env): string | undefined {\n return env[environmentVariables.spinAppHost]\n}\n\nexport const spinVariables = {\n partnersSpinService: 'shopify--partners',\n manualCliSpinPortName: 'CLI_EXTENSION_SERVER',\n}\n/**\n * Fetches the port for a given spin service and port environment variable.\n *\n * @param service - The name of the spin service to fetch the port for.\n * @param portEnvName - The name of the environment variable to fetch the port from.\n * @param basePath - The base path to look for the port file.\n * @returns The port number or undefined if the port could not be found.\n */\nexport async function fetchSpinPort(\n service: string,\n portEnvName: string,\n basePath = '/run',\n): Promise<number | undefined> {\n const spinVersionConfigurations = [\n {\n path: joinPath(basePath, 'ports2', service, 'custom', portEnvName),\n contentPattern: /\\[{\"internal\":(\\d+)}\\]/,\n },\n {\n path: joinPath(basePath, 'ports', service, 'proc', portEnvName),\n contentPattern: /(\\d+)/,\n },\n ]\n for (const config of spinVersionConfigurations) {\n let fileContent: string\n\n try {\n // eslint-disable-next-line no-await-in-loop\n fileContent = await readFile(config.path)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n continue\n }\n\n const match = config.contentPattern.exec(fileContent)\n if (match && match[1] && !isNaN(parseInt(match[1], 10))) {\n return parseInt(match[1], 10)\n }\n }\n\n return undefined\n}\n"]}
1
+ {"version":3,"file":"spin.js","sourceRoot":"","sources":["../../../../src/public/node/context/spin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,UAAU,CAAA;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,cAAc,CAAA;AACvD,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,6CAA6C,CAAA;AAChG,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AACxF,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAEnC,MAAM,4BAA4B,GAAG,CAAC,YAAgC,EAAE,KAAa,EAAE,EAAE;IACvF,MAAM,YAAY,GAAG,aAAa,CAAA,GAAG,WAAW,CAAC,mBAAmB,CAClE,MAAM,CACP;EACD,KAAK;GACJ,CAAA;IACD,IAAI,SAA6B,CAAA;IACjC,IAAI,YAAY,EAAE;QAChB,SAAS,GAAG,aAAa,YAAY,6DAA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EACf,WAAmB,EACnB,QAAQ,GAAG,MAAM;IAEjB,MAAM,yBAAyB,GAAG;QAChC;YACE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC;YAClE,cAAc,EAAE,wBAAwB;SACzC;QACD;YACE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC;YAC/D,cAAc,EAAE,OAAO;SACxB;KACF,CAAA;IACD,KAAK,MAAM,MAAM,IAAI,yBAAyB,EAAE;QAC9C,IAAI,WAAmB,CAAA;QAEvB,IAAI;YACF,4CAA4C;YAC5C,WAAW,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACzC,qDAAqD;SACtD;QAAC,OAAO,KAAK,EAAE;YACd,SAAQ;SACT;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACrD,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;YAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;SAC9B;KACF;IAED,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {fileExists, readFile, readFileSync} from '../fs.js'\nimport {environmentVariables} from '../../../private/node/constants.js'\nimport {captureOutput} from '../system.js'\nimport {outputContent, outputToken} from '../output.js'\nimport {getCachedSpinFqdn, setCachedSpinFqdn} from '../../../private/node/context/spin-cache.js'\nimport {AbortError} from '../error.js'\nimport {Environment, serviceEnvironment} from '../../../private/node/context/service.js'\nimport {joinPath} from '../path.js'\n\nconst SpinInstanceNotFoundMessages = (spinInstance: string | undefined, error: string) => {\n const errorMessage = outputContent`${outputToken.genericShellCommand(\n `spin`,\n )} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:\n${error}\n `\n let nextSteps: string | undefined\n if (spinInstance) {\n nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`\n }\n return {errorMessage, nextSteps}\n}\n\nconst spinFqdnFilePath = '/etc/spin/machine/fqdn'\n\n/**\n * When ran in a Spin environment, it returns the fqdn of the instance.\n *\n * Will cache the value of the Spin FQDN during the execution of the CLI.\n * To avoid multiple calls to `readSync` or `show`.\n *\n * @param env - Environment variables.\n * @returns Fqdn of the Spin environment.\n */\nexport async function spinFqdn(env = process.env): Promise<string> {\n let spinFqdn = getCachedSpinFqdn()\n if (spinFqdn) return spinFqdn\n\n if (await fileExists(spinFqdnFilePath)) {\n spinFqdn = await readFileSync(spinFqdnFilePath).toString()\n } else {\n const spinInstance = await instance(env)\n const showResponse = await show(spinInstance, env)\n\n spinFqdn = showResponse.fqdn\n }\n setCachedSpinFqdn(spinFqdn)\n return spinFqdn\n}\n\n/**\n * Runs \"spin show\" and returns the JSON-parsed output.\n *\n * @param spinInstance - When it's undefined, we'll fetch the latest one.\n * @param env - Environment variables.\n * @returns The JSON-parsed output of the Spin CLI.\n * @throws Any error raised from the underlying Spin CLI.\n */\nexport async function show(spinInstance: string | undefined, env = process.env): Promise<{fqdn: string}> {\n const latest = spinInstance === undefined\n const args = latest ? ['show', '--latest', '--json'] : ['show', '--json']\n const output = await captureOutput('spin', args, {env})\n const json = JSON.parse(output)\n if (json.error) {\n const {errorMessage, nextSteps} = SpinInstanceNotFoundMessages(spinInstance, json.error)\n throw new AbortError(errorMessage, nextSteps)\n } else {\n return json\n }\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n *\n * @param env - Environment variables.\n * @returns True if the CLI is running in a Spin environment.\n */\nexport function isSpin(env = process.env): boolean {\n return isTruthy(env[environmentVariables.spin])\n}\n\n/**\n * Returns the value of the SPIN_INSTANCE environment variable.\n *\n * @param env - Environment variables.\n * @returns The value of the SPIN_INSTANCE environment variable.\n */\nexport function instance(env = process.env): string | undefined {\n return env[environmentVariables.spinInstance]\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n *\n * @param env - Environment variables.\n * @returns True if the CLI is running in a Spin environment.\n */\nexport function isSpinEnvironment(env = process.env): boolean {\n return serviceEnvironment(env) === Environment.Spin\n}\n\n/**\n * Returns the value of the SERVER_PORT environment variable.\n *\n * @param env - Environment variables.\n * @returns The value of the SERVER_PORT environment variable.\n */\nexport function appPort(env = process.env): number | undefined {\n const port = Number(env[environmentVariables.spinAppPort])\n return (!isNaN(port) && port) || undefined\n}\n\n/**\n * Returns the value of the SPIN_APP_HOST environment variable.\n *\n * @param env - Environment variables.\n * @returns The value of the SPIN_APP_HOST environment variable.\n */\nexport function appHost(env = process.env): string | undefined {\n return env[environmentVariables.spinAppHost]\n}\n\nexport const spinVariables = {\n partnersSpinService: 'shopify--partners',\n manualCliSpinPortName: 'CLI_EXTENSION_SERVER',\n}\n/**\n * Fetches the port for a given spin service and port environment variable.\n *\n * @param service - The name of the spin service to fetch the port for.\n * @param portEnvName - The name of the environment variable to fetch the port from.\n * @param basePath - The base path to look for the port file.\n * @returns The port number or undefined if the port could not be found.\n */\nexport async function fetchSpinPort(\n service: string,\n portEnvName: string,\n basePath = '/run',\n): Promise<number | undefined> {\n const spinVersionConfigurations = [\n {\n path: joinPath(basePath, 'ports2', service, 'custom', portEnvName),\n contentPattern: /\\[{\"internal\":(\\d+)}\\]/,\n },\n {\n path: joinPath(basePath, 'ports', service, 'proc', portEnvName),\n contentPattern: /(\\d+)/,\n },\n ]\n for (const config of spinVersionConfigurations) {\n let fileContent: string\n\n try {\n // eslint-disable-next-line no-await-in-loop\n fileContent = await readFile(config.path)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n continue\n }\n\n const match = config.contentPattern.exec(fileContent)\n if (match?.[1] && !isNaN(parseInt(match[1], 10))) {\n return parseInt(match[1], 10)\n }\n }\n\n return undefined\n}\n"]}
@@ -12,7 +12,7 @@ export class ShopifyConfig extends Config {
12
12
  if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) {
13
13
  path = execaSync('npm', ['prefix']).stdout.trim();
14
14
  }
15
- if (fileExistsSync(joinPath(`${path}`, 'package.json'))) {
15
+ if (fileExistsSync(joinPath(path, 'package.json'))) {
16
16
  // Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons:
17
17
  // 1. To allow users to use an older version of Hydrogen. (to not force upgrades)
18
18
  // 2. To allow the Hydrogen team to load a local version for testing.
@@ -22,11 +22,12 @@ export class ShopifyConfig extends Config {
22
22
  };
23
23
  }
24
24
  super(options);
25
- // eslint-disable-next-line dot-notation
26
- this['determinePriority'] = this.customPriority;
25
+ // @ts-expect-error: This is a private method that we are overriding. OCLIF doesn't provide a way to extend it.
26
+ // eslint-disable-next-line @typescript-eslint/unbound-method
27
+ this.determinePriority = this.customPriority;
27
28
  }
28
29
  customPriority(commands) {
29
- const oclifPlugins = this.pjson.oclif?.plugins ?? [];
30
+ const oclifPlugins = this.pjson.oclif.plugins ?? [];
30
31
  const commandPlugins = commands.sort((aCommand, bCommand) => {
31
32
  // eslint-disable-next-line no-restricted-syntax
32
33
  const pluginAliasA = aCommand.pluginAlias ?? 'A-Cannot-Find-This';
@@ -1 +1 @@
1
- {"version":3,"file":"custom-oclif-loader.js","sourceRoot":"","sources":["../../../src/public/node/custom-oclif-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AACtC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAU,MAAM,EAAC,MAAM,aAAa,CAAA;AAG3C,MAAM,OAAO,aAAc,SAAQ,MAAM;IACvC,YAAY,OAAgB;QAC1B,MAAM,WAAW,GAAG,GAAG,EAAE,CAA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AAQ,CAAC,UAAU,KAAK,MAAM,IAAI,QAAQ,CAAC,WAAW,KAAK,uBAAuB,EAAE;gBACtF,8CAA8C;gBAC9C,OAAO,CAAC,CAAA;aACT;YAED,IAAI,QAAQ,CAAC,WAAW,KAAK,uBAAuB,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,EAAE;gBACtF,8CAA8C;gBAC9C,OAAO,CAAC,CAAC,CAAA;aACV;YAED,6FAA6F;YAC7F,gEAAgE;YAChE,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,EAAE;gBACpE,wDAAwD;gBACxD,OAAO,MAAM,GAAG,MAAM,CAAA;aACvB;YAED,kDAAkD;YAClD,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,EAAE;gBACpE,OAAO,CAAC,CAAA;aACT;YAED,kDAAkD;YAClD,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,EAAE;gBACpE,OAAO,CAAC,CAAC,CAAA;aACV;YAED,iDAAiD;YACjD,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,EAAE;gBAClE,OAAO,CAAC,CAAA;aACT;YAED,iDAAiD;YACjD,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,EAAE;gBAClE,OAAO,CAAC,CAAC,CAAA;aACV;YAED,qDAAqD;YACrD,OAAO,CAAC,CAAA;QACV,CAAC,CAAC,CAAA;QACF,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF","sourcesContent":["import {fileExistsSync} from './fs.js'\nimport {cwd, joinPath, sniffForPath} from './path.js'\nimport {execaSync} from 'execa'\nimport {Command, Config} from '@oclif/core'\nimport {Options} from '@oclif/core/lib/interfaces/plugin.js'\n\nexport class ShopifyConfig extends Config {\n constructor(options: Options) {\n const currentPath = cwd()\n\n let path = sniffForPath() ?? currentPath\n // Hydrogen CI uses `hydrogen/hydrogen` path, while local dev uses `shopify/hydrogen`.\n const currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\\/hydrogen/i.test(currentPath)\n const ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO\n if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) {\n path = execaSync('npm', ['prefix']).stdout.trim()\n }\n if (fileExistsSync(joinPath(`${path}`, 'package.json'))) {\n // Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons:\n // 1. To allow users to use an older version of Hydrogen. (to not force upgrades)\n // 2. To allow the Hydrogen team to load a local version for testing.\n options.pluginAdditions = {\n core: ['@shopify/cli-hydrogen'],\n path,\n }\n }\n super(options)\n\n // eslint-disable-next-line dot-notation\n this['determinePriority'] = this.customPriority\n }\n\n customPriority(commands: Command.Loadable[]): Command.Loadable | undefined {\n const oclifPlugins = this.pjson.oclif?.plugins ?? []\n const commandPlugins = commands.sort((aCommand, bCommand) => {\n // eslint-disable-next-line no-restricted-syntax\n const pluginAliasA = aCommand.pluginAlias ?? 'A-Cannot-Find-This'\n // eslint-disable-next-line no-restricted-syntax\n const pluginAliasB = bCommand.pluginAlias ?? 'B-Cannot-Find-This'\n const aIndex = oclifPlugins.indexOf(pluginAliasA)\n const bIndex = oclifPlugins.indexOf(pluginAliasB)\n\n // If there is an external cli-hydrogen plugin, its commands should take priority over bundled ('core') commands\n if (aCommand.pluginType === 'core' && bCommand.pluginAlias === '@shopify/cli-hydrogen') {\n // If b is hydrogen and a is core sort b first\n return 1\n }\n\n if (aCommand.pluginAlias === '@shopify/cli-hydrogen' && bCommand.pluginType === 'core') {\n // If a is hydrogen and b is core sort a first\n return -1\n }\n\n // All other cases are the default implementation from the private `determinePriority` method\n // When both plugin types are 'core' plugins sort based on index\n if (aCommand.pluginType === 'core' && bCommand.pluginType === 'core') {\n // If b appears first in the pjson.plugins sort it first\n return aIndex - bIndex\n }\n\n // if b is a core plugin and a is not sort b first\n if (bCommand.pluginType === 'core' && aCommand.pluginType !== 'core') {\n return 1\n }\n\n // if a is a core plugin and b is not sort a first\n if (aCommand.pluginType === 'core' && bCommand.pluginType !== 'core') {\n return -1\n }\n\n // if a is a jit plugin and b is not sort b first\n if (aCommand.pluginType === 'jit' && bCommand.pluginType !== 'jit') {\n return 1\n }\n\n // if b is a jit plugin and a is not sort a first\n if (bCommand.pluginType === 'jit' && aCommand.pluginType !== 'jit') {\n return -1\n }\n\n // neither plugin is core, so do not change the order\n return 0\n })\n return commandPlugins[0]\n }\n}\n"]}
1
+ {"version":3,"file":"custom-oclif-loader.js","sourceRoot":"","sources":["../../../src/public/node/custom-oclif-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,SAAS,CAAA;AACtC,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,WAAW,CAAA;AACrD,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAU,MAAM,EAAC,MAAM,aAAa,CAAA;AAG3C,MAAM,OAAO,aAAc,SAAQ,MAAM;IACvC,YAAY,OAAgB;QAC1B,MAAM,WAAW,GAAG,GAAG,EAAE,CAAA;QAEzB,IAAI,IAAI,GAAG,YAAY,EAAE,IAAI,WAAW,CAAA;QACxC,sFAAsF;QACtF,MAAM,kCAAkC,GAAG,+BAA+B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC5F,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAA;QACnE,IAAI,kCAAkC,IAAI,CAAC,sBAAsB,EAAE;YACjE,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;SAClD;QACD,IAAI,cAAc,CAAC,QAAQ,C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ACxD,OAAO,MAAM,GAAG,MAAM,CAAA;aACvB;YAED,kDAAkD;YAClD,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,EAAE;gBACpE,OAAO,CAAC,CAAA;aACT;YAED,kDAAkD;YAClD,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,IAAI,QAAQ,CAAC,UAAU,KAAK,MAAM,EAAE;gBACpE,OAAO,CAAC,CAAC,CAAA;aACV;YAED,iDAAiD;YACjD,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,EAAE;gBAClE,OAAO,CAAC,CAAA;aACT;YAED,iDAAiD;YACjD,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,EAAE;gBAClE,OAAO,CAAC,CAAC,CAAA;aACV;YAED,qDAAqD;YACrD,OAAO,CAAC,CAAA;QACV,CAAC,CAAC,CAAA;QACF,OAAO,cAAc,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;CACF","sourcesContent":["import {fileExistsSync} from './fs.js'\nimport {cwd, joinPath, sniffForPath} from './path.js'\nimport {execaSync} from 'execa'\nimport {Command, Config} from '@oclif/core'\nimport {Options} from '@oclif/core/lib/interfaces/plugin.js'\n\nexport class ShopifyConfig extends Config {\n constructor(options: Options) {\n const currentPath = cwd()\n\n let path = sniffForPath() ?? currentPath\n // Hydrogen CI uses `hydrogen/hydrogen` path, while local dev uses `shopify/hydrogen`.\n const currentPathMightBeHydrogenMonorepo = /(shopify|hydrogen)\\/hydrogen/i.test(currentPath)\n const ignoreHydrogenMonorepo = process.env.IGNORE_HYDROGEN_MONOREPO\n if (currentPathMightBeHydrogenMonorepo && !ignoreHydrogenMonorepo) {\n path = execaSync('npm', ['prefix']).stdout.trim()\n }\n if (fileExistsSync(joinPath(path, 'package.json'))) {\n // Hydrogen is bundled, but we still want to support loading it as an external plugin for two reasons:\n // 1. To allow users to use an older version of Hydrogen. (to not force upgrades)\n // 2. To allow the Hydrogen team to load a local version for testing.\n options.pluginAdditions = {\n core: ['@shopify/cli-hydrogen'],\n path,\n }\n }\n super(options)\n\n // @ts-expect-error: This is a private method that we are overriding. OCLIF doesn't provide a way to extend it.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.determinePriority = this.customPriority\n }\n\n customPriority(commands: Command.Loadable[]): Command.Loadable | undefined {\n const oclifPlugins = this.pjson.oclif.plugins ?? []\n const commandPlugins = commands.sort((aCommand, bCommand) => {\n // eslint-disable-next-line no-restricted-syntax\n const pluginAliasA = aCommand.pluginAlias ?? 'A-Cannot-Find-This'\n // eslint-disable-next-line no-restricted-syntax\n const pluginAliasB = bCommand.pluginAlias ?? 'B-Cannot-Find-This'\n const aIndex = oclifPlugins.indexOf(pluginAliasA)\n const bIndex = oclifPlugins.indexOf(pluginAliasB)\n\n // If there is an external cli-hydrogen plugin, its commands should take priority over bundled ('core') commands\n if (aCommand.pluginType === 'core' && bCommand.pluginAlias === '@shopify/cli-hydrogen') {\n // If b is hydrogen and a is core sort b first\n return 1\n }\n\n if (aCommand.pluginAlias === '@shopify/cli-hydrogen' && bCommand.pluginType === 'core') {\n // If a is hydrogen and b is core sort a first\n return -1\n }\n\n // All other cases are the default implementation from the private `determinePriority` method\n // When both plugin types are 'core' plugins sort based on index\n if (aCommand.pluginType === 'core' && bCommand.pluginType === 'core') {\n // If b appears first in the pjson.plugins sort it first\n return aIndex - bIndex\n }\n\n // if b is a core plugin and a is not sort b first\n if (bCommand.pluginType === 'core' && aCommand.pluginType !== 'core') {\n return 1\n }\n\n // if a is a core plugin and b is not sort a first\n if (aCommand.pluginType === 'core' && bCommand.pluginType !== 'core') {\n return -1\n }\n\n // if a is a jit plugin and b is not sort b first\n if (aCommand.pluginType === 'jit' && bCommand.pluginType !== 'jit') {\n return 1\n }\n\n // if b is a jit plugin and a is not sort a first\n if (bCommand.pluginType === 'jit' && aCommand.pluginType !== 'jit') {\n return -1\n }\n\n // neither plugin is core, so do not change the order\n return 0\n })\n return commandPlugins[0]\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
1
2
  import { AbortError } from './error.js';
2
3
  import { fileExists, readFile, writeFile } from './fs.js';
3
4
  import { outputDebug, outputContent, outputToken } from '../../public/node/output.js';
@@ -91,7 +92,7 @@ export function createDotEnvFileLine(key, value, quote) {
91
92
  if (quote) {
92
93
  return `${key}=${quote}${value}${quote}`;
93
94
  }
94
- if (value && value.includes('\n')) {
95
+ if (value?.includes('\n')) {
95
96
  const quoteCharacter = ['"', "'", '`'].find((char) => !value.includes(char));
96
97
  if (!quoteCharacter) {
97
98
  throw new AbortError(`The environment file patch has an env value that can't be surrounded by quotes: ${value}`);
@@ -1 +1 @@
1
- {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AACvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAC,KAAK,EAAC,MAAM,QAAQ,CAAA;AAgB5B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,WAAW,CAAC,aAAa,CAAA,4BAA4B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9E,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,MAAM,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;KACxE;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO;QACL,IAAI;QACJ,S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CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SAC/D;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,KAAc,EAAE,KAAc;IAC9E,IAAI,KAAK,EAAE;QACT,OAAO,GAAG,GAAG,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE,CAAA;KACzC;IACD,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACjC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAE5E,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,UAAU,CAAC,mFAAmF,KAAK,EAAE,CAAC,CAAA;SACjH;QAED,OAAO,GAAG,GAAG,IAAI,cAAc,GAAG,KAAK,GAAG,cAAc,EAAE,CAAA;KAC3D;IACD,OAAO,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {fileExists, readFile, writeFile} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport {parse} from 'dotenv'\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n outputDebug(outputContent`Reading the .env file at ${outputToken.path(path)}`)\n if (!(await fileExists(path))) {\n throw new AbortError(`The environment file at ${path} does not exist.`)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile): Promise<void> {\n const fileContent = Object.entries(file.variables)\n .map(([key, value]) => createDotEnvFileLine(key, value))\n .join('\\n')\n\n await writeFile(file.path, fileContent)\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const envFileLines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n let multilineVariable:\n | {\n key: string\n value: string\n quote: string\n }\n | undefined\n\n for (const line of envFileLines) {\n if (multilineVariable) {\n if (line.endsWith(multilineVariable.quote)) {\n let lineToWrite = createDotEnvFileLine(\n multilineVariable.key,\n multilineVariable.value + line.slice(0, -1),\n multilineVariable.quote,\n )\n const newValue = updatedValues[multilineVariable.key]\n if (newValue) {\n alreadyPresentKeys.push(multilineVariable.key)\n lineToWrite = createDotEnvFileLine(multilineVariable.key, newValue)\n }\n outputLines.push(lineToWrite)\n multilineVariable = undefined\n } else {\n multilineVariable.value += `${line}\\n`\n }\n continue\n }\n\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const value = (match[2] || '').trim()\n\n if (/^[\"'`]/.test(value) && !value.endsWith(value[0]!)) {\n multilineVariable = {\n key,\n value: `${value.slice(1)}\\n`,\n quote: value[0]!,\n }\n continue\n }\n\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = createDotEnvFileLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n if (multilineVariable) {\n throw new AbortError(`Multi-line environment variable '${multilineVariable.key}' is not properly enclosed.`)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(createDotEnvFileLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n\nexport function createDotEnvFileLine(key: string, value?: string, quote?: string): string {\n if (quote) {\n return `${key}=${quote}${value}${quote}`\n }\n if (value && value.includes('\\n')) {\n const quoteCharacter = ['\"', \"'\", '`'].find((char) => !value.includes(char))\n\n if (!quoteCharacter) {\n throw new AbortError(`The environment file patch has an env value that can't be surrounded by quotes: ${value}`)\n }\n\n return `${key}=${quoteCharacter}${value}${quoteCharacter}`\n }\n return `${key}=${value}`\n}\n"]}
1
+ {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AACvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAC,KAAK,EAAC,MAAM,QAAQ,CAAA;AAgB5B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,WAAW,CAAC,aAAa,CAAA,4BAA4B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9E,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,MAAM,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;KACxE;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ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CAAC,GAAG,6BAA6B,CAAC,CAAA;KAC7G;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SAC/D;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,KAAc,EAAE,KAAc;IAC9E,IAAI,KAAK,EAAE;QACT,OAAO,GAAG,GAAG,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE,CAAA;KACzC;IACD,IAAI,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAE5E,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,UAAU,CAAC,mFAAmF,KAAK,EAAE,CAAC,CAAA;SACjH;QAED,OAAO,GAAG,GAAG,IAAI,cAAc,GAAG,KAAK,GAAG,cAAc,EAAE,CAAA;KAC3D;IACD,OAAO,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport {AbortError} from './error.js'\nimport {fileExists, readFile, writeFile} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport {parse} from 'dotenv'\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n outputDebug(outputContent`Reading the .env file at ${outputToken.path(path)}`)\n if (!(await fileExists(path))) {\n throw new AbortError(`The environment file at ${path} does not exist.`)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile): Promise<void> {\n const fileContent = Object.entries(file.variables)\n .map(([key, value]) => createDotEnvFileLine(key, value))\n .join('\\n')\n\n await writeFile(file.path, fileContent)\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const envFileLines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n let multilineVariable:\n | {\n key: string\n value: string\n quote: string\n }\n | undefined\n\n for (const line of envFileLines) {\n if (multilineVariable) {\n if (line.endsWith(multilineVariable.quote)) {\n let lineToWrite = createDotEnvFileLine(\n multilineVariable.key,\n multilineVariable.value + line.slice(0, -1),\n multilineVariable.quote,\n )\n const newValue = updatedValues[multilineVariable.key]\n if (newValue) {\n alreadyPresentKeys.push(multilineVariable.key)\n lineToWrite = createDotEnvFileLine(multilineVariable.key, newValue)\n }\n outputLines.push(lineToWrite)\n multilineVariable = undefined\n } else {\n multilineVariable.value += `${line}\\n`\n }\n continue\n }\n\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const value = (match[2] || '').trim()\n\n if (/^[\"'`]/.test(value) && !value.endsWith(value[0]!)) {\n multilineVariable = {\n key,\n value: `${value.slice(1)}\\n`,\n quote: value[0]!,\n }\n continue\n }\n\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = createDotEnvFileLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n if (multilineVariable) {\n throw new AbortError(`Multi-line environment variable '${multilineVariable.key}' is not properly enclosed.`)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(createDotEnvFileLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n\nexport function createDotEnvFileLine(key: string, value?: string, quote?: string): string {\n if (quote) {\n return `${key}=${quote}${value}${quote}`\n }\n if (value?.includes('\\n')) {\n const quoteCharacter = ['\"', \"'\", '`'].find((char) => !value.includes(char))\n\n if (!quoteCharacter) {\n throw new AbortError(`The environment file patch has an env value that can't be surrounded by quotes: ${value}`)\n }\n\n return `${key}=${quoteCharacter}${value}${quoteCharacter}`\n }\n return `${key}=${value}`\n}\n"]}
@@ -9,7 +9,7 @@ import { renderWarning } from './ui.js';
9
9
  * @returns The loaded environments.
10
10
  */
11
11
  export async function loadEnvironment(environmentName, fileName, options) {
12
- const basePath = options?.from && options?.from !== '.' ? options.from : cwd();
12
+ const basePath = options?.from && options.from !== '.' ? options.from : cwd();
13
13
  const filePath = await findPathUp(fileName, {
14
14
  cwd: basePath,
15
15
  type: 'file',
@@ -1 +1 @@
1
- {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/public/node/environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AACpC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAA;AAUrC;;;;GAI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PathUp, readFile} from './fs.js'\nimport {cwd} from './path.js'\nimport * as metadata from './metadata.js'\nimport {renderWarning} from './ui.js'\nimport {JsonMap} from '../../private/common/json.js'\n\nexport interface Environments {\n [name: string]: JsonMap\n}\n\ninterface LoadEnvironmentOptions {\n from?: string\n}\n/**\n * Loads environments from a file.\n * @param dir - The file path to load environments from.\n * @returns The loaded environments.\n */\nexport async function loadEnvironment(\n environmentName: string,\n fileName: string,\n options?: LoadEnvironmentOptions,\n): Promise<JsonMap | undefined> {\n const basePath = options?.from && options?.from !== '.' ? options.from : cwd()\n const filePath = await findPathUp(fileName, {\n cwd: basePath,\n type: 'file',\n })\n if (!filePath) {\n renderWarning({body: 'Environment file not found.'})\n return undefined\n }\n const environmentsJson = decodeToml(await readFile(filePath)) as Environments\n const environments = environmentsJson.environments\n if (!environments) {\n renderWarning({\n body: ['No environments found in', {command: filePath}, {char: '.'}],\n })\n return undefined\n }\n const environment = environments[environmentName] as JsonMap\n if (!environment)\n renderWarning({\n body: ['Environment', {command: environmentName}, 'not found.'],\n })\n\n await metadata.addSensitiveMetadata(() => ({\n environmentFlags: JSON.stringify(environment),\n }))\n\n return environment\n}\n"]}
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/public/node/environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AACpC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAA;AAUrC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,eAAuB,EACvB,QAAgB,EAChB,OAAgC;IAEhC,MAAM,QAAQ,GAAG,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;IAC7E,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE;QAC1C,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;IACF,IAAI,CAAC,QAAQ,EAAE;QACb,aAAa,CAAC,EAAC,IAAI,EAAE,6BAA6B,EAAC,CAAC,CAAA;QACpD,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAiB,CAAA;IAC7E,MAAM,YAAY,GAAG,gBAAgB,CAAC,YAAY,CAAA;IAClD,IAAI,CAAC,YAAY,EAAE;QACjB,aAAa,CAAC;YACZ,IAAI,EAAE,CAAC,0BAA0B,EAAE,EAAC,OAAO,EAAE,QAAQ,EAAC,EAAE,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC;SACrE,CAAC,CAAA;QACF,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,eAAe,CAAY,CAAA;IAC5D,IAAI,CAAC,WAAW;QACd,aAAa,CAAC;YACZ,IAAI,EAAE,CAAC,aAAa,EAAE,EAAC,OAAO,EAAE,eAAe,EAAC,EAAE,YAAY,CAAC;SAChE,CAAC,CAAA;IAEJ,MAAM,QAAQ,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC;QACzC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;KAC9C,CAAC,CAAC,CAAA;IAEH,OAAO,WAAW,CAAA;AACpB,CAAC","sourcesContent":["import {decodeToml} from './toml.js'\nimport {findPathUp, readFile} from './fs.js'\nimport {cwd} from './path.js'\nimport * as metadata from './metadata.js'\nimport {renderWarning} from './ui.js'\nimport {JsonMap} from '../../private/common/json.js'\n\nexport interface Environments {\n [name: string]: JsonMap\n}\n\ninterface LoadEnvironmentOptions {\n from?: string\n}\n/**\n * Loads environments from a file.\n * @param dir - The file path to load environments from.\n * @returns The loaded environments.\n */\nexport async function loadEnvironment(\n environmentName: string,\n fileName: string,\n options?: LoadEnvironmentOptions,\n): Promise<JsonMap | undefined> {\n const basePath = options?.from && options.from !== '.' ? options.from : cwd()\n const filePath = await findPathUp(fileName, {\n cwd: basePath,\n type: 'file',\n })\n if (!filePath) {\n renderWarning({body: 'Environment file not found.'})\n return undefined\n }\n const environmentsJson = decodeToml(await readFile(filePath)) as Environments\n const environments = environmentsJson.environments\n if (!environments) {\n renderWarning({\n body: ['No environments found in', {command: filePath}, {char: '.'}],\n })\n return undefined\n }\n const environment = environments[environmentName] as JsonMap\n if (!environment)\n renderWarning({\n body: ['Environment', {command: environmentName}, 'not found.'],\n })\n\n await metadata.addSensitiveMetadata(() => ({\n environmentFlags: JSON.stringify(environment),\n }))\n\n return environment\n}\n"]}
@@ -2,7 +2,7 @@ import { reportAnalyticsEvent } from './analytics.js';
2
2
  import * as path from './path.js';
3
3
  import { fanoutHooks } from './plugins.js';
4
4
  import * as metadata from './metadata.js';
5
- import { AbortSilentError, CancelExecution, errorMapper, shouldReportError, handler, cleanSingleStackTracePath, } from './error.js';
5
+ import { AbortSilentError, CancelExecution, errorMapper, shouldReportErrorAsUnexpected, handler, cleanSingleStackTracePath, } from './error.js';
6
6
  import { getEnvironmentData } from '../../private/node/analytics.js';
7
7
  import { outputDebug, outputInfo } from '../../public/node/output.js';
8
8
  import { bugsnagApiKey, reportingRateLimit } from '../../private/node/constants.js';
@@ -36,7 +36,7 @@ export async function errorHandler(error, config) {
36
36
  const reportError = async (error, config) => {
37
37
  // categorise the error first
38
38
  let exitMode = 'expected_error';
39
- if (shouldReportError(error))
39
+ if (shouldReportErrorAsUnexpected(error))
40
40
  exitMode = 'unexpected_error';
41
41
  if (config !== undefined) {
42
42
  // Log an analytics event when there's an error
@@ -133,7 +133,7 @@ export function cleanStackFrameFilePath({ currentFilePath, projectRoot, pluginLo
133
133
  const fullLocation = path.isAbsolutePath(currentFilePath)
134
134
  ? currentFilePath
135
135
  : path.joinPath(projectRoot, currentFilePath);
136
- const matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.indexOf(pluginPath) === 0)[0];
136
+ const matchingPluginPath = pluginLocations.filter(({ pluginPath }) => fullLocation.startsWith(pluginPath))[0];
137
137
  if (matchingPluginPath !== undefined) {
138
138
  // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )
139
139
  return path.joinPath(matchingPluginPath.name, path.relativePath(matchingPluginPath.pluginPath, fullLocation));
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,oBAAoB,EAAC,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,yBAAyB,GAC1B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AACjF,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAC,QAAQ,EAAa,MAAM,aAAa,CAAA;AAChD,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAgB,MAAM,aAAa,CAAA;AAC1C,OAA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CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE;QAC5D,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,6DAA6D;IAC7D,aAAa;IACb,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE;QACvB,OAAM;KACP;IACD,6DAA6D;IAC7D,aAAa;IACb,OAAO,CAAC,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,eAAe;QAC3B,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,KAAK;QACvB,oBAAoB,EAAE,CAAC,YAAY,CAAC;KACrC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CommandExitMode, reportAnalyticsEvent} from './analytics.js'\nimport * as path from './path.js'\nimport {fanoutHooks} from './plugins.js'\nimport * as metadata from './metadata.js'\nimport {\n AbortSilentError,\n CancelExecution,\n errorMapper,\n shouldReportError,\n handler,\n cleanSingleStackTracePath,\n} from './error.js'\nimport {getEnvironmentData} from '../../private/node/analytics.js'\nimport {outputDebug, outputInfo} from '../../public/node/output.js'\nimport {bugsnagApiKey, reportingRateLimit} from '../../private/node/constants.js'\nimport {printEventsJson} from '../../private/node/demo-recorder.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {runWithRateLimit} from '../../private/node/conf-store.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport async function errorHandler(\n error: Error & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): Promise<void> {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n outputInfo(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilentError) {\n printEventsJson()\n } else {\n return errorMapper(error)\n .then((error) => {\n return handler(error)\n })\n .then((mappedError) => {\n printEventsJson()\n return reportError(mappedError, config)\n })\n }\n}\n\nconst reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {\n // categorise the error first\n let exitMode: CommandExitMode = 'expected_error'\n if (shouldReportError(error)) exitMode = 'unexpected_error'\n\n if (config !== undefined) {\n // Log an analytics event when there's an error\n await reportAnalyticsEvent({config, errorMessage: error instanceof Error ? error.message : undefined, exitMode})\n }\n await sendErrorToBugsnag(error, exitMode)\n}\n\n/**\n * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.\n *\n * @returns the reported error (this may have been tweaked for better reporting), and a bool to indicate if the error was actually submitted or not\n */\nexport async function sendErrorToBugsnag(\n error: unknown,\n exitMode: Omit<CommandExitMode, 'ok'>,\n): Promise<{reported: false; error: unknown; unhandled: unknown} | {error: Error; reported: true; unhandled: boolean}> {\n if (settings.debug) {\n outputDebug(`Skipping Bugsnag report`)\n return {reported: false, error, unhandled: undefined}\n }\n\n // If the error was unexpected, we flag it as \"unhandled\" in Bugsnag. This is a helpful distinction.\n const unhandled = exitMode === 'unexpected_error'\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n if (error instanceof Error) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && error.trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = cleanSingleStackTracePath(item.file)\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n let withinRateLimit = false\n await runWithRateLimit({\n key: 'send-error-to-bugsnag',\n ...reportingRateLimit,\n task: async () => {\n withinRateLimit = true\n },\n })\n if (!withinRateLimit) {\n outputDebug(`Skipping Bugsnag report due to rate limiting`)\n report = false\n }\n\n if (report) {\n initializeBugsnag()\n await new Promise((resolve, reject) => {\n outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`)\n const eventHandler = (event: Event) => {\n event.severity = 'error'\n event.unhandled = unhandled\n }\n const errorHandler = (error: unknown) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.notify(reportableError, eventHandler, errorHandler)\n })\n }\n return {error: reportableError, reported: report, unhandled}\n}\n\n/**\n * If the given file path is within a node_modules folder, remove prefix up\n * to and including the node_modules folder.\n *\n * This gives us very consistent paths for errors generated by the CLI.\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolutePath(currentFilePath)\n ? currentFilePath\n : path.joinPath(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.indexOf(pluginPath) === 0)[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.joinPath(matchingPluginPath.name, path.relativePath(matchingPluginPath.pluginPath, fullLocation))\n }\n\n // strip prefix up to node_modules folder, so we can normalize error reporting\n return currentFilePath.replace(/.*node_modules\\//, '')\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(config: Interfaces.Config): Promise<void> {\n // Bugsnag have their own plug-ins that use this private field\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? path.cwd()\n const projectRoot = path.normalizePath(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n [...config.plugins].map(async ([_, plugin]) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalizePath(followSymlinks)}\n }),\n )\n initializeBugsnag()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.addOnError(async (event) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n event.errors.forEach((error: any) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error.stacktrace.forEach((stackFrame: any) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n try {\n await addBugsnagMetadata(event, config)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (metadataError) {\n outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`)\n }\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\nexport async function addBugsnagMetadata(event: any, config: Interfaces.Config): Promise<void> {\n const publicData = metadata.getAllPublicMetadata()\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n const {startCommand} = commandStartOptions ?? {}\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n\n const environment = await getEnvironmentData(config)\n\n const allMetadata = {\n command: startCommand,\n ...appPublic,\n ...publicData,\n ...environment,\n pluginData: otherPluginsPublic,\n }\n\n const appData = {} as {[key: string]: unknown}\n const commandData = {} as {[key: string]: unknown}\n const environmentData = {} as {[key: string]: unknown}\n const miscData = {} as {[key: string]: unknown}\n const appKeys = ['api_key', 'partner_id', 'project_type']\n const commandKeys = ['command']\n const environmentKeys = ['cli_version', 'node_version', 'ruby_version', 'uname']\n\n Object.entries(allMetadata).forEach(([key, value]) => {\n if (key.startsWith('app_') || appKeys.includes(key)) {\n appData[key] = value\n } else if (key.startsWith('cmd_') || commandKeys.includes(key)) {\n commandData[key] = value\n } else if (key.startsWith('env_') || environmentKeys) {\n environmentData[key] = value\n } else {\n miscData[key] = value\n }\n })\n\n // app, command, environment, misc\n const bugsnagMetadata = {\n 'Shopify App': appData,\n Command: commandData,\n Environment: environmentData,\n Misc: miscData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n\nfunction initializeBugsnag() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (Bugsnag.isStarted()) {\n return\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: CLI_KIT_VERSION,\n autoTrackSessions: false,\n autoDetectErrors: false,\n enabledReleaseStages: ['production'],\n })\n}\n"]}
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,oBAAoB,EAAC,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,6BAA6B,EAC7B,OAAO,EACP,yBAAyB,GAC1B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAC,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,CAAC,IAAI,eAAe,EAAE;YACpD,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;aAAM;YACL,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACtB;IACH,CAAC,CAAC,CAAA;IAEF,kCAAkC;IAClC,MAAM,eAAe,GAAG;QACtB,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,WAAW;QACpB,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,QAAQ;KACf,CAAA;IACD,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE;QAC5D,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,6DAA6D;IAC7D,aAAa;IACb,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE;QACvB,OAAM;KACP;IACD,6DAA6D;IAC7D,aAAa;IACb,OAAO,CAAC,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,eAAe;QAC3B,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,KAAK;QACvB,oBAAoB,EAAE,CAAC,YAAY,CAAC;KACrC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CommandExitMode, reportAnalyticsEvent} from './analytics.js'\nimport * as path from './path.js'\nimport {fanoutHooks} from './plugins.js'\nimport * as metadata from './metadata.js'\nimport {\n AbortSilentError,\n CancelExecution,\n errorMapper,\n shouldReportErrorAsUnexpected,\n handler,\n cleanSingleStackTracePath,\n} from './error.js'\nimport {getEnvironmentData} from '../../private/node/analytics.js'\nimport {outputDebug, outputInfo} from '../../public/node/output.js'\nimport {bugsnagApiKey, reportingRateLimit} from '../../private/node/constants.js'\nimport {printEventsJson} from '../../private/node/demo-recorder.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {runWithRateLimit} from '../../private/node/conf-store.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport async function errorHandler(\n error: Error & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): Promise<void> {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n outputInfo(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilentError) {\n printEventsJson()\n } else {\n return errorMapper(error)\n .then((error) => {\n return handler(error)\n })\n .then((mappedError) => {\n printEventsJson()\n return reportError(mappedError, config)\n })\n }\n}\n\nconst reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {\n // categorise the error first\n let exitMode: CommandExitMode = 'expected_error'\n if (shouldReportErrorAsUnexpected(error)) exitMode = 'unexpected_error'\n\n if (config !== undefined) {\n // Log an analytics event when there's an error\n await reportAnalyticsEvent({config, errorMessage: error instanceof Error ? error.message : undefined, exitMode})\n }\n await sendErrorToBugsnag(error, exitMode)\n}\n\n/**\n * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.\n *\n * @returns the reported error (this may have been tweaked for better reporting), and a bool to indicate if the error was actually submitted or not\n */\nexport async function sendErrorToBugsnag(\n error: unknown,\n exitMode: Omit<CommandExitMode, 'ok'>,\n): Promise<{reported: false; error: unknown; unhandled: unknown} | {error: Error; reported: true; unhandled: boolean}> {\n if (settings.debug) {\n outputDebug(`Skipping Bugsnag report`)\n return {reported: false, error, unhandled: undefined}\n }\n\n // If the error was unexpected, we flag it as \"unhandled\" in Bugsnag. This is a helpful distinction.\n const unhandled = exitMode === 'unexpected_error'\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n if (error instanceof Error) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && error.trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = cleanSingleStackTracePath(item.file)\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n let withinRateLimit = false\n await runWithRateLimit({\n key: 'send-error-to-bugsnag',\n ...reportingRateLimit,\n task: async () => {\n withinRateLimit = true\n },\n })\n if (!withinRateLimit) {\n outputDebug(`Skipping Bugsnag report due to rate limiting`)\n report = false\n }\n\n if (report) {\n initializeBugsnag()\n await new Promise((resolve, reject) => {\n outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`)\n const eventHandler = (event: Event) => {\n event.severity = 'error'\n event.unhandled = unhandled\n }\n const errorHandler = (error: unknown) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.notify(reportableError, eventHandler, errorHandler)\n })\n }\n return {error: reportableError, reported: report, unhandled}\n}\n\n/**\n * If the given file path is within a node_modules folder, remove prefix up\n * to and including the node_modules folder.\n *\n * This gives us very consistent paths for errors generated by the CLI.\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolutePath(currentFilePath)\n ? currentFilePath\n : path.joinPath(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.startsWith(pluginPath))[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.joinPath(matchingPluginPath.name, path.relativePath(matchingPluginPath.pluginPath, fullLocation))\n }\n\n // strip prefix up to node_modules folder, so we can normalize error reporting\n return currentFilePath.replace(/.*node_modules\\//, '')\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(config: Interfaces.Config): Promise<void> {\n // Bugsnag have their own plug-ins that use this private field\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? path.cwd()\n const projectRoot = path.normalizePath(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n [...config.plugins].map(async ([_, plugin]) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalizePath(followSymlinks)}\n }),\n )\n initializeBugsnag()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.addOnError(async (event) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n event.errors.forEach((error: any) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error.stacktrace.forEach((stackFrame: any) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n try {\n await addBugsnagMetadata(event, config)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (metadataError) {\n outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`)\n }\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\nexport async function addBugsnagMetadata(event: any, config: Interfaces.Config): Promise<void> {\n const publicData = metadata.getAllPublicMetadata()\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n const {startCommand} = commandStartOptions ?? {}\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n\n const environment = await getEnvironmentData(config)\n\n const allMetadata = {\n command: startCommand,\n ...appPublic,\n ...publicData,\n ...environment,\n pluginData: otherPluginsPublic,\n }\n\n const appData = {} as {[key: string]: unknown}\n const commandData = {} as {[key: string]: unknown}\n const environmentData = {} as {[key: string]: unknown}\n const miscData = {} as {[key: string]: unknown}\n const appKeys = ['api_key', 'partner_id', 'project_type']\n const commandKeys = ['command']\n const environmentKeys = ['cli_version', 'node_version', 'ruby_version', 'uname']\n\n Object.entries(allMetadata).forEach(([key, value]) => {\n if (key.startsWith('app_') || appKeys.includes(key)) {\n appData[key] = value\n } else if (key.startsWith('cmd_') || commandKeys.includes(key)) {\n commandData[key] = value\n } else if (key.startsWith('env_') || environmentKeys) {\n environmentData[key] = value\n } else {\n miscData[key] = value\n }\n })\n\n // app, command, environment, misc\n const bugsnagMetadata = {\n 'Shopify App': appData,\n Command: commandData,\n Environment: environmentData,\n Misc: miscData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n\nfunction initializeBugsnag() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (Bugsnag.isStarted()) {\n return\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: CLI_KIT_VERSION,\n autoTrackSessions: false,\n autoDetectErrors: false,\n enabledReleaseStages: ['production'],\n })\n}\n"]}
@@ -75,12 +75,12 @@ export declare function handler(error: unknown): Promise<unknown>;
75
75
  */
76
76
  export declare function errorMapper(error: unknown): Promise<unknown>;
77
77
  /**
78
- * A function that checks if an error should be reported as unhandled.
78
+ * A function that checks if an error should be reported as unexpected.
79
79
  *
80
80
  * @param error - Error to be checked.
81
- * @returns A boolean indicating if the error should be reported.
81
+ * @returns A boolean indicating if the error should be reported as unexpected.
82
82
  */
83
- export declare function shouldReportError(error: unknown): boolean;
83
+ export declare function shouldReportErrorAsUnexpected(error: unknown): boolean;
84
84
  /**
85
85
  * Stack traces usually have file:// - we strip that and also remove the Windows drive designation.
86
86
  *
@@ -146,13 +146,18 @@ function isFatal(error) {
146
146
  }
147
147
  }
148
148
  /**
149
- * A function that checks if an error should be reported as unhandled.
149
+ * A function that checks if an error should be reported as unexpected.
150
150
  *
151
151
  * @param error - Error to be checked.
152
- * @returns A boolean indicating if the error should be reported.
152
+ * @returns A boolean indicating if the error should be reported as unexpected.
153
153
  */
154
- export function shouldReportError(error) {
154
+ export function shouldReportErrorAsUnexpected(error) {
155
155
  if (!isFatal(error)) {
156
+ // this means its not one of the CLI wrapped errors
157
+ if (error instanceof Error) {
158
+ const message = error.message;
159
+ return !errorMessageImpliesEnvironmentIssue(message);
160
+ }
156
161
  return true;
157
162
  }
158
163
  if (error.type === FatalErrorType.Bug) {
@@ -171,4 +176,25 @@ export function cleanSingleStackTracePath(filePath) {
171
176
  .replace('file:/', '/')
172
177
  .replace(/^\/?[A-Z]:/, '');
173
178
  }
179
+ /**
180
+ * There are certain errors that we know are not due to a CLI bug, but are environmental/user error.
181
+ *
182
+ * @param message - The error message to check.
183
+ * @returns A boolean indicating if the error message implies an environment issue.
184
+ */
185
+ function errorMessageImpliesEnvironmentIssue(message) {
186
+ const environmentIssueMessages = [
187
+ 'EPERM: operation not permitted, scandir',
188
+ 'EACCES: permission denied',
189
+ 'EPERM: operation not permitted, symlink',
190
+ 'This version of npm supports the following node versions',
191
+ 'EBUSY: resource busy or locked, rmdir',
192
+ 'getaddrinfo ENOTFOUND',
193
+ 'Client network socket disconnected before secure TLS connection was established',
194
+ 'spawn EPERM',
195
+ 'socket hang up',
196
+ ];
197
+ const anyMatches = environmentIssueMessages.some((issueMessage) => message.includes(issueMessage));
198
+ return anyMatches;
199
+ }
174
200
  //# sourceMappingURL=error.js.map