@shopify/cli-kit 3.70.0 → 3.71.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 (85) hide show
  1. package/dist/cli/api/graphql/admin/generated/theme_files_upsert.d.ts +21 -0
  2. package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js +82 -0
  3. package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js.map +1 -0
  4. package/dist/private/node/api.d.ts +1 -1
  5. package/dist/private/node/api.js +30 -2
  6. package/dist/private/node/api.js.map +1 -1
  7. package/dist/private/node/constants.d.ts +2 -0
  8. package/dist/private/node/constants.js +2 -0
  9. package/dist/private/node/constants.js.map +1 -1
  10. package/dist/private/node/session/exchange.js +2 -2
  11. package/dist/private/node/session/exchange.js.map +1 -1
  12. package/dist/private/node/session/scopes.js +3 -5
  13. package/dist/private/node/session/scopes.js.map +1 -1
  14. package/dist/private/node/session.js +2 -3
  15. package/dist/private/node/session.js.map +1 -1
  16. package/dist/private/node/ui/alert.js +1 -3
  17. package/dist/private/node/ui/alert.js.map +1 -1
  18. package/dist/private/node/ui/components/ConcurrentOutput.js +0 -2
  19. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  20. package/dist/private/node/ui/components/Link.js +3 -0
  21. package/dist/private/node/ui/components/Link.js.map +1 -1
  22. package/dist/private/node/ui/components/Link.test.js +23 -0
  23. package/dist/private/node/ui/components/Link.test.js.map +1 -1
  24. package/dist/private/node/ui.js +1 -1
  25. package/dist/private/node/ui.js.map +1 -1
  26. package/dist/public/common/version.d.ts +1 -1
  27. package/dist/public/common/version.js +1 -1
  28. package/dist/public/common/version.js.map +1 -1
  29. package/dist/public/node/api/admin.js +11 -1
  30. package/dist/public/node/api/admin.js.map +1 -1
  31. package/dist/public/node/api/graphql.d.ts +2 -0
  32. package/dist/public/node/api/graphql.js +2 -2
  33. package/dist/public/node/api/graphql.js.map +1 -1
  34. package/dist/public/node/api/webhooks.d.ts +13 -0
  35. package/dist/public/node/api/webhooks.js +34 -0
  36. package/dist/public/node/api/webhooks.js.map +1 -0
  37. package/dist/public/node/cli-launcher.d.ts +12 -0
  38. package/dist/public/node/cli-launcher.js +29 -0
  39. package/dist/public/node/cli-launcher.js.map +1 -0
  40. package/dist/public/node/cli.d.ts +12 -10
  41. package/dist/public/node/cli.js +38 -100
  42. package/dist/public/node/cli.js.map +1 -1
  43. package/dist/public/node/context/fqdn.js +11 -7
  44. package/dist/public/node/context/fqdn.js.map +1 -1
  45. package/dist/public/node/context/local.d.ts +7 -0
  46. package/dist/public/node/context/local.js +9 -0
  47. package/dist/public/node/context/local.js.map +1 -1
  48. package/dist/public/node/environment.d.ts +7 -0
  49. package/dist/public/node/environment.js +11 -0
  50. package/dist/public/node/environment.js.map +1 -1
  51. package/dist/public/node/error-handler.js +1 -3
  52. package/dist/public/node/error-handler.js.map +1 -1
  53. package/dist/public/node/hooks/prerun.js +0 -2
  54. package/dist/public/node/hooks/prerun.js.map +1 -1
  55. package/dist/public/node/json-schema.d.ts +2 -1
  56. package/dist/public/node/json-schema.js +8 -3
  57. package/dist/public/node/json-schema.js.map +1 -1
  58. package/dist/public/node/notifications-system.d.ts +3 -1
  59. package/dist/public/node/notifications-system.js +9 -1
  60. package/dist/public/node/notifications-system.js.map +1 -1
  61. package/dist/public/node/output.d.ts +1 -6
  62. package/dist/public/node/output.js +1 -5
  63. package/dist/public/node/output.js.map +1 -1
  64. package/dist/public/node/path.d.ts +3 -3
  65. package/dist/public/node/path.js +4 -5
  66. package/dist/public/node/path.js.map +1 -1
  67. package/dist/public/node/system.js +14 -2
  68. package/dist/public/node/system.js.map +1 -1
  69. package/dist/public/node/themes/api.js +67 -8
  70. package/dist/public/node/themes/api.js.map +1 -1
  71. package/dist/public/node/themes/factories.d.ts +1 -3
  72. package/dist/public/node/themes/factories.js +0 -16
  73. package/dist/public/node/themes/factories.js.map +1 -1
  74. package/dist/public/node/tree-kill.js +0 -2
  75. package/dist/public/node/tree-kill.js.map +1 -1
  76. package/dist/public/node/ui.js +30 -80
  77. package/dist/public/node/ui.js.map +1 -1
  78. package/dist/public/node/vendor/dev_server/DevServer.d.ts +19 -0
  79. package/dist/public/node/vendor/dev_server/DevServer.js +170 -0
  80. package/dist/public/node/vendor/dev_server/DevServer.js.map +1 -0
  81. package/dist/tsconfig.tsbuildinfo +1 -1
  82. package/package.json +7 -4
  83. package/dist/private/node/demo-recorder.d.ts +0 -17
  84. package/dist/private/node/demo-recorder.js +0 -121
  85. package/dist/private/node/demo-recorder.js.map +0 -1
