@donotdev/cli 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5106,15 +5106,15 @@ var require_pattern = __commonJS({
5106
5106
  exports.removeDuplicateSlashes = removeDuplicateSlashes;
5107
5107
  function partitionAbsoluteAndRelative(patterns) {
5108
5108
  const absolute = [];
5109
- const relative3 = [];
5109
+ const relative4 = [];
5110
5110
  for (const pattern of patterns) {
5111
5111
  if (isAbsolute(pattern)) {
5112
5112
  absolute.push(pattern);
5113
5113
  } else {
5114
- relative3.push(pattern);
5114
+ relative4.push(pattern);
5115
5115
  }
5116
5116
  }
5117
- return [absolute, relative3];
5117
+ return [absolute, relative4];
5118
5118
  }
5119
5119
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
5120
5120
  function isAbsolute(pattern) {
@@ -8709,7 +8709,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8709
8709
  function readdirSync3(dirPath, options) {
8710
8710
  return pathResolverInstance.readdirSync(dirPath, options);
8711
8711
  }
8712
- var pathResolverInstance, getRepoRoot, resolvePackage, normalizePath, pathExists, read, readSync, writeSync, removeSync, statSync2, ensureDirSync, readdir, getRelativePathBetween, getDirname, joinPath;
8712
+ var pathResolverInstance, getRepoRoot, resolvePackage, resolveFrameworkPackage, normalizePath, pathExists, read, readSync, writeSync, removeSync, statSync2, lstatSync3, ensureDirSync, readdir, getRelativePathBetween, getDirname, joinPath;
8713
8713
  var init_pathResolver = __esm({
8714
8714
  "packages/tooling/src/utils/pathResolver.ts"() {
8715
8715
  "use strict";
@@ -8718,6 +8718,7 @@ var init_pathResolver = __esm({
8718
8718
  pathResolverInstance = PathResolver.getInstance({ debug: false });
8719
8719
  getRepoRoot = () => pathResolverInstance.getRepoRoot();
8720
8720
  resolvePackage = (spec, from) => pathResolverInstance.resolvePackage(spec, from || null);
8721
+ resolveFrameworkPackage = (name, from) => pathResolverInstance.resolveFrameworkPackage(name, from || null);
8721
8722
  normalizePath = (...pathSegments) => {
8722
8723
  return pathResolverInstance.normalizePath(join3(...pathSegments));
8723
8724
  };
@@ -8727,6 +8728,7 @@ var init_pathResolver = __esm({
8727
8728
  writeSync = (filePath, content, options) => pathResolverInstance.writeSync(filePath, content, options);
8728
8729
  removeSync = (path) => pathResolverInstance.removeSync(path);
8729
8730
  statSync2 = (filePath) => pathResolverInstance.statSync(filePath);
8731
+ lstatSync3 = (filePath) => pathResolverInstance.lstatSync(filePath);
8730
8732
  ensureDirSync = (dirPath) => pathResolverInstance.ensureDirSync(dirPath);
8731
8733
  readdir = async (dirPath, options) => pathResolverInstance.readdir(dirPath, options);
8732
8734
  getRelativePathBetween = (from, to) => {
@@ -13114,10 +13116,10 @@ var require_resolve_block_map = __commonJS({
13114
13116
  let offset = bm.offset;
13115
13117
  let commentEnd = null;
13116
13118
  for (const collItem of bm.items) {
13117
- const { start, key, sep: sep2, value } = collItem;
13119
+ const { start, key, sep: sep3, value } = collItem;
13118
13120
  const keyProps = resolveProps.resolveProps(start, {
13119
13121
  indicator: "explicit-key-ind",
13120
- next: key ?? sep2?.[0],
13122
+ next: key ?? sep3?.[0],
13121
13123
  offset,
13122
13124
  onError,
13123
13125
  parentIndent: bm.indent,
@@ -13131,7 +13133,7 @@ var require_resolve_block_map = __commonJS({
13131
13133
  else if ("indent" in key && key.indent !== bm.indent)
13132
13134
  onError(offset, "BAD_INDENT", startColMsg);
13133
13135
  }
13134
- if (!keyProps.anchor && !keyProps.tag && !sep2) {
13136
+ if (!keyProps.anchor && !keyProps.tag && !sep3) {
13135
13137
  commentEnd = keyProps.end;
13136
13138
  if (keyProps.comment) {
13137
13139
  if (map.comment)
@@ -13155,7 +13157,7 @@ var require_resolve_block_map = __commonJS({
13155
13157
  ctx.atKey = false;
13156
13158
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
13157
13159
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
13158
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
13160
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
13159
13161
  indicator: "map-value-ind",
13160
13162
  next: value,
13161
13163
  offset: keyNode.range[2],
@@ -13171,7 +13173,7 @@ var require_resolve_block_map = __commonJS({
13171
13173
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
13172
13174
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
13173
13175
  }
13174
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
13176
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep3, null, valueProps, onError);
13175
13177
  if (ctx.schema.compat)
13176
13178
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
13177
13179
  offset = valueNode.range[2];
@@ -13264,7 +13266,7 @@ var require_resolve_end = __commonJS({
13264
13266
  let comment = "";
13265
13267
  if (end) {
13266
13268
  let hasSpace = false;
13267
- let sep2 = "";
13269
+ let sep3 = "";
13268
13270
  for (const token of end) {
13269
13271
  const { source, type } = token;
13270
13272
  switch (type) {
@@ -13278,13 +13280,13 @@ var require_resolve_end = __commonJS({
13278
13280
  if (!comment)
13279
13281
  comment = cb;
13280
13282
  else
13281
- comment += sep2 + cb;
13282
- sep2 = "";
13283
+ comment += sep3 + cb;
13284
+ sep3 = "";
13283
13285
  break;
13284
13286
  }
13285
13287
  case "newline":
13286
13288
  if (comment)
13287
- sep2 += source;
13289
+ sep3 += source;
13288
13290
  hasSpace = true;
13289
13291
  break;
13290
13292
  default:
@@ -13328,18 +13330,18 @@ var require_resolve_flow_collection = __commonJS({
13328
13330
  let offset = fc.offset + fc.start.source.length;
13329
13331
  for (let i2 = 0; i2 < fc.items.length; ++i2) {
13330
13332
  const collItem = fc.items[i2];
13331
- const { start, key, sep: sep2, value } = collItem;
13333
+ const { start, key, sep: sep3, value } = collItem;
13332
13334
  const props = resolveProps.resolveProps(start, {
13333
13335
  flow: fcName,
13334
13336
  indicator: "explicit-key-ind",
13335
- next: key ?? sep2?.[0],
13337
+ next: key ?? sep3?.[0],
13336
13338
  offset,
13337
13339
  onError,
13338
13340
  parentIndent: fc.indent,
13339
13341
  startOnNewline: false
13340
13342
  });
13341
13343
  if (!props.found) {
13342
- if (!props.anchor && !props.tag && !sep2 && !value) {
13344
+ if (!props.anchor && !props.tag && !sep3 && !value) {
13343
13345
  if (i2 === 0 && props.comma)
13344
13346
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
13345
13347
  else if (i2 < fc.items.length - 1)
@@ -13393,8 +13395,8 @@ var require_resolve_flow_collection = __commonJS({
13393
13395
  }
13394
13396
  }
13395
13397
  }
13396
- if (!isMap && !sep2 && !props.found) {
13397
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
13398
+ if (!isMap && !sep3 && !props.found) {
13399
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep3, null, props, onError);
13398
13400
  coll.items.push(valueNode);
13399
13401
  offset = valueNode.range[2];
13400
13402
  if (isBlock(value))
@@ -13406,7 +13408,7 @@ var require_resolve_flow_collection = __commonJS({
13406
13408
  if (isBlock(key))
13407
13409
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
13408
13410
  ctx.atKey = false;
13409
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
13411
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
13410
13412
  flow: fcName,
13411
13413
  indicator: "map-value-ind",
13412
13414
  next: value,
@@ -13417,8 +13419,8 @@ var require_resolve_flow_collection = __commonJS({
13417
13419
  });
13418
13420
  if (valueProps.found) {
13419
13421
  if (!isMap && !props.found && ctx.options.strict) {
13420
- if (sep2)
13421
- for (const st of sep2) {
13422
+ if (sep3)
13423
+ for (const st of sep3) {
13422
13424
  if (st === valueProps.found)
13423
13425
  break;
13424
13426
  if (st.type === "newline") {
@@ -13435,7 +13437,7 @@ var require_resolve_flow_collection = __commonJS({
13435
13437
  else
13436
13438
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
13437
13439
  }
13438
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
13440
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
13439
13441
  if (valueNode) {
13440
13442
  if (isBlock(value))
13441
13443
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -13617,7 +13619,7 @@ var require_resolve_block_scalar = __commonJS({
13617
13619
  chompStart = i2 + 1;
13618
13620
  }
13619
13621
  let value = "";
13620
- let sep2 = "";
13622
+ let sep3 = "";
13621
13623
  let prevMoreIndented = false;
13622
13624
  for (let i2 = 0; i2 < contentStart; ++i2)
13623
13625
  value += lines[i2][0].slice(trimIndent) + "\n";
@@ -13634,24 +13636,24 @@ var require_resolve_block_scalar = __commonJS({
13634
13636
  indent = "";
13635
13637
  }
13636
13638
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
13637
- value += sep2 + indent.slice(trimIndent) + content;
13638
- sep2 = "\n";
13639
+ value += sep3 + indent.slice(trimIndent) + content;
13640
+ sep3 = "\n";
13639
13641
  } else if (indent.length > trimIndent || content[0] === " ") {
13640
- if (sep2 === " ")
13641
- sep2 = "\n";
13642
- else if (!prevMoreIndented && sep2 === "\n")
13643
- sep2 = "\n\n";
13644
- value += sep2 + indent.slice(trimIndent) + content;
13645
- sep2 = "\n";
13642
+ if (sep3 === " ")
13643
+ sep3 = "\n";
13644
+ else if (!prevMoreIndented && sep3 === "\n")
13645
+ sep3 = "\n\n";
13646
+ value += sep3 + indent.slice(trimIndent) + content;
13647
+ sep3 = "\n";
13646
13648
  prevMoreIndented = true;
13647
13649
  } else if (content === "") {
13648
- if (sep2 === "\n")
13650
+ if (sep3 === "\n")
13649
13651
  value += "\n";
13650
13652
  else
13651
- sep2 = "\n";
13653
+ sep3 = "\n";
13652
13654
  } else {
13653
- value += sep2 + content;
13654
- sep2 = " ";
13655
+ value += sep3 + content;
13656
+ sep3 = " ";
13655
13657
  prevMoreIndented = false;
13656
13658
  }
13657
13659
  }
@@ -13835,25 +13837,25 @@ var require_resolve_flow_scalar = __commonJS({
13835
13837
  trimBoth = /^[ \t]+|[ \t]+$/g;
13836
13838
  }
13837
13839
  let res = match[1].replace(trimEnd, "");
13838
- let sep2 = " ";
13840
+ let sep3 = " ";
13839
13841
  let pos = line.lastIndex;
13840
13842
  while (match = line.exec(source)) {
13841
13843
  const lm = match[1].replace(trimBoth, "");
13842
13844
  if (lm === "") {
13843
- if (sep2 === "\n")
13844
- res += sep2;
13845
+ if (sep3 === "\n")
13846
+ res += sep3;
13845
13847
  else
13846
- sep2 = "\n";
13848
+ sep3 = "\n";
13847
13849
  } else {
13848
- res += sep2 + lm;
13849
- sep2 = " ";
13850
+ res += sep3 + lm;
13851
+ sep3 = " ";
13850
13852
  }
13851
13853
  pos = line.lastIndex;
13852
13854
  }
13853
13855
  const last = /[ \t]*(.*)/sy;
13854
13856
  last.lastIndex = pos;
13855
13857
  match = last.exec(source);
13856
- return res + sep2 + (match?.[1] ?? "");
13858
+ return res + sep3 + (match?.[1] ?? "");
13857
13859
  }
13858
13860
  function doubleQuotedValue(source, onError) {
13859
13861
  let res = "";
@@ -14670,14 +14672,14 @@ var require_cst_stringify = __commonJS({
14670
14672
  }
14671
14673
  }
14672
14674
  }
14673
- function stringifyItem({ start, key, sep: sep2, value }) {
14675
+ function stringifyItem({ start, key, sep: sep3, value }) {
14674
14676
  let res = "";
14675
14677
  for (const st of start)
14676
14678
  res += st.source;
14677
14679
  if (key)
14678
14680
  res += stringifyToken(key);
14679
- if (sep2)
14680
- for (const st of sep2)
14681
+ if (sep3)
14682
+ for (const st of sep3)
14681
14683
  res += st.source;
14682
14684
  if (value)
14683
14685
  res += stringifyToken(value);
@@ -15849,18 +15851,18 @@ var require_parser = __commonJS({
15849
15851
  if (this.type === "map-value-ind") {
15850
15852
  const prev = getPrevProps(this.peek(2));
15851
15853
  const start = getFirstKeyStartProps(prev);
15852
- let sep2;
15854
+ let sep3;
15853
15855
  if (scalar.end) {
15854
- sep2 = scalar.end;
15855
- sep2.push(this.sourceToken);
15856
+ sep3 = scalar.end;
15857
+ sep3.push(this.sourceToken);
15856
15858
  delete scalar.end;
15857
15859
  } else
15858
- sep2 = [this.sourceToken];
15860
+ sep3 = [this.sourceToken];
15859
15861
  const map = {
15860
15862
  type: "block-map",
15861
15863
  offset: scalar.offset,
15862
15864
  indent: scalar.indent,
15863
- items: [{ start, key: scalar, sep: sep2 }]
15865
+ items: [{ start, key: scalar, sep: sep3 }]
15864
15866
  };
15865
15867
  this.onKeyLine = true;
15866
15868
  this.stack[this.stack.length - 1] = map;
@@ -16013,15 +16015,15 @@ var require_parser = __commonJS({
16013
16015
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
16014
16016
  const start2 = getFirstKeyStartProps(it.start);
16015
16017
  const key = it.key;
16016
- const sep2 = it.sep;
16017
- sep2.push(this.sourceToken);
16018
+ const sep3 = it.sep;
16019
+ sep3.push(this.sourceToken);
16018
16020
  delete it.key;
16019
16021
  delete it.sep;
16020
16022
  this.stack.push({
16021
16023
  type: "block-map",
16022
16024
  offset: this.offset,
16023
16025
  indent: this.indent,
16024
- items: [{ start: start2, key, sep: sep2 }]
16026
+ items: [{ start: start2, key, sep: sep3 }]
16025
16027
  });
16026
16028
  } else if (start.length > 0) {
16027
16029
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -16215,13 +16217,13 @@ var require_parser = __commonJS({
16215
16217
  const prev = getPrevProps(parent);
16216
16218
  const start = getFirstKeyStartProps(prev);
16217
16219
  fixFlowSeqItems(fc);
16218
- const sep2 = fc.end.splice(1, fc.end.length);
16219
- sep2.push(this.sourceToken);
16220
+ const sep3 = fc.end.splice(1, fc.end.length);
16221
+ sep3.push(this.sourceToken);
16220
16222
  const map = {
16221
16223
  type: "block-map",
16222
16224
  offset: fc.offset,
16223
16225
  indent: fc.indent,
16224
- items: [{ start, key: fc, sep: sep2 }]
16226
+ items: [{ start, key: fc, sep: sep3 }]
16225
16227
  };
16226
16228
  this.onKeyLine = true;
16227
16229
  this.stack[this.stack.length - 1] = map;
@@ -19892,7 +19894,7 @@ __export(bundle_edge_function_exports, {
19892
19894
  bundleEdgeFunction: () => bundleEdgeFunction
19893
19895
  });
19894
19896
  import fs2 from "node:fs";
19895
- import { resolve as resolve4, dirname as dirname5, join as join4 } from "node:path";
19897
+ import { resolve as resolve4, dirname as dirname5, join as join4, relative as relative3, sep as sep2 } from "node:path";
19896
19898
  function detectWorkspace() {
19897
19899
  let currentDir = process.cwd();
19898
19900
  const maxDepth = 10;
@@ -19974,25 +19976,19 @@ function createDenoEdgePlugin(workspace, denoImports, functionsDir) {
19974
19976
  setup(build2) {
19975
19977
  build2.onResolve({ filter: /^@donotdev\/functions\/.+/ }, (args) => {
19976
19978
  const subpath = args.path.replace("@donotdev/functions/", "");
19977
- if (workspace.type === "dndev") {
19978
- return {
19979
- path: resolve4(
19980
- workspace.root,
19981
- "packages",
19982
- "functions",
19983
- "src",
19984
- subpath,
19985
- "index.ts"
19986
- )
19987
- };
19979
+ const packageDir = workspace.type === "dndev" ? resolve4(workspace.root, "packages", "functions") : resolveFrameworkPackage("@donotdev/functions", functionsDir);
19980
+ if (!packageDir) {
19981
+ throw new Error(
19982
+ `@donotdev/functions not found from ${functionsDir}. Install it in the app.`
19983
+ );
19988
19984
  }
19989
- const resolved = resolvePackageExport(
19990
- "@donotdev/functions",
19991
- `./${subpath}`,
19992
- functionsDir
19993
- );
19994
- if (resolved) return { path: resolved };
19995
- return null;
19985
+ const entry = resolve4(packageDir, "src", subpath, "index.ts");
19986
+ if (!fs2.existsSync(entry)) {
19987
+ throw new Error(
19988
+ `${args.path} has no source entry at ${entry}. Check the import path.`
19989
+ );
19990
+ }
19991
+ return { path: entry };
19996
19992
  });
19997
19993
  build2.onResolve({ filter: /^@donotdev\/core$/ }, (args) => {
19998
19994
  if (workspace.type === "dndev") {
@@ -20111,6 +20107,7 @@ function createDenoEdgePlugin(workspace, denoImports, functionsDir) {
20111
20107
  build2.onResolve({ filter: /.*/ }, (args) => {
20112
20108
  if (args.kind === "entry-point") return null;
20113
20109
  if (args.path.startsWith(".") || args.path.startsWith("/")) return null;
20110
+ if (args.path.startsWith("node:")) return { path: args.path, external: true };
20114
20111
  if (args.path.startsWith("@donotdev/")) return null;
20115
20112
  const packageRoot = args.path.startsWith("@") ? args.path.split("/").slice(0, 2).join("/") : args.path.split("/")[0];
20116
20113
  if (packageRoot && ALWAYS_BUNDLE.has(packageRoot)) return null;
@@ -20125,6 +20122,72 @@ function createDenoEdgePlugin(workspace, denoImports, functionsDir) {
20125
20122
  }
20126
20123
  };
20127
20124
  }
20125
+ function importChain(metafile, entry, target) {
20126
+ const previous = /* @__PURE__ */ new Map([[entry, null]]);
20127
+ const queue = [entry];
20128
+ while (queue.length > 0) {
20129
+ const current = queue.shift();
20130
+ if (current === target) break;
20131
+ for (const imported of metafile.inputs[current]?.imports ?? []) {
20132
+ if (previous.has(imported.path)) continue;
20133
+ previous.set(imported.path, current);
20134
+ queue.push(imported.path);
20135
+ }
20136
+ }
20137
+ if (!previous.has(target)) return [target];
20138
+ const chain = [];
20139
+ for (let at = target; at !== null; at = previous.get(at) ?? null) {
20140
+ chain.unshift(at);
20141
+ }
20142
+ return chain;
20143
+ }
20144
+ function assertEdgeBoundary(metafile, entryPointPath, workspace, functionsDir) {
20145
+ const isFrameworkModule = (input) => {
20146
+ const absolute = resolve4(process.cwd(), input);
20147
+ if (absolute.startsWith(resolve4(functionsDir) + sep2)) return false;
20148
+ return absolute.includes(`${sep2}node_modules${sep2}@donotdev${sep2}`) || workspace.type === "dndev" && absolute.startsWith(resolve4(workspace.root, "packages") + sep2);
20149
+ };
20150
+ const entry = relative3(process.cwd(), entryPointPath).split(sep2).join("/");
20151
+ if (!metafile.inputs[entry]) {
20152
+ throw new Error(`Edge bundle metafile has no input for ${entryPointPath}`);
20153
+ }
20154
+ const output = Object.values(metafile.outputs)[0];
20155
+ if (!output) throw new Error("Edge bundle metafile has no output");
20156
+ const bundled = Object.entries(output.inputs).filter(([, info2]) => info2.bytesInOutput > 0).map(([input]) => input);
20157
+ const externals = output.imports.filter((imported) => imported.external).map((imported) => imported.path);
20158
+ const firstHit = /* @__PURE__ */ new Map();
20159
+ for (const { label, pattern, frameworkOnly } of EDGE_FORBIDDEN) {
20160
+ const input = bundled.find((path) => pattern.test(path));
20161
+ if (input) {
20162
+ firstHit.set(label, { module: input, importer: input });
20163
+ continue;
20164
+ }
20165
+ const hit = externals.filter((path) => pattern.test(path)).flatMap((external) => {
20166
+ const importers = bundled.filter(
20167
+ (path) => metafile.inputs[path]?.imports.some(
20168
+ (imported) => imported.external && imported.path === external
20169
+ )
20170
+ );
20171
+ return (importers.length > 0 ? importers : [entry]).map((importer) => ({
20172
+ module: external,
20173
+ importer
20174
+ }));
20175
+ }).find(({ importer }) => !frameworkOnly || isFrameworkModule(importer));
20176
+ if (hit) firstHit.set(label, hit);
20177
+ }
20178
+ if (firstHit.size > 0) {
20179
+ const violations = [...firstHit].map(([label, { module, importer }]) => {
20180
+ const chain = importChain(metafile, entry, importer);
20181
+ if (module !== importer) chain.push(module);
20182
+ return `${label}:
20183
+ ${chain.join("\n \u2192 ")}`;
20184
+ });
20185
+ throw new Error(
20186
+ `Edge function ${entryPointPath} would load modules that do not belong in a Supabase Edge Function:
20187
+ ` + violations.map((v) => ` - ${v}`).join("\n") + "\nThe chain shows which import pulls each one in. Import Supabase or provider-neutral modules instead (@donotdev/functions/supabase, @donotdev/core/server); never Firebase, client code or React. If the chain goes through @donotdev/functions, update it to the same version as your CLI."
20188
+ );
20189
+ }
20190
+ }
20128
20191
  async function bundleEdgeFunction(options) {
20129
20192
  const { entryPointPath, functionsDir } = options;
20130
20193
  const workspace = detectWorkspace();
@@ -20181,7 +20244,8 @@ async function bundleEdgeFunction(options) {
20181
20244
  plugins: [createDenoEdgePlugin(workspace, denoImports, functionsDir)],
20182
20245
  mainFields: ["module", "main"],
20183
20246
  conditions: ["import", "module"],
20184
- logLevel: "warning"
20247
+ logLevel: "warning",
20248
+ metafile: true
20185
20249
  };
20186
20250
  const result = await (0, import_esbuild.build)(config);
20187
20251
  if (result.errors.length > 0) {
@@ -20189,6 +20253,7 @@ async function bundleEdgeFunction(options) {
20189
20253
  throw new Error(`Edge function bundling failed:
20190
20254
  ${errorMessages}`);
20191
20255
  }
20256
+ assertEdgeBoundary(result.metafile, entryPointPath, workspace, functionsDir);
20192
20257
  if (result.warnings.length > 0) {
20193
20258
  for (const warning of result.warnings) {
20194
20259
  log2.debug(`[bundle-edge] Warning: ${warning.text}`);
@@ -20242,7 +20307,7 @@ ${errors.length} function(s) failed to bundle`);
20242
20307
  All ${results.length} function(s) built to ${buildDir}`);
20243
20308
  return { success: true, functions: results, errors: [] };
20244
20309
  }
20245
- var import_esbuild, ALWAYS_BUNDLE;
20310
+ var import_esbuild, ALWAYS_BUNDLE, EDGE_FORBIDDEN;
20246
20311
  var init_bundle_edge_function = __esm({
20247
20312
  "packages/tooling/src/utils/bundle-edge-function.ts"() {
20248
20313
  "use strict";
@@ -20251,6 +20316,19 @@ var init_bundle_edge_function = __esm({
20251
20316
  init_cli_output();
20252
20317
  init_pathResolver();
20253
20318
  ALWAYS_BUNDLE = /* @__PURE__ */ new Set(["valibot"]);
20319
+ EDGE_FORBIDDEN = [
20320
+ { label: "firebase-admin", pattern: /(^|[/:])firebase-admin(\/|$)/ },
20321
+ { label: "firebase-functions", pattern: /(^|[/:])firebase-functions(\/|$)/ },
20322
+ {
20323
+ label: "@donotdev/firebase",
20324
+ pattern: /(^|[/:])@donotdev\/firebase(\/|$)|(^|\/)providers\/firebase\//
20325
+ },
20326
+ {
20327
+ label: "client code (@donotdev/utils client)",
20328
+ pattern: /core\/utils\/src\/client\//
20329
+ },
20330
+ { label: "react", pattern: /(^|[/:])react(\/|$)/, frameworkOnly: true }
20331
+ ];
20254
20332
  }
20255
20333
  });
20256
20334
 
@@ -21794,6 +21872,7 @@ async function deployRules(appDir, serviceAccountPath, projectId, config, option
21794
21872
  init_utils2();
21795
21873
  import { execFileSync } from "node:child_process";
21796
21874
  import { createHash } from "node:crypto";
21875
+ import { readlinkSync } from "node:fs";
21797
21876
  init_vercel_api();
21798
21877
  init_vercel_token();
21799
21878
  init_cli_output();
@@ -21803,6 +21882,7 @@ init_secrets_resolver();
21803
21882
  var UPLOAD_BATCH_SIZE = 10;
21804
21883
  var POLL_INTERVAL_MS = 3e3;
21805
21884
  var POLL_MAX_ATTEMPTS = 100;
21885
+ var SYMLINK_MODE = 41471;
21806
21886
  function apiHeaders(token, extra) {
21807
21887
  return { Authorization: `Bearer ${token}`, ...extra };
21808
21888
  }
@@ -21818,10 +21898,14 @@ async function collectDistFiles(distDir) {
21818
21898
  });
21819
21899
  for (const entry of entries) {
21820
21900
  const fullPath = joinPath(dir, entry.name);
21821
- if (entry.isDirectory()) {
21901
+ const isDir = entry.isDirectory() || entry.isSymbolicLink() && statSync2(fullPath)?.isDirectory() === true;
21902
+ if (isDir) {
21822
21903
  await walk(fullPath);
21823
21904
  } else {
21824
21905
  const content = await read(fullPath, { format: "buffer" });
21906
+ if (!content) {
21907
+ throw new Error(`Cannot read ${fullPath} for upload`);
21908
+ }
21825
21909
  const sha = createHash("sha1").update(content).digest("hex");
21826
21910
  files.push({
21827
21911
  relativePath: getRelativePathBetween(distDir, fullPath),
@@ -21835,7 +21919,7 @@ async function collectDistFiles(distDir) {
21835
21919
  await walk(distDir);
21836
21920
  return files;
21837
21921
  }
21838
- async function collectVercelOutputFiles(appDir) {
21922
+ async function collectVercelOutputFiles(appDir, repoRoot) {
21839
21923
  const outputRoot = joinPath(appDir, ".vercel/output");
21840
21924
  if (!pathExists(outputRoot)) return [];
21841
21925
  const files = [];
@@ -21845,10 +21929,14 @@ async function collectVercelOutputFiles(appDir) {
21845
21929
  });
21846
21930
  for (const entry of entries) {
21847
21931
  const fullPath = joinPath(dir, entry.name);
21848
- if (entry.isDirectory()) {
21932
+ const isDir = entry.isDirectory() || entry.isSymbolicLink() && statSync2(fullPath)?.isDirectory() === true;
21933
+ if (isDir) {
21849
21934
  await walk(fullPath);
21850
21935
  } else {
21851
21936
  const content = await read(fullPath, { format: "buffer" });
21937
+ if (!content) {
21938
+ throw new Error(`Cannot read ${fullPath} for upload`);
21939
+ }
21852
21940
  const sha = createHash("sha1").update(content).digest("hex");
21853
21941
  files.push({
21854
21942
  relativePath: getRelativePathBetween(appDir, fullPath),
@@ -21860,7 +21948,39 @@ async function collectVercelOutputFiles(appDir) {
21860
21948
  }
21861
21949
  }
21862
21950
  await walk(outputRoot);
21863
- return files;
21951
+ const mapped = [];
21952
+ for (const file of files) {
21953
+ if (!file.relativePath.endsWith(".func/.vc-config.json")) continue;
21954
+ const config = JSON.parse(file.content.toString("utf8"));
21955
+ const funcDir = file.relativePath.slice(0, -"/.vc-config.json".length);
21956
+ for (const [target, source] of Object.entries(config.filePathMap ?? {})) {
21957
+ const sourcePath = joinPath(repoRoot, source);
21958
+ if (lstatSync3(sourcePath)?.isSymbolicLink()) {
21959
+ const linkTarget = Buffer2.from(readlinkSync(sourcePath), "utf8");
21960
+ mapped.push({
21961
+ relativePath: `${funcDir}/${target}`,
21962
+ content: linkTarget,
21963
+ sha: createHash("sha1").update(linkTarget).digest("hex"),
21964
+ size: linkTarget.byteLength,
21965
+ mode: SYMLINK_MODE
21966
+ });
21967
+ continue;
21968
+ }
21969
+ const content = await read(sourcePath, { format: "buffer" });
21970
+ if (!content) {
21971
+ throw new Error(
21972
+ `filePathMap of ${funcDir}: cannot read ${sourcePath} (resolved from the repository root)`
21973
+ );
21974
+ }
21975
+ mapped.push({
21976
+ relativePath: `${funcDir}/${target}`,
21977
+ content,
21978
+ sha: createHash("sha1").update(content).digest("hex"),
21979
+ size: content.byteLength
21980
+ });
21981
+ }
21982
+ }
21983
+ return [...files, ...mapped];
21864
21984
  }
21865
21985
  function runVercelBuild(appDir, projectRoot) {
21866
21986
  const result = resolveVercelCredentials(appDir, projectRoot);
@@ -22009,7 +22129,8 @@ async function createDeployment(files, token, orgId, projectId, projectName) {
22009
22129
  files: files.map((f) => ({
22010
22130
  file: f.relativePath,
22011
22131
  sha: f.sha,
22012
- size: f.size
22132
+ size: f.size,
22133
+ ...f.mode !== void 0 ? { mode: f.mode } : {}
22013
22134
  })),
22014
22135
  projectSettings: {
22015
22136
  buildCommand: "",
@@ -22084,7 +22205,7 @@ async function waitForReady(deploymentId, token, orgId) {
22084
22205
  }
22085
22206
  throw new Error("Deployment timed out (5+ minutes)");
22086
22207
  }
22087
- async function deployVercelFrontend(appDir, config, framework = "unknown") {
22208
+ async function deployVercelFrontend(appDir, repoRoot, config, framework = "unknown") {
22088
22209
  const result = resolveVercelCredentials(appDir);
22089
22210
  if ("missing" in result) {
22090
22211
  const missing = result.missing ?? [];
@@ -22122,7 +22243,7 @@ async function deployVercelFrontend(appDir, config, framework = "unknown") {
22122
22243
  );
22123
22244
  }
22124
22245
  log2.info("Collecting .vercel/output files...");
22125
- const outputFiles = await collectVercelOutputFiles(appDir);
22246
+ const outputFiles = await collectVercelOutputFiles(appDir, repoRoot);
22126
22247
  if (outputFiles.length === 0) {
22127
22248
  throw new Error(
22128
22249
  ".vercel/output is empty \u2014 vercel build may have failed."
@@ -22553,11 +22674,20 @@ async function main2(options = {}) {
22553
22674
  ...serviceAccountPath ? [`Service Account: ${serviceAccountPath}`] : []
22554
22675
  ].join("\n");
22555
22676
  note(configNote, "Deployment Configuration");
22677
+ if (options.dryRun) {
22678
+ outro("Dry run: build checked, nothing uploaded or deployed.");
22679
+ return;
22680
+ }
22556
22681
  if (shouldDeployFirebaseFrontend && serviceAccountPath && config.project) {
22557
22682
  await deployFrontend(appDir, serviceAccountPath, config.project, config);
22558
22683
  }
22559
22684
  if (shouldDeployVercelFrontend) {
22560
- await deployVercelFrontend(appDir, config, appProviderInfo.framework);
22685
+ await deployVercelFrontend(
22686
+ appDir,
22687
+ projectRoot,
22688
+ config,
22689
+ appProviderInfo.framework
22690
+ );
22561
22691
  }
22562
22692
  if (shouldDeployFirebaseFunctions && serviceAccountPath && config.project) {
22563
22693
  const functionsEnvPath = joinPath(appDir, "functions", ".env");