@shopify/create-app 3.76.2 → 3.77.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.
@@ -9,7 +9,7 @@ import {
9
9
  packageManagerFromUserAgent,
10
10
  removeSession,
11
11
  setSession
12
- } from "./chunk-DVNRCA3A.js";
12
+ } from "./chunk-EOJTBQOC.js";
13
13
  import {
14
14
  AbortError,
15
15
  BugError,
@@ -27,11 +27,13 @@ import {
27
27
  hashString,
28
28
  import_ts_error,
29
29
  isAppManagementDisabled,
30
+ isCI,
30
31
  isCloudEnvironment,
31
32
  isSpin,
32
33
  isTTY,
33
34
  keypress,
34
35
  macAddress,
36
+ maxRequestTimeForNetworkCallsMs,
35
37
  nonRandomUUID,
36
38
  openURL,
37
39
  outputCompleted,
@@ -43,9 +45,11 @@ import {
43
45
  runWithTimer,
44
46
  serviceEnvironment,
45
47
  sessionConstants,
48
+ skipNetworkLevelRetry,
49
+ sleep,
46
50
  spinFqdn,
47
51
  themeToken
48
- } from "./chunk-4YFG4SYR.js";
52
+ } from "./chunk-J27B2HLC.js";
49
53
  import {
50
54
  cwd
51
55
  } from "./chunk-ZUCWDIGE.js";
@@ -15528,11 +15532,11 @@ var require_url_state_machine = __commonJS({
15528
15532
  function isSpecialScheme(scheme) {
15529
15533
  return specialSchemes[scheme] !== void 0;
15530
15534
  }
15531
- function isSpecial(url) {
15532
- return isSpecialScheme(url.scheme);
15535
+ function isSpecial(url4) {
15536
+ return isSpecialScheme(url4.scheme);
15533
15537
  }
15534
- function isNotSpecial(url) {
15535
- return !isSpecialScheme(url.scheme);
15538
+ function isNotSpecial(url4) {
15539
+ return !isSpecialScheme(url4.scheme);
15536
15540
  }
15537
15541
  function defaultPort(scheme) {
15538
15542
  return specialSchemes[scheme];
@@ -15679,8 +15683,8 @@ var require_url_state_machine = __commonJS({
15679
15683
  arr[i] !== 0 ? (currLen > maxLen && (maxIdx = currStart, maxLen = currLen), currStart = null, currLen = 0) : (currStart === null && (currStart = i), ++currLen);
15680
15684
  return currLen > maxLen ? currStart : maxIdx;
15681
15685
  }
15682
- function serializeHost(host) {
15683
- return typeof host == "number" ? serializeIPv4(host) : host instanceof Array ? `[${serializeIPv6(host)}]` : host;
15686
+ function serializeHost(host4) {
15687
+ return typeof host4 == "number" ? serializeIPv4(host4) : host4 instanceof Array ? `[${serializeIPv6(host4)}]` : host4;
15684
15688
  }
15685
15689
  function domainToASCII(domain, beStrict = !1) {
15686
15690
  let result = tr46.toASCII(domain, {
@@ -15692,30 +15696,30 @@ var require_url_state_machine = __commonJS({
15692
15696
  });
15693
15697
  return result === null || result === "" ? failure : result;
15694
15698
  }
15695
- function trimControlChars(url) {
15696
- return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/ug, "");
15699
+ function trimControlChars(url4) {
15700
+ return url4.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/ug, "");
15697
15701
  }
15698
- function trimTabAndNewline(url) {
15699
- return url.replace(/\u0009|\u000A|\u000D/ug, "");
15702
+ function trimTabAndNewline(url4) {
15703
+ return url4.replace(/\u0009|\u000A|\u000D/ug, "");
15700
15704
  }
15701
- function shortenPath(url) {
15702
- let { path } = url;
15703
- path.length !== 0 && (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0]) || path.pop());
15705
+ function shortenPath(url4) {
15706
+ let { path } = url4;
15707
+ path.length !== 0 && (url4.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0]) || path.pop());
15704
15708
  }
15705
- function includesCredentials(url) {
15706
- return url.username !== "" || url.password !== "";
15709
+ function includesCredentials(url4) {
15710
+ return url4.username !== "" || url4.password !== "";
15707
15711
  }
15708
- function cannotHaveAUsernamePasswordPort(url) {
15709
- return url.host === null || url.host === "" || url.scheme === "file";
15712
+ function cannotHaveAUsernamePasswordPort(url4) {
15713
+ return url4.host === null || url4.host === "" || url4.scheme === "file";
15710
15714
  }
15711
- function hasAnOpaquePath(url) {
15712
- return typeof url.path == "string";
15715
+ function hasAnOpaquePath(url4) {
15716
+ return typeof url4.path == "string";
15713
15717
  }
15714
15718
  function isNormalizedWindowsDriveLetter(string) {
15715
15719
  return /^[A-Za-z]:$/u.test(string);
15716
15720
  }
15717
- function URLStateMachine(input, base, encodingOverride, url, stateOverride) {
15718
- if (this.pointer = 0, this.input = input, this.base = base || null, this.encodingOverride = encodingOverride || "utf-8", this.stateOverride = stateOverride, this.url = url, this.failure = !1, this.parseError = !1, !this.url) {
15721
+ function URLStateMachine(input, base, encodingOverride, url4, stateOverride) {
15722
+ if (this.pointer = 0, this.input = input, this.base = base || null, this.encodingOverride = encodingOverride || "utf-8", this.stateOverride = stateOverride, this.url = url4, this.failure = !1, this.parseError = !1, !this.url) {
15719
15723
  this.url = {
15720
15724
  scheme: "",
15721
15725
  username: "",
@@ -15815,19 +15819,19 @@ var require_url_state_machine = __commonJS({
15815
15819
  return this.parseError = !0, failure;
15816
15820
  if (this.stateOverride === "hostname")
15817
15821
  return !1;
15818
- let host = parseHost(this.buffer, isNotSpecial(this.url));
15819
- if (host === failure)
15822
+ let host4 = parseHost(this.buffer, isNotSpecial(this.url));
15823
+ if (host4 === failure)
15820
15824
  return failure;
15821
- this.url.host = host, this.buffer = "", this.state = "port";
15825
+ this.url.host = host4, this.buffer = "", this.state = "port";
15822
15826
  } else if (isNaN(c) || c === p("/") || c === p("?") || c === p("#") || isSpecial(this.url) && c === p("\\")) {
15823
15827
  if (--this.pointer, isSpecial(this.url) && this.buffer === "")
15824
15828
  return this.parseError = !0, failure;
15825
15829
  if (this.stateOverride && this.buffer === "" && (includesCredentials(this.url) || this.url.port !== null))
15826
15830
  return this.parseError = !0, !1;
15827
- let host = parseHost(this.buffer, isNotSpecial(this.url));
15828
- if (host === failure)
15831
+ let host4 = parseHost(this.buffer, isNotSpecial(this.url));
15832
+ if (host4 === failure)
15829
15833
  return failure;
15830
- if (this.url.host = host, this.buffer = "", this.state = "path start", this.stateOverride)
15834
+ if (this.url.host = host4, this.buffer = "", this.state = "path start", this.stateOverride)
15831
15835
  return !1;
15832
15836
  } else
15833
15837
  c === p("[") ? this.arrFlag = !0 : c === p("]") && (this.arrFlag = !1), this.buffer += cStr;
@@ -15870,10 +15874,10 @@ var require_url_state_machine = __commonJS({
15870
15874
  return !1;
15871
15875
  this.state = "path start";
15872
15876
  } else {
15873
- let host = parseHost(this.buffer, isNotSpecial(this.url));
15874
- if (host === failure)
15877
+ let host4 = parseHost(this.buffer, isNotSpecial(this.url));
15878
+ if (host4 === failure)
15875
15879
  return failure;
15876
- if (host === "localhost" && (host = ""), this.url.host = host, this.stateOverride)
15880
+ if (host4 === "localhost" && (host4 = ""), this.url.host = host4, this.stateOverride)
15877
15881
  return !1;
15878
15882
  this.buffer = "", this.state = "path start";
15879
15883
  }
@@ -15900,28 +15904,28 @@ var require_url_state_machine = __commonJS({
15900
15904
  URLStateMachine.prototype["parse fragment"] = function(c) {
15901
15905
  return isNaN(c) || (c === p("%") && (!infra.isASCIIHex(this.input[this.pointer + 1]) || !infra.isASCIIHex(this.input[this.pointer + 2])) && (this.parseError = !0), this.url.fragment += utf8PercentEncodeCodePoint(c, isFragmentPercentEncode)), !0;
15902
15906
  };
15903
- function serializeURL(url, excludeFragment) {
15904
- let output = `${url.scheme}:`;
15905
- return url.host !== null && (output += "//", (url.username !== "" || url.password !== "") && (output += url.username, url.password !== "" && (output += `:${url.password}`), output += "@"), output += serializeHost(url.host), url.port !== null && (output += `:${url.port}`)), url.host === null && !hasAnOpaquePath(url) && url.path.length > 1 && url.path[0] === "" && (output += "/."), output += serializePath(url), url.query !== null && (output += `?${url.query}`), !excludeFragment && url.fragment !== null && (output += `#${url.fragment}`), output;
15907
+ function serializeURL(url4, excludeFragment) {
15908
+ let output = `${url4.scheme}:`;
15909
+ return url4.host !== null && (output += "//", (url4.username !== "" || url4.password !== "") && (output += url4.username, url4.password !== "" && (output += `:${url4.password}`), output += "@"), output += serializeHost(url4.host), url4.port !== null && (output += `:${url4.port}`)), url4.host === null && !hasAnOpaquePath(url4) && url4.path.length > 1 && url4.path[0] === "" && (output += "/."), output += serializePath(url4), url4.query !== null && (output += `?${url4.query}`), !excludeFragment && url4.fragment !== null && (output += `#${url4.fragment}`), output;
15906
15910
  }
15907
15911
  function serializeOrigin(tuple) {
15908
15912
  let result = `${tuple.scheme}://`;
15909
15913
  return result += serializeHost(tuple.host), tuple.port !== null && (result += `:${tuple.port}`), result;
15910
15914
  }
15911
- function serializePath(url) {
15912
- if (hasAnOpaquePath(url))
15913
- return url.path;
15915
+ function serializePath(url4) {
15916
+ if (hasAnOpaquePath(url4))
15917
+ return url4.path;
15914
15918
  let output = "";
15915
- for (let segment of url.path)
15919
+ for (let segment of url4.path)
15916
15920
  output += `/${segment}`;
15917
15921
  return output;
15918
15922
  }
15919
15923
  module.exports.serializeURL = serializeURL;
15920
15924
  module.exports.serializePath = serializePath;
15921
- module.exports.serializeURLOrigin = function(url) {
15922
- switch (url.scheme) {
15925
+ module.exports.serializeURLOrigin = function(url4) {
15926
+ switch (url4.scheme) {
15923
15927
  case "blob": {
15924
- let pathURL = module.exports.parseURL(serializePath(url));
15928
+ let pathURL = module.exports.parseURL(serializePath(url4));
15925
15929
  return pathURL === null || pathURL.scheme !== "http" && pathURL.scheme !== "https" ? "null" : module.exports.serializeURLOrigin(pathURL);
15926
15930
  }
15927
15931
  case "ftp":
@@ -15930,9 +15934,9 @@ var require_url_state_machine = __commonJS({
15930
15934
  case "ws":
15931
15935
  case "wss":
15932
15936
  return serializeOrigin({
15933
- scheme: url.scheme,
15934
- host: url.host,
15935
- port: url.port
15937
+ scheme: url4.scheme,
15938
+ host: url4.host,
15939
+ port: url4.port
15936
15940
  });
15937
15941
  case "file":
15938
15942
  return "null";
@@ -15945,11 +15949,11 @@ var require_url_state_machine = __commonJS({
15945
15949
  let usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride);
15946
15950
  return usm.failure ? null : usm.url;
15947
15951
  };
15948
- module.exports.setTheUsername = function(url, username) {
15949
- url.username = utf8PercentEncodeString(username, isUserinfoPercentEncode);
15952
+ module.exports.setTheUsername = function(url4, username) {
15953
+ url4.username = utf8PercentEncodeString(username, isUserinfoPercentEncode);
15950
15954
  };
15951
- module.exports.setThePassword = function(url, password) {
15952
- url.password = utf8PercentEncodeString(password, isUserinfoPercentEncode);
15955
+ module.exports.setThePassword = function(url4, password) {
15956
+ url4.password = utf8PercentEncodeString(password, isUserinfoPercentEncode);
15953
15957
  };
15954
15958
  module.exports.serializeHost = serializeHost;
15955
15959
  module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort;
@@ -16486,18 +16490,18 @@ var require_URL_impl = __commonJS({
16486
16490
  // Unlike the spec, we duplicate some code between the constructor and canParse, because we want to give useful error
16487
16491
  // messages in the constructor that distinguish between the different causes of failure.
16488
16492
  constructor(globalObject, constructorArgs) {
16489
- let url = constructorArgs[0], base = constructorArgs[1], parsedBase = null;
16493
+ let url4 = constructorArgs[0], base = constructorArgs[1], parsedBase = null;
16490
16494
  if (base !== void 0 && (parsedBase = usm.basicURLParse(base), parsedBase === null))
16491
16495
  throw new TypeError(`Invalid base URL: ${base}`);
16492
- let parsedURL = usm.basicURLParse(url, { baseURL: parsedBase });
16496
+ let parsedURL = usm.basicURLParse(url4, { baseURL: parsedBase });
16493
16497
  if (parsedURL === null)
16494
- throw new TypeError(`Invalid URL: ${url}`);
16498
+ throw new TypeError(`Invalid URL: ${url4}`);
16495
16499
  let query = parsedURL.query !== null ? parsedURL.query : "";
16496
16500
  this._url = parsedURL, this._query = URLSearchParams2.createImpl(globalObject, [query], { doNotStripQMark: !0 }), this._query._url = this;
16497
16501
  }
16498
- static canParse(url, base) {
16502
+ static canParse(url4, base) {
16499
16503
  let parsedBase = null;
16500
- return !(base !== void 0 && (parsedBase = usm.basicURLParse(base), parsedBase === null) || usm.basicURLParse(url, { baseURL: parsedBase }) === null);
16504
+ return !(base !== void 0 && (parsedBase = usm.basicURLParse(base), parsedBase === null) || usm.basicURLParse(url4, { baseURL: parsedBase }) === null);
16501
16505
  }
16502
16506
  get href() {
16503
16507
  return usm.serializeURL(this._url);
@@ -16532,8 +16536,8 @@ var require_URL_impl = __commonJS({
16532
16536
  usm.cannotHaveAUsernamePasswordPort(this._url) || usm.setThePassword(this._url, v);
16533
16537
  }
16534
16538
  get host() {
16535
- let url = this._url;
16536
- return url.host === null ? "" : url.port === null ? usm.serializeHost(url.host) : `${usm.serializeHost(url.host)}:${usm.serializeInteger(url.port)}`;
16539
+ let url4 = this._url;
16540
+ return url4.host === null ? "" : url4.port === null ? usm.serializeHost(url4.host) : `${usm.serializeHost(url4.host)}:${usm.serializeInteger(url4.port)}`;
16537
16541
  }
16538
16542
  set host(v) {
16539
16543
  usm.hasAnOpaquePath(this._url) || usm.basicURLParse(v, { url: this._url, stateOverride: "host" });
@@ -16560,13 +16564,13 @@ var require_URL_impl = __commonJS({
16560
16564
  return this._url.query === null || this._url.query === "" ? "" : `?${this._url.query}`;
16561
16565
  }
16562
16566
  set search(v) {
16563
- let url = this._url;
16567
+ let url4 = this._url;
16564
16568
  if (v === "") {
16565
- url.query = null, this._query._list = [], this._potentiallyStripTrailingSpacesFromAnOpaquePath();
16569
+ url4.query = null, this._query._list = [], this._potentiallyStripTrailingSpacesFromAnOpaquePath();
16566
16570
  return;
16567
16571
  }
16568
16572
  let input = v[0] === "?" ? v.substring(1) : v;
16569
- url.query = "", usm.basicURLParse(input, { url, stateOverride: "query" }), this._query._list = urlencoded.parseUrlencodedString(input);
16573
+ url4.query = "", usm.basicURLParse(input, { url: url4, stateOverride: "query" }), this._query._list = urlencoded.parseUrlencodedString(input);
16570
16574
  }
16571
16575
  get searchParams() {
16572
16576
  return this._query;
@@ -16636,7 +16640,7 @@ var require_URL = __commonJS({
16636
16640
  return;
16637
16641
  let ctorRegistry = utils.initCtorRegistry(globalObject);
16638
16642
  class URL2 {
16639
- constructor(url) {
16643
+ constructor(url4) {
16640
16644
  if (arguments.length < 1)
16641
16645
  throw new globalObject.TypeError(
16642
16646
  `Failed to construct 'URL': 1 argument required, but only ${arguments.length} present.`
@@ -16832,7 +16836,7 @@ var require_URL = __commonJS({
16832
16836
  globals: globalObject
16833
16837
  }), esValue[implSymbol].hash = V;
16834
16838
  }
16835
- static canParse(url) {
16839
+ static canParse(url4) {
16836
16840
  if (arguments.length < 1)
16837
16841
  throw new globalObject.TypeError(
16838
16842
  `Failed to execute 'canParse' on 'URL': 1 argument required, but only ${arguments.length} present.`
@@ -17594,11 +17598,11 @@ var require_lib2 = __commonJS({
17594
17598
  let orig = new URL$1(original).protocol, dest = new URL$1(destination).protocol;
17595
17599
  return orig === dest;
17596
17600
  };
17597
- function fetch4(url, opts) {
17601
+ function fetch4(url4, opts) {
17598
17602
  if (!fetch4.Promise)
17599
17603
  throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
17600
17604
  return Body2.Promise = fetch4.Promise, new fetch4.Promise(function(resolve, reject) {
17601
- let request = new Request2(url, opts), options = getNodeRequestOptions2(request), send = (options.protocol === "https:" ? https3 : http3).request, signal = request.signal, response = null, abort = function() {
17605
+ let request = new Request2(url4, opts), options = getNodeRequestOptions2(request), send = (options.protocol === "https:" ? https3 : http3).request, signal = request.signal, response = null, abort = function() {
17602
17606
  let error = new AbortError3("The user aborted a request.");
17603
17607
  reject(error), request.body && request.body instanceof Stream3.Readable && destroyStream(request.body, error), !(!response || !response.body) && response.body.emit("error", error);
17604
17608
  };
@@ -17761,8 +17765,8 @@ var require_lib2 = __commonJS({
17761
17765
  var require_node_ponyfill = __commonJS({
17762
17766
  "../../node_modules/.pnpm/cross-fetch@3.1.8/node_modules/cross-fetch/dist/node-ponyfill.js"(exports, module) {
17763
17767
  init_cjs_shims();
17764
- var nodeFetch = require_lib2(), realFetch = nodeFetch.default || nodeFetch, fetch4 = function(url, options) {
17765
- return /^\/\//.test(url) && (url = "https:" + url), realFetch.call(this, url, options);
17768
+ var nodeFetch = require_lib2(), realFetch = nodeFetch.default || nodeFetch, fetch4 = function(url4, options) {
17769
+ return /^\/\//.test(url4) && (url4 = "https:" + url4), realFetch.call(this, url4, options);
17766
17770
  };
17767
17771
  fetch4.ponyfill = !0;
17768
17772
  module.exports = exports = fetch4;
@@ -26797,7 +26801,7 @@ var require_populate = __commonJS({
26797
26801
  var require_form_data = __commonJS({
26798
26802
  "../../node_modules/.pnpm/form-data@4.0.1/node_modules/form-data/lib/form_data.js"(exports, module) {
26799
26803
  init_cjs_shims();
26800
- 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_populate();
26804
+ var CombinedStream = require_combined_stream(), util2 = __require("util"), path = __require("path"), http3 = __require("http"), https3 = __require("https"), parseUrl = __require("url").parse, fs6 = __require("fs"), Stream3 = __require("stream").Stream, mime = require_mime_types(), asynckit = require_asynckit(), populate = require_populate();
26801
26805
  module.exports = FormData3;
26802
26806
  util2.inherits(FormData3, CombinedStream);
26803
26807
  function FormData3(options) {
@@ -26825,7 +26829,7 @@ var require_form_data = __commonJS({
26825
26829
  options.knownLength != null ? valueLength += +options.knownLength : Buffer.isBuffer(value) ? valueLength = value.length : typeof value == "string" && (valueLength = Buffer.byteLength(value)), this._valueLength += valueLength, this._overheadLength += Buffer.byteLength(header) + FormData3.LINE_BREAK.length, !(!value || !value.path && !(value.readable && value.hasOwnProperty("httpVersion")) && !(value instanceof Stream3)) && (options.knownLength || this._valuesToMeasure.push(value));
26826
26830
  };
26827
26831
  FormData3.prototype._lengthRetriever = function(value, callback) {
26828
- 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) {
26832
+ value.hasOwnProperty("fd") ? value.end != null && value.end != 1 / 0 && value.start != null ? callback(null, value.end + 1 - (value.start ? value.start : 0)) : fs6.stat(value.path, function(err2, stat) {
26829
26833
  var fileSize;
26830
26834
  if (err2) {
26831
26835
  callback(err2);
@@ -26947,7 +26951,7 @@ var require_form_data = __commonJS({
26947
26951
 
26948
26952
  // ../cli-kit/dist/public/common/version.js
26949
26953
  init_cjs_shims();
26950
- var CLI_KIT_VERSION = "3.76.2";
26954
+ var CLI_KIT_VERSION = "3.77.1";
26951
26955
 
26952
26956
  // ../cli-kit/dist/private/node/analytics.js
26953
26957
  init_cjs_shims();
@@ -30048,11 +30052,42 @@ async function shouldRejectUnauthorizedRequests() {
30048
30052
 
30049
30053
  // ../cli-kit/dist/private/node/api/urls.js
30050
30054
  init_cjs_shims();
30051
- function sanitizeURL(url) {
30052
- let parsedUrl = new URL(url);
30055
+ function sanitizeURL(url4) {
30056
+ let parsedUrl = new URL(url4);
30053
30057
  return parsedUrl.searchParams.has("subject_token") && parsedUrl.searchParams.set("subject_token", "****"), parsedUrl.searchParams.has("token") && parsedUrl.searchParams.set("token", "****"), parsedUrl.toString();
30054
30058
  }
30055
30059
 
30060
+ // ../cli-kit/dist/private/node/sleep-with-backoff.js
30061
+ init_cjs_shims();
30062
+ var DEFAULT_RETRY_DELAY_MS = 300, DEFAULT_MAX_TIME_MS = 1e4;
30063
+ function calculateBackoffDelay(attempt, firstDelayMs, maximumDelayMs = DEFAULT_MAX_TIME_MS / 3) {
30064
+ if (attempt === 0)
30065
+ return 0;
30066
+ let delayMultiplier = 2 ** (attempt - 1);
30067
+ return Math.min(firstDelayMs * delayMultiplier, maximumDelayMs);
30068
+ }
30069
+ async function* backoffGenerator(shouldContinue, firstDelayMs) {
30070
+ let attempt = 0;
30071
+ for (; ; ) {
30072
+ let nextDelayMs = calculateBackoffDelay(attempt, firstDelayMs);
30073
+ if (!shouldContinue(nextDelayMs))
30074
+ return { remainingMs: 0, iterations: attempt };
30075
+ await sleep(nextDelayMs / 1e3), yield nextDelayMs, attempt++;
30076
+ }
30077
+ }
30078
+ async function* sleepWithBackoffUntil(maxTimeMs = DEFAULT_MAX_TIME_MS, firstDelayMs = DEFAULT_RETRY_DELAY_MS) {
30079
+ if (maxTimeMs <= 0)
30080
+ return { remainingMs: 0, iterations: 0 };
30081
+ let startTime = Date.now(), generator = backoffGenerator((nextDelay) => Date.now() - startTime + nextDelay <= maxTimeMs, firstDelayMs), attempt = 0;
30082
+ for await (let delayMs of generator)
30083
+ yield delayMs, attempt++;
30084
+ let elapsedTime = Date.now() - startTime;
30085
+ return {
30086
+ remainingMs: maxTimeMs - elapsedTime,
30087
+ iterations: attempt
30088
+ };
30089
+ }
30090
+
30056
30091
  // ../../node_modules/.pnpm/graphql-request@6.1.0_graphql@16.10.0/node_modules/graphql-request/build/esm/index.js
30057
30092
  init_cjs_shims();
30058
30093
 
@@ -30274,7 +30309,7 @@ var resolveHeaders = (headers) => {
30274
30309
  }), acc), []);
30275
30310
  return `query=${encodeURIComponent(params_.jsonSerializer.stringify(payload))}`;
30276
30311
  }, createHttpMethodFetcher = (method) => async (params) => {
30277
- let { url, query, variables, operationName, fetch: fetch4, fetchOptions, middleware } = params, headers = { ...params.headers }, queryParams = "", body;
30312
+ let { url: url4, query, variables, operationName, fetch: fetch4, fetchOptions, middleware } = params, headers = { ...params.headers }, queryParams = "", body;
30278
30313
  method === "POST" ? (body = createRequestBody(query, variables, operationName, fetchOptions.jsonSerializer), typeof body == "string" && (headers["Content-Type"] = "application/json")) : queryParams = buildRequestConfig({
30279
30314
  query,
30280
30315
  variables,
@@ -30286,20 +30321,20 @@ var resolveHeaders = (headers) => {
30286
30321
  headers,
30287
30322
  body,
30288
30323
  ...fetchOptions
30289
- }, urlResolved = url, initResolved = init;
30324
+ }, urlResolved = url4, initResolved = init;
30290
30325
  if (middleware) {
30291
- let result = await Promise.resolve(middleware({ ...init, url, operationName, variables })), { url: urlNew, ...initNew } = result;
30326
+ let result = await Promise.resolve(middleware({ ...init, url: url4, operationName, variables })), { url: urlNew, ...initNew } = result;
30292
30327
  urlResolved = urlNew, initResolved = initNew;
30293
30328
  }
30294
30329
  return queryParams && (urlResolved = `${urlResolved}?${queryParams}`), await fetch4(urlResolved, initResolved);
30295
30330
  }, GraphQLClient = class {
30296
- constructor(url, requestConfig = {}) {
30297
- this.url = url, this.requestConfig = requestConfig, this.rawRequest = async (...args) => {
30298
- let [queryOrOptions, variables, requestHeaders] = args, rawRequestOptions = parseRawRequestArgs(queryOrOptions, variables, requestHeaders), { headers, fetch: fetch4 = CrossFetch.default, method = "POST", requestMiddleware, responseMiddleware, ...fetchOptions } = this.requestConfig, { url: url2 } = this;
30331
+ constructor(url4, requestConfig = {}) {
30332
+ this.url = url4, this.requestConfig = requestConfig, this.rawRequest = async (...args) => {
30333
+ let [queryOrOptions, variables, requestHeaders] = args, rawRequestOptions = parseRawRequestArgs(queryOrOptions, variables, requestHeaders), { headers, fetch: fetch4 = CrossFetch.default, method = "POST", requestMiddleware, responseMiddleware, ...fetchOptions } = this.requestConfig, { url: url5 } = this;
30299
30334
  rawRequestOptions.signal !== void 0 && (fetchOptions.signal = rawRequestOptions.signal);
30300
30335
  let { operationName } = resolveRequestDocument(rawRequestOptions.query);
30301
30336
  return makeRequest({
30302
- url: url2,
30337
+ url: url5,
30303
30338
  query: rawRequestOptions.query,
30304
30339
  variables: rawRequestOptions.variables,
30305
30340
  headers: {
@@ -30317,11 +30352,11 @@ var resolveHeaders = (headers) => {
30317
30352
  };
30318
30353
  }
30319
30354
  async request(documentOrOptions, ...variablesAndRequestHeaders) {
30320
- let [variables, requestHeaders] = variablesAndRequestHeaders, requestOptions = parseRequestArgs(documentOrOptions, variables, requestHeaders), { headers, fetch: fetch4 = CrossFetch.default, method = "POST", requestMiddleware, responseMiddleware, ...fetchOptions } = this.requestConfig, { url } = this;
30355
+ let [variables, requestHeaders] = variablesAndRequestHeaders, requestOptions = parseRequestArgs(documentOrOptions, variables, requestHeaders), { headers, fetch: fetch4 = CrossFetch.default, method = "POST", requestMiddleware, responseMiddleware, ...fetchOptions } = this.requestConfig, { url: url4 } = this;
30321
30356
  requestOptions.signal !== void 0 && (fetchOptions.signal = requestOptions.signal);
30322
30357
  let { query, operationName } = resolveRequestDocument(requestOptions.document);
30323
30358
  return makeRequest({
30324
- url,
30359
+ url: url4,
30325
30360
  query,
30326
30361
  variables: requestOptions.variables,
30327
30362
  headers: {
@@ -30413,7 +30448,7 @@ var createRequestBody = (query, variables, operationName, jsonSerializer) => {
30413
30448
 
30414
30449
  // ../cli-kit/dist/private/node/api.js
30415
30450
  import { performance } from "perf_hooks";
30416
- var allAPIs = ["admin", "storefront-renderer", "partners", "business-platform", "app-management"], DEFAULT_RETRY_DELAY_MS = 1e3, DEFAULT_RETRY_LIMIT = 10, interestingResponseHeaders = /* @__PURE__ */ new Set([
30451
+ var allAPIs = ["admin", "storefront-renderer", "partners", "business-platform", "app-management"], DEFAULT_RETRY_DELAY_MS2 = 1e3, DEFAULT_RETRY_LIMIT = 10, interestingResponseHeaders = /* @__PURE__ */ new Set([
30417
30452
  "cache-control",
30418
30453
  "content-type",
30419
30454
  "etag",
@@ -30424,10 +30459,38 @@ var allAPIs = ["admin", "storefront-renderer", "partners", "business-platform",
30424
30459
  function responseHeaderIsInteresting(header) {
30425
30460
  return interestingResponseHeaders.has(header);
30426
30461
  }
30427
- async function makeVerboseRequest({ request, url }) {
30428
- let t0 = performance.now(), duration = 0, responseHeaders = {}, sanitizedUrl = sanitizeURL(url), response = {};
30462
+ function isARetryableNetworkError(error) {
30463
+ return error instanceof Error ? [
30464
+ "socket hang up",
30465
+ "ECONNRESET",
30466
+ "ECONNABORTED",
30467
+ "ENOTFOUND",
30468
+ "ENETUNREACH",
30469
+ "network socket disonnected",
30470
+ "ETIMEDOUT",
30471
+ "ECONNREFUSED",
30472
+ "EAI_FAIL",
30473
+ "The operation was aborted."
30474
+ ].some((issueMessage) => error.message.includes(issueMessage)) : !1;
30475
+ }
30476
+ async function runRequestWithNetworkLevelRetry(requestOptions) {
30477
+ if (!requestOptions.useNetworkLevelRetry)
30478
+ return requestOptions.request();
30479
+ let lastSeenError;
30480
+ for await (let _delayMs of sleepWithBackoffUntil(requestOptions.maxRetryTimeMs))
30481
+ try {
30482
+ return await requestOptions.request();
30483
+ } catch (err2) {
30484
+ if (lastSeenError = err2, !isARetryableNetworkError(err2))
30485
+ throw err2;
30486
+ outputDebug(`Retrying request to ${requestOptions.url} due to network error ${err2}`);
30487
+ }
30488
+ throw lastSeenError;
30489
+ }
30490
+ async function makeVerboseRequest(requestOptions) {
30491
+ let t0 = performance.now(), duration = 0, responseHeaders = {}, sanitizedUrl = sanitizeURL(requestOptions.url), response = {};
30429
30492
  try {
30430
- response = await request(), response.headers.forEach((value, key) => {
30493
+ response = await runRequestWithNetworkLevelRetry(requestOptions), response.headers.forEach((value, key) => {
30431
30494
  responseHeaderIsInteresting(key) && (responseHeaders[key] = value);
30432
30495
  });
30433
30496
  } catch (err2) {
@@ -30493,8 +30556,8 @@ async function makeVerboseRequest({ request, url }) {
30493
30556
  function errorsIncludeStatus429(error) {
30494
30557
  return error.response.status === 429 ? !0 : typeof error.response.errors == "string" ? !1 : error.response.errors?.some((error2) => error2.extensions?.code === "429") ?? !1;
30495
30558
  }
30496
- async function simpleRequestWithDebugLog({ request, url }, errorHandler) {
30497
- let result = await makeVerboseRequest({ request, url });
30559
+ async function simpleRequestWithDebugLog(requestOptions, errorHandler) {
30560
+ let result = await makeVerboseRequest(requestOptions);
30498
30561
  switch (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
30499
30562
  With response headers:
30500
30563
  ${result.sanitizedHeaders}
@@ -30511,10 +30574,10 @@ ${result.sanitizedHeaders}
30511
30574
  throw errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30512
30575
  }
30513
30576
  }
30514
- async function retryAwareRequest({ request, url }, errorHandler, unauthorizedHandler, retryOptions = {
30577
+ async function retryAwareRequest(requestOptions, errorHandler, unauthorizedHandler, retryOptions = {
30515
30578
  scheduleDelay: setTimeout
30516
30579
  }) {
30517
- let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest({ request, url });
30580
+ let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest(requestOptions);
30518
30581
  for (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
30519
30582
  With response headers:
30520
30583
  ${result.sanitizedHeaders}
@@ -30533,10 +30596,10 @@ ${result.sanitizedHeaders}
30533
30596
  if (limitRetriesTo <= retriesUsed)
30534
30597
  throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler ? errorHandler(result.clientError, result.requestId) : result.clientError;
30535
30598
  retriesUsed += 1;
30536
- let retryDelayMs = result.delayMs ?? retryOptions.defaultDelayMs ?? DEFAULT_RETRY_DELAY_MS;
30599
+ let retryDelayMs = result.delayMs ?? retryOptions.defaultDelayMs ?? DEFAULT_RETRY_DELAY_MS2;
30537
30600
  outputDebug(`Scheduling retry request #${retriesUsed} to ${result.sanitizedUrl} in ${retryDelayMs} ms`), result = await new Promise((resolve) => {
30538
30601
  retryOptions.scheduleDelay(() => {
30539
- resolve(makeVerboseRequest({ request, url }));
30602
+ resolve(makeVerboseRequest(requestOptions));
30540
30603
  }, retryDelayMs);
30541
30604
  });
30542
30605
  }
@@ -30596,137 +30659,229 @@ init_cjs_shims();
30596
30659
  // ../cli-kit/dist/public/node/context/fqdn.js
30597
30660
  init_cjs_shims();
30598
30661
 
30599
- // ../cli-kit/dist/public/node/vendor/dev_server/DevServer.js
30662
+ // ../cli-kit/dist/public/node/vendor/dev_server/index.js
30663
+ init_cjs_shims();
30664
+
30665
+ // ../cli-kit/dist/public/node/vendor/dev_server/env.js
30666
+ init_cjs_shims();
30667
+ var isDevServerEnvironment = process.env.USING_DEV === "1" || process.env.SPIN === "1";
30668
+ function assertCompatibleEnvironment() {
30669
+ if (!isDevServerEnvironment)
30670
+ throw new Error("DevServer is not supported in this environment");
30671
+ }
30672
+
30673
+ // ../cli-kit/dist/public/node/vendor/dev_server/dev-server.js
30674
+ init_cjs_shims();
30675
+ import fs5 from "node:fs";
30676
+
30677
+ // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-2024.js
30600
30678
  init_cjs_shims();
30601
30679
  var ni = __toESM(require_network_interfaces(), 1);
30602
- import fs from "fs";
30603
- import * as os from "os";
30604
- import { execSync } from "child_process";
30605
- var DevServerUtils = class _DevServerUtils {
30606
- static assertConnectable(name, addr, port) {
30607
- try {
30608
- execSync(`nc -z -v -w 1 ${addr} ${port}`, {
30609
- timeout: _DevServerUtils.CONNECT_TIMEOUT,
30610
- stdio: "ignore"
30611
- });
30612
- } catch {
30613
- throw new Error(`NET FAILED DevServer for '${name}' is not running on ${port} / ${addr}: \`dev up ${name}\` to start it.`);
30614
- }
30680
+ import fs2 from "node:fs";
30681
+
30682
+ // ../cli-kit/dist/public/node/vendor/dev_server/network/index.js
30683
+ init_cjs_shims();
30684
+ import { spawnSync } from "node:child_process";
30685
+
30686
+ // ../cli-kit/dist/public/node/vendor/dev_server/network/host.js
30687
+ init_cjs_shims();
30688
+ import fs from "node:fs";
30689
+ var HOSTS_FILE = "/etc/hosts", hostToIpCache = {}, lastModifiedTime = 0;
30690
+ function loadHostsFile() {
30691
+ try {
30692
+ let modifiedTime = fs.statSync(HOSTS_FILE).mtimeMs;
30693
+ if (modifiedTime === lastModifiedTime)
30694
+ return;
30695
+ let lines = fs.readFileSync(HOSTS_FILE, "utf8").split(/\r?\n/);
30696
+ hostToIpCache = {};
30697
+ for (let line of lines) {
30698
+ if (line.trim().startsWith("#") || line.trim() === "")
30699
+ continue;
30700
+ let matches = /^\s*(?<ipAddress>[^\s#]+)\s+(?<matchedHostName>[^\s#]+)\s*(#.*)?$/.exec(line);
30701
+ if (matches && matches.groups) {
30702
+ let { ipAddress, matchedHostName } = matches.groups;
30703
+ matchedHostName && ipAddress && (hostToIpCache[matchedHostName] = ipAddress);
30704
+ }
30705
+ }
30706
+ lastModifiedTime = modifiedTime;
30707
+ } catch (error) {
30708
+ console.log("Error reading hosts file:", error);
30615
30709
  }
30616
- static inferenceModeAndProjectIsEdition2016(name) {
30617
- try {
30618
- fs.accessSync(_DevServerUtils.INFERENCE_MODE_SENTINEL);
30619
- try {
30620
- return fs.accessSync(`/opt/nginx/etc/manifest/${name}/current/edition-2024`), !1;
30621
- } catch {
30622
- return !0;
30623
- }
30624
- } catch {
30625
- return !1;
30626
- }
30710
+ }
30711
+ function getIpFromHosts(hostname) {
30712
+ loadHostsFile();
30713
+ let ipAddress = hostToIpCache[hostname];
30714
+ if (ipAddress)
30715
+ return ipAddress;
30716
+ throw new Error(`No IP found for hostname: ${hostname}`);
30717
+ }
30718
+
30719
+ // ../cli-kit/dist/public/node/vendor/dev_server/network/index.js
30720
+ var DEFAULT_CONNECT_TIMEOUT = 100, checkPort;
30721
+ function assertConnectable(options) {
30722
+ checkPort || (checkPort = getCheckPortHelper());
30723
+ let { port, addr, timeout = DEFAULT_CONNECT_TIMEOUT } = options;
30724
+ try {
30725
+ if (!checkPort(addr === "localhost" ? "127.0.0.1" : addr, port, timeout))
30726
+ throw new Error(`DevServer for '${options.projectName}' is not running on ${port} / ${addr}: \`dev up ${options.projectName}\` to start it.`);
30727
+ } catch (err2) {
30728
+ throw new Error(`DevServer check for '${options.projectName}' on ${port} / ${addr} failed (${err2})`);
30627
30729
  }
30628
- static getIpFromHosts(hostname) {
30629
- try {
30630
- let lines = fs.readFileSync(_DevServerUtils.HOSTS_FILE, "utf8").split(/\r?\n/);
30631
- for (let line of lines) {
30632
- let matches = /^\s*?([^#]+?)\s+([^#]+?)$/.exec(line);
30633
- if (matches && matches.length === 3 && matches[2] === hostname)
30634
- return matches[1];
30635
- }
30636
- } catch (error) {
30637
- console.error("Error reading hosts file:", error);
30638
- }
30639
- throw new Error(`No IP found for hostname: ${hostname}`);
30730
+ }
30731
+ function getCheckPortHelper() {
30732
+ return fallbackCheckPort;
30733
+ }
30734
+ function fallbackCheckPort(address, port, timeout) {
30735
+ return spawnSync("nc", ["-z", "-w", "1", address, port.toString()], {
30736
+ timeout,
30737
+ stdio: "ignore"
30738
+ }).status === 0;
30739
+ }
30740
+
30741
+ // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-2024.js
30742
+ var NON_SHOP_PREFIXES = ["app", "dev", "shopify"], BACKEND_PORT = 8080;
30743
+ function createServer(projectName) {
30744
+ return {
30745
+ host: (options = {}) => host(projectName, options),
30746
+ url: (options = {}) => url(projectName, options)
30747
+ };
30748
+ }
30749
+ function host(projectName, options = {}) {
30750
+ assertCompatibleEnvironment(), (assertRunningOverride || assertRunning2024)(projectName);
30751
+ let prefix = (options.nonstandardHostPrefix || projectName).replace(/_/g, "-");
30752
+ if (projectName === "shopify") {
30753
+ if (prefix.endsWith("-dev-api"))
30754
+ return `${prefix.replace("-dev-api", "")}.dev-api.shop.dev`;
30755
+ if (!NON_SHOP_PREFIXES.includes(prefix))
30756
+ return `${prefix}.my.shop.dev`;
30757
+ }
30758
+ return `${prefix}.shop.dev`;
30759
+ }
30760
+ function url(projectName, options = {}) {
30761
+ return `https://${host(projectName, options)}`;
30762
+ }
30763
+ function assertRunning2024(projectName) {
30764
+ assertConnectable({
30765
+ projectName,
30766
+ addr: getBackendIp(projectName),
30767
+ port: BACKEND_PORT
30768
+ });
30769
+ }
30770
+ function getBackendIp(projectName) {
30771
+ try {
30772
+ let backendIp = resolveBackendHost(projectName);
30773
+ return ni.fromIp(backendIp, { internal: !0, ipVersion: 4 }), backendIp;
30774
+ } catch {
30775
+ throw new Error(`DevServer for '${projectName}' is not running: \`dev up ${projectName}\` to start it.`);
30640
30776
  }
30641
- static getAddrPort2024(name) {
30642
- try {
30643
- let backendIp = _DevServerUtils.resolveBackendHost(name), interfaceName = ni.fromIp(backendIp, {
30644
- internal: !0,
30645
- ipVersion: 4
30646
- });
30647
- return [backendIp, _DevServerUtils.BACKEND_PORT];
30648
- } catch {
30649
- throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30650
- }
30777
+ }
30778
+ function resolveBackendHost(name) {
30779
+ let host4;
30780
+ try {
30781
+ host4 = fs2.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);
30782
+ } catch {
30783
+ host4 = `${name}.root.shopify.dev.internal`;
30651
30784
  }
30652
- static getAddrPort2016(name) {
30653
- try {
30654
- let portContent = fs.readFileSync(`${os.homedir()}/.local/run/services/${name}/server/port`, "utf-8");
30655
- return ["localhost", parseInt(portContent, 10)];
30656
- } catch {
30657
- throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30658
- }
30785
+ try {
30786
+ return getIpFromHosts(host4);
30787
+ } catch {
30788
+ return host4;
30659
30789
  }
30660
- static resolveBackendHost(name) {
30661
- let host;
30662
- try {
30663
- host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);
30664
- } catch {
30665
- host = `${name}.root.shopify.dev.internal`;
30666
- }
30667
- try {
30668
- return _DevServerUtils.getIpFromHosts(host);
30669
- } catch {
30670
- return host;
30671
- }
30790
+ }
30791
+ var assertRunningOverride;
30792
+
30793
+ // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-2016.js
30794
+ init_cjs_shims();
30795
+ import fs3 from "fs";
30796
+ import * as os from "node:os";
30797
+ function createServer2(projectName) {
30798
+ return {
30799
+ host: (options = {}) => host2(projectName, options),
30800
+ url: (options = {}) => url2(projectName, options)
30801
+ };
30802
+ }
30803
+ function host2(projectName, options = {}) {
30804
+ return assertCompatibleEnvironment(), (assertRunningOverride2 || assertRunning2016)(projectName), `${options.nonstandardHostPrefix || projectName}.myshopify.io`;
30805
+ }
30806
+ function url2(projectName, options = {}) {
30807
+ return `https://${host2(projectName, options)}`;
30808
+ }
30809
+ function assertRunning2016(projectName) {
30810
+ let [addr, port] = getAddrPort(projectName);
30811
+ assertConnectable({ projectName, addr, port });
30812
+ }
30813
+ function getAddrPort(name) {
30814
+ try {
30815
+ let portContent = fs3.readFileSync(`${os.homedir()}/.local/run/services/${name}/server/port`, "utf-8");
30816
+ return ["localhost", parseInt(portContent, 10)];
30817
+ } catch {
30818
+ throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
30672
30819
  }
30673
- };
30674
- DevServerUtils.INFERENCE_MODE_SENTINEL = "/opt/dev/misc/dev-server-inference-mode";
30675
- DevServerUtils.BACKEND_PORT = 8080;
30676
- DevServerUtils.CONNECT_TIMEOUT = 100;
30677
- DevServerUtils.HOSTS_FILE = "/etc/hosts";
30820
+ }
30821
+ var assertRunningOverride2;
30822
+
30823
+ // ../cli-kit/dist/public/node/vendor/dev_server/dev-server-spin.js
30824
+ init_cjs_shims();
30825
+ import fs4 from "node:fs";
30826
+ function createServer3(projectName) {
30827
+ return {
30828
+ host: (options = {}) => host3(projectName, options),
30829
+ url: (options = {}) => url3(projectName, options)
30830
+ };
30831
+ }
30832
+ function host3(projectName, { nonstandardHostPrefix } = {}) {
30833
+ assertCompatibleEnvironment();
30834
+ let services = fs4.readdirSync("/run/ports2").filter((file) => file.endsWith(`--${projectName}`));
30835
+ if (services.length === 0)
30836
+ throw new Error(`DevServer for '${projectName}' not present in this spin environment`);
30837
+ if (projectName === "shopify")
30838
+ return `${nonstandardHostPrefix?.replace(/[-_]dev[-_]api$/, "")}.${projectName}.${process.env.SPIN_FQDN}`;
30839
+ let match = new RegExp(`^(.+)${projectName}$`).exec(services[0]), organization = match ? match[1] : "";
30840
+ return `${organization === "shopify--" ? "" : `${organization}`}${projectName}.${process.env.SPIN_FQDN}`;
30841
+ }
30842
+ function url3(projectName, options = {}) {
30843
+ return `https://${host3(projectName, options)}`;
30844
+ }
30845
+
30846
+ // ../cli-kit/dist/public/node/vendor/dev_server/dev-server.js
30678
30847
  var DevServer = class {
30679
- constructor(name) {
30680
- if (!process.env.SPIN && !process.env.USING_DEV)
30681
- throw new Error("DevServer is not supported in this environment");
30682
- if (name === "shopify")
30683
- throw new Error("Use DevServer.core for the 'shopify' project");
30684
- this.name = name;
30685
- }
30686
- url({ nonstandardHostPrefix } = {}) {
30687
- return `https://${this.host({ nonstandardHostPrefix })}`;
30688
- }
30689
- host({ nonstandardHostPrefix } = {}) {
30690
- let prefix = nonstandardHostPrefix || this.name;
30691
- if (process.env.SPIN === "1") {
30692
- let services = fs.readdirSync("/run/ports2").filter((file) => file.endsWith(`--${this.name}`));
30693
- if (services.length === 0)
30694
- throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
30695
- let match = new RegExp(`^(.+)${this.name}$`).exec(services[0]), organization = match ? match[1] : "";
30696
- return `${organization !== "shopify--" ? `${organization}` : ""}${this.name}.${process.env.SPIN_FQDN}`;
30697
- } else return DevServerUtils.inferenceModeAndProjectIsEdition2016(this.name) ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.shop.dev`);
30698
- }
30699
- assertRunningLocally2024() {
30700
- let [addr, port] = DevServerUtils.getAddrPort2024(this.name);
30701
- DevServerUtils.assertConnectable(this.name, addr, port);
30702
- }
30703
- assertRunningLocally2016() {
30704
- let [addr, port] = DevServerUtils.getAddrPort2016(this.name);
30705
- DevServerUtils.assertConnectable(this.name, addr, port);
30848
+ constructor(projectName) {
30849
+ if (this.projectName = projectName, projectName === "shopify")
30850
+ throw new Error("Use `import {DevServerCore}` for the 'shopify' project");
30851
+ this.serverImpl = inferProjectServer(projectName);
30852
+ }
30853
+ host(options) {
30854
+ return this.serverImpl.host(options);
30855
+ }
30856
+ url(options) {
30857
+ return this.serverImpl.url(options);
30706
30858
  }
30707
30859
  }, DevServerCore = class {
30708
30860
  constructor() {
30709
- this.name = "shopify";
30710
- }
30711
- url(prefix) {
30712
- return `https://${this.host(prefix)}`;
30861
+ this.serverImpl = inferProjectServer("shopify");
30713
30862
  }
30714
30863
  host(prefix) {
30715
- if (process.env.SPIN === "1") {
30716
- if (!fs.readdirSync("/run/ports2").find((file) => file.endsWith(`--${this.name}`)))
30717
- throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
30718
- return `${prefix}.${this.name}.${process.env.SPIN_FQDN}`;
30719
- } else return DevServerUtils.inferenceModeAndProjectIsEdition2016("shopify") ? (this.assertRunningLocally2016(), `${prefix}.myshopify.io`) : (this.assertRunningLocally2024(), `${prefix}.my.shop.dev`);
30864
+ return this.serverImpl.host({ nonstandardHostPrefix: prefix });
30720
30865
  }
30721
- assertRunningLocally2024() {
30722
- let [addr, port] = DevServerUtils.getAddrPort2024("shopify");
30723
- DevServerUtils.assertConnectable("shopify", addr, port);
30866
+ url(prefix) {
30867
+ return this.serverImpl.url({ nonstandardHostPrefix: prefix });
30724
30868
  }
30725
- assertRunningLocally2016() {
30726
- let [addr, port] = DevServerUtils.getAddrPort2016("shopify");
30727
- DevServerUtils.assertConnectable("shopify", addr, port);
30869
+ }, INFERENCE_MODE_SENTINEL = "/opt/dev/misc/dev-server-inference-mode";
30870
+ function inferProjectServer(projectName) {
30871
+ return process.env.SPIN === "1" ? createServer3(projectName) : inferenceModeAndProjectIsEdition2016(projectName) ? createServer2(projectName) : createServer(projectName);
30872
+ }
30873
+ function inferenceModeAndProjectIsEdition2016(projectName) {
30874
+ try {
30875
+ fs5.accessSync(INFERENCE_MODE_SENTINEL);
30876
+ try {
30877
+ return fs5.accessSync(`/opt/nginx/etc/manifest/${projectName}/current/edition-2024`), !1;
30878
+ } catch {
30879
+ return !0;
30880
+ }
30881
+ } catch {
30882
+ return !1;
30728
30883
  }
30729
- };
30884
+ }
30730
30885
 
30731
30886
  // ../cli-kit/dist/public/node/context/fqdn.js
30732
30887
  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.");
@@ -31234,12 +31389,12 @@ var INTERNALS2 = Symbol("Response internals"), Response = class _Response extend
31234
31389
  * @param {number} status An optional status code for the response (e.g., 302.)
31235
31390
  * @returns {Response} A Response object.
31236
31391
  */
31237
- static redirect(url, status = 302) {
31392
+ static redirect(url4, status = 302) {
31238
31393
  if (!isRedirect(status))
31239
31394
  throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
31240
31395
  return new _Response(null, {
31241
31396
  headers: {
31242
- location: new URL(url).toString()
31397
+ location: new URL(url4).toString()
31243
31398
  },
31244
31399
  status
31245
31400
  });
@@ -31290,8 +31445,8 @@ var getSearch = (parsedURL) => {
31290
31445
  // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/referrer.js
31291
31446
  init_cjs_shims();
31292
31447
  import { isIP } from "node:net";
31293
- function stripURLForUseAsAReferrer(url, originOnly = !1) {
31294
- return url == null || (url = new URL(url), /^(about|blob|data):$/.test(url.protocol)) ? "no-referrer" : (url.username = "", url.password = "", url.hash = "", originOnly && (url.pathname = "", url.search = ""), url);
31448
+ function stripURLForUseAsAReferrer(url4, originOnly = !1) {
31449
+ return url4 == null || (url4 = new URL(url4), /^(about|blob|data):$/.test(url4.protocol)) ? "no-referrer" : (url4.username = "", url4.password = "", url4.hash = "", originOnly && (url4.pathname = "", url4.search = ""), url4);
31295
31450
  }
31296
31451
  var ReferrerPolicy = /* @__PURE__ */ new Set([
31297
31452
  "",
@@ -31309,14 +31464,14 @@ function validateReferrerPolicy(referrerPolicy) {
31309
31464
  throw new TypeError(`Invalid referrerPolicy: ${referrerPolicy}`);
31310
31465
  return referrerPolicy;
31311
31466
  }
31312
- function isOriginPotentiallyTrustworthy(url) {
31313
- if (/^(http|ws)s:$/.test(url.protocol))
31467
+ function isOriginPotentiallyTrustworthy(url4) {
31468
+ if (/^(http|ws)s:$/.test(url4.protocol))
31314
31469
  return !0;
31315
- let hostIp = url.host.replace(/(^\[)|(]$)/g, ""), hostIPVersion = isIP(hostIp);
31316
- return hostIPVersion === 4 && /^127\./.test(hostIp) || hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp) ? !0 : url.host === "localhost" || url.host.endsWith(".localhost") ? !1 : url.protocol === "file:";
31470
+ let hostIp = url4.host.replace(/(^\[)|(]$)/g, ""), hostIPVersion = isIP(hostIp);
31471
+ return hostIPVersion === 4 && /^127\./.test(hostIp) || hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp) ? !0 : url4.host === "localhost" || url4.host.endsWith(".localhost") ? !1 : url4.protocol === "file:";
31317
31472
  }
31318
- function isUrlPotentiallyTrustworthy(url) {
31319
- return /^about:(blank|srcdoc)$/.test(url) || url.protocol === "data:" || /^(blob|filesystem):$/.test(url.protocol) ? !0 : isOriginPotentiallyTrustworthy(url);
31473
+ function isUrlPotentiallyTrustworthy(url4) {
31474
+ return /^about:(blank|srcdoc)$/.test(url4) || url4.protocol === "data:" || /^(blob|filesystem):$/.test(url4.protocol) ? !0 : isOriginPotentiallyTrustworthy(url4);
31320
31475
  }
31321
31476
  function determineRequestsReferrer(request, { referrerURLCallback, referrerOriginCallback } = {}) {
31322
31477
  if (request.referrer === "no-referrer" || request.referrerPolicy === "")
@@ -31491,11 +31646,11 @@ var AbortError2 = class extends FetchBaseError {
31491
31646
 
31492
31647
  // ../../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/index.js
31493
31648
  var supportedSchemas = /* @__PURE__ */ new Set(["data:", "http:", "https:"]);
31494
- async function fetch(url, options_) {
31649
+ async function fetch(url4, options_) {
31495
31650
  return new Promise((resolve, reject) => {
31496
- let request = new Request(url, options_), { parsedURL, options } = getNodeRequestOptions(request);
31651
+ let request = new Request(url4, options_), { parsedURL, options } = getNodeRequestOptions(request);
31497
31652
  if (!supportedSchemas.has(parsedURL.protocol))
31498
- throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
31653
+ throw new TypeError(`node-fetch cannot load ${url4}. URL scheme "${parsedURL.protocol.replace(/:$/, "")}" is not supported.`);
31499
31654
  if (parsedURL.protocol === "data:") {
31500
31655
  let data = dist_default(request.url), response2 = new Response(data, { headers: { "Content-Type": data.typeFull } });
31501
31656
  resolve(response2);
@@ -31666,25 +31821,76 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
31666
31821
  function formData() {
31667
31822
  return new import_form_data.default();
31668
31823
  }
31669
- async function fetch2(url, init) {
31670
- return runWithTimer("cmd_all_timing_network_ms")(() => simpleRequestWithDebugLog({ url: url.toString(), request: () => fetch(url, init) }));
31671
- }
31672
- async function shopifyFetch(url, init) {
31673
- let sanitizedUrl = sanitizeURL(url.toString()), options = {
31674
- ...init ?? {},
31675
- headers: {
31676
- ...await buildHeaders(),
31677
- ...init?.headers ?? {}
31678
- }
31824
+ function requestMode(preset = "default", env = process.env) {
31825
+ let networkLevelRetryIsSupported = !skipNetworkLevelRetry(env);
31826
+ switch (preset) {
31827
+ case "default":
31828
+ return {
31829
+ useNetworkLevelRetry: networkLevelRetryIsSupported,
31830
+ maxRetryTimeMs: DEFAULT_MAX_TIME_MS,
31831
+ useAbortSignal: !0,
31832
+ timeoutMs: maxRequestTimeForNetworkCallsMs(env)
31833
+ };
31834
+ case "non-blocking":
31835
+ return {
31836
+ useNetworkLevelRetry: !1,
31837
+ useAbortSignal: !0,
31838
+ timeoutMs: maxRequestTimeForNetworkCallsMs(env)
31839
+ };
31840
+ case "slow-request":
31841
+ return {
31842
+ useNetworkLevelRetry: !1,
31843
+ useAbortSignal: !1
31844
+ };
31845
+ }
31846
+ return {
31847
+ ...preset,
31848
+ useNetworkLevelRetry: networkLevelRetryIsSupported && preset.useNetworkLevelRetry
31679
31849
  };
31680
- return outputDebug(outputContent`Sending ${options.method ?? "GET"} request to URL ${sanitizedUrl}
31850
+ }
31851
+ function abortSignalFromRequestBehaviour(behaviour) {
31852
+ let signal;
31853
+ return behaviour.useAbortSignal === !0 ? signal = AbortSignal.timeout(behaviour.timeoutMs) : behaviour.useAbortSignal && typeof behaviour.useAbortSignal == "function" ? signal = behaviour.useAbortSignal() : behaviour.useAbortSignal && (signal = behaviour.useAbortSignal), signal;
31854
+ }
31855
+ async function innerFetch({ url: url4, behaviour, init, logRequest, useHttpsAgent }) {
31856
+ logRequest && outputDebug(outputContent`Sending ${init?.method ?? "GET"} request to URL ${sanitizeURL(url4.toString())}
31681
31857
  With request headers:
31682
- ${sanitizedHeadersOutput(options.headers ?? {})}
31683
- `), runWithTimer("cmd_all_timing_network_ms")(async () => simpleRequestWithDebugLog({
31684
- url: url.toString(),
31685
- request: async () => fetch(url, { ...init, agent: await httpsAgent() })
31858
+ ${sanitizedHeadersOutput(init?.headers ?? {})}
31859
+ `);
31860
+ let agent;
31861
+ useHttpsAgent && (agent = await httpsAgent());
31862
+ let request = async () => {
31863
+ let signal = abortSignalFromRequestBehaviour(behaviour);
31864
+ return init?.signal && (signal = init.signal), fetch(url4, { ...init, agent, signal });
31865
+ };
31866
+ return runWithTimer("cmd_all_timing_network_ms")(async () => simpleRequestWithDebugLog({
31867
+ url: url4.toString(),
31868
+ request,
31869
+ ...behaviour
31686
31870
  }));
31687
31871
  }
31872
+ async function fetch2(url4, init, preferredBehaviour) {
31873
+ let options = {
31874
+ url: url4,
31875
+ init,
31876
+ logRequest: !1,
31877
+ useHttpsAgent: !1,
31878
+ // all special behaviours are disabled by default
31879
+ behaviour: requestMode(preferredBehaviour || "non-blocking")
31880
+ };
31881
+ return innerFetch(options);
31882
+ }
31883
+ async function shopifyFetch(url4, init, preferredBehaviour) {
31884
+ let options = {
31885
+ url: url4,
31886
+ init,
31887
+ logRequest: !0,
31888
+ useHttpsAgent: !0,
31889
+ // special behaviours enabled by default
31890
+ behaviour: preferredBehaviour ? requestMode(preferredBehaviour) : requestMode()
31891
+ };
31892
+ return innerFetch(options);
31893
+ }
31688
31894
 
31689
31895
  // ../cli-kit/dist/public/node/result.js
31690
31896
  init_cjs_shims();
@@ -31955,9 +32161,9 @@ If you're the store owner, then you need to log in to the store directly using t
31955
32161
  return error === "invalid_grant" ? new InvalidGrantError() : error === "invalid_request" ? new InvalidRequestError() : error === "invalid_target" ? new InvalidTargetError(invalidTargetErrorMessage) : new AbortError(error);
31956
32162
  }
31957
32163
  async function tokenRequest(params) {
31958
- let fqdn = await identityFqdn(), url = new URL(`https://${fqdn}/oauth/token`);
31959
- url.search = new URLSearchParams(Object.entries(params)).toString();
31960
- let res = await shopifyFetch(url.href, { method: "POST" }), payload = await res.json();
32164
+ let fqdn = await identityFqdn(), url4 = new URL(`https://${fqdn}/oauth/token`);
32165
+ url4.search = new URLSearchParams(Object.entries(params)).toString();
32166
+ let res = await shopifyFetch(url4.href, { method: "POST" }), payload = await res.json();
31961
32167
  return res.ok ? ok(payload) : err(payload.error);
31962
32168
  }
31963
32169
  function buildIdentityToken(result, existingUserId) {
@@ -32002,7 +32208,7 @@ async function remove() {
32002
32208
  // ../cli-kit/dist/private/node/session/device-authorization.js
32003
32209
  init_cjs_shims();
32004
32210
  async function requestDeviceAuthorization(scopes) {
32005
- let fqdn = await identityFqdn(), queryParams = { client_id: clientId(), scope: scopes.join(" ") }, url = `https://${fqdn}/oauth/device_authorization`, jsonResult = await (await shopifyFetch(url, {
32211
+ let fqdn = await identityFqdn(), queryParams = { client_id: clientId(), scope: scopes.join(" ") }, url4 = `https://${fqdn}/oauth/device_authorization`, jsonResult = await (await shopifyFetch(url4, {
32006
32212
  method: "POST",
32007
32213
  headers: { "Content-type": "application/x-www-form-urlencoded" },
32008
32214
  body: convertRequestToParams(queryParams)
@@ -32010,13 +32216,13 @@ async function requestDeviceAuthorization(scopes) {
32010
32216
  if (outputDebug(outputContent`Received device authorization code: ${outputToken.json(jsonResult)}`), !jsonResult.device_code || !jsonResult.verification_uri_complete)
32011
32217
  throw new BugError("Failed to start authorization process");
32012
32218
  if (outputInfo(`
32013
- To run this command, log in to Shopify.`), !isTTY())
32219
+ To run this command, log in to Shopify.`), isCI())
32014
32220
  throw new AbortError("Authorization is required to continue, but the current environment does not support interactive prompts.", "To resolve this, specify credentials in your environment, or run the command in an interactive environment such as your local terminal.");
32015
32221
  outputInfo(outputContent`User verification code: ${jsonResult.user_code}`);
32016
32222
  let linkToken = outputToken.link(jsonResult.verification_uri_complete), cloudMessage = () => {
32017
32223
  outputInfo(outputContent`👉 Open this link to start the auth process: ${linkToken}`);
32018
32224
  };
32019
- return isCloudEnvironment() ? cloudMessage() : (outputInfo("\u{1F449} Press any key to open the login page on your browser"), await keypress(), await openURL(jsonResult.verification_uri_complete) ? outputInfo(outputContent`Opened link to start the auth process: ${linkToken}`) : cloudMessage()), {
32225
+ return isCloudEnvironment() || !isTTY() ? cloudMessage() : (outputInfo("\u{1F449} Press any key to open the login page on your browser"), await keypress(), await openURL(jsonResult.verification_uri_complete) ? outputInfo(outputContent`Opened link to start the auth process: ${linkToken}`) : cloudMessage()), {
32020
32226
  deviceCode: jsonResult.device_code,
32021
32227
  userCode: jsonResult.user_code,
32022
32228
  verificationUri: jsonResult.verification_uri,
@@ -32280,7 +32486,10 @@ export {
32280
32486
  require_mime_types,
32281
32487
  FetchError,
32282
32488
  formData,
32489
+ requestMode,
32490
+ abortSignalFromRequestBehaviour,
32283
32491
  fetch2 as fetch,
32492
+ shopifyFetch,
32284
32493
  z,
32285
32494
  partnersFqdn,
32286
32495
  appManagementFqdn,
@@ -32317,4 +32526,4 @@ mime-types/index.js:
32317
32526
  * MIT Licensed
32318
32527
  *)
32319
32528
  */
32320
- //# sourceMappingURL=chunk-DH5OC5ON.js.map
32529
+ //# sourceMappingURL=chunk-PC72P66L.js.map