@shopify/cli-kit 3.33.0 → 3.35.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 (212) hide show
  1. package/dist/git.js +3 -3
  2. package/dist/git.js.map +1 -1
  3. package/dist/http/fetch.js +1 -1
  4. package/dist/http/fetch.js.map +1 -1
  5. package/dist/http.js +2 -2
  6. package/dist/http.js.map +1 -1
  7. package/dist/index.d.ts +0 -7
  8. package/dist/index.js +0 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/metadata.js +1 -1
  11. package/dist/metadata.js.map +1 -1
  12. package/dist/npm.js +3 -3
  13. package/dist/npm.js.map +1 -1
  14. package/dist/output.js +4 -4
  15. package/dist/output.js.map +1 -1
  16. package/dist/path.d.ts +1 -1
  17. package/dist/path.js +5 -3
  18. package/dist/path.js.map +1 -1
  19. package/dist/private/node/analytics.js +6 -9
  20. package/dist/private/node/analytics.js.map +1 -1
  21. package/dist/private/node/api/graphql.js +2 -1
  22. package/dist/private/node/api/graphql.js.map +1 -1
  23. package/dist/private/node/api/headers.d.ts +2 -2
  24. package/dist/private/node/api/headers.js +4 -4
  25. package/dist/private/node/api/headers.js.map +1 -1
  26. package/dist/private/node/api/rest.d.ts +6 -4
  27. package/dist/private/node/api/rest.js +8 -7
  28. package/dist/private/node/api/rest.js.map +1 -1
  29. package/dist/private/node/constants.d.ts +42 -0
  30. package/dist/private/node/constants.js +58 -0
  31. package/dist/private/node/constants.js.map +1 -0
  32. package/dist/private/node/environment/service.d.ts +18 -0
  33. package/dist/private/node/environment/service.js +32 -0
  34. package/dist/private/node/environment/service.js.map +1 -0
  35. package/dist/{environment → private/node/environment}/spin-cache.d.ts +0 -0
  36. package/dist/{environment → private/node/environment}/spin-cache.js +0 -0
  37. package/dist/private/node/environment/spin-cache.js.map +1 -0
  38. package/dist/{environment → private/node/environment}/utilities.d.ts +0 -0
  39. package/dist/{environment → private/node/environment}/utilities.js +0 -0
  40. package/dist/private/node/environment/utilities.js.map +1 -0
  41. package/dist/{session → private/node/session}/authorize.d.ts +1 -5
  42. package/dist/{session → private/node/session}/authorize.js +9 -9
  43. package/dist/private/node/session/authorize.js.map +1 -0
  44. package/dist/{session → private/node/session}/device-authorization.d.ts +0 -0
  45. package/dist/{session → private/node/session}/device-authorization.js +7 -9
  46. package/dist/private/node/session/device-authorization.js.map +1 -0
  47. package/dist/{session → private/node/session}/exchange.d.ts +2 -2
  48. package/dist/{session → private/node/session}/exchange.js +5 -5
  49. package/dist/private/node/session/exchange.js.map +1 -0
  50. package/dist/{session → private/node/session}/identity-token-validation.d.ts +0 -0
  51. package/dist/{session → private/node/session}/identity-token-validation.js +4 -4
  52. package/dist/private/node/session/identity-token-validation.js.map +1 -0
  53. package/dist/{session → private/node/session}/identity.d.ts +1 -1
  54. package/dist/{session → private/node/session}/identity.js +2 -3
  55. package/dist/private/node/session/identity.js.map +1 -0
  56. package/dist/{session → private/node/session}/post-auth.d.ts +1 -1
  57. package/dist/{session → private/node/session}/post-auth.js +10 -10
  58. package/dist/private/node/session/post-auth.js.map +1 -0
  59. package/dist/{session → private/node/session}/redirect-listener.d.ts +0 -0
  60. package/dist/{session → private/node/session}/redirect-listener.js +2 -2
  61. package/dist/private/node/session/redirect-listener.js.map +1 -0
  62. package/dist/{session → private/node/session}/schema.d.ts +1 -1
  63. package/dist/{session → private/node/session}/schema.js +1 -1
  64. package/dist/private/node/session/schema.js.map +1 -0
  65. package/dist/{session → private/node/session}/scopes.d.ts +1 -1
  66. package/dist/{session → private/node/session}/scopes.js +2 -2
  67. package/dist/private/node/session/scopes.js.map +1 -0
  68. package/dist/{session → private/node/session}/store.d.ts +0 -0
  69. package/dist/{session → private/node/session}/store.js +10 -10
  70. package/dist/private/node/session/store.js.map +1 -0
  71. package/dist/{session → private/node/session}/validate.d.ts +0 -0
  72. package/dist/{session → private/node/session}/validate.js +4 -4
  73. package/dist/private/node/session/validate.js.map +1 -0
  74. package/dist/private/node/session.d.ts +56 -0
  75. package/dist/{session.js → private/node/session.js} +98 -134
  76. package/dist/private/node/session.js.map +1 -0
  77. package/dist/private/node/ui/components/SelectPrompt.d.ts +2 -1
  78. package/dist/private/node/ui/components/SelectPrompt.js +2 -1
  79. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  80. package/dist/private/node/ui/components/Table/Column.d.ts +5 -0
  81. package/dist/private/node/ui/components/Table/Column.js +2 -0
  82. package/dist/private/node/ui/components/Table/Column.js.map +1 -0
  83. package/dist/private/node/ui/components/Table/Row.d.ts +12 -0
  84. package/dist/private/node/ui/components/Table/Row.js +24 -0
  85. package/dist/private/node/ui/components/Table/Row.js.map +1 -0
  86. package/dist/private/node/ui/components/Table/ScalarDict.d.ts +5 -0
  87. package/dist/private/node/ui/components/Table/ScalarDict.js +2 -0
  88. package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -0
  89. package/dist/private/node/ui/components/Table/Table.d.ts +12 -0
  90. package/dist/private/node/ui/components/Table/Table.js +30 -0
  91. package/dist/private/node/ui/components/Table/Table.js.map +1 -0
  92. package/dist/private/node/ui/components/Table/Table.test.d.ts +1 -0
  93. package/dist/private/node/ui/components/Table/Table.test.js +41 -0
  94. package/dist/private/node/ui/components/Table/Table.test.js.map +1 -0
  95. package/dist/private/node/ui.js +1 -1
  96. package/dist/private/node/ui.js.map +1 -1
  97. package/dist/public/common/string.d.ts +11 -0
  98. package/dist/public/common/string.js +21 -0
  99. package/dist/public/common/string.js.map +1 -1
  100. package/dist/public/common/version.d.ts +1 -0
  101. package/dist/public/common/version.js +2 -0
  102. package/dist/public/common/version.js.map +1 -0
  103. package/dist/public/node/analytics.js +5 -5
  104. package/dist/public/node/analytics.js.map +1 -1
  105. package/dist/public/node/api/admin.d.ts +5 -2
  106. package/dist/public/node/api/admin.js +4 -3
  107. package/dist/public/node/api/admin.js.map +1 -1
  108. package/dist/public/node/api/partners.js +1 -1
  109. package/dist/public/node/api/partners.js.map +1 -1
  110. package/dist/public/node/base-command.js +2 -2
  111. package/dist/public/node/base-command.js.map +1 -1
  112. package/dist/public/node/cli.d.ts +8 -0
  113. package/dist/public/node/cli.js +25 -8
  114. package/dist/public/node/cli.js.map +1 -1
  115. package/dist/public/node/dot-env.js +2 -2
  116. package/dist/public/node/dot-env.js.map +1 -1
  117. package/dist/public/node/environment/fqdn.d.ts +26 -0
  118. package/dist/{environment → public/node/environment}/fqdn.js +15 -31
  119. package/dist/public/node/environment/fqdn.js.map +1 -0
  120. package/dist/{environment → public/node/environment}/local.d.ts +62 -15
  121. package/dist/{environment → public/node/environment}/local.js +81 -36
  122. package/dist/public/node/environment/local.js.map +1 -0
  123. package/dist/public/node/environment/spin.d.ts +43 -0
  124. package/dist/{environment → public/node/environment}/spin.js +31 -38
  125. package/dist/public/node/environment/spin.js.map +1 -0
  126. package/dist/public/node/error-handler.js +6 -5
  127. package/dist/public/node/error-handler.js.map +1 -1
  128. package/dist/public/node/fs.d.ts +222 -3
  129. package/dist/public/node/fs.js +338 -2
  130. package/dist/public/node/fs.js.map +1 -1
  131. package/dist/public/node/git.d.ts +90 -0
  132. package/dist/public/node/git.js +174 -0
  133. package/dist/public/node/git.js.map +1 -0
  134. package/dist/public/node/liquid.js +6 -6
  135. package/dist/public/node/liquid.js.map +1 -1
  136. package/dist/public/node/node-package-manager.d.ts +0 -10
  137. package/dist/public/node/node-package-manager.js +3 -20
  138. package/dist/public/node/node-package-manager.js.map +1 -1
  139. package/dist/public/node/presets.js +2 -2
  140. package/dist/public/node/presets.js.map +1 -1
  141. package/dist/public/node/ruby.d.ts +1 -1
  142. package/dist/public/node/ruby.js +19 -20
  143. package/dist/public/node/ruby.js.map +1 -1
  144. package/dist/public/node/session.d.ts +53 -0
  145. package/dist/public/node/session.js +95 -0
  146. package/dist/public/node/session.js.map +1 -0
  147. package/dist/public/node/system.d.ts +44 -0
  148. package/dist/{system.js → public/node/system.js} +34 -54
  149. package/dist/public/node/system.js.map +1 -0
  150. package/dist/public/node/tcp.js +1 -1
  151. package/dist/public/node/tcp.js.map +1 -1
  152. package/dist/public/node/ui.d.ts +13 -0
  153. package/dist/public/node/ui.js +14 -0
  154. package/dist/public/node/ui.js.map +1 -1
  155. package/dist/public/node/vscode.js +5 -5
  156. package/dist/public/node/vscode.js.map +1 -1
  157. package/dist/secure-store.js +4 -4
  158. package/dist/secure-store.js.map +1 -1
  159. package/dist/store.d.ts +10 -10
  160. package/dist/store.js +21 -22
  161. package/dist/store.js.map +1 -1
  162. package/dist/testing/store.js +3 -3
  163. package/dist/testing/store.js.map +1 -1
  164. package/dist/testing/ui.js +1 -1
  165. package/dist/testing/ui.js.map +1 -1
  166. package/dist/tsconfig.tsbuildinfo +1 -1
  167. package/dist/ui.js +4 -4
  168. package/dist/ui.js.map +1 -1
  169. package/package.json +10 -7
  170. package/dist/cli.d.ts +0 -8
  171. package/dist/cli.js +0 -18
  172. package/dist/cli.js.map +0 -1
  173. package/dist/constants.d.ts +0 -51
  174. package/dist/constants.js +0 -70
  175. package/dist/constants.js.map +0 -1
  176. package/dist/environment/fqdn.d.ts +0 -29
  177. package/dist/environment/fqdn.js.map +0 -1
  178. package/dist/environment/local.js.map +0 -1
  179. package/dist/environment/service.d.ts +0 -4
  180. package/dist/environment/service.js +0 -19
  181. package/dist/environment/service.js.map +0 -1
  182. package/dist/environment/spin-cache.js.map +0 -1
  183. package/dist/environment/spin.d.ts +0 -50
  184. package/dist/environment/spin.js.map +0 -1
  185. package/dist/environment/utilities.js.map +0 -1
  186. package/dist/environment.d.ts +0 -7
  187. package/dist/environment.js +0 -8
  188. package/dist/environment.js.map +0 -1
  189. package/dist/file.d.ts +0 -98
  190. package/dist/file.js +0 -216
  191. package/dist/file.js.map +0 -1
  192. package/dist/network/service.d.ts +0 -14
  193. package/dist/network/service.js +0 -11
  194. package/dist/network/service.js.map +0 -1
  195. package/dist/session/authorize.js.map +0 -1
  196. package/dist/session/device-authorization.js.map +0 -1
  197. package/dist/session/exchange.js.map +0 -1
  198. package/dist/session/identity-token-validation.js.map +0 -1
  199. package/dist/session/identity.js.map +0 -1
  200. package/dist/session/post-auth.js.map +0 -1
  201. package/dist/session/redirect-listener.js.map +0 -1
  202. package/dist/session/schema.js.map +0 -1
  203. package/dist/session/scopes.js.map +0 -1
  204. package/dist/session/store.js.map +0 -1
  205. package/dist/session/token.d.ts +0 -40
  206. package/dist/session/token.js +0 -22
  207. package/dist/session/token.js.map +0 -1
  208. package/dist/session/validate.js.map +0 -1
  209. package/dist/session.d.ts +0 -96
  210. package/dist/session.js.map +0 -1
  211. package/dist/system.d.ts +0 -51
  212. package/dist/system.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { Flags } from '@oclif/core';
