@c4a/context-cli 0.7.80 → 0.7.81

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/cli.js CHANGED
@@ -94280,6 +94280,35 @@ function normalizeSubpath2(value) {
94280
94280
  const normalized = value.replace(/\\/g, "/").split("/").filter((part) => part.length > 0 && part !== ".").join("/");
94281
94281
  return normalized.length > 0 ? normalized : undefined;
94282
94282
  }
94283
+ function explicitSubpath(value, sourceName) {
94284
+ const parts = value.replace(/\\/g, "/").split("/");
94285
+ if (isAbsolute16(value) || /^[A-Za-z]:/.test(value) || parts.includes("..")) {
94286
+ throw new ContextError(ExitCode.UserError, `repo source subpath must stay inside the repository: ${value}`, {
94287
+ category: ErrorCategory.UserInputInvalid,
94288
+ sourceName,
94289
+ subpath: value,
94290
+ next: "Pass --subpath as a repository-relative directory such as apps/web, or . for the repository root."
94291
+ });
94292
+ }
94293
+ return normalizeSubpath2(value);
94294
+ }
94295
+ function requestedSubpath(input) {
94296
+ if (input.value === undefined)
94297
+ return input.current;
94298
+ const { value, sourceName } = input;
94299
+ const localScope = input.localScoped ? input.current : undefined;
94300
+ const requested = explicitSubpath(value, sourceName);
94301
+ if (localScope !== undefined && localScope !== requested) {
94302
+ throw new ContextError(ExitCode.UserError, `repo source subpath ${requested ?? "."} conflicts with local path scope ${localScope}`, {
94303
+ category: ErrorCategory.UserInputInvalid,
94304
+ sourceName,
94305
+ subpath: value,
94306
+ localSubpath: localScope,
94307
+ next: "Pass --local at the repository root together with --subpath, or pass only --local pointing at the module directory."
94308
+ });
94309
+ }
94310
+ return requested;
94311
+ }
94283
94312
  function scopedLocalPath(rootAbs, subpath) {
94284
94313
  return subpath === undefined ? rootAbs : resolve30(rootAbs, subpath);
94285
94314
  }
@@ -94525,6 +94554,12 @@ async function normalizeAddInput(input, existing) {
94525
94554
  }
94526
94555
  }
94527
94556
  }
