@shopify/cli-kit 4.6.1 → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/private/node/analytics/bounded-collections.js +1 -4
  2. package/dist/private/node/analytics/bounded-collections.js.map +1 -1
  3. package/dist/private/node/analytics/graphql-error-codes.d.ts +2 -2
  4. package/dist/private/node/analytics/graphql-error-codes.js +2 -2
  5. package/dist/private/node/analytics/graphql-error-codes.js.map +1 -1
  6. package/dist/private/node/analytics.js +12 -7
  7. package/dist/private/node/analytics.js.map +1 -1
  8. package/dist/private/node/api/headers.js +3 -0
  9. package/dist/private/node/api/headers.js.map +1 -1
  10. package/dist/private/node/api.js +8 -8
  11. package/dist/private/node/api.js.map +1 -1
  12. package/dist/private/node/conf-store.js +1 -1
  13. package/dist/private/node/conf-store.js.map +1 -1
  14. package/dist/private/node/content-tokens.js +27 -2
  15. package/dist/private/node/content-tokens.js.map +1 -1
  16. package/dist/private/node/otel-metrics.d.ts +1 -1
  17. package/dist/private/node/otel-metrics.js +5 -2
  18. package/dist/private/node/otel-metrics.js.map +1 -1
  19. package/dist/private/node/plugin-hints.d.ts +16 -0
  20. package/dist/private/node/plugin-hints.js +29 -0
  21. package/dist/private/node/plugin-hints.js.map +1 -0
  22. package/dist/private/node/request-ids.js +2 -3
  23. package/dist/private/node/request-ids.js.map +1 -1
  24. package/dist/private/node/session/device-authorization.js +4 -7
  25. package/dist/private/node/session/device-authorization.js.map +1 -1
  26. package/dist/private/node/session/exchange.d.ts +4 -4
  27. package/dist/private/node/session/exchange.js +21 -5
  28. package/dist/private/node/session/exchange.js.map +1 -1
  29. package/dist/private/node/testing/ui.js +18 -19
  30. package/dist/private/node/testing/ui.js.map +1 -1
  31. package/dist/private/node/ui/components/Alert.d.ts +1 -1
  32. package/dist/private/node/ui/components/Alert.js.map +1 -1
  33. package/dist/private/node/ui/components/ConcurrentOutput.test.js +2 -0
  34. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  35. package/dist/private/node/ui/components/DangerousConfirmationPrompt.d.ts +1 -1
  36. package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -1
  37. package/dist/private/node/ui/components/List.d.ts +1 -1
  38. package/dist/private/node/ui/components/List.js.map +1 -1
  39. package/dist/private/node/ui/components/Prompts/InfoMessage.d.ts +1 -1
  40. package/dist/private/node/ui/components/Prompts/InfoMessage.js.map +1 -1
  41. package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +1 -1
  42. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
  43. package/dist/private/node/ui/components/Prompts/PromptLayout.d.ts +1 -1
  44. package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -1
  45. package/dist/private/node/ui/components/SingleTask.test.js +1 -0
  46. package/dist/private/node/ui/components/SingleTask.test.js.map +1 -1
  47. package/dist/private/node/ui/components/TabularData.d.ts +1 -1
  48. package/dist/private/node/ui/components/TabularData.js +2 -1
  49. package/dist/private/node/ui/components/TabularData.js.map +1 -1
  50. package/dist/private/node/ui/components/TextPrompt.d.ts +1 -1
  51. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  52. package/dist/private/node/ui/components/TokenizedText.d.ts +1 -38
  53. package/dist/private/node/ui/components/TokenizedText.js +0 -54
  54. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  55. package/dist/private/node/ui/components/TokenizedText.test.js +2 -1
  56. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  57. package/dist/private/node/ui/components/token-item.d.ts +38 -0
  58. package/dist/private/node/ui/components/token-item.js +63 -0
  59. package/dist/private/node/ui/components/token-item.js.map +1 -0
  60. package/dist/private/node/ui/hooks/use-abort-signal.js +5 -4
  61. package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -1
  62. package/dist/private/node/ui/hooks/use-select-state.js +2 -1
  63. package/dist/private/node/ui/hooks/use-select-state.js.map +1 -1
  64. package/dist/private/node/ui/utilities.d.ts +6 -6
  65. package/dist/private/node/ui/utilities.js +1 -1
  66. package/dist/private/node/ui/utilities.js.map +1 -1
  67. package/dist/private/node/ui.js +18 -15
  68. package/dist/private/node/ui.js.map +1 -1
  69. package/dist/public/common/string.d.ts +1 -1
  70. package/dist/public/common/string.js.map +1 -1
  71. package/dist/public/common/version.d.ts +1 -1
  72. package/dist/public/common/version.js +1 -1
  73. package/dist/public/common/version.js.map +1 -1
  74. package/dist/public/node/abort.d.ts +14 -6
  75. package/dist/public/node/abort.js +7 -6
  76. package/dist/public/node/abort.js.map +1 -1
  77. package/dist/public/node/analytics.d.ts +1 -0
  78. package/dist/public/node/analytics.js +79 -32
  79. package/dist/public/node/analytics.js.map +1 -1
  80. package/dist/public/node/api/admin.js +1 -1
  81. package/dist/public/node/api/admin.js.map +1 -1
  82. package/dist/public/node/base-command.d.ts +10 -0
  83. package/dist/public/node/base-command.js +31 -8
  84. package/dist/public/node/base-command.js.map +1 -1
  85. package/dist/public/node/cli.d.ts +13 -0
  86. package/dist/public/node/cli.js +18 -2
  87. package/dist/public/node/cli.js.map +1 -1
  88. package/dist/public/node/context/local.d.ts +3 -1
  89. package/dist/public/node/context/local.js +14 -7
  90. package/dist/public/node/context/local.js.map +1 -1
  91. package/dist/public/node/custom-oclif-loader.js +19 -16
  92. package/dist/public/node/custom-oclif-loader.js.map +1 -1
  93. package/dist/public/node/doctor/framework.js +4 -5
  94. package/dist/public/node/doctor/framework.js.map +1 -1
  95. package/dist/public/node/environment.js +8 -11
  96. package/dist/public/node/environment.js.map +1 -1
  97. package/dist/public/node/error.d.ts +1 -4
  98. package/dist/public/node/error.js +20 -7
  99. package/dist/public/node/error.js.map +1 -1
  100. package/dist/public/node/git.js +7 -5
  101. package/dist/public/node/git.js.map +1 -1
  102. package/dist/public/node/global-context.js +1 -1
  103. package/dist/public/node/global-context.js.map +1 -1
  104. package/dist/public/node/hidden-folder.js +2 -4
  105. package/dist/public/node/hidden-folder.js.map +1 -1
  106. package/dist/public/node/hooks/postrun.js +1 -1
  107. package/dist/public/node/hooks/postrun.js.map +1 -1
  108. package/dist/public/node/hooks/prerun.js +5 -1
  109. package/dist/public/node/hooks/prerun.js.map +1 -1
  110. package/dist/public/node/local-storage.js +1 -0
  111. package/dist/public/node/local-storage.js.map +1 -1
  112. package/dist/public/node/metadata.d.ts +3 -0
  113. package/dist/public/node/metadata.js.map +1 -1
  114. package/dist/public/node/mimes.js +1 -3
  115. package/dist/public/node/mimes.js.map +1 -1
  116. package/dist/public/node/node-package-manager.js +31 -73
  117. package/dist/public/node/node-package-manager.js.map +1 -1
  118. package/dist/public/node/notifications-system.js +19 -3
  119. package/dist/public/node/notifications-system.js.map +1 -1
  120. package/dist/public/node/os.js +5 -10
  121. package/dist/public/node/os.js.map +1 -1
  122. package/dist/public/node/output.js +11 -20
  123. package/dist/public/node/output.js.map +1 -1
  124. package/dist/public/node/plugins/tunnel.d.ts +1 -2
  125. package/dist/public/node/plugins/tunnel.js +2 -2
  126. package/dist/public/node/plugins/tunnel.js.map +1 -1
  127. package/dist/public/node/result.js +4 -2
  128. package/dist/public/node/result.js.map +1 -1
  129. package/dist/public/node/serial-batch-processor.js +4 -3
  130. package/dist/public/node/serial-batch-processor.js.map +1 -1
  131. package/dist/public/node/store-auth-session.js +1 -1
  132. package/dist/public/node/store-auth-session.js.map +1 -1
  133. package/dist/public/node/system.d.ts +15 -1
  134. package/dist/public/node/system.js +42 -6
  135. package/dist/public/node/system.js.map +1 -1
  136. package/dist/public/node/themes/conf.js +2 -2
  137. package/dist/public/node/themes/conf.js.map +1 -1
  138. package/dist/public/node/themes/factories.js +2 -2
  139. package/dist/public/node/themes/factories.js.map +1 -1
  140. package/dist/public/node/themes/theme-manager.js +2 -0
  141. package/dist/public/node/themes/theme-manager.js.map +1 -1
  142. package/dist/public/node/themes/urls.js +7 -7
  143. package/dist/public/node/themes/urls.js.map +1 -1
  144. package/dist/public/node/toml/toml-file.js +12 -13
  145. package/dist/public/node/toml/toml-file.js.map +1 -1
  146. package/dist/public/node/ui.d.ts +1 -1
  147. package/dist/public/node/ui.js +1 -1
  148. package/dist/public/node/ui.js.map +1 -1
  149. package/dist/public/node/vendor/dev_server/dev-server-2024.js +14 -2
  150. package/dist/public/node/vendor/dev_server/dev-server-2024.js.map +1 -1
  151. package/dist/public/node/vendor/dev_server/dev-server.js +3 -0
  152. package/dist/public/node/vendor/dev_server/dev-server.js.map +1 -1
  153. package/dist/public/node/vendor/dev_server/network/index.js +1 -1
  154. package/dist/public/node/vendor/dev_server/network/index.js.map +1 -1
  155. package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js +1 -0
  156. package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js.map +1 -1
  157. package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js +5 -2
  158. package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js.map +1 -1
  159. package/dist/public/node/vendor/otel-js/service/types.d.ts +2 -2
  160. package/dist/public/node/vendor/otel-js/service/types.js.map +1 -1
  161. package/dist/public/node/vscode.js +12 -11
  162. package/dist/public/node/vscode.js.map +1 -1
  163. package/dist/tsconfig.tsbuildinfo +1 -1
  164. package/package.json +3 -9