1
2
  function setupEnvironmentVariables(options) {
2
3
  /**
3
4
  * By setting DEBUG=* when --verbose is passed we are increasing the
@@ -24,7 +25,7 @@ export async function runCLI(options) {
24
25
  * and therefore it has no effect.
25
26
  */
26
27
  const { errorHandler } = await import('./error-handler.js');
27
- const { isDevelopment } = await import('../../environment/local.js');
28
+ const { isDevelopment } = await import('./environment/local.js');
28
29
  const { run, settings, flush } = await import('@oclif/core');
29
30
  if (isDevelopment()) {
30
31
  settings.debug = true;
@@ -52,15 +53,15 @@ export async function runCreateCLI(options) {
52
53
  await runCLI(options);
53
54
  }
54
55
  export async function useLocalCLIIfDetected(filepath) {
55
- const { isTruthy } = await import('../../environment/utilities.js');
56
- const constants = await import('../../constants.js');
56
+ const { isTruthy } = await import('../../private/node/environment/utilities.js');
57
+ const { environmentVariables } = await import('../../private/node/constants.js');
57
58
  const { join } = await import('../../path.js');
58
- const { exec } = await import('../../system.js');
59
+ const { exec } = await import('./system.js');
59
60
  // Temporary flag while we test out this feature and ensure it won't break anything!
60
- if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect]))
61
+ if (!isTruthy(process.env[environmentVariables.enableCliRedirect]))
61
62
  return false;
