@shopify/create-app 3.70.0 → 3.71.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/{chunk-PNN7RS7Y.js → chunk-3NSN5Z4N.js} +100 -11
  2. package/dist/{chunk-MCWNOYSH.js → chunk-3VW6K5FB.js} +14 -19
  3. package/dist/{chunk-YQS36GWM.js → chunk-3XCGQAXK.js} +4 -6
  4. package/dist/{chunk-L7M22NDW.js → chunk-6WYZ3SZB.js} +2 -2
  5. package/dist/{chunk-2A7GNM7F.js → chunk-7F4XFNYI.js} +2 -2
  6. package/dist/{chunk-AZIUHI45.js → chunk-CQGOPQQH.js} +5 -5
  7. package/dist/{chunk-CWXZ7XAM.js → chunk-GRIQNZDW.js} +238 -36
  8. package/dist/{chunk-2IJ2KQU2.js → chunk-JLMBYXKI.js} +22965 -22766
  9. package/dist/{chunk-MX4RJDBM.js → chunk-KYB6A4PE.js} +1 -2
  10. package/dist/{chunk-4NI5A7A4.js → chunk-RPNIXREV.js} +5 -7
  11. package/dist/{chunk-64XEMSHA.js → chunk-XBBBOMWZ.js} +3 -3
  12. package/dist/{custom-oclif-loader-BSDHBJI5.js → custom-oclif-loader-APVSUKMR.js} +9 -11
  13. package/dist/{del-42HQA7PR.js → del-2FOJ63S7.js} +4 -4
  14. package/dist/{error-handler-JYEQI7TL.js → error-handler-JHT2GJHK.js} +11 -13
  15. package/dist/hooks/postrun.js +9 -11
  16. package/dist/hooks/prerun.js +9 -13
  17. package/dist/index.js +34325 -32252
  18. package/dist/index.test.js +120 -65
  19. package/dist/{lib-H5ZGVBFQ.js → lib-EGJUAXU5.js} +5 -5
  20. package/dist/{local-TH3U2SLS.js → local-7TFODKTC.js} +9 -9
  21. package/dist/{node-package-manager-BPA6G6YC.js → node-package-manager-VYFJFJTO.js} +8 -10
  22. package/dist/{out-ZDSLKX4N.js → out-MHEKZJWS.js} +2 -2
  23. package/dist/{path-G6AAF6UV.js → path-5SZGULBR.js} +2 -3
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/dist/{ui-RPO3BY7Q.js → ui-UKHR7I4C.js} +7 -9
  26. package/oclif.manifest.json +1 -1
  27. package/package.json +3 -3
  28. package/dist/chunk-BB6N2XSA.js +0 -112
  29. package/dist/chunk-IDT7CLPE.js +0 -116
  30. package/dist/constants-JHPIMZ2O.js +0 -26
  31. package/dist/system-B7E6HTDC.js +0 -27
