@shopify/cli-kit 3.10.1 → 3.12.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 (80) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/dist/analytics.d.ts +2 -1
  4. package/dist/analytics.js +5 -1
  5. package/dist/analytics.js.map +1 -1
  6. package/dist/api/admin.js +2 -6
  7. package/dist/api/admin.js.map +1 -1
  8. package/dist/api/identity.js +2 -2
  9. package/dist/api/identity.js.map +1 -1
  10. package/dist/api/partners.js +2 -10
  11. package/dist/api/partners.js.map +1 -1
  12. package/dist/common/result.d.ts +17 -0
  13. package/dist/common/result.js +31 -0
  14. package/dist/common/result.js.map +1 -0
  15. package/dist/constants.d.ts +8 -4
  16. package/dist/constants.js +9 -4
  17. package/dist/constants.js.map +1 -1
  18. package/dist/environment/fqdn.js +4 -4
  19. package/dist/environment/fqdn.js.map +1 -1
  20. package/dist/environment/local.d.ts +5 -1
  21. package/dist/environment/local.js +24 -3
  22. package/dist/environment/local.js.map +1 -1
  23. package/dist/environment/service.d.ts +2 -17
  24. package/dist/environment/service.js +5 -46
  25. package/dist/environment/service.js.map +1 -1
  26. package/dist/environment/spin-cache.d.ts +2 -0
  27. package/dist/environment/spin-cache.js +8 -0
  28. package/dist/environment/spin-cache.js.map +1 -0
  29. package/dist/environment/spin.d.ts +3 -0
  30. package/dist/environment/spin.js +19 -3
  31. package/dist/environment/spin.js.map +1 -1
  32. package/dist/error.d.ts +0 -1
  33. package/dist/error.js +0 -1
  34. package/dist/error.js.map +1 -1
  35. package/dist/http/fetch.d.ts +1 -2
  36. package/dist/http/fetch.js +2 -2
  37. package/dist/http/fetch.js.map +1 -1
  38. package/dist/http/graphql.d.ts +0 -2
  39. package/dist/http/graphql.js +1 -1
  40. package/dist/http/graphql.js.map +1 -1
  41. package/dist/http.d.ts +2 -3
  42. package/dist/http.js +5 -5
  43. package/dist/http.js.map +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +1 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/log.d.ts +21 -0
  48. package/dist/log.js +155 -0
  49. package/dist/log.js.map +1 -0
  50. package/dist/node/base-command.d.ts +3 -1
  51. package/dist/node/base-command.js +5 -2
  52. package/dist/node/base-command.js.map +1 -1
  53. package/dist/node/cli.d.ts +2 -1
  54. package/dist/node/cli.js +51 -2
  55. package/dist/node/cli.js.map +1 -1
  56. package/dist/node/hooks/init.js +2 -2
  57. package/dist/node/hooks/init.js.map +1 -1
  58. package/dist/node/hooks/prerun.js.map +1 -1
  59. package/dist/node/node-package-manager.d.ts +2 -2
  60. package/dist/node/node-package-manager.js +9 -16
  61. package/dist/node/node-package-manager.js.map +1 -1
  62. package/dist/output.d.ts +1 -8
  63. package/dist/output.js +2 -99
  64. package/dist/output.js.map +1 -1
  65. package/dist/port.js +1 -1
  66. package/dist/port.js.map +1 -1
  67. package/dist/session/device-authorization.d.ts +32 -0
  68. package/dist/session/device-authorization.js +92 -0
  69. package/dist/session/device-authorization.js.map +1 -0
  70. package/dist/session/exchange.d.ts +9 -0
  71. package/dist/session/exchange.js +49 -23
  72. package/dist/session/exchange.js.map +1 -1
  73. package/dist/session/identity.js +5 -5
  74. package/dist/session/identity.js.map +1 -1
  75. package/dist/session.js +19 -7
  76. package/dist/session.js.map +1 -1
  77. package/dist/tsconfig.tsbuildinfo +1 -1
  78. package/dist/ui.js +2 -1
  79. package/dist/ui.js.map +1 -1
  80. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 3.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 454641be: Allow running shopify installed globally instead of npm/yarn/pnpm shopify
8
+
9
+ ## 3.11.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 79508f56: Don't allow the log file to grow too much
14
+ - 922c204e: New Result type for handling errors
15
+ - ddbf7ee4: Add new authentication method for cloud environments
16
+
17
+ ### Patch Changes
18
+
19
+ - 38dedc05: Fix getRandomPort retries
20
+
3
21
  ## 3.10.1
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  With the Shopify command line interface (Shopify CLI 3.0), you can:
9
9
  - build custom storefronts and manage their hosting
10
- - initialize, build, dev, and deploy Shopify apps — and scaffold app extensions
10
+ - initialize, build, dev, and deploy Shopify apps — and generate app extensions
11
11
 
12
12
  <p>&nbsp;</p>
13
13
 
@@ -1,9 +1,10 @@
1
+ import BaseCommand from './node/base-command.js';
1
2
  import { Interfaces } from '@oclif/core';
2
3
  interface StartOptions {
3
4
  command: string;
4
5
  args: string[];
5
6
  currentTime?: number;
6
- commandClass?: Interfaces.Command.Class;
7
+ commandClass?: Interfaces.Command.Class | typeof BaseCommand;
7
8
  }
8
9
  export declare const start: ({ command, args, currentTime, commandClass }: StartOptions) => Promise<void>;
