@shopify/cli-kit 4.8.5 → 4.9.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.
- package/dist/private/node/analytics.js +5 -3
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/status-checks.d.ts +7 -0
- package/dist/private/node/api/status-checks.js +11 -0
- package/dist/private/node/api/status-checks.js.map +1 -0
- package/dist/private/node/api.d.ts +15 -0
- package/dist/private/node/api.js +28 -0
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/command-event-context.d.ts +29 -0
- package/dist/private/node/command-event-context.js +43 -0
- package/dist/private/node/command-event-context.js.map +1 -0
- package/dist/private/node/command-event-output.d.ts +7 -0
- package/dist/private/node/command-event-output.js +16 -0
- package/dist/private/node/command-event-output.js.map +1 -0
- package/dist/private/node/command-json-schema.d.ts +10 -0
- package/dist/private/node/command-json-schema.js +38 -0
- package/dist/private/node/command-json-schema.js.map +1 -0
- package/dist/private/node/context/agent.d.ts +1 -0
- package/dist/private/node/context/agent.js +44 -0
- package/dist/private/node/context/agent.js.map +1 -0
- package/dist/private/node/json-error.d.ts +23 -0
- package/dist/private/node/json-error.js +123 -0
- package/dist/private/node/json-error.js.map +1 -0
- package/dist/private/node/output.js +3 -1
- package/dist/private/node/output.js.map +1 -1
- package/dist/private/node/output.test.d.ts +1 -0
- package/dist/private/node/output.test.js +74 -0
- package/dist/private/node/output.test.js.map +1 -0
- package/dist/private/node/session/device-authorization.js +49 -15
- package/dist/private/node/session/device-authorization.js.map +1 -1
- package/dist/private/node/session/validate.js +9 -22
- package/dist/private/node/session/validate.js.map +1 -1
- package/dist/private/node/ui/alert.d.ts +1 -1
- package/dist/private/node/ui/alert.js +29 -3
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +8 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js +54 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js +3 -3
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js +16 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.js +3 -2
- package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js +20 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.d.ts +2 -9
- package/dist/private/node/ui/components/Tasks.js +5 -44
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.js +3 -3
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +15 -1
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/token-item.d.ts +2 -0
- package/dist/private/node/ui/components/token-item.js +26 -0
- package/dist/private/node/ui/components/token-item.js.map +1 -1
- package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +3 -3
- package/dist/private/node/ui/hooks/use-async-and-unmount.js +2 -2
- package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -1
- package/dist/private/node/ui/tasks.d.ts +10 -0
- package/dist/private/node/ui/tasks.js +68 -0
- package/dist/private/node/ui/tasks.js.map +1 -0
- package/dist/public/common/command-events.d.ts +125 -0
- package/dist/public/common/command-events.js +54 -0
- package/dist/public/common/command-events.js.map +1 -0
- package/dist/public/common/json-output-schema.d.ts +10 -0
- package/dist/public/common/json-output-schema.js +17 -0
- package/dist/public/common/json-output-schema.js.map +1 -0
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.js +18 -1
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/app-management.d.ts +1 -0
- package/dist/public/node/api/app-management.js +4 -0
- package/dist/public/node/api/app-management.js.map +1 -1
- package/dist/public/node/api/bulk-operations/download-bulk-operation-results.d.ts +3 -3
- package/dist/public/node/api/bulk-operations/download-bulk-operation-results.js +5 -3
- package/dist/public/node/api/bulk-operations/download-bulk-operation-results.js.map +1 -1
- package/dist/public/node/base-command.d.ts +6 -0
- package/dist/public/node/base-command.js +34 -5
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli-launcher.js +20 -2
- package/dist/public/node/cli-launcher.js.map +1 -1
- package/dist/public/node/cli.d.ts +1 -0
- package/dist/public/node/cli.js +2 -0
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/command-events.d.ts +65 -0
- package/dist/public/node/command-events.js +71 -0
- package/dist/public/node/command-events.js.map +1 -0
- package/dist/public/node/context/local.d.ts +6 -0
- package/dist/public/node/context/local.js +10 -1
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.d.ts +6 -0
- package/dist/public/node/custom-oclif-loader.js +45 -19
- package/dist/public/node/custom-oclif-loader.js.map +1 -1
- package/dist/public/node/environment.d.ts +2 -1
- package/dist/public/node/environment.js +3 -2
- package/dist/public/node/environment.js.map +1 -1
- package/dist/public/node/error/index.d.ts +91 -0
- package/dist/public/node/error/index.js +266 -0
- package/dist/public/node/error/index.js.map +1 -0
- package/dist/public/node/error/schema.d.ts +472 -0
- package/dist/public/node/error/schema.js +54 -0
- package/dist/public/node/error/schema.js.map +1 -0
- package/dist/public/node/error/types.d.ts +9 -0
- package/dist/public/node/error/types.js +2 -0
- package/dist/public/node/error/types.js.map +1 -0
- package/dist/public/node/error.d.ts +1 -87
- package/dist/public/node/error.js +1 -252
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.d.ts +17 -3
- package/dist/public/node/fs.js +7 -5
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/json-output-schema.d.ts +26 -0
- package/dist/public/node/json-output-schema.js +30 -0
- package/dist/public/node/json-output-schema.js.map +1 -0
- package/dist/public/node/local-storage.d.ts +1 -0
- package/dist/public/node/local-storage.js +54 -21
- package/dist/public/node/local-storage.js.map +1 -1
- package/dist/public/node/monorail.d.ts +3 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/multiple-installation-warning.d.ts +1 -1
- package/dist/public/node/multiple-installation-warning.js +2 -3
- package/dist/public/node/multiple-installation-warning.js.map +1 -1
- package/dist/public/node/no-input.d.ts +11 -0
- package/dist/public/node/no-input.js +19 -0
- package/dist/public/node/no-input.js.map +1 -0
- package/dist/public/node/output.d.ts +6 -0
- package/dist/public/node/output.js +40 -0
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.js +3 -1
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/system.d.ts +2 -2
- package/dist/public/node/system.js +8 -4
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/testing/output.d.ts +30 -0
- package/dist/public/node/testing/output.js +83 -0
- package/dist/public/node/testing/output.js.map +1 -1
- package/dist/public/node/ui.d.ts +5 -1
- package/dist/public/node/ui.js +89 -5
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/upgrade.js +17 -2
- package/dist/public/node/upgrade.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,SAAS,IAAI,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAgBjC,KAAK,UAAU,oBAAoB,CAAC,WAAmC,O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,EAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAA;IACrE,UAAU,EAAE,CAAA;AACd,CAAC","sourcesContent":["import {isTruthy} from './context/utilities.js'\nimport {launchCLI as defaultLaunchCli} from './cli-launcher.js'\nimport {environmentVariables} from '../../private/node/constants.js'\nimport {Flags} from '@oclif/core'\nimport type {LazyCommandLoader} from './custom-oclif-loader.js'\n\n/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n /** Optional lazy command loader for on-demand command loading */\n lazyCommandLoader?: LazyCommandLoader\n}\n\nasync function exitIfOldNodeVersion(versions: NodeJS.ProcessVersions = process.versions) {\n const nodeVersion = versions.node\n const nodeMajorVersion = Number(nodeVersion.split('.')[0])\n\n const currentSupportedNodeVersion = 22\n if (nodeMajorVersion < currentSupportedNodeVersion) {\n const {renderError} = await import('./ui.js')\n renderError({\n headline: 'Upgrade to a supported Node version now.',\n body: [\n `Node ${nodeMajorVersion} has reached end-of-life and poses security risks. When you upgrade to a`,\n {\n link: {\n url: 'https://nodejs.dev/en/about/previous-releases',\n label: 'supported version',\n },\n },\n {char: ','},\n \"you'll be able to use Shopify CLI without interruption.\",\n ],\n })\n process.exit(1)\n }\n}\n\nfunction setupEnvironmentVariables(\n options: Pick<RunCLIOptions, 'development'>,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (argv.includes('--verbose')) {\n env.DEBUG = env.DEBUG ?? '*'\n }\n if (options.development) {\n env.SHOPIFY_CLI_ENV = env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\nfunction forceNoColor(argv: string[] = process.argv, env: NodeJS.ProcessEnv = process.env) {\n if (\n argv.includes('--no-color') ||\n argv.includes('--json') ||\n argv.includes('-j') ||\n isTruthy(env.NO_COLOR) ||\n isTruthy(env.SHOPIFY_FLAG_NO_COLOR) ||\n isTruthy(env[environmentVariables.json]) ||\n env.TERM === 'dumb'\n ) {\n env.FORCE_COLOR = '0'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(\n options: RunCLIOptions & {runInCreateMode?: boolean},\n launchCLI: (options: {moduleURL: string; lazyCommandLoader?: LazyCommandLoader}) => Promise<void> = defaultLaunchCli,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n setupEnvironmentVariables(options, argv, env)\n if (options.runInCreateMode) {\n await addInitToArgvWhenRunningCreateCLI(options, argv)\n }\n forceNoColor(argv, env)\n await exitIfOldNodeVersion(versions)\n return launchCLI({moduleURL: options.moduleURL, lazyCommandLoader: options.lazyCommandLoader})\n}\n\nasync function addInitToArgvWhenRunningCreateCLI(\n options: Pick<RunCLIOptions, 'moduleURL'>,\n argv: string[] = process.argv,\n): Promise<void> {\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('./path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex = argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n argv.splice(initIndex, 0, 'init')\n }\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(\n options: RunCLIOptions,\n launchCLI: (options: {moduleURL: string}) => Promise<void> = defaultLaunchCli,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n return runCLI({...options, runInCreateMode: true}, launchCLI, argv, env, versions)\n}\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n 'no-color': Flags.boolean({\n hidden: false,\n description: 'Disable color output.',\n env: 'SHOPIFY_FLAG_NO_COLOR',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the output. May include sensitive data.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\nexport const jsonFlag = {\n json: Flags.boolean({\n char: 'j',\n description: 'Output the result as JSON. Automatically disables color output.',\n hidden: false,\n default: false,\n env: environmentVariables.json,\n }),\n}\n\nexport const authAliasFlag = {\n 'auth-alias': Flags.string({\n description: 'Alias of the Shopify account to use for authentication.',\n env: 'SHOPIFY_FLAG_AUTH_ALIAS',\n }),\n}\n\n/**\n * Builds a `--port` flag that only accepts a valid port number. The flag parses its\n * value as an integer and rejects anything that isn't a whole number between 1 and\n * 65535, so commands fail with a clear message instead of crashing on an out-of-range\n * port. The accepted range is appended to the description so it shows up in `--help`.\n * @param options - Optional overrides for the flag's description, environment variable, and visibility.\n * @returns An oclif integer flag constrained to the valid port range.\n */\nexport const portFlag = (options: {description?: string; env?: string; hidden?: boolean} = {}) => {\n const description = [options.description, 'Must be between 1 and 65535.'].filter(Boolean).join(' ')\n return Flags.integer({min: 1, max: 65535, ...options, description})\n}\n\n/**\n * Marks a flag as required when the CLI cannot prompt for a value.\n *\n * The flag remains optional in interactive terminals. In non-interactive environments,\n * `BaseCommand` validates the flag automatically and the requirement is shown in `--help`.\n * Use `BaseCommand.nonTTYFlagRequirements` for conditional or alternative requirements.\n *\n * @param flag - An oclif flag definition.\n * @returns A new flag definition annotated for non-interactive validation and help output.\n */\nexport function requiredIfNonInteractive<TFlag extends {description?: string}>(flag: TFlag): TFlag {\n const existingDescription = flag.description?.trimEnd()\n const punctuatedDescription =\n existingDescription && !existingDescription.endsWith('.') ? `${existingDescription}.` : existingDescription\n const description = [punctuatedDescription, 'Required if non interactive.'].filter(Boolean).join(' ')\n\n return {...flag, description, requiredIfNonInteractive: true}\n}\n\n/**\n * Clear the CLI cache, used to store some API responses and handle notifications status\n */\nexport async function clearCache(): Promise<void> {\n const {cacheClear} = await import('../../private/node/conf-store.js')\n cacheClear()\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AACzC,OAAO,EAAC,SAAS,IAAI,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAgBjC,KAAK,UAAU,oBAAoB,CAAC,WAAmC,OAAO,CAAC,QAAQ;IACrF,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAA;IACjC,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAE1D,MAAM,2BAA2B,GAAG,EAAE,CAAA;IACtC,IAAI,gBAAgB,GAAG,2BAA2B,EAAE,CAAC;QACnD,MAAM,EAAC,WAAW,EAAC,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAA;QAC7C,WAAW,CAAC;YACV,QAAQ,EAAE,0CAA0C;YACpD,IAAI,EAAE;gBACJ,QAAQ,gBAAgB,0EAA0E;gBAClG;oBACE,IAAI,EAAE;wBACJ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C,UAAkE,EAAE,EAAE,EAAE;IAC/F,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACnG,OAAO,KAAK,CAAC,OAAO,CAAC,EAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,WAAW,EAAC,CAAC,CAAA;AACrE,CAAC,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CAAuC,IAAW;IACxF,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,CAAA;IACvD,MAAM,qBAAqB,GACzB,mBAAmB,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,mBAAmB,GAAG,CAAC,CAAC,CAAC,mBAAmB,CAAA;IAC7G,MAAM,WAAW,GAAG,CAAC,qBAAqB,EAAE,8BAA8B,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAErG,OAAO,EAAC,GAAG,IAAI,EAAE,WAAW,EAAE,wBAAwB,EAAE,IAAI,EAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAA;IACrE,UAAU,EAAE,CAAA;AACd,CAAC","sourcesContent":["import {isTruthy} from './context/utilities.js'\nimport {noInputFlag} from './no-input.js'\nimport {launchCLI as defaultLaunchCli} from './cli-launcher.js'\nimport {environmentVariables} from '../../private/node/constants.js'\nimport {Flags} from '@oclif/core'\nimport type {LazyCommandLoader} from './custom-oclif-loader.js'\n\n/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n /** Optional lazy command loader for on-demand command loading */\n lazyCommandLoader?: LazyCommandLoader\n}\n\nasync function exitIfOldNodeVersion(versions: NodeJS.ProcessVersions = process.versions) {\n const nodeVersion = versions.node\n const nodeMajorVersion = Number(nodeVersion.split('.')[0])\n\n const currentSupportedNodeVersion = 22\n if (nodeMajorVersion < currentSupportedNodeVersion) {\n const {renderError} = await import('./ui.js')\n renderError({\n headline: 'Upgrade to a supported Node version now.',\n body: [\n `Node ${nodeMajorVersion} has reached end-of-life and poses security risks. When you upgrade to a`,\n {\n link: {\n url: 'https://nodejs.dev/en/about/previous-releases',\n label: 'supported version',\n },\n },\n {char: ','},\n \"you'll be able to use Shopify CLI without interruption.\",\n ],\n })\n process.exit(1)\n }\n}\n\nfunction setupEnvironmentVariables(\n options: Pick<RunCLIOptions, 'development'>,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (argv.includes('--verbose')) {\n env.DEBUG = env.DEBUG ?? '*'\n }\n if (options.development) {\n env.SHOPIFY_CLI_ENV = env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\nfunction forceNoColor(argv: string[] = process.argv, env: NodeJS.ProcessEnv = process.env) {\n if (\n argv.includes('--no-color') ||\n argv.includes('--json') ||\n argv.includes('-j') ||\n isTruthy(env.NO_COLOR) ||\n isTruthy(env.SHOPIFY_FLAG_NO_COLOR) ||\n isTruthy(env[environmentVariables.json]) ||\n env.TERM === 'dumb'\n ) {\n env.FORCE_COLOR = '0'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(\n options: RunCLIOptions & {runInCreateMode?: boolean},\n launchCLI: (options: {moduleURL: string; lazyCommandLoader?: LazyCommandLoader}) => Promise<void> = defaultLaunchCli,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n setupEnvironmentVariables(options, argv, env)\n if (options.runInCreateMode) {\n await addInitToArgvWhenRunningCreateCLI(options, argv)\n }\n forceNoColor(argv, env)\n await exitIfOldNodeVersion(versions)\n return launchCLI({moduleURL: options.moduleURL, lazyCommandLoader: options.lazyCommandLoader})\n}\n\nasync function addInitToArgvWhenRunningCreateCLI(\n options: Pick<RunCLIOptions, 'moduleURL'>,\n argv: string[] = process.argv,\n): Promise<void> {\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('./path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex = argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n argv.splice(initIndex, 0, 'init')\n }\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(\n options: RunCLIOptions,\n launchCLI: (options: {moduleURL: string}) => Promise<void> = defaultLaunchCli,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n return runCLI({...options, runInCreateMode: true}, launchCLI, argv, env, versions)\n}\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n ...noInputFlag,\n 'no-color': Flags.boolean({\n hidden: false,\n description: 'Disable color output.',\n env: 'SHOPIFY_FLAG_NO_COLOR',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the output. May include sensitive data.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\nexport const jsonFlag = {\n json: Flags.boolean({\n char: 'j',\n description: 'Output the result as JSON. Automatically disables color output.',\n hidden: false,\n default: false,\n env: environmentVariables.json,\n }),\n}\n\nexport const authAliasFlag = {\n 'auth-alias': Flags.string({\n description: 'Alias of the Shopify account to use for authentication.',\n env: 'SHOPIFY_FLAG_AUTH_ALIAS',\n }),\n}\n\n/**\n * Builds a `--port` flag that only accepts a valid port number. The flag parses its\n * value as an integer and rejects anything that isn't a whole number between 1 and\n * 65535, so commands fail with a clear message instead of crashing on an out-of-range\n * port. The accepted range is appended to the description so it shows up in `--help`.\n * @param options - Optional overrides for the flag's description, environment variable, and visibility.\n * @returns An oclif integer flag constrained to the valid port range.\n */\nexport const portFlag = (options: {description?: string; env?: string; hidden?: boolean} = {}) => {\n const description = [options.description, 'Must be between 1 and 65535.'].filter(Boolean).join(' ')\n return Flags.integer({min: 1, max: 65535, ...options, description})\n}\n\n/**\n * Marks a flag as required when the CLI cannot prompt for a value.\n *\n * The flag remains optional in interactive terminals. In non-interactive environments,\n * `BaseCommand` validates the flag automatically and the requirement is shown in `--help`.\n * Use `BaseCommand.nonTTYFlagRequirements` for conditional or alternative requirements.\n *\n * @param flag - An oclif flag definition.\n * @returns A new flag definition annotated for non-interactive validation and help output.\n */\nexport function requiredIfNonInteractive<TFlag extends {description?: string}>(flag: TFlag): TFlag {\n const existingDescription = flag.description?.trimEnd()\n const punctuatedDescription =\n existingDescription && !existingDescription.endsWith('.') ? `${existingDescription}.` : existingDescription\n const description = [punctuatedDescription, 'Required if non interactive.'].filter(Boolean).join(' ')\n\n return {...flag, description, requiredIfNonInteractive: true}\n}\n\n/**\n * Clear the CLI cache, used to store some API responses and handle notifications status\n */\nexport async function clearCache(): Promise<void> {\n const {cacheClear} = await import('../../private/node/conf-store.js')\n cacheClear()\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type CommandEvent } from '../common/command-events.js';
|
|
2
|
+
export { commandEventOutputMode, emitCommandEvent, runWithCommandEvents, type CommandEventOutputMode, } from '../../private/node/command-event-context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Runs the complete CLI lifecycle with the event presentation selected by its arguments.
|
|
5
|
+
*
|
|
6
|
+
* @param argv - The command arguments used to determine whether JSON output is enabled.
|
|
7
|
+
* @param execute - The command lifecycle to run.
|
|
8
|
+
* @returns The result of the command lifecycle.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runWithCommandEventsForCommand<TResult>(argv: string[], execute: () => TResult): TResult;
|
|
11
|
+
export declare const commandEventOutputSchema: import("./json-output-schema.js").JsonOutputSchema<import("zod").ZodDiscriminatedUnion<"type", [import("zod").ZodObject<{
|
|
12
|
+
type: import("zod").ZodLiteral<"diagnostic">;
|
|
13
|
+
timestamp: import("zod").ZodString;
|
|
14
|
+
level: import("zod").ZodEnum<["debug", "info", "warning", "error"]>;
|
|
15
|
+
message: import("zod").ZodString;
|
|
16
|
+
code: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
}, "strict", import("zod").ZodTypeAny, {
|
|
18
|
+
type: "diagnostic";
|
|
19
|
+
message: string;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
level: "info" | "error" | "debug" | "warning";
|
|
22
|
+
code?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
type: "diagnostic";
|
|
25
|
+
message: string;
|
|
26
|
+
timestamp: string;
|
|
27
|
+
level: "info" | "error" | "debug" | "warning";
|
|
28
|
+
code?: string | undefined;
|
|
29
|
+
}>, import("zod").ZodObject<{
|
|
30
|
+
type: import("zod").ZodLiteral<"progress">;
|
|
31
|
+
timestamp: import("zod").ZodString;
|
|
32
|
+
status: import("zod").ZodEnum<["started", "updated", "retrying", "completed", "failed"]>;
|
|
33
|
+
operation: import("zod").ZodString;
|
|
34
|
+
message: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
|
+
current: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
36
|
+
total: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
37
|
+
}, "strict", import("zod").ZodTypeAny, {
|
|
38
|
+
type: "progress";
|
|
39
|
+
status: "started" | "updated" | "retrying" | "completed" | "failed";
|
|
40
|
+
timestamp: string;
|
|
41
|
+
operation: string;
|
|
42
|
+
message?: string | undefined;
|
|
43
|
+
current?: number | undefined;
|
|
44
|
+
total?: number | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
type: "progress";
|
|
47
|
+
status: "started" | "updated" | "retrying" | "completed" | "failed";
|
|
48
|
+
timestamp: string;
|
|
49
|
+
operation: string;
|
|
50
|
+
message?: string | undefined;
|
|
51
|
+
current?: number | undefined;
|
|
52
|
+
total?: number | undefined;
|
|
53
|
+
}>]>>;
|
|
54
|
+
/**
|
|
55
|
+
* Renders a command side event to stderr using the existing CLI output behavior.
|
|
56
|
+
*
|
|
57
|
+
* @param event - The event to render.
|
|
58
|
+
*/
|
|
59
|
+
export declare function renderCommandEvent(event: CommandEvent): void;
|
|
60
|
+
/**
|
|
61
|
+
* Renders a command side event as compact JSON to stderr.
|
|
62
|
+
*
|
|
63
|
+
* @param event - The event to render.
|
|
64
|
+
*/
|
|
65
|
+
export declare function renderCommandEventAsJson(event: CommandEvent): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { outputDebug, outputInfo, outputWarn } from './output.js';
|
|
2
|
+
import { jsonOutputEnabled } from './environment.js';
|
|
3
|
+
import { defineJsonOutputSchema } from './json-output-schema.js';
|
|
4
|
+
import { commandDiagnosticEventSchema, commandEventSchema, commandProgressEventSchema, } from '../common/command-events.js';
|
|
5
|
+
import { outputCommandEventAsJson } from '../../private/node/command-event-output.js';
|
|
6
|
+
import { output } from '../../private/node/output.js';
|
|
7
|
+
import { commandEventOutputMode, runWithCommandEvents } from '../../private/node/command-event-context.js';
|
|
8
|
+
export { commandEventOutputMode, emitCommandEvent, runWithCommandEvents, } from '../../private/node/command-event-context.js';
|
|
9
|
+
/**
|
|
10
|
+
* Runs the complete CLI lifecycle with the event presentation selected by its arguments.
|
|
11
|
+
*
|
|
12
|
+
* @param argv - The command arguments used to determine whether JSON output is enabled.
|
|
13
|
+
* @param execute - The command lifecycle to run.
|
|
14
|
+
* @returns The result of the command lifecycle.
|
|
15
|
+
*/
|
|
16
|
+
export function runWithCommandEventsForCommand(argv, execute) {
|
|
17
|
+
if (commandEventOutputMode() !== undefined)
|
|
18
|
+
return execute();
|
|
19
|
+
const outputMode = jsonOutputEnabled(process.env, argv) ? 'json' : 'text';
|
|
20
|
+
return runWithCommandEvents({
|
|
21
|
+
outputMode,
|
|
22
|
+
sink: outputMode === 'json'
|
|
23
|
+
? renderCommandEventAsJson
|
|
24
|
+
: (event, options) => {
|
|
25
|
+
if (!options?.alreadyRendered)
|
|
26
|
+
renderCommandEvent(event);
|
|
27
|
+
},
|
|
28
|
+
}, execute);
|
|
29
|
+
}
|
|
30
|
+
export const commandEventOutputSchema = defineJsonOutputSchema({
|
|
31
|
+
name: 'CommandEvent',
|
|
32
|
+
schema: commandEventSchema,
|
|
33
|
+
definitions: {
|
|
34
|
+
CommandDiagnosticEvent: commandDiagnosticEventSchema,
|
|
35
|
+
CommandProgressEvent: commandProgressEventSchema,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Renders a command side event to stderr using the existing CLI output behavior.
|
|
40
|
+
*
|
|
41
|
+
* @param event - The event to render.
|
|
42
|
+
*/
|
|
43
|
+
export function renderCommandEvent(event) {
|
|
44
|
+
if (event.type === 'progress') {
|
|
45
|
+
outputInfo(event.message ?? event.operation);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
switch (event.level) {
|
|
49
|
+
case 'debug':
|
|
50
|
+
outputDebug(event.message);
|
|
51
|
+
break;
|
|
52
|
+
case 'info':
|
|
53
|
+
outputInfo(event.message);
|
|
54
|
+
break;
|
|
55
|
+
case 'warning':
|
|
56
|
+
outputWarn(event.message);
|
|
57
|
+
break;
|
|
58
|
+
case 'error':
|
|
59
|
+
output(event.message, 'error');
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Renders a command side event as compact JSON to stderr.
|
|
65
|
+
*
|
|
66
|
+
* @param event - The event to render.
|
|
67
|
+
*/
|
|
68
|
+
export function renderCommandEventAsJson(event) {
|
|
69
|
+
outputCommandEventAsJson(event);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=command-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-events.js","sourceRoot":"","sources":["../../../src/public/node/command-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,sBAAsB,EAAC,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,0BAA0B,GAE3B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAC,wBAAwB,EAAC,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAA;AACnD,OAAO,EAAC,sBAAsB,EAAE,oBAAoB,EAAC,MAAM,6CAA6C,CAAA;AAExG,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,6CAA6C,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAAU,IAAc,EAAE,OAAsB;IAC5F,IAAI,sBAAsB,EAAE,KAAK,SAAS;QAAE,OAAO,OAAO,EAAE,CAAA;IAE5D,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAA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jsonOutputEnabled} from './environment.js'\nimport {defineJsonOutputSchema} from './json-output-schema.js'\nimport {\n commandDiagnosticEventSchema,\n commandEventSchema,\n commandProgressEventSchema,\n type CommandEvent,\n} from '../common/command-events.js'\nimport {outputCommandEventAsJson} from '../../private/node/command-event-output.js'\nimport {output} from '../../private/node/output.js'\nimport {commandEventOutputMode, runWithCommandEvents} from '../../private/node/command-event-context.js'\n\nexport {\n commandEventOutputMode,\n emitCommandEvent,\n runWithCommandEvents,\n type CommandEventOutputMode,\n} from '../../private/node/command-event-context.js'\n\n/**\n * Runs the complete CLI lifecycle with the event presentation selected by its arguments.\n *\n * @param argv - The command arguments used to determine whether JSON output is enabled.\n * @param execute - The command lifecycle to run.\n * @returns The result of the command lifecycle.\n */\nexport function runWithCommandEventsForCommand<TResult>(argv: string[], execute: () => TResult): TResult {\n if (commandEventOutputMode() !== undefined) return execute()\n\n const outputMode = jsonOutputEnabled(process.env, argv) ? 'json' : 'text'\n return runWithCommandEvents(\n {\n outputMode,\n sink:\n outputMode === 'json'\n ? renderCommandEventAsJson\n : (event, options) => {\n if (!options?.alreadyRendered) renderCommandEvent(event)\n },\n },\n execute,\n )\n}\n\nexport const commandEventOutputSchema = defineJsonOutputSchema({\n name: 'CommandEvent',\n schema: commandEventSchema,\n definitions: {\n CommandDiagnosticEvent: commandDiagnosticEventSchema,\n CommandProgressEvent: commandProgressEventSchema,\n },\n})\n\n/**\n * Renders a command side event to stderr using the existing CLI output behavior.\n *\n * @param event - The event to render.\n */\nexport function renderCommandEvent(event: CommandEvent): void {\n if (event.type === 'progress') {\n outputInfo(event.message ?? event.operation)\n return\n }\n\n switch (event.level) {\n case 'debug':\n outputDebug(event.message)\n break\n case 'info':\n outputInfo(event.message)\n break\n case 'warning':\n outputWarn(event.message)\n break\n case 'error':\n output(event.message, 'error')\n break\n }\n}\n\n/**\n * Renders a command side event as compact JSON to stderr.\n *\n * @param event - The event to render.\n */\nexport function renderCommandEventAsJson(event: CommandEvent): void {\n outputCommandEventAsJson(event)\n}\n"]}
|
|
@@ -11,6 +11,12 @@ export declare function isTerminalInteractive(): boolean;
|
|
|
11
11
|
* @returns The path to the user's home directory.
|
|
12
12
|
*/
|
|
13
13
|
export declare function homeDirectory(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Clears the memoized result of isUnitTest so the environment variable is re-read.
|
|
16
|
+
*
|
|
17
|
+
* Only intended for test helpers that temporarily toggle unit-test detection.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resetMemoizedIsUnitTest(): void;
|
|
14
20
|
/**
|
|
15
21
|
* Returns true if the CLI is running in debug mode.
|
|
16
22
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isTruthy } from './utilities.js';
|
|
2
|
+
import { isInputDisabled } from '../no-input.js';
|
|
2
3
|
import { getCIMetadata, isSet } from '../../../private/node/context/utilities.js';
|
|
3
4
|
import { defaultThemeKitAccessDomain, environmentVariables, pathConstants } from '../../../private/node/constants.js';
|
|
4
5
|
import { randomUUID } from 'crypto';
|
|
@@ -19,7 +20,7 @@ async function lazyExec(command, args) {
|
|
|
19
20
|
* @returns True if the terminal is interactive.
|
|
20
21
|
*/
|
|
21
22
|
export function isTerminalInteractive() {
|
|
22
|
-
return Boolean(process.stdout.isTTY && process.env.TERM !== 'dumb' && !('CI' in process.env));
|
|
23
|
+
return Boolean(!isInputDisabled() && process.stdout.isTTY && process.env.TERM !== 'dumb' && !('CI' in process.env));
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Returns the path to the user's home directory.
|
|
@@ -37,6 +38,14 @@ let memoizedIsVerbose;
|
|
|
37
38
|
* Memoized value for the unit test check.
|
|
38
39
|
*/
|
|
39
40
|
let memoizedIsUnitTest;
|
|
41
|
+
/**
|
|
42
|
+
* Clears the memoized result of isUnitTest so the environment variable is re-read.
|
|
43
|
+
*
|
|
44
|
+
* Only intended for test helpers that temporarily toggle unit-test detection.
|
|
45
|
+
*/
|
|
46
|
+
export function resetMemoizedIsUnitTest() {
|
|
47
|
+
memoizedIsUnitTest = undefined;
|
|
48
|
+
}
|
|
40
49
|
/**
|
|
41
50
|
* Returns true if the CLI is running in debug mode.
|
|
42
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACnH,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,IAAI,CAAA;AAE7C,4FAA4F;AAC5F,qFAAqF;AACrF,KAAK,UAAU,cAAc,CAAC,IAAY;IACxC,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAc;IACrD,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAC3C,MAAM,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AAC/F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;GAEG;AACH,IAAI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,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,QAAQ,GAAG,mBAAmB,CAAA;IACpC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;SACzD,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,KAAK,EAAsC,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAA;IAClG,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAChG,OAAO,aAAa,EAAE,GAAG,IAAI,UAAU,EAAE,CAAA;AAC3C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;IAE7D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAA;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAA;AACnF,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {defaultThemeKitAccessDomain, environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {randomUUID} from 'crypto'\nimport {homedir, networkInterfaces} from 'os'\n\n// Dynamic imports to avoid circular dependency: context/local → fs → output → context/local\n// fileExists and exec are only used in specific async functions, not at module init.\nasync function lazyFileExists(path: string): Promise<boolean> {\n const {fileExists} = await import('../fs.js')\n return fileExists(path)\n}\n\nasync function lazyExec(command: string, args: string[]): Promise<void> {\n const {exec} = await import('../system.js')\n await exec(command, args)\n}\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 Boolean(process.stdout.isTTY && process.env.TERM !== 'dumb' && !('CI' in process.env))\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 * Memoized value for the verbose check.\n */\nlet memoizedIsVerbose: boolean | undefined\n\n/**\n * Memoized value for the unit test check.\n */\nlet memoizedIsUnitTest: boolean | undefined\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 if (env === process.env) {\n // Memoize the result to avoid repeated scans of process.argv and env lookups\n // in high-frequency paths like outputDebug.\n return (memoizedIsVerbose ??= isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose'))\n }\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).\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 lazyFileExists(pathConstants.executables.dev)\n return devInstalled\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 if (env === process.env) {\n // Memoize the result as SHOPIFY_UNIT_TEST is static during execution\n // and checked frequently to suppress output.\n return (memoizedIsUnitTest ??= isTruthy(env[environmentVariables.unitTest]))\n }\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 or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return (\n isTruthy(env[environmentVariables.noAnalytics]) ||\n isTruthy(env[environmentVariables.optOutInstrumentation]) ||\n isDevelopment(env)\n )\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 can run the \"doctor-release\" command.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI can run the \"doctor-release\" command.\n */\nexport function canRunDoctorRelease(env = process.env): boolean {\n return isTruthy(env[environmentVariables.doctor])\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: '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 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 lazyExec('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 } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found, preferring external interfaces. Returns a random\n * value when no interface has a MAC, so callers hashing it as a device id don't group\n * unrelated devices together.\n *\n * @returns Mac address.\n */\nexport async function macAddress(): Promise<string> {\n const emptyMac = '00:00:00:00:00:00'\n const interfacesWithMac = Object.values(networkInterfaces())\n .flat()\n .filter((iface): iface is NonNullable<typeof iface> => Boolean(iface && iface.mac !== emptyMac))\n const bestInterface = interfacesWithMac.find((iface) => !iface.internal) ?? interfacesWithMac[0]\n return bestInterface?.mac ?? randomUUID()\n}\n\n/**\n * Get the domain for theme kit access.\n *\n * It can be overridden via the SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN environment\n * variable.\n *\n * @param env - The environment variables from the environment of the process.\n *\n * @returns The domain for theme kit access.\n */\nexport function getThemeKitAccessDomain(env = process.env): string {\n const domain = env[environmentVariables.themeKitAccessDomain]\n\n return isSet(domain) ? domain : defaultThemeKitAccessDomain\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 {\n const domain = env[environmentVariables.otelURL]\n\n return isSet(domain) ? domain : '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,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACnH,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,IAAI,CAAA;AAE7C,4FAA4F;AAC5F,qFAAqF;AACrF,KAAK,UAAU,cAAc,CAAC,IAAY;IACxC,MAAM,EAAC,UAAU,EAAC,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAA;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAc;IACrD,MAAM,EAAC,IAAI,EAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAC3C,MAAM,IAAI,CA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AC,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAA;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAA;AACnF,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {isInputDisabled} from '../no-input.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {defaultThemeKitAccessDomain, environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {randomUUID} from 'crypto'\nimport {homedir, networkInterfaces} from 'os'\n\n// Dynamic imports to avoid circular dependency: context/local → fs → output → context/local\n// fileExists and exec are only used in specific async functions, not at module init.\nasync function lazyFileExists(path: string): Promise<boolean> {\n const {fileExists} = await import('../fs.js')\n return fileExists(path)\n}\n\nasync function lazyExec(command: string, args: string[]): Promise<void> {\n const {exec} = await import('../system.js')\n await exec(command, args)\n}\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 Boolean(!isInputDisabled() && process.stdout.isTTY && process.env.TERM !== 'dumb' && !('CI' in process.env))\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 * Memoized value for the verbose check.\n */\nlet memoizedIsVerbose: boolean | undefined\n\n/**\n * Memoized value for the unit test check.\n */\nlet memoizedIsUnitTest: boolean | undefined\n\n/**\n * Clears the memoized result of isUnitTest so the environment variable is re-read.\n *\n * Only intended for test helpers that temporarily toggle unit-test detection.\n */\nexport function resetMemoizedIsUnitTest(): void {\n memoizedIsUnitTest = undefined\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 if (env === process.env) {\n // Memoize the result to avoid repeated scans of process.argv and env lookups\n // in high-frequency paths like outputDebug.\n return (memoizedIsVerbose ??= isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose'))\n }\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).\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 lazyFileExists(pathConstants.executables.dev)\n return devInstalled\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 if (env === process.env) {\n // Memoize the result as SHOPIFY_UNIT_TEST is static during execution\n // and checked frequently to suppress output.\n return (memoizedIsUnitTest ??= isTruthy(env[environmentVariables.unitTest]))\n }\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 or OPT_OUT_INSTRUMENTATION is truthy, or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return (\n isTruthy(env[environmentVariables.noAnalytics]) ||\n isTruthy(env[environmentVariables.optOutInstrumentation]) ||\n isDevelopment(env)\n )\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 can run the \"doctor-release\" command.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI can run the \"doctor-release\" command.\n */\nexport function canRunDoctorRelease(env = process.env): boolean {\n return isTruthy(env[environmentVariables.doctor])\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: '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 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 lazyExec('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 } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found, preferring external interfaces. Returns a random\n * value when no interface has a MAC, so callers hashing it as a device id don't group\n * unrelated devices together.\n *\n * @returns Mac address.\n */\nexport async function macAddress(): Promise<string> {\n const emptyMac = '00:00:00:00:00:00'\n const interfacesWithMac = Object.values(networkInterfaces())\n .flat()\n .filter((iface): iface is NonNullable<typeof iface> => Boolean(iface && iface.mac !== emptyMac))\n const bestInterface = interfacesWithMac.find((iface) => !iface.internal) ?? interfacesWithMac[0]\n return bestInterface?.mac ?? randomUUID()\n}\n\n/**\n * Get the domain for theme kit access.\n *\n * It can be overridden via the SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN environment\n * variable.\n *\n * @param env - The environment variables from the environment of the process.\n *\n * @returns The domain for theme kit access.\n */\nexport function getThemeKitAccessDomain(env = process.env): string {\n const domain = env[environmentVariables.themeKitAccessDomain]\n\n return isSet(domain) ? domain : defaultThemeKitAccessDomain\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 {\n const domain = env[environmentVariables.otelURL]\n\n return isSet(domain) ? domain : 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
|
|
@@ -17,6 +17,12 @@ export declare class ShopifyConfig extends Config {
|
|
|
17
17
|
* @param loader - The lazy command loader function.
|
|
18
18
|
*/
|
|
19
19
|
setLazyCommandLoader(loader: LazyCommandLoader): void;
|
|
20
|
+
/**
|
|
21
|
+
* Override load to protect oclif's shell detection from a failing OS user lookup.
|
|
22
|
+
*
|
|
23
|
+
* @returns A promise that resolves once the config is loaded.
|
|
24
|
+
*/
|
|
25
|
+
load(): Promise<void>;
|
|
20
26
|
/**
|
|
21
27
|
* Override runCommand to use lazy loading when available.
|
|
22
28
|
* Instead of calling cmd.load() which triggers loading ALL commands via index.js,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { runWithCommandEventsForCommand } from './command-events.js';
|
|
1
2
|
import { Config } from '@oclif/core';
|
|
3
|
+
import os from 'os';
|
|
2
4
|
/**
|
|
3
5
|
* Subclass of oclif's Config that loads command classes on demand for faster CLI startup.
|
|
4
6
|
*/
|
|
@@ -13,6 +15,15 @@ export class ShopifyConfig extends Config {
|
|
|
13
15
|
setLazyCommandLoader(loader) {
|
|
14
16
|
this.lazyCommandLoader = loader;
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Override load to protect oclif's shell detection from a failing OS user lookup.
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves once the config is loaded.
|
|
22
|
+
*/
|
|
23
|
+
async load() {
|
|
24
|
+
setShellVariableWhenUserLookupFails();
|
|
25
|
+
return super.load();
|
|
26
|
+
}
|
|
16
27
|
/**
|
|
17
28
|
* Override runCommand to use lazy loading when available.
|
|
18
29
|
* Instead of calling cmd.load() which triggers loading ALL commands via index.js,
|
|
@@ -24,25 +35,40 @@ export class ShopifyConfig extends Config {
|
|
|
24
35
|
* @returns The command result.
|
|
25
36
|
*/
|
|
26
37
|
async runCommand(id, argv = [], cachedCommand = null) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
return runWithCommandEventsForCommand(argv, async () => {
|
|
39
|
+
if (!this.lazyCommandLoader) {
|
|
40
|
+
return super.runCommand(id, argv, cachedCommand);
|
|
41
|
+
}
|
|
42
|
+
const cmd = cachedCommand ?? this.findCommand(id);
|
|
43
|
+
if (!cmd) {
|
|
44
|
+
return super.runCommand(id, argv, cachedCommand);
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
const commandClass = (await this.lazyCommandLoader(id));
|
|
48
|
+
if (!commandClass) {
|
|
49
|
+
return super.runCommand(id, argv, cachedCommand);
|
|
50
|
+
}
|
|
51
|
+
commandClass.id = id;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
commandClass.plugin = cmd.plugin ?? this.rootPlugin;
|
|
54
|
+
await this.runHook('prerun', { argv, Command: commandClass });
|
|
55
|
+
const result = (await commandClass.run(argv, this));
|
|
56
|
+
await this.runHook('postrun', { argv, Command: commandClass, result });
|
|
57
|
+
return result;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// oclif reads SHELL and falls back to os.userInfo(), which throws when the OS can't resolve the current
|
|
62
|
+
// user, killing the CLI during load. Remove once oclif guards that call.
|
|
63
|
+
function setShellVariableWhenUserLookupFails() {
|
|
64
|
+
if (process.env.SHELL !== undefined)
|
|
65
|
+
return;
|
|
66
|
+
try {
|
|
67
|
+
os.userInfo();
|
|
68
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
process.env.SHELL = 'unknown';
|
|
46
72
|
}
|
|
47
73
|
}
|
|
48
74
|
//# sourceMappingURL=custom-oclif-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-oclif-loader.js","sourceRoot":"","sources":["../../../src/public/node/custom-oclif-loader.ts"],"names":[],"mappings":"AAA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AAU,CAAI,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,CAAA;YACrD,CAAC;YAED,YAAY,CAAC,EAAE,GAAG,EAAE,CAAA;YACpB,8DAA8D;YAC9D,YAAY,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,IAAK,IAAY,CAAC,UAAU,CAAA;YAC5D,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,YAAY,EAAC,CAAC,CAAA;YAC3D,MAAM,MAAM,GAAG,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAM,CAAA;YACxD,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAC,CAAC,CAAA;YACpE,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,wGAAwG;AACxG,yEAAyE;AACzE,SAAS,mCAAmC;IAC1C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS;QAAE,OAAM;IAE3C,IAAI,CAAC;QACH,EAAE,CAAC,QAAQ,EAAE,CAAA;QACb,qDAAqD;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,CAAA;IAC/B,CAAC;AACH,CAAC","sourcesContent":["import {runWithCommandEventsForCommand} from './command-events.js'\nimport {Command, Config} from '@oclif/core'\nimport os from 'os'\n\n/**\n * Optional lazy command loader function.\n * If set, ShopifyConfig will use it to load individual commands on demand\n * instead of importing the entire COMMANDS module (which triggers loading all packages).\n */\nexport type LazyCommandLoader = (id: string) => Promise<typeof Command | undefined>\n\n/**\n * Subclass of oclif's Config that loads command classes on demand for faster CLI startup.\n */\nexport class ShopifyConfig extends Config {\n private lazyCommandLoader?: LazyCommandLoader\n\n /**\n * Set a lazy command loader that will be used to load individual command classes on demand,\n * bypassing the default oclif behavior of importing the entire COMMANDS module.\n *\n * @param loader - The lazy command loader function.\n */\n setLazyCommandLoader(loader: LazyCommandLoader): void {\n this.lazyCommandLoader = loader\n }\n\n /**\n * Override load to protect oclif's shell detection from a failing OS user lookup.\n *\n * @returns A promise that resolves once the config is loaded.\n */\n async load(): Promise<void> {\n setShellVariableWhenUserLookupFails()\n return super.load()\n }\n\n /**\n * Override runCommand to use lazy loading when available.\n * Instead of calling cmd.load() which triggers loading ALL commands via index.js,\n * we directly import only the needed command module.\n *\n * @param id - The command ID to run.\n * @param argv - The arguments to pass to the command.\n * @param cachedCommand - An optional cached command loadable.\n * @returns The command result.\n */\n async runCommand<T = unknown>(\n id: string,\n argv: string[] = [],\n cachedCommand: Command.Loadable | null = null,\n ): Promise<T> {\n return runWithCommandEventsForCommand(argv, async () => {\n if (!this.lazyCommandLoader) {\n return super.runCommand<T>(id, argv, cachedCommand)\n }\n\n const cmd = cachedCommand ?? this.findCommand(id)\n if (!cmd) {\n return super.runCommand<T>(id, argv, cachedCommand)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const commandClass = (await this.lazyCommandLoader(id)) as any\n if (!commandClass) {\n return super.runCommand<T>(id, argv, cachedCommand)\n }\n\n commandClass.id = id\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n commandClass.plugin = cmd.plugin ?? (this as any).rootPlugin\n await this.runHook('prerun', {argv, Command: commandClass})\n const result = (await commandClass.run(argv, this)) as T\n await this.runHook('postrun', {argv, Command: commandClass, result})\n return result\n })\n }\n}\n\n// oclif reads SHELL and falls back to os.userInfo(), which throws when the OS can't resolve the current\n// user, killing the CLI during load. Remove once oclif guards that call.\nfunction setShellVariableWhenUserLookupFails(): void {\n if (process.env.SHELL !== undefined) return\n\n try {\n os.userInfo()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n process.env.SHELL = 'unknown'\n }\n}\n"]}
|
|
@@ -42,9 +42,10 @@ export declare function getIdentityTokenInformation(): {
|
|
|
42
42
|
* Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).
|
|
43
43
|
*
|
|
44
44
|
* @param environment - Process environment variables.
|
|
45
|
+
* @param argv - Command arguments to inspect for JSON flags.
|
|
45
46
|
* @returns True if the JSON output is enabled, false otherwise.
|
|
46
47
|
*/
|
|
47
|
-
export declare function jsonOutputEnabled(environment?: NodeJS.ProcessEnv): boolean;
|
|
48
|
+
export declare function jsonOutputEnabled(environment?: NodeJS.ProcessEnv, argv?: string[]): boolean;
|
|
48
49
|
/**
|
|
49
50
|
* If true, the CLI should not use the network level retry.
|
|
50
51
|
*
|
|
@@ -67,10 +67,11 @@ export function getIdentityTokenInformation() {
|
|
|
67
67
|
* Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).
|
|
68
68
|
*
|
|
69
69
|
* @param environment - Process environment variables.
|
|
70
|
+
* @param argv - Command arguments to inspect for JSON flags.
|
|
70
71
|
* @returns True if the JSON output is enabled, false otherwise.
|
|
71
72
|
*/
|
|
72
|
-
export function jsonOutputEnabled(environment = getEnvironmentVariables()) {
|
|
73
|
-
return sniffForJson() || isTruthy(environment[environmentVariables.json]);
|
|
73
|
+
export function jsonOutputEnabled(environment = getEnvironmentVariables(), argv = process.argv) {
|
|
74
|
+
return sniffForJson(argv) || isTruthy(environment[environmentVariables.json]);
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
77
|
* If true, the CLI should not use the network level retry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/public/node/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,oBAAoB,EAAE,0BAA0B,EAAC,MAAM,iCAAiC,CAAA;AAEhG;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,OAAO,CAAC,GAAG,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAA;IACrC,OAAO,GAAG,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAA;AAChG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAA;AACrE,CAAC;AAED,SAAS,cAAc,CAAC,KAAyB;IAC/C,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,cAAc,CAAC,uBAAuB,EAAE,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC,CAAA;AAC1F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,MAAM,aAAa,GAAG,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAA;IACnF,MAAM,YAAY,GAAG,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAA;IACjF,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAA;IACrD,OAAO;QACL,WAAW,EAAE,aAAa;QAC1B,YAAY;QACZ,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC;KACrC,CAAA;AACH,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/public/node/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,M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AC1B,YAAY;QACZ,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC;KACrC,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAW,GAAG,uBAAuB,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI;IAC5F,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAW,GAAG,uBAAuB,EAAE;IAC3E,OAAO,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,WAAW,GAAG,uBAAuB,EAAE;IACrF,OAAO,cAAc,CAAC,WAAW,CAAC,oBAAoB,CAAC,6BAA6B,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAA;AACrG,CAAC","sourcesContent":["import {nonRandomUUID} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {sniffForJson} from './path.js'\nimport {environmentVariables, systemEnvironmentVariables} from '../../private/node/constants.js'\n\n/**\n * It returns the environment variables of the environment\n * where the Node process is running.\n *\n * This function exists to prevent the access of the process\n * global variable which is discouraged via the no-process-env\n * ESLint rule.\n *\n * @returns Current process environment variables.\n */\nexport function getEnvironmentVariables(): NodeJS.ProcessEnv {\n return process.env\n}\n\n/**\n * Returns the value of the SHOPIFY_APP_AUTOMATION_TOKEN environment variable,\n * falling back to the deprecated SHOPIFY_CLI_PARTNERS_TOKEN.\n *\n * @returns The app automation token value, or undefined if neither env var is set.\n */\nexport function getAppAutomationToken(): string | undefined {\n const env = getEnvironmentVariables()\n return env[environmentVariables.appAutomationToken] ?? env[environmentVariables.partnersToken]\n}\n\n/**\n * Returns the value of the organization id from the environment variables.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function getOrganization(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.organization]\n}\n\nfunction parseEnvNumber(value: string | undefined): number | undefined {\n if (value && !isNaN(Number(value))) {\n return Number(value)\n }\n return undefined\n}\n\n/**\n * Return the backend port value.\n *\n * @returns The port as a number. Undefined otherwise.\n */\nexport function getBackendPort(): number | undefined {\n return parseEnvNumber(getEnvironmentVariables()[systemEnvironmentVariables.backendPort])\n}\n\n/**\n * Returns the information of the identity & refresh tokens, provided by environment variables.\n *\n * @returns The identity token information in case it exists.\n */\nexport function getIdentityTokenInformation(): {accessToken: string; refreshToken: string; userId: string} | undefined {\n const identityToken = getEnvironmentVariables()[environmentVariables.identityToken]\n const refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken]\n if (!identityToken || !refreshToken) return undefined\n return {\n accessToken: identityToken,\n refreshToken,\n userId: nonRandomUUID(identityToken),\n }\n}\n\n/**\n * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).\n *\n * @param environment - Process environment variables.\n * @param argv - Command arguments to inspect for JSON flags.\n * @returns True if the JSON output is enabled, false otherwise.\n */\nexport function jsonOutputEnabled(environment = getEnvironmentVariables(), argv = process.argv): boolean {\n return sniffForJson(argv) || isTruthy(environment[environmentVariables.json])\n}\n\n/**\n * If true, the CLI should not use the network level retry.\n *\n * If there is an error when calling a network API that looks like a DNS or connectivity issue, the CLI will by default\n * automatically retry the request.\n *\n * @param environment - Process environment variables.\n * @returns True if the SHOPIFY_CLI_SKIP_NETWORK_LEVEL_RETRY environment variable is set.\n */\nexport function skipNetworkLevelRetry(environment = getEnvironmentVariables()): boolean {\n return isTruthy(environment[environmentVariables.skipNetworkLevelRetry])\n}\n\n/**\n * Returns the default maximum request time for network calls in milliseconds.\n *\n * After this long, API requests may be cancelled by an AbortSignal. The limit can be overridden by setting the\n * SHOPIFY_CLI_MAX_REQUEST_TIME_FOR_NETWORK_CALLS environment variable.\n *\n * @param environment - Process environment variables.\n * @returns The maximum request time in milliseconds.\n */\nexport function maxRequestTimeForNetworkCallsMs(environment = getEnvironmentVariables()): number {\n return parseEnvNumber(environment[environmentVariables.maxRequestTimeForNetworkCalls]) ?? 30 * 1000\n}\n"]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { OutputMessage } from '../output.js';
|
|
2
|
+
import { type InlineToken, type TokenItem } from '../../../private/node/ui/components/token-item.js';
|
|
3
|
+
import type { AlertCustomSection } from '../ui.js';
|
|
4
|
+
export declare enum FatalErrorType {
|
|
5
|
+
Abort = 0,
|
|
6
|
+
AbortSilent = 1,
|
|
7
|
+
Bug = 2
|
|
8
|
+
}
|
|
9
|
+
export declare class CancelExecution extends Error {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.
|
|
13
|
+
* There shouldn't be code that catches fatal errors.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class FatalError extends Error {
|
|
16
|
+
tryMessage: TokenItem | null;
|
|
17
|
+
type: FatalErrorType;
|
|
18
|
+
nextSteps?: TokenItem<InlineToken>[];
|
|
19
|
+
formattedMessage?: TokenItem;
|
|
20
|
+
customSections?: AlertCustomSection[];
|
|
21
|
+
/** A stable code for JSON consumers to identify this error, included only when known. */
|
|
22
|
+
code?: string;
|
|
23
|
+
/** Selected JSON-serializable data to include in JSON errors. Never attach the raw error or request. */
|
|
24
|
+
details?: unknown;
|
|
25
|
+
skipOclifErrorHandling: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new FatalError error.
|
|
28
|
+
*
|
|
29
|
+
* @param message - The error message.
|
|
30
|
+
* @param type - The type of fatal error.
|
|
31
|
+
* @param tryMessage - The message that recommends next steps to the user.
|
|
32
|
+
* You can pass a string a {@link TokenizedString} or a {@link TokenItem}
|
|
33
|
+
* if you need to style the message inside the error Banner component.
|
|
34
|
+
* @param nextSteps - Message to show as "next steps" with suggestions to solve the issue.
|
|
35
|
+
* @param customSections - Custom sections to show in the error banner. To be used if nextSteps is not enough.
|
|
36
|
+
*/
|
|
37
|
+
constructor(message: TokenItem | OutputMessage, type: FatalErrorType, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem<InlineToken>[], customSections?: AlertCustomSection[]);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An abort error is a fatal error that shouldn't be reported as a bug.
|
|
41
|
+
* Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer.
|
|
42
|
+
*/
|
|
43
|
+
export declare class AbortError extends FatalError {
|
|
44
|
+
constructor(message: TokenItem | OutputMessage, tryMessage?: TokenItem | OutputMessage | null, nextSteps?: TokenItem<InlineToken>[], customSections?: AlertCustomSection[]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* An external error is similar to Abort but has extra command and args attributes.
|
|
48
|
+
* This is useful to represent errors coming from external commands, usually executed by execa.
|
|
49
|
+
*/
|
|
50
|
+
export declare class ExternalError extends FatalError {
|
|
51
|
+
command: string;
|
|
52
|
+
args: string[];
|
|
53
|
+
constructor(message: OutputMessage, command: string, args: string[], tryMessage?: TokenItem | OutputMessage | null);
|
|
54
|
+
}
|
|
55
|
+
export declare class AbortSilentError extends FatalError {
|
|
56
|
+
constructor();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A bug error is an error that represents a bug and therefore should be reported.
|
|
60
|
+
*/
|
|
61
|
+
export declare class BugError extends FatalError {
|
|
62
|
+
constructor(message: TokenItem | OutputMessage, tryMessage?: TokenItem | OutputMessage | null);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A function that handles errors that blow up in the CLI.
|
|
66
|
+
*
|
|
67
|
+
* @param error - Error to be handled.
|
|
68
|
+
* @returns A promise that resolves with the error passed.
|
|
69
|
+
*/
|
|
70
|
+
export declare function handler(error: unknown): Promise<unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* A function that maps an error to an Abort with the stack trace when coming from the CLI.
|
|
73
|
+
*
|
|
74
|
+
* @param error - Error to be mapped.
|
|
75
|
+
* @returns A promise that resolves with the new error object.
|
|
76
|
+
*/
|
|
77
|
+
export declare function errorMapper(error: unknown): Promise<unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* A function that checks if an error should be reported as unexpected.
|
|
80
|
+
*
|
|
81
|
+
* @param error - Error to be checked.
|
|
82
|
+
* @returns A boolean indicating if the error should be reported as unexpected.
|
|
83
|
+
*/
|
|
84
|
+
export declare function shouldReportErrorAsUnexpected(error: unknown): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Stack traces usually have file:// - we strip that and also remove the Windows drive designation.
|
|
87
|
+
*
|
|
88
|
+
* @param filePath - Path to be cleaned.
|
|
89
|
+
* @returns The cleaned path.
|
|
90
|
+
*/
|
|
91
|
+
export declare function cleanSingleStackTracePath(filePath: string): string;
|