@shopify/create-app 3.69.4 → 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 (31) hide show
  1. package/dist/{chunk-Q3BCFN7X.js → chunk-33RXIX54.js} +15 -20
  2. package/dist/{chunk-4XZVKK5N.js → chunk-4ZKJC2JB.js} +3 -3
  3. package/dist/{chunk-L7M22NDW.js → chunk-6WYZ3SZB.js} +2 -2
  4. package/dist/{chunk-2A7GNM7F.js → chunk-7F4XFNYI.js} +2 -2
  5. package/dist/{chunk-AZIUHI45.js → chunk-CQGOPQQH.js} +5 -5
  6. package/dist/{chunk-CZRFEKLZ.js → chunk-JPPYUT6M.js} +23535 -23336
  7. package/dist/{chunk-MX4RJDBM.js → chunk-KYB6A4PE.js} +1 -2
  8. package/dist/{chunk-A7RFWXE2.js → chunk-PATNPZAL.js} +14 -11
  9. package/dist/{chunk-BB4M6AYQ.js → chunk-PGUENKZG.js} +28 -212
  10. package/dist/{chunk-ZYFGLOXH.js → chunk-PUMOQDXS.js} +258 -57
  11. package/dist/{chunk-PNN7RS7Y.js → chunk-X36SPRUS.js} +100 -11
  12. package/dist/{custom-oclif-loader-53O4TZIJ.js → custom-oclif-loader-OP5VH4KR.js} +9 -11
  13. package/dist/{del-42HQA7PR.js → del-2FOJ63S7.js} +4 -4
  14. package/dist/{error-handler-WHWFBH7O.js → error-handler-WKRKCPUQ.js} +11 -13
  15. package/dist/hooks/postrun.js +9 -11
  16. package/dist/hooks/prerun.js +9 -13
  17. package/dist/index.js +149240 -145769
  18. package/dist/index.test.js +120 -65
  19. package/dist/{lib-H5ZGVBFQ.js → lib-EGJUAXU5.js} +5 -5
  20. package/dist/{local-RKKDDHC7.js → local-IPRKH7YW.js} +9 -9
  21. package/dist/{node-package-manager-MZVZACMV.js → node-package-manager-CPX2FDHZ.js} +8 -10
  22. package/dist/{out-ZDSLKX4N.js → out-MHEKZJWS.js} +2 -2
  23. package/dist/{path-G6AAF6UV.js → path-EGU2FCFY.js} +2 -3
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/dist/{ui-5ZHMFGW7.js → ui-AAFX7Q72.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-G6AY2JW5.js +0 -115
  30. package/dist/constants-GVJLI6RE.js +0 -24
  31. package/dist/system-HEFPAS7V.js +0 -27
@@ -12,7 +12,7 @@ import {
12
12
  removeSession,
13
13
  setCachedPartnerAccountStatus,
14
14
  setSession
15
- } from "./chunk-A7RFWXE2.js";
15
+ } from "./chunk-PATNPZAL.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,
49
+ systemEnvironmentVariables,
50
+ themeKitAccessDomain,
46
51
  themeToken
47
- } from "./chunk-CZRFEKLZ.js";
52
+ } from "./chunk-JPPYUT6M.js";
48
53
  import {
49
- defaultThemeKitAccessDomain,
50
- environmentVariables,
51
- sessionConstants,
52
- systemEnvironmentVariables
53
- } from "./chunk-G6AY2JW5.js";
54
- import {
55
- cwd
56
- } from "./chunk-BB6N2XSA.js";
54
+ cwd,
55
+ sniffForJson
56
+ } from "./chunk-X36SPRUS.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.69.4";
29345
+ var CLI_KIT_VERSION = "3.71.0";
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
@@ -32195,7 +32378,7 @@ function buildHeaders(token) {
32195
32378
  ...firstPartyDev() && { "X-Shopify-Cli-Employee": "1" }
32196
32379
  };
32197
32380
  if (token) {
32198
- let authString = token.match(/^shp(at|ua|ca)/) ? token : `Bearer ${token}`;
32381
+ let authString = token.match(/^shp(at|ua|ca|tka)/) ? token : `Bearer ${token}`;
32199
32382
  headers.authorization = authString, headers["X-Shopify-Access-Token"] = authString;
32200
32383
  }
32201
32384
  return headers;