@@ -12,7 +12,7 @@ import {
12
12
  removeSession,
13
13
  setCachedPartnerAccountStatus,
14
14
  setSession
15
- } from "./chunk-YQS36GWM.js";
15
+ } from "./chunk-3XCGQAXK.js";
16
16
  import {
17
17
  AbortError,
18
18
  BugError,
@@ -23,9 +23,11 @@ import {
23
23
  ciPlatform,
24
24
  cloudEnvironment,
25
25
  currentProcessIsGlobal,
26
+ environmentVariables,
26
27
  execa,
27
28
  firstPartyDev,
28
29
  import_ts_error,
30
+ isAppManagementEnabled,
29
31
  isCloudEnvironment,
30
32
  isSpin,
31
33
  isTTY,
@@ -41,19 +43,17 @@ import {
41
43
  outputWarn,
42
44
  runWithTimer,
43
45
  serviceEnvironment,
46
+ sessionConstants,
44
47
  spinFqdn,
45
48
  stringifyMessage,
46
- themeToken
47
- } from "./chunk-2IJ2KQU2.js";
48
- import {
49
- environmentVariables,
50
- sessionConstants,
51
49
  systemEnvironmentVariables,
52
- themeKitAccessDomain
53
- } from "./chunk-IDT7CLPE.js";
50
+ themeKitAccessDomain,
51
+ themeToken
52
+ } from "./chunk-JLMBYXKI.js";
54
53
  import {
55
- cwd
56
- } from "./chunk-BB6N2XSA.js";
54
+ cwd,
55
+ sniffForJson
56
+ } from "./chunk-3NSN5Z4N.js";
57
57
  import {
58
58
  __commonJS,
59
59
  __require,
@@ -61,6 +61,57 @@ import {
61
61
  init_cjs_shims
62
62
  } from "./chunk-POZ5MGPT.js";
63
63
 
64
+ // ../../node_modules/.pnpm/network-interfaces@1.1.0/node_modules/network-interfaces/index.js
65
+ var require_network_interfaces = __commonJS({
66
+ "../../node_modules/.pnpm/network-interfaces@1.1.0/node_modules/network-interfaces/index.js"(exports2) {
67
+ "use strict";
68
+ init_cjs_shims();
69
+ var os2 = __require("os");
70
+ function isValid2(address, options2) {
71
+ return !(typeof options2.internal == "boolean" && address.internal !== options2.internal || options2.ipVersion === 4 && address.family !== "IPv4" || options2.ipVersion === 6 && address.family !== "IPv6");
72
+ }
73
+ function findAddresses(interfaceName, options2 = {}) {
74
+ let addresses = os2.networkInterfaces()[interfaceName];
75
+ if (!addresses)
76
+ throw new Error(`Network interface "${interfaceName}" does not exist`);
77
+ let result = [];
78
+ for (let address of addresses)
79
+ isValid2(address, options2) && result.push(address);
80
+ return result;
81
+ }
82
+ exports2.toIp = function(interfaceName, options2) {
83
+ let addresses = findAddresses(interfaceName, options2);
84
+ if (addresses.length === 0)
85
+ throw new Error(`No suitable IP address found on interface "${interfaceName}"`);
86
+ return addresses[0].address;
87
+ };
88
+ exports2.toIps = function(interfaceName, options2) {
89
+ return findAddresses(interfaceName, options2).map((address) => address.address);
90
+ };
91
+ exports2.fromIp = function(ip, options2) {
92
+ let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces);
93
+ for (let interfaceName of interfaceNames)
94
+ for (let address of interfaces[interfaceName])
95
+ if (address.address === ip && isValid2(address, options2))
96
+ return interfaceName;
97
+ throw new Error(`No suitable interfaces were found with IP address "${ip}"`);
98
+ };
99
+ exports2.getInterface = function(options2) {
100
+ let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces);
101
+ for (let interfaceName of interfaceNames)
102
+ if (findAddresses(interfaceName, options2).length > 0)
103
+ return interfaceName;
104
+ throw new Error("No suitable interfaces were found");
105
+ };
106
+ exports2.getInterfaces = function(options2) {
107
+ let interfaces = os2.networkInterfaces(), interfaceNames = Object.keys(interfaces), result = [];
108
+ for (let interfaceName of interfaceNames)
109
+ findAddresses(interfaceName, options2).length > 0 && result.push(interfaceName);
110
+ return result;
111
+ };
112
+ }
113
+ });
114
+
64
115
  // ../../node_modules/.pnpm/extract-files@9.0.0/node_modules/extract-files/public/ReactNativeFile.js