62
63
  // Setting an env variable in the child process prevents accidental recursion.
63
- if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect]))
64
+ if (isTruthy(process.env[environmentVariables.skipCliRedirect]))
64
65
  return false;
65
66
  // If already running via package manager, we can assume it's running correctly already.
66
67
  if (process.env.npm_config_user_agent)
@@ -74,7 +75,7 @@ export async function useLocalCLIIfDetected(filepath) {
74
75
  try {
75
76
  await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {
76
77
  stdio: 'inherit',
77
- env: { [constants.default.environmentVariables.skipCliRedirect]: '1' },
78
+ env: { [environmentVariables.skipCliRedirect]: '1' },
78
79
  });
79
80
  // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any
80
81
  }
@@ -84,7 +85,7 @@ export async function useLocalCLIIfDetected(filepath) {
84
85
  return true;
85
86
  }
86
87
  export async function localCliPackage() {
87
- const { captureOutput } = await import('../../system.js');
88
+ const { captureOutput } = await import('./system.js');
88
89
  let npmListOutput = '';
89
90
  let localShopifyCLI = {};
90
91
  try {
@@ -102,5 +103,21 @@ export async function localCliPackage() {
102
103
  };
103
104
  return dependenciesList['@shopify/cli'];
104
105
  }
106
+ /**
107
+ * An object that contains the flags that
108
+ * are shared across all the commands.
109
+ */
110
+ export const globalFlags = {
111
+ preset: Flags.string({
112
+ hidden: true,
113
+ description: 'The preset to apply to the current command.',
114
+ env: 'SHOPIFY_FLAG_PRESET',
115
+ }),
116
+ verbose: Flags.boolean({
117
+ hidden: false,
118
+ description: 'Increase the verbosity of the logs.',
119
+ env: 'SHOPIFY_FLAG_VERBOSE',
120
+ }),
121
+ };
105
122
  export default runCLI;
106
123
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAWA,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GA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e,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL)\n .then(() => flush())\n .catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../../environment/utilities.js')\n const constants = await import('../../constants.js')\n const {join} = await import('../../path.js')\n const {exec} = await import('../../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAajC,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAA;KAC7C;IACD,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAA;KAC3E;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAClC;;;;OAIG;IACH,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACzD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAA;IAC9D,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAE1D,IAAI,aAAa,EAAE,EAAE;QACnB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACtB;IAED,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC;SAC9B,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;SACnB,KAAK,CAAC,YAA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,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAEnD,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,IAAI,eAAe,GAAgB,EAAE,CAAA;IACrC,IAAI;QACF,aAAa,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACpF,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;QACnB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,6CAA6C;QAC1D,GAAG,EAAE,qBAAqB;KAC3B,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,qCAAqC;QAClD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["import {Flags} from '@oclif/core'\n\n/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('./environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL)\n .then(() => flush())\n .catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../../private/node/environment/utilities.js')\n const {environmentVariables} = await import('../../private/node/constants.js')\n const {join} = await import('../../path.js')\n const {exec} = await import('./system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('./system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n preset: Flags.string({\n hidden: true,\n description: 'The preset to apply to the current command.',\n env: 'SHOPIFY_FLAG_PRESET',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the logs.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\nexport default runCLI\n"]}
@@ -1,5 +1,5 @@
1
1
  import { AbortError } from './error.js';
