create-cloudflare 2.70.1 → 2.70.2

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 (2) hide show
  1. package/dist/cli.js +1830 -1543
  2. package/package.json +6 -6
package/dist/cli.js CHANGED
@@ -32661,8 +32661,8 @@ var require_index_688c5d50 = __commonJS({
32661
32661
  var pathReservations = () => {
32662
32662
  const queues = /* @__PURE__ */ new Map();
32663
32663
  const reservations = /* @__PURE__ */ new Map();
32664
- const { join: join9 } = path__default["default"];
32665
- const getDirs = (path7) => join9(path7).split(/[\\/]/).slice(0, -1).reduce((set, path8) => set.length ? set.concat(join9(set[set.length - 1], path8)) : [path8], []);
32664
+ const { join: join10 } = path__default["default"];
32665
+ const getDirs = (path7) => join10(path7).split(/[\\/]/).slice(0, -1).reduce((set, path8) => set.length ? set.concat(join10(set[set.length - 1], path8)) : [path8], []);
32666
32666
  const running = /* @__PURE__ */ new Set();
32667
32667
  const getQueues = (fn) => {
32668
32668
  const res = reservations.get(fn);
@@ -47871,10 +47871,10 @@ var require_stringify2 = __commonJS({
47871
47871
  replacer = null;
47872
47872
  indent2 = EMPTY;
47873
47873
  };
47874
- var join9 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY;
47874
+ var join10 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY;
47875
47875
  var join_content = (inside, value, gap) => {
47876
47876
  const comment = process_comments(value, PREFIX_BEFORE, gap + indent2, true);
47877
- return join9(comment, inside, gap);
47877
+ return join10(comment, inside, gap);
47878
47878
  };
47879
47879
  var array_stringify = (value, gap) => {
47880
47880
  const deeper_gap = gap + indent2;
@@ -47885,7 +47885,7 @@ var require_stringify2 = __commonJS({
47885
47885
  if (i !== 0) {
47886
47886
  inside += COMMA;
47887
47887
  }
47888
- const before = join9(
47888
+ const before = join10(
47889
47889
  after_comma,
47890
47890
  process_comments(value, BEFORE(i), deeper_gap),
47891
47891
  deeper_gap
@@ -47895,7 +47895,7 @@ var require_stringify2 = __commonJS({
47895
47895
  inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
47896
47896
  after_comma = process_comments(value, AFTER(i), deeper_gap);
47897
47897
  }
47898
- inside += join9(
47898
+ inside += join10(
47899
47899
  after_comma,
47900
47900
  process_comments(value, PREFIX_AFTER, deeper_gap),
47901
47901
  deeper_gap
@@ -47920,7 +47920,7 @@ var require_stringify2 = __commonJS({
47920
47920
  inside += COMMA;
47921
47921
  }
47922
47922
  first = false;
47923
- const before = join9(
47923
+ const before = join10(
47924
47924
  after_comma,
47925
47925
  process_comments(value, BEFORE(key), deeper_gap),
47926
47926
  deeper_gap
@@ -47930,7 +47930,7 @@ var require_stringify2 = __commonJS({
47930
47930
  after_comma = process_comments(value, AFTER(key), deeper_gap);
47931
47931
  };
47932
47932
  keys.forEach(iteratee);
47933
- inside += join9(
47933
+ inside += join10(
47934
47934
  after_comma,
47935
47935
  process_comments(value, PREFIX_AFTER, deeper_gap),
47936
47936
  deeper_gap
@@ -52225,7 +52225,7 @@ var require_util8 = __commonJS({
52225
52225
  return path6;
52226
52226
  }
52227
52227
  exports2.normalize = normalize2;
52228
- function join9(aRoot, aPath) {
52228
+ function join10(aRoot, aPath) {
52229
52229
  if (aRoot === "") {
52230
52230
  aRoot = ".";
52231
52231
  }
@@ -52257,7 +52257,7 @@ var require_util8 = __commonJS({
52257
52257
  }
52258
52258
  return joined;
52259
52259
  }
52260
- exports2.join = join9;
52260
+ exports2.join = join10;
52261
52261
  exports2.isAbsolute = function(aPath) {
52262
52262
  return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
52263
52263
  };
@@ -52430,7 +52430,7 @@ var require_util8 = __commonJS({
52430
52430
  parsed.path = parsed.path.substring(0, index + 1);
52431
52431
  }
52432
52432
  }
52433
- sourceURL = join9(urlGenerate(parsed), sourceURL);
52433
+ sourceURL = join10(urlGenerate(parsed), sourceURL);
52434
52434
  }
52435
52435
  return normalize2(sourceURL);
52436
52436
  }
@@ -73902,8 +73902,8 @@ __export(cli_exports, {
73902
73902
  setupProjectDirectory: () => setupProjectDirectory
73903
73903
  });
73904
73904
  module.exports = __toCommonJS(cli_exports);
73905
- var import_node_fs21 = require("node:fs");
73906
- var import_node_path24 = require("node:path");
73905
+ var import_node_fs22 = require("node:fs");
73906
+ var import_node_path25 = require("node:path");
73907
73907
  var import_node_process14 = require("node:process");
73908
73908
 
73909
73909
  // ../../node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
@@ -83612,14 +83612,24 @@ __export2(mod_esm_exports, {
83612
83612
  var import_mod_cjs = __toESM2(require_mod_cjs3(), 1);
83613
83613
  __reExport2(mod_esm_exports, __toESM2(require_mod_cjs3(), 1));
83614
83614
  var mod_esm_default = import_mod_cjs.default;
83615
+ function getGlobalConfigPath({
83616
+ appName = "wrangler",
83617
+ leadingDot = true,
83618
+ useLegacyHomeDir = true
83619
+ } = {}) {
83620
+ const dirName = `${leadingDot ? "." : ""}${appName}`;
83621
+ const configDir = mod_esm_default(dirName).config();
83622
+ if (useLegacyHomeDir) {
83623
+ const legacyConfigDir = import_node_path2.default.join(import_node_os2.default.homedir(), dirName);
83624
+ if (isDirectory(legacyConfigDir)) {
83625
+ return legacyConfigDir;
83626
+ }
83627
+ }
83628
+ return configDir;
83629
+ }
83630
+ __name(getGlobalConfigPath, "getGlobalConfigPath");
83615
83631
  function getGlobalWranglerConfigPath() {
83616
- const configDir = mod_esm_default(".wrangler").config();
83617
- const legacyConfigDir = import_node_path2.default.join(import_node_os2.default.homedir(), ".wrangler");
83618
- if (isDirectory(legacyConfigDir)) {
83619
- return legacyConfigDir;
83620
- } else {
83621
- return configDir;
83622
- }
83632
+ return getGlobalConfigPath();
83623
83633
  }
83624
83634
  __name(getGlobalWranglerConfigPath, "getGlobalWranglerConfigPath");
83625
83635
  function getBooleanEnvironmentVariableFactory(options) {
@@ -90010,7 +90020,7 @@ __name(maybeThrowFriendlyError, "maybeThrowFriendlyError");
90010
90020
  function logHeaders(headers, logger) {
90011
90021
  const clone = cloneHeaders(headers);
90012
90022
  clone.delete("Authorization");
90013
- logger.debugWithSanitization(
90023
+ logger.debugWithSanitization?.(
90014
90024
  "HEADERS:",
90015
90025
  JSON.stringify(Object.fromEntries(clone), null, 2)
90016
90026
  );
@@ -90031,11 +90041,11 @@ async function performApiFetchBase(complianceConfig, resource, init = {}, userAg
90031
90041
  logger.debug(
90032
90042
  `-- START CF API REQUEST: ${method} ${getCloudflareApiBaseUrl(complianceConfig)}${resource}`
90033
90043
  );
90034
- logger.debugWithSanitization("QUERY STRING:", queryString);
90044
+ logger.debugWithSanitization?.("QUERY STRING:", queryString);
90035
90045
  logHeaders(headers, logger);
90036
- logger.debugWithSanitization("INIT:", JSON.stringify({ ...init }, null, 2));
90046
+ logger.debugWithSanitization?.("INIT:", JSON.stringify({ ...init }, null, 2));
90037
90047
  if (init.body instanceof import_undici.FormData) {
90038
- logger.debugWithSanitization(
90048
+ logger.debugWithSanitization?.(
90039
90049
  "BODY:",
90040
90050
  await new import_undici.Response(init.body).text(),
90041
90051
  null,
@@ -90073,7 +90083,7 @@ async function fetchInternalBase(complianceConfig, resource, init = {}, userAgen
90073
90083
  response.status
90074
90084
  );
90075
90085
  logHeaders(response.headers, logger);
90076
- logger.debugWithSanitization("RESPONSE:", jsonText);
90086
+ logger.debugWithSanitization?.("RESPONSE:", jsonText);
90077
90087
  logger.debug("-- END CF API RESPONSE");
90078
90088
  if (!jsonText && (response.status === 204 || response.status === 205)) {
90079
90089
  return {
@@ -90312,6 +90322,27 @@ function throwWAFBlockError(headers, method, resource, status2, statusText) {
90312
90322
  });
90313
90323
  }
90314
90324
  __name(throwWAFBlockError, "throwWAFBlockError");
90325
+ async function fetchKVGetValueBase(complianceConfig, accountId, namespaceId, key, userAgent, logger, credentials) {
90326
+ const headers = new import_undici.Headers();
90327
+ addAuthorizationHeader(headers, credentials);
90328
+ headers.set("User-Agent", userAgent);
90329
+ maybeAddTraceHeader(headers);
90330
+ const resource = `${getCloudflareApiBaseUrl(complianceConfig)}/accounts/${accountId}/storage/kv/namespaces/${namespaceId}/values/${key}`;
90331
+ logger.debug(`-- START CF API REQUEST: GET ${resource}`);
90332
+ logger.debug("-- END CF API REQUEST");
90333
+ const response = await (0, import_undici.fetch)(resource, {
90334
+ method: "GET",
90335
+ headers
90336
+ });
90337
+ if (response.ok) {
90338
+ return await response.arrayBuffer();
90339
+ } else {
90340
+ throw new Error(
90341
+ `Failed to fetch ${resource} - ${response.status}: ${response.statusText}`
90342
+ );
90343
+ }
90344
+ }
90345
+ __name(fetchKVGetValueBase, "fetchKVGetValueBase");
90315
90346
  function hasCursor(result_info) {
90316
90347
  const cursor = result_info?.cursor;
90317
90348
  return cursor !== void 0 && cursor !== null && cursor !== "";
@@ -97392,7 +97423,7 @@ var Yargs = YargsFactory(esm_default2);
97392
97423
  var yargs_default = Yargs;
97393
97424
 
97394
97425
  // package.json
97395
- var version = "2.70.1";
97426
+ var version = "2.70.2";
97396
97427
 
97397
97428
  // src/metrics.ts
97398
97429
  var import_node_async_hooks = require("node:async_hooks");
@@ -97841,10 +97872,10 @@ var runTelemetryCommand = (action) => {
97841
97872
  };
97842
97873
 
97843
97874
  // src/templates.ts
97844
- var import_node_fs18 = require("node:fs");
97875
+ var import_node_fs19 = require("node:fs");
97845
97876
  var import_promises7 = require("node:fs/promises");
97846
97877
  var import_node_os7 = require("node:os");
97847
- var import_node_path19 = require("node:path");
97878
+ var import_node_path20 = require("node:path");
97848
97879
  var import_deepmerge = __toESM(require_cjs());
97849
97880
  var import_degit = __toESM(require_dist());
97850
97881
 
@@ -97852,8 +97883,8 @@ var import_degit = __toESM(require_dist());
97852
97883
  var import_haikunator = __toESM(require_dist_web());
97853
97884
 
97854
97885
  // src/helpers/packages.ts
97855
- var import_node_fs7 = require("node:fs");
97856
- var import_node_path8 = __toESM(require("node:path"));
97886
+ var import_node_fs9 = require("node:fs");
97887
+ var import_node_path10 = __toESM(require("node:path"));
97857
97888
 
97858
97889
  // ../cli/dist/packages.mjs
97859
97890
  var import_node_path7 = __toESM(require("node:path"), 1);
@@ -97957,1580 +97988,1828 @@ async function installWrangler(packageManager, isWorkspaceRoot) {
97957
97988
 
97958
97989
  // src/helpers/packages.ts
97959
97990
  var import_undici3 = __toESM(require_undici());
97960
- var installPackages2 = async (packages, config49 = {}) => {
97961
- const { npm: npm25 } = detectPackageManager();
97962
- return installPackages(npm25, packages, config49);
97963
- };
97964
- async function installWrangler2() {
97965
- const { npm: npm25 } = detectPackageManager();
97966
- return installWrangler(npm25, false);
97967
- }
97968
- var npmInstall = async (ctx) => {
97969
- const nodeModulesPath = import_node_path8.default.join(ctx.project.path, "node_modules");
97970
- if ((0, import_node_fs7.existsSync)(nodeModulesPath)) {
97971
- return;
97972
- }
97973
- const { npm: npm25 } = detectPackageManager();
97974
- await runCommand([npm25, "install"], {
97975
- silent: true,
97976
- startText: "Installing dependencies",
97977
- doneText: `${brandColor("installed")} ${dim(`via \`${npm25} install\``)}`
97978
- });
97979
- };
97980
- async function getLatestPackageVersion(packageSpecifier) {
97981
- const resp = await (0, import_undici3.fetch)(`https://registry.npmjs.org/${packageSpecifier}`);
97982
- const npmInfo = await resp.json();
97983
- return npmInfo["dist-tags"].latest;
97984
- }
97985
-
97986
- // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
97987
- var import_node_process13 = __toESM(require("node:process"), 1);
97988
- var import_node_path9 = __toESM(require("node:path"), 1);
97989
- var import_node_url2 = require("node:url");
97990
- var import_node_child_process8 = __toESM(require("node:child_process"), 1);
97991
- var import_promises5 = __toESM(require("node:fs/promises"), 1);
97992
-
97993
- // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
97994
- var import_node_util3 = require("node:util");
97995
- var import_node_child_process3 = __toESM(require("node:child_process"), 1);
97996
- var import_promises4 = __toESM(require("node:fs/promises"), 1);
97997
97991
 
97998
- // ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
97999
- var import_node_process7 = __toESM(require("node:process"), 1);
98000
- var import_node_os5 = __toESM(require("node:os"), 1);
98001
- var import_node_fs10 = __toESM(require("node:fs"), 1);
97992
+ // src/helpers/pnpmBuildApprovals.ts
97993
+ var import_node_fs8 = require("node:fs");
97994
+ var import_node_path9 = require("node:path");
98002
97995
 
98003
- // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
98004
- var import_node_fs9 = __toESM(require("node:fs"), 1);
97996
+ // src/helpers/files.ts
97997
+ var import_node_fs7 = __toESM(require("node:fs"));
97998
+ var import_node_path8 = require("node:path");
97999
+ var import_comment_json = __toESM(require_src3());
98005
98000
 
98006
- // ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
98007
- var import_node_fs8 = __toESM(require("node:fs"), 1);
98008
- var isDockerCached;
98009
- function hasDockerEnv() {
98010
- try {
98011
- import_node_fs8.default.statSync("/.dockerenv");
98012
- return true;
98013
- } catch {
98014
- return false;
98015
- }
98016
- }
98017
- function hasDockerCGroup() {
98018
- try {
98019
- return import_node_fs8.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
98020
- } catch {
98021
- return false;
98022
- }
98001
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/error.js
98002
+ function getLineColFromPtr2(string, ptr) {
98003
+ let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
98004
+ return [lines.length, lines.pop().length + 1];
98023
98005
  }
98024
- function isDocker() {
98025
- if (isDockerCached === void 0) {
98026
- isDockerCached = hasDockerEnv() || hasDockerCGroup();
98006
+ function makeCodeBlock2(string, line, column) {
98007
+ let lines = string.split(/\r\n|\n|\r/g);
98008
+ let codeblock = "";
98009
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
98010
+ for (let i = line - 1; i <= line + 1; i++) {
98011
+ let l = lines[i - 1];
98012
+ if (!l)
98013
+ continue;
98014
+ codeblock += i.toString().padEnd(numberLen, " ");
98015
+ codeblock += ": ";
98016
+ codeblock += l;
98017
+ codeblock += "\n";
98018
+ if (i === line) {
98019
+ codeblock += " ".repeat(numberLen + column + 2);
98020
+ codeblock += "^\n";
98021
+ }
98027
98022
  }
98028
- return isDockerCached;
98023
+ return codeblock;
98029
98024
  }
98025
+ var TomlError2 = class extends Error {
98026
+ line;
98027
+ column;
98028
+ codeblock;
98029
+ constructor(message, options) {
98030
+ const [line, column] = getLineColFromPtr2(options.toml, options.ptr);
98031
+ const codeblock = makeCodeBlock2(options.toml, line, column);
98032
+ super(`Invalid TOML document: ${message}
98030
98033
 
98031
- // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
98032
- var cachedResult;
98033
- var hasContainerEnv = () => {
98034
- try {
98035
- import_node_fs9.default.statSync("/run/.containerenv");
98036
- return true;
98037
- } catch {
98038
- return false;
98034
+ ${codeblock}`, options);
98035
+ this.line = line;
98036
+ this.column = column;
98037
+ this.codeblock = codeblock;
98039
98038
  }
98040
98039
  };
98041
- function isInsideContainer() {
98042
- if (cachedResult === void 0) {
98043
- cachedResult = hasContainerEnv() || isDocker();
98044
- }
98045
- return cachedResult;
98046
- }
98047
98040
 
98048
- // ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
98049
- var isWsl = () => {
98050
- if (import_node_process7.default.platform !== "linux") {
98051
- return false;
98052
- }
98053
- if (import_node_os5.default.release().toLowerCase().includes("microsoft")) {
98054
- if (isInsideContainer()) {
98055
- return false;
98041
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/util.js
98042
+ function isEscaped2(str, ptr) {
98043
+ let i = 0;
98044
+ while (str[ptr - ++i] === "\\")
98045
+ ;
98046
+ return --i && i % 2;
98047
+ }
98048
+ function indexOfNewline2(str, start = 0, end = str.length) {
98049
+ let idx = str.indexOf("\n", start);
98050
+ if (str[idx - 1] === "\r")
98051
+ idx--;
98052
+ return idx <= end ? idx : -1;
98053
+ }
98054
+ function skipComment2(str, ptr) {
98055
+ for (let i = ptr; i < str.length; i++) {
98056
+ let c2 = str[i];
98057
+ if (c2 === "\n")
98058
+ return i;
98059
+ if (c2 === "\r" && str[i + 1] === "\n")
98060
+ return i + 1;
98061
+ if (c2 < " " && c2 !== " " || c2 === "\x7F") {
98062
+ throw new TomlError2("control characters are not allowed in comments", {
98063
+ toml: str,
98064
+ ptr
98065
+ });
98056
98066
  }
98057
- return true;
98058
98067
  }
98059
- try {
98060
- return import_node_fs10.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
98061
- } catch {
98062
- return false;
98068
+ return str.length;
98069
+ }
98070
+ function skipVoid2(str, ptr, banNewLines, banComments) {
98071
+ let c2;
98072
+ while ((c2 = str[ptr]) === " " || c2 === " " || !banNewLines && (c2 === "\n" || c2 === "\r" && str[ptr + 1] === "\n"))
98073
+ ptr++;
98074
+ return banComments || c2 !== "#" ? ptr : skipVoid2(str, skipComment2(str, ptr), banNewLines);
98075
+ }
98076
+ function skipUntil2(str, ptr, sep, end, banNewLines = false) {
98077
+ if (!end) {
98078
+ ptr = indexOfNewline2(str, ptr);
98079
+ return ptr < 0 ? str.length : ptr;
98063
98080
  }
98064
- };
98065
- var is_wsl_default = import_node_process7.default.env.__IS_WSL_TEST__ ? isWsl : isWsl();
98066
-
98067
- // ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
98068
- var import_node_process8 = __toESM(require("node:process"), 1);
98069
- var import_node_buffer = require("node:buffer");
98070
- var import_node_util2 = require("node:util");
98071
- var import_node_child_process2 = __toESM(require("node:child_process"), 1);
98072
- var execFile = (0, import_node_util2.promisify)(import_node_child_process2.default.execFile);
98073
- var powerShellPath = () => `${import_node_process8.default.env.SYSTEMROOT || import_node_process8.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
98074
- var executePowerShell = async (command2, options = {}) => {
98075
- const {
98076
- powerShellPath: psPath,
98077
- ...execFileOptions
98078
- } = options;
98079
- const encodedCommand = executePowerShell.encodeCommand(command2);
98080
- return execFile(
98081
- psPath ?? powerShellPath(),
98082
- [
98083
- ...executePowerShell.argumentsPrefix,
98084
- encodedCommand
98085
- ],
98086
- {
98087
- encoding: "utf8",
98088
- ...execFileOptions
98089
- }
98090
- );
98091
- };
98092
- executePowerShell.argumentsPrefix = [
98093
- "-NoProfile",
98094
- "-NonInteractive",
98095
- "-ExecutionPolicy",
98096
- "Bypass",
98097
- "-EncodedCommand"
98098
- ];
98099
- executePowerShell.encodeCommand = (command2) => import_node_buffer.Buffer.from(command2, "utf16le").toString("base64");
98100
- executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
98101
-
98102
- // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
98103
- function parseMountPointFromConfig(content) {
98104
- for (const line of content.split("\n")) {
98105
- if (/^\s*#/.test(line)) {
98106
- continue;
98081
+ for (let i = ptr; i < str.length; i++) {
98082
+ let c2 = str[i];
98083
+ if (c2 === "#") {
98084
+ i = indexOfNewline2(str, i);
98085
+ } else if (c2 === sep) {
98086
+ return i + 1;
98087
+ } else if (c2 === end || banNewLines && (c2 === "\n" || c2 === "\r" && str[i + 1] === "\n")) {
98088
+ return i;
98107
98089
  }
98108
- const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
98109
- if (!match) {
98110
- continue;
98090
+ }
98091
+ throw new TomlError2("cannot find end of structure", {
98092
+ toml: str,
98093
+ ptr
98094
+ });
98095
+ }
98096
+ function getStringEnd2(str, seek) {
98097
+ let first = str[seek];
98098
+ let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
98099
+ seek += target.length - 1;
98100
+ do
98101
+ seek = str.indexOf(target, ++seek);
98102
+ while (seek > -1 && first !== "'" && isEscaped2(str, seek));
98103
+ if (seek > -1) {
98104
+ seek += target.length;
98105
+ if (target.length > 1) {
98106
+ if (str[seek] === first)
98107
+ seek++;
98108
+ if (str[seek] === first)
98109
+ seek++;
98111
98110
  }
98112
- return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
98113
98111
  }
98112
+ return seek;
98114
98113
  }
98115
98114
 
98116
- // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
98117
- var execFile2 = (0, import_node_util3.promisify)(import_node_child_process3.default.execFile);
98118
- var wslDrivesMountPoint = /* @__PURE__ */ (() => {
98119
- const defaultMountPoint = "/mnt/";
98120
- let mountPoint;
98121
- return async function() {
98122
- if (mountPoint) {
98123
- return mountPoint;
98124
- }
98125
- const configFilePath = "/etc/wsl.conf";
98126
- let isConfigFileExists = false;
98127
- try {
98128
- await import_promises4.default.access(configFilePath, import_promises4.constants.F_OK);
98129
- isConfigFileExists = true;
98130
- } catch {
98131
- }
98132
- if (!isConfigFileExists) {
98133
- return defaultMountPoint;
98134
- }
98135
- const configContent = await import_promises4.default.readFile(configFilePath, { encoding: "utf8" });
98136
- const parsedMountPoint = parseMountPointFromConfig(configContent);
98137
- if (parsedMountPoint === void 0) {
98138
- return defaultMountPoint;
98115
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/date.js
98116
+ var DATE_TIME_RE2 = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
98117
+ var TomlDate2 = class _TomlDate2 extends Date {
98118
+ #hasDate = false;
98119
+ #hasTime = false;
98120
+ #offset = null;
98121
+ constructor(date) {
98122
+ let hasDate = true;
98123
+ let hasTime = true;
98124
+ let offset = "Z";
98125
+ if (typeof date === "string") {
98126
+ let match = date.match(DATE_TIME_RE2);
98127
+ if (match) {
98128
+ if (!match[1]) {
98129
+ hasDate = false;
98130
+ date = `0000-01-01T${date}`;
98131
+ }
98132
+ hasTime = !!match[2];
98133
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
98134
+ if (match[2] && +match[2] > 23) {
98135
+ date = "";
98136
+ } else {
98137
+ offset = match[3] || null;
98138
+ date = date.toUpperCase();
98139
+ if (!offset && hasTime)
98140
+ date += "Z";
98141
+ }
98142
+ } else {
98143
+ date = "";
98144
+ }
98139
98145
  }
98140
- mountPoint = parsedMountPoint;
98141
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
98142
- return mountPoint;
98143
- };
98144
- })();
98145
- var powerShellPathFromWsl = async () => {
98146
- const mountPoint = await wslDrivesMountPoint();
98147
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
98148
- };
98149
- var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
98150
- var canAccessPowerShellPromise;
98151
- var canAccessPowerShell = async () => {
98152
- canAccessPowerShellPromise ??= (async () => {
98153
- try {
98154
- const psPath = await powerShellPath2();
98155
- await import_promises4.default.access(psPath, import_promises4.constants.X_OK);
98156
- return true;
98157
- } catch {
98158
- return false;
98146
+ super(date);
98147
+ if (!isNaN(this.getTime())) {
98148
+ this.#hasDate = hasDate;
98149
+ this.#hasTime = hasTime;
98150
+ this.#offset = offset;
98159
98151
  }
98160
- })();
98161
- return canAccessPowerShellPromise;
98162
- };
98163
- var wslDefaultBrowser = async () => {
98164
- const psPath = await powerShellPath2();
98165
- const command2 = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
98166
- const { stdout: stdout2 } = await executePowerShell(command2, { powerShellPath: psPath });
98167
- return stdout2.trim();
98168
- };
98169
- var convertWslPathToWindows = async (path6) => {
98170
- if (/^[a-z]+:\/\//i.test(path6)) {
98171
- return path6;
98172
98152
  }
98173
- try {
98174
- const { stdout: stdout2 } = await execFile2("wslpath", ["-aw", path6], { encoding: "utf8" });
98175
- return stdout2.trim();
98176
- } catch {
98177
- return path6;
98153
+ isDateTime() {
98154
+ return this.#hasDate && this.#hasTime;
98178
98155
  }
98179
- };
98180
-
98181
- // ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
98182
- function defineLazyProperty(object, propertyName, valueGetter) {
98183
- const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
98184
- Object.defineProperty(object, propertyName, {
98185
- configurable: true,
98186
- enumerable: true,
98187
- get() {
98188
- const result = valueGetter();
98189
- define2(result);
98190
- return result;
98191
- },
98192
- set(value) {
98193
- define2(value);
98194
- }
98195
- });
98196
- return object;
98197
- }
98198
-
98199
- // ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/index.js
98200
- var import_node_util7 = require("node:util");
98201
- var import_node_process11 = __toESM(require("node:process"), 1);
98202
- var import_node_child_process7 = require("node:child_process");
98203
-
98204
- // ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
98205
- var import_node_util4 = require("node:util");
98206
- var import_node_process9 = __toESM(require("node:process"), 1);
98207
- var import_node_child_process4 = require("node:child_process");
98208
- var execFileAsync = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
98209
- async function defaultBrowserId() {
98210
- if (import_node_process9.default.platform !== "darwin") {
98211
- throw new Error("macOS only");
98156
+ isLocal() {
98157
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
98212
98158
  }
98213
- const { stdout: stdout2 } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
98214
- const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout2);
98215
- const browserId = match?.groups.id ?? "com.apple.Safari";
98216
- if (browserId === "com.apple.safari") {
98217
- return "com.apple.Safari";
98159
+ isDate() {
98160
+ return this.#hasDate && !this.#hasTime;
98218
98161
  }
98219
- return browserId;
98220
- }
98221
-
98222
- // ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
98223
- var import_node_process10 = __toESM(require("node:process"), 1);
98224
- var import_node_util5 = require("node:util");
98225
- var import_node_child_process5 = require("node:child_process");
98226
- var execFileAsync2 = (0, import_node_util5.promisify)(import_node_child_process5.execFile);
98227
- async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
98228
- if (import_node_process10.default.platform !== "darwin") {
98229
- throw new Error("macOS only");
98162
+ isTime() {
98163
+ return this.#hasTime && !this.#hasDate;
98230
98164
  }
98231
- const outputArguments = humanReadableOutput ? [] : ["-ss"];
98232
- const execOptions = {};
98233
- if (signal) {
98234
- execOptions.signal = signal;
98165
+ isValid() {
98166
+ return this.#hasDate || this.#hasTime;
98235
98167
  }
98236
- const { stdout: stdout2 } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
98237
- return stdout2.trim();
98238
- }
98239
-
98240
- // ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
98241
- async function bundleName(bundleId) {
98242
- return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
98243
- tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
98244
- }
98245
-
98246
- // ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/windows.js
98247
- var import_node_util6 = require("node:util");
98248
- var import_node_child_process6 = require("node:child_process");
98249
- var execFileAsync3 = (0, import_node_util6.promisify)(import_node_child_process6.execFile);
98250
- var windowsBrowserProgIds = {
98251
- MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
98252
- // The missing `L` is correct.
98253
- MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
98254
- MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
98255
- AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
98256
- ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
98257
- ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
98258
- ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
98259
- ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
98260
- BraveHTML: { name: "Brave", id: "com.brave.Browser" },
98261
- BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
98262
- BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
98263
- BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
98264
- FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
98265
- OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
98266
- VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
98267
- "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
98268
- };
98269
- var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
98270
- var UnknownBrowserError = class extends Error {
98271
- };
98272
- async function defaultBrowser(_execFileAsync = execFileAsync3) {
98273
- const { stdout: stdout2 } = await _execFileAsync("reg", [
98274
- "QUERY",
98275
- " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
98276
- "/v",
98277
- "ProgId"
98278
- ]);
98279
- const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout2);
98280
- if (!match) {
98281
- throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout2)}`);
98168
+ toISOString() {
98169
+ let iso = super.toISOString();
98170
+ if (this.isDate())
98171
+ return iso.slice(0, 10);
98172
+ if (this.isTime())
98173
+ return iso.slice(11, 23);
98174
+ if (this.#offset === null)
98175
+ return iso.slice(0, -1);
98176
+ if (this.#offset === "Z")
98177
+ return iso;
98178
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
98179
+ offset = this.#offset[0] === "-" ? offset : -offset;
98180
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
98181
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
98282
98182
  }
98283
- const { id } = match.groups;
98284
- const browser = windowsBrowserProgIds[id];
98285
- if (!browser) {
98286
- throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
98183
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
98184
+ let date = new _TomlDate2(jsDate);
98185
+ date.#offset = offset;
98186
+ return date;
98287
98187
  }
98288
- return browser;
98289
- }
98290
-
98291
- // ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/index.js
98292
- var execFileAsync4 = (0, import_node_util7.promisify)(import_node_child_process7.execFile);
98293
- var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
98294
- async function defaultBrowser2() {
98295
- if (import_node_process11.default.platform === "darwin") {
98296
- const id = await defaultBrowserId();
98297
- const name3 = await bundleName(id);
98298
- return { name: name3, id };
98188
+ static wrapAsLocalDateTime(jsDate) {
98189
+ let date = new _TomlDate2(jsDate);
98190
+ date.#offset = null;
98191
+ return date;
98299
98192
  }
98300
- if (import_node_process11.default.platform === "linux") {
98301
- const { stdout: stdout2 } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
98302
- const id = stdout2.trim();
98303
- const name3 = titleize(id.replace(/.desktop$/, "").replace("-", " "));
98304
- return { name: name3, id };
98193
+ static wrapAsLocalDate(jsDate) {
98194
+ let date = new _TomlDate2(jsDate);
98195
+ date.#hasTime = false;
98196
+ date.#offset = null;
98197
+ return date;
98305
98198
  }
98306
- if (import_node_process11.default.platform === "win32") {
98307
- return defaultBrowser();
98199
+ static wrapAsLocalTime(jsDate) {
98200
+ let date = new _TomlDate2(jsDate);
98201
+ date.#hasDate = false;
98202
+ date.#offset = null;
98203
+ return date;
98308
98204
  }
98309
- throw new Error("Only macOS, Linux, and Windows are supported");
98310
- }
98205
+ };
98311
98206
 
98312
- // ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
98313
- var import_node_process12 = __toESM(require("node:process"), 1);
98314
- var isInSsh = Boolean(import_node_process12.default.env.SSH_CONNECTION || import_node_process12.default.env.SSH_CLIENT || import_node_process12.default.env.SSH_TTY);
98315
- var is_in_ssh_default = isInSsh;
98316
-
98317
- // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
98318
- var import_meta2 = {};
98319
- var fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
98320
- var __dirname3 = import_meta2.url ? import_node_path9.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)) : "";
98321
- var localXdgOpenPath = import_node_path9.default.join(__dirname3, "xdg-open");
98322
- var { platform, arch: arch2 } = import_node_process13.default;
98323
- var tryEachApp = async (apps2, opener) => {
98324
- if (apps2.length === 0) {
98325
- return;
98326
- }
98327
- const errors = [];
98328
- for (const app of apps2) {
98329
- try {
98330
- return await opener(app);
98331
- } catch (error2) {
98332
- errors.push(error2);
98333
- }
98334
- }
98335
- throw new AggregateError(errors, "Failed to open in all supported apps");
98207
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/primitive.js
98208
+ var INT_REGEX2 = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
98209
+ var FLOAT_REGEX2 = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
98210
+ var LEADING_ZERO2 = /^[+-]?0[0-9_]/;
98211
+ var ESCAPE_REGEX2 = /^[0-9a-f]{4,8}$/i;
98212
+ var ESC_MAP2 = {
98213
+ b: "\b",
98214
+ t: " ",
98215
+ n: "\n",
98216
+ f: "\f",
98217
+ r: "\r",
98218
+ '"': '"',
98219
+ "\\": "\\"
98336
98220
  };
98337
- var baseOpen = async (options) => {
98338
- options = {
98339
- wait: false,
98340
- background: false,
98341
- newInstance: false,
98342
- allowNonzeroExitCode: false,
98343
- ...options
98344
- };
98345
- const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
98346
- delete options[fallbackAttemptSymbol];
98347
- if (Array.isArray(options.app)) {
98348
- return tryEachApp(options.app, (singleApp) => baseOpen({
98349
- ...options,
98350
- app: singleApp,
98351
- [fallbackAttemptSymbol]: true
98352
- }));
98353
- }
98354
- let { name: app, arguments: appArguments = [] } = options.app ?? {};
98355
- appArguments = [...appArguments];
98356
- if (Array.isArray(app)) {
98357
- return tryEachApp(app, (appName) => baseOpen({
98358
- ...options,
98359
- app: {
98360
- name: appName,
98361
- arguments: appArguments
98362
- },
98363
- [fallbackAttemptSymbol]: true
98364
- }));
98221
+ function parseString2(str, ptr = 0, endPtr = str.length) {
98222
+ let isLiteral = str[ptr] === "'";
98223
+ let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
98224
+ if (isMultiline) {
98225
+ endPtr -= 2;
98226
+ if (str[ptr += 2] === "\r")
98227
+ ptr++;
98228
+ if (str[ptr] === "\n")
98229
+ ptr++;
98365
98230
  }
98366
- if (app === "browser" || app === "browserPrivate") {
98367
- const ids = {
98368
- "com.google.chrome": "chrome",
98369
- "google-chrome.desktop": "chrome",
98370
- "com.brave.browser": "brave",
98371
- "org.mozilla.firefox": "firefox",
98372
- "firefox.desktop": "firefox",
98373
- "com.microsoft.msedge": "edge",
98374
- "com.microsoft.edge": "edge",
98375
- "com.microsoft.edgemac": "edge",
98376
- "microsoft-edge.desktop": "edge",
98377
- "com.apple.safari": "safari"
98378
- };
98379
- const flags = {
98380
- chrome: "--incognito",
98381
- brave: "--incognito",
98382
- firefox: "--private-window",
98383
- edge: "--inPrivate"
98384
- // Safari doesn't support private mode via command line
98385
- };
98386
- let browser;
98387
- if (is_wsl_default) {
98388
- const progId = await wslDefaultBrowser();
98389
- const browserInfo = _windowsBrowserProgIdMap.get(progId);
98390
- browser = browserInfo ?? {};
98391
- } else {
98392
- browser = await defaultBrowser2();
98231
+ let tmp = 0;
98232
+ let isEscape;
98233
+ let parsed = "";
98234
+ let sliceStart = ptr;
98235
+ while (ptr < endPtr - 1) {
98236
+ let c2 = str[ptr++];
98237
+ if (c2 === "\n" || c2 === "\r" && str[ptr] === "\n") {
98238
+ if (!isMultiline) {
98239
+ throw new TomlError2("newlines are not allowed in strings", {
98240
+ toml: str,
98241
+ ptr: ptr - 1
98242
+ });
98243
+ }
98244
+ } else if (c2 < " " && c2 !== " " || c2 === "\x7F") {
98245
+ throw new TomlError2("control characters are not allowed in strings", {
98246
+ toml: str,
98247
+ ptr: ptr - 1
98248
+ });
98393
98249
  }
98394
- if (browser.id in ids) {
98395
- const browserName = ids[browser.id.toLowerCase()];
98396
- if (app === "browserPrivate") {
98397
- if (browserName === "safari") {
98398
- throw new Error("Safari doesn't support opening in private mode via command line");
98250
+ if (isEscape) {
98251
+ isEscape = false;
98252
+ if (c2 === "u" || c2 === "U") {
98253
+ let code = str.slice(ptr, ptr += c2 === "u" ? 4 : 8);
98254
+ if (!ESCAPE_REGEX2.test(code)) {
98255
+ throw new TomlError2("invalid unicode escape", {
98256
+ toml: str,
98257
+ ptr: tmp
98258
+ });
98399
98259
  }
98400
- appArguments.push(flags[browserName]);
98401
- }
98402
- return baseOpen({
98403
- ...options,
98404
- app: {
98405
- name: apps[browserName],
98406
- arguments: appArguments
98260
+ try {
98261
+ parsed += String.fromCodePoint(parseInt(code, 16));
98262
+ } catch {
98263
+ throw new TomlError2("invalid unicode escape", {
98264
+ toml: str,
98265
+ ptr: tmp
98266
+ });
98407
98267
  }
98408
- });
98268
+ } else if (isMultiline && (c2 === "\n" || c2 === " " || c2 === " " || c2 === "\r")) {
98269
+ ptr = skipVoid2(str, ptr - 1, true);
98270
+ if (str[ptr] !== "\n" && str[ptr] !== "\r") {
98271
+ throw new TomlError2("invalid escape: only line-ending whitespace may be escaped", {
98272
+ toml: str,
98273
+ ptr: tmp
98274
+ });
98275
+ }
98276
+ ptr = skipVoid2(str, ptr);
98277
+ } else if (c2 in ESC_MAP2) {
98278
+ parsed += ESC_MAP2[c2];
98279
+ } else {
98280
+ throw new TomlError2("unrecognized escape sequence", {
98281
+ toml: str,
98282
+ ptr: tmp
98283
+ });
98284
+ }
98285
+ sliceStart = ptr;
98286
+ } else if (!isLiteral && c2 === "\\") {
98287
+ tmp = ptr - 1;
98288
+ isEscape = true;
98289
+ parsed += str.slice(sliceStart, tmp);
98409
98290
  }
98410
- throw new Error(`${browser.name} is not supported as a default browser`);
98411
98291
  }
98412
- let command2;
98413
- const cliArguments = [];
98414
- const childProcessOptions = {};
98415
- let shouldUseWindowsInWsl = false;
98416
- if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
98417
- shouldUseWindowsInWsl = await canAccessPowerShell();
98418
- }
98419
- if (platform === "darwin") {
98420
- command2 = "open";
98421
- if (options.wait) {
98422
- cliArguments.push("--wait-apps");
98423
- }
98424
- if (options.background) {
98425
- cliArguments.push("--background");
98426
- }
98427
- if (options.newInstance) {
98428
- cliArguments.push("--new");
98429
- }
98430
- if (app) {
98431
- cliArguments.push("-a", app);
98432
- }
98433
- } else if (platform === "win32" || shouldUseWindowsInWsl) {
98434
- command2 = await powerShellPath2();
98435
- cliArguments.push(...executePowerShell.argumentsPrefix);
98436
- if (!is_wsl_default) {
98437
- childProcessOptions.windowsVerbatimArguments = true;
98438
- }
98439
- if (is_wsl_default && options.target) {
98440
- options.target = await convertWslPathToWindows(options.target);
98292
+ return parsed + str.slice(sliceStart, endPtr - 1);
98293
+ }
98294
+ function parseValue2(value, toml, ptr, integersAsBigInt) {
98295
+ if (value === "true")
98296
+ return true;
98297
+ if (value === "false")
98298
+ return false;
98299
+ if (value === "-inf")
98300
+ return -Infinity;
98301
+ if (value === "inf" || value === "+inf")
98302
+ return Infinity;
98303
+ if (value === "nan" || value === "+nan" || value === "-nan")
98304
+ return NaN;
98305
+ if (value === "-0")
98306
+ return integersAsBigInt ? 0n : 0;
98307
+ let isInt = INT_REGEX2.test(value);
98308
+ if (isInt || FLOAT_REGEX2.test(value)) {
98309
+ if (LEADING_ZERO2.test(value)) {
98310
+ throw new TomlError2("leading zeroes are not allowed", {
98311
+ toml,
98312
+ ptr
98313
+ });
98441
98314
  }
98442
- const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
98443
- if (options.wait) {
98444
- encodedArguments.push("-Wait");
98315
+ value = value.replace(/_/g, "");
98316
+ let numeric = +value;
98317
+ if (isNaN(numeric)) {
98318
+ throw new TomlError2("invalid number", {
98319
+ toml,
98320
+ ptr
98321
+ });
98445
98322
  }
98446
- if (app) {
98447
- encodedArguments.push(executePowerShell.escapeArgument(app));
98448
- if (options.target) {
98449
- appArguments.push(options.target);
98323
+ if (isInt) {
98324
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
98325
+ throw new TomlError2("integer value cannot be represented losslessly", {
98326
+ toml,
98327
+ ptr
98328
+ });
98450
98329
  }
98451
- } else if (options.target) {
98452
- encodedArguments.push(executePowerShell.escapeArgument(options.target));
98453
- }
98454
- if (appArguments.length > 0) {
98455
- appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
98456
- encodedArguments.push("-ArgumentList", appArguments.join(","));
98330
+ if (isInt || integersAsBigInt === true)
98331
+ numeric = BigInt(value);
98457
98332
  }
98458
- options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
98459
- if (!options.wait) {
98460
- childProcessOptions.stdio = "ignore";
98333
+ return numeric;
98334
+ }
98335
+ const date = new TomlDate2(value);
98336
+ if (!date.isValid()) {
98337
+ throw new TomlError2("invalid value", {
98338
+ toml,
98339
+ ptr
98340
+ });
98341
+ }
98342
+ return date;
98343
+ }
98344
+
98345
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/extract.js
98346
+ function sliceAndTrimEndOf2(str, startPtr, endPtr, allowNewLines) {
98347
+ let value = str.slice(startPtr, endPtr);
98348
+ let commentIdx = value.indexOf("#");
98349
+ if (commentIdx > -1) {
98350
+ skipComment2(str, commentIdx);
98351
+ value = value.slice(0, commentIdx);
98352
+ }
98353
+ let trimmed = value.trimEnd();
98354
+ if (!allowNewLines) {
98355
+ let newlineIdx = value.indexOf("\n", trimmed.length);
98356
+ if (newlineIdx > -1) {
98357
+ throw new TomlError2("newlines are not allowed in inline tables", {
98358
+ toml: str,
98359
+ ptr: startPtr + newlineIdx
98360
+ });
98461
98361
  }
98462
- } else {
98463
- if (app) {
98464
- command2 = app;
98465
- } else {
98466
- const isBundled = !__dirname3 || __dirname3 === "/";
98467
- let exeLocalXdgOpen = false;
98468
- try {
98469
- await import_promises5.default.access(localXdgOpenPath, import_promises5.constants.X_OK);
98470
- exeLocalXdgOpen = true;
98471
- } catch {
98362
+ }
98363
+ return [trimmed, commentIdx];
98364
+ }
98365
+ function extractValue2(str, ptr, end, depth, integersAsBigInt) {
98366
+ if (depth === 0) {
98367
+ throw new TomlError2("document contains excessively nested structures. aborting.", {
98368
+ toml: str,
98369
+ ptr
98370
+ });
98371
+ }
98372
+ let c2 = str[ptr];
98373
+ if (c2 === "[" || c2 === "{") {
98374
+ let [value, endPtr2] = c2 === "[" ? parseArray2(str, ptr, depth, integersAsBigInt) : parseInlineTable2(str, ptr, depth, integersAsBigInt);
98375
+ let newPtr = end ? skipUntil2(str, endPtr2, ",", end) : endPtr2;
98376
+ if (endPtr2 - newPtr && end === "}") {
98377
+ let nextNewLine = indexOfNewline2(str, endPtr2, newPtr);
98378
+ if (nextNewLine > -1) {
98379
+ throw new TomlError2("newlines are not allowed in inline tables", {
98380
+ toml: str,
98381
+ ptr: nextNewLine
98382
+ });
98472
98383
  }
98473
- const useSystemXdgOpen = import_node_process13.default.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
98474
- command2 = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
98475
- }
98476
- if (appArguments.length > 0) {
98477
- cliArguments.push(...appArguments);
98478
98384
  }
98479
- if (!options.wait) {
98480
- childProcessOptions.stdio = "ignore";
98481
- childProcessOptions.detached = true;
98385
+ return [value, newPtr];
98386
+ }
98387
+ let endPtr;
98388
+ if (c2 === '"' || c2 === "'") {
98389
+ endPtr = getStringEnd2(str, ptr);
98390
+ let parsed = parseString2(str, ptr, endPtr);
98391
+ if (end) {
98392
+ endPtr = skipVoid2(str, endPtr, end !== "]");
98393
+ if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
98394
+ throw new TomlError2("unexpected character encountered", {
98395
+ toml: str,
98396
+ ptr: endPtr
98397
+ });
98398
+ }
98399
+ endPtr += +(str[endPtr] === ",");
98482
98400
  }
98401
+ return [parsed, endPtr];
98483
98402
  }
98484
- if (platform === "darwin" && appArguments.length > 0) {
98485
- cliArguments.push("--args", ...appArguments);
98403
+ endPtr = skipUntil2(str, ptr, ",", end);
98404
+ let slice = sliceAndTrimEndOf2(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
98405
+ if (!slice[0]) {
98406
+ throw new TomlError2("incomplete key-value declaration: no value specified", {
98407
+ toml: str,
98408
+ ptr
98409
+ });
98486
98410
  }
98487
- if (options.target) {
98488
- cliArguments.push(options.target);
98411
+ if (end && slice[1] > -1) {
98412
+ endPtr = skipVoid2(str, ptr + slice[1]);
98413
+ endPtr += +(str[endPtr] === ",");
98489
98414
  }
98490
- const subprocess = import_node_child_process8.default.spawn(command2, cliArguments, childProcessOptions);
98491
- if (options.wait) {
98492
- return new Promise((resolve13, reject) => {
98493
- subprocess.once("error", reject);
98494
- subprocess.once("close", (exitCode) => {
98495
- if (!options.allowNonzeroExitCode && exitCode !== 0) {
98496
- reject(new Error(`Exited with code ${exitCode}`));
98497
- return;
98498
- }
98499
- resolve13(subprocess);
98500
- });
98415
+ return [
98416
+ parseValue2(slice[0], str, ptr, integersAsBigInt),
98417
+ endPtr
98418
+ ];
98419
+ }
98420
+
98421
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/struct.js
98422
+ var KEY_PART_RE2 = /^[a-zA-Z0-9-_]+[ \t]*$/;
98423
+ function parseKey2(str, ptr, end = "=") {
98424
+ let dot = ptr - 1;
98425
+ let parsed = [];
98426
+ let endPtr = str.indexOf(end, ptr);
98427
+ if (endPtr < 0) {
98428
+ throw new TomlError2("incomplete key-value: cannot find end of key", {
98429
+ toml: str,
98430
+ ptr
98501
98431
  });
98502
98432
  }
98503
- if (isFallbackAttempt) {
98504
- return new Promise((resolve13, reject) => {
98505
- subprocess.once("error", reject);
98506
- subprocess.once("spawn", () => {
98507
- subprocess.once("close", (exitCode) => {
98508
- subprocess.off("error", reject);
98509
- if (exitCode !== 0) {
98510
- reject(new Error(`Exited with code ${exitCode}`));
98511
- return;
98433
+ do {
98434
+ let c2 = str[ptr = ++dot];
98435
+ if (c2 !== " " && c2 !== " ") {
98436
+ if (c2 === '"' || c2 === "'") {
98437
+ if (c2 === str[ptr + 1] && c2 === str[ptr + 2]) {
98438
+ throw new TomlError2("multiline strings are not allowed in keys", {
98439
+ toml: str,
98440
+ ptr
98441
+ });
98442
+ }
98443
+ let eos = getStringEnd2(str, ptr);
98444
+ if (eos < 0) {
98445
+ throw new TomlError2("unfinished string encountered", {
98446
+ toml: str,
98447
+ ptr
98448
+ });
98449
+ }
98450
+ dot = str.indexOf(".", eos);
98451
+ let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
98452
+ let newLine = indexOfNewline2(strEnd);
98453
+ if (newLine > -1) {
98454
+ throw new TomlError2("newlines are not allowed in keys", {
98455
+ toml: str,
98456
+ ptr: ptr + dot + newLine
98457
+ });
98458
+ }
98459
+ if (strEnd.trimStart()) {
98460
+ throw new TomlError2("found extra tokens after the string part", {
98461
+ toml: str,
98462
+ ptr: eos
98463
+ });
98464
+ }
98465
+ if (endPtr < eos) {
98466
+ endPtr = str.indexOf(end, eos);
98467
+ if (endPtr < 0) {
98468
+ throw new TomlError2("incomplete key-value: cannot find end of key", {
98469
+ toml: str,
98470
+ ptr
98471
+ });
98512
98472
  }
98513
- subprocess.unref();
98514
- resolve13(subprocess);
98473
+ }
98474
+ parsed.push(parseString2(str, ptr, eos));
98475
+ } else {
98476
+ dot = str.indexOf(".", ptr);
98477
+ let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
98478
+ if (!KEY_PART_RE2.test(part)) {
98479
+ throw new TomlError2("only letter, numbers, dashes and underscores are allowed in keys", {
98480
+ toml: str,
98481
+ ptr
98482
+ });
98483
+ }
98484
+ parsed.push(part.trimEnd());
98485
+ }
98486
+ }
98487
+ } while (dot + 1 && dot < endPtr);
98488
+ return [parsed, skipVoid2(str, endPtr + 1, true, true)];
98489
+ }
98490
+ function parseInlineTable2(str, ptr, depth, integersAsBigInt) {
98491
+ let res = {};
98492
+ let seen = /* @__PURE__ */ new Set();
98493
+ let c2;
98494
+ let comma = 0;
98495
+ ptr++;
98496
+ while ((c2 = str[ptr++]) !== "}" && c2) {
98497
+ let err = { toml: str, ptr: ptr - 1 };
98498
+ if (c2 === "\n") {
98499
+ throw new TomlError2("newlines are not allowed in inline tables", err);
98500
+ } else if (c2 === "#") {
98501
+ throw new TomlError2("inline tables cannot contain comments", err);
98502
+ } else if (c2 === ",") {
98503
+ throw new TomlError2("expected key-value, found comma", err);
98504
+ } else if (c2 !== " " && c2 !== " ") {
98505
+ let k;
98506
+ let t2 = res;
98507
+ let hasOwn = false;
98508
+ let [key, keyEndPtr] = parseKey2(str, ptr - 1);
98509
+ for (let i = 0; i < key.length; i++) {
98510
+ if (i)
98511
+ t2 = hasOwn ? t2[k] : t2[k] = {};
98512
+ k = key[i];
98513
+ if ((hasOwn = Object.hasOwn(t2, k)) && (typeof t2[k] !== "object" || seen.has(t2[k]))) {
98514
+ throw new TomlError2("trying to redefine an already defined value", {
98515
+ toml: str,
98516
+ ptr
98517
+ });
98518
+ }
98519
+ if (!hasOwn && k === "__proto__") {
98520
+ Object.defineProperty(t2, k, { enumerable: true, configurable: true, writable: true });
98521
+ }
98522
+ }
98523
+ if (hasOwn) {
98524
+ throw new TomlError2("trying to redefine an already defined value", {
98525
+ toml: str,
98526
+ ptr
98515
98527
  });
98516
- });
98528
+ }
98529
+ let [value, valueEndPtr] = extractValue2(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
98530
+ seen.add(value);
98531
+ t2[k] = value;
98532
+ ptr = valueEndPtr;
98533
+ comma = str[ptr - 1] === "," ? ptr - 1 : 0;
98534
+ }
98535
+ }
98536
+ if (comma) {
98537
+ throw new TomlError2("trailing commas are not allowed in inline tables", {
98538
+ toml: str,
98539
+ ptr: comma
98517
98540
  });
98518
98541
  }
98519
- subprocess.unref();
98520
- return new Promise((resolve13, reject) => {
98521
- subprocess.once("error", reject);
98522
- subprocess.once("spawn", () => {
98523
- subprocess.off("error", reject);
98524
- resolve13(subprocess);
98542
+ if (!c2) {
98543
+ throw new TomlError2("unfinished table encountered", {
98544
+ toml: str,
98545
+ ptr
98525
98546
  });
98526
- });
98527
- };
98528
- var open = (target, options) => {
98529
- if (typeof target !== "string") {
98530
- throw new TypeError("Expected a `target`");
98531
98547
  }
98532
- return baseOpen({
98533
- ...options,
98534
- target
98535
- });
98536
- };
98537
- function detectArchBinary(binary) {
98538
- if (typeof binary === "string" || Array.isArray(binary)) {
98539
- return binary;
98548
+ return [res, ptr];
98549
+ }
98550
+ function parseArray2(str, ptr, depth, integersAsBigInt) {
98551
+ let res = [];
98552
+ let c2;
98553
+ ptr++;
98554
+ while ((c2 = str[ptr++]) !== "]" && c2) {
98555
+ if (c2 === ",") {
98556
+ throw new TomlError2("expected value, found comma", {
98557
+ toml: str,
98558
+ ptr: ptr - 1
98559
+ });
98560
+ } else if (c2 === "#")
98561
+ ptr = skipComment2(str, ptr);
98562
+ else if (c2 !== " " && c2 !== " " && c2 !== "\n" && c2 !== "\r") {
98563
+ let e = extractValue2(str, ptr - 1, "]", depth - 1, integersAsBigInt);
98564
+ res.push(e[0]);
98565
+ ptr = e[1];
98566
+ }
98540
98567
  }
98541
- const { [arch2]: archBinary } = binary;
98542
- if (!archBinary) {
98543
- throw new Error(`${arch2} is not supported`);
98568
+ if (!c2) {
98569
+ throw new TomlError2("unfinished array encountered", {
98570
+ toml: str,
98571
+ ptr
98572
+ });
98544
98573
  }
98545
- return archBinary;
98574
+ return [res, ptr];
98546
98575
  }
98547
- function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
98548
- if (wsl && is_wsl_default) {
98549
- return detectArchBinary(wsl);
98576
+
98577
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/parse.js
98578
+ function peekTable2(key, table, meta, type) {
98579
+ let t2 = table;
98580
+ let m = meta;
98581
+ let k;
98582
+ let hasOwn = false;
98583
+ let state;
98584
+ for (let i = 0; i < key.length; i++) {
98585
+ if (i) {
98586
+ t2 = hasOwn ? t2[k] : t2[k] = {};
98587
+ m = (state = m[k]).c;
98588
+ if (type === 0 && (state.t === 1 || state.t === 2)) {
98589
+ return null;
98590
+ }
98591
+ if (state.t === 2) {
98592
+ let l = t2.length - 1;
98593
+ t2 = t2[l];
98594
+ m = m[l].c;
98595
+ }
98596
+ }
98597
+ k = key[i];
98598
+ if ((hasOwn = Object.hasOwn(t2, k)) && m[k]?.t === 0 && m[k]?.d) {
98599
+ return null;
98600
+ }
98601
+ if (!hasOwn) {
98602
+ if (k === "__proto__") {
98603
+ Object.defineProperty(t2, k, { enumerable: true, configurable: true, writable: true });
98604
+ Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
98605
+ }
98606
+ m[k] = {
98607
+ t: i < key.length - 1 && type === 2 ? 3 : type,
98608
+ d: false,
98609
+ i: 0,
98610
+ c: {}
98611
+ };
98612
+ }
98550
98613
  }
98551
- if (!platformBinary) {
98552
- throw new Error(`${platform} is not supported`);
98614
+ state = m[k];
98615
+ if (state.t !== type && !(type === 1 && state.t === 3)) {
98616
+ return null;
98553
98617
  }
98554
- return detectArchBinary(platformBinary);
98555
- }
98556
- var apps = {
98557
- browser: "browser",
98558
- browserPrivate: "browserPrivate"
98559
- };
98560
- defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
98561
- darwin: "google chrome",
98562
- win32: "chrome",
98563
- // `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
98564
- linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
98565
- }, {
98566
- wsl: {
98567
- ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
98568
- x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
98618
+ if (type === 2) {
98619
+ if (!state.d) {
98620
+ state.d = true;
98621
+ t2[k] = [];
98622
+ }
98623
+ t2[k].push(t2 = {});
98624
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
98569
98625
  }
98570
- }));
98571
- defineLazyProperty(apps, "brave", () => detectPlatformBinary({
98572
- darwin: "brave browser",
98573
- win32: "brave",
98574
- linux: ["brave-browser", "brave"]
98575
- }, {
98576
- wsl: {
98577
- ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
98578
- x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
98626
+ if (state.d) {
98627
+ return null;
98579
98628
  }
98580
- }));
98581
- defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
98582
- darwin: "firefox",
98583
- win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
98584
- linux: "firefox"
98585
- }, {
98586
- wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
98587
- }));
98588
- defineLazyProperty(apps, "edge", () => detectPlatformBinary({
98589
- darwin: "microsoft edge",
98590
- win32: "msedge",
98591
- linux: ["microsoft-edge", "microsoft-edge-dev"]
98592
- }, {
98593
- wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
98594
- }));
98595
- defineLazyProperty(apps, "safari", () => detectPlatformBinary({
98596
- darwin: "Safari"
98597
- }));
98598
- var open_default = open;
98599
-
98600
- // src/helpers/cli.ts
98601
- var import_semver2 = __toESM(require_semver2());
98602
- async function openInBrowser(url) {
98603
- updateStatus("Opening browser");
98604
- const childProcess4 = await open_default(url);
98605
- childProcess4.on("error", () => {
98606
- warn("Failed to open browser");
98607
- });
98608
- }
98609
- var isUpdateAvailable = async () => {
98610
- const s = spinner(spinnerFrames.vertical, blue);
98611
- s.start("Checking if a newer version is available");
98612
- try {
98613
- const latestVersion = await getLatestPackageVersion("create-cloudflare");
98614
- return (
98615
- // Don't auto-update to major versions
98616
- import_semver2.default.diff(latestVersion, version) !== "major" && import_semver2.default.gt(latestVersion, version)
98617
- );
98618
- } catch {
98619
- s.update("Failed to read latest version from npm.");
98620
- return false;
98621
- } finally {
98622
- s.stop();
98629
+ state.d = true;
98630
+ if (type === 1) {
98631
+ t2 = hasOwn ? t2[k] : t2[k] = {};
98632
+ } else if (type === 0 && hasOwn) {
98633
+ return null;
98623
98634
  }
98624
- };
98625
- var C3_DEFAULTS = {
98626
- projectName: new import_haikunator.default().haikunate({ tokenHex: true }),
98627
- category: "hello-world",
98628
- type: "hello-world-with-assets",
98629
- framework: "analog",
98630
- experimental: false,
98631
- autoUpdate: true,
98632
- deploy: false,
98633
- git: true,
98634
- agents: true,
98635
- open: true,
98636
- lang: "ts",
98637
- template: "cloudflare/workers-sdk/packages/create-cloudflare/templates/hello-world-with-assets"
98638
- };
98639
- var WRANGLER_DEFAULTS = {
98640
- ...C3_DEFAULTS,
98641
- type: "hello-world-with-assets",
98642
- deploy: false
98643
- };
98644
-
98645
- // src/helpers/files.ts
98646
- var import_node_fs11 = __toESM(require("node:fs"));
98647
- var import_node_path10 = require("node:path");
98648
- var import_comment_json = __toESM(require_src3());
98649
-
98650
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/error.js
98651
- function getLineColFromPtr2(string, ptr) {
98652
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
98653
- return [lines.length, lines.pop().length + 1];
98635
+ return [k, t2, state.c];
98654
98636
  }
98655
- function makeCodeBlock2(string, line, column) {
98656
- let lines = string.split(/\r\n|\n|\r/g);
98657
- let codeblock = "";
98658
- let numberLen = (Math.log10(line + 1) | 0) + 1;
98659
- for (let i = line - 1; i <= line + 1; i++) {
98660
- let l = lines[i - 1];
98661
- if (!l)
98662
- continue;
98663
- codeblock += i.toString().padEnd(numberLen, " ");
98664
- codeblock += ": ";
98665
- codeblock += l;
98666
- codeblock += "\n";
98667
- if (i === line) {
98668
- codeblock += " ".repeat(numberLen + column + 2);
98669
- codeblock += "^\n";
98637
+ function parse4(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
98638
+ let res = {};
98639
+ let meta = {};
98640
+ let tbl = res;
98641
+ let m = meta;
98642
+ for (let ptr = skipVoid2(toml, 0); ptr < toml.length; ) {
98643
+ if (toml[ptr] === "[") {
98644
+ let isTableArray = toml[++ptr] === "[";
98645
+ let k = parseKey2(toml, ptr += +isTableArray, "]");
98646
+ if (isTableArray) {
98647
+ if (toml[k[1] - 1] !== "]") {
98648
+ throw new TomlError2("expected end of table declaration", {
98649
+ toml,
98650
+ ptr: k[1] - 1
98651
+ });
98652
+ }
98653
+ k[1]++;
98654
+ }
98655
+ let p2 = peekTable2(
98656
+ k[0],
98657
+ res,
98658
+ meta,
98659
+ isTableArray ? 2 : 1
98660
+ /* Type.EXPLICIT */
98661
+ );
98662
+ if (!p2) {
98663
+ throw new TomlError2("trying to redefine an already defined table or value", {
98664
+ toml,
98665
+ ptr
98666
+ });
98667
+ }
98668
+ m = p2[2];
98669
+ tbl = p2[1];
98670
+ ptr = k[1];
98671
+ } else {
98672
+ let k = parseKey2(toml, ptr);
98673
+ let p2 = peekTable2(
98674
+ k[0],
98675
+ tbl,
98676
+ m,
98677
+ 0
98678
+ /* Type.DOTTED */
98679
+ );
98680
+ if (!p2) {
98681
+ throw new TomlError2("trying to redefine an already defined table or value", {
98682
+ toml,
98683
+ ptr
98684
+ });
98685
+ }
98686
+ let v = extractValue2(toml, k[1], void 0, maxDepth, integersAsBigInt);
98687
+ p2[1][p2[0]] = v[0];
98688
+ ptr = v[1];
98689
+ }
98690
+ ptr = skipVoid2(toml, ptr, true);
98691
+ if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
98692
+ throw new TomlError2("each key-value declaration must be followed by an end-of-line", {
98693
+ toml,
98694
+ ptr
98695
+ });
98670
98696
  }
98697
+ ptr = skipVoid2(toml, ptr);
98671
98698
  }
98672
- return codeblock;
98699
+ return res;
98673
98700
  }
98674
- var TomlError2 = class extends Error {
98675
- line;
98676
- column;
98677
- codeblock;
98678
- constructor(message, options) {
98679
- const [line, column] = getLineColFromPtr2(options.toml, options.ptr);
98680
- const codeblock = makeCodeBlock2(options.toml, line, column);
98681
- super(`Invalid TOML document: ${message}
98682
98701
 
98683
- ${codeblock}`, options);
98684
- this.line = line;
98685
- this.column = column;
98686
- this.codeblock = codeblock;
98702
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/stringify.js
98703
+ var BARE_KEY2 = /^[a-z0-9-_]+$/i;
98704
+ function extendedTypeOf2(obj) {
98705
+ let type = typeof obj;
98706
+ if (type === "object") {
98707
+ if (Array.isArray(obj))
98708
+ return "array";
98709
+ if (obj instanceof Date)
98710
+ return "date";
98687
98711
  }
98688
- };
98689
-
98690
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/util.js
98691
- function isEscaped2(str, ptr) {
98692
- let i = 0;
98693
- while (str[ptr - ++i] === "\\")
98694
- ;
98695
- return --i && i % 2;
98696
- }
98697
- function indexOfNewline2(str, start = 0, end = str.length) {
98698
- let idx = str.indexOf("\n", start);
98699
- if (str[idx - 1] === "\r")
98700
- idx--;
98701
- return idx <= end ? idx : -1;
98712
+ return type;
98702
98713
  }
98703
- function skipComment2(str, ptr) {
98704
- for (let i = ptr; i < str.length; i++) {
98705
- let c2 = str[i];
98706
- if (c2 === "\n")
98707
- return i;
98708
- if (c2 === "\r" && str[i + 1] === "\n")
98709
- return i + 1;
98710
- if (c2 < " " && c2 !== " " || c2 === "\x7F") {
98711
- throw new TomlError2("control characters are not allowed in comments", {
98712
- toml: str,
98713
- ptr
98714
- });
98715
- }
98714
+ function isArrayOfTables2(obj) {
98715
+ for (let i = 0; i < obj.length; i++) {
98716
+ if (extendedTypeOf2(obj[i]) !== "object")
98717
+ return false;
98716
98718
  }
98717
- return str.length;
98719
+ return obj.length != 0;
98718
98720
  }
98719
- function skipVoid2(str, ptr, banNewLines, banComments) {
98720
- let c2;
98721
- while ((c2 = str[ptr]) === " " || c2 === " " || !banNewLines && (c2 === "\n" || c2 === "\r" && str[ptr + 1] === "\n"))
98722
- ptr++;
98723
- return banComments || c2 !== "#" ? ptr : skipVoid2(str, skipComment2(str, ptr), banNewLines);
98721
+ function formatString2(s) {
98722
+ return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
98724
98723
  }
98725
- function skipUntil2(str, ptr, sep, end, banNewLines = false) {
98726
- if (!end) {
98727
- ptr = indexOfNewline2(str, ptr);
98728
- return ptr < 0 ? str.length : ptr;
98724
+ function stringifyValue2(val, type, depth, numberAsFloat) {
98725
+ if (depth === 0) {
98726
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
98729
98727
  }
98730
- for (let i = ptr; i < str.length; i++) {
98731
- let c2 = str[i];
98732
- if (c2 === "#") {
98733
- i = indexOfNewline2(str, i);
98734
- } else if (c2 === sep) {
98735
- return i + 1;
98736
- } else if (c2 === end || banNewLines && (c2 === "\n" || c2 === "\r" && str[i + 1] === "\n")) {
98737
- return i;
98728
+ if (type === "number") {
98729
+ if (isNaN(val))
98730
+ return "nan";
98731
+ if (val === Infinity)
98732
+ return "inf";
98733
+ if (val === -Infinity)
98734
+ return "-inf";
98735
+ if (numberAsFloat && Number.isInteger(val))
98736
+ return val.toFixed(1);
98737
+ return val.toString();
98738
+ }
98739
+ if (type === "bigint" || type === "boolean") {
98740
+ return val.toString();
98741
+ }
98742
+ if (type === "string") {
98743
+ return formatString2(val);
98744
+ }
98745
+ if (type === "date") {
98746
+ if (isNaN(val.getTime())) {
98747
+ throw new TypeError("cannot serialize invalid date");
98738
98748
  }
98749
+ return val.toISOString();
98750
+ }
98751
+ if (type === "object") {
98752
+ return stringifyInlineTable2(val, depth, numberAsFloat);
98753
+ }
98754
+ if (type === "array") {
98755
+ return stringifyArray2(val, depth, numberAsFloat);
98739
98756
  }
98740
- throw new TomlError2("cannot find end of structure", {
98741
- toml: str,
98742
- ptr
98743
- });
98744
98757
  }
98745
- function getStringEnd2(str, seek) {
98746
- let first = str[seek];
98747
- let target = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
98748
- seek += target.length - 1;
98749
- do
98750
- seek = str.indexOf(target, ++seek);
98751
- while (seek > -1 && first !== "'" && isEscaped2(str, seek));
98752
- if (seek > -1) {
98753
- seek += target.length;
98754
- if (target.length > 1) {
98755
- if (str[seek] === first)
98756
- seek++;
98757
- if (str[seek] === first)
98758
- seek++;
98759
- }
98758
+ function stringifyInlineTable2(obj, depth, numberAsFloat) {
98759
+ let keys = Object.keys(obj);
98760
+ if (keys.length === 0)
98761
+ return "{}";
98762
+ let res = "{ ";
98763
+ for (let i = 0; i < keys.length; i++) {
98764
+ let k = keys[i];
98765
+ if (i)
98766
+ res += ", ";
98767
+ res += BARE_KEY2.test(k) ? k : formatString2(k);
98768
+ res += " = ";
98769
+ res += stringifyValue2(obj[k], extendedTypeOf2(obj[k]), depth - 1, numberAsFloat);
98760
98770
  }
98761
- return seek;
98771
+ return res + " }";
98762
98772
  }
98763
-
98764
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/date.js
98765
- var DATE_TIME_RE2 = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
98766
- var TomlDate2 = class _TomlDate2 extends Date {
98767
- #hasDate = false;
98768
- #hasTime = false;
98769
- #offset = null;
98770
- constructor(date) {
98771
- let hasDate = true;
98772
- let hasTime = true;
98773
- let offset = "Z";
98774
- if (typeof date === "string") {
98775
- let match = date.match(DATE_TIME_RE2);
98776
- if (match) {
98777
- if (!match[1]) {
98778
- hasDate = false;
98779
- date = `0000-01-01T${date}`;
98780
- }
98781
- hasTime = !!match[2];
98782
- hasTime && date[10] === " " && (date = date.replace(" ", "T"));
98783
- if (match[2] && +match[2] > 23) {
98784
- date = "";
98785
- } else {
98786
- offset = match[3] || null;
98787
- date = date.toUpperCase();
98788
- if (!offset && hasTime)
98789
- date += "Z";
98790
- }
98791
- } else {
98792
- date = "";
98793
- }
98794
- }
98795
- super(date);
98796
- if (!isNaN(this.getTime())) {
98797
- this.#hasDate = hasDate;
98798
- this.#hasTime = hasTime;
98799
- this.#offset = offset;
98773
+ function stringifyArray2(array, depth, numberAsFloat) {
98774
+ if (array.length === 0)
98775
+ return "[]";
98776
+ let res = "[ ";
98777
+ for (let i = 0; i < array.length; i++) {
98778
+ if (i)
98779
+ res += ", ";
98780
+ if (array[i] === null || array[i] === void 0) {
98781
+ throw new TypeError("arrays cannot contain null or undefined values");
98800
98782
  }
98783
+ res += stringifyValue2(array[i], extendedTypeOf2(array[i]), depth - 1, numberAsFloat);
98801
98784
  }
98802
- isDateTime() {
98803
- return this.#hasDate && this.#hasTime;
98785
+ return res + " ]";
98786
+ }
98787
+ function stringifyArrayTable2(array, key, depth, numberAsFloat) {
98788
+ if (depth === 0) {
98789
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
98804
98790
  }
98805
- isLocal() {
98806
- return !this.#hasDate || !this.#hasTime || !this.#offset;
98791
+ let res = "";
98792
+ for (let i = 0; i < array.length; i++) {
98793
+ res += `${res && "\n"}[[${key}]]
98794
+ `;
98795
+ res += stringifyTable2(0, array[i], key, depth, numberAsFloat);
98807
98796
  }
98808
- isDate() {
98809
- return this.#hasDate && !this.#hasTime;
98797
+ return res;
98798
+ }
98799
+ function stringifyTable2(tableKey, obj, prefix, depth, numberAsFloat) {
98800
+ if (depth === 0) {
98801
+ throw new Error("Could not stringify the object: maximum object depth exceeded");
98810
98802
  }
98811
- isTime() {
98812
- return this.#hasTime && !this.#hasDate;
98803
+ let preamble = "";
98804
+ let tables = "";
98805
+ let keys = Object.keys(obj);
98806
+ for (let i = 0; i < keys.length; i++) {
98807
+ let k = keys[i];
98808
+ if (obj[k] !== null && obj[k] !== void 0) {
98809
+ let type = extendedTypeOf2(obj[k]);
98810
+ if (type === "symbol" || type === "function") {
98811
+ throw new TypeError(`cannot serialize values of type '${type}'`);
98812
+ }
98813
+ let key = BARE_KEY2.test(k) ? k : formatString2(k);
98814
+ if (type === "array" && isArrayOfTables2(obj[k])) {
98815
+ tables += (tables && "\n") + stringifyArrayTable2(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
98816
+ } else if (type === "object") {
98817
+ let tblKey = prefix ? `${prefix}.${key}` : key;
98818
+ tables += (tables && "\n") + stringifyTable2(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
98819
+ } else {
98820
+ preamble += key;
98821
+ preamble += " = ";
98822
+ preamble += stringifyValue2(obj[k], type, depth, numberAsFloat);
98823
+ preamble += "\n";
98824
+ }
98825
+ }
98813
98826
  }
98814
- isValid() {
98815
- return this.#hasDate || this.#hasTime;
98827
+ if (tableKey && (preamble || !tables))
98828
+ preamble = preamble ? `[${tableKey}]
98829
+ ${preamble}` : `[${tableKey}]`;
98830
+ return preamble && tables ? `${preamble}
98831
+ ${tables}` : preamble || tables;
98832
+ }
98833
+ function stringify2(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
98834
+ if (extendedTypeOf2(obj) !== "object") {
98835
+ throw new TypeError("stringify can only be called with an object");
98816
98836
  }
98817
- toISOString() {
98818
- let iso = super.toISOString();
98819
- if (this.isDate())
98820
- return iso.slice(0, 10);
98821
- if (this.isTime())
98822
- return iso.slice(11, 23);
98823
- if (this.#offset === null)
98824
- return iso.slice(0, -1);
98825
- if (this.#offset === "Z")
98826
- return iso;
98827
- let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
98828
- offset = this.#offset[0] === "-" ? offset : -offset;
98829
- let offsetDate = new Date(this.getTime() - offset * 6e4);
98830
- return offsetDate.toISOString().slice(0, -1) + this.#offset;
98837
+ let str = stringifyTable2(0, obj, "", maxDepth, numbersAsFloat);
98838
+ if (str[str.length - 1] !== "\n")
98839
+ return str + "\n";
98840
+ return str;
98841
+ }
98842
+
98843
+ // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/index.js
98844
+ var dist_default4 = { parse: parse4, stringify: stringify2, TomlDate: TomlDate2, TomlError: TomlError2 };
98845
+
98846
+ // src/helpers/files.ts
98847
+ var writeFile3 = (path6, content) => {
98848
+ try {
98849
+ import_node_fs7.default.writeFileSync(path6, content);
98850
+ } catch (error2) {
98851
+ throw new Error(error2);
98831
98852
  }
98832
- static wrapAsOffsetDateTime(jsDate, offset = "Z") {
98833
- let date = new _TomlDate2(jsDate);
98834
- date.#offset = offset;
98835
- return date;
98853
+ };
98854
+ var readFile = (path6) => {
98855
+ try {
98856
+ return import_node_fs7.default.readFileSync(path6, "utf-8");
98857
+ } catch (error2) {
98858
+ throw new Error(error2);
98836
98859
  }
98837
- static wrapAsLocalDateTime(jsDate) {
98838
- let date = new _TomlDate2(jsDate);
98839
- date.#offset = null;
98840
- return date;
98860
+ };
98861
+ var removeFile = (path6) => {
98862
+ try {
98863
+ import_node_fs7.default.rmSync(path6, { force: true });
98864
+ } catch (error2) {
98865
+ throw new Error(`Remove file failed: ${path6}`, { cause: error2 });
98841
98866
  }
98842
- static wrapAsLocalDate(jsDate) {
98843
- let date = new _TomlDate2(jsDate);
98844
- date.#hasTime = false;
98845
- date.#offset = null;
98846
- return date;
98867
+ };
98868
+ var readJSON = (path6) => {
98869
+ const contents = readFile(path6);
98870
+ return contents ? (0, import_comment_json.parse)(contents) : contents;
98871
+ };
98872
+ var writeJSON = (path6, object, stringifySpace = " ") => {
98873
+ writeFile3(path6, (0, import_comment_json.stringify)(object, null, stringifySpace));
98874
+ };
98875
+ var usesTypescript = (ctx) => {
98876
+ return hasTsConfig(ctx.project.path);
98877
+ };
98878
+ var hasTsConfig = (path6) => {
98879
+ return (0, import_node_fs7.existsSync)((0, import_node_path8.join)(`${path6}`, `tsconfig.json`));
98880
+ };
98881
+
98882
+ // src/helpers/pnpmBuildApprovals.ts
98883
+ var APPROVED_BUILDS = ["esbuild", "workerd", "sharp"];
98884
+ var APPROVED_BUILDS_SET = new Set(APPROVED_BUILDS);
98885
+ var writePnpmBuildApprovals = (projectPath) => {
98886
+ const { npm: npm25 } = detectPackageManager();
98887
+ if (npm25 !== "pnpm") {
98888
+ return;
98847
98889
  }
98848
- static wrapAsLocalTime(jsDate) {
98849
- let date = new _TomlDate2(jsDate);
98850
- date.#hasDate = false;
98851
- date.#offset = null;
98852
- return date;
98890
+ const yamlPath = (0, import_node_path9.join)(projectPath, "pnpm-workspace.yaml");
98891
+ if (!(0, import_node_fs8.existsSync)(yamlPath)) {
98892
+ writeFile3(yamlPath, freshWorkspaceYaml());
98893
+ return;
98894
+ }
98895
+ const original = readFile(yamlPath);
98896
+ const updated = mergeAllowBuilds(original);
98897
+ if (updated !== original) {
98898
+ writeFile3(yamlPath, updated);
98853
98899
  }
98854
98900
  };
98855
-
98856
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/primitive.js
98857
- var INT_REGEX2 = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
98858
- var FLOAT_REGEX2 = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
98859
- var LEADING_ZERO2 = /^[+-]?0[0-9_]/;
98860
- var ESCAPE_REGEX2 = /^[0-9a-f]{4,8}$/i;
98861
- var ESC_MAP2 = {
98862
- b: "\b",
98863
- t: " ",
98864
- n: "\n",
98865
- f: "\f",
98866
- r: "\r",
98867
- '"': '"',
98868
- "\\": "\\"
98901
+ var FRESH_HEADER = [
98902
+ "# Pre-approve build scripts for the packages C3 itself installs that need",
98903
+ "# them: `workerd` downloads the platform binary, `esbuild` and `sharp`",
98904
+ "# (via miniflare) download/build native bindings. Without these, pnpm 11+",
98905
+ "# aborts the install with ERR_PNPM_IGNORED_BUILDS."
98906
+ ];
98907
+ var formatEntry = (pkg) => pkg.startsWith("@") ? ` '${pkg}': true` : ` ${pkg}: true`;
98908
+ var freshWorkspaceYaml = () => [
98909
+ ...FRESH_HEADER,
98910
+ "allowBuilds:",
98911
+ ...APPROVED_BUILDS.map(formatEntry),
98912
+ ""
98913
+ ].join("\n");
98914
+ var ALLOW_BUILDS_ENTRY = /^( {2})(['"]?)([^'":]+)\2:\s*(.*)$/;
98915
+ var mergeAllowBuilds = (original) => {
98916
+ const eol = detectEol(original);
98917
+ const lines = original.split(/\r?\n/);
98918
+ const headerIdx = lines.findIndex((line) => /^allowBuilds:\s*$/.test(line));
98919
+ if (headerIdx === -1) {
98920
+ const needsLeadingBlank = lines.length > 0 && lines[lines.length - 1] !== "";
98921
+ const block = [
98922
+ ...needsLeadingBlank ? [""] : [],
98923
+ ...FRESH_HEADER,
98924
+ "allowBuilds:",
98925
+ ...APPROVED_BUILDS.map(formatEntry),
98926
+ ""
98927
+ ].join(eol);
98928
+ return original.replace(/(\r?\n)?$/, eol + block);
98929
+ }
98930
+ const seenOurKeys = /* @__PURE__ */ new Set();
98931
+ let blockEnd = lines.length;
98932
+ for (let i = headerIdx + 1; i < lines.length; i++) {
98933
+ const line = lines[i];
98934
+ if (line.trim() === "") {
98935
+ continue;
98936
+ }
98937
+ if (!line.startsWith(" ")) {
98938
+ blockEnd = i;
98939
+ break;
98940
+ }
98941
+ const match = line.match(ALLOW_BUILDS_ENTRY);
98942
+ if (!match) {
98943
+ continue;
98944
+ }
98945
+ const [, indent2, quote, key, value] = match;
98946
+ if (!APPROVED_BUILDS_SET.has(key)) {
98947
+ continue;
98948
+ }
98949
+ seenOurKeys.add(key);
98950
+ const trimmed = value.trim();
98951
+ if (trimmed !== "true" && trimmed !== "false") {
98952
+ lines[i] = `${indent2}${quote}${key}${quote}: true`;
98953
+ }
98954
+ }
98955
+ const missing = APPROVED_BUILDS.filter((pkg) => !seenOurKeys.has(pkg)).map(
98956
+ formatEntry
98957
+ );
98958
+ if (missing.length > 0) {
98959
+ lines.splice(blockEnd, 0, ...missing);
98960
+ }
98961
+ return lines.join(eol);
98869
98962
  };
98870
- function parseString2(str, ptr = 0, endPtr = str.length) {
98871
- let isLiteral = str[ptr] === "'";
98872
- let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
98873
- if (isMultiline) {
98874
- endPtr -= 2;
98875
- if (str[ptr += 2] === "\r")
98876
- ptr++;
98877
- if (str[ptr] === "\n")
98878
- ptr++;
98963
+ var detectEol = (text) => text.includes("\r\n") ? "\r\n" : "\n";
98964
+ var isPnpmIgnoredBuildsError = (error2) => {
98965
+ if (!(error2 instanceof Error)) {
98966
+ return false;
98879
98967
  }
98880
- let tmp = 0;
98881
- let isEscape;
98882
- let parsed = "";
98883
- let sliceStart = ptr;
98884
- while (ptr < endPtr - 1) {
98885
- let c2 = str[ptr++];
98886
- if (c2 === "\n" || c2 === "\r" && str[ptr] === "\n") {
98887
- if (!isMultiline) {
98888
- throw new TomlError2("newlines are not allowed in strings", {
98889
- toml: str,
98890
- ptr: ptr - 1
98891
- });
98892
- }
98893
- } else if (c2 < " " && c2 !== " " || c2 === "\x7F") {
98894
- throw new TomlError2("control characters are not allowed in strings", {
98895
- toml: str,
98896
- ptr: ptr - 1
98897
- });
98968
+ return error2.message.includes("ERR_PNPM_IGNORED_BUILDS");
98969
+ };
98970
+ var IGNORED_BUILDS_LINE = /Ignored build scripts:\s*([^\n\r]+)/;
98971
+ var extractIgnoredBuildPackages = (error2) => {
98972
+ const text = error2 instanceof Error ? error2.message : typeof error2 === "string" ? error2 : "";
98973
+ const match = text.match(IGNORED_BUILDS_LINE);
98974
+ if (!match) {
98975
+ return [];
98976
+ }
98977
+ const seen = /* @__PURE__ */ new Set();
98978
+ const result = [];
98979
+ for (const raw of match[1].split(",")) {
98980
+ const trimmed = raw.trim();
98981
+ if (!trimmed) {
98982
+ continue;
98898
98983
  }
98899
- if (isEscape) {
98900
- isEscape = false;
98901
- if (c2 === "u" || c2 === "U") {
98902
- let code = str.slice(ptr, ptr += c2 === "u" ? 4 : 8);
98903
- if (!ESCAPE_REGEX2.test(code)) {
98904
- throw new TomlError2("invalid unicode escape", {
98905
- toml: str,
98906
- ptr: tmp
98907
- });
98908
- }
98909
- try {
98910
- parsed += String.fromCodePoint(parseInt(code, 16));
98911
- } catch {
98912
- throw new TomlError2("invalid unicode escape", {
98913
- toml: str,
98914
- ptr: tmp
98915
- });
98916
- }
98917
- } else if (isMultiline && (c2 === "\n" || c2 === " " || c2 === " " || c2 === "\r")) {
98918
- ptr = skipVoid2(str, ptr - 1, true);
98919
- if (str[ptr] !== "\n" && str[ptr] !== "\r") {
98920
- throw new TomlError2("invalid escape: only line-ending whitespace may be escaped", {
98921
- toml: str,
98922
- ptr: tmp
98923
- });
98924
- }
98925
- ptr = skipVoid2(str, ptr);
98926
- } else if (c2 in ESC_MAP2) {
98927
- parsed += ESC_MAP2[c2];
98928
- } else {
98929
- throw new TomlError2("unrecognized escape sequence", {
98930
- toml: str,
98931
- ptr: tmp
98932
- });
98933
- }
98934
- sliceStart = ptr;
98935
- } else if (!isLiteral && c2 === "\\") {
98936
- tmp = ptr - 1;
98937
- isEscape = true;
98938
- parsed += str.slice(sliceStart, tmp);
98984
+ const name3 = stripPackageVersion(trimmed);
98985
+ if (name3 && !seen.has(name3)) {
98986
+ seen.add(name3);
98987
+ result.push(name3);
98939
98988
  }
98940
98989
  }
98941
- return parsed + str.slice(sliceStart, endPtr - 1);
98990
+ return result;
98991
+ };
98992
+ var stripPackageVersion = (spec) => {
98993
+ if (spec.startsWith("@")) {
98994
+ const slashIdx = spec.indexOf("/");
98995
+ if (slashIdx === -1) {
98996
+ return spec;
98997
+ }
98998
+ const versionAt = spec.indexOf("@", slashIdx);
98999
+ return versionAt === -1 ? spec : spec.slice(0, versionAt);
99000
+ }
99001
+ const atIdx = spec.indexOf("@");
99002
+ return atIdx === -1 ? spec : spec.slice(0, atIdx);
99003
+ };
99004
+ var IgnoredBuildsError = class extends Error {
99005
+ packages;
99006
+ constructor(packages, cause) {
99007
+ const list = packages.length > 0 ? packages.join(", ") : "(unknown)";
99008
+ super(`pnpm blocked unapproved dependency build scripts: ${list}`);
99009
+ this.name = "IgnoredBuildsError";
99010
+ this.packages = packages;
99011
+ if (cause !== void 0) {
99012
+ this.cause = cause;
99013
+ }
99014
+ }
99015
+ };
99016
+ var isIgnoredBuildsError = (error2) => error2 instanceof IgnoredBuildsError;
99017
+ var getPnpmIgnoredBuildsGuidance = (packages = []) => {
99018
+ const approveCommand = packages.length > 0 ? ` pnpm approve-builds ${packages.join(" ")}` : " pnpm approve-builds";
99019
+ return [
99020
+ "create-cloudflare only pre-approves build scripts for the packages it",
99021
+ "installs itself. The packages flagged above were introduced by the",
99022
+ "framework generator and need to be approved separately.",
99023
+ "",
99024
+ "Inside the generated project, run:",
99025
+ "",
99026
+ approveCommand,
99027
+ "",
99028
+ "then re-run the install."
99029
+ ].join("\n");
99030
+ };
99031
+
99032
+ // src/helpers/packages.ts
99033
+ var installPackages2 = async (packages, config49 = {}) => {
99034
+ const { npm: npm25 } = detectPackageManager();
99035
+ return installPackages(npm25, packages, config49);
99036
+ };
99037
+ async function installWrangler2() {
99038
+ const { npm: npm25 } = detectPackageManager();
99039
+ return installWrangler(npm25, false);
98942
99040
  }
98943
- function parseValue2(value, toml, ptr, integersAsBigInt) {
98944
- if (value === "true")
98945
- return true;
98946
- if (value === "false")
98947
- return false;
98948
- if (value === "-inf")
98949
- return -Infinity;
98950
- if (value === "inf" || value === "+inf")
98951
- return Infinity;
98952
- if (value === "nan" || value === "+nan" || value === "-nan")
98953
- return NaN;
98954
- if (value === "-0")
98955
- return integersAsBigInt ? 0n : 0;
98956
- let isInt = INT_REGEX2.test(value);
98957
- if (isInt || FLOAT_REGEX2.test(value)) {
98958
- if (LEADING_ZERO2.test(value)) {
98959
- throw new TomlError2("leading zeroes are not allowed", {
98960
- toml,
98961
- ptr
98962
- });
99041
+ var npmInstall = async (ctx) => {
99042
+ const nodeModulesPath = import_node_path10.default.join(ctx.project.path, "node_modules");
99043
+ if ((0, import_node_fs9.existsSync)(nodeModulesPath)) {
99044
+ return;
99045
+ }
99046
+ const { npm: npm25 } = detectPackageManager();
99047
+ if (npm25 === "pnpm") {
99048
+ await pnpmInstallWithBuildApprovalRetry(npm25);
99049
+ return;
99050
+ }
99051
+ await runCommand([npm25, "install"], {
99052
+ silent: true,
99053
+ startText: "Installing dependencies",
99054
+ doneText: `${brandColor("installed")} ${dim(`via \`${npm25} install\``)}`
99055
+ });
99056
+ };
99057
+ var runPnpmInstallQuiet = async (npm25, startText) => {
99058
+ const s = spinner();
99059
+ s.start(startText);
99060
+ try {
99061
+ await runCommand([npm25, "install"], { silent: true, useSpinner: false });
99062
+ s.stop(`${brandColor("installed")} ${dim(`via \`${npm25} install\``)}`);
99063
+ } catch (err) {
99064
+ s.stop(red("install failed"));
99065
+ throw err;
99066
+ }
99067
+ };
99068
+ var pnpmInstallWithBuildApprovalRetry = async (npm25) => {
99069
+ try {
99070
+ await runPnpmInstallQuiet(npm25, "Installing dependencies");
99071
+ return;
99072
+ } catch (err) {
99073
+ if (!isPnpmIgnoredBuildsError(err)) {
99074
+ throw err;
98963
99075
  }
98964
- value = value.replace(/_/g, "");
98965
- let numeric = +value;
98966
- if (isNaN(numeric)) {
98967
- throw new TomlError2("invalid number", {
98968
- toml,
98969
- ptr
98970
- });
99076
+ await recoverFromIgnoredBuilds(npm25, err);
99077
+ }
99078
+ };
99079
+ var STDIN_EOF_MARKER = "__c3_stdin_eof__";
99080
+ var isStdinEOFError = (err) => err instanceof Error && err.message === STDIN_EOF_MARKER;
99081
+ var promptOrEOF = async (packages) => {
99082
+ const prompt = inputPrompt({
99083
+ type: "confirm",
99084
+ question: `Run \`pnpm approve-builds ${packages.join(" ")}\` and retry the install?`,
99085
+ label: "approve-builds",
99086
+ defaultValue: true,
99087
+ throwOnError: true
99088
+ });
99089
+ if (process.stdin.isTTY) {
99090
+ return prompt;
99091
+ }
99092
+ let onEnd;
99093
+ const eof = new Promise((_2, reject) => {
99094
+ onEnd = () => reject(new Error(STDIN_EOF_MARKER));
99095
+ process.stdin.once("end", onEnd);
99096
+ process.stdin.resume();
99097
+ });
99098
+ prompt.catch(() => {
99099
+ });
99100
+ try {
99101
+ return await Promise.race([prompt, eof]);
99102
+ } finally {
99103
+ if (onEnd) {
99104
+ process.stdin.removeListener("end", onEnd);
98971
99105
  }
98972
- if (isInt) {
98973
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
98974
- throw new TomlError2("integer value cannot be represented losslessly", {
98975
- toml,
98976
- ptr
98977
- });
98978
- }
98979
- if (isInt || integersAsBigInt === true)
98980
- numeric = BigInt(value);
99106
+ }
99107
+ };
99108
+ var recoverFromIgnoredBuilds = async (npm25, originalErr) => {
99109
+ const packages = extractIgnoredBuildPackages(originalErr);
99110
+ if (packages.length === 0) {
99111
+ throw new IgnoredBuildsError([], originalErr);
99112
+ }
99113
+ updateStatus(
99114
+ `${red("pnpm refused to run build scripts for:")} ${packages.join(", ")}`
99115
+ );
99116
+ let approve;
99117
+ try {
99118
+ approve = await promptOrEOF(packages);
99119
+ } catch (promptErr) {
99120
+ if (promptErr instanceof CancelError || isStdinEOFError(promptErr)) {
99121
+ throw new IgnoredBuildsError(packages, originalErr);
98981
99122
  }
98982
- return numeric;
99123
+ throw promptErr;
98983
99124
  }
98984
- const date = new TomlDate2(value);
98985
- if (!date.isValid()) {
98986
- throw new TomlError2("invalid value", {
98987
- toml,
98988
- ptr
98989
- });
99125
+ if (!approve) {
99126
+ throw new IgnoredBuildsError(packages, originalErr);
98990
99127
  }
98991
- return date;
99128
+ await runCommand([npm25, "approve-builds", ...packages], {
99129
+ silent: true,
99130
+ startText: "Approving dependency build scripts",
99131
+ doneText: `${brandColor("approved")} ${dim(packages.join(", "))}`
99132
+ });
99133
+ try {
99134
+ await runPnpmInstallQuiet(npm25, "Re-running install");
99135
+ } catch (retryErr) {
99136
+ if (isPnpmIgnoredBuildsError(retryErr)) {
99137
+ throw new IgnoredBuildsError(
99138
+ extractIgnoredBuildPackages(retryErr),
99139
+ retryErr
99140
+ );
99141
+ }
99142
+ throw retryErr;
99143
+ }
99144
+ };
99145
+ async function getLatestPackageVersion(packageSpecifier) {
99146
+ const resp = await (0, import_undici3.fetch)(`https://registry.npmjs.org/${packageSpecifier}`);
99147
+ const npmInfo = await resp.json();
99148
+ return npmInfo["dist-tags"].latest;
98992
99149
  }
98993
99150
 
98994
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/extract.js
98995
- function sliceAndTrimEndOf2(str, startPtr, endPtr, allowNewLines) {
98996
- let value = str.slice(startPtr, endPtr);
98997
- let commentIdx = value.indexOf("#");
98998
- if (commentIdx > -1) {
98999
- skipComment2(str, commentIdx);
99000
- value = value.slice(0, commentIdx);
99151
+ // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
99152
+ var import_node_process13 = __toESM(require("node:process"), 1);
99153
+ var import_node_path11 = __toESM(require("node:path"), 1);
99154
+ var import_node_url2 = require("node:url");
99155
+ var import_node_child_process8 = __toESM(require("node:child_process"), 1);
99156
+ var import_promises5 = __toESM(require("node:fs/promises"), 1);
99157
+
99158
+ // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
99159
+ var import_node_util3 = require("node:util");
99160
+ var import_node_child_process3 = __toESM(require("node:child_process"), 1);
99161
+ var import_promises4 = __toESM(require("node:fs/promises"), 1);
99162
+
99163
+ // ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
99164
+ var import_node_process7 = __toESM(require("node:process"), 1);
99165
+ var import_node_os5 = __toESM(require("node:os"), 1);
99166
+ var import_node_fs12 = __toESM(require("node:fs"), 1);
99167
+
99168
+ // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
99169
+ var import_node_fs11 = __toESM(require("node:fs"), 1);
99170
+
99171
+ // ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
99172
+ var import_node_fs10 = __toESM(require("node:fs"), 1);
99173
+ var isDockerCached;
99174
+ function hasDockerEnv() {
99175
+ try {
99176
+ import_node_fs10.default.statSync("/.dockerenv");
99177
+ return true;
99178
+ } catch {
99179
+ return false;
99001
99180
  }
99002
- let trimmed = value.trimEnd();
99003
- if (!allowNewLines) {
99004
- let newlineIdx = value.indexOf("\n", trimmed.length);
99005
- if (newlineIdx > -1) {
99006
- throw new TomlError2("newlines are not allowed in inline tables", {
99007
- toml: str,
99008
- ptr: startPtr + newlineIdx
99009
- });
99010
- }
99181
+ }
99182
+ function hasDockerCGroup() {
99183
+ try {
99184
+ return import_node_fs10.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
99185
+ } catch {
99186
+ return false;
99011
99187
  }
99012
- return [trimmed, commentIdx];
99013
99188
  }
99014
- function extractValue2(str, ptr, end, depth, integersAsBigInt) {
99015
- if (depth === 0) {
99016
- throw new TomlError2("document contains excessively nested structures. aborting.", {
99017
- toml: str,
99018
- ptr
99019
- });
99189
+ function isDocker() {
99190
+ if (isDockerCached === void 0) {
99191
+ isDockerCached = hasDockerEnv() || hasDockerCGroup();
99020
99192
  }
99021
- let c2 = str[ptr];
99022
- if (c2 === "[" || c2 === "{") {
99023
- let [value, endPtr2] = c2 === "[" ? parseArray2(str, ptr, depth, integersAsBigInt) : parseInlineTable2(str, ptr, depth, integersAsBigInt);
99024
- let newPtr = end ? skipUntil2(str, endPtr2, ",", end) : endPtr2;
99025
- if (endPtr2 - newPtr && end === "}") {
99026
- let nextNewLine = indexOfNewline2(str, endPtr2, newPtr);
99027
- if (nextNewLine > -1) {
99028
- throw new TomlError2("newlines are not allowed in inline tables", {
99029
- toml: str,
99030
- ptr: nextNewLine
99031
- });
99032
- }
99033
- }
99034
- return [value, newPtr];
99193
+ return isDockerCached;
99194
+ }
99195
+
99196
+ // ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
99197
+ var cachedResult;
99198
+ var hasContainerEnv = () => {
99199
+ try {
99200
+ import_node_fs11.default.statSync("/run/.containerenv");
99201
+ return true;
99202
+ } catch {
99203
+ return false;
99035
99204
  }
99036
- let endPtr;
99037
- if (c2 === '"' || c2 === "'") {
99038
- endPtr = getStringEnd2(str, ptr);
99039
- let parsed = parseString2(str, ptr, endPtr);
99040
- if (end) {
99041
- endPtr = skipVoid2(str, endPtr, end !== "]");
99042
- if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") {
99043
- throw new TomlError2("unexpected character encountered", {
99044
- toml: str,
99045
- ptr: endPtr
99046
- });
99047
- }
99048
- endPtr += +(str[endPtr] === ",");
99205
+ };
99206
+ function isInsideContainer() {
99207
+ if (cachedResult === void 0) {
99208
+ cachedResult = hasContainerEnv() || isDocker();
99209
+ }
99210
+ return cachedResult;
99211
+ }
99212
+
99213
+ // ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
99214
+ var isWsl = () => {
99215
+ if (import_node_process7.default.platform !== "linux") {
99216
+ return false;
99217
+ }
99218
+ if (import_node_os5.default.release().toLowerCase().includes("microsoft")) {
99219
+ if (isInsideContainer()) {
99220
+ return false;
99049
99221
  }
99050
- return [parsed, endPtr];
99222
+ return true;
99051
99223
  }
99052
- endPtr = skipUntil2(str, ptr, ",", end);
99053
- let slice = sliceAndTrimEndOf2(str, ptr, endPtr - +(str[endPtr - 1] === ","), end === "]");
99054
- if (!slice[0]) {
99055
- throw new TomlError2("incomplete key-value declaration: no value specified", {
99056
- toml: str,
99057
- ptr
99058
- });
99224
+ try {
99225
+ return import_node_fs12.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
99226
+ } catch {
99227
+ return false;
99059
99228
  }
99060
- if (end && slice[1] > -1) {
99061
- endPtr = skipVoid2(str, ptr + slice[1]);
99062
- endPtr += +(str[endPtr] === ",");
99229
+ };
99230
+ var is_wsl_default = import_node_process7.default.env.__IS_WSL_TEST__ ? isWsl : isWsl();
99231
+
99232
+ // ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
99233
+ var import_node_process8 = __toESM(require("node:process"), 1);
99234
+ var import_node_buffer = require("node:buffer");
99235
+ var import_node_util2 = require("node:util");
99236
+ var import_node_child_process2 = __toESM(require("node:child_process"), 1);
99237
+ var execFile = (0, import_node_util2.promisify)(import_node_child_process2.default.execFile);
99238
+ var powerShellPath = () => `${import_node_process8.default.env.SYSTEMROOT || import_node_process8.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
99239
+ var executePowerShell = async (command2, options = {}) => {
99240
+ const {
99241
+ powerShellPath: psPath,
99242
+ ...execFileOptions
99243
+ } = options;
99244
+ const encodedCommand = executePowerShell.encodeCommand(command2);
99245
+ return execFile(
99246
+ psPath ?? powerShellPath(),
99247
+ [
99248
+ ...executePowerShell.argumentsPrefix,
99249
+ encodedCommand
99250
+ ],
99251
+ {
99252
+ encoding: "utf8",
99253
+ ...execFileOptions
99254
+ }
99255
+ );
99256
+ };
99257
+ executePowerShell.argumentsPrefix = [
99258
+ "-NoProfile",
99259
+ "-NonInteractive",
99260
+ "-ExecutionPolicy",
99261
+ "Bypass",
99262
+ "-EncodedCommand"
99263
+ ];
99264
+ executePowerShell.encodeCommand = (command2) => import_node_buffer.Buffer.from(command2, "utf16le").toString("base64");
99265
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
99266
+
99267
+ // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
99268
+ function parseMountPointFromConfig(content) {
99269
+ for (const line of content.split("\n")) {
99270
+ if (/^\s*#/.test(line)) {
99271
+ continue;
99272
+ }
99273
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
99274
+ if (!match) {
99275
+ continue;
99276
+ }
99277
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
99063
99278
  }
99064
- return [
99065
- parseValue2(slice[0], str, ptr, integersAsBigInt),
99066
- endPtr
99067
- ];
99068
99279
  }
99069
99280
 
99070
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/struct.js
99071
- var KEY_PART_RE2 = /^[a-zA-Z0-9-_]+[ \t]*$/;
99072
- function parseKey2(str, ptr, end = "=") {
99073
- let dot = ptr - 1;
99074
- let parsed = [];
99075
- let endPtr = str.indexOf(end, ptr);
99076
- if (endPtr < 0) {
99077
- throw new TomlError2("incomplete key-value: cannot find end of key", {
99078
- toml: str,
99079
- ptr
99080
- });
99281
+ // ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
99282
+ var execFile2 = (0, import_node_util3.promisify)(import_node_child_process3.default.execFile);
99283
+ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
99284
+ const defaultMountPoint = "/mnt/";
99285
+ let mountPoint;
99286
+ return async function() {
99287
+ if (mountPoint) {
99288
+ return mountPoint;
99289
+ }
99290
+ const configFilePath = "/etc/wsl.conf";
99291
+ let isConfigFileExists = false;
99292
+ try {
99293
+ await import_promises4.default.access(configFilePath, import_promises4.constants.F_OK);
99294
+ isConfigFileExists = true;
99295
+ } catch {
99296
+ }
99297
+ if (!isConfigFileExists) {
99298
+ return defaultMountPoint;
99299
+ }
99300
+ const configContent = await import_promises4.default.readFile(configFilePath, { encoding: "utf8" });
99301
+ const parsedMountPoint = parseMountPointFromConfig(configContent);
99302
+ if (parsedMountPoint === void 0) {
99303
+ return defaultMountPoint;
99304
+ }
99305
+ mountPoint = parsedMountPoint;
99306
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
99307
+ return mountPoint;
99308
+ };
99309
+ })();
99310
+ var powerShellPathFromWsl = async () => {
99311
+ const mountPoint = await wslDrivesMountPoint();
99312
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
99313
+ };
99314
+ var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
99315
+ var canAccessPowerShellPromise;
99316
+ var canAccessPowerShell = async () => {
99317
+ canAccessPowerShellPromise ??= (async () => {
99318
+ try {
99319
+ const psPath = await powerShellPath2();
99320
+ await import_promises4.default.access(psPath, import_promises4.constants.X_OK);
99321
+ return true;
99322
+ } catch {
99323
+ return false;
99324
+ }
99325
+ })();
99326
+ return canAccessPowerShellPromise;
99327
+ };
99328
+ var wslDefaultBrowser = async () => {
99329
+ const psPath = await powerShellPath2();
99330
+ const command2 = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
99331
+ const { stdout: stdout2 } = await executePowerShell(command2, { powerShellPath: psPath });
99332
+ return stdout2.trim();
99333
+ };
99334
+ var convertWslPathToWindows = async (path6) => {
99335
+ if (/^[a-z]+:\/\//i.test(path6)) {
99336
+ return path6;
99081
99337
  }
99082
- do {
99083
- let c2 = str[ptr = ++dot];
99084
- if (c2 !== " " && c2 !== " ") {
99085
- if (c2 === '"' || c2 === "'") {
99086
- if (c2 === str[ptr + 1] && c2 === str[ptr + 2]) {
99087
- throw new TomlError2("multiline strings are not allowed in keys", {
99088
- toml: str,
99089
- ptr
99090
- });
99091
- }
99092
- let eos = getStringEnd2(str, ptr);
99093
- if (eos < 0) {
99094
- throw new TomlError2("unfinished string encountered", {
99095
- toml: str,
99096
- ptr
99097
- });
99098
- }
99099
- dot = str.indexOf(".", eos);
99100
- let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
99101
- let newLine = indexOfNewline2(strEnd);
99102
- if (newLine > -1) {
99103
- throw new TomlError2("newlines are not allowed in keys", {
99104
- toml: str,
99105
- ptr: ptr + dot + newLine
99106
- });
99107
- }
99108
- if (strEnd.trimStart()) {
99109
- throw new TomlError2("found extra tokens after the string part", {
99110
- toml: str,
99111
- ptr: eos
99112
- });
99113
- }
99114
- if (endPtr < eos) {
99115
- endPtr = str.indexOf(end, eos);
99116
- if (endPtr < 0) {
99117
- throw new TomlError2("incomplete key-value: cannot find end of key", {
99118
- toml: str,
99119
- ptr
99120
- });
99121
- }
99122
- }
99123
- parsed.push(parseString2(str, ptr, eos));
99124
- } else {
99125
- dot = str.indexOf(".", ptr);
99126
- let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
99127
- if (!KEY_PART_RE2.test(part)) {
99128
- throw new TomlError2("only letter, numbers, dashes and underscores are allowed in keys", {
99129
- toml: str,
99130
- ptr
99131
- });
99132
- }
99133
- parsed.push(part.trimEnd());
99134
- }
99338
+ try {
99339
+ const { stdout: stdout2 } = await execFile2("wslpath", ["-aw", path6], { encoding: "utf8" });
99340
+ return stdout2.trim();
99341
+ } catch {
99342
+ return path6;
99343
+ }
99344
+ };
99345
+
99346
+ // ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
99347
+ function defineLazyProperty(object, propertyName, valueGetter) {
99348
+ const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
99349
+ Object.defineProperty(object, propertyName, {
99350
+ configurable: true,
99351
+ enumerable: true,
99352
+ get() {
99353
+ const result = valueGetter();
99354
+ define2(result);
99355
+ return result;
99356
+ },
99357
+ set(value) {
99358
+ define2(value);
99135
99359
  }
99136
- } while (dot + 1 && dot < endPtr);
99137
- return [parsed, skipVoid2(str, endPtr + 1, true, true)];
99360
+ });
99361
+ return object;
99138
99362
  }
99139
- function parseInlineTable2(str, ptr, depth, integersAsBigInt) {
99140
- let res = {};
99141
- let seen = /* @__PURE__ */ new Set();
99142
- let c2;
99143
- let comma = 0;
99144
- ptr++;
99145
- while ((c2 = str[ptr++]) !== "}" && c2) {
99146
- let err = { toml: str, ptr: ptr - 1 };
99147
- if (c2 === "\n") {
99148
- throw new TomlError2("newlines are not allowed in inline tables", err);
99149
- } else if (c2 === "#") {
99150
- throw new TomlError2("inline tables cannot contain comments", err);
99151
- } else if (c2 === ",") {
99152
- throw new TomlError2("expected key-value, found comma", err);
99153
- } else if (c2 !== " " && c2 !== " ") {
99154
- let k;
99155
- let t2 = res;
99156
- let hasOwn = false;
99157
- let [key, keyEndPtr] = parseKey2(str, ptr - 1);
99158
- for (let i = 0; i < key.length; i++) {
99159
- if (i)
99160
- t2 = hasOwn ? t2[k] : t2[k] = {};
99161
- k = key[i];
99162
- if ((hasOwn = Object.hasOwn(t2, k)) && (typeof t2[k] !== "object" || seen.has(t2[k]))) {
99163
- throw new TomlError2("trying to redefine an already defined value", {
99164
- toml: str,
99165
- ptr
99166
- });
99167
- }
99168
- if (!hasOwn && k === "__proto__") {
99169
- Object.defineProperty(t2, k, { enumerable: true, configurable: true, writable: true });
99170
- }
99171
- }
99172
- if (hasOwn) {
99173
- throw new TomlError2("trying to redefine an already defined value", {
99174
- toml: str,
99175
- ptr
99176
- });
99177
- }
99178
- let [value, valueEndPtr] = extractValue2(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
99179
- seen.add(value);
99180
- t2[k] = value;
99181
- ptr = valueEndPtr;
99182
- comma = str[ptr - 1] === "," ? ptr - 1 : 0;
99183
- }
99363
+
99364
+ // ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/index.js
99365
+ var import_node_util7 = require("node:util");
99366
+ var import_node_process11 = __toESM(require("node:process"), 1);
99367
+ var import_node_child_process7 = require("node:child_process");
99368
+
99369
+ // ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
99370
+ var import_node_util4 = require("node:util");
99371
+ var import_node_process9 = __toESM(require("node:process"), 1);
99372
+ var import_node_child_process4 = require("node:child_process");
99373
+ var execFileAsync = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
99374
+ async function defaultBrowserId() {
99375
+ if (import_node_process9.default.platform !== "darwin") {
99376
+ throw new Error("macOS only");
99184
99377
  }
99185
- if (comma) {
99186
- throw new TomlError2("trailing commas are not allowed in inline tables", {
99187
- toml: str,
99188
- ptr: comma
99189
- });
99378
+ const { stdout: stdout2 } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
99379
+ const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout2);
99380
+ const browserId = match?.groups.id ?? "com.apple.Safari";
99381
+ if (browserId === "com.apple.safari") {
99382
+ return "com.apple.Safari";
99190
99383
  }
99191
- if (!c2) {
99192
- throw new TomlError2("unfinished table encountered", {
99193
- toml: str,
99194
- ptr
99195
- });
99384
+ return browserId;
99385
+ }
99386
+
99387
+ // ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
99388
+ var import_node_process10 = __toESM(require("node:process"), 1);
99389
+ var import_node_util5 = require("node:util");
99390
+ var import_node_child_process5 = require("node:child_process");
99391
+ var execFileAsync2 = (0, import_node_util5.promisify)(import_node_child_process5.execFile);
99392
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
99393
+ if (import_node_process10.default.platform !== "darwin") {
99394
+ throw new Error("macOS only");
99196
99395
  }
99197
- return [res, ptr];
99396
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
99397
+ const execOptions = {};
99398
+ if (signal) {
99399
+ execOptions.signal = signal;
99400
+ }
99401
+ const { stdout: stdout2 } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
99402
+ return stdout2.trim();
99198
99403
  }
99199
- function parseArray2(str, ptr, depth, integersAsBigInt) {
99200
- let res = [];
99201
- let c2;
99202
- ptr++;
99203
- while ((c2 = str[ptr++]) !== "]" && c2) {
99204
- if (c2 === ",") {
99205
- throw new TomlError2("expected value, found comma", {
99206
- toml: str,
99207
- ptr: ptr - 1
99208
- });
99209
- } else if (c2 === "#")
99210
- ptr = skipComment2(str, ptr);
99211
- else if (c2 !== " " && c2 !== " " && c2 !== "\n" && c2 !== "\r") {
99212
- let e = extractValue2(str, ptr - 1, "]", depth - 1, integersAsBigInt);
99213
- res.push(e[0]);
99214
- ptr = e[1];
99215
- }
99404
+
99405
+ // ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
99406
+ async function bundleName(bundleId) {
99407
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
99408
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
99409
+ }
99410
+
99411
+ // ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/windows.js
99412
+ var import_node_util6 = require("node:util");
99413
+ var import_node_child_process6 = require("node:child_process");
99414
+ var execFileAsync3 = (0, import_node_util6.promisify)(import_node_child_process6.execFile);
99415
+ var windowsBrowserProgIds = {
99416
+ MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
99417
+ // The missing `L` is correct.
99418
+ MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
99419
+ MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
99420
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
99421
+ ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
99422
+ ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
99423
+ ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
99424
+ ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
99425
+ BraveHTML: { name: "Brave", id: "com.brave.Browser" },
99426
+ BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
99427
+ BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
99428
+ BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
99429
+ FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
99430
+ OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
99431
+ VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
99432
+ "IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
99433
+ };
99434
+ var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
99435
+ var UnknownBrowserError = class extends Error {
99436
+ };
99437
+ async function defaultBrowser(_execFileAsync = execFileAsync3) {
99438
+ const { stdout: stdout2 } = await _execFileAsync("reg", [
99439
+ "QUERY",
99440
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
99441
+ "/v",
99442
+ "ProgId"
99443
+ ]);
99444
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout2);
99445
+ if (!match) {
99446
+ throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout2)}`);
99216
99447
  }
99217
- if (!c2) {
99218
- throw new TomlError2("unfinished array encountered", {
99219
- toml: str,
99220
- ptr
99221
- });
99448
+ const { id } = match.groups;
99449
+ const browser = windowsBrowserProgIds[id];
99450
+ if (!browser) {
99451
+ throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
99222
99452
  }
99223
- return [res, ptr];
99453
+ return browser;
99224
99454
  }
99225
99455
 
99226
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/parse.js
99227
- function peekTable2(key, table, meta, type) {
99228
- let t2 = table;
99229
- let m = meta;
99230
- let k;
99231
- let hasOwn = false;
99232
- let state;
99233
- for (let i = 0; i < key.length; i++) {
99234
- if (i) {
99235
- t2 = hasOwn ? t2[k] : t2[k] = {};
99236
- m = (state = m[k]).c;
99237
- if (type === 0 && (state.t === 1 || state.t === 2)) {
99238
- return null;
99239
- }
99240
- if (state.t === 2) {
99241
- let l = t2.length - 1;
99242
- t2 = t2[l];
99243
- m = m[l].c;
99244
- }
99456
+ // ../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/index.js
99457
+ var execFileAsync4 = (0, import_node_util7.promisify)(import_node_child_process7.execFile);
99458
+ var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
99459
+ async function defaultBrowser2() {
99460
+ if (import_node_process11.default.platform === "darwin") {
99461
+ const id = await defaultBrowserId();
99462
+ const name3 = await bundleName(id);
99463
+ return { name: name3, id };
99464
+ }
99465
+ if (import_node_process11.default.platform === "linux") {
99466
+ const { stdout: stdout2 } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
99467
+ const id = stdout2.trim();
99468
+ const name3 = titleize(id.replace(/.desktop$/, "").replace("-", " "));
99469
+ return { name: name3, id };
99470
+ }
99471
+ if (import_node_process11.default.platform === "win32") {
99472
+ return defaultBrowser();
99473
+ }
99474
+ throw new Error("Only macOS, Linux, and Windows are supported");
99475
+ }
99476
+
99477
+ // ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
99478
+ var import_node_process12 = __toESM(require("node:process"), 1);
99479
+ var isInSsh = Boolean(import_node_process12.default.env.SSH_CONNECTION || import_node_process12.default.env.SSH_CLIENT || import_node_process12.default.env.SSH_TTY);
99480
+ var is_in_ssh_default = isInSsh;
99481
+
99482
+ // ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
99483
+ var import_meta2 = {};
99484
+ var fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
99485
+ var __dirname3 = import_meta2.url ? import_node_path11.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)) : "";
99486
+ var localXdgOpenPath = import_node_path11.default.join(__dirname3, "xdg-open");
99487
+ var { platform, arch: arch2 } = import_node_process13.default;
99488
+ var tryEachApp = async (apps2, opener) => {
99489
+ if (apps2.length === 0) {
99490
+ return;
99491
+ }
99492
+ const errors = [];
99493
+ for (const app of apps2) {
99494
+ try {
99495
+ return await opener(app);
99496
+ } catch (error2) {
99497
+ errors.push(error2);
99245
99498
  }
99246
- k = key[i];
99247
- if ((hasOwn = Object.hasOwn(t2, k)) && m[k]?.t === 0 && m[k]?.d) {
99248
- return null;
99499
+ }
99500
+ throw new AggregateError(errors, "Failed to open in all supported apps");
99501
+ };
99502
+ var baseOpen = async (options) => {
99503
+ options = {
99504
+ wait: false,
99505
+ background: false,
99506
+ newInstance: false,
99507
+ allowNonzeroExitCode: false,
99508
+ ...options
99509
+ };
99510
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
99511
+ delete options[fallbackAttemptSymbol];
99512
+ if (Array.isArray(options.app)) {
99513
+ return tryEachApp(options.app, (singleApp) => baseOpen({
99514
+ ...options,
99515
+ app: singleApp,
99516
+ [fallbackAttemptSymbol]: true
99517
+ }));
99518
+ }
99519
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
99520
+ appArguments = [...appArguments];
99521
+ if (Array.isArray(app)) {
99522
+ return tryEachApp(app, (appName) => baseOpen({
99523
+ ...options,
99524
+ app: {
99525
+ name: appName,
99526
+ arguments: appArguments
99527
+ },
99528
+ [fallbackAttemptSymbol]: true
99529
+ }));
99530
+ }
99531
+ if (app === "browser" || app === "browserPrivate") {
99532
+ const ids = {
99533
+ "com.google.chrome": "chrome",
99534
+ "google-chrome.desktop": "chrome",
99535
+ "com.brave.browser": "brave",
99536
+ "org.mozilla.firefox": "firefox",
99537
+ "firefox.desktop": "firefox",
99538
+ "com.microsoft.msedge": "edge",
99539
+ "com.microsoft.edge": "edge",
99540
+ "com.microsoft.edgemac": "edge",
99541
+ "microsoft-edge.desktop": "edge",
99542
+ "com.apple.safari": "safari"
99543
+ };
99544
+ const flags = {
99545
+ chrome: "--incognito",
99546
+ brave: "--incognito",
99547
+ firefox: "--private-window",
99548
+ edge: "--inPrivate"
99549
+ // Safari doesn't support private mode via command line
99550
+ };
99551
+ let browser;
99552
+ if (is_wsl_default) {
99553
+ const progId = await wslDefaultBrowser();
99554
+ const browserInfo = _windowsBrowserProgIdMap.get(progId);
99555
+ browser = browserInfo ?? {};
99556
+ } else {
99557
+ browser = await defaultBrowser2();
99249
99558
  }
99250
- if (!hasOwn) {
99251
- if (k === "__proto__") {
99252
- Object.defineProperty(t2, k, { enumerable: true, configurable: true, writable: true });
99253
- Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
99559
+ if (browser.id in ids) {
99560
+ const browserName = ids[browser.id.toLowerCase()];
99561
+ if (app === "browserPrivate") {
99562
+ if (browserName === "safari") {
99563
+ throw new Error("Safari doesn't support opening in private mode via command line");
99564
+ }
99565
+ appArguments.push(flags[browserName]);
99254
99566
  }
99255
- m[k] = {
99256
- t: i < key.length - 1 && type === 2 ? 3 : type,
99257
- d: false,
99258
- i: 0,
99259
- c: {}
99260
- };
99567
+ return baseOpen({
99568
+ ...options,
99569
+ app: {
99570
+ name: apps[browserName],
99571
+ arguments: appArguments
99572
+ }
99573
+ });
99261
99574
  }
99575
+ throw new Error(`${browser.name} is not supported as a default browser`);
99262
99576
  }
99263
- state = m[k];
99264
- if (state.t !== type && !(type === 1 && state.t === 3)) {
99265
- return null;
99577
+ let command2;
99578
+ const cliArguments = [];
99579
+ const childProcessOptions = {};
99580
+ let shouldUseWindowsInWsl = false;
99581
+ if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
99582
+ shouldUseWindowsInWsl = await canAccessPowerShell();
99266
99583
  }
99267
- if (type === 2) {
99268
- if (!state.d) {
99269
- state.d = true;
99270
- t2[k] = [];
99584
+ if (platform === "darwin") {
99585
+ command2 = "open";
99586
+ if (options.wait) {
99587
+ cliArguments.push("--wait-apps");
99271
99588
  }
99272
- t2[k].push(t2 = {});
99273
- state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
99274
- }
99275
- if (state.d) {
99276
- return null;
99277
- }
99278
- state.d = true;
99279
- if (type === 1) {
99280
- t2 = hasOwn ? t2[k] : t2[k] = {};
99281
- } else if (type === 0 && hasOwn) {
99282
- return null;
99283
- }
99284
- return [k, t2, state.c];
99285
- }
99286
- function parse4(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
99287
- let res = {};
99288
- let meta = {};
99289
- let tbl = res;
99290
- let m = meta;
99291
- for (let ptr = skipVoid2(toml, 0); ptr < toml.length; ) {
99292
- if (toml[ptr] === "[") {
99293
- let isTableArray = toml[++ptr] === "[";
99294
- let k = parseKey2(toml, ptr += +isTableArray, "]");
99295
- if (isTableArray) {
99296
- if (toml[k[1] - 1] !== "]") {
99297
- throw new TomlError2("expected end of table declaration", {
99298
- toml,
99299
- ptr: k[1] - 1
99300
- });
99301
- }
99302
- k[1]++;
99303
- }
99304
- let p2 = peekTable2(
99305
- k[0],
99306
- res,
99307
- meta,
99308
- isTableArray ? 2 : 1
99309
- /* Type.EXPLICIT */
99310
- );
99311
- if (!p2) {
99312
- throw new TomlError2("trying to redefine an already defined table or value", {
99313
- toml,
99314
- ptr
99315
- });
99589
+ if (options.background) {
99590
+ cliArguments.push("--background");
99591
+ }
99592
+ if (options.newInstance) {
99593
+ cliArguments.push("--new");
99594
+ }
99595
+ if (app) {
99596
+ cliArguments.push("-a", app);
99597
+ }
99598
+ } else if (platform === "win32" || shouldUseWindowsInWsl) {
99599
+ command2 = await powerShellPath2();
99600
+ cliArguments.push(...executePowerShell.argumentsPrefix);
99601
+ if (!is_wsl_default) {
99602
+ childProcessOptions.windowsVerbatimArguments = true;
99603
+ }
99604
+ if (is_wsl_default && options.target) {
99605
+ options.target = await convertWslPathToWindows(options.target);
99606
+ }
99607
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
99608
+ if (options.wait) {
99609
+ encodedArguments.push("-Wait");
99610
+ }
99611
+ if (app) {
99612
+ encodedArguments.push(executePowerShell.escapeArgument(app));
99613
+ if (options.target) {
99614
+ appArguments.push(options.target);
99316
99615
  }
99317
- m = p2[2];
99318
- tbl = p2[1];
99319
- ptr = k[1];
99616
+ } else if (options.target) {
99617
+ encodedArguments.push(executePowerShell.escapeArgument(options.target));
99618
+ }
99619
+ if (appArguments.length > 0) {
99620
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
99621
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
99622
+ }
99623
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
99624
+ if (!options.wait) {
99625
+ childProcessOptions.stdio = "ignore";
99626
+ }
99627
+ } else {
99628
+ if (app) {
99629
+ command2 = app;
99320
99630
  } else {
99321
- let k = parseKey2(toml, ptr);
99322
- let p2 = peekTable2(
99323
- k[0],
99324
- tbl,
99325
- m,
99326
- 0
99327
- /* Type.DOTTED */
99328
- );
99329
- if (!p2) {
99330
- throw new TomlError2("trying to redefine an already defined table or value", {
99331
- toml,
99332
- ptr
99333
- });
99631
+ const isBundled = !__dirname3 || __dirname3 === "/";
99632
+ let exeLocalXdgOpen = false;
99633
+ try {
99634
+ await import_promises5.default.access(localXdgOpenPath, import_promises5.constants.X_OK);
99635
+ exeLocalXdgOpen = true;
99636
+ } catch {
99334
99637
  }
99335
- let v = extractValue2(toml, k[1], void 0, maxDepth, integersAsBigInt);
99336
- p2[1][p2[0]] = v[0];
99337
- ptr = v[1];
99638
+ const useSystemXdgOpen = import_node_process13.default.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
99639
+ command2 = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
99338
99640
  }
99339
- ptr = skipVoid2(toml, ptr, true);
99340
- if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") {
99341
- throw new TomlError2("each key-value declaration must be followed by an end-of-line", {
99342
- toml,
99343
- ptr
99344
- });
99641
+ if (appArguments.length > 0) {
99642
+ cliArguments.push(...appArguments);
99643
+ }
99644
+ if (!options.wait) {
99645
+ childProcessOptions.stdio = "ignore";
99646
+ childProcessOptions.detached = true;
99345
99647
  }
99346
- ptr = skipVoid2(toml, ptr);
99347
- }
99348
- return res;
99349
- }
99350
-
99351
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/stringify.js
99352
- var BARE_KEY2 = /^[a-z0-9-_]+$/i;
99353
- function extendedTypeOf2(obj) {
99354
- let type = typeof obj;
99355
- if (type === "object") {
99356
- if (Array.isArray(obj))
99357
- return "array";
99358
- if (obj instanceof Date)
99359
- return "date";
99360
- }
99361
- return type;
99362
- }
99363
- function isArrayOfTables2(obj) {
99364
- for (let i = 0; i < obj.length; i++) {
99365
- if (extendedTypeOf2(obj[i]) !== "object")
99366
- return false;
99367
- }
99368
- return obj.length != 0;
99369
- }
99370
- function formatString2(s) {
99371
- return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
99372
- }
99373
- function stringifyValue2(val, type, depth, numberAsFloat) {
99374
- if (depth === 0) {
99375
- throw new Error("Could not stringify the object: maximum object depth exceeded");
99376
- }
99377
- if (type === "number") {
99378
- if (isNaN(val))
99379
- return "nan";
99380
- if (val === Infinity)
99381
- return "inf";
99382
- if (val === -Infinity)
99383
- return "-inf";
99384
- if (numberAsFloat && Number.isInteger(val))
99385
- return val.toFixed(1);
99386
- return val.toString();
99387
99648
  }
99388
- if (type === "bigint" || type === "boolean") {
99389
- return val.toString();
99649
+ if (platform === "darwin" && appArguments.length > 0) {
99650
+ cliArguments.push("--args", ...appArguments);
99390
99651
  }
99391
- if (type === "string") {
99392
- return formatString2(val);
99652
+ if (options.target) {
99653
+ cliArguments.push(options.target);
99393
99654
  }
99394
- if (type === "date") {
99395
- if (isNaN(val.getTime())) {
99396
- throw new TypeError("cannot serialize invalid date");
99397
- }
99398
- return val.toISOString();
99655
+ const subprocess = import_node_child_process8.default.spawn(command2, cliArguments, childProcessOptions);
99656
+ if (options.wait) {
99657
+ return new Promise((resolve13, reject) => {
99658
+ subprocess.once("error", reject);
99659
+ subprocess.once("close", (exitCode) => {
99660
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
99661
+ reject(new Error(`Exited with code ${exitCode}`));
99662
+ return;
99663
+ }
99664
+ resolve13(subprocess);
99665
+ });
99666
+ });
99399
99667
  }
99400
- if (type === "object") {
99401
- return stringifyInlineTable2(val, depth, numberAsFloat);
99668
+ if (isFallbackAttempt) {
99669
+ return new Promise((resolve13, reject) => {
99670
+ subprocess.once("error", reject);
99671
+ subprocess.once("spawn", () => {
99672
+ subprocess.once("close", (exitCode) => {
99673
+ subprocess.off("error", reject);
99674
+ if (exitCode !== 0) {
99675
+ reject(new Error(`Exited with code ${exitCode}`));
99676
+ return;
99677
+ }
99678
+ subprocess.unref();
99679
+ resolve13(subprocess);
99680
+ });
99681
+ });
99682
+ });
99402
99683
  }
99403
- if (type === "array") {
99404
- return stringifyArray2(val, depth, numberAsFloat);
99684
+ subprocess.unref();
99685
+ return new Promise((resolve13, reject) => {
99686
+ subprocess.once("error", reject);
99687
+ subprocess.once("spawn", () => {
99688
+ subprocess.off("error", reject);
99689
+ resolve13(subprocess);
99690
+ });
99691
+ });
99692
+ };
99693
+ var open = (target, options) => {
99694
+ if (typeof target !== "string") {
99695
+ throw new TypeError("Expected a `target`");
99405
99696
  }
99406
- }
99407
- function stringifyInlineTable2(obj, depth, numberAsFloat) {
99408
- let keys = Object.keys(obj);
99409
- if (keys.length === 0)
99410
- return "{}";
99411
- let res = "{ ";
99412
- for (let i = 0; i < keys.length; i++) {
99413
- let k = keys[i];
99414
- if (i)
99415
- res += ", ";
99416
- res += BARE_KEY2.test(k) ? k : formatString2(k);
99417
- res += " = ";
99418
- res += stringifyValue2(obj[k], extendedTypeOf2(obj[k]), depth - 1, numberAsFloat);
99697
+ return baseOpen({
99698
+ ...options,
99699
+ target
99700
+ });
99701
+ };
99702
+ function detectArchBinary(binary) {
99703
+ if (typeof binary === "string" || Array.isArray(binary)) {
99704
+ return binary;
99419
99705
  }
99420
- return res + " }";
99421
- }
99422
- function stringifyArray2(array, depth, numberAsFloat) {
99423
- if (array.length === 0)
99424
- return "[]";
99425
- let res = "[ ";
99426
- for (let i = 0; i < array.length; i++) {
99427
- if (i)
99428
- res += ", ";
99429
- if (array[i] === null || array[i] === void 0) {
99430
- throw new TypeError("arrays cannot contain null or undefined values");
99431
- }
99432
- res += stringifyValue2(array[i], extendedTypeOf2(array[i]), depth - 1, numberAsFloat);
99706
+ const { [arch2]: archBinary } = binary;
99707
+ if (!archBinary) {
99708
+ throw new Error(`${arch2} is not supported`);
99433
99709
  }
99434
- return res + " ]";
99710
+ return archBinary;
99435
99711
  }
99436
- function stringifyArrayTable2(array, key, depth, numberAsFloat) {
99437
- if (depth === 0) {
99438
- throw new Error("Could not stringify the object: maximum object depth exceeded");
99712
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
99713
+ if (wsl && is_wsl_default) {
99714
+ return detectArchBinary(wsl);
99439
99715
  }
99440
- let res = "";
99441
- for (let i = 0; i < array.length; i++) {
99442
- res += `${res && "\n"}[[${key}]]
99443
- `;
99444
- res += stringifyTable2(0, array[i], key, depth, numberAsFloat);
99716
+ if (!platformBinary) {
99717
+ throw new Error(`${platform} is not supported`);
99445
99718
  }
99446
- return res;
99719
+ return detectArchBinary(platformBinary);
99447
99720
  }
99448
- function stringifyTable2(tableKey, obj, prefix, depth, numberAsFloat) {
99449
- if (depth === 0) {
99450
- throw new Error("Could not stringify the object: maximum object depth exceeded");
99451
- }
99452
- let preamble = "";
99453
- let tables = "";
99454
- let keys = Object.keys(obj);
99455
- for (let i = 0; i < keys.length; i++) {
99456
- let k = keys[i];
99457
- if (obj[k] !== null && obj[k] !== void 0) {
99458
- let type = extendedTypeOf2(obj[k]);
99459
- if (type === "symbol" || type === "function") {
99460
- throw new TypeError(`cannot serialize values of type '${type}'`);
99461
- }
99462
- let key = BARE_KEY2.test(k) ? k : formatString2(k);
99463
- if (type === "array" && isArrayOfTables2(obj[k])) {
99464
- tables += (tables && "\n") + stringifyArrayTable2(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
99465
- } else if (type === "object") {
99466
- let tblKey = prefix ? `${prefix}.${key}` : key;
99467
- tables += (tables && "\n") + stringifyTable2(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
99468
- } else {
99469
- preamble += key;
99470
- preamble += " = ";
99471
- preamble += stringifyValue2(obj[k], type, depth, numberAsFloat);
99472
- preamble += "\n";
99473
- }
99474
- }
99721
+ var apps = {
99722
+ browser: "browser",
99723
+ browserPrivate: "browserPrivate"
99724
+ };
99725
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
99726
+ darwin: "google chrome",
99727
+ win32: "chrome",
99728
+ // `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
99729
+ linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
99730
+ }, {
99731
+ wsl: {
99732
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
99733
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
99475
99734
  }
99476
- if (tableKey && (preamble || !tables))
99477
- preamble = preamble ? `[${tableKey}]
99478
- ${preamble}` : `[${tableKey}]`;
99479
- return preamble && tables ? `${preamble}
99480
- ${tables}` : preamble || tables;
99481
- }
99482
- function stringify2(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
99483
- if (extendedTypeOf2(obj) !== "object") {
99484
- throw new TypeError("stringify can only be called with an object");
99735
+ }));
99736
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
99737
+ darwin: "brave browser",
99738
+ win32: "brave",
99739
+ linux: ["brave-browser", "brave"]
99740
+ }, {
99741
+ wsl: {
99742
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
99743
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
99485
99744
  }
99486
- let str = stringifyTable2(0, obj, "", maxDepth, numbersAsFloat);
99487
- if (str[str.length - 1] !== "\n")
99488
- return str + "\n";
99489
- return str;
99490
- }
99491
-
99492
- // ../../node_modules/.pnpm/smol-toml@1.5.2/node_modules/smol-toml/dist/index.js
99493
- var dist_default4 = { parse: parse4, stringify: stringify2, TomlDate: TomlDate2, TomlError: TomlError2 };
99745
+ }));
99746
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
99747
+ darwin: "firefox",
99748
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
99749
+ linux: "firefox"
99750
+ }, {
99751
+ wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
99752
+ }));
99753
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
99754
+ darwin: "microsoft edge",
99755
+ win32: "msedge",
99756
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
99757
+ }, {
99758
+ wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
99759
+ }));
99760
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({
99761
+ darwin: "Safari"
99762
+ }));
99763
+ var open_default = open;
99494
99764
 
99495
- // src/helpers/files.ts
99496
- var writeFile3 = (path6, content) => {
99497
- try {
99498
- import_node_fs11.default.writeFileSync(path6, content);
99499
- } catch (error2) {
99500
- throw new Error(error2);
99501
- }
99502
- };
99503
- var readFile = (path6) => {
99504
- try {
99505
- return import_node_fs11.default.readFileSync(path6, "utf-8");
99506
- } catch (error2) {
99507
- throw new Error(error2);
99508
- }
99509
- };
99510
- var removeFile = (path6) => {
99765
+ // src/helpers/cli.ts
99766
+ var import_semver2 = __toESM(require_semver2());
99767
+ async function openInBrowser(url) {
99768
+ updateStatus("Opening browser");
99769
+ const childProcess4 = await open_default(url);
99770
+ childProcess4.on("error", () => {
99771
+ warn("Failed to open browser");
99772
+ });
99773
+ }
99774
+ var isUpdateAvailable = async () => {
99775
+ const s = spinner(spinnerFrames.vertical, blue);
99776
+ s.start("Checking if a newer version is available");
99511
99777
  try {
99512
- import_node_fs11.default.rmSync(path6, { force: true });
99513
- } catch (error2) {
99514
- throw new Error(`Remove file failed: ${path6}`, { cause: error2 });
99778
+ const latestVersion = await getLatestPackageVersion("create-cloudflare");
99779
+ return (
99780
+ // Don't auto-update to major versions
99781
+ import_semver2.default.diff(latestVersion, version) !== "major" && import_semver2.default.gt(latestVersion, version)
99782
+ );
99783
+ } catch {
99784
+ s.update("Failed to read latest version from npm.");
99785
+ return false;
99786
+ } finally {
99787
+ s.stop();
99515
99788
  }
99516
99789
  };
99517
- var readJSON = (path6) => {
99518
- const contents = readFile(path6);
99519
- return contents ? (0, import_comment_json.parse)(contents) : contents;
99520
- };
99521
- var writeJSON = (path6, object, stringifySpace = " ") => {
99522
- writeFile3(path6, (0, import_comment_json.stringify)(object, null, stringifySpace));
99523
- };
99524
- var usesTypescript = (ctx) => {
99525
- return hasTsConfig(ctx.project.path);
99790
+ var C3_DEFAULTS = {
99791
+ projectName: new import_haikunator.default().haikunate({ tokenHex: true }),
99792
+ category: "hello-world",
99793
+ type: "hello-world-with-assets",
99794
+ framework: "analog",
99795
+ experimental: false,
99796
+ autoUpdate: true,
99797
+ deploy: false,
99798
+ git: true,
99799
+ agents: true,
99800
+ open: true,
99801
+ lang: "ts",
99802
+ template: "cloudflare/workers-sdk/packages/create-cloudflare/templates/hello-world-with-assets"
99526
99803
  };
99527
- var hasTsConfig = (path6) => {
99528
- return (0, import_node_fs11.existsSync)((0, import_node_path10.join)(`${path6}`, `tsconfig.json`));
99804
+ var WRANGLER_DEFAULTS = {
99805
+ ...C3_DEFAULTS,
99806
+ type: "hello-world-with-assets",
99807
+ deploy: false
99529
99808
  };
99530
99809
 
99531
99810
  // ../codemod/dist/index.mjs
99532
- var import_node_fs12 = require("node:fs");
99533
- var import_node_path11 = __toESM(require("node:path"), 1);
99811
+ var import_node_fs13 = require("node:fs");
99812
+ var import_node_path12 = __toESM(require("node:path"), 1);
99534
99813
  var recast = __toESM(require_main2(), 1);
99535
99814
  var esprimaParser = __toESM(require_esprima3(), 1);
99536
99815
  var typescriptParser = __toESM(require_typescript2(), 1);
@@ -99555,10 +99834,10 @@ function parseTs(src) {
99555
99834
  }
99556
99835
  __name2(parseTs, "parseTs");
99557
99836
  function parseFile(filePath) {
99558
- const lang = import_node_path11.default.extname(filePath).slice(1);
99837
+ const lang = import_node_path12.default.extname(filePath).slice(1);
99559
99838
  const parser2 = lang === "js" ? esprimaParser : typescriptParser;
99560
99839
  try {
99561
- const fileContents = (0, import_node_fs12.readFileSync)(import_node_path11.default.resolve(filePath), "utf-8");
99840
+ const fileContents = (0, import_node_fs13.readFileSync)(import_node_path12.default.resolve(filePath), "utf-8");
99562
99841
  if (fileContents) {
99563
99842
  return recast.parse(fileContents, { parser: parser2 }).program;
99564
99843
  }
@@ -99572,7 +99851,7 @@ function transformFile(filePath, methods) {
99572
99851
  const ast = parseFile(filePath);
99573
99852
  if (ast) {
99574
99853
  recast.visit(ast, methods);
99575
- (0, import_node_fs12.writeFileSync)(filePath, recast.print(ast).code);
99854
+ (0, import_node_fs13.writeFileSync)(filePath, recast.print(ast).code);
99576
99855
  }
99577
99856
  }
99578
99857
  __name2(transformFile, "transformFile");
@@ -99611,7 +99890,7 @@ var package_default = {
99611
99890
  name: "frameworks_clis_info",
99612
99891
  dependencies: {
99613
99892
  "@angular/create": "22.0.0",
99614
- "@tanstack/cli": "0.69.1",
99893
+ "@tanstack/cli": "0.69.2",
99615
99894
  "create-analog": "2.6.0",
99616
99895
  "create-astro": "5.0.6",
99617
99896
  "create-docusaurus": "3.10.1",
@@ -99662,8 +99941,8 @@ var runFrameworkGenerator = async (ctx, args) => {
99662
99941
  };
99663
99942
 
99664
99943
  // src/helpers/compatDate.ts
99665
- var import_node_fs13 = require("node:fs");
99666
- var import_node_path12 = require("node:path");
99944
+ var import_node_fs14 = require("node:fs");
99945
+ var import_node_path13 = require("node:path");
99667
99946
  function getWorkerdCompatibilityDate(_projectPath) {
99668
99947
  const s = spinner();
99669
99948
  s.start("Retrieving current workerd compatibility date");
@@ -99672,14 +99951,14 @@ function getWorkerdCompatibilityDate(_projectPath) {
99672
99951
  return date;
99673
99952
  }
99674
99953
  function getLatestTypesEntrypoint(ctx) {
99675
- const workersTypesPath = (0, import_node_path12.resolve)(
99954
+ const workersTypesPath = (0, import_node_path13.resolve)(
99676
99955
  ctx.project.path,
99677
99956
  "node_modules",
99678
99957
  "@cloudflare",
99679
99958
  "workers-types"
99680
99959
  );
99681
99960
  try {
99682
- const entrypoints = (0, import_node_fs13.readdirSync)(workersTypesPath);
99961
+ const entrypoints = (0, import_node_fs14.readdirSync)(workersTypesPath);
99683
99962
  const sorted = entrypoints.filter((filename) => filename.match(/(\d{4})-(\d{2})-(\d{2})/)).sort().reverse();
99684
99963
  if (sorted.length === 0) {
99685
99964
  return null;
@@ -99763,7 +100042,7 @@ var config = {
99763
100042
  var c3_default = config;
99764
100043
 
99765
100044
  // templates/angular/pages/c3.ts
99766
- var import_node_path13 = require("node:path");
100045
+ var import_node_path14 = require("node:path");
99767
100046
  var { npm: npm2 } = detectPackageManager();
99768
100047
  var generate2 = async (ctx) => {
99769
100048
  await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
@@ -99785,23 +100064,23 @@ async function updateAppCode() {
99785
100064
  const s = spinner();
99786
100065
  s.start(`Updating application code`);
99787
100066
  const appConfigPath = "src/app/app.config.ts";
99788
- const appConfig = readFile((0, import_node_path13.resolve)(appConfigPath));
100067
+ const appConfig = readFile((0, import_node_path14.resolve)(appConfigPath));
99789
100068
  const newAppConfig = "import { provideHttpClient, withFetch } from '@angular/common/http';\n" + appConfig.replace(
99790
100069
  "providers: [",
99791
100070
  "providers: [provideHttpClient(withFetch()), "
99792
100071
  );
99793
- writeFile3((0, import_node_path13.resolve)(appConfigPath), newAppConfig);
100072
+ writeFile3((0, import_node_path14.resolve)(appConfigPath), newAppConfig);
99794
100073
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
99795
100074
  const appServerRoutesPath = "src/app/app.routes.server.ts";
99796
- const appRoutes = readFile((0, import_node_path13.resolve)(appServerRoutesPath));
100075
+ const appRoutes = readFile((0, import_node_path14.resolve)(appServerRoutesPath));
99797
100076
  const newAppRoutes = appRoutes.replace(
99798
100077
  "RenderMode.Prerender",
99799
100078
  "RenderMode.Server"
99800
100079
  );
99801
- writeFile3((0, import_node_path13.resolve)(appServerRoutesPath), newAppRoutes);
100080
+ writeFile3((0, import_node_path14.resolve)(appServerRoutesPath), newAppRoutes);
99802
100081
  s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
99803
100082
  s.start(`Updating package.json`);
99804
- const packageJsonPath = (0, import_node_path13.resolve)("package.json");
100083
+ const packageJsonPath = (0, import_node_path14.resolve)("package.json");
99805
100084
  const packageManifest = readJSON(packageJsonPath);
99806
100085
  delete packageManifest["dependencies"]?.["express"];
99807
100086
  delete packageManifest["devDependencies"]?.["@types/express"];
@@ -99817,7 +100096,7 @@ function updateAngularJson(ctx) {
99817
100096
  architectSection.build.options.outputMode = "server";
99818
100097
  architectSection.build.options.ssr.platform = "neutral";
99819
100098
  architectSection.build.options.assets.push("src/_routes.json");
99820
- writeFile3((0, import_node_path13.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
100099
+ writeFile3((0, import_node_path14.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
99821
100100
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
99822
100101
  }
99823
100102
  var config2 = {
@@ -99849,7 +100128,7 @@ var config2 = {
99849
100128
  var c3_default2 = config2;
99850
100129
 
99851
100130
  // templates/angular/workers/c3.ts
99852
- var import_node_path14 = require("node:path");
100131
+ var import_node_path15 = require("node:path");
99853
100132
  var { npm: npm3 } = detectPackageManager();
99854
100133
  var generate3 = async (ctx) => {
99855
100134
  await runFrameworkGenerator(ctx, [ctx.project.name, "--ssr"]);
@@ -99871,23 +100150,23 @@ async function updateAppCode2() {
99871
100150
  const s = spinner();
99872
100151
  s.start(`Updating application code`);
99873
100152
  const appConfigPath = "src/app/app.config.ts";
99874
- const appConfig = readFile((0, import_node_path14.resolve)(appConfigPath));
100153
+ const appConfig = readFile((0, import_node_path15.resolve)(appConfigPath));
99875
100154
  const newAppConfig = "import { provideHttpClient, withFetch } from '@angular/common/http';\n" + appConfig.replace(
99876
100155
  "providers: [",
99877
100156
  "providers: [provideHttpClient(withFetch()), "
99878
100157
  );
99879
- writeFile3((0, import_node_path14.resolve)(appConfigPath), newAppConfig);
100158
+ writeFile3((0, import_node_path15.resolve)(appConfigPath), newAppConfig);
99880
100159
  s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
99881
100160
  const appServerRoutesPath = "src/app/app.routes.server.ts";
99882
- const appRoutes = readFile((0, import_node_path14.resolve)(appServerRoutesPath));
100161
+ const appRoutes = readFile((0, import_node_path15.resolve)(appServerRoutesPath));
99883
100162
  const newAppRoutes = appRoutes.replace(
99884
100163
  "RenderMode.Prerender",
99885
100164
  "RenderMode.Server"
99886
100165
  );
99887
- writeFile3((0, import_node_path14.resolve)(appServerRoutesPath), newAppRoutes);
100166
+ writeFile3((0, import_node_path15.resolve)(appServerRoutesPath), newAppRoutes);
99888
100167
  s.stop(`${brandColor(`updated`)} ${dim(appServerRoutesPath)}`);
99889
100168
  s.start(`Updating package.json`);
99890
- const packageJsonPath = (0, import_node_path14.resolve)("package.json");
100169
+ const packageJsonPath = (0, import_node_path15.resolve)("package.json");
99891
100170
  const packageManifest = readJSON(packageJsonPath);
99892
100171
  delete packageManifest["dependencies"]?.["express"];
99893
100172
  delete packageManifest["devDependencies"]?.["@types/express"];
@@ -99897,12 +100176,12 @@ async function updateAppCode2() {
99897
100176
  function updateAngularJson2(ctx) {
99898
100177
  const s = spinner();
99899
100178
  s.start(`Updating angular.json config`);
99900
- const angularJson = readJSON((0, import_node_path14.resolve)("angular.json"));
100179
+ const angularJson = readJSON((0, import_node_path15.resolve)("angular.json"));
99901
100180
  const architectSection = angularJson.projects[ctx.project.name].architect;
99902
100181
  architectSection.build.options.outputPath = "dist";
99903
100182
  architectSection.build.options.outputMode = "server";
99904
100183
  architectSection.build.options.ssr.platform = "neutral";
99905
- writeFile3((0, import_node_path14.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
100184
+ writeFile3((0, import_node_path15.resolve)("angular.json"), JSON.stringify(angularJson, null, 2));
99906
100185
  s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
99907
100186
  }
99908
100187
  var config3 = {
@@ -100737,10 +101016,10 @@ var config25 = {
100737
101016
  var c3_default28 = config25;
100738
101017
 
100739
101018
  // templates/pre-existing/c3.ts
100740
- var import_node_fs14 = require("node:fs");
101019
+ var import_node_fs15 = require("node:fs");
100741
101020
  var import_promises6 = require("node:fs/promises");
100742
101021
  var import_node_os6 = require("node:os");
100743
- var import_node_path15 = require("node:path");
101022
+ var import_node_path16 = require("node:path");
100744
101023
 
100745
101024
  // src/helpers/command.ts
100746
101025
  var runWranglerCommand = async (command2, opts = {}) => {
@@ -100870,7 +101149,7 @@ async function copyExistingWorkerFiles(ctx) {
100870
101149
  }
100871
101150
  );
100872
101151
  }
100873
- const tempdir = await (0, import_promises6.mkdtemp)((0, import_node_path15.join)((0, import_node_os6.tmpdir)(), "c3-wrangler-init--from-dash-"));
101152
+ const tempdir = await (0, import_promises6.mkdtemp)((0, import_node_path16.join)((0, import_node_os6.tmpdir)(), "c3-wrangler-init--from-dash-"));
100874
101153
  await runCommand(
100875
101154
  [
100876
101155
  ...dlx,
@@ -100893,16 +101172,16 @@ async function copyExistingWorkerFiles(ctx) {
100893
101172
  }
100894
101173
  );
100895
101174
  await (0, import_promises6.cp)(
100896
- (0, import_node_path15.join)(tempdir, ctx.args.existingScript, "src"),
100897
- (0, import_node_path15.join)(ctx.project.path, "src"),
101175
+ (0, import_node_path16.join)(tempdir, ctx.args.existingScript, "src"),
101176
+ (0, import_node_path16.join)(ctx.project.path, "src"),
100898
101177
  { recursive: true }
100899
101178
  );
100900
101179
  const configFiles = ["wrangler.jsonc", "wrangler.json", "wrangler.toml"];
100901
101180
  let configFileCopied = false;
100902
101181
  for (const configFile of configFiles) {
100903
- const sourcePath = (0, import_node_path15.join)(tempdir, ctx.args.existingScript, configFile);
100904
- if ((0, import_node_fs14.existsSync)(sourcePath)) {
100905
- await (0, import_promises6.cp)(sourcePath, (0, import_node_path15.join)(ctx.project.path, configFile));
101182
+ const sourcePath = (0, import_node_path16.join)(tempdir, ctx.args.existingScript, configFile);
101183
+ if ((0, import_node_fs15.existsSync)(sourcePath)) {
101184
+ await (0, import_promises6.cp)(sourcePath, (0, import_node_path16.join)(ctx.project.path, configFile));
100906
101185
  configFileCopied = true;
100907
101186
  break;
100908
101187
  }
@@ -100973,20 +101252,20 @@ var config27 = {
100973
101252
  var c3_default30 = config27;
100974
101253
 
100975
101254
  // src/helpers/codemod.ts
100976
- var import_node_fs15 = require("node:fs");
100977
- var import_node_path16 = require("node:path");
101255
+ var import_node_fs16 = require("node:fs");
101256
+ var import_node_path17 = require("node:path");
100978
101257
  var loadSnippets = (parentFolder) => {
100979
- const snippetsPath = (0, import_node_path16.join)(parentFolder, "snippets");
100980
- if (!(0, import_node_fs15.lstatSync)(snippetsPath, { throwIfNoEntry: false })?.isDirectory()) {
101258
+ const snippetsPath = (0, import_node_path17.join)(parentFolder, "snippets");
101259
+ if (!(0, import_node_fs16.lstatSync)(snippetsPath, { throwIfNoEntry: false })?.isDirectory()) {
100981
101260
  return {};
100982
101261
  }
100983
- const files = (0, import_node_fs15.readdirSync)(snippetsPath);
100984
- return files.filter((fileName) => (0, import_node_fs15.lstatSync)((0, import_node_path16.join)(snippetsPath, fileName)).isFile()).filter((fileName) => [".js", ".ts"].includes((0, import_node_path16.extname)(fileName))).reduce((acc, snippetPath) => {
101262
+ const files = (0, import_node_fs16.readdirSync)(snippetsPath);
101263
+ return files.filter((fileName) => (0, import_node_fs16.lstatSync)((0, import_node_path17.join)(snippetsPath, fileName)).isFile()).filter((fileName) => [".js", ".ts"].includes((0, import_node_path17.extname)(fileName))).reduce((acc, snippetPath) => {
100985
101264
  const [file2, ext] = snippetPath.split(".");
100986
101265
  const key = `${file2}${ext === "js" ? "Js" : "Ts"}`;
100987
101266
  return {
100988
101267
  ...acc,
100989
- [key]: parseFile((0, import_node_path16.join)(snippetsPath, snippetPath))?.body
101268
+ [key]: parseFile((0, import_node_path17.join)(snippetsPath, snippetPath))?.body
100990
101269
  };
100991
101270
  }, {});
100992
101271
  };
@@ -101177,7 +101456,7 @@ var config30 = {
101177
101456
  var c3_default33 = config30;
101178
101457
 
101179
101458
  // templates/react-router/c3.ts
101180
- var import_node_path17 = require("node:path");
101459
+ var import_node_path18 = require("node:path");
101181
101460
  var { npm: npm12 } = detectPackageManager();
101182
101461
  var generate18 = async (ctx) => {
101183
101462
  await runFrameworkGenerator(ctx, [
@@ -101196,9 +101475,9 @@ var configure10 = async (ctx) => {
101196
101475
  });
101197
101476
  const s = spinner();
101198
101477
  s.start("Removing non-Cloudflare artifacts from template");
101199
- removeFile((0, import_node_path17.resolve)(ctx.project.path, "Dockerfile"));
101200
- removeFile((0, import_node_path17.resolve)(ctx.project.path, ".dockerignore"));
101201
- const pkgJsonPath = (0, import_node_path17.resolve)(ctx.project.path, "package.json");
101478
+ removeFile((0, import_node_path18.resolve)(ctx.project.path, "Dockerfile"));
101479
+ removeFile((0, import_node_path18.resolve)(ctx.project.path, ".dockerignore"));
101480
+ const pkgJsonPath = (0, import_node_path18.resolve)(ctx.project.path, "package.json");
101202
101481
  const pkgJson = readJSON(pkgJsonPath);
101203
101482
  delete pkgJson.dependencies?.["@react-router/node"];
101204
101483
  delete pkgJson.dependencies?.["@react-router/serve"];
@@ -101573,7 +101852,7 @@ var config37 = {
101573
101852
  var c3_default40 = config37;
101574
101853
 
101575
101854
  // templates/svelte/pages/c3.ts
101576
- var import_node_fs16 = require("node:fs");
101855
+ var import_node_fs17 = require("node:fs");
101577
101856
  var recast10 = __toESM(require_main2());
101578
101857
  var { npm: npm17 } = detectPackageManager();
101579
101858
  var generate23 = async (ctx) => {
@@ -101605,7 +101884,7 @@ var updateSvelteConfig = () => {
101605
101884
  };
101606
101885
  var updatePlaywrightConfig = (shouldUseTypescript) => {
101607
101886
  const filePath = `playwright.config.${shouldUseTypescript ? "ts" : "js"}`;
101608
- if (!(0, import_node_fs16.existsSync)(filePath)) {
101887
+ if (!(0, import_node_fs17.existsSync)(filePath)) {
101609
101888
  return;
101610
101889
  }
101611
101890
  updateStatus(`Changing webServer port in ${blue(filePath)}`);
@@ -102104,7 +102383,7 @@ If the application uses Durable Objects or Workflows, refer to the relevant best
102104
102383
  var import_node_assert6 = __toESM(require("node:assert"));
102105
102384
 
102106
102385
  // ../wrangler/package.json
102107
- var version2 = "4.99.0";
102386
+ var version2 = "4.100.0";
102108
102387
 
102109
102388
  // src/git.ts
102110
102389
  var offerGit = async (ctx) => {
@@ -102292,8 +102571,8 @@ async function getProductionBranch(cwd) {
102292
102571
  }
102293
102572
 
102294
102573
  // src/validators.ts
102295
- var import_node_fs17 = require("node:fs");
102296
- var import_node_path18 = require("node:path");
102574
+ var import_node_fs18 = require("node:fs");
102575
+ var import_node_path19 = require("node:path");
102297
102576
  var TEMPLATE_REGEX = /^(?:(?:https:\/\/)?(?<httpsUrl>[^:/]+\.[^:/]+)\/|git@(?<gitUrl>[^:/]+)[:/]|(?<shorthandUrl>[^/]+):)?(?<user>[^/\s]+)\/(?<repository>[^/\s#]+)(?:(?<subdirectoryPath>(?:\/[^/\s#]+)+))?(?:\/)?(?:#(?<tag>.+))?/;
102298
102577
  var validateTemplateUrl = (value) => {
102299
102578
  if (!String(value).match(TEMPLATE_REGEX)) {
@@ -102301,17 +102580,17 @@ var validateTemplateUrl = (value) => {
102301
102580
  }
102302
102581
  };
102303
102582
  var validateProjectDirectory = (relativePath, args) => {
102304
- const path6 = (0, import_node_path18.resolve)(relativePath);
102305
- const existsAlready = (0, import_node_fs17.existsSync)(path6);
102583
+ const path6 = (0, import_node_path19.resolve)(relativePath);
102584
+ const existsAlready = (0, import_node_fs18.existsSync)(path6);
102306
102585
  if (existsAlready) {
102307
- for (const file2 of (0, import_node_fs17.readdirSync)(path6)) {
102586
+ for (const file2 of (0, import_node_fs18.readdirSync)(path6)) {
102308
102587
  if (!isAllowedExistingFile(file2)) {
102309
102588
  return `Directory \`${relativePath}\` already exists and contains files that might conflict. Please choose a new name.`;
102310
102589
  }
102311
102590
  }
102312
102591
  }
102313
102592
  if (!args.existingScript) {
102314
- const projectName = (0, import_node_path18.basename)(path6);
102593
+ const projectName = (0, import_node_path19.basename)(path6);
102315
102594
  const invalidChars = /[^a-z0-9-]/;
102316
102595
  const invalidStartEnd = /^-|-$/;
102317
102596
  if (projectName.match(invalidStartEnd)) {
@@ -102765,7 +103044,7 @@ var createContext = async (args, prevArgs) => {
102765
103044
  envInterfaceName: "Env",
102766
103045
  ...template
102767
103046
  };
102768
- const path6 = (0, import_node_path19.resolve)(projectName);
103047
+ const path6 = (0, import_node_path20.resolve)(projectName);
102769
103048
  const languageVariants = template.copyFiles && !isVariantInfo(template.copyFiles) && !template.copyFiles.selectVariant ? Object.keys(template.copyFiles.variants) : [];
102770
103049
  if (languageVariants.length > 0) {
102771
103050
  if (hasTsConfig(path6)) {
@@ -102791,8 +103070,8 @@ var createContext = async (args, prevArgs) => {
102791
103070
  }
102792
103071
  }
102793
103072
  }
102794
- const name3 = (0, import_node_path19.basename)(path6);
102795
- const directory = (0, import_node_path19.dirname)(path6);
103073
+ const name3 = (0, import_node_path20.basename)(path6);
103074
+ const directory = (0, import_node_path20.dirname)(path6);
102796
103075
  const originalCWD = process.cwd();
102797
103076
  return {
102798
103077
  project: { name: name3, path: path6 },
@@ -102812,7 +103091,7 @@ async function copyTemplateFiles(ctx) {
102812
103091
  const { copyFiles } = ctx.template;
102813
103092
  let srcdir;
102814
103093
  if (isVariantInfo(copyFiles)) {
102815
- srcdir = (0, import_node_path19.join)(getTemplatePath(ctx), copyFiles.path);
103094
+ srcdir = (0, import_node_path20.join)(getTemplatePath(ctx), copyFiles.path);
102816
103095
  } else {
102817
103096
  const selectVariant = copyFiles.selectVariant ?? defaultSelectVariant;
102818
103097
  const variant = await selectVariant(ctx);
@@ -102822,22 +103101,22 @@ async function copyTemplateFiles(ctx) {
102822
103101
  `Unknown variant provided: ${JSON.stringify(variant ?? "")}`
102823
103102
  );
102824
103103
  }
102825
- srcdir = (0, import_node_path19.join)(getTemplatePath(ctx), variantInfo.path);
103104
+ srcdir = (0, import_node_path20.join)(getTemplatePath(ctx), variantInfo.path);
102826
103105
  }
102827
103106
  const copyDestDir = getCopyFilesDestinationDir(ctx);
102828
- const destdir = (0, import_node_path19.join)(ctx.project.path, ...copyDestDir ? [copyDestDir] : []);
103107
+ const destdir = (0, import_node_path20.join)(ctx.project.path, ...copyDestDir ? [copyDestDir] : []);
102829
103108
  const s = spinner();
102830
103109
  s.start(`Copying template files`);
102831
103110
  await (0, import_promises7.cp)(srcdir, destdir, { recursive: true, force: true });
102832
- const dummyGitIgnorePath = (0, import_node_path19.join)(destdir, "__dot__gitignore");
102833
- if ((0, import_node_fs18.existsSync)(dummyGitIgnorePath)) {
102834
- await (0, import_promises7.rename)(dummyGitIgnorePath, (0, import_node_path19.join)(destdir, ".gitignore"));
103111
+ const dummyGitIgnorePath = (0, import_node_path20.join)(destdir, "__dot__gitignore");
103112
+ if ((0, import_node_fs19.existsSync)(dummyGitIgnorePath)) {
103113
+ await (0, import_promises7.rename)(dummyGitIgnorePath, (0, import_node_path20.join)(destdir, ".gitignore"));
102835
103114
  }
102836
103115
  s.stop(`${brandColor("files")} ${dim("copied to project directory")}`);
102837
103116
  }
102838
103117
  function writeAgentsMd(projectPath) {
102839
- const agentsMdPath = (0, import_node_path19.join)(projectPath, "AGENTS.md");
102840
- if ((0, import_node_fs18.existsSync)(agentsMdPath)) {
103118
+ const agentsMdPath = (0, import_node_path20.join)(projectPath, "AGENTS.md");
103119
+ if ((0, import_node_fs19.existsSync)(agentsMdPath)) {
102841
103120
  return;
102842
103121
  }
102843
103122
  writeFile3(agentsMdPath, getAgentsMd());
@@ -102866,26 +103145,26 @@ var validateTemplate = (path6, config49) => {
102866
103145
  return;
102867
103146
  }
102868
103147
  if (isVariantInfo(config49.copyFiles)) {
102869
- validateTemplateSrcDirectory((0, import_node_path19.resolve)(path6, config49.copyFiles.path), config49);
103148
+ validateTemplateSrcDirectory((0, import_node_path20.resolve)(path6, config49.copyFiles.path), config49);
102870
103149
  } else {
102871
103150
  for (const variant of Object.values(config49.copyFiles.variants)) {
102872
- validateTemplateSrcDirectory((0, import_node_path19.resolve)(path6, variant.path), config49);
103151
+ validateTemplateSrcDirectory((0, import_node_path20.resolve)(path6, variant.path), config49);
102873
103152
  }
102874
103153
  }
102875
103154
  };
102876
103155
  var validateTemplateSrcDirectory = (path6, config49) => {
102877
103156
  if (config49.platform === "workers") {
102878
- const wranglerTomlPath = (0, import_node_path19.resolve)(path6, "wrangler.toml");
102879
- const wranglerJsonPath = (0, import_node_path19.resolve)(path6, "wrangler.json");
102880
- const wranglerJsoncPath = (0, import_node_path19.resolve)(path6, "wrangler.jsonc");
102881
- if (!(0, import_node_fs18.existsSync)(wranglerTomlPath) && !(0, import_node_fs18.existsSync)(wranglerJsonPath) && !(0, import_node_fs18.existsSync)(wranglerJsoncPath)) {
103157
+ const wranglerTomlPath = (0, import_node_path20.resolve)(path6, "wrangler.toml");
103158
+ const wranglerJsonPath = (0, import_node_path20.resolve)(path6, "wrangler.json");
103159
+ const wranglerJsoncPath = (0, import_node_path20.resolve)(path6, "wrangler.jsonc");
103160
+ if (!(0, import_node_fs19.existsSync)(wranglerTomlPath) && !(0, import_node_fs19.existsSync)(wranglerJsonPath) && !(0, import_node_fs19.existsSync)(wranglerJsoncPath)) {
102882
103161
  throw new Error(
102883
103162
  `create-cloudflare templates must contain a "wrangler.toml" or "wrangler.json(c)" file.`
102884
103163
  );
102885
103164
  }
102886
103165
  }
102887
- const pkgJsonPath = (0, import_node_path19.resolve)(path6, "package.json");
102888
- if (!(0, import_node_fs18.existsSync)(pkgJsonPath)) {
103166
+ const pkgJsonPath = (0, import_node_path20.resolve)(path6, "package.json");
103167
+ if (!(0, import_node_fs19.existsSync)(pkgJsonPath)) {
102889
103168
  throw new Error(
102890
103169
  `create-cloudflare templates must contain a "package.json" file.`
102891
103170
  );
@@ -102902,10 +103181,10 @@ var inferTemplateConfig = (path6) => {
102902
103181
  };
102903
103182
  var inferCopyFilesDefinition = (path6) => {
102904
103183
  const variants = {};
102905
- if ((0, import_node_fs18.existsSync)((0, import_node_path19.join)(path6, "js"))) {
103184
+ if ((0, import_node_fs19.existsSync)((0, import_node_path20.join)(path6, "js"))) {
102906
103185
  variants["js"] = { path: "./js" };
102907
103186
  }
102908
- if ((0, import_node_fs18.existsSync)((0, import_node_path19.join)(path6, "ts"))) {
103187
+ if ((0, import_node_fs19.existsSync)((0, import_node_path20.join)(path6, "ts"))) {
102909
103188
  variants["ts"] = { path: "./ts" };
102910
103189
  }
102911
103190
  const copyFiles = Object.keys(variants).length !== 0 ? { variants } : { path: "." };
@@ -102940,7 +103219,7 @@ Use the format "github:<owner>/<repo>/sub/directory[#<branch>]" to clone a speci
102940
103219
  force: true,
102941
103220
  mode: options.mode
102942
103221
  });
102943
- const tmpDir = options.intoFolder ?? await (0, import_promises7.mkdtemp)((0, import_node_path19.join)((0, import_node_os7.tmpdir)(), "c3-template"));
103222
+ const tmpDir = options.intoFolder ?? await (0, import_promises7.mkdtemp)((0, import_node_path20.join)((0, import_node_os7.tmpdir)(), "c3-template"));
102944
103223
  await emitter.clone(tmpDir);
102945
103224
  return tmpDir;
102946
103225
  } catch {
@@ -102949,8 +103228,8 @@ Use the format "github:<owner>/<repo>/sub/directory[#<branch>]" to clone a speci
102949
103228
  }
102950
103229
  }
102951
103230
  function updatePythonPackageName(path6, projectName) {
102952
- const pyProjectFile = (0, import_node_path19.resolve)(path6, "pyproject.toml");
102953
- if (!(0, import_node_fs18.existsSync)(pyProjectFile)) {
103231
+ const pyProjectFile = (0, import_node_path20.resolve)(path6, "pyproject.toml");
103232
+ if (!(0, import_node_fs19.existsSync)(pyProjectFile)) {
102954
103233
  return;
102955
103234
  }
102956
103235
  const s = spinner();
@@ -102962,7 +103241,7 @@ function updatePythonPackageName(path6, projectName) {
102962
103241
  }
102963
103242
  var updatePackageName = (ctx) => {
102964
103243
  const placeholderNames = ["<PACKAGE_NAME>", "<TBD>", "TBD", ""];
102965
- const pkgJsonPath = (0, import_node_path19.resolve)(ctx.project.path, "package.json");
103244
+ const pkgJsonPath = (0, import_node_path20.resolve)(ctx.project.path, "package.json");
102966
103245
  const pkgJson = readJSON(pkgJsonPath);
102967
103246
  if (!placeholderNames.includes(pkgJson.name)) {
102968
103247
  return;
@@ -102980,7 +103259,7 @@ var updatePackageScripts = async (ctx) => {
102980
103259
  }
102981
103260
  const s = spinner();
102982
103261
  s.start("Updating `package.json` scripts");
102983
- const pkgJsonPath = (0, import_node_path19.resolve)(ctx.project.path, "package.json");
103262
+ const pkgJsonPath = (0, import_node_path20.resolve)(ctx.project.path, "package.json");
102984
103263
  let pkgJson = readJSON(pkgJsonPath);
102985
103264
  const transformed = await ctx.template.transformPackageJson(pkgJson, ctx);
102986
103265
  pkgJson = (0, import_deepmerge.default)(pkgJson, transformed);
@@ -102989,9 +103268,9 @@ var updatePackageScripts = async (ctx) => {
102989
103268
  };
102990
103269
  var getTemplatePath = (ctx) => {
102991
103270
  if (ctx.template.path) {
102992
- return (0, import_node_path19.resolve)(__dirname, "..", ctx.template.path);
103271
+ return (0, import_node_path20.resolve)(__dirname, "..", ctx.template.path);
102993
103272
  }
102994
- return (0, import_node_path19.resolve)(__dirname, "..", "templates", ctx.template.id);
103273
+ return (0, import_node_path20.resolve)(__dirname, "..", "templates", ctx.template.id);
102995
103274
  };
102996
103275
  var isVariantInfo = (copyFiles) => {
102997
103276
  return "path" in copyFiles;
@@ -103368,7 +103647,7 @@ var processArgument = async (args, key, promptConfig) => {
103368
103647
  // src/deploy.ts
103369
103648
  var import_promises9 = require("node:fs/promises");
103370
103649
  var import_node_os8 = require("node:os");
103371
- var import_node_path21 = require("node:path");
103650
+ var import_node_path22 = require("node:path");
103372
103651
 
103373
103652
  // src/helpers/poll.ts
103374
103653
  var import_promises8 = require("node:timers/promises");
@@ -103460,8 +103739,8 @@ function secondsSince(start) {
103460
103739
  }
103461
103740
 
103462
103741
  // src/wrangler/config.ts
103463
- var import_node_fs19 = require("node:fs");
103464
- var import_node_path20 = require("node:path");
103742
+ var import_node_fs20 = require("node:fs");
103743
+ var import_node_path21 = require("node:path");
103465
103744
 
103466
103745
  // src/helpers/json.ts
103467
103746
  var import_comment_json2 = __toESM(require_src3());
@@ -103573,22 +103852,22 @@ ${generateHintsAsTomlComments(wranglerToml)}
103573
103852
  }
103574
103853
  };
103575
103854
  var getWranglerTomlPath = (ctx) => {
103576
- return (0, import_node_path20.resolve)(ctx.project.path, "wrangler.toml");
103855
+ return (0, import_node_path21.resolve)(ctx.project.path, "wrangler.toml");
103577
103856
  };
103578
103857
  var getWranglerJsonPath = (ctx) => {
103579
- return (0, import_node_path20.resolve)(ctx.project.path, "wrangler.json");
103858
+ return (0, import_node_path21.resolve)(ctx.project.path, "wrangler.json");
103580
103859
  };
103581
103860
  var getWranglerJsoncPath = (ctx) => {
103582
- return (0, import_node_path20.resolve)(ctx.project.path, "wrangler.jsonc");
103861
+ return (0, import_node_path21.resolve)(ctx.project.path, "wrangler.jsonc");
103583
103862
  };
103584
103863
  var wranglerTomlExists = (ctx) => {
103585
103864
  const wranglerTomlPath = getWranglerTomlPath(ctx);
103586
- return (0, import_node_fs19.existsSync)(wranglerTomlPath);
103865
+ return (0, import_node_fs20.existsSync)(wranglerTomlPath);
103587
103866
  };
103588
103867
  var wranglerJsonOrJsoncExists = (ctx) => {
103589
103868
  const wranglerJsonPath = getWranglerJsonPath(ctx);
103590
103869
  const wranglerJsoncPath = getWranglerJsoncPath(ctx);
103591
- return (0, import_node_fs19.existsSync)(wranglerJsonPath) || (0, import_node_fs19.existsSync)(wranglerJsoncPath);
103870
+ return (0, import_node_fs20.existsSync)(wranglerJsonPath) || (0, import_node_fs20.existsSync)(wranglerJsoncPath);
103592
103871
  };
103593
103872
  var readWranglerToml = (ctx) => {
103594
103873
  const wranglerTomlPath = getWranglerTomlPath(ctx);
@@ -103596,7 +103875,7 @@ var readWranglerToml = (ctx) => {
103596
103875
  };
103597
103876
  var readWranglerJsonOrJsonc = (ctx, reviver) => {
103598
103877
  const wranglerJsonPath = getWranglerJsonPath(ctx);
103599
- if ((0, import_node_fs19.existsSync)(wranglerJsonPath)) {
103878
+ if ((0, import_node_fs20.existsSync)(wranglerJsonPath)) {
103600
103879
  return readJSONWithComments(wranglerJsonPath, reviver);
103601
103880
  }
103602
103881
  const wranglerJsoncPath = getWranglerJsoncPath(ctx);
@@ -103608,7 +103887,7 @@ var writeWranglerToml = (ctx, contents) => {
103608
103887
  };
103609
103888
  var writeWranglerJsonOrJsonc = (ctx, config49) => {
103610
103889
  const wranglerJsonPath = getWranglerJsonPath(ctx);
103611
- if ((0, import_node_fs19.existsSync)(wranglerJsonPath)) {
103890
+ if ((0, import_node_fs20.existsSync)(wranglerJsonPath)) {
103612
103891
  return writeJSONWithComments(wranglerJsonPath, config49);
103613
103892
  }
103614
103893
  const wranglerJsoncPath = getWranglerJsoncPath(ctx);
@@ -103616,10 +103895,10 @@ var writeWranglerJsonOrJsonc = (ctx, config49) => {
103616
103895
  };
103617
103896
  var addVscodeConfig = (ctx) => {
103618
103897
  const settingsPath = `${ctx.project.path}/.vscode/settings.json`;
103619
- if ((0, import_node_fs19.existsSync)(settingsPath)) {
103898
+ if ((0, import_node_fs20.existsSync)(settingsPath)) {
103620
103899
  return;
103621
103900
  }
103622
- (0, import_node_fs19.mkdirSync)(`${ctx.project.path}/.vscode`, { recursive: true });
103901
+ (0, import_node_fs20.mkdirSync)(`${ctx.project.path}/.vscode`, { recursive: true });
103623
103902
  writeJSON(settingsPath, {
103624
103903
  "files.associations": {
103625
103904
  "wrangler.json": "jsonc"
@@ -103785,8 +104064,8 @@ var runDeploy = async (ctx) => {
103785
104064
  JSON.stringify(ctx.commitMessage)
103786
104065
  ] : []
103787
104066
  ];
103788
- const outputFile = (0, import_node_path21.join)(
103789
- await (0, import_promises9.mkdtemp)((0, import_node_path21.join)((0, import_node_os8.tmpdir)(), "c3-wrangler-deploy-")),
104067
+ const outputFile = (0, import_node_path22.join)(
104068
+ await (0, import_promises9.mkdtemp)((0, import_node_path22.join)((0, import_node_os8.tmpdir)(), "c3-wrangler-deploy-")),
103790
104069
  "output.json"
103791
104070
  );
103792
104071
  await runCommand(deployCmd, {
@@ -103848,7 +104127,7 @@ var hasBinding = (node) => {
103848
104127
  };
103849
104128
 
103850
104129
  // src/dialog.ts
103851
- var import_node_path22 = require("node:path");
104130
+ var import_node_path23 = require("node:path");
103852
104131
  function createDialog(lines) {
103853
104132
  const screenWidth = process.stdout.columns;
103854
104133
  const maxLineWidth = Math.max(
@@ -103888,7 +104167,7 @@ function printWelcomeMessage(version3, telemetryEnabled, args) {
103888
104167
  }
103889
104168
  var printSummary = (ctx) => {
103890
104169
  const dashboardUrl = ctx.account ? `https://dash.cloudflare.com/?to=/:account/workers/services/view/${ctx.project.name}/production` : null;
103891
- const relativePath = (0, import_node_path22.relative)(ctx.originalCWD, ctx.project.path);
104170
+ const relativePath = (0, import_node_path23.relative)(ctx.originalCWD, ctx.project.path);
103892
104171
  const cdCommand = relativePath ? `cd ${relativePath}` : null;
103893
104172
  const { npm: npm25 } = detectPackageManager();
103894
104173
  const deployCommand = quoteShellArgs([
@@ -104359,8 +104638,8 @@ var createProject = async (ctx) => {
104359
104638
  };
104360
104639
 
104361
104640
  // src/workers.ts
104362
- var import_node_fs20 = require("node:fs");
104363
- var import_node_path23 = require("node:path");
104641
+ var import_node_fs21 = require("node:fs");
104642
+ var import_node_path24 = require("node:path");
104364
104643
 
104365
104644
  // ../../node_modules/.pnpm/jsonc-parser@3.2.0/node_modules/jsonc-parser/lib/esm/impl/scanner.js
104366
104645
  function createScanner2(text, ignoreTrivia = false) {
@@ -105690,8 +105969,8 @@ async function addTypes(ctx) {
105690
105969
  await updateTsConfig(ctx, { usesNodeCompat });
105691
105970
  }
105692
105971
  async function generateWorkersTypes(ctx, npm25) {
105693
- const packageJsonPath = (0, import_node_path23.join)(ctx.project.path, "package.json");
105694
- if (!(0, import_node_fs20.existsSync)(packageJsonPath)) {
105972
+ const packageJsonPath = (0, import_node_path24.join)(ctx.project.path, "package.json");
105973
+ if (!(0, import_node_fs21.existsSync)(packageJsonPath)) {
105695
105974
  return;
105696
105975
  }
105697
105976
  const packageManifest = readJSON(packageJsonPath);
@@ -105730,8 +106009,8 @@ var maybeInstallNodeTypes = async (ctx, npm25) => {
105730
106009
  return false;
105731
106010
  };
105732
106011
  async function updateTsConfig(ctx, { usesNodeCompat }) {
105733
- const tsconfigPath = (0, import_node_path23.join)(ctx.project.path, "tsconfig.json");
105734
- if (!(0, import_node_fs20.existsSync)(tsconfigPath)) {
106012
+ const tsconfigPath = (0, import_node_path24.join)(ctx.project.path, "tsconfig.json");
106013
+ if (!(0, import_node_fs21.existsSync)(tsconfigPath)) {
105735
106014
  return;
105736
106015
  }
105737
106016
  const tsconfig = readFile(tsconfigPath);
@@ -105861,8 +106140,8 @@ var setupProjectDirectory = (ctx) => {
105861
106140
  if (err) {
105862
106141
  throw new Error(err);
105863
106142
  }
105864
- const directory = (0, import_node_path24.dirname)(path6);
105865
- (0, import_node_fs21.mkdirSync)(directory, { recursive: true });
106143
+ const directory = (0, import_node_path25.dirname)(path6);
106144
+ (0, import_node_fs22.mkdirSync)(directory, { recursive: true });
105866
106145
  (0, import_node_process14.chdir)(directory);
105867
106146
  };
105868
106147
  var create = async (ctx) => {
@@ -105875,6 +106154,7 @@ var create = async (ctx) => {
105875
106154
  await copyTemplateFiles(ctx);
105876
106155
  }
105877
106156
  updatePackageName(ctx);
106157
+ writePnpmBuildApprovals(ctx.project.path);
105878
106158
  (0, import_node_process14.chdir)(ctx.project.path);
105879
106159
  await npmInstall(ctx);
105880
106160
  await rectifyPmMismatch(ctx);
@@ -105940,9 +106220,16 @@ var offerAgentsMd = async (ctx) => {
105940
106220
  main(process.argv).catch((e) => {
105941
106221
  if (e instanceof CancelError) {
105942
106222
  cancel(e.message);
106223
+ return;
106224
+ }
106225
+ if (isIgnoredBuildsError(e)) {
106226
+ error(`${e.message}
106227
+
106228
+ ${getPnpmIgnoredBuildsGuidance(e.packages)}`);
105943
106229
  } else {
105944
106230
  error(e);
105945
106231
  }
106232
+ process.exitCode = 1;
105946
106233
  }).finally(async () => {
105947
106234
  await reporter.waitForAllEventsSettled();
105948
106235
  process.exit();