@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.
package/dist/index.js CHANGED
@@ -5330,15 +5330,15 @@ var require_pattern = __commonJS({
5330
5330
  exports.removeDuplicateSlashes = removeDuplicateSlashes;
5331
5331
  function partitionAbsoluteAndRelative(patterns) {
5332
5332
  const absolute = [];
5333
- const relative3 = [];
5333
+ const relative4 = [];
5334
5334
  for (const pattern of patterns) {
5335
5335
  if (isAbsolute2(pattern)) {
5336
5336
  absolute.push(pattern);
5337
5337
  } else {
5338
- relative3.push(pattern);
5338
+ relative4.push(pattern);
5339
5339
  }
5340
5340
  }
5341
- return [absolute, relative3];
5341
+ return [absolute, relative4];
5342
5342
  }
5343
5343
  exports.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
5344
5344
  function isAbsolute2(pattern) {
@@ -9303,8 +9303,8 @@ var init_pathResolver = __esm({
9303
9303
  if (normalizedTarget === normalizedRoot) {
9304
9304
  return true;
9305
9305
  }
9306
- const relative3 = getRelativePathBetween(normalizedRoot, normalizedTarget);
9307
- return Boolean(relative3) && !relative3.startsWith("../") && !relative3.startsWith("/") && !relative3.includes("..");
9306
+ const relative4 = getRelativePathBetween(normalizedRoot, normalizedTarget);
9307
+ return Boolean(relative4) && !relative4.startsWith("../") && !relative4.startsWith("/") && !relative4.includes("..");
9308
9308
  };
9309
9309
  }
9310
9310
  });
@@ -12320,7 +12320,7 @@ __export(bundle_edge_function_exports, {
12320
12320
  bundleEdgeFunction: () => bundleEdgeFunction
12321
12321
  });
12322
12322
  import fs2 from "node:fs";
12323
- import { resolve as resolve4, dirname as dirname5, join as join4 } from "node:path";
12323
+ import { resolve as resolve4, dirname as dirname5, join as join4, relative as relative3, sep as sep2 } from "node:path";
12324
12324
  function detectWorkspace() {
12325
12325
  let currentDir = process.cwd();
12326
12326
  const maxDepth = 10;
@@ -12402,25 +12402,19 @@ function createDenoEdgePlugin(workspace, denoImports, functionsDir) {
12402
12402
  setup(build2) {
12403
12403
  build2.onResolve({ filter: /^@donotdev\/functions\/.+/ }, (args) => {
12404
12404
  const subpath = args.path.replace("@donotdev/functions/", "");
12405
- if (workspace.type === "dndev") {
12406
- return {
12407
- path: resolve4(
12408
- workspace.root,
12409
- "packages",
12410
- "functions",
12411
- "src",
12412
- subpath,
12413
- "index.ts"
12414
- )
12415
- };
12405
+ const packageDir = workspace.type === "dndev" ? resolve4(workspace.root, "packages", "functions") : resolveFrameworkPackage("@donotdev/functions", functionsDir);
12406
+ if (!packageDir) {
12407
+ throw new Error(
12408
+ `@donotdev/functions not found from ${functionsDir}. Install it in the app.`
12409
+ );
12416
12410
  }
12417
- const resolved = resolvePackageExport(
12418
- "@donotdev/functions",
12419
- `./${subpath}`,
12420
- functionsDir
12421
- );
12422
- if (resolved) return { path: resolved };
12423
- return null;
12411
+ const entry = resolve4(packageDir, "src", subpath, "index.ts");
12412
+ if (!fs2.existsSync(entry)) {
12413
+ throw new Error(
12414
+ `${args.path} has no source entry at ${entry}. Check the import path.`
12415
+ );
12416
+ }
12417
+ return { path: entry };
12424
12418
  });
12425
12419
  build2.onResolve({ filter: /^@donotdev\/core$/ }, (args) => {
12426
12420
  if (workspace.type === "dndev") {
@@ -12539,6 +12533,7 @@ function createDenoEdgePlugin(workspace, denoImports, functionsDir) {
12539
12533
  build2.onResolve({ filter: /.*/ }, (args) => {
12540
12534
  if (args.kind === "entry-point") return null;
12541
12535
  if (args.path.startsWith(".") || args.path.startsWith("/")) return null;
12536
+ if (args.path.startsWith("node:")) return { path: args.path, external: true };
12542
12537
  if (args.path.startsWith("@donotdev/")) return null;
12543
12538
  const packageRoot = args.path.startsWith("@") ? args.path.split("/").slice(0, 2).join("/") : args.path.split("/")[0];
12544
12539
  if (packageRoot && ALWAYS_BUNDLE.has(packageRoot)) return null;
@@ -12553,6 +12548,72 @@ function createDenoEdgePlugin(workspace, denoImports, functionsDir) {
12553
12548
  }
12554
12549
  };
12555
12550
  }
12551
+ function importChain(metafile, entry, target) {
12552
+ const previous = /* @__PURE__ */ new Map([[entry, null]]);
12553
+ const queue = [entry];
12554
+ while (queue.length > 0) {
12555
+ const current = queue.shift();
12556
+ if (current === target) break;
12557
+ for (const imported of metafile.inputs[current]?.imports ?? []) {
12558
+ if (previous.has(imported.path)) continue;
12559
+ previous.set(imported.path, current);
12560
+ queue.push(imported.path);
12561
+ }
12562
+ }
12563
+ if (!previous.has(target)) return [target];
12564
+ const chain = [];
12565
+ for (let at = target; at !== null; at = previous.get(at) ?? null) {
12566
+ chain.unshift(at);
12567
+ }
12568
+ return chain;
12569
+ }
12570
+ function assertEdgeBoundary(metafile, entryPointPath, workspace, functionsDir) {
12571
+ const isFrameworkModule = (input) => {
12572
+ const absolute = resolve4(process.cwd(), input);
12573
+ if (absolute.startsWith(resolve4(functionsDir) + sep2)) return false;
12574
+ return absolute.includes(`${sep2}node_modules${sep2}@donotdev${sep2}`) || workspace.type === "dndev" && absolute.startsWith(resolve4(workspace.root, "packages") + sep2);
12575
+ };
12576
+ const entry = relative3(process.cwd(), entryPointPath).split(sep2).join("/");
12577
+ if (!metafile.inputs[entry]) {
12578
+ throw new Error(`Edge bundle metafile has no input for ${entryPointPath}`);
12579
+ }
12580
+ const output = Object.values(metafile.outputs)[0];
12581
+ if (!output) throw new Error("Edge bundle metafile has no output");
12582
+ const bundled = Object.entries(output.inputs).filter(([, info2]) => info2.bytesInOutput > 0).map(([input]) => input);
12583
+ const externals = output.imports.filter((imported) => imported.external).map((imported) => imported.path);
12584
+ const firstHit = /* @__PURE__ */ new Map();
12585
+ for (const { label, pattern, frameworkOnly } of EDGE_FORBIDDEN) {
12586
+ const input = bundled.find((path) => pattern.test(path));
12587
+ if (input) {
12588
+ firstHit.set(label, { module: input, importer: input });
12589
+ continue;
12590
+ }
12591
+ const hit = externals.filter((path) => pattern.test(path)).flatMap((external) => {
12592
+ const importers = bundled.filter(
12593
+ (path) => metafile.inputs[path]?.imports.some(
12594
+ (imported) => imported.external && imported.path === external
12595
+ )
12596
+ );
12597
+ return (importers.length > 0 ? importers : [entry]).map((importer) => ({
12598
+ module: external,
12599
+ importer
12600
+ }));
12601
+ }).find(({ importer }) => !frameworkOnly || isFrameworkModule(importer));
12602
+ if (hit) firstHit.set(label, hit);
12603
+ }
12604
+ if (firstHit.size > 0) {
12605
+ const violations = [...firstHit].map(([label, { module, importer }]) => {
12606
+ const chain = importChain(metafile, entry, importer);
12607
+ if (module !== importer) chain.push(module);
12608
+ return `${label}:
12609
+ ${chain.join("\n \u2192 ")}`;
12610
+ });
12611
+ throw new Error(
12612
+ `Edge function ${entryPointPath} would load modules that do not belong in a Supabase Edge Function:
12613
+ ` + 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."
12614
+ );
12615
+ }
12616
+ }
12556
12617
  async function bundleEdgeFunction(options) {
12557
12618
  const { entryPointPath, functionsDir } = options;
12558
12619
  const workspace = detectWorkspace();
@@ -12609,7 +12670,8 @@ async function bundleEdgeFunction(options) {
12609
12670
  plugins: [createDenoEdgePlugin(workspace, denoImports, functionsDir)],
12610
12671
  mainFields: ["module", "main"],
12611
12672
  conditions: ["import", "module"],
12612
- logLevel: "warning"
12673
+ logLevel: "warning",
12674
+ metafile: true
12613
12675
  };
12614
12676
  const result = await (0, import_esbuild.build)(config);
12615
12677
  if (result.errors.length > 0) {
@@ -12617,6 +12679,7 @@ async function bundleEdgeFunction(options) {
12617
12679
  throw new Error(`Edge function bundling failed:
12618
12680
  ${errorMessages}`);
12619
12681
  }
12682
+ assertEdgeBoundary(result.metafile, entryPointPath, workspace, functionsDir);
12620
12683
  if (result.warnings.length > 0) {
12621
12684
  for (const warning of result.warnings) {
12622
12685
  log2.debug(`[bundle-edge] Warning: ${warning.text}`);
@@ -12670,7 +12733,7 @@ ${errors.length} function(s) failed to bundle`);
12670
12733
  All ${results.length} function(s) built to ${buildDir}`);
12671
12734
  return { success: true, functions: results, errors: [] };
12672
12735
  }
12673
- var import_esbuild, ALWAYS_BUNDLE;
12736
+ var import_esbuild, ALWAYS_BUNDLE, EDGE_FORBIDDEN;
12674
12737
  var init_bundle_edge_function = __esm({
12675
12738
  "packages/tooling/src/utils/bundle-edge-function.ts"() {
12676
12739
  "use strict";
@@ -12679,6 +12742,19 @@ var init_bundle_edge_function = __esm({
12679
12742
  init_cli_output();
12680
12743
  init_pathResolver();
12681
12744
  ALWAYS_BUNDLE = /* @__PURE__ */ new Set(["valibot"]);
12745
+ EDGE_FORBIDDEN = [
12746
+ { label: "firebase-admin", pattern: /(^|[/:])firebase-admin(\/|$)/ },
12747
+ { label: "firebase-functions", pattern: /(^|[/:])firebase-functions(\/|$)/ },
12748
+ {
12749
+ label: "@donotdev/firebase",
12750
+ pattern: /(^|[/:])@donotdev\/firebase(\/|$)|(^|\/)providers\/firebase\//
12751
+ },
12752
+ {
12753
+ label: "client code (@donotdev/utils client)",
12754
+ pattern: /core\/utils\/src\/client\//
12755
+ },
12756
+ { label: "react", pattern: /(^|[/:])react(\/|$)/, frameworkOnly: true }
12757
+ ];
12682
12758
  }
12683
12759
  });
12684
12760
 
@@ -16697,10 +16773,10 @@ var require_resolve_block_map = __commonJS({
16697
16773
  let offset = bm.offset;
16698
16774
  let commentEnd = null;
16699
16775
  for (const collItem of bm.items) {
16700
- const { start, key, sep: sep2, value } = collItem;
16776
+ const { start, key, sep: sep3, value } = collItem;
16701
16777
  const keyProps = resolveProps.resolveProps(start, {
16702
16778
  indicator: "explicit-key-ind",
16703
- next: key ?? sep2?.[0],
16779
+ next: key ?? sep3?.[0],
16704
16780
  offset,
16705
16781
  onError,
16706
16782
  parentIndent: bm.indent,
@@ -16714,7 +16790,7 @@ var require_resolve_block_map = __commonJS({
16714
16790
  else if ("indent" in key && key.indent !== bm.indent)
16715
16791
  onError(offset, "BAD_INDENT", startColMsg);
16716
16792
  }
16717
- if (!keyProps.anchor && !keyProps.tag && !sep2) {
16793
+ if (!keyProps.anchor && !keyProps.tag && !sep3) {
16718
16794
  commentEnd = keyProps.end;
16719
16795
  if (keyProps.comment) {
16720
16796
  if (map.comment)
@@ -16738,7 +16814,7 @@ var require_resolve_block_map = __commonJS({
16738
16814
  ctx.atKey = false;
16739
16815
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
16740
16816
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
16741
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
16817
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
16742
16818
  indicator: "map-value-ind",
16743
16819
  next: value,
16744
16820
  offset: keyNode.range[2],
@@ -16754,7 +16830,7 @@ var require_resolve_block_map = __commonJS({
16754
16830
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
16755
16831
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
16756
16832
  }
16757
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
16833
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep3, null, valueProps, onError);
16758
16834
  if (ctx.schema.compat)
16759
16835
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
16760
16836
  offset = valueNode.range[2];
@@ -16847,7 +16923,7 @@ var require_resolve_end = __commonJS({
16847
16923
  let comment = "";
16848
16924
  if (end) {
16849
16925
  let hasSpace = false;
16850
- let sep2 = "";
16926
+ let sep3 = "";
16851
16927
  for (const token of end) {
16852
16928
  const { source, type } = token;
16853
16929
  switch (type) {
@@ -16861,13 +16937,13 @@ var require_resolve_end = __commonJS({
16861
16937
  if (!comment)
16862
16938
  comment = cb;
16863
16939
  else
16864
- comment += sep2 + cb;
16865
- sep2 = "";
16940
+ comment += sep3 + cb;
16941
+ sep3 = "";
16866
16942
  break;
16867
16943
  }
16868
16944
  case "newline":
16869
16945
  if (comment)
16870
- sep2 += source;
16946
+ sep3 += source;
16871
16947
  hasSpace = true;
16872
16948
  break;
16873
16949
  default:
@@ -16911,18 +16987,18 @@ var require_resolve_flow_collection = __commonJS({
16911
16987
  let offset = fc.offset + fc.start.source.length;
16912
16988
  for (let i2 = 0; i2 < fc.items.length; ++i2) {
16913
16989
  const collItem = fc.items[i2];
16914
- const { start, key, sep: sep2, value } = collItem;
16990
+ const { start, key, sep: sep3, value } = collItem;
16915
16991
  const props = resolveProps.resolveProps(start, {
16916
16992
  flow: fcName,
16917
16993
  indicator: "explicit-key-ind",
16918
- next: key ?? sep2?.[0],
16994
+ next: key ?? sep3?.[0],
16919
16995
  offset,
16920
16996
  onError,
16921
16997
  parentIndent: fc.indent,
16922
16998
  startOnNewline: false
16923
16999
  });
16924
17000
  if (!props.found) {
16925
- if (!props.anchor && !props.tag && !sep2 && !value) {
17001
+ if (!props.anchor && !props.tag && !sep3 && !value) {
16926
17002
  if (i2 === 0 && props.comma)
16927
17003
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
16928
17004
  else if (i2 < fc.items.length - 1)
@@ -16976,8 +17052,8 @@ var require_resolve_flow_collection = __commonJS({
16976
17052
  }
16977
17053
  }
16978
17054
  }
16979
- if (!isMap && !sep2 && !props.found) {
16980
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
17055
+ if (!isMap && !sep3 && !props.found) {
17056
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep3, null, props, onError);
16981
17057
  coll.items.push(valueNode);
16982
17058
  offset = valueNode.range[2];
16983
17059
  if (isBlock(value))
@@ -16989,7 +17065,7 @@ var require_resolve_flow_collection = __commonJS({
16989
17065
  if (isBlock(key))
16990
17066
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
16991
17067
  ctx.atKey = false;
16992
- const valueProps = resolveProps.resolveProps(sep2 ?? [], {
17068
+ const valueProps = resolveProps.resolveProps(sep3 ?? [], {
16993
17069
  flow: fcName,
16994
17070
  indicator: "map-value-ind",
16995
17071
  next: value,
@@ -17000,8 +17076,8 @@ var require_resolve_flow_collection = __commonJS({
17000
17076
  });
17001
17077
  if (valueProps.found) {
17002
17078
  if (!isMap && !props.found && ctx.options.strict) {
17003
- if (sep2)
17004
- for (const st of sep2) {
17079
+ if (sep3)
17080
+ for (const st of sep3) {
17005
17081
  if (st === valueProps.found)
17006
17082
  break;
17007
17083
  if (st.type === "newline") {
@@ -17018,7 +17094,7 @@ var require_resolve_flow_collection = __commonJS({
17018
17094
  else
17019
17095
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
17020
17096
  }
17021
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
17097
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep3, null, valueProps, onError) : null;
17022
17098
  if (valueNode) {
17023
17099
  if (isBlock(value))
17024
17100
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -17200,7 +17276,7 @@ var require_resolve_block_scalar = __commonJS({
17200
17276
  chompStart = i2 + 1;
17201
17277
  }
17202
17278
  let value = "";
17203
- let sep2 = "";
17279
+ let sep3 = "";
17204
17280
  let prevMoreIndented = false;
17205
17281
  for (let i2 = 0; i2 < contentStart; ++i2)
17206
17282
  value += lines[i2][0].slice(trimIndent) + "\n";
@@ -17217,24 +17293,24 @@ var require_resolve_block_scalar = __commonJS({
17217
17293
  indent = "";
17218
17294
  }
17219
17295
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
17220
- value += sep2 + indent.slice(trimIndent) + content;
17221
- sep2 = "\n";
17296
+ value += sep3 + indent.slice(trimIndent) + content;
17297
+ sep3 = "\n";
17222
17298
  } else if (indent.length > trimIndent || content[0] === " ") {
17223
- if (sep2 === " ")
17224
- sep2 = "\n";
17225
- else if (!prevMoreIndented && sep2 === "\n")
17226
- sep2 = "\n\n";
17227
- value += sep2 + indent.slice(trimIndent) + content;
17228
- sep2 = "\n";
17299
+ if (sep3 === " ")
17300
+ sep3 = "\n";
17301
+ else if (!prevMoreIndented && sep3 === "\n")
17302
+ sep3 = "\n\n";
17303
+ value += sep3 + indent.slice(trimIndent) + content;
17304
+ sep3 = "\n";
17229
17305
  prevMoreIndented = true;
17230
17306
  } else if (content === "") {
17231
- if (sep2 === "\n")
17307
+ if (sep3 === "\n")
17232
17308
  value += "\n";
17233
17309
  else
17234
- sep2 = "\n";
17310
+ sep3 = "\n";
17235
17311
  } else {
17236
- value += sep2 + content;
17237
- sep2 = " ";
17312
+ value += sep3 + content;
17313
+ sep3 = " ";
17238
17314
  prevMoreIndented = false;
17239
17315
  }
17240
17316
  }
@@ -17418,25 +17494,25 @@ var require_resolve_flow_scalar = __commonJS({
17418
17494
  trimBoth = /^[ \t]+|[ \t]+$/g;
17419
17495
  }
17420
17496
  let res = match[1].replace(trimEnd, "");
17421
- let sep2 = " ";
17497
+ let sep3 = " ";
17422
17498
  let pos = line.lastIndex;
17423
17499
  while (match = line.exec(source)) {
17424
17500
  const lm = match[1].replace(trimBoth, "");
17425
17501
  if (lm === "") {
17426
- if (sep2 === "\n")
17427
- res += sep2;
17502
+ if (sep3 === "\n")
17503
+ res += sep3;
17428
17504
  else
17429
- sep2 = "\n";
17505
+ sep3 = "\n";
17430
17506
  } else {
17431
- res += sep2 + lm;
17432
- sep2 = " ";
17507
+ res += sep3 + lm;
17508
+ sep3 = " ";
17433
17509
  }
17434
17510
  pos = line.lastIndex;
17435
17511
  }
17436
17512
  const last = /[ \t]*(.*)/sy;
17437
17513
  last.lastIndex = pos;
17438
17514
  match = last.exec(source);
17439
- return res + sep2 + (match?.[1] ?? "");
17515
+ return res + sep3 + (match?.[1] ?? "");
17440
17516
  }
17441
17517
  function doubleQuotedValue(source, onError) {
17442
17518
  let res = "";
@@ -18253,14 +18329,14 @@ var require_cst_stringify = __commonJS({
18253
18329
  }
18254
18330
  }
18255
18331
  }
18256
- function stringifyItem({ start, key, sep: sep2, value }) {
18332
+ function stringifyItem({ start, key, sep: sep3, value }) {
18257
18333
  let res = "";
18258
18334
  for (const st of start)
18259
18335
  res += st.source;
18260
18336
  if (key)
18261
18337
  res += stringifyToken(key);
18262
- if (sep2)
18263
- for (const st of sep2)
18338
+ if (sep3)
18339
+ for (const st of sep3)
18264
18340
  res += st.source;
18265
18341
  if (value)
18266
18342
  res += stringifyToken(value);
@@ -19432,18 +19508,18 @@ var require_parser = __commonJS({
19432
19508
  if (this.type === "map-value-ind") {
19433
19509
  const prev = getPrevProps(this.peek(2));
19434
19510
  const start = getFirstKeyStartProps(prev);
19435
- let sep2;
19511
+ let sep3;
19436
19512
  if (scalar.end) {
19437
- sep2 = scalar.end;
19438
- sep2.push(this.sourceToken);
19513
+ sep3 = scalar.end;
19514
+ sep3.push(this.sourceToken);
19439
19515
  delete scalar.end;
19440
19516
  } else
19441
- sep2 = [this.sourceToken];
19517
+ sep3 = [this.sourceToken];
19442
19518
  const map = {
19443
19519
  type: "block-map",
19444
19520
  offset: scalar.offset,
19445
19521
  indent: scalar.indent,
19446
- items: [{ start, key: scalar, sep: sep2 }]
19522
+ items: [{ start, key: scalar, sep: sep3 }]
19447
19523
  };
19448
19524
  this.onKeyLine = true;
19449
19525
  this.stack[this.stack.length - 1] = map;
@@ -19596,15 +19672,15 @@ var require_parser = __commonJS({
19596
19672
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
19597
19673
  const start2 = getFirstKeyStartProps(it.start);
19598
19674
  const key = it.key;
19599
- const sep2 = it.sep;
19600
- sep2.push(this.sourceToken);
19675
+ const sep3 = it.sep;
19676
+ sep3.push(this.sourceToken);
19601
19677
  delete it.key;
19602
19678
  delete it.sep;
19603
19679
  this.stack.push({
19604
19680
  type: "block-map",
19605
19681
  offset: this.offset,
19606
19682
  indent: this.indent,
19607
- items: [{ start: start2, key, sep: sep2 }]
19683
+ items: [{ start: start2, key, sep: sep3 }]
19608
19684
  });
19609
19685
  } else if (start.length > 0) {
19610
19686
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -19798,13 +19874,13 @@ var require_parser = __commonJS({
19798
19874
  const prev = getPrevProps(parent);
19799
19875
  const start = getFirstKeyStartProps(prev);
19800
19876
  fixFlowSeqItems(fc);
19801
- const sep2 = fc.end.splice(1, fc.end.length);
19802
- sep2.push(this.sourceToken);
19877
+ const sep3 = fc.end.splice(1, fc.end.length);
19878
+ sep3.push(this.sourceToken);
19803
19879
  const map = {
19804
19880
  type: "block-map",
19805
19881
  offset: fc.offset,
19806
19882
  indent: fc.indent,
19807
- items: [{ start, key: fc, sep: sep2 }]
19883
+ items: [{ start, key: fc, sep: sep3 }]
19808
19884
  };
19809
19885
  this.onKeyLine = true;
19810
19886
  this.stack[this.stack.length - 1] = map;
@@ -24063,6 +24139,7 @@ async function deployRules(appDir, serviceAccountPath, projectId, config, option
24063
24139
  init_utils2();
24064
24140
  import { execFileSync as execFileSync4 } from "node:child_process";
24065
24141
  import { createHash } from "node:crypto";
24142
+ import { readlinkSync } from "node:fs";
24066
24143
  init_vercel_api();
24067
24144
  init_vercel_token();
24068
24145
  init_cli_output();
@@ -24072,6 +24149,7 @@ init_secrets_resolver();
24072
24149
  var UPLOAD_BATCH_SIZE = 10;
24073
24150
  var POLL_INTERVAL_MS = 3e3;
24074
24151
  var POLL_MAX_ATTEMPTS = 100;
24152
+ var SYMLINK_MODE = 41471;
24075
24153
  function apiHeaders(token, extra) {
24076
24154
  return { Authorization: `Bearer ${token}`, ...extra };
24077
24155
  }
@@ -24087,10 +24165,14 @@ async function collectDistFiles(distDir) {
24087
24165
  });
24088
24166
  for (const entry of entries) {
24089
24167
  const fullPath = joinPath(dir, entry.name);
24090
- if (entry.isDirectory()) {
24168
+ const isDir = entry.isDirectory() || entry.isSymbolicLink() && statSync2(fullPath)?.isDirectory() === true;
24169
+ if (isDir) {
24091
24170
  await walk(fullPath);
24092
24171
  } else {
24093
24172
  const content = await read(fullPath, { format: "buffer" });
24173
+ if (!content) {
24174
+ throw new Error(`Cannot read ${fullPath} for upload`);
24175
+ }
24094
24176
  const sha = createHash("sha1").update(content).digest("hex");
24095
24177
  files.push({
24096
24178
  relativePath: getRelativePathBetween(distDir, fullPath),
@@ -24104,7 +24186,7 @@ async function collectDistFiles(distDir) {
24104
24186
  await walk(distDir);
24105
24187
  return files;
24106
24188
  }
24107
- async function collectVercelOutputFiles(appDir) {
24189
+ async function collectVercelOutputFiles(appDir, repoRoot) {
24108
24190
  const outputRoot = joinPath(appDir, ".vercel/output");
24109
24191
  if (!pathExists(outputRoot)) return [];
24110
24192
  const files = [];
@@ -24114,10 +24196,14 @@ async function collectVercelOutputFiles(appDir) {
24114
24196
  });
24115
24197
  for (const entry of entries) {
24116
24198
  const fullPath = joinPath(dir, entry.name);
24117
- if (entry.isDirectory()) {
24199
+ const isDir = entry.isDirectory() || entry.isSymbolicLink() && statSync2(fullPath)?.isDirectory() === true;
24200
+ if (isDir) {
24118
24201
  await walk(fullPath);
24119
24202
  } else {
24120
24203
  const content = await read(fullPath, { format: "buffer" });
24204
+ if (!content) {
24205
+ throw new Error(`Cannot read ${fullPath} for upload`);
24206
+ }
24121
24207
  const sha = createHash("sha1").update(content).digest("hex");
24122
24208
  files.push({
24123
24209
  relativePath: getRelativePathBetween(appDir, fullPath),
@@ -24129,7 +24215,39 @@ async function collectVercelOutputFiles(appDir) {
24129
24215
  }
24130
24216
  }
24131
24217
  await walk(outputRoot);
24132
- return files;
24218
+ const mapped = [];
24219
+ for (const file of files) {
24220
+ if (!file.relativePath.endsWith(".func/.vc-config.json")) continue;
24221
+ const config = JSON.parse(file.content.toString("utf8"));
24222
+ const funcDir = file.relativePath.slice(0, -"/.vc-config.json".length);
24223
+ for (const [target, source] of Object.entries(config.filePathMap ?? {})) {
24224
+ const sourcePath = joinPath(repoRoot, source);
24225
+ if (lstatSync3(sourcePath)?.isSymbolicLink()) {
24226
+ const linkTarget = Buffer2.from(readlinkSync(sourcePath), "utf8");
24227
+ mapped.push({
24228
+ relativePath: `${funcDir}/${target}`,
24229
+ content: linkTarget,
24230
+ sha: createHash("sha1").update(linkTarget).digest("hex"),
24231
+ size: linkTarget.byteLength,
24232
+ mode: SYMLINK_MODE
24233
+ });
24234
+ continue;
24235
+ }
24236
+ const content = await read(sourcePath, { format: "buffer" });
24237
+ if (!content) {
24238
+ throw new Error(
24239
+ `filePathMap of ${funcDir}: cannot read ${sourcePath} (resolved from the repository root)`
24240
+ );
24241
+ }
24242
+ mapped.push({
24243
+ relativePath: `${funcDir}/${target}`,
24244
+ content,
24245
+ sha: createHash("sha1").update(content).digest("hex"),
24246
+ size: content.byteLength
24247
+ });
24248
+ }
24249
+ }
24250
+ return [...files, ...mapped];
24133
24251
  }
24134
24252
  function runVercelBuild(appDir, projectRoot) {
24135
24253
  const result = resolveVercelCredentials(appDir, projectRoot);
@@ -24278,7 +24396,8 @@ async function createDeployment(files, token, orgId, projectId, projectName) {
24278
24396
  files: files.map((f) => ({
24279
24397
  file: f.relativePath,
24280
24398
  sha: f.sha,
24281
- size: f.size
24399
+ size: f.size,
24400
+ ...f.mode !== void 0 ? { mode: f.mode } : {}
24282
24401
  })),
24283
24402
  projectSettings: {
24284
24403
  buildCommand: "",
@@ -24353,7 +24472,7 @@ async function waitForReady(deploymentId, token, orgId) {
24353
24472
  }
24354
24473
  throw new Error("Deployment timed out (5+ minutes)");
24355
24474
  }
24356
- async function deployVercelFrontend(appDir, config, framework = "unknown") {
24475
+ async function deployVercelFrontend(appDir, repoRoot, config, framework = "unknown") {
24357
24476
  const result = resolveVercelCredentials(appDir);
24358
24477
  if ("missing" in result) {
24359
24478
  const missing = result.missing ?? [];
@@ -24391,7 +24510,7 @@ async function deployVercelFrontend(appDir, config, framework = "unknown") {
24391
24510
  );
24392
24511
  }
24393
24512
  log2.info("Collecting .vercel/output files...");
24394
- const outputFiles = await collectVercelOutputFiles(appDir);
24513
+ const outputFiles = await collectVercelOutputFiles(appDir, repoRoot);
24395
24514
  if (outputFiles.length === 0) {
24396
24515
  throw new Error(
24397
24516
  ".vercel/output is empty \u2014 vercel build may have failed."
@@ -24822,11 +24941,20 @@ async function main6(options = {}) {
24822
24941
  ...serviceAccountPath ? [`Service Account: ${serviceAccountPath}`] : []
24823
24942
  ].join("\n");
24824
24943
  note(configNote, "Deployment Configuration");
24944
+ if (options.dryRun) {
24945
+ outro("Dry run: build checked, nothing uploaded or deployed.");
24946
+ return;
24947
+ }
24825
24948
  if (shouldDeployFirebaseFrontend && serviceAccountPath && config.project) {
24826
24949
  await deployFrontend(appDir, serviceAccountPath, config.project, config);
24827
24950
  }
24828
24951
  if (shouldDeployVercelFrontend) {
24829
- await deployVercelFrontend(appDir, config, appProviderInfo.framework);
24952
+ await deployVercelFrontend(
24953
+ appDir,
24954
+ projectRoot,
24955
+ config,
24956
+ appProviderInfo.framework
24957
+ );
24830
24958
  }
24831
24959
  if (shouldDeployFirebaseFunctions && serviceAccountPath && config.project) {
24832
24960
  const functionsEnvPath = joinPath(appDir, "functions", ".env");
@@ -25254,6 +25382,8 @@ async function createApp(appName, appConfig, workspaceRoot, templatesRoot) {
25254
25382
  appName,
25255
25383
  appShortName: appName.toUpperCase().replace(/-/g, " "),
25256
25384
  includeFunctions: Boolean(row.functionsTemplate),
25385
+ // vercel.json functions/rewrites/env only fit Vercel API functions, not Supabase or Firebase ones.
25386
+ includeVercelFunctions: row.functionsTemplate === "functions-vercel",
25257
25387
  needsCRUD: Boolean(appConfig.needsCRUD),
25258
25388
  setupGithubActions: false,
25259
25389
  appNames: [appName],
@@ -25348,6 +25478,8 @@ async function createApp(appName, appConfig, workspaceRoot, templatesRoot) {
25348
25478
  appName,
25349
25479
  template: isReservedTemplate ? "vite" : appTemplate,
25350
25480
  includeFunctions: Boolean(row.functionsTemplate),
25481
+ // vercel.json functions/rewrites/env only fit Vercel API functions, not Supabase or Firebase ones.
25482
+ includeVercelFunctions: row.functionsTemplate === "functions-vercel",
25351
25483
  platform: isReservedTemplate ? void 0 : backendPlatform
25352
25484
  });
25353
25485
  const packageJsonPath = joinPath(appDir, "package.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Command-line interface for DoNotDev Framework",
5
5
  "type": "module",
6
6
  "private": false,