@@ -0,0 +1,12 @@
1
+ interface Options {
2
+ moduleURL: string;
3
+ argv?: string[];
4
+ }
5
+ /**
6
+ * Launches the CLI through our custom OCLIF loader.
7
+ *
8
+ * @param options - Options.
9
+ * @returns A promise that resolves when the CLI has been launched.
10
+ */
11
+ export declare function launchCLI(options: Options): Promise<void>;
12
+ export {};
@@ -0,0 +1,29 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ /**
3
+ * Launches the CLI through our custom OCLIF loader.
4
+ *
5
+ * @param options - Options.
6
+ * @returns A promise that resolves when the CLI has been launched.
7
+ */
8
+ export async function launchCLI(options) {
9
+ const { errorHandler } = await import('./error-handler.js');
10
+ const { isDevelopment } = await import('./context/local.js');
11
+ const oclif = await import('@oclif/core');
12
+ const { ShopifyConfig } = await import('./custom-oclif-loader.js');
13
+ if (isDevelopment()) {
14
+ oclif.default.settings.debug = true;
15
+ }
16
+ try {
17
+ // Use a custom OCLIF config to customize the behavior of the CLI
18
+ const config = new ShopifyConfig({ root: fileURLToPath(options.moduleURL) });
19
+ await config.load();
20
+ await oclif.default.run(options.argv, config);
21
+ await oclif.default.flush();
22
+ // eslint-disable-next-line no-catch-all/no-catch-all
23
+ }
24
+ catch (error) {
25
+ await errorHandler(error);
26
+ return oclif.default.Errors.handle(error);
27
+ }
28
+ }
29
+ //# sourceMappingURL=cli-launcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-launcher.js","sourceRoot":"","sources":["../../../src/public/node/cli-launcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAOtC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAgB;IAC9C,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACzD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC1D,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IACzC,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAA;IAEhE,IAAI,aAAa,EAAE,EAAE;QACnB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACpC;IAED,IAAI;QACF,iEAAiE;QACjE,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,EAAC,CAAC,CAAA;QAC1E,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;QAEnB,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7C,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAC3B,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,CAAC,KAAc,CAAC,CAAA;QAClC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAc,CAAC,CAAA;KACnD;AACH,CAAC","sourcesContent":["import {fileURLToPath} from 'node:url'\n\ninterface Options {\n moduleURL: string\n argv?: string[]\n}\n\n/**\n * Launches the CLI through our custom OCLIF loader.\n *\n * @param options - Options.\n * @returns A promise that resolves when the CLI has been launched.\n */\nexport async function launchCLI(options: Options): Promise<void> {\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('./context/local.js')\n const oclif = await import('@oclif/core')\n const {ShopifyConfig} = await import('./custom-oclif-loader.js')\n\n if (isDevelopment()) {\n oclif.default.settings.debug = true\n }\n\n try {\n // Use a custom OCLIF config to customize the behavior of the CLI\n const config = new ShopifyConfig({root: fileURLToPath(options.moduleURL)})\n await config.load()\n\n await oclif.default.run(options.argv, config)\n await oclif.default.flush()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n await errorHandler(error as Error)\n return oclif.default.Errors.handle(error as Error)\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  /**
2
3
  * IMPORTANT NOTE: Imports in this module are dynamic to ensure that "setupEnvironmentVariables" can dynamically
3
4
  * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules
