@shopify/cli-kit 3.37.0 → 3.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/private/node/api/graphql.js +7 -7
  5. package/dist/private/node/api/graphql.js.map +1 -1
  6. package/dist/{network → private/node}/api.d.ts +0 -0
  7. package/dist/{network → private/node}/api.js +0 -0
  8. package/dist/private/node/api.js.map +1 -0
  9. package/dist/private/node/conf-store.js +4 -4
  10. package/dist/private/node/conf-store.js.map +1 -1
  11. package/dist/{content-tokens.d.ts → private/node/content-tokens.d.ts} +11 -11
  12. package/dist/{content-tokens.js → private/node/content-tokens.js} +3 -3
  13. package/dist/private/node/content-tokens.js.map +1 -0
  14. package/dist/private/node/secure-store.js +4 -4
  15. package/dist/private/node/secure-store.js.map +1 -1
  16. package/dist/private/node/session/authorize.js +3 -3
  17. package/dist/private/node/session/authorize.js.map +1 -1
  18. package/dist/private/node/session/device-authorization.js +6 -6
  19. package/dist/private/node/session/device-authorization.js.map +1 -1
  20. package/dist/private/node/session/exchange.js.map +1 -1
  21. package/dist/private/node/session/identity-token-validation.js +5 -5
  22. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  23. package/dist/private/node/session/identity.d.ts +1 -1
  24. package/dist/private/node/session/identity.js.map +1 -1
  25. package/dist/private/node/session/redirect-listener.js +2 -2
  26. package/dist/private/node/session/redirect-listener.js.map +1 -1
  27. package/dist/private/node/session/scopes.d.ts +1 -1
  28. package/dist/private/node/session/scopes.js +1 -1
  29. package/dist/private/node/session/scopes.js.map +1 -1
  30. package/dist/private/node/session/store.js +4 -4
  31. package/dist/private/node/session/store.js.map +1 -1
  32. package/dist/private/node/session/validate.js +2 -2
  33. package/dist/private/node/session/validate.js.map +1 -1
  34. package/dist/private/node/session.js +19 -19
  35. package/dist/private/node/session.js.map +1 -1
  36. package/dist/private/node/ui/alert.js +1 -1
  37. package/dist/private/node/ui/alert.js.map +1 -1
  38. package/dist/private/node/ui/components/Alert.test.js +1 -1
  39. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  40. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -1
  41. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  42. package/dist/private/node/ui/components/ConcurrentOutput.test.js +1 -1
  43. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  44. package/dist/private/node/ui/components/FatalError.test.js +1 -1
  45. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  46. package/dist/private/node/ui/components/List.test.js +1 -1
  47. package/dist/private/node/ui/components/List.test.js.map +1 -1
  48. package/dist/private/node/ui/components/SelectPrompt.test.js +1 -1
  49. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  50. package/dist/private/node/ui/components/Tasks.test.js +1 -1
  51. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  52. package/dist/private/node/ui/components/TextPrompt.test.js +1 -1
  53. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  54. package/dist/private/node/ui/components/TokenizedText.test.js +1 -1
  55. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  56. package/dist/private/node/ui.d.ts +1 -1
  57. package/dist/private/node/ui.js +1 -1
  58. package/dist/private/node/ui.js.map +1 -1
  59. package/dist/public/common/string.js +1 -1
  60. package/dist/public/common/string.js.map +1 -1
  61. package/dist/public/common/version.d.ts +1 -1
  62. package/dist/public/common/version.js +1 -1
  63. package/dist/public/common/version.js.map +1 -1
  64. package/dist/public/node/analytics.js +5 -5
  65. package/dist/public/node/analytics.js.map +1 -1
  66. package/dist/public/node/api/admin.js +2 -2
  67. package/dist/public/node/api/admin.js.map +1 -1
  68. package/dist/public/node/archiver.js +2 -2
  69. package/dist/public/node/archiver.js.map +1 -1
  70. package/dist/public/node/base-command.js +4 -4
  71. package/dist/public/node/base-command.js.map +1 -1
  72. package/dist/public/node/dot-env.js +2 -2
  73. package/dist/public/node/dot-env.js.map +1 -1
  74. package/dist/public/node/environment/spin.js +2 -2
  75. package/dist/public/node/environment/spin.js.map +1 -1
  76. package/dist/public/node/error-handler.js +3 -3
  77. package/dist/public/node/error-handler.js.map +1 -1
  78. package/dist/public/node/error.d.ts +5 -5
  79. package/dist/public/node/error.js +1 -1
  80. package/dist/public/node/error.js.map +1 -1
  81. package/dist/public/node/fs.js +19 -19
  82. package/dist/public/node/fs.js.map +1 -1
  83. package/dist/public/node/git.js +8 -8
  84. package/dist/public/node/git.js.map +1 -1
  85. package/dist/public/node/github.js +2 -2
  86. package/dist/public/node/github.js.map +1 -1
  87. package/dist/public/node/hooks/postrun.js +2 -2
  88. package/dist/public/node/hooks/postrun.js.map +1 -1
  89. package/dist/public/node/hooks/prerun.js +2 -2
  90. package/dist/public/node/hooks/prerun.js.map +1 -1
  91. package/dist/public/node/http.js +3 -3
  92. package/dist/public/node/http.js.map +1 -1
  93. package/dist/public/node/liquid.js +2 -2
  94. package/dist/public/node/liquid.js.map +1 -1
  95. package/dist/public/node/monorail.js +4 -4
  96. package/dist/public/node/monorail.js.map +1 -1
  97. package/dist/public/node/node-package-manager.js +9 -9
  98. package/dist/public/node/node-package-manager.js.map +1 -1
  99. package/dist/public/node/os.js +2 -2
  100. package/dist/public/node/os.js.map +1 -1
  101. package/dist/{output.d.ts → public/node/output.d.ts} +100 -41
  102. package/dist/{output.js → public/node/output.js} +129 -50
  103. package/dist/public/node/output.js.map +1 -0
  104. package/dist/public/node/ruby.js +7 -5
  105. package/dist/public/node/ruby.js.map +1 -1
  106. package/dist/public/node/session.js +9 -9
  107. package/dist/public/node/session.js.map +1 -1
  108. package/dist/public/node/system.js +2 -2
  109. package/dist/public/node/system.js.map +1 -1
  110. package/dist/public/node/tcp.js +4 -4
  111. package/dist/public/node/tcp.js.map +1 -1
  112. package/dist/public/node/testing/output.js +10 -9
  113. package/dist/public/node/testing/output.js.map +1 -1
  114. package/dist/public/node/ui.d.ts +1 -1
  115. package/dist/public/node/ui.js +1 -1
  116. package/dist/public/node/ui.js.map +1 -1
  117. package/dist/public/node/vscode.js +4 -4
  118. package/dist/public/node/vscode.js.map +1 -1
  119. package/dist/tsconfig.tsbuildinfo +1 -1
  120. package/dist/ui.js +9 -9
  121. package/dist/ui.js.map +1 -1
  122. package/package.json +1 -1
  123. package/dist/content-tokens.js.map +0 -1
  124. package/dist/network/api.js.map +0 -1
  125. package/dist/output.js.map +0 -1