65
116
  var require_ReactNativeFile = __commonJS({
66
117
  "../../node_modules/.pnpm/extract-files@9.0.0/node_modules/extract-files/public/ReactNativeFile.js"(exports2, module2) {
@@ -9100,7 +9151,7 @@ var require_populate = __commonJS({
9100
9151
  var require_form_data = __commonJS({
9101
9152
  "../../node_modules/.pnpm/form-data@3.0.1/node_modules/form-data/lib/form_data.js"(exports2, module2) {
9102
9153
  init_cjs_shims();
9103
- var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs = __require("fs"), mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate();
9154
+ var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs2 = __require("fs"), mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate();
9104
9155
  module2.exports = FormData4;
9105
9156
  util2.inherits(FormData4, CombinedStream);
9106
9157
  function FormData4(options2) {
@@ -9128,7 +9179,7 @@ var require_form_data = __commonJS({
9128
9179
  options2.knownLength != null ? valueLength += +options2.knownLength : Buffer.isBuffer(value) ? valueLength = value.length : typeof value == "string" && (valueLength = Buffer.byteLength(value)), this._valueLength += valueLength, this._overheadLength += Buffer.byteLength(header) + FormData4.LINE_BREAK.length, !(!value || !value.path && !(value.readable && value.hasOwnProperty("httpVersion"))) && (options2.knownLength || this._valuesToMeasure.push(value));
9129
9180
  };
9130
9181
  FormData4.prototype._lengthRetriever = function(value, callback) {
9131
- value.hasOwnProperty("fd") ? value.end != null && value.end != 1 / 0 && value.start != null ? callback(null, value.end + 1 - (value.start ? value.start : 0)) : fs.stat(value.path, function(err2, stat) {
9182
+ value.hasOwnProperty("fd") ? value.end != null && value.end != 1 / 0 && value.start != null ? callback(null, value.end + 1 - (value.start ? value.start : 0)) : fs2.stat(value.path, function(err2, stat) {
9132
9183
  var fileSize;
9133
9184
  if (err2) {
9134
9185
  callback(err2);
@@ -26686,7 +26737,7 @@ var require_populate2 = __commonJS({
26686
26737
  var require_form_data2 = __commonJS({
26687
26738
  "../../node_modules/.pnpm/form-data@4.0.0/node_modules/form-data/lib/form_data.js"(exports2, module2) {
26688
26739
  init_cjs_shims();
26689
- var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs = __require("fs"), Stream3 = __require("stream").Stream, mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate2();
26740
+ var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs2 = __require("fs"), Stream3 = __require("stream").Stream, mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate2();
26690
26741
  module2.exports = FormData4;
26691
26742
  util2.inherits(FormData4, CombinedStream);
26692
26743
  function FormData4(options2) {
@@ -26714,7 +26765,7 @@ var require_form_data2 = __commonJS({
26714
26765
  options2.knownLength != null ? valueLength += +options2.knownLength : Buffer.isBuffer(value) ? valueLength = value.length : typeof value == "string" && (valueLength = Buffer.byteLength(value)), this._valueLength += valueLength, this._overheadLength += Buffer.byteLength(header) + FormData4.LINE_BREAK.length, !(!value || !value.path && !(value.readable && value.hasOwnProperty("httpVersion")) && !(value instanceof Stream3)) && (options2.knownLength || this._valuesToMeasure.push(value));
26715
26766
  };
26716
26767
  FormData4.prototype._lengthRetriever = function(value, callback) {
26717
- value.hasOwnProperty("fd") ? value.end != null && value.end != 1 / 0 && value.start != null ? callback(null, value.end + 1 - (value.start ? value.start : 0)) : fs.stat(value.path, function(err2, stat) {
26768
+ value.hasOwnProperty("fd") ? value.end != null && value.end != 1 / 0 && value.start != null ? callback(null, value.end + 1 - (value.start ? value.start : 0)) : fs2.stat(value.path, function(err2, stat) {
26718
26769
  var fileSize;
26719
26770
  if (err2) {
26720
26771
  callback(err2);
@@ -29291,7 +29342,7 @@ var require_lib3 = __commonJS({
29291
29342
 
29292
29343
  // ../cli-kit/dist/public/common/version.js
29293
29344
  init_cjs_shims();
29294
- var CLI_KIT_VERSION = "3.70.0";
29345
+ var CLI_KIT_VERSION = "3.71.1";
29295
29346
 
29296
29347
  // ../cli-kit/dist/private/node/analytics.js
29297
29348
  init_cjs_shims();
@@ -32054,10 +32105,6 @@ function deepStrict(schema) {
32054
32105
  } else
32055
32106
  return schema instanceof ZodOptional ? deepStrict(schema._def.innerType).optional() : schema;
32056
32107
  }
32057
- function errorsToString(errors) {
32058
- return errors.map((error) => error.path.join(".").concat(": ").concat(error.message ?? "Unknow error")).join(`
32059
- `);
32060
- }
32061
32108
 
32062
32109
  // ../cli-kit/dist/private/node/session/schema.js
32063
32110
  var DateSchema = z.preprocess((arg) => typeof arg == "string" || arg instanceof Date ? new Date(arg) : null, z.date()), IdentityTokenSchema = z.object({
@@ -32092,12 +32139,148 @@ init_cjs_shims();
32092
32139
 
32093
32140
  // ../cli-kit/dist/public/node/context/fqdn.js
32094
32141
  init_cjs_shims();
32142
+
32143
+ // ../cli-kit/dist/public/node/vendor/dev_server/DevServer.js
32144
+ init_cjs_shims();
32145
+ var ni = __toESM(require_network_interfaces(), 1);
32146
+ import fs from "fs";
32147
+ import * as os from "os";
32148
+ import { execSync } from "child_process";
32149
+ var DevServerUtils = class _DevServerUtils {
32150
+ static assertConnectable(name, addr, port) {
32151
+ try {
32152
+ execSync(`nc -z -v -w 1 ${addr} ${port}`, {
32153
+ timeout: _DevServerUtils.CONNECT_TIMEOUT,
32154
+ stdio: "ignore"
32155
+ });
32156
+ } catch {
32157
+ throw new Error(`NET FAILED DevServer for '${name}' is not running on ${port} / ${addr}: \`dev up ${name}\` to start it.`);
32158
+ }
32159
+ }
32160
+ static inferenceModeAndProjectIsEdition2016(name) {
32161
+ try {
32162
+ fs.accessSync(_DevServerUtils.INFERENCE_MODE_SENTINEL);
32163
+ try {
32164
+ return fs.accessSync(`/opt/nginx/etc/manifest/${name}/current/edition-2024`), !1;
32165
+ } catch {
32166
+ return !0;
32167
+ }
32168
+ } catch {
32169
+ return !1;
32170
+ }
32171
+ }
32172
+ static getIpFromHosts(hostname) {
32173
+ try {
32174
+ let lines = fs.readFileSync(_DevServerUtils.HOSTS_FILE, "utf8").split(/\r?\n/);
32175
+ for (let line of lines) {
32176
+ let matches = /^\s*?([^#]+?)\s+([^#]+?)$/.exec(line);
32177
+ if (matches && matches.length === 3 && matches[2] === hostname)
32178
+ return matches[1];
32179
+ }
32180
+ } catch (error) {
32181
+ console.error("Error reading hosts file:", error);
32182
+ }
32183
+ throw new Error(`No IP found for hostname: ${hostname}`);
32184
+ }
32185
+ static getAddrPort2024(name) {
32186
+ try {
32187
+ let backendIp = _DevServerUtils.resolveBackendHost(name), interfaceName = ni.fromIp(backendIp, {
32188
+ internal: !0,
32189
+ ipVersion: 4
32190
+ });
32191
+ return [backendIp, _DevServerUtils.BACKEND_PORT];
32192
+ } catch {
32193
+ throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
32194
+ }
32195
+ }
32196
+ static getAddrPort2016(name) {
32197
+ try {
32198
+ let portContent = fs.readFileSync(`${os.homedir()}/.local/run/services/${name}/server/port`, "utf-8");
32199
+ return ["localhost", parseInt(portContent, 10)];
32200
+ } catch {
32201
+ throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
32202
+ }
32203
+ }
32204
+ static resolveBackendHost(name) {
32205
+ let host;
32206
+ try {
32207
+ host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);
32208
+ } catch {
32209
+ host = `${name}.root.shopify.dev.internal`;
32210
+ }
32211
+ try {
32212
+ return _DevServerUtils.getIpFromHosts(host);
32213
+ } catch {
32214
+ return host;
32215
+ }
32216
+ }
32217
+ };
32218
+ DevServerUtils.INFERENCE_MODE_SENTINEL = "/opt/dev/misc/dev-server-inference-mode";
32219
+ DevServerUtils.BACKEND_PORT = 8080;
32220
+ DevServerUtils.CONNECT_TIMEOUT = 100;
32221
+ DevServerUtils.HOSTS_FILE = "/etc/hosts";
32222
+ var DevServer = class {
32223
+ constructor(name) {
32224
+ if (!process.env.SPIN && !process.env.USING_DEV)
32225
+ throw new Error("DevServer is not supported in this environment");
32226
+ if (name === "shopify")
32227
+ throw new Error("Use DevServer.core for the 'shopify' project");
32228
+ this.name = name;
32229
+ }
32230
+ url({ nonstandardHostPrefix } = {}) {
32231
+ return `https://${this.host({ nonstandardHostPrefix })}`;
32232
+ }
32233
+ host({ nonstandardHostPrefix } = {}) {
32234
+ let prefix = nonstandardHostPrefix || this.name;
32235
+ if (process.env.SPIN === "1") {
32236
+ let services = fs.readdirSync("/run/ports2").filter((file) => file.endsWith(`--${this.name}`));
32237
+ if (services.length === 0)
32238
+ throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
32239
+ let match = new RegExp(`^(.+)${this.name}$`).exec(services[0]), organization = match ? match[1] : "";
32240
+ return `${organization !== "shopify--" ? `${organization}` : ""}${this.name}.${process.env.SPIN_FQDN}`;
32241
+ } else
32242
+ return DevServerUtils.inferenceModeAndProjectIsEdition2016(this.name) ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.shop.dev`);
32243
+ }
32244
+ assertRunningLocally2024() {
32245
+ let [addr, port] = DevServerUtils.getAddrPort2024(this.name);
32246
+ DevServerUtils.assertConnectable(this.name, addr, port);
32247
+ }
32248
+ assertRunningLocally2016() {
32249
+ let [addr, port] = DevServerUtils.getAddrPort2016(this.name);
32250
+ DevServerUtils.assertConnectable(this.name, addr, port);
32251
+ }
32252
+ }, DevServerCore = class {
32253
+ constructor() {
32254
+ this.name = "shopify";
32255
+ }
32256
+ url(prefix) {
32257
+ return `https://${this.host(prefix)}`;
32258
+ }
32259
+ host(prefix) {
32260
+ if (process.env.SPIN === "1") {
32261
+ if (!fs.readdirSync("/run/ports2").find((file) => file.endsWith(`--${this.name}`)))
32262
+ throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
32263
+ return `${prefix}.${this.name}.${process.env.SPIN_FQDN}`;
32264
+ } else
32265
+ return DevServerUtils.inferenceModeAndProjectIsEdition2016("shopify") ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.my.shop.dev`);
32266
+ }
32267
+ assertRunningLocally2024() {
32268
+ let [addr, port] = DevServerUtils.getAddrPort2024("shopify");
32269
+ DevServerUtils.assertConnectable("shopify", addr, port);
32270
+ }
32271
+ assertRunningLocally2016() {
32272
+ let [addr, port] = DevServerUtils.getAddrPort2016("shopify");
32273
+ DevServerUtils.assertConnectable("shopify", addr, port);
32274
+ }
32275
+ };
32276
+
32277
+ // ../cli-kit/dist/public/node/context/fqdn.js
32095
32278
  var CouldntObtainPartnersSpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment."), CouldntObtainIdentitySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment."), CouldntObtainShopifySpinFQDNError = new AbortError("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment."), NotProvidedStoreFQDNError = new AbortError("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
32096
32279
  async function partnersFqdn() {
32097
32280
  let environment = serviceEnvironment(), productionFqdn = "partners.shopify.com";
32098
32281
  switch (environment) {
32099
32282
  case "local":
32100
- return "partners.myshopify.io";
32283
+ return new DevServer("partners").host();
32101
32284
  case "spin":
32102
32285
  return `partners.${await spinFqdn()}`;
32103
32286
  default:
@@ -32108,7 +32291,7 @@ async function appManagementFqdn() {
32108
32291
  let environment = serviceEnvironment(), productionFqdn = "app.shopify.com";
32109
32292
  switch (environment) {
32110
32293
  case "local":
32111
- return "app.shopify.myshopify.io";
32294
+ return new DevServerCore().host("app");
32112
32295
  case "spin":
32113
32296
  return `app.shopify.${await spinFqdn()}`;
32114
32297
  default:
@@ -32119,7 +32302,7 @@ async function developerDashboardFqdn() {
32119
32302
  let environment = serviceEnvironment(), productionFqdn = "dev.shopify.com";
32120
32303
  switch (environment) {
32121
32304
  case "local":
32122
- return "dev.shopify.myshopify.io";
32305
+ return new DevServerCore().host("dev");
32123
32306
  case "spin":
32124
32307
  return `dev.shopify.${await spinFqdn()}`;
32125
32308
  default:
@@ -32130,7 +32313,7 @@ async function businessPlatformFqdn() {
32130
32313
  let environment = serviceEnvironment(), productionFqdn = "destinations.shopifysvc.com";
32131
32314
  switch (environment) {
32132
32315
  case "local":
32133
- return "business-platform.myshopify.io";
32316
+ return new DevServer("business-platform").host();
32134
32317
  case "spin":
32135
32318
  return `business-platform.${await spinFqdn()}`;
32136
32319
  default:
@@ -32141,7 +32324,7 @@ async function identityFqdn() {
32141
32324
  let environment = serviceEnvironment(), productionFqdn = "accounts.shopify.com";
32142
32325
  switch (environment) {
32143
32326
  case "local":
32144
- return "identity.myshopify.io";
32327
+ return new DevServer("identity").host();
32145
32328
  case "spin":
32146
32329
  return `identity.${await spinFqdn()}`;
32147
32330
  default:
@@ -32152,14 +32335,14 @@ async function normalizeStoreFqdn(store2) {
32152
32335
  let storeFqdn = store2.replace(/^https?:\/\//, "").replace(/\/$/, ""), addDomain = async (storeFqdn2) => {
32153
32336
  switch (serviceEnvironment()) {
32154
32337
  case "local":
32155
- return `${storeFqdn2}.myshopify.io`;
32338
+ return new DevServerCore().host(storeFqdn2);
32156
32339
  case "spin":
32157
32340
  return `${storeFqdn2}.shopify.${await spinFqdn()}`;
32158
32341
  default:
32159
32342
  return `${storeFqdn2}.myshopify.com`;
32160
32343
  }
32161
32344
  };
32162
- return ((storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev") || storeFqdn2.includes("shopify.io"))(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
32345
+ return ((storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev") || storeFqdn2.includes("shopify.io") || storeFqdn2.includes(".shop.dev"))(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
32163
32346
  }
32164
32347
 
32165
32348
  // ../cli-kit/dist/public/node/http.js
@@ -32642,7 +32825,16 @@ async function makeVerboseRequest({ request, url }) {
32642
32825
  requestId: responseHeaders["x-request-id"],
32643
32826
  delayMs
32644
32827
  };
32645
- }
32828
+ } else if (err2.response.status === 401)
32829
+ return {
32830
+ status: "unauthorized",
32831
+ clientError: err2,
32832
+ duration,
32833
+ sanitizedHeaders,
32834
+ sanitizedUrl,
32835
+ requestId: responseHeaders["x-request-id"],
32836
+ delayMs: 500
32837
+ };
32646
32838
  return {
32647
32839
  status: "client-error",
32648
32840
  clientError: err2,
@@ -32688,9 +32880,11 @@ ${result.sanitizedHeaders}
32688
32880
  throw errorHandler2 ? errorHandler2(result.error, result.requestId) : result.error;
32689
32881
  case "can-retry":
32690
32882
  throw errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32883
+ case "unauthorized":
32884
+ throw errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32691
32885
  }
32692
32886
  }
32693
- async function retryAwareRequest({ request, url }, errorHandler2, retryOptions = {
32887
+ async function retryAwareRequest({ request, url }, errorHandler2, unauthorizedHandler, retryOptions = {
32694
32888
  scheduleDelay: setTimeout
32695
32889
  }) {
32696
32890
  let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest({ request, url });
@@ -32704,6 +32898,11 @@ ${result.sanitizedHeaders}
32704
32898
  throw errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32705
32899
  if (result.status === "unknown-error")
32706
32900
  throw errorHandler2 ? errorHandler2(result.error, result.requestId) : result.error;
32901
+ if (result.status === "unauthorized")
32902
+ if (unauthorizedHandler)
32903
+ await unauthorizedHandler();
32904
+ else
32905
+ throw result.clientError;
32707
32906
  if (limitRetriesTo <= retriesUsed)
32708
32907
  throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32709
32908
  retriesUsed += 1;
@@ -33816,9 +34015,9 @@ function defaultApiScopes(api, systemEnvironment = process.env) {
33816
34015
  case "partners":
33817
34016
  return ["cli"];
33818
34017
  case "business-platform":
33819
- return isTruthy(systemEnvironment.USE_APP_MANAGEMENT_API) ? ["destinations", "store-management"] : ["destinations"];
34018
+ return isAppManagementEnabled(systemEnvironment) ? ["destinations", "store-management"] : ["destinations"];
33820
34019
  case "app-management":
33821
- return isTruthy(systemEnvironment.USE_APP_MANAGEMENT_API) ? ["app-management"] : [];
34020
+ return isAppManagementEnabled(systemEnvironment) ? ["app-management"] : [];
33822
34021
  default:
33823
34022
  throw new BugError(`Unknown API: ${api}`);
33824
34023
  }
@@ -33965,7 +34164,7 @@ var InvalidGrantError = class extends import_ts_error.ExtendableError {
33965
34164
  }, InvalidTargetError = class extends AbortError {
33966
34165
  };
33967
34166
  async function exchangeAccessForApplicationTokens(identityToken, scopes, store2) {
33968
- let token = identityToken.accessToken, appManagementEnabled = isTruthy(process.env.USE_APP_MANAGEMENT_API), [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([
34167
+ let token = identityToken.accessToken, appManagementEnabled = isAppManagementEnabled(), [partners, storefront, businessPlatform, admin, appManagement] = await Promise.all([
33969
34168
  requestAppToken("partners", token, scopes.partners),
33970
34169
  requestAppToken("storefront-renderer", token, scopes.storefront),
33971
34170
  requestAppToken("business-platform", token, scopes.businessPlatform),
@@ -34200,14 +34399,14 @@ Request ID: ${requestId}
34200
34399
 
34201
34400
  // ../cli-kit/dist/public/node/api/graphql.js
34202
34401
  async function performGraphQLRequest(options2) {
34203
- let { token, addedHeaders, queryAsString, variables, api, url, responseOptions } = options2, headers = {
34402
+ let { token, addedHeaders, queryAsString, variables, api, url, responseOptions, unauthorizedHandler } = options2, headers = {
34204
34403
  ...addedHeaders,
34205
34404
  ...buildHeaders(token)
34206
34405
  };
34207
34406
  debugLogRequestInfo(api, queryAsString, url, variables, headers);
34208
34407
  let clientOptions = { agent: await httpsAgent(), headers }, client = new GraphQLClient(url, clientOptions);
34209
34408
  return runWithTimer("cmd_all_timing_network_ms")(async () => {
34210
- let response = await retryAwareRequest({ request: () => client.rawRequest(queryAsString, variables), url }, responseOptions?.handleErrors === !1 ? void 0 : errorHandler(api));
34409
+ let response = await retryAwareRequest({ request: () => client.rawRequest(queryAsString, variables), url }, responseOptions?.handleErrors === !1 ? void 0 : errorHandler(api), unauthorizedHandler);
34211
34410
  responseOptions?.onResponse && responseOptions.onResponse(response);
34212
34411
  try {
34213
34412
  let requestId = response.headers.get("x-request-id");
@@ -34317,6 +34516,9 @@ function getIdentityTokenInformation() {
34317
34516
  userId: nonRandomUUID(identityToken)
34318
34517
  };
34319
34518
  }
34519
+ function jsonOutputEnabled(environment = getEnvironmentVariables()) {
34520
+ return sniffForJson() || isTruthy(environment[environmentVariables.json]);
34521
+ }
34320
34522
 
34321
34523
  // ../cli-kit/dist/private/node/session.js
34322
34524
  var userId, authMethod = "none";
@@ -34405,7 +34607,7 @@ async function executeCompleteFlow(applications, identityFqdn2) {
34405
34607
  return outputCompleted("Logged in."), session;
34406
34608
  }
34407
34609
  async function ensureUserHasPartnerAccount(partnersToken, userId2) {
34408
- if (!isTruthy(process.env.USE_APP_MANAGEMENT_API) && (outputDebug(outputContent`Verifying that the user has a Partner organization`), !await hasPartnerAccount(partnersToken, userId2) && (outputInfo(`
34610
+ if (!isAppManagementEnabled() && (outputDebug(outputContent`Verifying that the user has a Partner organization`), !await hasPartnerAccount(partnersToken, userId2) && (outputInfo(`
34409
34611
  A Shopify Partners organization is needed to proceed.`), outputInfo("\u{1F449} Press any key to create one"), await keypress(), await openURL(`https://${await partnersFqdn()}/signup`), outputInfo(outputContent`👉 Press any key when you have ${outputToken.cyan("created the organization")}`), outputWarn(outputContent`Make sure you've confirmed your Shopify and the Partner organization from the email`), await keypress(), !await hasPartnerAccount(partnersToken, userId2))))
34410
34612
  throw new AbortError("Couldn't find your Shopify Partners organization", "Have you confirmed your accounts from the emails you received?");
34411
34613
  }
@@ -34602,7 +34804,6 @@ export {
34602
34804
  fetch2 as fetch,
34603
34805
  z,
34604
34806
  deepStrict,
34605
- errorsToString,
34606
34807
  partnersFqdn,
34607
34808
  appManagementFqdn,
34608
34809
  developerDashboardFqdn,
@@ -34628,6 +34829,7 @@ export {
34628
34829
  getEnvironmentVariables,
34629
34830
  getPartnersToken,
34630
34831
  getBackendPort,
34832
+ jsonOutputEnabled,
34631
34833
  getLastSeenUserIdAfterAuth,
34632
34834
  setLastSeenUserIdAfterAuth,
34633
34835
  setLastSeenAuthMethod,
@@ -34656,4 +34858,4 @@ mime-types/index.js:
34656
34858
  * MIT Licensed
34657
34859
  *)
34658
34860
  */
34659
- //# sourceMappingURL=chunk-CWXZ7XAM.js.map
34861
+ //# sourceMappingURL=chunk-GRIQNZDW.js.map