@shopify/cli-kit 4.9.4 → 5.0.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 (124) hide show
  1. package/dist/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.d.ts +5 -0
  2. package/dist/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.js +22 -0
  3. package/dist/cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.js.map +1 -1
  4. package/dist/private/node/api/graphql.d.ts +2 -1
  5. package/dist/private/node/api/graphql.js +12 -1
  6. package/dist/private/node/api/graphql.js.map +1 -1
  7. package/dist/private/node/api.d.ts +2 -0
  8. package/dist/private/node/api.js +49 -22
  9. package/dist/private/node/api.js.map +1 -1
  10. package/dist/private/node/command-json-schema.js +1 -0
  11. package/dist/private/node/command-json-schema.js.map +1 -1
  12. package/dist/private/node/constants.d.ts +1 -0
  13. package/dist/private/node/constants.js +1 -0
  14. package/dist/private/node/constants.js.map +1 -1
  15. package/dist/private/node/dev-instance-output.d.ts +47 -0
  16. package/dist/private/node/dev-instance-output.js +143 -0
  17. package/dist/private/node/dev-instance-output.js.map +1 -0
  18. package/dist/private/node/json-error.d.ts +1 -15
  19. package/dist/private/node/json-error.js +4 -98
  20. package/dist/private/node/json-error.js.map +1 -1
  21. package/dist/private/node/output-context.d.ts +8 -0
  22. package/dist/private/node/output-context.js +10 -0
  23. package/dist/private/node/output-context.js.map +1 -0
  24. package/dist/private/node/output.test.js +4 -4
  25. package/dist/private/node/output.test.js.map +1 -1
  26. package/dist/private/node/session/automation-token.d.ts +50 -0
  27. package/dist/private/node/session/automation-token.js +77 -0
  28. package/dist/private/node/session/automation-token.js.map +1 -0
  29. package/dist/private/node/session/exchange.d.ts +2 -1
  30. package/dist/private/node/session/exchange.js +5 -3
  31. package/dist/private/node/session/exchange.js.map +1 -1
  32. package/dist/private/node/session/permanent-store-domain.d.ts +21 -0
  33. package/dist/private/node/session/permanent-store-domain.js +72 -0
  34. package/dist/private/node/session/permanent-store-domain.js.map +1 -0
  35. package/dist/private/node/session.d.ts +3 -2
  36. package/dist/private/node/session.js +12 -3
  37. package/dist/private/node/session.js.map +1 -1
  38. package/dist/private/node/themes/trust-challenge.d.ts +31 -0
  39. package/dist/private/node/themes/trust-challenge.js +143 -0
  40. package/dist/private/node/themes/trust-challenge.js.map +1 -0
  41. package/dist/private/node/ui/alert.js +1 -1
  42. package/dist/private/node/ui/alert.js.map +1 -1
  43. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -7
  44. package/dist/private/node/ui/components/ConcurrentOutput.js +4 -8
  45. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  46. package/dist/private/node/ui/components/LoadingBar.js +9 -15
  47. package/dist/private/node/ui/components/LoadingBar.js.map +1 -1
  48. package/dist/private/node/ui/components/LoadingBar.test.js +45 -107
  49. package/dist/private/node/ui/components/LoadingBar.test.js.map +1 -1
  50. package/dist/private/node/ui/components/LoadingIndicator.d.ts +7 -0
  51. package/dist/private/node/ui/components/LoadingIndicator.js +22 -0
  52. package/dist/private/node/ui/components/LoadingIndicator.js.map +1 -0
  53. package/dist/public/common/version.d.ts +1 -1
  54. package/dist/public/common/version.js +1 -1
  55. package/dist/public/common/version.js.map +1 -1
  56. package/dist/public/node/api/admin.js +13 -0
  57. package/dist/public/node/api/admin.js.map +1 -1
  58. package/dist/public/node/api/graphql.js +38 -7
  59. package/dist/public/node/api/graphql.js.map +1 -1
  60. package/dist/public/node/archiver.js +13 -6
  61. package/dist/public/node/archiver.js.map +1 -1
  62. package/dist/public/node/base-command.d.ts +6 -0
  63. package/dist/public/node/base-command.js +97 -16
  64. package/dist/public/node/base-command.js.map +1 -1
  65. package/dist/public/node/dev-instance.d.ts +138 -0
  66. package/dist/public/node/dev-instance.js +365 -0
  67. package/dist/public/node/dev-instance.js.map +1 -0
  68. package/dist/public/node/environment.d.ts +6 -3
  69. package/dist/public/node/environment.js +11 -4
  70. package/dist/public/node/environment.js.map +1 -1
  71. package/dist/public/node/error/index.js +2 -1
  72. package/dist/public/node/error/index.js.map +1 -1
  73. package/dist/public/node/error/schema.d.ts +24 -24
  74. package/dist/public/node/error/serialization.d.ts +8 -0
  75. package/dist/public/node/error/serialization.js +103 -0
  76. package/dist/public/node/error/serialization.js.map +1 -0
  77. package/dist/public/node/graphiql/server.js +18 -2
  78. package/dist/public/node/graphiql/server.js.map +1 -1
  79. package/dist/public/node/is-global.js +2 -1
  80. package/dist/public/node/is-global.js.map +1 -1
  81. package/dist/public/node/notifications-system.d.ts +6 -6
  82. package/dist/public/node/path.d.ts +19 -3
  83. package/dist/public/node/path.js +21 -3
  84. package/dist/public/node/path.js.map +1 -1
  85. package/dist/public/node/session.d.ts +36 -2
  86. package/dist/public/node/session.js +48 -4
  87. package/dist/public/node/session.js.map +1 -1
  88. package/dist/public/node/system.d.ts +4 -0
  89. package/dist/public/node/system.js +39 -9
  90. package/dist/public/node/system.js.map +1 -1
  91. package/dist/public/node/themes/api.d.ts +9 -0
  92. package/dist/public/node/themes/api.js +50 -22
  93. package/dist/public/node/themes/api.js.map +1 -1
  94. package/dist/public/node/themes/theme-manager.d.ts +8 -1
  95. package/dist/public/node/themes/theme-manager.js +1 -1
  96. package/dist/public/node/themes/theme-manager.js.map +1 -1
  97. package/dist/public/node/tree-kill.js +12 -2
  98. package/dist/public/node/tree-kill.js.map +1 -1
  99. package/dist/public/node/ui/components.d.ts +1 -0
  100. package/dist/public/node/ui/components.js +1 -0
  101. package/dist/public/node/ui/components.js.map +1 -1
  102. package/dist/public/node/ui.d.ts +24 -4
  103. package/dist/public/node/ui.js +41 -18
  104. package/dist/public/node/ui.js.map +1 -1
  105. package/dist/public/node/upgrade/output.d.ts +17 -0
  106. package/dist/public/node/upgrade/output.js +51 -0
  107. package/dist/public/node/upgrade/output.js.map +1 -0
  108. package/dist/public/node/upgrade/result.d.ts +8 -0
  109. package/dist/public/node/upgrade/result.js +21 -0
  110. package/dist/public/node/upgrade/result.js.map +1 -0
  111. package/dist/public/node/upgrade/types.d.ts +61 -0
  112. package/dist/public/node/upgrade/types.js +46 -0
  113. package/dist/public/node/upgrade/types.js.map +1 -0
  114. package/dist/public/node/upgrade.d.ts +8 -0
  115. package/dist/public/node/upgrade.js +57 -22
  116. package/dist/public/node/upgrade.js.map +1 -1
  117. package/dist/tsconfig.tsbuildinfo +1 -1
  118. package/package.json +3 -3
  119. package/dist/private/node/ui/components/TextAnimation.d.ts +0 -10
  120. package/dist/private/node/ui/components/TextAnimation.js +0 -56
  121. package/dist/private/node/ui/components/TextAnimation.js.map +0 -1
  122. package/dist/private/node/ui/components/TextAnimation.test.d.ts +0 -1
  123. package/dist/private/node/ui/components/TextAnimation.test.js +0 -73
  124. package/dist/private/node/ui/components/TextAnimation.test.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,8BAA8B,EAAC,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAC,aAAa,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AACpE,OAAO,EAAC,sBAAsB,EAAC,MAAM,cAAc,CAAA;AACnD,OAAO,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AAGvD,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,OAAO,EAAU,MAAM,EAAE,KAAK,EAAC,MAAM,aAAa,CAA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AG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACvF,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,aAAa,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,8BAA8B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7G,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAA;QAC/C,aAAa,CAAC;YACZ,QAAQ,EAAE,iCAAiC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpG,IAAI,EAAE;gBACJ,iGAAiG;gBACjG,+BAA+B,aAAa,EAAE;aAC/C;SACF,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACxF,6GAA6G;IAC7G,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {runWithCommandEventsForCommand} from './command-events.js'\nimport {outputContent, outputResult, outputToken} from './output.js'\nimport {setCurrentSessionAlias} from './session.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {setCurrentCommandId} from './global-context.js'\nimport {type JsonOutputSchema} from './json-output-schema.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Config, Errors, Flags} from '@oclif/core'\nimport {OutputFlags, Input, ParserOutput, FlagInput, OutputArgs} from '@oclif/core/parser'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ArgOutput = OutputArgs<any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FlagOutput = OutputFlags<any>\n\nexport interface NonTTYFlagRequirement {\n /** At least one of these flags must be present when the requirement applies. */\n flags: string[]\n /** Determines whether the requirement applies to the parsed flags. */\n when?: (flags: FlagOutput) => boolean\n}\n\ninterface EnvironmentFlags {\n 'auth-alias'?: string\n environment?: string[]\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n static baseFlags: FlagInput<{}> = {\n 'json-schema': Flags.boolean({\n description: \"Print the command's JSON schemas.\",\n env: 'SHOPIFY_FLAG_JSON_SCHEMA',\n }),\n }\n\n static descriptionWithMarkdown?: string\n\n public static get jsonOutputSchema(): JsonOutputSchema | undefined {\n return undefined\n }\n\n public static get requiresSyncAnalytics(): boolean {\n return false\n }\n\n public static nonTTYFlagRequirements(_flags: FlagOutput): NonTTYFlagRequirement[] {\n return []\n }\n\n // Include the JSON result schema and convert Markdown links to plain text for command help.\n public static descriptionForHelp(): string | undefined {\n const description = (this.descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n return appendJsonOutputSchema(description, this.jsonOutputSchema)\n }\n\n /** @deprecated Use descriptionForHelp instead. */\n public static descriptionWithoutMarkdown(): string | undefined {\n return this.descriptionForHelp()\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n const {errorHandler} = await import('./error-handler.js')\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n protected async _run<T>(): Promise<T> {\n return runWithCommandEventsForCommand(this.argv, () => super._run<T>())\n }\n\n protected async init(): Promise<unknown> {\n this.exitWithTimestampWhenEnvVariablePresent()\n setCurrentCommandId(this.id ?? '')\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n const {registerCleanBugsnagErrorsFromWithinPlugins} = await import('./error-handler.js')\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n await removeDuplicatedPlugins(this.config)\n this.showNpmFlagWarning()\n const {showNotificationsIfNeeded} = await import('./notifications-system.js')\n await showNotificationsIfNeeded()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n // eslint-disable-next-line no-void\n void import('./ui.js').then(({renderWarning}) => {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n })\n }\n }\n\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputResult(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean; 'auth-alias'?: string},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await setCurrentSessionAlias(result.flags['auth-alias'])\n await addFromParsedFlags(result.flags)\n this.failMissingNonTTYFlagRequirements(result.flags, this.applicableNonTTYFlagRequirements(result.flags))\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n this.failMissingNonTTYFlagRequirements(\n flags,\n requiredFlags.map((flag) => ({flags: [flag]})),\n )\n }\n\n private failMissingNonTTYFlagRequirements(flags: FlagOutput, requirements: NonTTYFlagRequirement[]): void {\n if (terminalSupportsPrompting()) return\n\n const missingRequirements = requirements.filter((requirement) =>\n requirement.flags.every((flag) => flags[flag] === undefined || flags[flag] === false),\n )\n if (missingRequirements.length === 0) return\n\n const heading = missingRequirements.length === 1 ? 'Flag not specified' : 'Flags not specified'\n const formattedRequirements = missingRequirements\n .map((requirement) => requirement.flags.map((flag) => `--${flag}`).join(' or '))\n .join('\\n')\n const explanation = missingRequirements.length === 1 ? 'This flag is required' : 'These flags are required'\n\n throw new AbortError(\n outputContent`${heading}:\n\n${outputToken.cyan(formattedRequirements)}\n\n${explanation} in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the options in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n\n private applicableNonTTYFlagRequirements(flags: FlagOutput): NonTTYFlagRequirement[] {\n const command = this.constructor as unknown as {\n flags?: FlagInput\n baseFlags?: FlagInput\n nonTTYFlagRequirements?: (flags: FlagOutput) => NonTTYFlagRequirement[]\n }\n const allFlags = {...command.baseFlags, ...command.flags}\n const requirementsFromFlags = Object.entries(allFlags)\n .filter(([, flag]) => Boolean((flag as {requiredIfNonInteractive?: boolean}).requiredIfNonInteractive))\n .map(([name]) => ({flags: [name]}))\n const commandRequirements = (command.nonTTYFlagRequirements?.(flags) ?? []).filter(\n (requirement) => requirement.when?.(flags) ?? true,\n )\n\n return [...requirementsFromFlags, ...commandRequirements]\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n\n if (!environmentsFileName) return originalResult\n\n const {environmentFilePath} = await import('./environments.js')\n const environmentFileExists = await environmentFilePath(environmentsFileName, {from: flags.path})\n\n // Handle both string and array cases for environment flag\n let environments: string[] = []\n if (flags.environment) {\n environments = Array.isArray(flags.environment) ? flags.environment : [flags.environment]\n }\n\n const environmentSpecified = environments.length > 0\n\n // Noop if no environment file exists and none was specified\n if (!environmentFileExists && !environmentSpecified) return originalResult\n\n // Noop if multiple environments were specified (let commands handle this)\n if (environmentSpecified && environments.length > 1) return originalResult\n\n const {environment, isDefaultEnvironment} = await this.loadEnvironmentForCommand(\n flags.path,\n environmentsFileName,\n environments[0],\n )\n\n if (!environment) return originalResult\n if (isDefaultEnvironment && !commandSupportsFlag(options?.flags, 'environment')) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv ?? this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ...(isDefaultEnvironment ? ['--environment', 'default'] : []),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n isDefaultEnvironment ? 'default' : (environments[0] as string),\n environment,\n )\n\n return result\n }\n\n /**\n * Tries to load an environment to forward to the command. If no environment\n * is specified it will try to load a default environment.\n */\n private async loadEnvironmentForCommand(\n path: string | undefined,\n environmentsFileName: string,\n specifiedEnvironment: string | undefined,\n ): Promise<{environment: JsonMap | undefined; isDefaultEnvironment: boolean}> {\n const {loadEnvironment} = await import('./environments.js')\n if (specifiedEnvironment) {\n const environment = await loadEnvironment(specifiedEnvironment, environmentsFileName, {from: path})\n return {environment, isDefaultEnvironment: false}\n }\n\n const environment = await loadEnvironment('default', environmentsFileName, {from: path, silent: true})\n return {environment, isDefaultEnvironment: 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 environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n // eslint-disable-next-line no-void\n void import('./ui.js').then(({renderInfo}) => {\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\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 */\nexport function noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = commandSupportsFlag(options?.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nfunction commandSupportsFlag(flags: FlagInput | undefined, flagName: string): boolean {\n return Boolean(flags) && Object.prototype.hasOwnProperty.call(flags, flagName)\n}\n\nfunction appendJsonOutputSchema(description: string, outputSchema: JsonOutputSchema | undefined): string {\n if (!outputSchema) return description\n\n const jsonOutputDescription = `Use \\`--json-schema\\` to print the result, error, and event schemas.\n\nOutput from \\`--json\\` conforms to the \\`${outputSchema.name}\\` schema.\n\n\\`\\`\\`json\n${JSON.stringify(outputSchema.jsonSchema, null, 2)}\n\\`\\`\\``\n\n return [description, jsonOutputDescription].filter(Boolean).join('\\n\\n')\n}\n\nasync function removeDuplicatedPlugins(config: Config): Promise<void> {\n const plugins = Array.from(config.plugins.values())\n const bundlePlugins = ['@shopify/app', '@shopify/plugin-cloudflare']\n const pluginsToRemove = plugins.filter((plugin) => bundlePlugins.includes(plugin.name))\n if (pluginsToRemove.length > 0) {\n const commandsToRun = pluginsToRemove.map((plugin) => ` - shopify plugins remove ${plugin.name}`).join('\\n')\n const {renderWarning} = await import('./ui.js')\n renderWarning({\n headline: `Unsupported plugins detected: ${pluginsToRemove.map((plugin) => plugin.name).join(', ')}`,\n body: [\n 'They are already included in the CLI and installing them as custom plugins can cause conflicts.',\n `You can fix it by running:\\n${commandsToRun}`,\n ],\n })\n }\n const filteredPlugins = plugins.filter((plugin) => !bundlePlugins.includes(plugin.name))\n // eslint-disable-next-line require-atomic-updates -- config.plugins won't be modified by renderWarning above\n config.plugins = new Map(filteredPlugins.map((plugin) => [plugin.name, plugin]))\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,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,aAAa,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AACpE,OAAO,EAAC,sBAAsB,EAAC,MAAM,cAAc,CAAA;AACnD,OAAO,EAAC,yBAAyB,EAAC,MAAM,aAAa,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AAGvD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,iCAAiC,EAAC,MAAM,gDAAgD,CAAA;AAChG,OAAO,EAAC,oBAAoB,EAAC,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,OAAO,EAAU,MAAM,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAqB1D,MAAe,WAAY,SAAQ,OAAO;IACxC,MAAM,CAAC,SAAS,GAAkB;QAChC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC;YAC3B,WAAW,EAAE,mCAAmC;YAChD,GAAG,EAAE,0BAA0B;SAChC,CAAC;KACH,CAAA;IAED,MAAM,CAAC,uBAAuB,CAAS;IAEhC,MAAM,KAAK,gBAAgB;QAChC,OAAO,SAAS,CAAA;I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,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACpG,IAAI,EAAE;gBACJ,iGAAiG;gBACjG,+BAA+B,aAAa,EAAE;aAC/C;SACF,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACxF,6GAA6G;IAC7G,MAAM,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {\n commandEventOutputMode,\n emitCommandEvent,\n renderCommandEventAsJson,\n runWithCommandEvents,\n runWithCommandEventsForCommand,\n} from './command-events.js'\nimport {outputContent, outputResult, outputToken} from './output.js'\nimport {setCurrentSessionAlias} from './session.js'\nimport {terminalSupportsPrompting} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {setCurrentCommandId} from './global-context.js'\nimport {type JsonOutputSchema} from './json-output-schema.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {environmentVariables} from '../../private/node/constants.js'\nimport {deprecatedAutomationTokenVariable} from '../../private/node/session/automation-token.js'\nimport {runAtMinimumInterval} from '../../private/node/conf-store.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Config, Errors, Flags} from '@oclif/core'\nimport {OutputFlags, Input, ParserOutput, FlagInput, OutputArgs} from '@oclif/core/parser'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ArgOutput = OutputArgs<any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FlagOutput = OutputFlags<any>\n\nexport interface NonTTYFlagRequirement {\n /** At least one of these flags must be present when the requirement applies. */\n flags: string[]\n /** Determines whether the requirement applies to the parsed flags. */\n when?: (flags: FlagOutput) => boolean\n}\n\ninterface EnvironmentFlags {\n 'auth-alias'?: string\n environment?: string[]\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n static baseFlags: FlagInput<{}> = {\n 'json-schema': Flags.boolean({\n description: \"Print the command's JSON schemas.\",\n env: 'SHOPIFY_FLAG_JSON_SCHEMA',\n }),\n }\n\n static descriptionWithMarkdown?: string\n\n public static get jsonOutputSchema(): JsonOutputSchema | undefined {\n return undefined\n }\n\n public static get requiresSyncAnalytics(): boolean {\n return false\n }\n\n public static nonTTYFlagRequirements(_flags: FlagOutput): NonTTYFlagRequirement[] {\n return []\n }\n\n // Include the JSON result schema and convert Markdown links to plain text for command help.\n public static descriptionForHelp(): string | undefined {\n const description = (this.descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n return appendJsonOutputSchema(description, this.jsonOutputSchema)\n }\n\n /** @deprecated Use descriptionForHelp instead. */\n public static descriptionWithoutMarkdown(): string | undefined {\n return this.descriptionForHelp()\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n private jsonOutputFromFlags = false\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n const handleError = async () => {\n error.skipOclifErrorHandling = true\n const {errorHandler} = await import('./error-handler.js')\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n if (this.jsonOutputFromFlags && commandEventOutputMode() !== 'json') {\n return runWithCommandEvents({outputMode: 'json', sink: renderCommandEventAsJson}, handleError)\n }\n return handleError()\n }\n\n protected async _run<T>(): Promise<T> {\n return runWithCommandEventsForCommand(this.argv, () => super._run<T>())\n }\n\n protected async init(): Promise<unknown> {\n this.exitWithTimestampWhenEnvVariablePresent()\n setCurrentCommandId(this.id ?? '')\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n const {registerCleanBugsnagErrorsFromWithinPlugins} = await import('./error-handler.js')\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n await removeDuplicatedPlugins(this.config)\n this.showNpmFlagWarning()\n await this.showDeprecatedAutomationTokenVariableWarning()\n const {showNotificationsIfNeeded} = await import('./notifications-system.js')\n await showNotificationsIfNeeded()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n // eslint-disable-next-line no-void\n void import('./ui.js').then(({renderWarning}) => {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n })\n }\n }\n\n // SHOPIFY_APP_AUTOMATION_TOKEN and SHOPIFY_CLI_PARTNERS_TOKEN keep working, but SHOPIFY_SERVICE_ACCOUNT_TOKEN replaces\n // them and takes the same tokens. This warning is how people still using an old name find out about the new one.\n protected async showDeprecatedAutomationTokenVariableWarning(): Promise<void> {\n const variable = deprecatedAutomationTokenVariable()\n if (!variable) return\n\n // Show the warning only once per day\n await runAtMinimumInterval('warn-on-deprecated-automation-token-variable', {days: 1}, async () => {\n const {renderWarning} = await import('./ui.js')\n renderWarning({\n headline: `${variable} is deprecated.`,\n body: `Move the token to ${environmentVariables.serviceAccountToken}. ${variable} still works for now, but a future release will stop reading it.`,\n })\n })\n }\n\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputResult(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean; 'auth-alias'?: string},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n const parsed = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n const result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(parsed, options, argv)\n return this.runWithParsedOutput(result.flags, async () => {\n await setCurrentSessionAlias(result.flags['auth-alias'])\n await addFromParsedFlags(result.flags)\n this.validateNonTTYFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n })\n }\n\n protected runWithParsedOutput<T>(flags: FlagOutput, execute: () => T): T {\n const command = this.constructor as typeof BaseCommand\n const json =\n commandSupportsFlag(command.flags, 'json') &&\n (flags.json === true || (commandSupportsJsonOutputFormat(command.flags) && flags.output === 'json'))\n this.jsonOutputFromFlags ||= json\n if (json && commandEventOutputMode() !== 'json') {\n return runWithCommandEvents({outputMode: 'json', sink: renderCommandEventAsJson}, execute)\n }\n return execute()\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected async parseEnvironmentFlags<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(environment: JsonMap, options: Input<TFlags, TGlobalFlags, TArgs>, explicitFlags: FlagOutput): Promise<FlagOutput> {\n const originalArgv = this.argv\n try {\n const result = await super.parse(options, [\n ...originalArgv,\n ...argsFromEnvironment(environment, options, explicitFlags),\n ])\n return result.flags\n } finally {\n // Oclif replaces argv when parsing; the next environment needs the original arguments.\n this.argv = originalArgv\n }\n }\n\n protected validateNonTTYFlags(flags: FlagOutput): void {\n this.failMissingNonTTYFlagRequirements(flags, this.applicableNonTTYFlagRequirements(flags))\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n this.failMissingNonTTYFlagRequirements(\n flags,\n requiredFlags.map((flag) => ({flags: [flag]})),\n )\n }\n\n private failMissingNonTTYFlagRequirements(flags: FlagOutput, requirements: NonTTYFlagRequirement[]): void {\n if (terminalSupportsPrompting()) return\n\n const missingRequirements = requirements.filter((requirement) =>\n requirement.flags.every((flag) => flags[flag] === undefined || flags[flag] === false),\n )\n if (missingRequirements.length === 0) return\n\n const heading = missingRequirements.length === 1 ? 'Flag not specified' : 'Flags not specified'\n const formattedRequirements = missingRequirements\n .map((requirement) => requirement.flags.map((flag) => `--${flag}`).join(' or '))\n .join('\\n')\n const explanation = missingRequirements.length === 1 ? 'This flag is required' : 'These flags are required'\n\n throw new AbortError(\n outputContent`${heading}:\n\n${outputToken.cyan(formattedRequirements)}\n\n${explanation} in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the options in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n\n private applicableNonTTYFlagRequirements(flags: FlagOutput): NonTTYFlagRequirement[] {\n const command = this.constructor as unknown as {\n flags?: FlagInput\n baseFlags?: FlagInput\n nonTTYFlagRequirements?: (flags: FlagOutput) => NonTTYFlagRequirement[]\n }\n const allFlags = {...command.baseFlags, ...command.flags}\n const requirementsFromFlags = Object.entries(allFlags)\n .filter(([, flag]) => Boolean((flag as {requiredIfNonInteractive?: boolean}).requiredIfNonInteractive))\n .map(([name]) => ({flags: [name]}))\n const commandRequirements = (command.nonTTYFlagRequirements?.(flags) ?? []).filter(\n (requirement) => requirement.when?.(flags) ?? true,\n )\n\n return [...requirementsFromFlags, ...commandRequirements]\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n\n if (!environmentsFileName) return originalResult\n\n const {environmentFilePath} = await import('./environments.js')\n const environmentFileExists = await environmentFilePath(environmentsFileName, {from: flags.path})\n\n // Handle both string and array cases for environment flag\n let environments: string[] = []\n if (flags.environment) {\n environments = Array.isArray(flags.environment) ? flags.environment : [flags.environment]\n }\n\n const environmentSpecified = environments.length > 0\n\n // Noop if no environment file exists and none was specified\n if (!environmentFileExists && !environmentSpecified) return originalResult\n\n // Noop if multiple environments were specified (let commands handle this)\n if (environmentSpecified && environments.length > 1) return originalResult\n\n const {environment, isDefaultEnvironment} = await this.loadEnvironmentForCommand(\n flags.path,\n environmentsFileName,\n environments[0],\n )\n\n if (!environment) return originalResult\n if (isDefaultEnvironment && !commandSupportsFlag(options?.flags, 'environment')) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Remember the requested format before environment flag validation can fail.\n const effectiveFlags = {...environment, ...noDefaultsResult.flags}\n this.jsonOutputFromFlags =\n (commandSupportsFlag(options?.flags, 'json') && effectiveFlags.json === true) ||\n (commandSupportsJsonOutputFormat(options?.flags) && effectiveFlags.output === 'json')\n const normalizedEnvironment =\n commandSupportsFlag(options?.flags, 'json') &&\n commandSupportsJsonOutputFormat(options?.flags) &&\n effectiveFlags.output === 'json'\n ? {json: true, ...environment}\n : environment\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv ?? this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(normalizedEnvironment, options, noDefaultsResult.flags),\n ...(isDefaultEnvironment ? ['--environment', 'default'] : []),\n ])\n\n // Report successful application of the environment.\n const report = () =>\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n isDefaultEnvironment ? 'default' : (environments[0] as string),\n environment,\n )\n this.runWithParsedOutput(result.flags, report)\n\n return result\n }\n\n /**\n * Tries to load an environment to forward to the command. If no environment\n * is specified it will try to load a default environment.\n */\n private async loadEnvironmentForCommand(\n path: string | undefined,\n environmentsFileName: string,\n specifiedEnvironment: string | undefined,\n ): Promise<{environment: JsonMap | undefined; isDefaultEnvironment: boolean}> {\n const {loadEnvironment} = await import('./environments.js')\n if (specifiedEnvironment) {\n const environment = await loadEnvironment(specifiedEnvironment, environmentsFileName, {from: path})\n return {environment, isDefaultEnvironment: false}\n }\n\n const environment = await loadEnvironment('default', environmentsFileName, {from: path, silent: true})\n return {environment, isDefaultEnvironment: 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 environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' || name === 'store-password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n if (commandEventOutputMode() === 'json') {\n emitCommandEvent({\n type: 'diagnostic',\n level: 'info',\n message: `Using applicable flags from ${environmentName} environment:\\n${items.join('\\n')}`,\n })\n return\n }\n // eslint-disable-next-line no-void\n void import('./ui.js').then(({renderInfo}) => {\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\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 */\nexport function noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n explicitFlags: FlagOutput,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = commandSupportsFlag(options?.flags, label)\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(explicitFlags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (options?.flags?.[label]?.type === 'boolean' && typeof value !== 'boolean') {\n throw new AbortError(outputContent`Environment flag ${outputToken.yellow(label)} must be a boolean.`)\n }\n if (typeof value === 'boolean') {\n if (value) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nfunction commandSupportsFlag(flags: FlagInput | undefined, flagName: string): boolean {\n return Boolean(flags) && Object.prototype.hasOwnProperty.call(flags, flagName)\n}\n\nfunction commandSupportsJsonOutputFormat(flags: FlagInput | undefined): boolean {\n const output = flags?.output\n return output?.type === 'option' && output.options?.includes('json') === true\n}\n\nfunction appendJsonOutputSchema(description: string, outputSchema: JsonOutputSchema | undefined): string {\n if (!outputSchema) return description\n\n const jsonOutputDescription = `Use \\`--json-schema\\` to print the result, error, and event schemas.\n\nOutput from \\`--json\\` conforms to the \\`${outputSchema.name}\\` schema.\n\n\\`\\`\\`json\n${JSON.stringify(outputSchema.jsonSchema, null, 2)}\n\\`\\`\\``\n\n return [description, jsonOutputDescription].filter(Boolean).join('\\n\\n')\n}\n\nasync function removeDuplicatedPlugins(config: Config): Promise<void> {\n const plugins = Array.from(config.plugins.values())\n const bundlePlugins = ['@shopify/app', '@shopify/plugin-cloudflare']\n const pluginsToRemove = plugins.filter((plugin) => bundlePlugins.includes(plugin.name))\n if (pluginsToRemove.length > 0) {\n const commandsToRun = pluginsToRemove.map((plugin) => ` - shopify plugins remove ${plugin.name}`).join('\\n')\n const {renderWarning} = await import('./ui.js')\n renderWarning({\n headline: `Unsupported plugins detected: ${pluginsToRemove.map((plugin) => plugin.name).join(', ')}`,\n body: [\n 'They are already included in the CLI and installing them as custom plugins can cause conflicts.',\n `You can fix it by running:\\n${commandsToRun}`,\n ],\n })\n }\n const filteredPlugins = plugins.filter((plugin) => !bundlePlugins.includes(plugin.name))\n // eslint-disable-next-line require-atomic-updates -- config.plugins won't be modified by renderWarning above\n config.plugins = new Map(filteredPlugins.map((plugin) => [plugin.name, plugin]))\n}\n\nexport default BaseCommand\n"]}
@@ -0,0 +1,138 @@
1
+ import { type DevInstanceLogEntry } from '../../private/node/dev-instance-output.js';
2
+ import { Writable } from 'stream';
3
+ /**
4
+ * A stable error code for JSON consumers when a long-running command refuses to start because another instance of
5
+ * it is already running for the same project.
6
+ */
7
+ export declare const DEV_INSTANCE_ALREADY_RUNNING_CODE = "dev_instance_already_running";
8
+ /**
9
+ * Describes a running instance of a long-running command such as `app dev` or `theme dev`.
10
+ * It's written to `.shopify/dev/<slug>.json` so agents and other tools can discover the instance.
11
+ */
12
+ export interface DevInstanceInfo {
13
+ schemaVersion: 1;
14
+ /** Identifies this run, including when the OS reuses a PID. */
15
+ sessionId: string;
16
+ /** The command that owns the instance, for example `app dev`. */
17
+ command: string;
18
+ /** Distinguishes instances of the same command in the same directory, for example the app configuration file. */
19
+ key?: string;
20
+ pid: number;
21
+ status: 'starting' | 'running';
22
+ startedAt: string;
23
+ updatedAt: string;
24
+ /** The project directory the instance runs for. */
25
+ directory: string;
26
+ /** The JSON Lines file the instance appends its output to. */
27
+ logFile: string;
28
+ /** Command-specific, JSON-serializable details such as URLs and ports. */
29
+ details: {
30
+ [key: string]: unknown;
31
+ };
32
+ }
33
+ export { devInstanceLogOutputSchema, type DevInstanceLogEntry } from '../../private/node/dev-instance-output.js';
34
+ export interface DevInstancePaths {
35
+ /** The folder that holds every dev instance of the project: `.shopify/dev`. */
36
+ folder: string;
37
+ /** The instance description. */
38
+ infoFile: string;
39
+ /** The lock directory, owned by `proper-lockfile`. */
40
+ lockFile: string;
41
+ /** The JSON Lines log. */
42
+ logFile: string;
43
+ }
44
+ export interface DevInstanceIdentity {
45
+ /** The command that owns the instance, for example `app dev`. */
46
+ command: string;
47
+ /** The project directory. */
48
+ directory: string;
49
+ /** Distinguishes several instances of the same command in the same directory. */
50
+ key?: string;
51
+ }
52
+ export interface AcquireDevInstanceOptions extends DevInstanceIdentity {
53
+ /** Initial command-specific details. */
54
+ details?: {
55
+ [key: string]: unknown;
56
+ };
57
+ /** Receives the exact JSONL bytes written to the session log. The caller owns this stream. */
58
+ logOutput?: Writable;
59
+ }
60
+ export interface DevInstanceUpdate {
61
+ status?: DevInstanceInfo['status'];
62
+ /** Merged into the existing details. */
63
+ details?: {
64
+ [key: string]: unknown;
65
+ };
66
+ }
67
+ export interface DevInstance {
68
+ readonly info: DevInstanceInfo;
69
+ readonly paths: DevInstancePaths;
70
+ /** Aborts when this session loses its lock or output fails. Consumers must stop their owned work. */
71
+ readonly abortSignal: AbortSignal;
72
+ /** Updates and persists the instance description. */
73
+ update: (changes: DevInstanceUpdate) => Promise<void>;
74
+ /** Appends one entry to the JSON Lines log. */
75
+ log: (entry: Omit<DevInstanceLogEntry, 'timestamp'> & {
76
+ timestamp?: string;
77
+ }) => Promise<void>;
78
+ /**
79
+ * Wraps a stream so every line written to it is also appended to the log, without ANSI styling.
80
+ * The returned stream forwards the original bytes to `target` unchanged.
81
+ */
82
+ tee: (target: Writable, options: {
83
+ source: string;
84
+ /** Treat each string write as a complete message. Byte writes remain buffered into lines. */
85
+ stringWritesAreMessages?: boolean;
86
+ }) => Writable;
87
+ /** Closes the log, removes the instance description and releases the lock. Safe to call more than once. */
88
+ release: () => Promise<void>;
89
+ }
90
+ /**
91
+ * Returns the files used by a dev instance. Every instance of a project shares `.shopify/dev`,
92
+ * with one `<slug>.json`, `<slug>.lock` and `<slug>.jsonl` per command and key.
93
+ *
94
+ * @param identity - The command, directory and optional key of the instance.
95
+ * @returns The paths of the instance files.
96
+ */
97
+ export declare function devInstancePaths(identity: DevInstanceIdentity): DevInstancePaths;
98
+ /**
99
+ * Marks this process as the running instance of a long-running command for a project.
100
+ *
101
+ * Mutual exclusion uses `proper-lockfile`: an atomic `mkdir` lock whose mtime this process refreshes as a heartbeat.
102
+ * An exclusive startup directory serializes abandoned-lock recovery. An interrupted startup requires explicit
103
+ * cleanup of that directory. A live owner blocks takeover, including when its heartbeat is stale.
104
+ *
105
+ * @param options - The instance identity, initial details.
106
+ * @returns The acquired instance.
107
+ * @throws AbortError with code {@link DEV_INSTANCE_ALREADY_RUNNING_CODE} when another live instance holds the lock.
108
+ */
109
+ export declare function acquireDevInstance(options: AcquireDevInstanceOptions): Promise<DevInstance>;
110
+ /**
111
+ * Acquires a dev instance and releases it after the callback completes or throws.
112
+ *
113
+ * @param options - The command, project and output options for the instance.
114
+ * @param execute - The work to run while the instance is owned.
115
+ * @returns The callback's result after instance cleanup completes.
116
+ */
117
+ export declare function withDevInstance<T>(options: AcquireDevInstanceOptions, execute: (instance: DevInstance) => T | Promise<T>): Promise<T>;
118
+ /**
119
+ * Returns the running instance of a command for a project, if there is one.
120
+ *
121
+ * @param identity - The command, directory and optional key of the instance.
122
+ * @returns The instance description, or undefined when no live instance holds the lock.
123
+ */
124
+ export declare function readDevInstance(identity: DevInstanceIdentity): Promise<DevInstanceInfo | undefined>;
125
+ /**
126
+ * Lists every running dev instance of a project, across commands and keys.
127
+ *
128
+ * @param directory - The project directory.
129
+ * @returns The descriptions of the live instances.
130
+ */
131
+ export declare function listDevInstances(directory: string): Promise<DevInstanceInfo[]>;
132
+ /**
133
+ * Checks whether a process exists. A process owned by another user counts as alive.
134
+ *
135
+ * @param pid - The process ID.
136
+ * @returns True when the process exists.
137
+ */
138
+ export declare function isProcessAlive(pid: number): boolean;
@@ -0,0 +1,365 @@
1
+ import { getOrCreateHiddenShopifyFolder } from './hidden-folder.js';
2
+ import { joinPath } from './path.js';
3
+ import { fileExists, glob, mkdir, readFile, removeFile, removeFileSync, renameFile, rmdir } from './fs.js';
4
+ import { AbortError } from './error.js';
5
+ import { outputDebug } from './output.js';
6
+ import { formatJsonOutputTimestamp } from './json-output-schema.js';
7
+ import { hashString, randomUUID } from './crypto.js';
8
+ import { createDevInstanceOutput } from '../../private/node/dev-instance-output.js';
9
+ import lockfile from 'proper-lockfile';
10
+ import fs, { readFileSync } from 'fs';
11
+ import { mkdir as mkdirExclusive, rmdir as removeEmptyDirectory, writeFile as writeFileWithMode } from 'fs/promises';
12
+ /**
13
+ * A stable error code for JSON consumers when a long-running command refuses to start because another instance of
14
+ * it is already running for the same project.
15
+ */
16
+ export const DEV_INSTANCE_ALREADY_RUNNING_CODE = 'dev_instance_already_running';
17
+ const DEV_INSTANCES_FOLDER = 'dev';
18
+ const DEFAULT_STALE_MS = 15_000;
19
+ export { devInstanceLogOutputSchema } from '../../private/node/dev-instance-output.js';
20
+ /**
21
+ * Returns the files used by a dev instance. Every instance of a project shares `.shopify/dev`,
22
+ * with one `<slug>.json`, `<slug>.lock` and `<slug>.jsonl` per command and key.
23
+ *
24
+ * @param identity - The command, directory and optional key of the instance.
25
+ * @returns The paths of the instance files.
26
+ */
27
+ export function devInstancePaths(identity) {
28
+ const folder = joinPath(identity.directory, '.shopify', DEV_INSTANCES_FOLDER);
29
+ const slug = devInstanceSlug(identity);
30
+ return {
31
+ folder,
32
+ infoFile: joinPath(folder, `${slug}.json`),
33
+ lockFile: joinPath(folder, `${slug}.lock`),
34
+ logFile: joinPath(folder, `${slug}.jsonl`),
35
+ };
36
+ }
37
+ /**
38
+ * Marks this process as the running instance of a long-running command for a project.
39
+ *
40
+ * Mutual exclusion uses `proper-lockfile`: an atomic `mkdir` lock whose mtime this process refreshes as a heartbeat.
41
+ * An exclusive startup directory serializes abandoned-lock recovery. An interrupted startup requires explicit
42
+ * cleanup of that directory. A live owner blocks takeover, including when its heartbeat is stale.
43
+ *
44
+ * @param options - The instance identity, initial details.
45
+ * @returns The acquired instance.
46
+ * @throws AbortError with code {@link DEV_INSTANCE_ALREADY_RUNNING_CODE} when another live instance holds the lock.
47
+ */
48
+ export async function acquireDevInstance(options) {
49
+ const paths = devInstancePaths(options);
50
+ await getOrCreateHiddenShopifyFolder(options.directory);
51
+ await mkdir(paths.folder);
52
+ const startupLock = `${paths.lockFile}.acquire`;
53
+ try {
54
+ await mkdirExclusive(startupLock, { mode: 0o700 });
55
+ }
56
+ catch (error) {
57
+ if (error.code !== 'EEXIST')
58
+ throw error;
59
+ const startupError = new AbortError(`Another \`shopify ${options.command}\` is starting, or a previous startup was interrupted.`, 'Wait for other starts to finish. If none is running, remove the startup lock below and try again.', [['Startup lock', { filePath: startupLock }]]);
60
+ startupError.code = DEV_INSTANCE_ALREADY_RUNNING_CODE;
61
+ throw startupError;
62
+ }
63
+ try {
64
+ return await createDevInstance(options, paths);
65
+ }
66
+ catch (error) {
67
+ if (!isLockedError(error))
68
+ throw error;
69
+ const existing = await readDevInstanceInfo(paths.infoFile);
70
+ throw devInstanceAlreadyRunningError(options, existing && isProcessAlive(existing.pid) ? existing : undefined);
71
+ }
72
+ finally {
73
+ await removeEmptyDirectory(startupLock);
74
+ }
75
+ }
76
+ /**
77
+ * Acquires a dev instance and releases it after the callback completes or throws.
78
+ *
79
+ * @param options - The command, project and output options for the instance.
80
+ * @param execute - The work to run while the instance is owned.
81
+ * @returns The callback's result after instance cleanup completes.
82
+ */
83
+ export async function withDevInstance(options, execute) {
84
+ const instance = await acquireDevInstance(options);
85
+ try {
86
+ return await execute(instance);
87
+ }
88
+ finally {
89
+ await instance.release();
90
+ }
91
+ }
92
+ async function createDevInstance(options, paths) {
93
+ const previous = await readDevInstanceInfo(paths.infoFile);
94
+ if (previous && isProcessAlive(previous.pid))
95
+ throw devInstanceAlreadyRunningError(options, previous);
96
+ const sessionId = randomUUID();
97
+ const abortController = new AbortController();
98
+ let compromised = false;
99
+ const ownsInfo = () => {
100
+ if (compromised)
101
+ return false;
102
+ try {
103
+ return JSON.parse(readFileSync(paths.infoFile, 'utf8')).sessionId === sessionId;
104
+ // A missing or unreadable record does not authorize deleting another session's files.
105
+ // eslint-disable-next-line no-catch-all/no-catch-all
106
+ }
107
+ catch {
108
+ return false;
109
+ }
110
+ };
111
+ let published = false;
112
+ const removeOwnedLockSync = (path) => {
113
+ if (published && !ownsInfo())
114
+ return;
115
+ try {
116
+ fs.rmdirSync(path);
117
+ }
118
+ catch (error) {
119
+ if (error.code !== 'ENOENT')
120
+ throw error;
121
+ }
122
+ };
123
+ const lockOptions = {
124
+ realpath: false,
125
+ lockfilePath: paths.lockFile,
126
+ stale: DEFAULT_STALE_MS,
127
+ retries: 0,
128
+ // The default handler throws asynchronously and would crash the long-running command.
129
+ onCompromised: (error) => {
130
+ compromised = true;
131
+ outputDebug(`The ${options.command} instance lock was compromised: ${error.message}`);
132
+ abortController.abort(new AbortError(`The ${options.command} instance lost its lock.`, 'Start the command again.'));
133
+ },
134
+ fs: {
135
+ ...fs,
136
+ rmdir: (path, callback) => {
137
+ if (published && !ownsInfo())
138
+ return callback(null);
139
+ // proper-lockfile requires the callback filesystem API.
140
+ // eslint-disable-next-line n/prefer-promises/fs
141
+ fs.rmdir(path, callback);
142
+ },
143
+ rmdirSync: removeOwnedLockSync,
144
+ },
145
+ };
146
+ if (previous)
147
+ await rmdir(paths.lockFile, { force: true });
148
+ const releaseLock = await lockfile.lock(paths.infoFile, lockOptions);
149
+ const now = formatJsonOutputTimestamp(new Date());
150
+ const info = {
151
+ schemaVersion: 1,
152
+ sessionId,
153
+ command: options.command,
154
+ ...(options.key ? { key: options.key } : {}),
155
+ pid: process.pid,
156
+ status: 'starting',
157
+ startedAt: now,
158
+ updatedAt: now,
159
+ directory: options.directory,
160
+ logFile: paths.logFile,
161
+ details: { ...(options.details ?? {}) },
162
+ };
163
+ let updates = Promise.resolve();
164
+ let released = false;
165
+ const output = createDevInstanceOutput({
166
+ logFile: paths.logFile,
167
+ logOutput: options.logOutput,
168
+ isActive: () => !released && !compromised,
169
+ onError: (error) => abortController.abort(error),
170
+ });
171
+ let releasePromise;
172
+ const removeInfoOnExit = () => {
173
+ // Remove the lock before the live owner's record, so a new starter cannot enter during cleanup.
174
+ if (!released && ownsInfo()) {
175
+ removeOwnedLockSync(paths.lockFile);
176
+ removeFileSync(paths.infoFile);
177
+ }
178
+ };
179
+ process.once('exit', removeInfoOnExit);
180
+ const instance = {
181
+ info,
182
+ paths,
183
+ abortSignal: abortController.signal,
184
+ update: async (changes) => {
185
+ if (releasePromise || compromised)
186
+ return;
187
+ if (changes.status)
188
+ info.status = changes.status;
189
+ if (changes.details)
190
+ info.details = { ...info.details, ...changes.details };
191
+ info.updatedAt = formatJsonOutputTimestamp(new Date());
192
+ const snapshot = { ...info, details: { ...info.details } };
193
+ const write = updates.then(async () => {
194
+ if (!compromised)
195
+ await writeDevInstanceInfo(paths.infoFile, snapshot);
196
+ });
197
+ updates = write.catch(() => { });
198
+ await write;
199
+ },
200
+ log: output.log,
201
+ tee: output.tee,
202
+ release: () => {
203
+ releasePromise ??= (async () => {
204
+ try {
205
+ const results = await output.flush();
206
+ const failure = results.find((result) => result.status === 'rejected');
207
+ await updates;
208
+ if (failure?.status === 'rejected')
209
+ throw failure.reason;
210
+ }
211
+ finally {
212
+ released = true;
213
+ process.removeListener('exit', removeInfoOnExit);
214
+ try {
215
+ await output.close();
216
+ }
217
+ finally {
218
+ const owned = ownsInfo();
219
+ await releaseLock().catch((error) => outputDebug(`Failed to release the dev instance lock: ${error.message}`));
220
+ if (owned)
221
+ await removeFile(paths.infoFile).catch(() => { });
222
+ }
223
+ }
224
+ })();
225
+ return releasePromise;
226
+ },
227
+ };
228
+ try {
229
+ await output.opened;
230
+ await writeDevInstanceInfo(paths.infoFile, info);
231
+ published = true;
232
+ return instance;
233
+ }
234
+ catch (error) {
235
+ // Closing an already failed log can reject too; preserve the original setup error.
236
+ await instance.release().catch((cleanupError) => outputDebug(cleanupError.message));
237
+ await removeFile(`${paths.infoFile}.${sessionId}.tmp`);
238
+ throw error;
239
+ }
240
+ }
241
+ /**
242
+ * Returns the running instance of a command for a project, if there is one.
243
+ *
244
+ * @param identity - The command, directory and optional key of the instance.
245
+ * @returns The instance description, or undefined when no live instance holds the lock.
246
+ */
247
+ export async function readDevInstance(identity) {
248
+ const paths = devInstancePaths(identity);
249
+ return readLiveDevInstance(paths);
250
+ }
251
+ /**
252
+ * Lists every running dev instance of a project, across commands and keys.
253
+ *
254
+ * @param directory - The project directory.
255
+ * @returns The descriptions of the live instances.
256
+ */
257
+ export async function listDevInstances(directory) {
258
+ const folder = joinPath(directory, '.shopify', DEV_INSTANCES_FOLDER);
259
+ if (!(await fileExists(folder)))
260
+ return [];
261
+ const infoFiles = await glob('*.json', { cwd: folder, absolute: true, onlyFiles: true });
262
+ const instances = await Promise.all(infoFiles.map((infoFile) => readLiveDevInstance({
263
+ folder,
264
+ infoFile,
265
+ lockFile: infoFile.replace(/\.json$/, '.lock'),
266
+ logFile: infoFile.replace(/\.json$/, '.jsonl'),
267
+ })));
268
+ return instances.filter((instance) => instance !== undefined);
269
+ }
270
+ /**
271
+ * Checks whether a process exists. A process owned by another user counts as alive.
272
+ *
273
+ * @param pid - The process ID.
274
+ * @returns True when the process exists.
275
+ */
276
+ export function isProcessAlive(pid) {
277
+ if (!Number.isInteger(pid) || pid <= 0)
278
+ return false;
279
+ try {
280
+ process.kill(pid, 0);
281
+ return true;
282
+ // eslint-disable-next-line no-catch-all/no-catch-all
283
+ }
284
+ catch (error) {
285
+ return error.code === 'EPERM';
286
+ }
287
+ }
288
+ async function readLiveDevInstance(paths) {
289
+ const info = await readDevInstanceInfo(paths.infoFile);
290
+ if (!info || !isProcessAlive(info.pid))
291
+ return undefined;
292
+ if (!(await lockIsFresh(paths)))
293
+ return undefined;
294
+ return info;
295
+ }
296
+ async function lockIsFresh(paths) {
297
+ try {
298
+ return await lockfile.check(paths.infoFile, {
299
+ realpath: false,
300
+ lockfilePath: paths.lockFile,
301
+ stale: DEFAULT_STALE_MS,
302
+ });
303
+ // eslint-disable-next-line no-catch-all/no-catch-all
304
+ }
305
+ catch {
306
+ return false;
307
+ }
308
+ }
309
+ async function readDevInstanceInfo(infoFile) {
310
+ try {
311
+ const parsed = JSON.parse(await readFile(infoFile));
312
+ return typeof parsed?.pid === 'number' ? parsed : undefined;
313
+ // eslint-disable-next-line no-catch-all/no-catch-all
314
+ }
315
+ catch {
316
+ return undefined;
317
+ }
318
+ }
319
+ async function writeDevInstanceInfo(infoFile, info) {
320
+ // Write then rename so readers never see a partial file. Details may hold local URLs with keys, so keep it private.
321
+ const temporaryFile = `${infoFile}.${info.sessionId}.tmp`;
322
+ await writeFileWithMode(temporaryFile, `${JSON.stringify(info, null, 2)}\n`, { mode: 0o600 });
323
+ await renameFile(temporaryFile, infoFile);
324
+ }
325
+ function isLockedError(error) {
326
+ return error?.code === 'ELOCKED';
327
+ }
328
+ function devInstanceSlug({ command, key }) {
329
+ const slug = [command, key]
330
+ .filter(Boolean)
331
+ .join('-')
332
+ .toLowerCase()
333
+ .replace(/[^a-z0-9._-]+/g, '-')
334
+ .replace(/^-+|-+$/g, '');
335
+ // Normalization can merge distinct identities, so hash the original command/key pair.
336
+ const identityHash = hashString(JSON.stringify([command, key ?? ''])).slice(0, 4);
337
+ return `${slug}-${identityHash}`;
338
+ }
339
+ function devInstanceAlreadyRunningError(identity, existing) {
340
+ const command = `shopify ${identity.command}`;
341
+ if (!existing) {
342
+ const error = new AbortError(`Another \`${command}\` is starting for this project.`, 'Wait a few seconds and try again, or stop the other process first.');
343
+ error.code = DEV_INSTANCE_ALREADY_RUNNING_CODE;
344
+ return error;
345
+ }
346
+ const stopCommand = process.platform === 'win32' ? `taskkill /PID ${existing.pid} /F` : `kill ${existing.pid}`;
347
+ const detailLines = Object.entries(existing.details)
348
+ .filter(([, value]) => typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
349
+ .map(([name, value]) => [name, String(value)]);
350
+ const error = new AbortError(`Another \`${command}\` is already running for this project.`, 'Use the running instance, or stop it before starting a new one.', [
351
+ ['Read its output in', { filePath: existing.logFile }],
352
+ ['Stop it with', { command: stopCommand }],
353
+ ], [
354
+ {
355
+ body: {
356
+ tabularData: [['PID', String(existing.pid)], ['Started', existing.startedAt], ...detailLines],
357
+ firstColumnSubdued: true,
358
+ },
359
+ },
360
+ ]);
361
+ error.code = DEV_INSTANCE_ALREADY_RUNNING_CODE;
362
+ error.details = { instance: existing };
363
+ return error;
364
+ }
365
+ //# sourceMappingURL=dev-instance.js.map