94557
+ subpath = requestedSubpath({
94558
+ value: input.subpath,
94559
+ sourceName,
94560
+ current: subpath,
94561
+ localScoped: localWasResolvedFromInput && gitRootAbs !== null
94562
+ });
94528
94563
  if (input.local !== undefined && (explicitRemote === null || explicitRef === null)) {
94529
94564
  if (originalLocalAbs === null || !existsSync22(originalLocalAbs)) {
94530
94565
  throw new ContextError(ExitCode.UserError, `repo source local path does not exist: ${input.local}`, {
@@ -115740,7 +115775,7 @@ async function readSourceBatchJournalStatus(input) {
115740
115775
 
115741
115776
  // src/project/sourceBatchRegistration.ts
115742
115777
  var ITEM_KEYS = {
115743
- repo: new Set(["type", "module", "local", "remote", "ref"]),
115778
+ repo: new Set(["type", "module", "local", "remote", "ref", "subpath"]),
115744
115779
  file: new Set(["type", "module", "local", "include"]),
115745
115780
  lark: new Set(["type", "module", "url", "docToken", "wikiToken", "title"])
115746
115781
  };
@@ -115784,7 +115819,12 @@ function optionalStringArray(record6, field, path3) {
115784
115819
  function assertAllowedKeys(record6, type, path3) {
115785
115820
  const unknown2 = Object.keys(record6).filter((key) => !ITEM_KEYS[type].has(key));
115786
115821
  if (unknown2.length > 0) {
115787
- throw inputError(`${path3} has unsupported field(s): ${unknown2.join(", ")}`, { path: path3, fields: unknown2 });
115822
+ const allowed = [...ITEM_KEYS[type]].join(", ");
115823
+ throw inputError(`${path3} has unsupported field(s): ${unknown2.join(", ")}; ${type} items accept ${allowed}`, {
115824
+ path: path3,
115825
+ fields: unknown2,
115826
+ allowed: [...ITEM_KEYS[type]]
115827
+ });
115788
115828
  }
115789
115829
  }
115790
115830
  function parseBatchItem(value, index2) {
@@ -115800,12 +115840,14 @@ function parseBatchItem(value, index2) {
115800
115840
  const local = optionalString(record6, "local", path3);
115801
115841
  const remote = optionalString(record6, "remote", path3);
115802
115842
  const ref2 = optionalString(record6, "ref", path3);
115843
+ const subpath = optionalString(record6, "subpath", path3);
115803
115844
  return {
115804
115845
  type,
115805
115846
  module: module2,
115806
115847
  ...local !== undefined ? { local } : {},
115807
115848
  ...remote !== undefined ? { remote } : {},
115808
- ...ref2 !== undefined ? { ref: ref2 } : {}
115849
+ ...ref2 !== undefined ? { ref: ref2 } : {},
115850
+ ...subpath !== undefined ? { subpath } : {}
115809
115851
  };
115810
115852
  }
115811
115853
  if (type === "file") {
@@ -117636,6 +117678,9 @@ repo.local is resolved from the Context project root. A valid local Git checkout
117636
117678
  lets the CLI infer origin and the current commit; remote/ref are needed only when
117637
117679
  that local identity cannot be resolved. If local is omitted, the CLI also accepts
117638
117680
  one uniquely named Git directory at <project-root>/<module> or ../<module>.
117681
+ repo.subpath is an optional repository-relative module directory. Use it with
117682
+ remote/ref, or with local pointing at the checkout root; a local module directory
117683
+ already sets the subpath.
117639
117684
  The current source-boundary Route requires the completed, presented work-start
117640
117685
  report shown above. A direct maintenance call outside that Route may omit it.
117641
117686
  For long batches, add --checkpoint --progress. Resume with --resume <job-id>;
@@ -117678,7 +117723,7 @@ Resume performs registration only unless --configure is explicitly supplied.
117678
117723
  }
117679
117724
  writeFormatted(result, format2);
117680
117725
  });
117681
- sourceAdd.command("repo [date]").description("Add or update a repo module under a valid YYYYMMDD batch in sources/repo/index.yaml").option("--configure", "Also select this source in a simple src/index.ts; does not capture").requiredOption("--module <name>", "concrete repo/package module name").option("--remote <url>", "repo remote URL; inferred from local origin when omitted").option("--ref <sha>", "pinned commit/ref; inferred from local HEAD when omitted").option("--local <path>", "local checkout path; may point at a monorepo subdirectory").option("--format <format>", "output format: json | yaml | table", "table").action(async (namespace, ...args) => {
117726
+ sourceAdd.command("repo [date]").description("Add or update a repo module under a valid YYYYMMDD batch in sources/repo/index.yaml").option("--configure", "Also select this source in a simple src/index.ts; does not capture").requiredOption("--module <name>", "concrete repo/package module name").option("--remote <url>", "repo remote URL; inferred from local origin when omitted").option("--ref <sha>", "pinned commit/ref; inferred from local HEAD when omitted").option("--local <path>", "local checkout path; may point at a monorepo subdirectory").option("--subpath <dir>", "repo-relative module directory; use with --remote/--ref or a --local repository root").option("--format <format>", "output format: json | yaml | table", "table").action(async (namespace, ...args) => {
117682
117727
  const options = actionOptions(...args);
117683
117728
  const format2 = assertChoice(options.format, DATA_FORMATS, "--format");
117684
117729
  const projectRoot2 = requireProjectRoot3(process.cwd(), "source add repo");
@@ -117693,13 +117738,15 @@ Resume performs registration only unless --configure is explicitly supplied.
117693
117738
  const local = optionalString2(options.local);
117694
117739
  const remote = optionalString2(options.remote);
117695
117740
  const ref2 = optionalString2(options.ref);
117741
+ const subpath = optionalString2(options.subpath);
117696
117742
  const result = await addRepoSource({
117697
117743
  projectRoot: projectRoot2,
117698
117744
  namespace: sourceNamespace.name,
117699
117745
  module,
117700
117746
  ...local !== undefined ? { local } : {},
117701
117747
  ...remote !== undefined ? { remote } : {},
117702
- ...ref2 !== undefined ? { ref: ref2 } : {}
117748
+ ...ref2 !== undefined ? { ref: ref2 } : {},
117749
+ ...subpath !== undefined ? { subpath } : {}
117703
117750
  });
117704
117751
  writeFormatted(options.configure ? { ...result, configuration: await configureRegisteredSources(projectRoot2, [{ type: "repo", name: `${sourceNamespace.name}/${module}` }]) } : result, format2);
117705
117752
  });