9
10
  interface ReportEventOptions {
package/dist/analytics.js CHANGED
@@ -8,10 +8,14 @@ import { publishEvent, MONORAIL_COMMAND_TOPIC } from './monorail.js';
8
8
  import { fanoutHooks } from './plugins.js';
9
9
  import { packageManagerUsedForCreating } from './node/node-package-manager.js';
10
10
  export const start = async ({ command, args, currentTime = new Date().getTime(), commandClass }) => {
11
+ let startCommand = command;
12
+ if (commandClass && Object.prototype.hasOwnProperty.call(command, 'analyticsNameOverride')) {
13
+ startCommand = commandClass.analyticsNameOverride() ?? command;
14
+ }
11
15
  await metadata.addSensitive(() => ({
12
16
  commandStartOptions: {
13
17
  startTime: currentTime,
14
- startCommand: command,
18
+ startCommand,
15
19
  startArgs: args,
16
20
  },
17
21
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,OAAO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UAAU,CAAC,WAAW,CAAC,CAAC,CAAA;IAErF,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,GAAG,eAAe,EAAE,CAAA;IAE1C,OAAO;QACL,KAAK,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;QAC5B,MAAM,EAAE,UAAU,CAAC,IAAI;QACvB,eAAe,EAAE,UAAU,CAAC,IAAI;QAChC,+BAA+B,EAAE,WAAW,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM;QAC7E,4BAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;QAC5D,SAAS,EAAE,MAAM,CAAC,KAAK;QACvB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,cAAc,EAAE;KAChD,CAAA;AACH,CAAC","sourcesContent":["import * as environment from './environment.js'\nimport {platformAndArch} from './os.js'\nimport {version as rubyVersion} from './node/ruby.js'\nimport {content, debug, token} from './output.js'\nimport constants from './constants.js'\nimport * as metadata from './metadata.js'\nimport {publishEvent, MONORAIL_COMMAND_TOPIC} from './monorail.js'\nimport {fanoutHooks} from './plugins.js'\nimport {packageManagerUsedForCreating} from './node/node-package-manager.js'\nimport {Interfaces} from '@oclif/core'\n\ninterface StartOptions {\n command: string\n args: string[]\n currentTime?: number\n commandClass?: Interfaces.Command.Class\n}\n\nexport const start = async ({command, args, currentTime = new Date().getTime(), commandClass}: StartOptions) => {\n await metadata.addSensitive(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand: command,\n startArgs: args,\n },\n }))\n\n await metadata.addPublic(() => ({\n cmd_all_launcher: packageManagerUsedForCreating(),\n cmd_all_plugin: commandClass?.plugin?.name,\n }))\n}\n\ninterface ReportEventOptions {\n config: Interfaces.Config\n errorMessage?: string\n}\n\n/**\n * Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.\n *\n * The payload for an event includes both generic data, and data gathered from installed plug-ins.\n *\n */\nexport async function reportEvent(options: ReportEventOptions) {\n try {\n const payload = await buildPayload(options)\n if (payload === undefined) {\n // Nothing to log\n return\n }\n if (!environment.local.alwaysLogAnalytics() && environment.local.analyticsDisabled()) {\n debug(content`Skipping command analytics, payload: ${token.json(payload)}`)\n return\n }\n const response = await publishEvent(MONORAIL_COMMAND_TOPIC, payload.public, payload.sensitive)\n if (response.type === 'error') {\n debug(response.message)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nconst buildPayload = async ({config, errorMessage}: ReportEventOptions) => {\n const {commandStartOptions, ...sensitiveMetadata} = metadata.getAllSensitive()\n if (commandStartOptions === undefined) {\n debug('Unable to log analytics event - no information on executed command')\n return\n }\n const {startCommand, startArgs, startTime} = commandStartOptions\n const currentTime = new Date().getTime()\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n const sensitivePluginData = await fanoutHooks(config, 'sensitive_command_metadata', {})\n\n const environmentData = getEnvironmentData(config)\n\n return {\n public: {\n command: startCommand,\n time_start: startTime,\n time_end: currentTime,\n total_time: currentTime - startTime,\n success: errorMessage === undefined,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n ...environmentData,\n ...appPublic,\n ...metadata.getAllPublic(),\n },\n sensitive: {\n args: startArgs.join(' '),\n error_message: errorMessage,\n metadata: JSON.stringify({\n ...sensitiveMetadata,\n extraPublic: {\n ...otherPluginsPublic,\n },\n extraSensitive: sensitivePluginData,\n }),\n },\n }\n}\n\nexport function getEnvironmentData(config: Interfaces.Config) {\n const ciPlatform = environment.local.ciPlatform()\n\n const pluginNames = config.plugins\n .map((plugin) => plugin.name)\n .sort()\n .filter((plugin) => !plugin.startsWith('@oclif/'))\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciPlatform.isCI,\n env_ci_platform: ciPlatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: environment.local.webIDEPlatform(),\n }\n}\n"]}
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAA;AAClE,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAA;AACxC,OAAO,EAAC,6BAA6B,EAAC,MAAM,gCAAgC,CAAA;AAW5E,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,EAAe,EAAE,EAAE;IAC7G,IAAI,YAAY,GAAW,OAAO,CAAA;IAClC,IAAI,YAAY,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE;QAC1F,YAAY,GAAI,YAAmC,CAAC,qBAAqB,EAAE,IAAI,OAAO,CAAA;KACvF;IAED,MAAM,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;QACjC,mBAAmB,EAAE;YACnB,SAAS,EAAE,WAAW;YACtB,YAA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AC,SAAS,CAAC;gBACvB,GAAG,iBAAiB;gBACpB,WAAW,EAAE;oBACX,GAAG,kBAAkB;iBACtB;gBACD,cAAc,EAAE,mBAAmB;aACpC,CAAC;SACH;KACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAyB;IAC1D,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,UAAU,EAAE,CAAA;IAEjD,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO;SAC/B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;SAC5B,IAAI,EAAE;SACN,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA;IACpD,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAA;IAErF,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,GAAG,eAAe,EAAE,CAAA;IAE1C,OAAO;QACL,KAAK,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;QAC5B,MAAM,EAAE,UAAU,CAAC,IAAI;QACvB,eAAe,EAAE,UAAU,CAAC,IAAI;QAChC,+BAA+B,EAAE,WAAW,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM;QAC7E,4BAA4B,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;QAC5D,SAAS,EAAE,MAAM,CAAC,KAAK;QACvB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,cAAc,EAAE;KAChD,CAAA;AACH,CAAC","sourcesContent":["import * as environment from './environment.js'\nimport {platformAndArch} from './os.js'\nimport {version as rubyVersion} from './node/ruby.js'\nimport {content, debug, token} from './output.js'\nimport constants from './constants.js'\nimport * as metadata from './metadata.js'\nimport {publishEvent, MONORAIL_COMMAND_TOPIC} from './monorail.js'\nimport {fanoutHooks} from './plugins.js'\nimport {packageManagerUsedForCreating} from './node/node-package-manager.js'\nimport BaseCommand from './node/base-command.js'\nimport {Interfaces} from '@oclif/core'\n\ninterface StartOptions {\n command: string\n args: string[]\n currentTime?: number\n commandClass?: Interfaces.Command.Class | typeof BaseCommand\n}\n\nexport const start = async ({command, args, currentTime = new Date().getTime(), commandClass}: StartOptions) => {\n let startCommand: string = command\n if (commandClass && Object.prototype.hasOwnProperty.call(command, 'analyticsNameOverride')) {\n startCommand = (commandClass as typeof BaseCommand).analyticsNameOverride() ?? command\n }\n\n await metadata.addSensitive(() => ({\n commandStartOptions: {\n startTime: currentTime,\n startCommand,\n startArgs: args,\n },\n }))\n\n await metadata.addPublic(() => ({\n cmd_all_launcher: packageManagerUsedForCreating(),\n cmd_all_plugin: commandClass?.plugin?.name,\n }))\n}\n\ninterface ReportEventOptions {\n config: Interfaces.Config\n errorMessage?: string\n}\n\n/**\n * Report an analytics event, sending it off to Monorail -- Shopify's internal analytics service.\n *\n * The payload for an event includes both generic data, and data gathered from installed plug-ins.\n *\n */\nexport async function reportEvent(options: ReportEventOptions) {\n try {\n const payload = await buildPayload(options)\n if (payload === undefined) {\n // Nothing to log\n return\n }\n if (!environment.local.alwaysLogAnalytics() && environment.local.analyticsDisabled()) {\n debug(content`Skipping command analytics, payload: ${token.json(payload)}`)\n return\n }\n const response = await publishEvent(MONORAIL_COMMAND_TOPIC, payload.public, payload.sensitive)\n if (response.type === 'error') {\n debug(response.message)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nconst buildPayload = async ({config, errorMessage}: ReportEventOptions) => {\n const {commandStartOptions, ...sensitiveMetadata} = metadata.getAllSensitive()\n if (commandStartOptions === undefined) {\n debug('Unable to log analytics event - no information on executed command')\n return\n }\n const {startCommand, startArgs, startTime} = commandStartOptions\n const currentTime = new Date().getTime()\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n const sensitivePluginData = await fanoutHooks(config, 'sensitive_command_metadata', {})\n\n const environmentData = getEnvironmentData(config)\n\n return {\n public: {\n command: startCommand,\n time_start: startTime,\n time_end: currentTime,\n total_time: currentTime - startTime,\n success: errorMessage === undefined,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n ...environmentData,\n ...appPublic,\n ...metadata.getAllPublic(),\n },\n sensitive: {\n args: startArgs.join(' '),\n error_message: errorMessage,\n metadata: JSON.stringify({\n ...sensitiveMetadata,\n extraPublic: {\n ...otherPluginsPublic,\n },\n extraSensitive: sensitivePluginData,\n }),\n },\n }\n}\n\nexport function getEnvironmentData(config: Interfaces.Config) {\n const ciPlatform = environment.local.ciPlatform()\n\n const pluginNames = config.plugins\n .map((plugin) => plugin.name)\n .sort()\n .filter((plugin) => !plugin.startsWith('@oclif/'))\n const shopifyPlugins = pluginNames.filter((plugin) => plugin.startsWith('@shopify/'))\n\n const {platform, arch} = platformAndArch()\n\n return {\n uname: `${platform} ${arch}`,\n env_ci: ciPlatform.isCI,\n env_ci_platform: ciPlatform.name,\n env_plugin_installed_any_custom: pluginNames.length !== shopifyPlugins.length,\n env_plugin_installed_shopify: JSON.stringify(shopifyPlugins),\n env_shell: config.shell,\n env_web_ide: environment.local.webIDEPlatform(),\n }\n}\n"]}
package/dist/api/admin.js CHANGED
@@ -19,11 +19,7 @@ export async function request(query, session, variables) {
19
19
  const version = await fetchApiVersion(session);
20
20
  const url = adminUrl(session.storeFqdn, version);
21
21
  const headers = await buildHeaders(session.token);
22
- const client = await graphqlClient({
23
- headers,
24
- url,
25
- service: 'shopify',
26
- });
22
+ const client = await graphqlClient({ headers, url });
27
23
  debugLogRequest(api, query, variables, headers);
28
24
  const response = await client.request(query, variables);
29
25
  return response;
@@ -33,7 +29,7 @@ async function fetchApiVersion(session) {
33
29
  const url = adminUrl(session.storeFqdn, 'unstable');
34
30
  const query = apiVersionQuery();
35
31
  const headers = await buildHeaders(session.token);
36
- const client = await graphqlClient({ url, headers, service: 'shopify' });
32
+ const client = await graphqlClient({ url, headers });
37
33
  debug(`
38
34
  Sending Admin GraphQL request to URL ${url} with query:
39
35
  ${query}
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AAEzE,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,cAAc,CAAA;AACjE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,GAAG,EAA6B,MAAM,iBAAiB,CAAA;AAE/D,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAE,EAAE;IAChD,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAA;IACnE,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;IACrD,OAAO,IAAI,KAAK,CACd,OAAO,CAAA,iDAAiD,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,KAAK,EAAE,CAAC,GAAG,EAC1G,OAAO,CAAA,4CAA4C,SAAS;;KAE3D,CACF,CAAA;AACH,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,OAAO,IAAI,GAAG,CAAC,wCAAwC,CAAC,CAAA;AAC1D,CAAC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,OAAqB,EAAE,SAAqB;IACnG,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AAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;IACjG,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,iBAAiB;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;SAChC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,EAAE,CAAC,CAAC,CAAE,CAAA;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {gql, RequestDocument, Variables} from 'graphql-request'\n\nconst UnauthorizedAccessError = (store: string) => {\n const adminLink = outputToken.link(`URL`, `https://${store}/admin`)\n const storeName = store.replace('.myshopify.com', '')\n return new Abort(\n content`Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`,\n content`• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.\n• If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.\n `,\n )\n}\n\nconst UnknownError = () => {\n return new Bug(`Unknown error connecting to your store`)\n}\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const api = 'Admin'\n return handlingErrors(api, async () => {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({\n headers,\n url,\n service: 'shopify',\n })\n debugLogRequest(api, query, variables, headers)\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({url, headers, service: 'shopify'})\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await client\n .request<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(query, {})\n .catch((err) => {\n throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError()\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]!\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
1
+ {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AAEzE,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,cAAc,CAAA;AACjE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,GAAG,EAA6B,MAAM,iBAAiB,CAAA;AAE/D,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAE,EAAE;IAChD,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAA;IACnE,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;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M,aAAa,CAAC,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC,CAAA;IAClD,KAAK,CAAC;uCAC+B,GAAG;EACxC,KAAK;GACJ,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,MAAM,MAAM;SACtB,OAAO,CAEL,KAAK,EAAE,EAAE,CAAC;SACZ,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;IACjG,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,iBAAiB;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;SAChC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,EAAE,CAAC,CAAC,CAAE,CAAA;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {gql, RequestDocument, Variables} from 'graphql-request'\n\nconst UnauthorizedAccessError = (store: string) => {\n const adminLink = outputToken.link(`URL`, `https://${store}/admin`)\n const storeName = store.replace('.myshopify.com', '')\n return new Abort(\n content`Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`,\n content`• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.\n• If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.\n `,\n )\n}\n\nconst UnknownError = () => {\n return new Bug(`Unknown error connecting to your store`)\n}\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const api = 'Admin'\n return handlingErrors(api, async () => {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({headers, url})\n debugLogRequest(api, query, variables, headers)\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({url, headers})\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await client\n .request<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(query, {})\n .catch((err) => {\n throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError()\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]!\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
@@ -10,7 +10,7 @@ export async function validateIdentityToken(token) {
10
10
  body: JSON.stringify({ token }),
11
11
  };
12
12
  debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`);
13
- const response = await shopifyFetch('shopify', instrospectionURL, options);
13
+ const response = await shopifyFetch(instrospectionURL, options);
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  const json = await response.json();
16
16
  debug(`The identity token is valid: ${json.valid}`);
@@ -23,7 +23,7 @@ export async function validateIdentityToken(token) {
23
23
  }
24
24
  }
25
25
  async function getInstrospectionEndpoint() {
26
- const response = await shopifyFetch('identity', `https://${await identity()}/.well-known/openid-configuration.json`);
26
+ const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`);
27
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
28
  const json = await response.json();
29
29
  return json.introspection_endpoint;
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACvD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,yBAAyB,EAAE,CAAA;QAC3D,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAC,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAC;YAC/E,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC;SAC9B,CAAA;QACD,KAAK,CAAC,kDAAkD,iBAAiB,EAAE,CAAC,CAAA;QAE5E,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,SAAS,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAC1E,8DAA8D;QAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEvC,KAAK,CAAC,gCAAgC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACnD,OAAO,IAAI,CAAC,KAAK,CAAA;QACjB,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACpH,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch('shopify', instrospectionURL, options)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch('identity', `https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACvD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,yBAAyB,EAAE,CAAA;QAC3D,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAC,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAC;YAC/E,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC;SAC9B,CAAA;QACD,KAAK,CAAC,kDAAkD,iBAAiB,EAAE,CAAC,CAAA;QAE5E,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAC/D,8DAA8D;QAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEvC,KAAK,CAAC,gCAAgC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACnD,OAAO,IAAI,CAAC,KAAK,CAAA;QACjB,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACxG,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch(instrospectionURL, options)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
@@ -10,11 +10,7 @@ export async function request(query, token, variables) {
10
10
  const url = `https://${fqdn}/api/cli/graphql`;
11
11
  const headers = await buildHeaders(token);
12
12
  debugLogRequest(api, query, variables, headers);
13
- const client = await graphqlClient({
14
- headers,
15
- service: 'partners',
16
- url,
17
- });
13
+ const client = await graphqlClient({ headers, url });
18
14
  const response = await client.request(query, variables);
19
15
  return response;
20
16
  });
@@ -37,11 +33,7 @@ export async function checkIfTokenIsRevoked(token) {
37
33
  const fqdn = await partnersFqdn();
38
34
  const url = `https://${fqdn}/api/cli/graphql`;
39
35
  const headers = await buildHeaders(token);
40
- const client = await graphqlClient({
41
- headers,
42
- url,
43
- service: 'partners',
44
- });
36
+ const client = await graphqlClient({ headers, url });
45
37
  try {
46
38
  await client.request(query, {});
47
39
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAY,WAAW,EAAE,GAAG,EAAkB,MAAM,iBAAiB,CAAA;AAE5E,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAE,SAAqB;IAC3F,MAAM,GAAG,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AAMD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,KAAc,EACd,KAAa,EACb,SAAmB;IAEnB,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,MAAM;QACf,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {Variables, ClientError, gql, RequestDocument} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({\n headers,\n service: 'partners',\n url,\n })\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\n/**\n * Check if the given token is revoked and no longer valid to interact with the Partners API.\n * @param token {string} - The token to check\n * @returns {Promise<boolean>} - True if the token is revoked, false otherwise\n */\nexport async function checkIfTokenIsRevoked(token: string): Promise<boolean> {\n const query = gql`\n {\n organizations(first: 1) {\n nodes {\n id\n }\n }\n }\n `\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n const client = await graphqlClient({\n headers,\n url,\n service: 'partners',\n })\n try {\n await client.request(query, {})\n return false\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n if (error instanceof ClientError) {\n return error.response.status === 401\n }\n return false\n }\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey {string} APIKey of the app where the query will be executed.\n * @param query {any} GraphQL query to execute.\n * @param token {string} Partners token\n * @param variables {any} GraphQL variables to pass to the query.\n * @returns {Promise<T>} The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
1
+ {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAY,WAAW,EAAE,GAAG,EAAkB,MAAM,iBAAiB,CAAA;AAE5E,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAE,SAAqB;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;QACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kB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CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {Variables, ClientError, gql, RequestDocument} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({headers, url})\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\n/**\n * Check if the given token is revoked and no longer valid to interact with the Partners API.\n * @param token {string} - The token to check\n * @returns {Promise<boolean>} - True if the token is revoked, false otherwise\n */\nexport async function checkIfTokenIsRevoked(token: string): Promise<boolean> {\n const query = gql`\n {\n organizations(first: 1) {\n nodes {\n id\n }\n }\n }\n `\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n const client = await graphqlClient({headers, url})\n try {\n await client.request(query, {})\n return false\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n if (error instanceof ClientError) {\n return error.response.status === 401\n }\n return false\n }\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey {string} APIKey of the app where the query will be executed.\n * @param query {any} GraphQL query to execute.\n * @param token {string} Partners token\n * @param variables {any} GraphQL variables to pass to the query.\n * @returns {Promise<T>} The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
@@ -0,0 +1,17 @@
1
+ export declare type Result<T, TError> = Ok<T, TError> | Err<T, TError>;
2
+ export declare const ok: <T, TError = never>(value: T) => Ok<T, TError>;
3
+ export declare const err: <T = never, TError = unknown>(err: TError) => Err<T, TError>;
4
+ export declare class Ok<T, TError> {
5
+ readonly value: T;
6
+ constructor(value: T);
7
+ isErr(): this is Err<T, TError>;
8
+ valueOrThrow(): T;
9
+ mapError<TMappedError>(mapper: (error: TError) => TMappedError): Result<T, TError>;
10
+ }
11
+ export declare class Err<T, TError> {
12
+ readonly error: TError;
13
+ constructor(error: TError);
14
+ isErr(): this is Err<T, TError>;
15
+ valueOrThrow(): T;
16
+ mapError<TMappedError>(mapper: (error: TError) => TMappedError): Result<T, TMappedError>;
17
+ }
@@ -0,0 +1,31 @@
1
+ export const ok = (value) => new Ok(value);
2
+ export const err = (err) => new Err(err);
3
+ export class Ok {
4
+ constructor(value) {
5
+ this.value = value;
6
+ }
7
+ isErr() {
8
+ return false;
9
+ }
10
+ valueOrThrow() {
11
+ return this.value;
12
+ }
13
+ mapError(mapper) {
14
+ return ok(this.value);
15
+ }
16
+ }
17
+ export class Err {
18
+ constructor(error) {
19
+ this.error = error;
20
+ }
21
+ isErr() {
22
+ return true;
23
+ }
24
+ valueOrThrow() {
25
+ throw this.error;
26
+ }
27
+ mapError(mapper) {
28
+ return err(mapper(this.error));
29
+ }
30
+ }
31
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/common/result.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,EAAE,GAAG,CAAoB,KAAQ,EAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAA;AAE/E,MAAM,CAAC,MAAM,GAAG,GAAG,CAA8B,GAAW,EAAkB,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;AAE7F,MAAM,OAAO,EAAE;IACb,YAAqB,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;IAEjC,KAAK;QACH,OAAO,KAAK,CAAA;IACd,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,QAAQ,CAAe,MAAuC;QAC5D,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;CACF;AAED,MAAM,OAAO,GAAG;IACd,YAAqB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAEtC,KAAK;QACH,OAAO,IAAI,CAAA;IACb,CAAC;IAED,YAAY;QACV,MAAM,IAAI,CAAC,KAAK,CAAA;IAClB,CAAC;IAED,QAAQ,CAAe,MAAuC;QAC5D,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAChC,CAAC;CACF","sourcesContent":["/* eslint-disable node/handle-callback-err */\nexport type Result<T, TError> = Ok<T, TError> | Err<T, TError>\n\nexport const ok = <T, TError = never>(value: T): Ok<T, TError> => new Ok(value)\n\nexport const err = <T = never, TError = unknown>(err: TError): Err<T, TError> => new Err(err)\n\nexport class Ok<T, TError> {\n constructor(readonly value: T) {}\n\n isErr(): this is Err<T, TError> {\n return false\n }\n\n valueOrThrow(): T {\n return this.value\n }\n\n mapError<TMappedError>(mapper: (error: TError) => TMappedError): Result<T, TError> {\n return ok(this.value)\n }\n}\n\nexport class Err<T, TError> {\n constructor(readonly error: TError) {}\n\n isErr(): this is Err<T, TError> {\n return true\n }\n\n valueOrThrow(): T {\n throw this.error\n }\n\n mapError<TMappedError>(mapper: (error: TError) => TMappedError): Result<T, TMappedError> {\n return err(mapper(this.error))\n }\n}\n"]}
@@ -2,11 +2,8 @@ declare const constants: {
2
2
  environmentVariables: {
3
3
  unitTest: string;
4
4
  env: string;
5
+ serviceEnv: string;
5
6
  runAsUser: string;
6
- partnersEnv: string;
7
- shopifyEnv: string;
8
- identityEnv: string;
9
- spin: string;
10
7
  spinInstance: string;
11
8
  spinWorkspace: string;
12
9
  spinNamespace: string;
@@ -16,7 +13,14 @@ declare const constants: {
16
13
  noAnalytics: string;
17
14
  alwaysLogAnalytics: string;
18
15
  firstPartyDev: string;
16
+ enableCliRedirect: string;
17
+ skipCliRedirect: string;
19
18
  debugGoBinary: string;
19
+ deviceAuth: string;
20
+ spin: string;
21
+ codespaces: string;
22
+ codespaceName: string;
23
+ gitpod: string;
20
24
  };
21
25
  paths: {
22
26
  executables: {
package/dist/constants.js CHANGED
@@ -11,11 +11,8 @@ const constants = {
11
11
  environmentVariables: {
12
12
  unitTest: 'SHOPIFY_UNIT_TEST',
13
13
  env: 'SHOPIFY_ENV',
14
+ serviceEnv: 'SHOPIFY_SERVICE_ENV',
14
15
  runAsUser: 'SHOPIFY_RUN_AS_USER',
15
- partnersEnv: 'SHOPIFY_PARTNERS_ENV',
16
- shopifyEnv: 'SHOPIFY_SHOPIFY_ENV',
17
- identityEnv: 'SHOPIFY_IDENTITY_ENV',
18
- spin: 'SPIN',
19
16
  spinInstance: 'SPIN_INSTANCE',
20
17
  spinWorkspace: 'SPIN_WORKSPACE',
21
18
  spinNamespace: 'SPIN_NAMESPACE',
@@ -25,7 +22,15 @@ const constants = {
25
22
  noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',
26
23
  alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',
27
24
  firstPartyDev: 'SHOPIFY_CLI_1P_DEV',
25
+ enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',
26
+ skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',
28
27
  debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',
28
+ deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',
29
+ // Variables to detect if the CLI is running in a cloud environment
30
+ spin: 'SPIN',
31
+ codespaces: 'CODESPACES',
32
+ codespaceName: 'CODESPACE_NAME',
33
+ gitpod: 'GITPOD_WORKSPACE_URL',
29
34
  },
30
35
  paths: {
31
36
  executables: {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACjE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,SAAS,GAAG;IAChB,oBAAoB,EAAE;QACpB,QAAQ,EAAE,mBAAmB;QAC7B,GAAG,EAAE,aAAa;QAClB,SAAS,EAAE,qBAAqB;QAChC,WAAW,EAAE,sBAAsB;QACnC,UAAU,EAAE,qBAAqB;QACjC,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,eAAe;QAC7B,aAAa,EAAE,gBAAgB;QAC/B,aAAa,EAAE,gBAAgB;QAC/B,QAAQ,EAAE,WAAW;QACrB,aAAa,EAAE,4BAA4B;QAC3C,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,0BAA0B;QACvC,kBAAkB,EAAE,kCAAkC;QACtD,aAAa,EAAE,oBAAoB;QACnC,aAAa,EAAE,yBAAyB;KACzC;IACD,KAAK,EAAE;QACL,WAAW,EAAE;YACX,GAAG,EAAE,kBAAkB;SACxB;QACD,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,EAAE;oBACT,OAAO,WAAW,EAAE,CAAA;gBACtB,CAAC;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,GAAG,EAAE;wBACT,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;oBAC1C,CAAC;oBACD,QAAQ,EAAE,GAAG,EAAE;wBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;oBACtD,CAAC;iBACF;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,oBAAoB,CAAC,EAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './version.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n unitTest: 'SHOPIFY_UNIT_TEST',\n env: 'SHOPIFY_ENV',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n partnersEnv: 'SHOPIFY_PARTNERS_ENV',\n shopifyEnv: 'SHOPIFY_SHOPIFY_ENV',\n identityEnv: 'SHOPIFY_IDENTITY_ENV',\n spin: 'SPIN',\n spinInstance: 'SPIN_INSTANCE',\n spinWorkspace: 'SPIN_WORKSPACE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinHost: 'SPIN_HOST',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,C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AAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["import {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './version.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n unitTest: 'SHOPIFY_UNIT_TEST',\n env: 'SHOPIFY_ENV',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n spinInstance: 'SPIN_INSTANCE',\n spinWorkspace: 'SPIN_WORKSPACE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinHost: 'SPIN_HOST',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n debugGoBinary: 'SHOPIFY_DEBUG_GO_BINARY',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n // Variables to detect if the CLI is running in a cloud environment\n spin: 'SPIN',\n codespaces: 'CODESPACES',\n codespaceName: 'CODESPACE_NAME',\n gitpod: 'GITPOD_WORKSPACE_URL',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
@@ -1,5 +1,5 @@
1
- import { partners as partnersEnvironment, shopify as shopifyEnvironment, identity as identityEnvironment, } from './service.js';
2
1
  import { fqdn as spinFqdn } from './spin.js';
2
+ import { serviceEnvironment } from './service.js';
3
3
  import { Abort } from '../error.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.");
@@ -10,7 +10,7 @@ export const NotProvidedStoreFQDNError = new Abort("Couldn't obtain the Shopify
10
10
  * @returns {string} Fully-qualified domain of the partners service we should interact with.
11
11
  */
12
12
  export async function partners() {
13
- const environment = partnersEnvironment();
13
+ const environment = serviceEnvironment();
14
14
  const productionFqdn = 'partners.shopify.com';
15
15
  switch (environment) {
16
16
  case 'local':
@@ -26,7 +26,7 @@ export async function partners() {
26
26
  * @returns {string} Fully-qualified domain of the Identity service we should interact with.
27
27
  */
28
28
  export async function identity() {
29
- const environment = identityEnvironment();
29
+ const environment = serviceEnvironment();
30
30
  const productionFqdn = 'accounts.shopify.com';
31
31
  switch (environment) {
32
32
  case 'local':
@@ -43,7 +43,7 @@ export async function identity() {
43
43
  * @returns {string} Fully-qualified domain of the Shopify service we should interact with.
44
44
  */
45
45
  export async function shopify(options = {}) {
46
- const environment = shopifyEnvironment();
46
+ const environment = serviceEnvironment();
47
47
  switch (environment) {
48
48
  case 'local':
49
49
  return 'shopify.myshopify.io';
@@ -1 +1 @@
1
- {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../src/environment/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,IAAI,mBAAmB,EAC/B,OAAO,IAAI,kBAAkB,EAC7B,QAAQ,IAAI,mBAAmB,GAChC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,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;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAA;IACzC,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;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,WAAW,GAAG,mBAAmB,EAAE,CAAA;IACzC,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,OAAO,CAAC,UAAgC,EAAE;IAC9D,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,sBAAsB,CAAA;QAC/B,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,OAAO,CAAC,SAAS,CAAA;aACzB;iBAAM;gBACL,MAAM,yBAAyB,CAAA;aAChC;KACJ;AACH,CAAC","sourcesContent":["import {\n partners as partnersEnvironment,\n shopify as shopifyEnvironment,\n identity as identityEnvironment,\n} from './service.js'\nimport {fqdn as spinFqdn} from './spin.js'\nimport {Abort} from '../error.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 * @returns {string} Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partners(): Promise<string> {\n const environment = partnersEnvironment()\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 * @returns {string} Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identity(): Promise<string> {\n const environment = identityEnvironment()\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 * It returns the Shopify service we should interact with.\n * Note the same fqdn is sued for the Admin and the Storefront Renderer APIs.\n * @returns {string} Fully-qualified domain of the Shopify service we should interact with.\n */\nexport async function shopify(options: {storeFqdn?: string} = {}): Promise<string> {\n const environment = shopifyEnvironment()\n switch (environment) {\n case 'local':\n return 'shopify.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n if (options.storeFqdn) {\n return options.storeFqdn\n } else {\n throw NotProvidedStoreFQDNError\n }\n }\n}\n"]}
1
+ {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../src/environment/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjC,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;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,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;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,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,OAAO,CAAC,UAAgC,EAAE;IAC9D,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,QAAQ,WAAW,EAAE;QACnB,KAAK,OAAO;YACV,OAAO,sBAAsB,CAAA;QAC/B,KAAK,MAAM;YACT,OAAO,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;QACvC;YACE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,OAAO,CAAC,SAAS,CAAA;aACzB;iBAAM;gBACL,MAAM,yBAAyB,CAAA;aAChC;KACJ;AACH,CAAC","sourcesContent":["import {fqdn as spinFqdn} from './spin.js'\nimport {serviceEnvironment} from './service.js'\nimport {Abort} from '../error.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 * @returns {string} Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partners(): 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 * @returns {string} Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identity(): 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 * It returns the Shopify service we should interact with.\n * Note the same fqdn is sued for the Admin and the Storefront Renderer APIs.\n * @returns {string} Fully-qualified domain of the Shopify service we should interact with.\n */\nexport async function shopify(options: {storeFqdn?: string} = {}): Promise<string> {\n const environment = serviceEnvironment()\n switch (environment) {\n case 'local':\n return 'shopify.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n if (options.storeFqdn) {\n return options.storeFqdn\n } else {\n throw NotProvidedStoreFQDNError\n }\n }\n}\n"]}
@@ -45,6 +45,10 @@ export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
45
45
  export declare function alwaysLogAnalytics(env?: NodeJS.ProcessEnv): boolean;
46
46
  export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
47
47
  export declare function isDebugGoBinary(env?: NodeJS.ProcessEnv): boolean;
48
+ export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
49
+ export declare function gitpodURL(env?: NodeJS.ProcessEnv): string | undefined;
50
+ export declare function codespaceURL(env?: NodeJS.ProcessEnv): string | undefined;
51
+ export declare function isCloudEnvironment(env?: NodeJS.ProcessEnv): boolean;
48
52
  /**
49
53
  * Returns whether the environment has Git available.
50
54
  * @returns {Promise<boolean>} A promise that resolves with the value.
@@ -63,4 +67,4 @@ export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
63
67
  /**
64
68
  * Gets info on the Web IDE platform the CLI is running on, if applicable
65
69
  */
66
- export declare function webIDEPlatform(env?: NodeJS.ProcessEnv): "codespaces" | undefined;
70
+ export declare function webIDEPlatform(env?: NodeJS.ProcessEnv): "codespaces" | "gitpod" | undefined;
@@ -45,7 +45,7 @@ export async function isShopify(env = process.env) {
45
45
  return !isTruthy(env[constants.environmentVariables.runAsUser]);
46
46
  }
47
47
  const devInstalled = await fileExists(constants.paths.executables.dev);
48
- return devInstalled || isSpin();
48
+ return devInstalled || isSpin(env);
49
49
  }
50
50
  /**
51
51
  * This variable is used when running unit tests to indicate that the CLI's business logic
@@ -75,6 +75,26 @@ export function firstPartyDev(env = process.env) {
75
75
  export function isDebugGoBinary(env = process.env) {
76
76
  return isTruthy(env[constants.environmentVariables.debugGoBinary]);
77
77
  }
78
+ export function useDeviceAuth(env = process.env) {
79
+ return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env);
80
+ }
81
+ // https://www.gitpod.io/docs/environment-variables#default-environment-variables
82
+ export function gitpodURL(env = process.env) {
83
+ return env[constants.environmentVariables.gitpod];
84
+ }
85
+ // https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables
86
+ export function codespaceURL(env = process.env) {
87
+ return env[constants.environmentVariables.codespaceName];
88
+ }
89
+ export function isCloudEnvironment(env = process.env) {
90
+ return isCodespaces(env) || isGitpod(env) || isSpin(env);
91
+ }
92
+ function isCodespaces(env = process.env) {
93
+ return isTruthy(env[constants.environmentVariables.codespaces]);
94
+ }
95
+ function isGitpod(env = process.env) {
96
+ return isSet(env[constants.environmentVariables.gitpod]);
97
+ }
78
98
  /**
79
99
  * Returns whether the environment has Git available.
80
100
  * @returns {Promise<boolean>} A promise that resolves with the value.
@@ -117,9 +137,10 @@ export function ciPlatform(env = process.env) {
117
137
  * Gets info on the Web IDE platform the CLI is running on, if applicable
118
138
  */
119
139
  export function webIDEPlatform(env = process.env) {
120
- if (isTruthy(env.CODESPACES)) {
140
+ if (isCodespaces(env))
121
141
  return 'codespaces';
122
- }
142
+ if (isGitpod(env))
143
+ return 'gitpod';
123
144
  return undefined;
124
145
  }
125
146
  //# sourceMappingURL=local.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAA;AAE/B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AAClE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACpG,CAAC;AAED;;;;GAIG;AACH,MA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,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAA;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI;QACF,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC9C,IAAI,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;QAC5B,OAAO,YAAY,CAAA;KACpB;IACD,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["import {isTruthy, isSet} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns {boolean} True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns {string} The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_ENV is development\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[constants.environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns {boolean} True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin()\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\nexport function isDebugGoBinary(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.debugGoBinary])\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns {Promise<boolean>} A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Gets info on the Web IDE platform the CLI is running on, if applicable\n */\nexport function webIDEPlatform(env = process.env) {\n if (isTruthy(env.CODESPACES)) {\n return 'codespaces'\n }\n return undefined\n}\n"]}
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAA;AAE/B;;;GAGG;AACH,MAAM,UAA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AG,OAAO,CAAC,GAAG;IAC9C,IAAI,YAAY,CAAC,GAAG,CAAC;QAAE,OAAO,YAAY,CAAA;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAA;IAClC,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["import {isTruthy, isSet} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns {boolean} True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns {string} The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_ENV is development\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[constants.environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns {boolean} True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/** Returns true if reporting analytics should always happen, regardless of DEBUG mode etc. */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.alwaysLogAnalytics])\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\nexport function isDebugGoBinary(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.debugGoBinary])\n}\n\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n// https://www.gitpod.io/docs/environment-variables#default-environment-variables\nexport function gitpodURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.gitpod]\n}\n\n// https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables\nexport function codespaceURL(env = process.env): string | undefined {\n return env[constants.environmentVariables.codespaceName]\n}\n\nexport function isCloudEnvironment(env = process.env): boolean {\n return isCodespaces(env) || isGitpod(env) || isSpin(env)\n}\n\nfunction isCodespaces(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.codespaces])\n}\n\nfunction isGitpod(env = process.env): boolean {\n return isSet(env[constants.environmentVariables.gitpod])\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns {Promise<boolean>} A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Gets info on the Web IDE platform the CLI is running on, if applicable\n */\nexport function webIDEPlatform(env = process.env) {\n if (isCodespaces(env)) return 'codespaces'\n if (isGitpod(env)) return 'gitpod'\n return undefined\n}\n"]}
@@ -1,18 +1,3 @@
1
1
  /// <reference types="node" />
2
- import { Environment, Service } from '../network/service.js';
3
- export declare function environmentForService(service: Service): Promise<Environment>;
4
- /**
5
- * Returns the environment to be used for the interactions with the partners' CLI API.
6
- * @param env The environment variables from the environment of the current process.
7
- */
8
- export declare function partners(env?: NodeJS.ProcessEnv): Environment;
9
- /**
10
- * Returns the environment to be used for the interactions with the admin API.
11
- * @param env The environment variables from the environment of the current process.
12
- */
13
- export declare function shopify(env?: NodeJS.ProcessEnv): Environment;
14
- /**
15
- * Returns the environment to be used for the interactions with identity.
16
- * @param env The environment variables from the environment of the current process.
17
- */
18
- export declare function identity(env?: NodeJS.ProcessEnv): Environment;
2
+ import { Environment } from '../network/service.js';
3
+ export declare function serviceEnvironment(env?: NodeJS.ProcessEnv): Environment;