@@ -4,7 +4,7 @@ import { isDevelopment } from './environment/local.js';
4
4
  import { addPublicMetadata } from './metadata.js';
5
5
  import { AbortError } from './error.js';
6
6
  import { cwd } from './path.js';
7
- import { content, info, token } from '../../output.js';
7
+ import { outputContent, outputInfo, outputToken } from '../../public/node/output.js';
8
8
  import { hashString } from '../../public/node/crypto.js';
9
9
  import { isTruthy } from '../../private/node/environment/utilities.js';
10
10
  import { Command } from '@oclif/core';
@@ -27,7 +27,7 @@ class BaseCommand extends Command {
27
27
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
28
28
  exitWithTimestampWhenEnvVariablePresent() {
29
29
  if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {
30
- info(`
30
+ outputInfo(`
31
31
  SHOPIFY_CLI_TIMESTAMP_START
32
32
  { "timestamp": ${Date.now()} }
33
33
  SHOPIFY_CLI_TIMESTAMP_END
@@ -102,7 +102,7 @@ function reportPresetApplication(noDefaultsFlags, flagsWithPresets, presetName,
102
102
  }
103
103
  if (Object.keys(changes).length === 0)
104
104
  return;
105
- info(content `Using applicable flags from the preset ${token.yellow(presetName)}:
105
+ outputInfo(outputContent `Using applicable flags from the preset ${outputToken.yellow(presetName)}:
106
106
 
107
107
  ${Object.entries(changes)
108
108
  .map(([name, value]) => `• ${name} = ${value}`)
@@ -156,7 +156,7 @@ function argsFromPreset(preset, options, noDefaultsResult) {
156
156
  args.push(`--${label}`);
157
157
  }
158
158
  else {
159
- throw new AbortError(content `Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`);
159
+ throw new AbortError(outputContent `Presets can only specify true for boolean flags. Attempted to set ${outputToken.yellow(label)} to false.`);
160
160
  }
161
161
  }
162
162
  else if (Array.isArray(value)) {
@@ -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,wBAAwB,EAAC,MAAM,cAAc,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAE7B,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,6CAA6C,CAAA;AACpE,OAAO,EAAC,OAAO,EAAa,MAAM,aAAa,CAAA;AAO/C,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,uCAAuC,EAAE,CAAA;QAC9C,IAAI,CAAC,aAAa,EAAE,EAAE;YACpB,yCAAyC;YACzC,MAAM,2CAA2C,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SAC/D;QACD,OAAO,KAAK,CAAC,IAAI,E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KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACnD,MAAM,uBAAuB,GAAG,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC5G,MAAM,qBAAqB,GACzB,gBAAgB,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC/F,IAAI,uBAAuB,IAAI,CAAC,qBAAqB,EAAE;YACrD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;gBAC9B,IAAI,KAAK,KAAK,IAAI,EAAE;oBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;iBACxB;qBAAM;oBACL,MAAM,IAAI,UAAU,CAClB,OAAO,CAAA,qEAAqE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAC5G,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 {loadPresetsFromDirectory} from './presets.js'\nimport {isDevelopment} from './environment/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {content, info, token} from '../../output.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {isTruthy} from '../../private/node/environment/utilities.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n await errorHandler(error, this.config)\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 return super.init()\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 info(`\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 Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) 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 preset'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 argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\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 preset\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 preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n info(content`Using applicable flags from the preset ${token.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\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 Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n): Interfaces.Input<TFlags, TGlobalFlags> | 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 Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\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 content`Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} 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,wBAAwB,EAAC,MAAM,cAAc,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAE7B,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAClF,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,6CAA6C,CAAA;AACpE,OAAO,EAAC,OAAO,EAAa,MAAM,aAAa,CAAA;AAO/C,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,MAA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AAK,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 {loadPresetsFromDirectory} from './presets.js'\nimport {isDevelopment} from './environment/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {outputContent, outputInfo, outputToken} from '../../public/node/output.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {isTruthy} from '../../private/node/environment/utilities.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n await errorHandler(error, this.config)\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 return super.init()\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 Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) 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 preset'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 argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\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 preset\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 preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n outputInfo(outputContent`Using applicable flags from the preset ${outputToken.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\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 Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n): Interfaces.Input<TFlags, TGlobalFlags> | 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 Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\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`Presets 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,6 +1,6 @@
1
1
  import { AbortError } from './error.js';
2
2
  import { fileExists, readFile, writeFile } from './fs.js';
3
- import { debug, content as outputContent, token } from '../../output.js';
3
+ import { outputDebug, outputContent, outputToken } from '../../public/node/output.js';
4
4
  import { parse, stringify } from 'envfile';
5
5
  /**
6
6
  * Error that's thrown when the .env is not found.
@@ -16,7 +16,7 @@ export const DotEnvNotFoundError = (path) => {
16
16
  * @returns An in-memory representation of the .env file.
17
17
  */
18
18
  export async function readAndParseDotEnv(path) {
19
- debug(outputContent `Reading the .env file at ${token.path(path)}`);
19
+ outputDebug(outputContent `Reading the .env file at ${outputToken.path(path)}`);
20
20
  if (!(await fileExists(path))) {
21
21
  throw DotEnvNotFoundError(path);
22
22
  }
@@ -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,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAc,EAAE;IAC9D,OAAO,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;AAC1E,CAAC,CAAA;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,KAAK,CAAC,aAAa,CAAA,4BAA4B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAClE,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;KAC1B,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAgB;IAChD,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;AACvD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,cAA6B,EAC7B,aAAkD;IAElD,MAAM,WAAW,GAAa,EAAE,CAAA;IAChC,MAAM,KAAK,GAAG,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEvE,MAAM,kBAAkB,GAAa,EAAE,CAAA;IAEvC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;IAEjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAC/C,IAAI,WAAW,GAAG,IAAI,CAAA;QAEtB,IAAI,KAAK,EAAE;YACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAA;YAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,QAAQ,EAAE;gBACZ,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC5B,WAAW,GAAG,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;aACpC;SACF;QAED,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;KAC9B;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,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {fileExists, readFile, writeFile} from './fs.js'\nimport {debug, content as outputContent, token} from '../../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string): AbortError => {\n return new AbortError(`The environment file at ${path} does not exist.`)\n}\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 debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await fileExists(path))) {\n throw DotEnvNotFoundError(path)\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 await writeFile(file.path, stringify(file.variables))\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 lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
1
+ {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../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AC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEvE,MAAM,kBAAkB,GAAa,EAAE,CAAA;IAEvC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;IAEjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAC/C,IAAI,WAAW,GAAG,IAAI,CAAA;QAEtB,IAAI,KAAK,EAAE;YACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAA;YAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,QAAQ,EAAE;gBACZ,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC5B,WAAW,GAAG,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;aACpC;SACF;QAED,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;KAC9B;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,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,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, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string): AbortError => {\n return new AbortError(`The environment file at ${path} does not exist.`)\n}\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 DotEnvNotFoundError(path)\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 await writeFile(file.path, stringify(file.variables))\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 lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
@@ -2,12 +2,12 @@ import { fileExists, readFileSync } from '../fs.js';
2
2
  import { isTruthy } from '../../../private/node/environment/utilities.js';
3
3
  import { environmentVariables } from '../../../private/node/constants.js';
4
4
  import { captureOutput } from '../system.js';
5
- import { content, token } from '../../../output.js';
5
+ import { outputContent, outputToken } from '../../../public/node/output.js';
6
6
  import { getCachedSpinFqdn, setCachedSpinFqdn } from '../../../private/node/environment/spin-cache.js';
7
7
  import { AbortError } from '../error.js';
8
8
  import { Environment, serviceEnvironment } from '../../../private/node/environment/service.js';
9
9
  const SpinInstanceNotFoundMessages = (spinInstance, error) => {
10
- const errorMessage = content `${token.genericShellCommand(`spin`)} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:
10
+ const errorMessage = outputContent `${outputToken.genericShellCommand(`spin`)} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:
11
11
  ${error}
12
12
  `;
13
13
  let nextSteps;
@@ -1 +1 @@
1
- {"version":3,"file":"spin.js","sourceRoot":"","sources":["../../../../src/public/node/environment/spin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,UAAU,CAAA;AACjD,OAAO,EAAC,QAAQ,EAAC,MAAM,gDAAgD,CAAA;AACvE,OAAO,EAAC,oBAAoB,EAAC,MAAM,oCAAoC,CAAA;AACvE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,iDAAiD,CAAA;AACpG,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,8CAA8C,CAAA;AAE5F,MAAM,4BAA4B,GAAG,CAAC,YAAgC,EAAE,KAAa,EAAE,EAAE;IACvF,MAAM,YAAY,GAAG,OAAO,CAAA,GAAG,KAAK,CAAC,mBAAmB,CACtD,MAAM,CACP;EACD,KAAK;GACJ,CAAA;IACD,IAAI,SAA6B,CAAA;IACjC,IAAI,YAAY,EAAE;QAChB,SAAS,GAAG,aAAa,YAAY,6DAA6D,CA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S,EAAC,GAAG,4BAA4B,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QACxF,MAAM,IAAI,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;KAC9C;SAAM;QACL,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;AACjD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,GAAG,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACjD,OAAO,kBAAkB,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AACrD,CAAC","sourcesContent":["import {fileExists, readFileSync} from '../fs.js'\nimport {isTruthy} from '../../../private/node/environment/utilities.js'\nimport {environmentVariables} from '../../../private/node/constants.js'\nimport {captureOutput} from '../system.js'\nimport {content, token} from '../../../output.js'\nimport {getCachedSpinFqdn, setCachedSpinFqdn} from '../../../private/node/environment/spin-cache.js'\nimport {AbortError} from '../error.js'\nimport {Environment, serviceEnvironment} from '../../../private/node/environment/service.js'\n\nconst SpinInstanceNotFoundMessages = (spinInstance: string | undefined, error: string) => {\n const errorMessage = content`${token.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"]}
1
+ {"version":3,"file":"spin.js","sourceRoot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CAAA;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACjD,OAAO,kBAAkB,CAAC,GAAG,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AACrD,CAAC","sourcesContent":["import {fileExists, readFileSync} from '../fs.js'\nimport {isTruthy} from '../../../private/node/environment/utilities.js'\nimport {environmentVariables} from '../../../private/node/constants.js'\nimport {captureOutput} from '../system.js'\nimport {outputContent, outputToken} from '../../../public/node/output.js'\nimport {getCachedSpinFqdn, setCachedSpinFqdn} from '../../../private/node/environment/spin-cache.js'\nimport {AbortError} from '../error.js'\nimport {Environment, serviceEnvironment} from '../../../private/node/environment/service.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"]}
@@ -4,7 +4,7 @@ import { fanoutHooks } from './plugins.js';
4
4
  import * as metadata from './metadata.js';
5
5
  import { AbortSilentError, CancelExecution, errorMapper, shouldReportError, handler, cleanSingleStackTracePath, } from './error.js';
6
6
  import { getEnvironmentData } from '../../private/node/analytics.js';
7
- import { debug, info } from '../../output.js';
7
+ import { outputDebug, outputInfo } from '../../public/node/output.js';
8
8
  import { bugsnagApiKey } from '../../private/node/constants.js';
9
9
  import { CLI_KIT_VERSION } from '../common/version.js';
10
10
  import { settings } from '@oclif/core';
@@ -14,7 +14,7 @@ import { realpath } from 'fs/promises';
14
14
  export function errorHandler(error, config) {
15
15
  if (error instanceof CancelExecution) {
16
16
  if (error.message && error.message !== '') {
17
- info(`✨ ${error.message}`);
17
+ outputInfo(`✨ ${error.message}`);
18
18
  }
19
19
  }
20
20
  else if (error instanceof AbortSilentError) {
@@ -136,7 +136,7 @@ export async function registerCleanBugsnagErrorsFromWithinPlugins(config) {
136
136
  // eslint-disable-next-line no-catch-all/no-catch-all
137
137
  }
138
138
  catch (metadataError) {
139
- debug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`);
139
+ outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`);
140
140
  }
141
141
  });
142
142
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAA;AACnD,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,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAa,MAAM,aAAa,CAAA;AAChD,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAgB,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAOpC,MAAM,UAAU,YAAY,CAAC,KAA8C,EAAE,MAA0B;IACrG,IAAI,KAAK,YAAY,eAAe,EAAE;QACpC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAA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AAW;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,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE;QACvB,OAAM;KACP;IACD,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;KACxB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {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 {debug, info} from '../../output.js'\nimport {bugsnagApiKey} from '../../private/node/constants.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport function errorHandler(\n error: (CancelExecution | AbortSilentError) & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): void\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config): Promise<void>\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config): unknown {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n info(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilentError) {\n process.exit(1)\n } else {\n return errorMapper(error)\n .then((error) => {\n return handler(error)\n })\n .then((mappedError) => reportError(mappedError, config))\n .then(() => {\n process.exit(1)\n })\n }\n}\n\nconst reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {\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})\n }\n await sendErrorToBugsnag(error)\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): Promise<{reported: false; error: unknown} | {error: Error; reported: true}> {\n if (settings.debug || !shouldReportError(error)) return {reported: false, 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 if (report) {\n initializeBugsnag()\n await new Promise((resolve, reject) => {\n Bugsnag.notify(reportableError, undefined, (error, event) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n })\n })\n }\n return {error: reportableError, reported: report}\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 // 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 Bugsnag.addOnError(async (event) => {\n event.errors.forEach((error) => {\n error.stacktrace.forEach((stackFrame) => {\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 debug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`)\n }\n })\n}\n\nexport async function addBugsnagMetadata(event: Event, 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 if (Bugsnag.isStarted()) {\n return\n }\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: CLI_KIT_VERSION,\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n}\n"]}
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,WAAW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AK;KACxB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {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} from '../../private/node/constants.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport function errorHandler(\n error: (CancelExecution | AbortSilentError) & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): void\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config): Promise<void>\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config): unknown {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n outputInfo(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilentError) {\n process.exit(1)\n } else {\n return errorMapper(error)\n .then((error) => {\n return handler(error)\n })\n .then((mappedError) => reportError(mappedError, config))\n .then(() => {\n process.exit(1)\n })\n }\n}\n\nconst reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {\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})\n }\n await sendErrorToBugsnag(error)\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): Promise<{reported: false; error: unknown} | {error: Error; reported: true}> {\n if (settings.debug || !shouldReportError(error)) return {reported: false, 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 if (report) {\n initializeBugsnag()\n await new Promise((resolve, reject) => {\n Bugsnag.notify(reportableError, undefined, (error, event) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n })\n })\n }\n return {error: reportableError, reported: report}\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 // 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 Bugsnag.addOnError(async (event) => {\n event.errors.forEach((error) => {\n error.stacktrace.forEach((stackFrame) => {\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\nexport async function addBugsnagMetadata(event: Event, 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 if (Bugsnag.isStarted()) {\n return\n }\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: CLI_KIT_VERSION,\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Message } from '../../output.js';
1
+ import { OutputMessage } from '../../public/node/output.js';
2
2
  import { TokenItem } from '../../private/node/ui/components/TokenizedText.js';
3
3
  export { ExtendableError } from 'ts-error';
4
4
  declare enum FatalErrorType {
@@ -26,7 +26,7 @@ export declare abstract class FatalError extends Error {
26
26
  * if you need to style the message inside the error Banner component.
27
27
  * @param nextSteps - Message to show as "next steps" with suggestions to solve the issue.
28
28
  */
29
- constructor(message: Message, type: FatalErrorType, tryMessage?: TokenItem | Message | null, nextSteps?: TokenItem[]);
29
+ constructor(message: OutputMessage, type: FatalErrorType, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem[]);
30
30
  }
31
31
  /**
32
32
  * An abort error is a fatal error that shouldn't be reported as a bug.
@@ -34,7 +34,7 @@ export declare abstract class FatalError extends Error {
34
34
  */
35
35
  export declare class AbortError extends FatalError {
36
36
  nextSteps?: TokenItem[];
37
- constructor(message: Message, tryMessage?: TokenItem | Message | null, nextSteps?: TokenItem[]);
37
+ constructor(message: OutputMessage, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem[]);
38
38
  }
39
39
  /**
40
40
  * An external error is similar to Abort but has extra command and args attributes.
@@ -43,7 +43,7 @@ export declare class AbortError extends FatalError {
43
43
  export declare class ExternalError extends FatalError {
44
44
  command: string;
45
45
  args: string[];
46
- constructor(message: Message, command: string, args: string[], tryMessage?: TokenItem | Message | null);
46
+ constructor(message: OutputMessage, command: string, args: string[], tryMessage?: TokenItem | OutputMessage | null);
47
47
  }
48
48
  export declare class AbortSilentError extends FatalError {
49
49
  constructor();
@@ -52,7 +52,7 @@ export declare class AbortSilentError extends FatalError {
52
52
  * A bug error is an error that represents a bug and therefore should be reported.
53
53
  */
54
54
  export declare class BugError extends FatalError {
55
- constructor(message: Message, tryMessage?: TokenItem | null);
55
+ constructor(message: OutputMessage, tryMessage?: TokenItem | null);
56
56
  }
57
57
  /**
58
58
  * A function that handles errors that blow up in the CLI.
@@ -1,5 +1,5 @@
1
1
  import { renderFatalError } from './ui.js';
2
- import { stringifyMessage, TokenizedString } from '../../output.js';
2
+ import { stringifyMessage, TokenizedString } from '../../public/node/output.js';
3
3
  import { normalizePath } from '../../public/node/path.js';
4
4
  import { Errors } from '@oclif/core';
5
5
  export { ExtendableError } from 'ts-error';
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/public/node/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAA;AACxC,OAAO,EAAU,gBAAgB,EAAE,eAAe,EAAC,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AAEvD,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAElC,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAA;AAExC,IAAK,cAIJ;AAJD,WAAK,cAAc;IACjB,qDAAK,CAAA;IACL,iEAAW,CAAA;IACX,iDAAG,CAAA;AACL,CAAC,EAJI,cAAc,KAAd,cAAc,QAIlB;AAED,MAA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AO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI;QACF,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC1D,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QACrC,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,aAAa,CAAC,QAAQ,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import {renderFatalError} from './ui.js'\nimport {Message, stringifyMessage, TokenizedString} from '../../output.js'\nimport {normalizePath} from '../../public/node/path.js'\nimport {TokenItem} from '../../private/node/ui/components/TokenizedText.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class FatalError extends Error {\n tryMessage: TokenItem | null\n type: FatalErrorType\n nextSteps?: TokenItem[]\n /**\n * Creates a new FatalError error.\n *\n * @param message - The error message.\n * @param type - The type of fatal error.\n * @param tryMessage - The message that recommends next steps to the user.\n * You can pass a string a {@link TokenizedString} or a {@link TokenItem}\n * if you need to style the message inside the error Banner component.\n * @param nextSteps - Message to show as \"next steps\" with suggestions to solve the issue.\n */\n constructor(\n message: Message,\n type: FatalErrorType,\n tryMessage: TokenItem | Message | null = null,\n nextSteps?: TokenItem[],\n ) {\n super(stringifyMessage(message))\n\n if (tryMessage) {\n if (tryMessage instanceof TokenizedString) {\n this.tryMessage = stringifyMessage(tryMessage)\n } else {\n this.tryMessage = tryMessage\n }\n } else {\n this.tryMessage = null\n }\n\n this.type = type\n this.nextSteps = nextSteps\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer.\n */\nexport class AbortError extends FatalError {\n nextSteps?: TokenItem[]\n constructor(message: Message, tryMessage: TokenItem | Message | null = null, nextSteps?: TokenItem[]) {\n super(message, FatalErrorType.Abort, tryMessage, nextSteps)\n }\n}\n\n/**\n * An external error is similar to Abort but has extra command and args attributes.\n * This is useful to represent errors coming from external commands, usually executed by execa.\n */\nexport class ExternalError extends FatalError {\n command: string\n args: string[]\n\n constructor(message: Message, command: string, args: string[], tryMessage: TokenItem | Message | null = null) {\n super(message, FatalErrorType.Abort, tryMessage)\n this.command = command\n this.args = args\n }\n}\n\nexport class AbortSilentError extends FatalError {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class BugError extends FatalError {\n constructor(message: Message, tryMessage: TokenItem | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n *\n * @param error - Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: unknown): Promise<unknown> {\n let fatal: FatalError\n if (isFatal(error)) {\n fatal = error\n } else if (typeof error === 'string') {\n fatal = new BugError(error)\n } else if (error instanceof Error) {\n fatal = new BugError(error.message)\n fatal.stack = error.stack\n } else {\n // errors can come in all shapes and sizes...\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const maybeError = error as any\n fatal = new BugError(maybeError?.message ?? 'Unknown error')\n if (maybeError?.stack) {\n fatal.stack = maybeError?.stack\n }\n }\n\n renderFatalError(fatal)\n return Promise.resolve(error)\n}\n\n/**\n * A function that maps an error to an Abort with the stack trace when coming from the CLI.\n *\n * @param error - Error to be mapped.\n * @returns A promise that resolves with the new error object.\n */\nexport function errorMapper(error: unknown): Promise<unknown> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new AbortError(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\n/**\n * A function that checks if an error is a fatal one.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error is a fatal one.\n */\nfunction isFatal(error: unknown): error is FatalError {\n try {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * A function that checks if an error should be reported.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error should be reported.\n */\nexport function shouldReportError(error: unknown): boolean {\n if (!isFatal(error)) {\n return true\n }\n if (error.type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n\n/**\n * Stack traces usually have file:// - we strip that and also remove the Windows drive designation.\n *\n * @param filePath - Path to be cleaned.\n * @returns The cleaned path.\n */\nexport function cleanSingleStackTracePath(filePath: string): string {\n return normalizePath(filePath)\n .replace('file:/', '/')\n .replace(/^\\/?[A-Z]:/, '')\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/public/node/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAA;AACxC,OAAO,EAAgB,gBAAgB,EAAE,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAC5F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AAEvD,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,C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M,WAAW,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;KACpC;SAAM;QACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC9B;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI;QACF,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC1D,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,GAAG,EAAE;QACrC,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,OAAO,aAAa,CAAC,QAAQ,CAAC;SAC3B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AAC9B,CAAC","sourcesContent":["import {renderFatalError} from './ui.js'\nimport {OutputMessage, stringifyMessage, TokenizedString} from '../../public/node/output.js'\nimport {normalizePath} from '../../public/node/path.js'\nimport {TokenItem} from '../../private/node/ui/components/TokenizedText.js'\nimport {Errors} from '@oclif/core'\n\nexport {ExtendableError} from 'ts-error'\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class FatalError extends Error {\n tryMessage: TokenItem | null\n type: FatalErrorType\n nextSteps?: TokenItem[]\n /**\n * Creates a new FatalError error.\n *\n * @param message - The error message.\n * @param type - The type of fatal error.\n * @param tryMessage - The message that recommends next steps to the user.\n * You can pass a string a {@link TokenizedString} or a {@link TokenItem}\n * if you need to style the message inside the error Banner component.\n * @param nextSteps - Message to show as \"next steps\" with suggestions to solve the issue.\n */\n constructor(\n message: OutputMessage,\n type: FatalErrorType,\n tryMessage: TokenItem | OutputMessage | null = null,\n nextSteps?: TokenItem[],\n ) {\n super(stringifyMessage(message))\n\n if (tryMessage) {\n if (tryMessage instanceof TokenizedString) {\n this.tryMessage = stringifyMessage(tryMessage)\n } else {\n this.tryMessage = tryMessage\n }\n } else {\n this.tryMessage = null\n }\n\n this.type = type\n this.nextSteps = nextSteps\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer.\n */\nexport class AbortError extends FatalError {\n nextSteps?: TokenItem[]\n constructor(message: OutputMessage, tryMessage: TokenItem | OutputMessage | null = null, nextSteps?: TokenItem[]) {\n super(message, FatalErrorType.Abort, tryMessage, nextSteps)\n }\n}\n\n/**\n * An external error is similar to Abort but has extra command and args attributes.\n * This is useful to represent errors coming from external commands, usually executed by execa.\n */\nexport class ExternalError extends FatalError {\n command: string\n args: string[]\n\n constructor(\n message: OutputMessage,\n command: string,\n args: string[],\n tryMessage: TokenItem | OutputMessage | null = null,\n ) {\n super(message, FatalErrorType.Abort, tryMessage)\n this.command = command\n this.args = args\n }\n}\n\nexport class AbortSilentError extends FatalError {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class BugError extends FatalError {\n constructor(message: OutputMessage, tryMessage: TokenItem | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n *\n * @param error - Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: unknown): Promise<unknown> {\n let fatal: FatalError\n if (isFatal(error)) {\n fatal = error\n } else if (typeof error === 'string') {\n fatal = new BugError(error)\n } else if (error instanceof Error) {\n fatal = new BugError(error.message)\n fatal.stack = error.stack\n } else {\n // errors can come in all shapes and sizes...\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const maybeError = error as any\n fatal = new BugError(maybeError?.message ?? 'Unknown error')\n if (maybeError?.stack) {\n fatal.stack = maybeError?.stack\n }\n }\n\n renderFatalError(fatal)\n return Promise.resolve(error)\n}\n\n/**\n * A function that maps an error to an Abort with the stack trace when coming from the CLI.\n *\n * @param error - Error to be mapped.\n * @returns A promise that resolves with the new error object.\n */\nexport function errorMapper(error: unknown): Promise<unknown> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new AbortError(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\n/**\n * A function that checks if an error is a fatal one.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error is a fatal one.\n */\nfunction isFatal(error: unknown): error is FatalError {\n try {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * A function that checks if an error should be reported.\n *\n * @param error - Error to be checked.\n * @returns A boolean indicating if the error should be reported.\n */\nexport function shouldReportError(error: unknown): boolean {\n if (!isFatal(error)) {\n return true\n }\n if (error.type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n\n/**\n * Stack traces usually have file:// - we strip that and also remove the Windows drive designation.\n *\n * @param filePath - Path to be cleaned.\n * @returns The cleaned path.\n */\nexport function cleanSingleStackTracePath(filePath: string): string {\n return normalizePath(filePath)\n .replace('file:/', '/')\n .replace(/^\\/?[A-Z]:/, '')\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { joinPath, normalizePath } from './path.js';
2
- import { content as outputContent, token, debug } from '../../output.js';
2
+ import { outputContent, outputToken, outputDebug } from '../../public/node/output.js';
3
3
  import { getRandomName } from '../common/string.js';
4
4
  import { copy as fsCopy, ensureFile as fsEnsureFile, ensureFileSync as fsEnsureFileSync, remove as fsRemove, removeSync as fsRemoveSync, move as fsMove,
5
5
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -44,7 +44,7 @@ export async function inTemporaryDirectory(callback) {
44
44
  * @returns A promise that resolves with the content of the file.
45
45
  */
46
46
  export async function readFile(path, options = { encoding: 'utf8' }) {
47
- debug(outputContent `Reading the content of file at ${token.path(path)}...`);
47
+ outputDebug(outputContent `Reading the content of file at ${outputToken.path(path)}...`);
48
48
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
49
  // @ts-ignore
50
50
  return fsReadFile(path, options);
@@ -56,7 +56,7 @@ export async function readFile(path, options = { encoding: 'utf8' }) {
56
56
  * @returns The content of the file.
57
57
  */
58
58
  export function readFileSync(path) {
59
- debug(outputContent `Sync-reading the content of file at ${token.path(path)}...`);
59
+ outputDebug(outputContent `Sync-reading the content of file at ${outputToken.path(path)}...`);
60
60
  return fsReadFileSync(path);
61
61
  }
62
62
  /**
@@ -75,7 +75,7 @@ export async function fileRealPath(path) {
75
75
  * @param to - Destination path.
76
76
  */
77
77
  export async function copyFile(from, to) {
78
- debug(outputContent `Copying file from ${token.path(from)} to ${token.path(to)}...`);
78
+ outputDebug(outputContent `Copying file from ${outputToken.path(from)} to ${outputToken.path(to)}...`);
79
79
  await fsCopy(from, to);
80
80
  }
81
81
  /**
@@ -84,7 +84,7 @@ export async function copyFile(from, to) {
84
84
  * @param path - Path to the file to be created.
85
85
  */
86
86
  export async function touchFile(path) {
87
- debug(outputContent `Creating an empty file at ${token.path(path)}...`);
87
+ outputDebug(outputContent `Creating an empty file at ${outputToken.path(path)}...`);
88
88
  await fsEnsureFile(path);
89
89
  }
90
90
  /**
@@ -93,7 +93,7 @@ export async function touchFile(path) {
93
93
  * @param path - Path to the file to be created.
94
94
  */
95
95
  export function touchFileSync(path) {
96
- debug(outputContent `Creating an empty file at ${token.path(path)}...`);
96
+ outputDebug(outputContent `Creating an empty file at ${outputToken.path(path)}...`);
97
97
  fsEnsureFileSync(path);
98
98
  }
99
99
  /**
@@ -103,7 +103,7 @@ export function touchFileSync(path) {
103
103
  * @param content - Content to be appended.
104
104
  */
105
105
  export async function appendFile(path, content) {
106
- debug(outputContent `Appending the following content to ${token.path(path)}:
106
+ outputDebug(outputContent `Appending the following content to ${outputToken.path(path)}:
107
107
  ${content
108
108
  .split('\n')
109
109
  .map((line) => ` ${line}`)
@@ -127,7 +127,7 @@ export function appendFileSync(path, data) {
127
127
  * @param data - Content to be written.
128
128
  */
129
129
  export async function writeFile(path, data) {
130
- debug(outputContent `Writing some content to file at ${token.path(path)}...`);
130
+ outputDebug(outputContent `Writing some content to file at ${outputToken.path(path)}...`);
131
131
  await fsWriteFile(path, data, { encoding: 'utf8' });
132
132
  }
133
133
  /**
@@ -137,7 +137,7 @@ export async function writeFile(path, data) {
137
137
  * @param data - Content to be written.
138
138
  */
139
139
  export function writeFileSync(path, data) {
140
- debug(outputContent `File-writing some content to file at ${token.path(path)}...`);
140
+ outputDebug(outputContent `File-writing some content to file at ${outputToken.path(path)}...`);
141
141
  fsWriteFileSync(path, data);
142
142
  }
143
143
  /**
@@ -146,7 +146,7 @@ export function writeFileSync(path, data) {
146
146
  * @param path - Path to the directory to be created.
147
147
  */
148
148
  export async function mkdir(path) {
149
- debug(outputContent `Creating directory at ${token.path(path)}...`);
149
+ outputDebug(outputContent `Creating directory at ${outputToken.path(path)}...`);
150
150
  await fsMkdir(path, { recursive: true });
151
151
  }
152
152
  /**
@@ -155,7 +155,7 @@ export async function mkdir(path) {
155
155
  * @param path - Path to the directory to be created.
156
156
  */
157
157
  export function mkdirSync(path) {
158
- debug(outputContent `Sync-creating directory at ${token.path(path)}...`);
158
+ outputDebug(outputContent `Sync-creating directory at ${outputToken.path(path)}...`);
159
159
  fsMkdirSync(path, { recursive: true });
160
160
  }
161
161
  /**
@@ -164,7 +164,7 @@ export function mkdirSync(path) {
164
164
  * @param path - Path to the file to be removed.
165
165
  */
166
166
  export async function removeFile(path) {
167
- debug(outputContent `Removing file at ${token.path(path)}...`);
167
+ outputDebug(outputContent `Removing file at ${outputToken.path(path)}...`);
168
168
  await fsRemove(path);
169
169
  }
170
170
  /**
@@ -173,7 +173,7 @@ export async function removeFile(path) {
173
173
  * @param path - Path to the file to be removed.
174
174
  */
175
175
  export function removeFileSync(path) {
176
- debug(outputContent `Sync-removing file at ${token.path(path)}...`);
176
+ outputDebug(outputContent `Sync-removing file at ${outputToken.path(path)}...`);
177
177
  fsRemoveSync(path);
178
178
  }
179
179
  /**
@@ -184,7 +184,7 @@ export function removeFileSync(path) {
184
184
  */
185
185
  export async function rmdir(path, options = {}) {
186
186
  const { default: del } = await import('del');
187
- debug(outputContent `Removing directory at ${token.path(path)}...`);
187
+ outputDebug(outputContent `Removing directory at ${outputToken.path(path)}...`);
188
188
  await del(path, { force: options.force });
189
189
  }
190
190
  /**
@@ -193,7 +193,7 @@ export async function rmdir(path, options = {}) {
193
193
  * @returns Path to the temporary directory.
194
194
  */
195
195
  export async function mkTmpDir() {
196
- debug(outputContent `Creating a temporary directory...`);
196
+ outputDebug(outputContent `Creating a temporary directory...`);
197
197
  const directory = await fsMkdtemp('tmp-');
198
198
  return directory;
199
199
  }
@@ -204,7 +204,7 @@ export async function mkTmpDir() {
204
204
  * @returns True if the path is a directory, false otherwise.
205
205
  */
206
206
  export async function isDirectory(path) {
207
- debug(outputContent `Checking if ${token.path(path)} is a directory...`);
207
+ outputDebug(outputContent `Checking if ${outputToken.path(path)} is a directory...`);
208
208
  return (await fsLstat(path)).isDirectory();
209
209
  }
210
210
  /**
@@ -214,7 +214,7 @@ export async function isDirectory(path) {
214
214
  * @returns The size of the file in bytes.
215
215
  */
216
216
  export async function fileSize(path) {
217
- debug(outputContent `Getting the size of file file at ${token.path(path)}...`);
217
+ outputDebug(outputContent `Getting the size of file file at ${outputToken.path(path)}...`);
218
218
  return (await fsStat(path)).size;
219
219
  }
220
220
  /**
@@ -224,7 +224,7 @@ export async function fileSize(path) {
224
224
  * @returns The size of the file in bytes.
225
225
  */
226
226
  export function fileSizeSync(path) {
227
- debug(outputContent `Sync-getting the size of file file at ${token.path(path)}...`);
227
+ outputDebug(outputContent `Sync-getting the size of file file at ${outputToken.path(path)}...`);
228
228
  return fsStatSync(path).size;
229
229
  }
230
230
  /**
@@ -243,7 +243,7 @@ export function createFileReadStream(path) {
243
243
  * @returns A unix timestamp.
244
244
  */
245
245
  export async function fileLastUpdated(path) {
246
- debug(outputContent `Getting last updated timestamp for file at ${token.path(path)}...`);
246
+ outputDebug(outputContent `Getting last updated timestamp for file at ${outputToken.path(path)}...`);
247
247
  return (await fsStat(path)).ctime;
248
248
  }
249
249
  /**