@@ -1 +1 @@
1
- {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAA;AAGxC,IAAI,oBAAoB,GAAG,KAAK,CAAA;AAEhC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,cAAc,GAAG,GAAG,CAAA;IAC1B,oFAAoF;IACpF,2DAA2D;IAC3D,MAAM,SAAS,GAAG,MAAM,CAAA;IAExB,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,IAAI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B,CAAC,GAAG,EAAE,CAAC,CAAC;gBACzC,mBAAmB,EAAE;oBACnB,GAAG,mBAAmB;oBACtB,SAAS,EAAE,WAAW;oBACtB,YAAY,EAAE,WAAW;iBAC1B;aACF,CAAC,CAAC,CAAA;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * Postrun hook — uses dynamic imports to avoid loading heavy modules (base-command, analytics)\n * at module evaluation time. These are only needed after the command has already finished.\n */\nimport {treeKill} from '../tree-kill.js'\nimport {Command, Hook} from '@oclif/core'\n\nlet postRunHookCompleted = false\n\n/**\n * Check if post run hook has completed.\n *\n * @returns Whether post run hook has completed.\n */\nexport function postRunHookHasCompleted(): boolean {\n return postRunHookCompleted\n}\n\n/**\n * Wait for the postrun hook to finish (so auto-upgrade has a chance to run) and then\n * tree-kill the current process tree before exiting.\n *\n * Long-running interactive commands like `app dev` need this when the user terminates\n * the command via `q` or Ctrl+C. The dev sub-processes such as servers and watchers keep\n * the event loop alive, so even after oclif's postrun hook completes the node process\n * won't exit on its own and we have to `treeKill` the process tree. We must not do that\n * before the postrun hook has actually finished running auto-upgrade, otherwise we would\n * kill the upgrade mid-way while `npm install` is still running.\n *\n * The flag `postRunHookCompleted` is flipped at the very end of the hook after\n * `autoUpgradeIfNeeded` resolves, so polling it here is safe.\n */\nexport function waitForPostRunHookAndExit(): void {\n const pollIntervalMs = 100\n // Auto-upgrade can take a while (npm/pnpm/yarn install). Cap the wait generously so\n // a stuck upgrade still terminates the process eventually.\n const maxWaitMs = 120000\n\n let elapsed = 0\n let terminating = false\n const handle = setInterval(() => {\n if (terminating) return\n if (postRunHookHasCompleted() || elapsed >= maxWaitMs) {\n terminating = true\n clearInterval(handle)\n treeKill(process.pid, 'SIGINT', false, () => {\n process.exit(0)\n })\n return\n }\n elapsed += pollIntervalMs\n }, pollIntervalMs)\n}\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Postrun = async ({config, Command}) => {\n await detectStopCommand(Command as unknown as typeof Command)\n\n const metadata = await import('../metadata.js')\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n if (commandStartOptions) {\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n ...commandStartOptions,\n endTime: new Date().getTime(),\n },\n }))\n }\n\n const {postrun: deprecationsHook} = await import('./deprecations.js')\n deprecationsHook(Command)\n\n const {outputDebug} = await import('../output.js')\n const command = Command.id.replace(/:/g, ' ')\n outputDebug(`Completed command ${command}`)\n\n if (!command.includes('notifications') && !command.includes('upgrade')) await autoUpgradeIfNeeded()\n\n const {reportAnalyticsEvent} = await import('../analytics.js')\n await reportAnalyticsEvent({config, exitMode: 'ok'})\n\n postRunHookCompleted = true\n}\n\n/**\n * Auto-upgrades the CLI after a command completes, if a newer version is available.\n * The entire flow is rate-limited to once per day unless forced via SHOPIFY_CLI_FORCE_AUTO_UPGRADE.\n *\n * @returns Resolves when the upgrade attempt (or fallback warning) is complete.\n */\nexport async function autoUpgradeIfNeeded(): Promise<void> {\n const {versionToAutoUpgrade, warnIfUpgradeAvailable} = await import('../upgrade.js')\n const newerVersion = versionToAutoUpgrade()\n if (!newerVersion) {\n await warnIfUpgradeAvailable()\n return\n }\n\n const forced = process.env.SHOPIFY_CLI_FORCE_AUTO_UPGRADE === '1'\n\n // SHOPIFY_CLI_FORCE_AUTO_UPGRADE bypasses the daily rate limit so tests and intentional upgrades always run.\n if (forced) {\n await performAutoUpgrade(newerVersion)\n } else {\n const {runAtMinimumInterval} = await import('../../../private/node/conf-store.js')\n // Rate-limit the entire upgrade flow to once per day to avoid repeated attempts and major-version warnings.\n await runAtMinimumInterval('auto-upgrade', {days: 1}, async () => {\n await performAutoUpgrade(newerVersion)\n })\n }\n}\n\nasync function performAutoUpgrade(newerVersion: string): Promise<void> {\n const [\n {CLI_KIT_VERSION},\n {isMajorVersionChange},\n {outputWarn, outputDebug},\n {getOutputUpdateCLIReminder, runCLIUpgrade, hasBlockingAutoUpgradeNotification},\n metadata,\n ] = await Promise.all([\n import('../../common/version.js'),\n import('../version.js'),\n import('../output.js'),\n import('../upgrade.js'),\n import('../metadata.js'),\n ])\n\n if (isMajorVersionChange(CLI_KIT_VERSION, newerVersion)) {\n outputWarn(getOutputUpdateCLIReminder(newerVersion, true))\n await metadata.addPublicMetadata(() => ({\n env_auto_upgrade_skipped_reason: 'major_version',\n }))\n return\n }\n\n // Notification kill switch: an `error`-type notification on the `autoupgrade` surface\n // silently disables auto-upgrade. Checked last — after every other gate, including the\n // daily rate limit and the major-version check — so the network fetch only happens when\n // we're about to actually run the upgrade.\n if (await hasBlockingAutoUpgradeNotification()) {\n await metadata.addPublicMetadata(() => ({\n env_auto_upgrade_skipped_reason: 'blocked_by_notification',\n }))\n return\n }\n\n try {\n await runCLIUpgrade({autoupgrade: true})\n await metadata.addPublicMetadata(() => ({env_auto_upgrade_success: true}))\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n const errorMessage = `Auto-upgrade failed: ${error}`\n outputDebug(errorMessage)\n outputWarn(getOutputUpdateCLIReminder(newerVersion))\n await metadata.addPublicMetadata(() => ({env_auto_upgrade_success: false}))\n // Report to Observe as a handled error without showing anything extra to the user\n const [{sendErrorToBugsnag}, {inferPackageManagerForGlobalCLI}] = await Promise.all([\n import('../error-handler.js'),\n import('../is-global.js'),\n ])\n const enrichedError = Object.assign(new Error(errorMessage), {\n packageManager: inferPackageManagerForGlobalCLI(),\n platform: process.platform,\n cliVersion: CLI_KIT_VERSION,\n })\n await sendErrorToBugsnag(enrichedError, 'expected_error')\n }\n}\n\n/**\n * Override the command name with the stop one for analytics purposes.\n *\n * @param commandClass - Command.Class.\n */\nasync function detectStopCommand(commandClass: Command.Class): Promise<void> {\n const currentTime = new Date().getTime()\n // Check for analyticsStopCommand without importing BaseCommand\n if (\n commandClass &&\n 'analyticsStopCommand' in commandClass &&\n typeof commandClass.analyticsStopCommand === 'function'\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stopCommand = (commandClass as any).analyticsStopCommand()\n if (stopCommand) {\n const metadata = await import('../metadata.js')\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n if (!commandStartOptions) return\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n ...commandStartOptions,\n startTime: currentTime,\n startCommand: stopCommand,\n },\n }))\n }\n }\n}\n"]}
1
+ {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAA;AAGxC,IAAI,oBAAoB,GAAG,KAAK,CAAA;AAEhC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,cAAc,GAAG,GAAG,CAAA;IAC1B,oFAAoF;IACpF,2DAA2D;IAC3D,MAAM,SAAS,GAAG,MAAM,CAAA;IAExB,IAAI,OAAO,GAAG,CAAC,CAAA;IACf,IAAI,WAAW,GAAG,KAAK,CAAA;IACvB,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,IAAI,WAAW;YAAE,OAAM;QACvB,IAAI,uBAAuB,EAAE,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;YACtD,WAAW,GAAG,IAAI,CAAA;YAClB,aAAa,CAAC,MAAM,CAAC,CAAA;YACrB,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;gBAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YACjB,CAAC,CAAC,CAAA;YACF,OAAM;QACR,CAAC;QACD,OAAO,IAAI,cAAc,CAAA;IAC3B,CAAC,EAAE,cAAc,CAAC,CAAA;AACpB,CAAC;AAED,gGAAgG;AAChG,MAAM,CAAC,MAAM,IAAI,GAAiB,KAAK,EAAE,EAAC,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,+BAA+B,EAAE;YACjD,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,eAAe;SAC5B,CAAC,CAAA;QACF,MAAM,kBAAkB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,iBAAiB,CAAC,YAA2B;IAC1D,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IACxC,+DAA+D;IAC/D,IACE,YAAY;QACZ,sBAAsB,IAAI,YAAY;QACtC,OAAO,YAAY,CAAC,oBAAoB,KAAK,UAAU,EACvD,CAAC;QACD,8DAA8D;QAC9D,MAAM,WAAW,GAAI,YAAoB,CAAC,oBAAoB,EAAE,CAAA;QAChE,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAA;YAC/C,MAAM,EAAC,mBAAmB,EAAC,GAAG,QAAQ,CAAC,uBAAuB,EAAE,CAAA;YAChE,IAAI,CAAC,mBAAmB;gBAAE,OAAM;YAChC,MAAM,QAAQ,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC;gBACzC,mBAAmB,EAAE;oBACnB,GAAG,mBAAmB;oBACtB,SAAS,EAAE,WAAW;oBACtB,YAAY,EAAE,WAAW;iBAC1B;aACF,CAAC,CAAC,CAAA;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * Postrun hook — uses dynamic imports to avoid loading heavy modules (base-command, analytics)\n * at module evaluation time. These are only needed after the command has already finished.\n */\nimport {treeKill} from '../tree-kill.js'\nimport {Command, Hook} from '@oclif/core'\n\nlet postRunHookCompleted = false\n\n/**\n * Check if post run hook has completed.\n *\n * @returns Whether post run hook has completed.\n */\nexport function postRunHookHasCompleted(): boolean {\n return postRunHookCompleted\n}\n\n/**\n * Wait for the postrun hook to finish (so auto-upgrade has a chance to run) and then\n * tree-kill the current process tree before exiting.\n *\n * Long-running interactive commands like `app dev` need this when the user terminates\n * the command via `q` or Ctrl+C. The dev sub-processes such as servers and watchers keep\n * the event loop alive, so even after oclif's postrun hook completes the node process\n * won't exit on its own and we have to `treeKill` the process tree. We must not do that\n * before the postrun hook has actually finished running auto-upgrade, otherwise we would\n * kill the upgrade mid-way while `npm install` is still running.\n *\n * The flag `postRunHookCompleted` is flipped at the very end of the hook after\n * `autoUpgradeIfNeeded` resolves, so polling it here is safe.\n */\nexport function waitForPostRunHookAndExit(): void {\n const pollIntervalMs = 100\n // Auto-upgrade can take a while (npm/pnpm/yarn install). Cap the wait generously so\n // a stuck upgrade still terminates the process eventually.\n const maxWaitMs = 120000\n\n let elapsed = 0\n let terminating = false\n const handle = setInterval(() => {\n if (terminating) return\n if (postRunHookHasCompleted() || elapsed >= maxWaitMs) {\n terminating = true\n clearInterval(handle)\n treeKill(process.pid, 'SIGINT', false, () => {\n process.exit(0)\n })\n return\n }\n elapsed += pollIntervalMs\n }, pollIntervalMs)\n}\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Postrun = async ({config, Command}) => {\n await detectStopCommand(Command as unknown as typeof Command)\n\n const metadata = await import('../metadata.js')\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n if (commandStartOptions) {\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n ...commandStartOptions,\n endTime: new Date().getTime(),\n },\n }))\n }\n\n const {postrun: deprecationsHook} = await import('./deprecations.js')\n deprecationsHook(Command)\n\n const {outputDebug} = await import('../output.js')\n const command = Command.id.replace(/:/g, ' ')\n outputDebug(`Completed command ${command}`)\n\n if (!command.includes('notifications') && !command.includes('upgrade') && !command.includes('send-analytics'))\n await autoUpgradeIfNeeded()\n\n const {reportAnalyticsEvent} = await import('../analytics.js')\n await reportAnalyticsEvent({config, exitMode: 'ok'})\n postRunHookCompleted = true\n}\n\n/**\n * Auto-upgrades the CLI after a command completes, if a newer version is available.\n * The entire flow is rate-limited to once per day unless forced via SHOPIFY_CLI_FORCE_AUTO_UPGRADE.\n *\n * @returns Resolves when the upgrade attempt (or fallback warning) is complete.\n */\nexport async function autoUpgradeIfNeeded(): Promise<void> {\n const {versionToAutoUpgrade, warnIfUpgradeAvailable} = await import('../upgrade.js')\n const newerVersion = versionToAutoUpgrade()\n if (!newerVersion) {\n await warnIfUpgradeAvailable()\n return\n }\n\n const forced = process.env.SHOPIFY_CLI_FORCE_AUTO_UPGRADE === '1'\n\n // SHOPIFY_CLI_FORCE_AUTO_UPGRADE bypasses the daily rate limit so tests and intentional upgrades always run.\n if (forced) {\n await performAutoUpgrade(newerVersion)\n } else {\n const {runAtMinimumInterval} = await import('../../../private/node/conf-store.js')\n // Rate-limit the entire upgrade flow to once per day to avoid repeated attempts and major-version warnings.\n await runAtMinimumInterval('auto-upgrade', {days: 1}, async () => {\n await performAutoUpgrade(newerVersion)\n })\n }\n}\n\nasync function performAutoUpgrade(newerVersion: string): Promise<void> {\n const [\n {CLI_KIT_VERSION},\n {isMajorVersionChange},\n {outputWarn, outputDebug},\n {getOutputUpdateCLIReminder, runCLIUpgrade, hasBlockingAutoUpgradeNotification},\n metadata,\n ] = await Promise.all([\n import('../../common/version.js'),\n import('../version.js'),\n import('../output.js'),\n import('../upgrade.js'),\n import('../metadata.js'),\n ])\n\n if (isMajorVersionChange(CLI_KIT_VERSION, newerVersion)) {\n outputWarn(getOutputUpdateCLIReminder(newerVersion, true))\n await metadata.addPublicMetadata(() => ({\n env_auto_upgrade_skipped_reason: 'major_version',\n }))\n return\n }\n\n // Notification kill switch: an `error`-type notification on the `autoupgrade` surface\n // silently disables auto-upgrade. Checked last — after every other gate, including the\n // daily rate limit and the major-version check — so the network fetch only happens when\n // we're about to actually run the upgrade.\n if (await hasBlockingAutoUpgradeNotification()) {\n await metadata.addPublicMetadata(() => ({\n env_auto_upgrade_skipped_reason: 'blocked_by_notification',\n }))\n return\n }\n\n try {\n await runCLIUpgrade({autoupgrade: true})\n await metadata.addPublicMetadata(() => ({env_auto_upgrade_success: true}))\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n const errorMessage = `Auto-upgrade failed: ${error}`\n outputDebug(errorMessage)\n outputWarn(getOutputUpdateCLIReminder(newerVersion))\n await metadata.addPublicMetadata(() => ({env_auto_upgrade_success: false}))\n // Report to Observe as a handled error without showing anything extra to the user\n const [{sendErrorToBugsnag}, {inferPackageManagerForGlobalCLI}] = await Promise.all([\n import('../error-handler.js'),\n import('../is-global.js'),\n ])\n const enrichedError = Object.assign(new Error(errorMessage), {\n packageManager: inferPackageManagerForGlobalCLI(),\n platform: process.platform,\n cliVersion: CLI_KIT_VERSION,\n })\n await sendErrorToBugsnag(enrichedError, 'expected_error')\n }\n}\n\n/**\n * Override the command name with the stop one for analytics purposes.\n *\n * @param commandClass - Command.Class.\n */\nasync function detectStopCommand(commandClass: Command.Class): Promise<void> {\n const currentTime = new Date().getTime()\n // Check for analyticsStopCommand without importing BaseCommand\n if (\n commandClass &&\n 'analyticsStopCommand' in commandClass &&\n typeof commandClass.analyticsStopCommand === 'function'\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stopCommand = (commandClass as any).analyticsStopCommand()\n if (stopCommand) {\n const metadata = await import('../metadata.js')\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n if (!commandStartOptions) return\n await metadata.addSensitiveMetadata(() => ({\n commandStartOptions: {\n ...commandStartOptions,\n startTime: currentTime,\n startCommand: stopCommand,\n },\n }))\n }\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { emitClaudeCodePluginHint } from '../../../private/node/plugin-hints.js';
1
2
  // This hook is called before each command run. More info: https://oclif.io/docs/hooks
2
3
  export const hook = async (options) => {
3
4
  const commandContent = parseCommandContent({
@@ -6,6 +7,9 @@ export const hook = async (options) => {
6
7
  pluginAlias: options.Command.plugin?.alias,
7
8
  });
8
9
  const args = options.argv;
10
+ // Emit on every resolved command invocation; --help, --version, and parse errors exit before prerun.
11
+ // Claude Code owns deduplication and covers first-party and plugin commands.
12
+ emitClaudeCodePluginHint();
9
13
  // Load heavy modules in parallel
10
14
  const [{ outputDebug }, analyticsMod, notificationsMod] = await Promise.all([
11
15
  import('../output.js'),
@@ -21,7 +25,7 @@ export const hook = async (options) => {
21
25
  };
22
26
  export function parseCommandContent(cmdInfo) {
23
27
  let commandContent = parseCreateCommand(cmdInfo.pluginAlias);
24
- commandContent ?? (commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases));
28
+ commandContent ??= parseNormalCommand(cmdInfo.id, cmdInfo.aliases);
25
29
  return commandContent;
26
30
  }
27
31
  function parseNormalCommand(id, aliases) {
@@ -1 +1 @@
1
- {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/prerun.ts"],"names":[],"mappings":"AAQA,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,cAAc,GAAG,mBAAmB,CAAC;QACzC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK;KAC3C,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAEzB,iCAAiC;IACjC,MAAM,CAAC,EAAC,WAAW,EAAC,EAAE,YAAY,EAAE,gBAAgB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACxE,MAAM,CAAC,cAAc,CAAC;QACtB,MAAM,CAAC,oCAAoC,CAAC;QAC5C,MAAM,CAAC,4BAA4B,CAAC;KACrC,CAAC,CAAA;IAEF,kDAAkD;IAClD,mCAAmC;IACnC,KAAK,8BAA8B,EAAE,CAAA;IAErC,WAAW,CAAC,mBAAmB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAA;IACxD,MAAM,YAAY,C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AA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAiB;IAClC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B;IAClD,MAAM,CAAC,EAAC,eAAe,EAAC,EAAE,EAAC,mBAAmB,EAAC,EAAE,EAAC,kBAAkB,EAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzF,MAAM,CAAC,yBAAyB,CAAC;QACjC,MAAM,CAAC,eAAe,CAAC;QACvB,MAAM,CAAC,4BAA4B,CAAC;KACrC,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,eAAe,CAAA;IACtC,IAAI,mBAAmB,CAAC,cAAc,CAAC,EAAE,CAAC;QACxC,OAAM;IACR,CAAC;IACD,mCAAmC;IACnC,KAAK,kBAAkB,CAAC,cAAc,EAAE,cAAc,EAAE,EAAC,kBAAkB,EAAE,EAAE,EAAC,CAAC,CAAA;AACnF,CAAC","sourcesContent":["import {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n\n // Load heavy modules in parallel\n const [{outputDebug}, analyticsMod, notificationsMod] = await Promise.all([\n import('../output.js'),\n import('../../../private/node/analytics.js'),\n import('../notifications-system.js'),\n ])\n\n // Fire upgrade check in background (non-blocking)\n // eslint-disable-next-line no-void\n void checkForNewVersionInBackground()\n\n outputDebug(`Running command ${commandContent.command}`)\n await analyticsMod.startAnalytics({commandContent, args, commandClass: options.Command})\n notificationsMod.fetchNotificationsInBackground(options.Command.id)\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}): CommandContent {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n commandContent ??= parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias?.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n\n/**\n * Triggers a background check for a newer CLI version (non-blocking).\n * The result is cached and consumed by the postrun hook for auto-upgrade.\n */\nexport async function checkForNewVersionInBackground(): Promise<void> {\n const [{CLI_KIT_VERSION}, {isPreReleaseVersion}, {checkForNewVersion}] = await Promise.all([\n import('../../common/version.js'),\n import('../version.js'),\n import('../node-package-manager.js'),\n ])\n const currentVersion = CLI_KIT_VERSION\n if (isPreReleaseVersion(currentVersion)) {\n return\n }\n // eslint-disable-next-line no-void\n void checkForNewVersion('@shopify/cli', currentVersion, {cacheExpiryInHours: 24})\n}\n"]}
1
+ {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAA;AAS9E,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,cAAc,GAAG,mBAAmB,CAAC;QACzC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK;KAC3C,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IAEzB,qGAAqG;IACrG,6EAA6E;IAC7E,wBAAwB,EAAE,CAAA;IAE1B,iCAAiC;IACjC,MAAM,CAAC,EAAC,WAAW,EAAC,EAAE,YAAY,EAAE,gBAAgB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACxE,MAAM,CAAC,cAAc,CAAC;QACtB,MAAM,CAAC,oCAAoC,CAAC;QAC5C,MAAM,CAAC,4BAA4B,CAAC;KACrC,CAAC,CAAA;IAEF,kDAAkD;IAClD,mCAAmC;IACnC,KAAK,8BAA8B,EAAE,CAAA;IAErC,WAAW,CAAC,mBAAmB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAA;IACxD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CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAiB;IAClC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B;IAClD,MAAM,CAAC,EAAC,eAAe,EAAC,EAAE,EAAC,mBAAmB,EAAC,EAAE,EAAC,kBAAkB,EAAC,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzF,MAAM,CAAC,yBAAyB,CAAC;QACjC,MAAM,CAAC,eAAe,CAAC;QACvB,MAAM,CAAC,4BAA4B,CAAC;KACrC,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,eAAe,CAAA;IACtC,IAAI,mBAAmB,CAAC,cAAc,CAAC,EAAE,CAAC;QACxC,OAAM;IACR,CAAC;IACD,mCAAmC;IACnC,KAAK,kBAAkB,CAAC,cAAc,EAAE,cAAc,EAAE,EAAC,kBAAkB,EAAE,EAAE,EAAC,CAAC,CAAA;AACnF,CAAC","sourcesContent":["import {emitClaudeCodePluginHint} from '../../../private/node/plugin-hints.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n\n // Emit on every resolved command invocation; --help, --version, and parse errors exit before prerun.\n // Claude Code owns deduplication and covers first-party and plugin commands.\n emitClaudeCodePluginHint()\n\n // Load heavy modules in parallel\n const [{outputDebug}, analyticsMod, notificationsMod] = await Promise.all([\n import('../output.js'),\n import('../../../private/node/analytics.js'),\n import('../notifications-system.js'),\n ])\n\n // Fire upgrade check in background (non-blocking)\n // eslint-disable-next-line no-void\n void checkForNewVersionInBackground()\n\n outputDebug(`Running command ${commandContent.command}`)\n await analyticsMod.startAnalytics({commandContent, args, commandClass: options.Command})\n notificationsMod.fetchNotificationsInBackground(options.Command.id)\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}): CommandContent {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n commandContent ??= parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias?.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n\n/**\n * Triggers a background check for a newer CLI version (non-blocking).\n * The result is cached and consumed by the postrun hook for auto-upgrade.\n */\nexport async function checkForNewVersionInBackground(): Promise<void> {\n const [{CLI_KIT_VERSION}, {isPreReleaseVersion}, {checkForNewVersion}] = await Promise.all([\n import('../../common/version.js'),\n import('../version.js'),\n import('../node-package-manager.js'),\n ])\n const currentVersion = CLI_KIT_VERSION\n if (isPreReleaseVersion(currentVersion)) {\n return\n }\n // eslint-disable-next-line no-void\n void checkForNewVersion('@shopify/cli', currentVersion, {cacheExpiryInHours: 24})\n}\n"]}
@@ -13,6 +13,7 @@ function deserializeJson(value) {
13
13
  */
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  export class LocalStorage {
16
+ config;
16
17
  constructor(options) {
17
18
  this.config = new Config({
18
19
  ...options,
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../../src/public/node/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,uBAAuB,EAAE,4BAA4B,EAAC,MAAM,SAAS,CAAA;AAC7E,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,MAAM,MAAM,MAAM,CAAA;AAEzB,SAAS,eAAe,CAAI,KAAa;IACvC,oGAAoG;IACpG,MAAM,yBAAyB,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAM,CAAA;AACnD,CAAC;AAED;;;GAGG;AACH,8DAA8D;AAC9D,MAAM,OAAO,YAAY;IAGvB,YAAY,OAA6C;QACvD,IAAI,CAAC,MAAM,GAAG,I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M,CAAC,IAAI,CAAC,EAAE,EAAC,CAAC,CAAA;QAE9D,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {fileHasWritePermissions, unixFileIsOwnedByCurrentUser} from './fs.js'\nimport {dirname} from './path.js'\nimport {TokenItem} from './ui.js'\nimport Config from 'conf'\n\nfunction deserializeJson<T>(value: string): T {\n // Some Windows editors encode UTF-8 files with a byte order mark, which JSON.parse does not accept.\n const valueWithoutByteOrderMark = value.replace(/^\\uFEFF/, '')\n return JSON.parse(valueWithoutByteOrderMark) as T\n}\n\n/**\n * A wrapper around the `conf` package that provides a strongly-typed interface\n * for accessing the local storage.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class LocalStorage<T extends Record<string, any>> {\n private readonly config: Config<T>\n\n constructor(options: {projectName?: string; cwd?: string}) {\n this.config = new Config<T>({\n ...options,\n clearInvalidConfig: true,\n deserialize: deserializeJson<T>,\n })\n }\n\n /**\n * Get a value from the local storage.\n *\n * @param key - The key to get.\n * @returns The value.\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n get<TKey extends keyof T>(key: TKey): T[TKey] | undefined {\n try {\n return this.config.get(key)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'get')\n }\n }\n\n /**\n * Set a value in the local storage.\n *\n * @param key - The key to set.\n * @param value - The value to set.\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n set<TKey extends keyof T>(key: TKey, value?: T[TKey]): void {\n try {\n this.config.set(key, value)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'set')\n }\n }\n\n /**\n * Delete a value from the local storage.\n *\n * @param key - The key to delete.\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n delete<TKey extends keyof T>(key: TKey): void {\n try {\n this.config.delete(key)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'delete')\n }\n }\n\n /**\n * Clear the local storage (delete all values).\n *\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n clear(): void {\n try {\n this.config.clear()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'clear')\n }\n }\n\n /**\n * Handle errors from config operations.\n * If the error is permission-related, throw an AbortError with helpful hints.\n * Otherwise, throw a BugError.\n *\n * @param error - The error that occurred.\n * @param operation - The operation that failed.\n * @throws AbortError if the error is permission-related.\n * @throws BugError if the error is not permission-related.\n */\n private handleError(error: unknown, operation: string): never {\n if (this.isPermissionError()) {\n throw new AbortError(`Failed to access local storage (${operation}): ${error}`, this.tryMessage())\n } else {\n throw new BugError(\n `Unexpected error while accessing local storage at ${this.config.path} (${operation}): ${error}`,\n )\n }\n }\n\n private isPermissionError(): boolean {\n const canAccessFile = fileHasWritePermissions(this.config.path)\n const canAccessFolder = fileHasWritePermissions(dirname(this.config.path))\n const ownsFile = unixFileIsOwnedByCurrentUser(this.config.path)\n\n return !canAccessFile || !canAccessFolder || ownsFile === false\n }\n\n private tryMessage() {\n const ownsFile = unixFileIsOwnedByCurrentUser(this.config.path)\n const ownsFolder = unixFileIsOwnedByCurrentUser(dirname(this.config.path))\n\n const message: TokenItem = [`Check that you have write permissions for`, {filePath: this.config.path}]\n if (ownsFile === false || ownsFolder === false) {\n message.push(\n '- The file is owned by a different user. This typically happens when Shopify CLI was previously run with elevated permissions (e.g., sudo).',\n )\n }\n\n message.push('\\n\\nTo resolve this, remove the Shopify CLI preferences folder:')\n message.push({command: `rm -rf ${dirname(this.config.path)}`})\n\n return message\n }\n}\n"]}
1
+ {"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../../src/public/node/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,uBAAuB,EAAE,4BAA4B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AC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QAE1E,MAAM,OAAO,GAAc,CAAC,2CAA2C,EAAE,EAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAC,CAAC,CAAA;QACtG,IAAI,QAAQ,KAAK,KAAK,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YAC/C,OAAO,CAAC,IAAI,CACV,6IAA6I,CAC9I,CAAA;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAA;QAC/E,OAAO,CAAC,IAAI,CAAC,EAAC,OAAO,EAAE,UAAU,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAC,CAAC,CAAA;QAE9D,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {fileHasWritePermissions, unixFileIsOwnedByCurrentUser} from './fs.js'\nimport {dirname} from './path.js'\nimport {TokenItem} from './ui.js'\nimport Config from 'conf'\n\nfunction deserializeJson<T>(value: string): T {\n // Some Windows editors encode UTF-8 files with a byte order mark, which JSON.parse does not accept.\n const valueWithoutByteOrderMark = value.replace(/^\\uFEFF/, '')\n return JSON.parse(valueWithoutByteOrderMark) as T\n}\n\n/**\n * A wrapper around the `conf` package that provides a strongly-typed interface\n * for accessing the local storage.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class LocalStorage<T extends Record<string, any>> {\n private readonly config: Config<T>\n\n constructor(options: {projectName?: string; cwd?: string}) {\n this.config = new Config<T>({\n ...options,\n clearInvalidConfig: true,\n deserialize: deserializeJson<T>,\n })\n }\n\n /**\n * Get a value from the local storage.\n *\n * @param key - The key to get.\n * @returns The value.\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n get<TKey extends keyof T>(key: TKey): T[TKey] | undefined {\n try {\n return this.config.get(key)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'get')\n }\n }\n\n /**\n * Set a value in the local storage.\n *\n * @param key - The key to set.\n * @param value - The value to set.\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n set<TKey extends keyof T>(key: TKey, value?: T[TKey]): void {\n try {\n this.config.set(key, value)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'set')\n }\n }\n\n /**\n * Delete a value from the local storage.\n *\n * @param key - The key to delete.\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n delete<TKey extends keyof T>(key: TKey): void {\n try {\n this.config.delete(key)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'delete')\n }\n }\n\n /**\n * Clear the local storage (delete all values).\n *\n * @throws AbortError if a permission error occurs.\n * @throws BugError if an unexpected error occurs.\n */\n clear(): void {\n try {\n this.config.clear()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n this.handleError(error, 'clear')\n }\n }\n\n /**\n * Handle errors from config operations.\n * If the error is permission-related, throw an AbortError with helpful hints.\n * Otherwise, throw a BugError.\n *\n * @param error - The error that occurred.\n * @param operation - The operation that failed.\n * @throws AbortError if the error is permission-related.\n * @throws BugError if the error is not permission-related.\n */\n private handleError(error: unknown, operation: string): never {\n if (this.isPermissionError()) {\n throw new AbortError(`Failed to access local storage (${operation}): ${error}`, this.tryMessage())\n } else {\n throw new BugError(\n `Unexpected error while accessing local storage at ${this.config.path} (${operation}): ${error}`,\n )\n }\n }\n\n private isPermissionError(): boolean {\n const canAccessFile = fileHasWritePermissions(this.config.path)\n const canAccessFolder = fileHasWritePermissions(dirname(this.config.path))\n const ownsFile = unixFileIsOwnedByCurrentUser(this.config.path)\n\n return !canAccessFile || !canAccessFolder || ownsFile === false\n }\n\n private tryMessage() {\n const ownsFile = unixFileIsOwnedByCurrentUser(this.config.path)\n const ownsFolder = unixFileIsOwnedByCurrentUser(dirname(this.config.path))\n\n const message: TokenItem = [`Check that you have write permissions for`, {filePath: this.config.path}]\n if (ownsFile === false || ownsFolder === false) {\n message.push(\n '- The file is owned by a different user. This typically happens when Shopify CLI was previously run with elevated permissions (e.g., sudo).',\n )\n }\n\n message.push('\\n\\nTo resolve this, remove the Shopify CLI preferences folder:')\n message.push({command: `rm -rf ${dirname(this.config.path)}`})\n\n return message\n }\n}\n"]}
@@ -42,6 +42,7 @@ declare const coreData: RuntimeMetadataManager<CmdFieldsFromMonorail, {
42
42
  startCommand: string;
43
43
  startTopic?: string;
44
44
  startArgs: string[];
45
+ requiresSyncAnalytics?: boolean;
45
46
  };
46
47
  } & {
47
48
  environmentFlags: string;
@@ -63,6 +64,7 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
63
64
  startCommand: string;
64
65
  startTopic?: string;
65
66
  startArgs: string[];
67
+ requiresSyncAnalytics?: boolean;
66
68
  };
67
69
  } & {
68
70
  environmentFlags: string;
@@ -83,6 +85,7 @@ export declare const getAllPublicMetadata: () => Partial<CmdFieldsFromMonorail>,
83
85
  startCommand: string;
84
86
  startTopic?: string;
85
87
  startArgs: string[];
88
+ requiresSyncAnalytics?: boolean;
86
89
  };
87
90
  } & {
88
91
  environmentFlags: string;
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/public/node/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAe3C;;;;GAIG;AACH,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AA4BD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAG5C,wBAA0C,EAAE;IAC5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;Q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7B,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,iBAAiB,CAAA;oBAC9G,CAAC;oBAED,+KAA+K;oBAC/K,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,aAAa,EAAE;wBACzC,KAAK;wBACL,QAAQ;wBACR,8DAA8D;qBACxD,CAAC,CAAA;oBACT,WAAW,CAAC,OAAO,CAAC,GAAG,KAAK,OAAO,EAAE;wBACnC,KAAK;wBACL,GAAG;wBACH,8DAA8D;qBACxD,CAAC,CAAA;oBAET,sCAAsC;oBACtC,IAAI,YAAY,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAW,CAAA;oBACrD,YAAY,IAAI,QAAQ,CAAA;oBAExB,wFAAwF;oBACxF,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,YAA8C,CAAA;gBACpE,CAAC;YACH,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAWD,MAAM,QAAQ,GAAG,8BAA8B,CAW7C,EAAC,yBAAyB,EAAE,CAAC,EAAE,yBAAyB,EAAE,CAAC,EAAC,CAAC,CAAA;AAE/D,MAAM,CAAC,MAAM,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,YAAY,EAAC,GACjH,QAAQ,CAAA","sourcesContent":["import {isUnitTest} from './context/local.js'\nimport {performance} from 'node:perf_hooks'\nimport type {PickByPrefix} from '../common/ts/pick-by-prefix.js'\nimport type {AnyJson} from '../../private/common/json.js'\nimport type {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\n/**\n * Get the error handling strategy for metadata.\n *\n * @returns 'mute-and-report' in production, 'bubble' in tests.\n */\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\n/**\n * Any key in T that has a numeric value.\n */\ntype NumericKeyOf<T> = {\n [K in keyof T]: T[K] extends number ? (K extends string ? K : never) : never\n}[keyof T]\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII. */\n addPublicMetadata: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /**\n * Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked\n * (this is a good fit for command args for instance).\n */\n addSensitiveMetadata: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data. */\n getAllPublicMetadata: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data. */\n getAllSensitiveMetadata: () => Partial<TSensitive>\n /** Run a function, monitoring how long it takes, and adding the elapsed time to a running total. */\n runWithTimer: (field: NumericKeyOf<TPublic>) => <T>(fn: () => Promise<T>) => Promise<T>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n * @param defaultPublicMetadata - Optional, default data for the container.\n * @returns A container for the metadata.\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = Record<string, never>,\n>(defaultPublicMetadata: Partial<TPublic> = {}): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {\n ...defaultPublicMetadata,\n },\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // This is very prone to becoming a circular dependency, so we import it dynamically\n const {sendErrorToBugsnag} = await import('./error-handler.js')\n await sendErrorToBugsnag(error, 'unexpected_error')\n }\n }\n }\n\n // See `runWithTimer` below.\n const durationStack: number[] = []\n\n return {\n getAllPublicMetadata: () => {\n return {...raw.public}\n },\n getAllSensitiveMetadata: () => {\n return {...raw.sensitive}\n },\n addPublicMetadata: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitiveMetadata: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n runWithTimer: (field: NumericKeyOf<TPublic>): (<T>(fn: () => Promise<T>) => Promise<T>) => {\n return async (fn) => {\n /**\n * For nested timers, we subtract the inner timer's duration from the outer timer's. We use a stack to track the\n * cumulative durations of nested timers. On starting a timer, we push a zero onto the stack to initialize the total\n * duration for subsequent nested timers. Before logging, we pop the stack to get the total nested timers' duration.\n * We subtract this from the current timer's actual duration to get its measurable duration. We then add the current\n * timer's actual duration to the stack's top, allowing any parent timer to deduct it from its own duration.\n */\n\n // Initialise the running total duration for all nested timers\n durationStack.push(0)\n\n // Do the work, and time it\n const start = performance.now()\n try {\n const result = await fn()\n return result\n } finally {\n let end = performance.now()\n // For very short durations, the end time can be before the start time(!) - we flatten this out to zero.\n end = Math.max(start, end)\n\n // The top of the stack is the total time for all nested timers\n const wallClockDuration = Math.max(end - start, 0)\n\n const childDurations = durationStack.pop()!\n const duration = Math.max(wallClockDuration - childDurations, 0)\n\n // If this is the topmost timer, the stack will be empty.\n if (durationStack.length > 0) {\n durationStack[durationStack.length - 1] = (durationStack[durationStack.length - 1] ?? 0) + wallClockDuration\n }\n\n // Log it -- we include it in the metadata, but also log via the standard performance API. The TS types for this library are not quite right, so we have to cast to `any` here.\n performance.measure(`${field}#measurable`, {\n start,\n duration,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any)\n performance.measure(`${field}#wall`, {\n start,\n end,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any)\n\n // There might not be a value set, yet\n let currentValue = (raw.public[field] || 0) as number\n currentValue += duration\n\n // TS is not quite smart enough to realise that raw.public[field] must be a numeric type\n raw.public[field] = currentValue as TPublic[NumericKeyOf<TPublic>]\n }\n }\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*`,\n// `cmd_app_*`, `cmd_theme_*`, `store_*`, and `env_auto_upgrade_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_create_app_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_theme_'> &\n PickByPrefix<MonorailEventPublic, 'store_'> &\n PickByPrefix<MonorailEventPublic, 'env_auto_upgrade_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n endTime?: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n } & {environmentFlags: string} & PickByPrefix<MonorailEventSensitive, 'store_'>\n>({cmd_all_timing_network_ms: 0, cmd_all_timing_prompts_ms: 0})\n\nexport const {getAllPublicMetadata, getAllSensitiveMetadata, addPublicMetadata, addSensitiveMetadata, runWithTimer} =\n coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
1
+ {"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/public/node/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAe3C;;;;GAIG;AACH,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AA4BD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAG5C,wBAA0C,EAAE;IAC5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE;YACN,GAAG,qBAAqB;SACzB;KACF,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAsB,EAAE,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;IACD,MAAM,YAAY,GAAG,CAAC,IAAyB,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EACvB,KAAiC,EACjC,KAAyB,EACzB,OAA8B,EAC9B,EAAE;QACF,MAAM,aAAa,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;QACvF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAA;YAC1B,KAAK,CAAC,IAAI,CAA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AC;YACH,CAAC,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AAWD,MAAM,QAAQ,GAAG,8BAA8B,CAY7C,EAAC,yBAAyB,EAAE,CAAC,EAAE,yBAAyB,EAAE,CAAC,EAAC,CAAC,CAAA;AAE/D,MAAM,CAAC,MAAM,EAAC,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,YAAY,EAAC,GACjH,QAAQ,CAAA","sourcesContent":["import {isUnitTest} from './context/local.js'\nimport {performance} from 'node:perf_hooks'\nimport type {PickByPrefix} from '../common/ts/pick-by-prefix.js'\nimport type {AnyJson} from '../../private/common/json.js'\nimport type {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\n/**\n * Get the error handling strategy for metadata.\n *\n * @returns 'mute-and-report' in production, 'bubble' in tests.\n */\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\n/**\n * Any key in T that has a numeric value.\n */\ntype NumericKeyOf<T> = {\n [K in keyof T]: T[K] extends number ? (K extends string ? K : never) : never\n}[keyof T]\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII. */\n addPublicMetadata: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /**\n * Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked\n * (this is a good fit for command args for instance).\n */\n addSensitiveMetadata: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data. */\n getAllPublicMetadata: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data. */\n getAllSensitiveMetadata: () => Partial<TSensitive>\n /** Run a function, monitoring how long it takes, and adding the elapsed time to a running total. */\n runWithTimer: (field: NumericKeyOf<TPublic>) => <T>(fn: () => Promise<T>) => Promise<T>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n * @param defaultPublicMetadata - Optional, default data for the container.\n * @returns A container for the metadata.\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = Record<string, never>,\n>(defaultPublicMetadata: Partial<TPublic> = {}): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {\n ...defaultPublicMetadata,\n },\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n // This is very prone to becoming a circular dependency, so we import it dynamically\n const {sendErrorToBugsnag} = await import('./error-handler.js')\n await sendErrorToBugsnag(error, 'unexpected_error')\n }\n }\n }\n\n // See `runWithTimer` below.\n const durationStack: number[] = []\n\n return {\n getAllPublicMetadata: () => {\n return {...raw.public}\n },\n getAllSensitiveMetadata: () => {\n return {...raw.sensitive}\n },\n addPublicMetadata: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitiveMetadata: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n runWithTimer: (field: NumericKeyOf<TPublic>): (<T>(fn: () => Promise<T>) => Promise<T>) => {\n return async (fn) => {\n /**\n * For nested timers, we subtract the inner timer's duration from the outer timer's. We use a stack to track the\n * cumulative durations of nested timers. On starting a timer, we push a zero onto the stack to initialize the total\n * duration for subsequent nested timers. Before logging, we pop the stack to get the total nested timers' duration.\n * We subtract this from the current timer's actual duration to get its measurable duration. We then add the current\n * timer's actual duration to the stack's top, allowing any parent timer to deduct it from its own duration.\n */\n\n // Initialise the running total duration for all nested timers\n durationStack.push(0)\n\n // Do the work, and time it\n const start = performance.now()\n try {\n const result = await fn()\n return result\n } finally {\n let end = performance.now()\n // For very short durations, the end time can be before the start time(!) - we flatten this out to zero.\n end = Math.max(start, end)\n\n // The top of the stack is the total time for all nested timers\n const wallClockDuration = Math.max(end - start, 0)\n\n const childDurations = durationStack.pop()!\n const duration = Math.max(wallClockDuration - childDurations, 0)\n\n // If this is the topmost timer, the stack will be empty.\n if (durationStack.length > 0) {\n durationStack[durationStack.length - 1] = (durationStack[durationStack.length - 1] ?? 0) + wallClockDuration\n }\n\n // Log it -- we include it in the metadata, but also log via the standard performance API. The TS types for this library are not quite right, so we have to cast to `any` here.\n performance.measure(`${field}#measurable`, {\n start,\n duration,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any)\n performance.measure(`${field}#wall`, {\n start,\n end,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any)\n\n // There might not be a value set, yet\n let currentValue = (raw.public[field] || 0) as number\n currentValue += duration\n\n // TS is not quite smart enough to realise that raw.public[field] must be a numeric type\n raw.public[field] = currentValue as TPublic[NumericKeyOf<TPublic>]\n }\n }\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*`,\n// `cmd_app_*`, `cmd_theme_*`, `store_*`, and `env_auto_upgrade_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_create_app_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_theme_'> &\n PickByPrefix<MonorailEventPublic, 'store_'> &\n PickByPrefix<MonorailEventPublic, 'env_auto_upgrade_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n endTime?: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n requiresSyncAnalytics?: boolean\n }\n } & {environmentFlags: string} & PickByPrefix<MonorailEventSensitive, 'store_'>\n>({cmd_all_timing_network_ms: 0, cmd_all_timing_prompts_ms: 0})\n\nexport const {getAllPublicMetadata, getAllSensitiveMetadata, addPublicMetadata, addSensitiveMetadata, runWithTimer} =\n coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
@@ -15,8 +15,6 @@ export function lookupMimeType(fileName) {
15
15
  * @param newTypes - Object of key-values where key is extension and value is mime type.
16
16
  */
17
17
  export function setMimeTypes(newTypes) {
18
- Object.entries(newTypes).forEach(([extension, mimeType]) => {
19
- mimes[extension] = mimeType;
20
- });
18
+ Object.assign(mimes, newTypes);
21
19
  }
22
20
  //# sourceMappingURL=mimes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mimes.js","sourceRoot":"","sources":["../../../src/public/node/mimes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,QAAQ,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,0BAA0B,CAAA;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgC;IAC3D,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE;QACzD,KAAK,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// import * as mimeTypes from 'mrmime'\nimport {lookup, mimes} from 'mrmime'\n\n/**\n * Returns the MIME type for a filename.\n *\n * @param fileName - Filename.\n * @returns The mime type.\n */\nexport function lookupMimeType(fileName: string): string {\n return lookup(fileName) ?? 'application/octet-stream'\n}\n\n/**\n * Adds MIME type(s) to the dictionary.\n *\n * @param newTypes - Object of key-values where key is extension and value is mime type.\n */\nexport function setMimeTypes(newTypes: Record<string, string>): void {\n Object.entries(newTypes).forEach(([extension, mimeType]) => {\n mimes[extension] = mimeType\n })\n}\n"]}
1
+ {"version":3,"file":"mimes.js","sourceRoot":"","sources":["../../../src/public/node/mimes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,QAAQ,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,0BAA0B,CAAA;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgC;IAC3D,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AAChC,CAAC","sourcesContent":["// import * as mimeTypes from 'mrmime'\nimport {lookup, mimes} from 'mrmime'\n\n/**\n * Returns the MIME type for a filename.\n *\n * @param fileName - Filename.\n * @returns The mime type.\n */\nexport function lookupMimeType(fileName: string): string {\n return lookup(fileName) ?? 'application/octet-stream'\n}\n\n/**\n * Adds MIME type(s) to the dictionary.\n *\n * @param newTypes - Object of key-values where key is extension and value is mime type.\n */\nexport function setMimeTypes(newTypes: Record<string, string>): void {\n Object.assign(mimes, newTypes)\n}\n"]}
@@ -374,19 +374,12 @@ export async function addNPMDependenciesWithoutVersionIfNeeded(dependencies, opt
374
374
  * @returns An array with the arguments.
375
375
  */
376
376
  function argumentsToAddDependenciesWithNPM(dependency, type) {
377
- let command = ['install'];
378
- command = command.concat(dependency);
379
- switch (type) {
380
- case 'dev':
381
- command.push('--save-dev');
382
- break;
383
- case 'peer':
384
- command.push('--save-peer');
385
- break;
386
- case 'prod':
387
- command.push('--save-prod');
388
- break;
389
- }
377
+ const typeFlags = {
378
+ dev: '--save-dev',
379
+ peer: '--save-peer',
380
+ prod: '--save-prod',
381
+ };
382
+ const command = ['install', dependency, typeFlags[type]];
390
383
  // NPM adds ^ to the installed version by default. We want to install exact versions unless specified otherwise.
391
384
  if (dependency.match(/@\d/g)) {
392
385
  command.push('--save-exact');
@@ -401,23 +394,12 @@ function argumentsToAddDependenciesWithNPM(dependency, type) {
401
394
  * @returns An array with the arguments.
402
395
  */
403
396
  function argumentsToAddDependenciesWithYarn(dependencies, type, addAtRoot = false) {
404
- let command = ['add'];
405
- if (addAtRoot) {
406
- command.push('-W');
407
- }
408
- command = command.concat(dependencies);
409
- switch (type) {
410
- case 'dev':
411
- command.push('--dev');
412
- break;
413
- case 'peer':
414
- command.push('--peer');
415
- break;
416
- case 'prod':
417
- command.push('--prod');
418
- break;
419
- }
420
- return command;
397
+ const typeFlags = {
398
+ dev: '--dev',
399
+ peer: '--peer',
400
+ prod: '--prod',
401
+ };
402
+ return ['add', ...(addAtRoot ? ['-W'] : []), ...dependencies, typeFlags[type]];
421
403
  }
422
404
  /**
423
405
  * Returns the arguments to add dependencies using PNPM.
@@ -427,23 +409,12 @@ function argumentsToAddDependenciesWithYarn(dependencies, type, addAtRoot = fals
427
409
  * @returns An array with the arguments.
428
410
  */
429
411
  function argumentsToAddDependenciesWithPNPM(dependencies, type, addAtRoot = false) {
430
- let command = ['add'];
431
- if (addAtRoot) {
432
- command.push('-w');
433
- }
434
- command = command.concat(dependencies);
435
- switch (type) {
436
- case 'dev':
437
- command.push('--save-dev');
438
- break;
439
- case 'peer':
440
- command.push('--save-peer');
441
- break;
442
- case 'prod':
443
- command.push('--save-prod');
444
- break;
445
- }
446
- return command;
412
+ const typeFlags = {
413
+ dev: '--save-dev',
414
+ peer: '--save-peer',
415
+ prod: '--save-prod',
416
+ };
417
+ return ['add', ...(addAtRoot ? ['-w'] : []), ...dependencies, typeFlags[type]];
447
418
  }
448
419
  /**
449
420
  * Returns the arguments to add dependencies using Bun.
@@ -452,19 +423,12 @@ function argumentsToAddDependenciesWithPNPM(dependencies, type, addAtRoot = fals
452
423
  * @returns An array with the arguments.
453
424
  */
454
425
  function argumentsToAddDependenciesWithBun(dependencies, type) {
455
- let command = ['add'];
456
- command = command.concat(dependencies);
457
- switch (type) {
458
- case 'dev':
459
- command.push('--development');
460
- break;
461
- case 'peer':
462
- command.push('--optional');
463
- break;
464
- case 'prod':
465
- break;
466
- }
467
- return command;
426
+ const typeFlags = {
427
+ dev: '--development',
428
+ peer: '--optional',
429
+ };
430
+ const flag = typeFlags[type];
431
+ return ['add', ...dependencies, ...(flag ? [flag] : [])];
468
432
  }
469
433
  /**
470
434
  * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
@@ -485,19 +449,13 @@ export async function findUpAndReadPackageJson(fromDirectory) {
485
449
  }
486
450
  export async function addResolutionOrOverride(directory, dependencies) {
487
451
  const packageManager = await getPackageManager(directory);
488
- const packageJsonPath = joinPath(directory, 'package.json');
489
- const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
490
- if (packageManager === 'yarn') {
491
- packageJsonContent.resolutions = packageJsonContent.resolutions
492
- ? { ...packageJsonContent.resolutions, ...dependencies }
493
- : dependencies;
494
- }
495
- if (packageManager === 'npm' || packageManager === 'pnpm' || packageManager === 'bun') {
496
- packageJsonContent.overrides = packageJsonContent.overrides
497
- ? { ...packageJsonContent.overrides, ...dependencies }
498
- : dependencies;
499
- }
500
- await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
452
+ const packageJsonContent = await readAndParsePackageJson(joinPath(directory, 'package.json'));
453
+ const key = packageManager === 'yarn' ? 'resolutions' : 'overrides';
454
+ packageJsonContent[key] = {
455
+ ...packageJsonContent[key],
456
+ ...dependencies,
457
+ };
458
+ await writePackageJSON(directory, packageJsonContent);
501
459
  }
502
460
  /**
503
461
  * Returns the latest available version of an NPM package.