2
- import { exists, read as readFile, write as writeFile } from '../../file.js';
2
+ import { fileExists, readFile, writeFile } from './fs.js';
3
3
  import { debug, content as outputContent, token } from '../../output.js';
4
4
  import { parse, stringify } from 'envfile';
5
5
  /**
@@ -17,7 +17,7 @@ export const DotEnvNotFoundError = (path) => {
17
17
  */
18
18
  export async function readAndParseDotEnv(path) {
19
19
  debug(outputContent `Reading the .env file at ${token.path(path)}`);
20
- if (!(await exists(path))) {
20
+ if (!(await fileExists(path))) {
21
21
  throw DotEnvNotFoundError(path);
22
22
  }
23
23
  const content = await readFile(path);
@@ -1 +1 @@
1
- {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,MAAM,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,IAAI,SAAS,EAAC,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAC,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAc,EAAE;IAC9D,OAAO,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;AAC1E,CAAC,CAAA;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,KAAK,CAAC,aAAa,CAAA,4BAA4B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAClE,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE;QACzB,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;I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E;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {exists, read as readFile, write as writeFile} from '../../file.js'\nimport {debug, content as outputContent, token} from '../../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string): AbortError => {\n return new AbortError(`The environment file at ${path} does not exist.`)\n}\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await exists(path))) {\n throw DotEnvNotFoundError(path)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile): Promise<void> {\n await writeFile(file.path, stringify(file.variables))\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
1
+ {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AACvD,OAAO,EAAC,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAc,EAAE;IAC9D,OAAO,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;AAC1E,CAAC,CAAA;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,KAAK,CAAC,aAAa,CAAA,4BAA4B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAClE,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;KAC1B,CAAA;AACH,CAAC;AAED;;;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AC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {fileExists, readFile, writeFile} from './fs.js'\nimport {debug, content as outputContent, token} from '../../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string): AbortError => {\n return new AbortError(`The environment file at ${path} does not exist.`)\n}\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await fileExists(path))) {\n throw DotEnvNotFoundError(path)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile): Promise<void> {\n await writeFile(file.path, stringify(file.variables))\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { Abort } from '../../../error.js';
2
+ export declare const CouldntObtainPartnersSpinFQDNError: Abort;
3
+ export declare const CouldntObtainIdentitySpinFQDNError: Abort;
4
+ export declare const CouldntObtainShopifySpinFQDNError: Abort;
5
+ export declare const NotProvidedStoreFQDNError: Abort;
6
+ /**
7
+ * It returns the Partners' API service we should interact with.
8
+ *
9
+ * @returns Fully-qualified domain of the partners service we should interact with.
10
+ */
11
+ export declare function partnersFqdn(): Promise<string>;
12
+ /**
13
+ * It returns the Identity service we should interact with.
14
+ *
15
+ * @returns Fully-qualified domain of the Identity service we should interact with.
16
+ */
17
+ export declare function identityFqdn(): Promise<string>;
18
+ /**
19
+ * Normalize the store name to be used in the CLI.
20
+ * It will add the .myshopify.com domain if it's not present.
21
+ * It will add the spin domain if it's not present and we're in a Spin environment.
22
+ *
23
+ * @param store - Store name.
24
+ * @returns Normalized store name.
25
+ */
26
+ export declare function normalizeStoreFqdn(store: string): Promise<string>;
@@ -1,15 +1,16 @@
1
- import { fqdn, fqdn as spinFqdn } from './spin.js';
2
- import { isSpinEnvironment, serviceEnvironment } from './service.js';
3
- import { Abort } from '../error.js';
1
+ import { isSpinEnvironment, spinFqdn } from './spin.js';
2
+ import { Abort } from '../../../error.js';
3
+ import { serviceEnvironment } from '../../../private/node/environment/service.js';
4
4
  export const CouldntObtainPartnersSpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.");
5
5
  export const CouldntObtainIdentitySpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.");
6
6
  export const CouldntObtainShopifySpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.");
7
7
  export const NotProvidedStoreFQDNError = new Abort("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
8
8
  /**
9
9
  * It returns the Partners' API service we should interact with.
10
+ *
10
11
  * @returns Fully-qualified domain of the partners service we should interact with.
11
12
  */
12
- export async function partners() {
13
+ export async function partnersFqdn() {
13
14
  const environment = serviceEnvironment();
14
15
  const productionFqdn = 'partners.shopify.com';
15
16
  switch (environment) {
@@ -23,9 +24,10 @@ export async function partners() {
23
24
  }
24
25
  /**
25
26
  * It returns the Identity service we should interact with.
27
+ *
26
28
  * @returns Fully-qualified domain of the Identity service we should interact with.
27
29
  */
28
- export async function identity() {
30
+ export async function identityFqdn() {
29
31
  const environment = serviceEnvironment();
30
32
  const productionFqdn = 'accounts.shopify.com';
31
33
  switch (environment) {
@@ -38,34 +40,16 @@ export async function identity() {
38
40
  }
39
41
  }
40
42
  /**
41
- * It returns the Shopify service we should interact with.
42
- * Note the same fqdn is sued for the Admin and the Storefront Renderer APIs.
43
- * @returns Fully-qualified domain of the Shopify service we should interact with.
43
+ * Normalize the store name to be used in the CLI.
44
+ * It will add the .myshopify.com domain if it's not present.
45
+ * It will add the spin domain if it's not present and we're in a Spin environment.
46
+ *
47
+ * @param store - Store name.
48
+ * @returns Normalized store name.
44
49
  */
45
- export async function shopify(options = {}) {
46
- const environment = serviceEnvironment();
47
- switch (environment) {
48
- case 'local':
49
- return 'shopify.myshopify.io';
50
- case 'spin':
51
- return `identity.${await spinFqdn()}`;
52
- default:
53
- if (options.storeFqdn) {
54
- return options.storeFqdn;
55
- }
56
- else {
57
- throw NotProvidedStoreFQDNError;
58
- }
59
- }
60
- }
61
- /**
62
- * Given a store, returns a valid store fqdn removing protocol and adding the proper domain in case is missing
63
- * @param store - Original store name provided by the user
64
- * @returns a valid store fqdn
65
- */
66
- export async function normalizeStoreName(store) {
50
+ export async function normalizeStoreFqdn(store) {
67
51
  const storeFqdn = store.replace(/^https?:\/\//, '').replace(/\/$/, '');
68
- const addDomain = async (storeFqdn) => isSpinEnvironment() ? `${storeFqdn}.shopify.${await fqdn()}` : `${storeFqdn}.myshopify.com`;
52
+ const addDomain = async (storeFqdn) => isSpinEnvironment() ? `${storeFqdn}.shopify.${await spinFqdn()}` : `${storeFqdn}.myshopify.com`;
69
53
  const containDomain = (storeFqdn) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev');
70
54
  return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
71
55
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/environment/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AACrD,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAC,kBAAkB,EAAC,MAAM,8CAA8C,CAAA;AAE/E,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,KAAK,CACzD,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,KAAK,CACzD,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,KAAK,CACxD,gGAAgG,CACjG,CAAA;AACD,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,KAAK,CAChD,2EAA2E,CAC5E,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,uBAAuB,CAAA;QAChC,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,OAAO,cAAc,CAAA;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAa;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACtE,MAAM,SAAS,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE,CAC5C,iBAAiB,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,gBAAgB,CAAA;IACjG,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IACnH,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {isSpinEnvironment, spinFqdn} from './spin.js'\nimport {Abort} from '../../../error.js'\nimport {serviceEnvironment} from '../../../private/node/environment/service.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new Abort(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partnersFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return 'partners.myshopify.io'\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n *\n * @returns Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identityFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return 'identity.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * Normalize the store name to be used in the CLI.\n * It will add the .myshopify.com domain if it's not present.\n * It will add the spin domain if it's not present and we're in a Spin environment.\n *\n * @param store - Store name.\n * @returns Normalized store name.\n */\nexport async function normalizeStoreFqdn(store: string): Promise<string> {\n const storeFqdn = store.replace(/^https?:\\/\\//, '').replace(/\\/$/, '')\n const addDomain = async (storeFqdn: string) =>\n isSpinEnvironment() ? `${storeFqdn}.shopify.${await spinFqdn()}` : `${storeFqdn}.myshopify.com`\n const containDomain = (storeFqdn: string) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
@@ -1,29 +1,35 @@
1
1
  /// <reference types="node" />
2
2
  /**
3
3
  * It returns true if the terminal is interactive.
4
+ *
4
5
  * @returns True if the terminal is interactive.
5
6
  */
6
7
  export declare function isTerminalInteractive(): boolean;
7
8
  /**
8
9
  * Returns the path to the user's home directory.
10
+ *
9
11
  * @returns The path to the user's home directory.
10
12
  */
11
13
  export declare function homeDirectory(): string;
12
14
  /**
13
15
  * Returns true if the CLI is running in debug mode.
16
+ *
14
17
  * @param env - The environment variables from the environment of the current process.
15
- * @returns true if SHOPIFY_ENV is development
18
+ * @returns True if SHOPIFY_ENV is development.
16
19
  */
17
20
  export declare function isDevelopment(env?: NodeJS.ProcessEnv): boolean;
18
21
  /**
19
22
  * Returns true if the CLI is running in verbose mode.
23
+ *
20
24
  * @param env - The environment variables from the environment of the current process.
21
- * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed
25
+ * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
22
26
  */
23
27
  export declare function isVerbose(env?: NodeJS.ProcessEnv): boolean;
24
28
  /**
25
29
  * Returns true if the environment in which the CLI is running is either
26
30
  * a local environment (where dev is present) or a cloud environment (spin).
31
+ *
32
+ * @param env - The environment variables from the environment of the current process.
27
33
  * @returns True if the CLI is used in a Shopify environment.
28
34
  */
29
35
  export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
@@ -31,38 +37,75 @@ export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
31
37
  * This variable is used when running unit tests to indicate that the CLI's business logic
32
38
  * is run as a subject of a unit test. We can use this variable to disable output through
33
39
  * the standard streams.
40
+ *
34
41
  * @param env - The environment variables from the environment of the current process.
35
42
  * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
36
43
  */
37
44
  export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
38
45
  /**
39
46
  * Returns true if reporting analytics is enabled.
47
+ *
40
48
  * @param env - The environment variables from the environment of the current process.
41
- * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
49
+ * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
42
50
  */
43
51
  export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
44
- /** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */
52
+ /**
53
+ * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.
54
+ *
55
+ * @param env - The environment variables from the environment of the current process.
56
+ * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.
57
+ */
45
58
  export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
59
+ /**
60
+ * Returns true if the CLI User is 1P.
61
+ *
62
+ * @param env - The environment variables from the environment of the current process.
63
+ * @returns True if SHOPIFY_CLI_1P is truthy.
64
+ */
46
65
  export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
66
+ /**
67
+ * Returns true if the CLI should use device auth.
68
+ *
69
+ * @param env - The environment variables from the environment of the current process.
70
+ * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.
71
+ */
47
72
  export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
73
+ /**
74
+ * Returns true if the CLI should use theme bundling.
75
+ *
76
+ * @param env - The environment variables from the environment of the current process.
77
+ * @returns True if SHOPIFY_CLI_THEME_BUNDLING is truthy.
78
+ */
48
79
  export declare function useThemeBundling(env?: NodeJS.ProcessEnv): boolean;
80
+ /**
81
+ * Return gitpodURL if we are running in gitpod.
82
+ * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.
83
+ *
84
+ * @param env - The environment variables from the environment of the current process.
85
+ * @returns The gitpod URL.
86
+ */
49
87
  export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
50
- export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
51
88
  /**
52
- * Checks if the CLI is run from a cloud environment
89
+ * Return codespaceURL if we are running in codespaces.
90
+ * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.
53
91
  *
54
- * @param env - Environment variables used when the cli is launched
92
+ * @param env - The environment variables from the environment of the current process.
93
+ * @returns The codespace URL.
94
+ */
95
+ export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
96
+ /**
97
+ * Checks if the CLI is run from a cloud environment.
55
98
  *
56
- * @returns True in case the CLI is run from a cloud environment
99
+ * @param env - Environment variables used when the cli is launched.
100
+ * @returns True in case the CLI is run from a cloud environment.
57
101
  */
58
102
  export declare function isCloudEnvironment(env?: NodeJS.ProcessEnv): boolean;
59
103
  /**
60
104
  * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
61
- * them. Platform name 'localhost' is returned otherwise
105
+ * them. Platform name 'localhost' is returned otherwise.
62
106
  *
63
- * @param env - Environment variables used when the cli is launched
64
- *
65
- * @returns Cloud platform information
107
+ * @param env - Environment variables used when the cli is launched.
108
+ * @returns Cloud platform information.
66
109
  */
67
110
  export declare function cloudEnvironment(env?: NodeJS.ProcessEnv): {
68
111
  platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost';
@@ -70,11 +113,15 @@ export declare function cloudEnvironment(env?: NodeJS.ProcessEnv): {
70
113
  };
71
114
  /**
72
115
  * Returns whether the environment has Git available.
116
+ *
73
117
  * @returns A promise that resolves with the value.
74
118
  */
75
119
  export declare function hasGit(): Promise<boolean>;
76
120
  /**
77
- * Gets info on the CI platform the CLI is running on, if applicable
121
+ * Gets info on the CI platform the CLI is running on, if applicable.
122
+ *
123
+ * @param env - The environment variables from the environment of the current process.
124
+ * @returns The CI platform info.
78
125
  */
79
126
  export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
80
127
  isCI: true;
@@ -84,8 +131,8 @@ export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
84
131
  name?: undefined;
85
132
  };
86
133
  /**
87
- * Returns the first mac address found
134
+ * Returns the first mac address found.
88
135
  *
89
- * @returns Mac address
136
+ * @returns Mac address.
90
137
  */
91
138
  export declare function macAddress(): Promise<string>;
@@ -1,13 +1,14 @@
1
- import { isTruthy, isSet } from './utilities.js';
2
- import { isSpin } from './spin.js';
3
- import constants from '../constants.js';
4
- import { exists as fileExists } from '../file.js';
1
+ import { isTruthy, isSet } from '../../../private/node/environment/utilities.js';
2
+ import { environmentVariables, pathConstants } from '../../../private/node/constants.js';
3
+ import { fileExists } from '../fs.js';
5
4
  import { exec } from '../system.js';
5
+ import { isSpin } from '../environment/spin.js';
6
6
  import isInteractive from 'is-interactive';
7
7
  import macaddress from 'macaddress';
8
8
  import { homedir } from 'os';
9
9
  /**
10
10
  * It returns true if the terminal is interactive.
11
+ *
11
12
  * @returns True if the terminal is interactive.
12
13
  */
13
14
  export function isTerminalInteractive() {
@@ -15,6 +16,7 @@ export function isTerminalInteractive() {
15
16
  }
16
17
  /**
17
18
  * Returns the path to the user's home directory.
19
+ *
18
20
  * @returns The path to the user's home directory.
19
21
  */
20
22
  export function homeDirectory() {
@@ -22,94 +24,133 @@ export function homeDirectory() {
22
24
  }
23
25
  /**
24
26
  * Returns true if the CLI is running in debug mode.
27
+ *
25
28
  * @param env - The environment variables from the environment of the current process.
26
- * @returns true if SHOPIFY_ENV is development
29
+ * @returns True if SHOPIFY_ENV is development.
27
30
  */
28
31
  export function isDevelopment(env = process.env) {
29
- return env[constants.environmentVariables.env] === 'development';
32
+ return env[environmentVariables.env] === 'development';
30
33
  }
31
34
  /**
32
35
  * Returns true if the CLI is running in verbose mode.
36
+ *
33
37
  * @param env - The environment variables from the environment of the current process.
34
- * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed
38
+ * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
35
39
  */
36
40
  export function isVerbose(env = process.env) {
37
- return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose');
41
+ return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose');
38
42
  }
39
43
  /**
40
44
  * Returns true if the environment in which the CLI is running is either
41
45
  * a local environment (where dev is present) or a cloud environment (spin).
46
+ *
47
+ * @param env - The environment variables from the environment of the current process.
42
48
  * @returns True if the CLI is used in a Shopify environment.
43
49
  */
44
50
  export async function isShopify(env = process.env) {
45
- if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {
46
- return !isTruthy(env[constants.environmentVariables.runAsUser]);
51
+ if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {
52
+ return !isTruthy(env[environmentVariables.runAsUser]);
47
53
  }
48
- const devInstalled = await fileExists(constants.paths.executables.dev);
54
+ const devInstalled = await fileExists(pathConstants.executables.dev);
49
55
  return devInstalled || isSpin(env);
50
56
  }
51
57
  /**
52
58
  * This variable is used when running unit tests to indicate that the CLI's business logic
53
59
  * is run as a subject of a unit test. We can use this variable to disable output through
54
60
  * the standard streams.
61
+ *
55
62
  * @param env - The environment variables from the environment of the current process.
56
63
  * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
57
64
  */
58
65
  export function isUnitTest(env = process.env) {
59
- return isTruthy(env[constants.environmentVariables.unitTest]);
66
+ return isTruthy(env[environmentVariables.unitTest]);
60
67
  }
61
68
  /**
62
69
  * Returns true if reporting analytics is enabled.
70
+ *
63
71
  * @param env - The environment variables from the environment of the current process.
64
- * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
72
+ * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
65
73
  */
66
74
  export function analyticsDisabled(env = process.env) {
67
- return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env);
75
+ return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env);
68
76
  }
69
- /** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */
77
+ /**
78
+ * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.
79
+ *
80
+ * @param env - The environment variables from the environment of the current process.
81
+ * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.
82
+ */
70
83
  export function alwaysLogAnalytics(env = process.env) {
71
- return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics]);
84
+ return isTruthy(env[environmentVariables.alwaysLogAnalytics]);
72
85
  }
86
+ /**
87
+ * Returns true if the CLI User is 1P.
88
+ *
89
+ * @param env - The environment variables from the environment of the current process.
90
+ * @returns True if SHOPIFY_CLI_1P is truthy.
91
+ */
73
92
  export function firstPartyDev(env = process.env) {
74
- return isTruthy(env[constants.environmentVariables.firstPartyDev]);
93
+ return isTruthy(env[environmentVariables.firstPartyDev]);
75
94
  }
95
+ /**
96
+ * Returns true if the CLI should use device auth.
97
+ *
98
+ * @param env - The environment variables from the environment of the current process.
99
+ * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.
100
+ */
76
101
  export function useDeviceAuth(env = process.env) {
77
- return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env);
102
+ return isTruthy(env[environmentVariables.deviceAuth]) || isCloudEnvironment(env);
78
103
  }
104
+ /**
105
+ * Returns true if the CLI should use theme bundling.
106
+ *
107
+ * @param env - The environment variables from the environment of the current process.
108
+ * @returns True if SHOPIFY_CLI_THEME_BUNDLING is truthy.
109
+ */
79
110
  export function useThemeBundling(env = process.env) {
80
- return isTruthy(env[constants.environmentVariables.themeBundling]);
111
+ return isTruthy(env[environmentVariables.themeBundling]);
81
112
  }
82
- // https://www.gitpod.io/docs/environment-variables#default-environment-variables
113
+ /**
114
+ * Return gitpodURL if we are running in gitpod.
115
+ * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.
116
+ *
117
+ * @param env - The environment variables from the environment of the current process.
118
+ * @returns The gitpod URL.
119
+ */
83
120
  export function gitpodURL(env = process.env) {
84
- return env[constants.environmentVariables.gitpod];
121
+ return env[environmentVariables.gitpod];
85
122
  }
86
- // https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables
123
+ /**
124
+ * Return codespaceURL if we are running in codespaces.
125
+ * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.
126
+ *
127
+ * @param env - The environment variables from the environment of the current process.
128
+ * @returns The codespace URL.
129
+ */
87
130
  export function codespaceURL(env = process.env) {
88
- return env[constants.environmentVariables.codespaceName];
131
+ return env[environmentVariables.codespaceName];
89
132
  }
90
133
  /**
91
- * Checks if the CLI is run from a cloud environment
92
- *
93
- * @param env - Environment variables used when the cli is launched
134
+ * Checks if the CLI is run from a cloud environment.
94
135
  *
95
- * @returns True in case the CLI is run from a cloud environment
136
+ * @param env - Environment variables used when the cli is launched.
137
+ * @returns True in case the CLI is run from a cloud environment.
96
138
  */
97
139
  export function isCloudEnvironment(env = process.env) {
98
140
  return cloudEnvironment(env).platform !== 'localhost';
99
141
  }
100
142
  /**
101
143
  * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of
102
- * them. Platform name 'localhost' is returned otherwise
144
+ * them. Platform name 'localhost' is returned otherwise.
103
145
  *
104
- * @param env - Environment variables used when the cli is launched
105
- *
106
- * @returns Cloud platform information
146
+ * @param env - Environment variables used when the cli is launched.
147
+ * @returns Cloud platform information.
107
148
  */
108
149
  export function cloudEnvironment(env = process.env) {
109
- if (isSet(env[constants.environmentVariables.codespaces])) {
150
+ if (isSet(env[environmentVariables.codespaces])) {
110
151
  return { platform: 'codespaces', editor: true };
111
152
  }
112
- if (isSet(env[constants.environmentVariables.gitpod])) {
153
+ if (isSet(env[environmentVariables.gitpod])) {
113
154
  return { platform: 'gitpod', editor: true };
114
155
  }
115
156
  if (isSpin(env)) {
@@ -119,6 +160,7 @@ export function cloudEnvironment(env = process.env) {
119
160
  }
120
161
  /**
121
162
  * Returns whether the environment has Git available.
163
+ *
122
164
  * @returns A promise that resolves with the value.
123
165
  */
124
166
  export async function hasGit() {
@@ -132,7 +174,10 @@ export async function hasGit() {
132
174
  }
133
175
  }
134
176
  /**
135
- * Gets info on the CI platform the CLI is running on, if applicable
177
+ * Gets info on the CI platform the CLI is running on, if applicable.
178
+ *
179
+ * @param env - The environment variables from the environment of the current process.
180
+ * @returns The CI platform info.
136
181
  */
137
182
  export function ciPlatform(env = process.env) {
138
183
  if (isTruthy(env.CI)) {
@@ -156,9 +201,9 @@ export function ciPlatform(env = process.env) {
156
201
  };
157
202
  }
158
203
  /**
159
- * Returns the first mac address found
204
+ * Returns the first mac address found.
160
205
  *
161
- * @returns Mac address
206
+ * @returns Mac address.
162
207
  */
163
208
  export function macAddress() {
164
209
  return macaddress.one();