@@ -13,19 +14,17 @@ interface RunCLIOptions {
13
14
  * a CLI
14
15
  * @param options - Options.
15
16
  */
16
- export declare function runCLI(options: RunCLIOptions): Promise<void>;
17
+ export declare function runCLI(options: RunCLIOptions & {
18
+ runInCreateMode?: boolean;
19
+ }, launchCLI: (options: {
20
+ moduleURL: string;
21
+ }) => Promise<void>, argv?: string[], env?: NodeJS.ProcessEnv, versions?: NodeJS.ProcessVersions): Promise<void>;
17
22
  /**
18
23
  * A function for create-x CLIs that automatically runs the "init" command.
19
24
  */
20
- export declare function runCreateCLI(options: RunCLIOptions): Promise<void>;
21
- export declare function useLocalCLIIfDetected(filepath: string): Promise<boolean>;
22
- interface CliPackageInfo {
23
- path: string;
24
- bin: {
25
- shopify: string;
26
- };
27
- }
28
- export declare function localCliPackage(): Promise<CliPackageInfo | undefined>;
25
+ export declare function runCreateCLI(options: RunCLIOptions, launchCLI: (options: {
26
+ moduleURL: string;
27
+ }) => Promise<void>, argv?: string[], env?: NodeJS.ProcessEnv, versions?: NodeJS.ProcessVersions): Promise<void>;
29
28
  /**
30
29
  * An object that contains the flags that
31
30
  * are shared across all the commands.
@@ -34,6 +33,9 @@ export declare const globalFlags: {
34
33
  'no-color': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
35
34
  verbose: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
36
35
  };
36
+ export declare const jsonFlag: {
37
+ json: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
38
+ };
37
39
  /**
38
40
  * Clear the CLI cache, used to store some API responses and handle notifications status
39
41
  */
@@ -1,10 +1,9 @@
1
1
  import { isTruthy } from './context/utilities.js';
2
- import { printEventsJson } from '../../private/node/demo-recorder.js';
3
2
  import { cacheClear } from '../../private/node/conf-store.js';
3
+ import { environmentVariables } from '../../private/node/constants.js';
4
4
  import { Flags } from '@oclif/core';
5
- import { fileURLToPath } from 'url';
6
- async function warnIfOldNodeVersion() {
7
- const nodeVersion = process.versions.node;
5
+ async function warnIfOldNodeVersion(versions = process.versions) {
6
+ const nodeVersion = versions.node;
8
7
  const nodeMajorVersion = Number(nodeVersion.split('.')[0]);
9
8
  const currentSupportedNodeVersion = 18;
10
9
  if (nodeMajorVersion < currentSupportedNodeVersion) {
@@ -25,25 +24,25 @@ async function warnIfOldNodeVersion() {
25
24
  });
26
25
  }
27
26
  }
28
- function setupEnvironmentVariables(options) {
27
+ function setupEnvironmentVariables(options, argv = process.argv, env = process.env) {
29
28
  /**
30
29
  * By setting DEBUG=* when --verbose is passed we are increasing the
31
30
  * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)
32
31
  * for logging, and it's configured through the DEBUG= environment variable.
33
32
  */
34
- if (process.argv.includes('--verbose')) {
35
- process.env.DEBUG = process.env.DEBUG ?? '*';
33
+ if (argv.includes('--verbose')) {
34
+ env.DEBUG = env.DEBUG ?? '*';
36
35
  }
37
36
  if (options.development) {
38
- process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development';
37
+ env.SHOPIFY_CLI_ENV = env.SHOPIFY_CLI_ENV ?? 'development';
39
38
  }
40
39
  }
41
- function forceNoColor() {
42
- if (process.argv.includes('--no-color') ||
43
- isTruthy(process.env.NO_COLOR) ||
44
- isTruthy(process.env.SHOPIFY_FLAG_NO_COLOR) ||
45
- process.env.TERM === 'dumb') {
46
- process.env.FORCE_COLOR = '0';
40
+ function forceNoColor(argv = process.argv, env = process.env) {
41
+ if (argv.includes('--no-color') ||
42
+ isTruthy(env.NO_COLOR) ||
43
+ isTruthy(env.SHOPIFY_FLAG_NO_COLOR) ||
44
+ env.TERM === 'dumb') {
45
+ env.FORCE_COLOR = '0';
47
46
  }
48
47
  }
49
48
  /**
@@ -51,103 +50,33 @@ function forceNoColor() {
51
50
  * a CLI
52
51
  * @param options - Options.
53
52
  */
54
- export async function runCLI(options) {
55
- setupEnvironmentVariables(options);
56
- forceNoColor();
57
- await warnIfOldNodeVersion();
58
- /**
59
- * These imports need to be dynamic because if they are static
60
- * they are loaded before we set the DEBUG=* environment variable
61
- * and therefore it has no effect.
62
- */
63
- const { errorHandler } = await import('./error-handler.js');
64
- const { isDevelopment } = await import('./context/local.js');
65
- const oclif = await import('@oclif/core');
66
- const { ShopifyConfig } = await import('./custom-oclif-loader.js');
67
- if (isDevelopment()) {
68
- oclif.default.settings.debug = true;
69
- }
70
- try {
71
- // Use a custom OCLIF config to customize the behavior of the CLI
72
- const config = new ShopifyConfig({ root: fileURLToPath(options.moduleURL) });
73
- await config.load();
74
- await oclif.default.run(undefined, config);
75
- await oclif.default.flush();
76
- printEventsJson();
77
- // eslint-disable-next-line no-catch-all/no-catch-all
78
- }
79
- catch (error) {
80
- await errorHandler(error);
81
- return oclif.default.Errors.handle(error);
53
+ export async function runCLI(options, launchCLI, argv = process.argv, env = process.env, versions = process.versions) {
54
+ setupEnvironmentVariables(options, argv, env);
55
+ if (options.runInCreateMode) {
56
+ await addInitToArgvWhenRunningCreateCLI(options, argv);
82
57
  }
58
+ forceNoColor(argv, env);
59
+ await warnIfOldNodeVersion(versions);
60
+ return launchCLI({ moduleURL: options.moduleURL });
83
61
  }
84
- /**
85
- * A function for create-x CLIs that automatically runs the "init" command.
86
- */
87
- export async function runCreateCLI(options) {
88
- setupEnvironmentVariables(options);
62
+ async function addInitToArgvWhenRunningCreateCLI(options, argv = process.argv) {
89
63
  const { findUpAndReadPackageJson } = await import('./node-package-manager.js');
90
64
  const { moduleDirectory } = await import('./path.js');
91
65
  const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL));
92
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
67
  const packageName = packageJson.content.name;
94
68
  const name = packageName.replace('@shopify/create-', '');
95
- const initIndex = process.argv.findIndex((arg) => arg.includes('init'));
69
+ const initIndex = argv.findIndex((arg) => arg.includes('init'));
96
70
  if (initIndex === -1) {
97
- const initIndex = process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${name}|dev|run)`))) + 1;
98
- process.argv.splice(initIndex, 0, 'init');
71
+ const initIndex = argv.findIndex((arg) => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${name}|dev|run)`))) + 1;
72
+ argv.splice(initIndex, 0, 'init');
99
73
  }
100
- await runCLI(options);
101
74
  }
102
- export async function useLocalCLIIfDetected(filepath) {
103
- const { environmentVariables } = await import('../../private/node/constants.js');
104
- const { joinPath: join } = await import('./path.js');
105
- const { exec } = await import('./system.js');
106
- // Temporary flag while we test out this feature and ensure it won't break anything!
107
- if (!isTruthy(process.env[environmentVariables.enableCliRedirect]))
108
- return false;
109
- // Setting an env variable in the child process prevents accidental recursion.
110
- if (isTruthy(process.env[environmentVariables.skipCliRedirect]))
111
- return false;
112
- // If already running via package manager, we can assume it's running correctly already.
113
- if (process.env.npm_config_user_agent)
114
- return false;
115
- const cliPackage = await localCliPackage();
116
- if (!cliPackage)
117
- return false;
118
- const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify);
119
- if (correctExecutablePath === filepath)
120
- return false;
121
- try {
122
- await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {
123
- stdio: 'inherit',
124
- env: { [environmentVariables.skipCliRedirect]: '1' },
125
- });
126
- // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any
127
- }
128
- catch (processError) {
129
- process.exit(processError.exitCode);
130
- }
131
- return true;
132
- }
133
- export async function localCliPackage() {
134
- const { captureOutput } = await import('./system.js');
135
- let npmListOutput = '';
136
- let localShopifyCLI = {};
137
- try {
138
- npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l']);
139
- localShopifyCLI = JSON.parse(npmListOutput);
140
- // eslint-disable-next-line no-catch-all/no-catch-all
141
- }
142
- catch (err) {
143
- return;
144
- }
145
- const dependenciesList = {
146
- ...localShopifyCLI.peerDependencies,
147
- ...localShopifyCLI.devDependencies,
148
- ...localShopifyCLI.dependencies,
149
- };
150
- return dependenciesList['@shopify/cli'];
75
+ /**
76
+ * A function for create-x CLIs that automatically runs the "init" command.
77
+ */
78
+ export async function runCreateCLI(options, launchCLI, argv = process.argv, env = process.env, versions = process.versions) {
79
+ return runCLI({ ...options, runInCreateMode: true }, launchCLI, argv, env, versions);
151
80
  }
152
81
  /**
153
82
  * An object that contains the flags that
@@ -165,6 +94,15 @@ export const globalFlags = {
165
94
  env: 'SHOPIFY_FLAG_VERBOSE',
166
95
  }),
167
96
  };
97
+ export const jsonFlag = {
98
+ json: Flags.boolean({
99
+ char: 'j',
100
+ description: 'Output the result as JSON.',
101
+ hidden: false,
102
+ default: false,
103
+ env: environmentVariables.json,
104
+ }),
105
+ };
168
106
  /**
169
107
  * Clear the CLI cache, used to store some API responses and handle notifications status
170
108
  */
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC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AAG,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,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC;QACxB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,uBAAuB;QACpC,GAAG,EAAE,uBAAuB;KAC7B,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,uCAAuC;QACpD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,UAAU,EAAE,CAAA;AACd,CAAC","sourcesContent":["import {isTruthy} from './context/utilities.js'\nimport {printEventsJson} from '../../private/node/demo-recorder.js'\nimport {cacheClear} from '../../private/node/conf-store.js'\nimport {Flags} from '@oclif/core'\nimport {fileURLToPath} from 'url'\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\nasync function warnIfOldNodeVersion() {\n const nodeVersion = process.versions.node\n const nodeMajorVersion = Number(nodeVersion.split('.')[0])\n\n const currentSupportedNodeVersion = 18\n if (nodeMajorVersion < currentSupportedNodeVersion) {\n const {renderWarning} = await import('./ui.js')\n renderWarning({\n headline: 'Upgrade to a supported Node version now.',\n body: [\n `Node ${nodeMajorVersion} has reached end-of-life and poses security risks. When you upgrade to a`,\n {\n link: {\n url: 'https://nodejs.dev/en/about/previous-releases',\n label: 'supported version',\n },\n },\n {char: ','},\n \"you'll be able to use Shopify CLI without interruption.\",\n ],\n })\n }\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\nfunction forceNoColor() {\n if (\n process.argv.includes('--no-color') ||\n isTruthy(process.env.NO_COLOR) ||\n isTruthy(process.env.SHOPIFY_FLAG_NO_COLOR) ||\n process.env.TERM === 'dumb'\n ) {\n process.env.FORCE_COLOR = '0'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n forceNoColor()\n await warnIfOldNodeVersion()\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('./context/local.js')\n const oclif = await import('@oclif/core')\n const {ShopifyConfig} = await import('./custom-oclif-loader.js')\n\n if (isDevelopment()) {\n oclif.default.settings.debug = true\n }\n\n try {\n // Use a custom OCLIF config to customize the behavior of the CLI\n const config = new ShopifyConfig({root: fileURLToPath(options.moduleURL)})\n await config.load()\n\n await oclif.default.run(undefined, config)\n await oclif.default.flush()\n printEventsJson()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n await errorHandler(error as Error)\n return oclif.default.Errors.handle(error as Error)\n }\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 {environmentVariables} = await import('../../private/node/constants.js')\n const {joinPath: 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 'no-color': Flags.boolean({\n hidden: false,\n description: 'Disable color output.',\n env: 'SHOPIFY_FLAG_NO_COLOR',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the output.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\n/**\n * Clear the CLI cache, used to store some API responses and handle notifications status\n */\nexport function clearCache(): void {\n cacheClear()\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAA;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AAajC,KAAK,UAAU,oBAAoB,CAAC,WAAmC,OAAO,CAAC,QAAQ;IACrF,MAAM,WAAW,GAAG,QAAQ,CAAC,IAA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AE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,yBAAyB,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAC9G,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;KAClC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAsB,EACtB,SAA0D,EAC1D,OAAiB,OAAO,CAAC,IAAI,EAC7B,MAAyB,OAAO,CAAC,GAAG,EACpC,WAAmC,OAAO,CAAC,QAAQ;IAEnD,OAAO,MAAM,CAAC,EAAC,GAAG,OAAO,EAAE,eAAe,EAAE,IAAI,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;AACpF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC;QACxB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,uBAAuB;QACpC,GAAG,EAAE,uBAAuB;KAC7B,CAAC;IACF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,uCAAuC;QACpD,GAAG,EAAE,sBAAsB;KAC5B,CAAC;CACH,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC;QAClB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,4BAA4B;QACzC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,GAAG,EAAE,oBAAoB,CAAC,IAAI;KAC/B,CAAC;CACH,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,UAAU,EAAE,CAAA;AACd,CAAC","sourcesContent":["import {isTruthy} from './context/utilities.js'\nimport {cacheClear} from '../../private/node/conf-store.js'\nimport {environmentVariables} from '../../private/node/constants.js'\nimport {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\nasync function warnIfOldNodeVersion(versions: NodeJS.ProcessVersions = process.versions) {\n const nodeVersion = versions.node\n const nodeMajorVersion = Number(nodeVersion.split('.')[0])\n\n const currentSupportedNodeVersion = 18\n if (nodeMajorVersion < currentSupportedNodeVersion) {\n const {renderWarning} = await import('./ui.js')\n renderWarning({\n headline: 'Upgrade to a supported Node version now.',\n body: [\n `Node ${nodeMajorVersion} has reached end-of-life and poses security risks. When you upgrade to a`,\n {\n link: {\n url: 'https://nodejs.dev/en/about/previous-releases',\n label: 'supported version',\n },\n },\n {char: ','},\n \"you'll be able to use Shopify CLI without interruption.\",\n ],\n })\n }\n}\n\nfunction setupEnvironmentVariables(\n options: Pick<RunCLIOptions, 'development'>,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (argv.includes('--verbose')) {\n env.DEBUG = env.DEBUG ?? '*'\n }\n if (options.development) {\n env.SHOPIFY_CLI_ENV = env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\nfunction forceNoColor(argv: string[] = process.argv, env: NodeJS.ProcessEnv = process.env) {\n if (\n argv.includes('--no-color') ||\n isTruthy(env.NO_COLOR) ||\n isTruthy(env.SHOPIFY_FLAG_NO_COLOR) ||\n env.TERM === 'dumb'\n ) {\n env.FORCE_COLOR = '0'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(\n options: RunCLIOptions & {runInCreateMode?: boolean},\n launchCLI: (options: {moduleURL: string}) => Promise<void>,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n setupEnvironmentVariables(options, argv, env)\n if (options.runInCreateMode) {\n await addInitToArgvWhenRunningCreateCLI(options, argv)\n }\n forceNoColor(argv, env)\n await warnIfOldNodeVersion(versions)\n return launchCLI({moduleURL: options.moduleURL})\n}\n\nasync function addInitToArgvWhenRunningCreateCLI(\n options: Pick<RunCLIOptions, 'moduleURL'>,\n argv: string[] = process.argv,\n): Promise<void> {\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('./path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex = argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n argv.splice(initIndex, 0, 'init')\n }\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(\n options: RunCLIOptions,\n launchCLI: (options: {moduleURL: string}) => Promise<void>,\n argv: string[] = process.argv,\n env: NodeJS.ProcessEnv = process.env,\n versions: NodeJS.ProcessVersions = process.versions,\n): Promise<void> {\n return runCLI({...options, runInCreateMode: true}, launchCLI, argv, env, versions)\n}\n\n/**\n * An object that contains the flags that\n * are shared across all the commands.\n */\nexport const globalFlags = {\n 'no-color': Flags.boolean({\n hidden: false,\n description: 'Disable color output.',\n env: 'SHOPIFY_FLAG_NO_COLOR',\n }),\n verbose: Flags.boolean({\n hidden: false,\n description: 'Increase the verbosity of the output.',\n env: 'SHOPIFY_FLAG_VERBOSE',\n }),\n}\n\nexport const jsonFlag = {\n json: Flags.boolean({\n char: 'j',\n description: 'Output the result as JSON.',\n hidden: false,\n default: false,\n env: environmentVariables.json,\n }),\n}\n\n/**\n * Clear the CLI cache, used to store some API responses and handle notifications status\n */\nexport function clearCache(): void {\n cacheClear()\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { spinFqdn } from './spin.js';
2
2
  import { AbortError } from '../error.js';
3
3
  import { serviceEnvironment } from '../../../private/node/context/service.js';
4
+ import { DevServer, DevServerCore } from '../vendor/dev_server/DevServer.js';
4
5
  export const CouldntObtainPartnersSpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.");
5
6
  export const CouldntObtainIdentitySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.");
6
7
  export const CouldntObtainShopifySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.");
@@ -15,7 +16,7 @@ export async function partnersFqdn() {
15
16
  const productionFqdn = 'partners.shopify.com';
16
17
  switch (environment) {
17
18
  case 'local':
18
- return 'partners.myshopify.io';
19
+ return new DevServer('partners').host();
19
20
  case 'spin':
20
21
  return `partners.${await spinFqdn()}`;
21
22
  default:
@@ -32,7 +33,7 @@ export async function appManagementFqdn() {
32
33
  const productionFqdn = 'app.shopify.com';
33
34
  switch (environment) {
34
35
  case 'local':
35
- return 'app.shopify.myshopify.io';
36
+ return new DevServerCore().host('app');
36
37
  case 'spin':
37
38
  return `app.shopify.${await spinFqdn()}`;
38
39
  default:
@@ -49,7 +50,7 @@ export async function developerDashboardFqdn() {
49
50
  const productionFqdn = 'dev.shopify.com';
50
51
  switch (environment) {
51
52
  case 'local':
52
- return 'dev.shopify.myshopify.io';
53
+ return new DevServerCore().host('dev');
53
54
  case 'spin':
54
55
  return `dev.shopify.${await spinFqdn()}`;
55
56
  default:
@@ -66,7 +67,7 @@ export async function businessPlatformFqdn() {
66
67
  const productionFqdn = 'destinations.shopifysvc.com';
67
68
  switch (environment) {
68
69
  case 'local':
69
- return 'business-platform.myshopify.io';
70
+ return new DevServer('business-platform').host();
70
71
  case 'spin':
71
72
  return `business-platform.${await spinFqdn()}`;
72
73
  default:
@@ -83,7 +84,7 @@ export async function identityFqdn() {
83
84
  const productionFqdn = 'accounts.shopify.com';
84
85
  switch (environment) {
85
86
  case 'local':
86
- return 'identity.myshopify.io';
87
+ return new DevServer('identity').host();
87
88
  case 'spin':
88
89
  return `identity.${await spinFqdn()}`;
89
90
  default:
@@ -103,14 +104,17 @@ export async function normalizeStoreFqdn(store) {
103
104
  const addDomain = async (storeFqdn) => {
104
105
  switch (serviceEnvironment()) {
105
106
  case 'local':
106
- return `${storeFqdn}.myshopify.io`;
107
+ return new DevServerCore().host(storeFqdn);
107
108
  case 'spin':
108
109
  return `${storeFqdn}.shopify.${await spinFqdn()}`;
109
110
  default:
110
111
  return `${storeFqdn}.myshopify.com`;
111
112
  }
112
113
  };
113
- const containDomain = (storeFqdn) => storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev') || storeFqdn.includes('shopify.io');
114
+ const containDomain = (storeFqdn) => storeFqdn.includes('.myshopify.com') ||
115
+ storeFqdn.includes('spin.dev') ||
116
+ storeFqdn.includes('shopify.io') ||
117
+ storeFqdn.includes('.shop.dev');
114
118
  return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
115
119
  }
116
120
  //# sourceMappingURL=fqdn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/context/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AAE3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,UAAU,CAC9D,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,kCAAkC,GAAG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AC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {spinFqdn} from './spin.js'\nimport {AbortError} from '../error.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new AbortError(\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 App Management API service we should interact with.\n *\n * @returns Fully-qualified domain of the App Management service we should interact with.\n */\nexport async function appManagementFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'app.shopify.com'\n switch (environment) {\n case 'local':\n return 'app.shopify.myshopify.io'\n case 'spin':\n return `app.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Developer Dashboard domain we should interact with.\n *\n * @returns Fully-qualified domain of the Developer Dashboard we should interact with.\n */\nexport async function developerDashboardFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'dev.shopify.com'\n switch (environment) {\n case 'local':\n return 'dev.shopify.myshopify.io'\n case 'spin':\n return `dev.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the BusinessPlatform' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function businessPlatformFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'destinations.shopifysvc.com'\n switch (environment) {\n case 'local':\n return 'business-platform.myshopify.io'\n case 'spin':\n return `business-platform.${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 switch (serviceEnvironment()) {\n case 'local':\n return `${storeFqdn}.myshopify.io`\n case 'spin':\n return `${storeFqdn}.shopify.${await spinFqdn()}`\n default:\n return `${storeFqdn}.myshopify.com`\n }\n }\n const containDomain = (storeFqdn: string) =>\n storeFqdn.includes('.myshopify.com') || storeFqdn.includes('spin.dev') || storeFqdn.includes('shopify.io')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
1
+ {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/context/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CA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BACV,OAAO,IAAI,aAAa,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC5C,KAAK,MAAM;gBACT,OAAO,GAAG,SAAS,YAAY,MAAM,QAAQ,EAAE,EAAE,CAAA;YACnD;gBACE,OAAO,GAAG,SAAS,gBAAgB,CAAA;SACtC;IACH,CAAC,CAAA;IACD,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE,CAC1C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACpC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC9B,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC;QAChC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACjC,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {spinFqdn} from './spin.js'\nimport {AbortError} from '../error.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\nimport {DevServer, DevServerCore} from '../vendor/dev_server/DevServer.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new AbortError(\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 new DevServer('partners').host()\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the App Management API service we should interact with.\n *\n * @returns Fully-qualified domain of the App Management service we should interact with.\n */\nexport async function appManagementFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'app.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServerCore().host('app')\n case 'spin':\n return `app.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Developer Dashboard domain we should interact with.\n *\n * @returns Fully-qualified domain of the Developer Dashboard we should interact with.\n */\nexport async function developerDashboardFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'dev.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServerCore().host('dev')\n case 'spin':\n return `dev.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the BusinessPlatform' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function businessPlatformFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'destinations.shopifysvc.com'\n switch (environment) {\n case 'local':\n return new DevServer('business-platform').host()\n case 'spin':\n return `business-platform.${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 new DevServer('identity').host()\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 switch (serviceEnvironment()) {\n case 'local':\n return new DevServerCore().host(storeFqdn)\n case 'spin':\n return `${storeFqdn}.shopify.${await spinFqdn()}`\n default:\n return `${storeFqdn}.myshopify.com`\n }\n }\n const containDomain = (storeFqdn: string) =>\n storeFqdn.includes('.myshopify.com') ||\n storeFqdn.includes('spin.dev') ||\n storeFqdn.includes('shopify.io') ||\n storeFqdn.includes('.shop.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
@@ -26,6 +26,13 @@ export declare function isDevelopment(env?: NodeJS.ProcessEnv): boolean;
26
26
  * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
27
27
  */
28
28
  export declare function isVerbose(env?: NodeJS.ProcessEnv): boolean;
29
+ /**
30
+ * It returns true if the App Management API is available.
31
+ *
32
+ * @param env - The environment variables from the environment of the current process.
33
+ * @returns True if the App Management API is available.
34
+ */
35
+ export declare function isAppManagementEnabled(env?: NodeJS.ProcessEnv): boolean;
29
36
  /**
30
37
  * Returns true if the environment in which the CLI is running is either
31
38
  * a local environment (where dev is present) or a cloud environment (spin).
@@ -41,6 +41,15 @@ export function isDevelopment(env = process.env) {
41
41
  export function isVerbose(env = process.env) {
42
42
  return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose');
43
43
  }
44
+ /**
45
+ * It returns true if the App Management API is available.
46
+ *
47
+ * @param env - The environment variables from the environment of the current process.
48
+ * @returns True if the App Management API is available.
49
+ */
50
+ export function isAppManagementEnabled(env = process.env) {
51
+ return isTruthy(env[environmentVariables.useAppManagement]);
52
+ }
44
53
  /**
45
54
  * Returns true if the environment in which the CLI is running is either
46
55
  * a local environment (where dev is present) or a cloud environment (spin).
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAA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AI;YACJ,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAA;KACF;SAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QACjC,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC;SACtC,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE;QAC5C,OAAO,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KACzC;IACD,OAAO,iDAAiD,CAAA;AAC1D,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.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 *\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[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.noThemeBundling])\n}\n\n/**\n * Returns true if the embedded CLI will be used for theme commands.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_BUNDLED_THEME_CLI is truthy.\n */\nexport function useEmbeddedThemeCLI(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.bundledThemeCLI])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await 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 *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string | undefined {\n if (isSet(env[environmentVariables.otelURL])) {\n return env[environmentVariables.otelURL]\n }\n return 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACtF,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3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IG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,IAAI,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE;QAC5C,OAAO,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KACzC;IACD,OAAO,iDAAiD,CAAA;AAC1D,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * It returns true if the App Management API is available.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the App Management API is available.\n */\nexport function isAppManagementEnabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.useAppManagement])\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 *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.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 *\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[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.noThemeBundling])\n}\n\n/**\n * Returns true if the embedded CLI will be used for theme commands.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_BUNDLED_THEME_CLI is truthy.\n */\nexport function useEmbeddedThemeCLI(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.bundledThemeCLI])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await 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 *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string | undefined {\n if (isSet(env[environmentVariables.otelURL])) {\n return env[environmentVariables.otelURL]\n }\n return 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
@@ -44,3 +44,10 @@ export declare function getIdentityTokenInformation(): {
44
44
  refreshToken: string;
45
45
  userId: string;
46
46
  } | undefined;
47
+ /**
48
+ * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).
49
+ *
50
+ * @param environment - Process environment variables.
51
+ * @returns True if the JSON output is enabled, false otherwise.
52
+ */
53
+ export declare function jsonOutputEnabled(environment?: NodeJS.ProcessEnv): boolean;
@@ -1,4 +1,6 @@
1
1
  import { nonRandomUUID } from './crypto.js';
2
+ import { isTruthy } from './context/utilities.js';
3
+ import { sniffForJson } from './path.js';
2
4
  import { environmentVariables, systemEnvironmentVariables } from '../../private/node/constants.js';
3
5
  /**
4
6
  * It returns the environment variables of the environment
@@ -65,4 +67,13 @@ export function getIdentityTokenInformation() {
65
67
  userId: nonRandomUUID(identityToken),
66
68
  };
67
69
  }
70
+ /**
71
+ * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).
72
+ *
73
+ * @param environment - Process environment variables.
74
+ * @returns True if the JSON output is enabled, false otherwise.
75
+ */
76
+ export function jsonOutputEnabled(environment = getEnvironmentVariables()) {
77
+ return sniffForJson() || isTruthy(environment[environmentVariables.json]);
78
+ }
68
79
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js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AACH,CAAC","sourcesContent":["import {nonRandomUUID} from './crypto.js'\nimport {environmentVariables, systemEnvironmentVariables} from '../../private/node/constants.js'\n\n/**\n * It returns the environment variables of the environment\n * where the Node process is running.\n *\n * This function exists to prevent the access of the process\n * global variable which is discouraged via the no-process-env\n * ESLint rule.\n *\n * @returns Current process environment variables.\n */\nexport function getEnvironmentVariables(): NodeJS.ProcessEnv {\n return process.env\n}\n\n/**\n * Returns the value of the SHOPIFY_CLI_PARTNERS_TOKEN environment variable.\n *\n * @returns Current process environment variables.\n */\nexport function getPartnersToken(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.partnersToken]\n}\n\n/**\n * Check if the current proccess is running using the partners token.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function usePartnersToken(): boolean {\n return getPartnersToken() !== undefined\n}\n\n/**\n * Returns the value of the organization id from the environment variables.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function getOrganization(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.organization]\n}\n\n/**\n * Return the backend port value.\n *\n * @returns The port as a number. Undefined otherwise.\n */\nexport function getBackendPort(): number | undefined {\n const backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort]\n if (backendPort && !isNaN(Number(backendPort))) {\n return Number(backendPort)\n }\n return undefined\n}\n\n/**\n * Returns the information of the identity & refresh tokens, provided by environment variables.\n *\n * @returns The identity token information in case it exists.\n */\nexport function getIdentityTokenInformation(): {accessToken: string; refreshToken: string; userId: string} | undefined {\n const identityToken = getEnvironmentVariables()[environmentVariables.identityToken]\n const refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken]\n if (!identityToken || !refreshToken) return undefined\n return {\n accessToken: identityToken,\n refreshToken,\n userId: nonRandomUUID(identityToken),\n }\n}\n"]}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/public/node/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,QA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;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAW,GAAG,uBAAuB,EAAE;IACvE,OAAO,YAAY,EAAE,IAAI,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;AAC3E,CAAC","sourcesContent":["import {nonRandomUUID} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {sniffForJson} from './path.js'\nimport {environmentVariables, systemEnvironmentVariables} from '../../private/node/constants.js'\n\n/**\n * It returns the environment variables of the environment\n * where the Node process is running.\n *\n * This function exists to prevent the access of the process\n * global variable which is discouraged via the no-process-env\n * ESLint rule.\n *\n * @returns Current process environment variables.\n */\nexport function getEnvironmentVariables(): NodeJS.ProcessEnv {\n return process.env\n}\n\n/**\n * Returns the value of the SHOPIFY_CLI_PARTNERS_TOKEN environment variable.\n *\n * @returns Current process environment variables.\n */\nexport function getPartnersToken(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.partnersToken]\n}\n\n/**\n * Check if the current proccess is running using the partners token.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function usePartnersToken(): boolean {\n return getPartnersToken() !== undefined\n}\n\n/**\n * Returns the value of the organization id from the environment variables.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function getOrganization(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.organization]\n}\n\n/**\n * Return the backend port value.\n *\n * @returns The port as a number. Undefined otherwise.\n */\nexport function getBackendPort(): number | undefined {\n const backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort]\n if (backendPort && !isNaN(Number(backendPort))) {\n return Number(backendPort)\n }\n return undefined\n}\n\n/**\n * Returns the information of the identity & refresh tokens, provided by environment variables.\n *\n * @returns The identity token information in case it exists.\n */\nexport function getIdentityTokenInformation(): {accessToken: string; refreshToken: string; userId: string} | undefined {\n const identityToken = getEnvironmentVariables()[environmentVariables.identityToken]\n const refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken]\n if (!identityToken || !refreshToken) return undefined\n return {\n accessToken: identityToken,\n refreshToken,\n userId: nonRandomUUID(identityToken),\n }\n}\n\n/**\n * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).\n *\n * @param environment - Process environment variables.\n * @returns True if the JSON output is enabled, false otherwise.\n */\nexport function jsonOutputEnabled(environment = getEnvironmentVariables()): boolean {\n return sniffForJson() || isTruthy(environment[environmentVariables.json])\n}\n"]}