@@ -32627,7 +32810,7 @@ async function makeVerboseRequest({ request, url }) {
32627
32810
  for (let [key, value] of err2.response.headers)
32628
32811
  responseHeaderIsInteresting(key) && (responseHeaders[key] = value);
32629
32812
  let sanitizedHeaders = sanitizedHeadersOutput(responseHeaders);
32630
- if (err2.response.errors?.some((error) => error.extensions.code === "429") || err2.response.status === 429) {
32813
+ if (errorsIncludeStatus429(err2)) {
32631
32814
  let delayMs;
32632
32815
  try {
32633
32816
  delayMs = responseHeaders["retry-after"] ? Number.parseInt(responseHeaders["retry-after"], 10) : void 0;
@@ -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,
@@ -32671,6 +32863,9 @@ async function makeVerboseRequest({ request, url }) {
32671
32863
  requestId: responseHeaders["x-request-id"]
32672
32864
  };
32673
32865
  }
32866
+ function errorsIncludeStatus429(error) {
32867
+ return error.response.status === 429 ? !0 : typeof error.response.errors == "string" ? !1 : error.response.errors?.some((error2) => error2.extensions?.code === "429") ?? !1;
32868
+ }
32674
32869
  async function simpleRequestWithDebugLog({ request, url }, errorHandler2) {
32675
32870
  let result = await makeVerboseRequest({ request, url });
32676
32871
  switch (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
@@ -32685,9 +32880,11 @@ ${result.sanitizedHeaders}
32685
32880
  throw errorHandler2 ? errorHandler2(result.error, result.requestId) : result.error;
32686
32881
  case "can-retry":
32687
32882
  throw errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32883
+ case "unauthorized":
32884
+ throw errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32688
32885
  }
32689
32886
  }
32690
- async function retryAwareRequest({ request, url }, errorHandler2, retryOptions = {
32887
+ async function retryAwareRequest({ request, url }, errorHandler2, unauthorizedHandler, retryOptions = {
32691
32888
  scheduleDelay: setTimeout
32692
32889
  }) {
32693
32890
  let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest({ request, url });
@@ -32701,6 +32898,11 @@ ${result.sanitizedHeaders}
32701
32898
  throw errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32702
32899
  if (result.status === "unknown-error")
32703
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;
32704
32906
  if (limitRetriesTo <= retriesUsed)
32705
32907
  throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler2 ? errorHandler2(result.clientError, result.requestId) : result.clientError;
32706
32908
  retriesUsed += 1;
@@ -33813,9 +34015,9 @@ function defaultApiScopes(api, systemEnvironment = process.env) {
33813
34015
  case "partners":
33814
34016
  return ["cli"];
33815
34017
  case "business-platform":
33816
- return isTruthy(systemEnvironment.USE_APP_MANAGEMENT_API) ? ["destinations", "store-management"] : ["destinations"];
34018
+ return isAppManagementEnabled(systemEnvironment) ? ["destinations", "store-management"] : ["destinations"];
33817
34019
  case "app-management":
33818
- return isTruthy(systemEnvironment.USE_APP_MANAGEMENT_API) ? ["app-management"] : [];
34020
+ return isAppManagementEnabled(systemEnvironment) ? ["app-management"] : [];
33819
34021
  default:
33820
34022
  throw new BugError(`Unknown API: ${api}`);
33821
34023
  }
@@ -33962,7 +34164,7 @@ var InvalidGrantError = class extends import_ts_error.ExtendableError {
33962
34164
  }, InvalidTargetError = class extends AbortError {
33963
34165
  };
33964
34166
  async function exchangeAccessForApplicationTokens(identityToken, scopes, store2) {
33965
- 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([
33966
34168
  requestAppToken("partners", token, scopes.partners),
33967
34169
  requestAppToken("storefront-renderer", token, scopes.storefront),
33968
34170
  requestAppToken("business-platform", token, scopes.businessPlatform),
@@ -34140,8 +34342,8 @@ function restRequestBody(requestBody) {
34140
34342
  if (requestBody)
34141
34343
  return JSON.stringify(requestBody);
34142
34344
  }
34143
- function restRequestUrl(session, apiVersion, path, searchParams = {}, env = process.env) {
34144
- let themeKitAccessDomain = env[environmentVariables.themeKitAccessDomain] || defaultThemeKitAccessDomain, url = new URL(isThemeAccessSession(session) ? `https://${themeKitAccessDomain}/cli/admin/api/${apiVersion}${path}.json` : `https://${session.storeFqdn}/admin/api/${apiVersion}${path}.json`);
34345
+ function restRequestUrl(session, apiVersion, path, searchParams = {}) {
34346
+ let url = new URL(isThemeAccessSession(session) ? `https://${themeKitAccessDomain}/cli/admin/api/${apiVersion}${path}.json` : `https://${session.storeFqdn}/admin/api/${apiVersion}${path}.json`);
34145
34347
  return Object.entries(searchParams).forEach(([name, value]) => {
34146
34348
  url.searchParams.set(name, value);
34147
34349
  }), url.toString();
@@ -34162,7 +34364,7 @@ init_cjs_shims();
34162
34364
 
34163
34365
  // ../cli-kit/dist/private/node/api/graphql.js
34164
34366
  init_cjs_shims();
34165
- function debugLogRequestInfo(api, query, variables, headers = {}) {
34367
+ function debugLogRequestInfo(api, query, url, variables, headers = {}) {
34166
34368
  outputDebug(outputContent`Sending ${outputToken.json(api)} GraphQL request:
34167
34369
  ${outputToken.raw(query.toString().trim())}
34168
34370
  ${variables ? `
@@ -34170,8 +34372,8 @@ With variables:
34170
34372
  ${sanitizeVariables(variables)}
34171
34373
  ` : ""}
34172
34374
  With request headers:
34173
- ${sanitizedHeadersOutput(headers)}
34174
- `);
34375
+ ${sanitizedHeadersOutput(headers)}\n
34376
+ to ${sanitizeURL(url)}`);
34175
34377
  }
34176
34378
  function sanitizeVariables(variables) {
34177
34379
  let result = { ...variables };
@@ -34197,14 +34399,14 @@ Request ID: ${requestId}
34197
34399
 
34198
34400
  // ../cli-kit/dist/public/node/api/graphql.js
34199
34401
  async function performGraphQLRequest(options2) {
34200
- let { token, addedHeaders, queryAsString, variables, api, url, responseOptions } = options2, headers = {
34402
+ let { token, addedHeaders, queryAsString, variables, api, url, responseOptions, unauthorizedHandler } = options2, headers = {
34201
34403
  ...addedHeaders,
34202
34404
  ...buildHeaders(token)
34203
34405
  };
34204
- debugLogRequestInfo(api, queryAsString, variables, headers);
34406
+ debugLogRequestInfo(api, queryAsString, url, variables, headers);
34205
34407
  let clientOptions = { agent: await httpsAgent(), headers }, client = new GraphQLClient(url, clientOptions);
34206
34408
  return runWithTimer("cmd_all_timing_network_ms")(async () => {
34207
- 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);
34208
34410
  responseOptions?.onResponse && responseOptions.onResponse(response);
34209
34411
  try {
34210
34412
  let requestId = response.headers.get("x-request-id");
@@ -34300,9 +34502,6 @@ function getEnvironmentVariables() {
34300
34502
  function getPartnersToken() {
34301
34503
  return getEnvironmentVariables()[environmentVariables.partnersToken];
34302
34504
  }
34303
- function getOrganization() {
34304
- return getEnvironmentVariables()[environmentVariables.organization];
34305
- }
34306
34505
  function getBackendPort() {
34307
34506
  let backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort];
34308
34507
  if (backendPort && !isNaN(Number(backendPort)))
@@ -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
  }
@@ -34591,16 +34793,6 @@ function flagIncluded(flag, commandClass) {
34591
34793
  export {
34592
34794
  getNextDeprecationDate,
34593
34795
  setNextDeprecationDate,
34594
- username,
34595
- platformAndArch,
34596
- hashString,
34597
- fileHash,
34598
- randomUUID,
34599
- nonRandomUUID,
34600
- getEnvironmentVariables,
34601
- getPartnersToken,
34602
- getOrganization,
34603
- getBackendPort,
34604
34796
  CLI_KIT_VERSION,
34605
34797
  require_mime_types,
34606
34798
  require_graphql2 as require_graphql,
@@ -34612,7 +34804,6 @@ export {
34612
34804
  fetch2 as fetch,
34613
34805
  z,
34614
34806
  deepStrict,
34615
- errorsToString,
34616
34807
  partnersFqdn,
34617
34808
  appManagementFqdn,
34618
34809
  developerDashboardFqdn,
@@ -34620,6 +34811,10 @@ export {
34620
34811
  normalizeStoreFqdn,
34621
34812
  ok,
34622
34813
  err,
34814
+ hashString,
34815
+ fileHash,
34816
+ randomUUID,
34817
+ nonRandomUUID,
34623
34818
  exchangeCustomPartnerToken,
34624
34819
  restRequestBody,
34625
34820
  restRequestUrl,
@@ -34631,10 +34826,16 @@ export {
34631
34826
  partnersRequest,
34632
34827
  partnersRequestDoc,
34633
34828
  handleDeprecations,
34829
+ getEnvironmentVariables,
34830
+ getPartnersToken,
34831
+ getBackendPort,
34832
+ jsonOutputEnabled,
34634
34833
  getLastSeenUserIdAfterAuth,
34635
34834
  setLastSeenUserIdAfterAuth,
34636
34835
  setLastSeenAuthMethod,
34637
34836
  ensureAuthenticated,
34837
+ username,
34838
+ platformAndArch,
34638
34839
  startAnalytics,
34639
34840
  getEnvironmentData,
34640
34841
  getSensitiveEnvironmentData
@@ -34657,4 +34858,4 @@ mime-types/index.js:
34657
34858
  * MIT Licensed
34658
34859
  *)
34659
34860
  */
34660
- //# sourceMappingURL=chunk-ZYFGLOXH.js.map
34861
+ //# sourceMappingURL=chunk-PUMOQDXS.js.map