@c4a/context-cli 0.7.80 → 0.7.82

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
@@ -89769,18 +89769,11 @@ function sidebar(entries2, label2 = (entry) => entry.title) {
89769
89769
  }));
89770
89770
  }
89771
89771
  function siteSections(entries2) {
89772
- const directoriesFirst = (siblings) => {
89773
- const ordered = [
89774
- ...siblings.filter((entry) => entry.children.length > 0),
89775
- ...siblings.filter((entry) => entry.children.length === 0)
89776
- ];
89777
- return ordered.map((entry) => ({ ...entry, children: directoriesFirst(entry.children) }));
89778
- };
89779
89772
  const pageLinks = (entry) => [
89780
89773
  ...entry.href ? [entry.href.split("#")[0]] : [],
89781
89774
  ...entry.children.flatMap(pageLinks)
89782
89775
  ];
89783
- return entries2.map((entry) => ({ ...entry, children: directoriesFirst(entry.children) })).map((entry) => ({
89776
+ return entries2.map((entry) => ({
89784
89777
  key: entry.key,
89785
89778
  title: entry.title,
89786
89779
  entry,
@@ -90008,16 +90001,24 @@ ${localized.body}`);
90008
90001
  for (const section of sections) {
90009
90002
  await writeFile22(join72(temporary, section.href.slice(1).replace(/\.html$/u, ".md")), localizer.variants((tag) => {
90010
90003
  const lines = [`# ${mdLabel(localizer.entryTitle(tag, section.entry))}`, "", '<div class="context-section-grid">', ""];
90011
- const groups = section.entries.filter((entry) => entry.children.length > 0);
90012
- const articles = section.entries.filter((entry) => entry.children.length === 0);
90013
- for (const group of groups) {
90014
- card(lines, group.href ? `[${mdLabel(localizer.entryTitle(tag, group))}](${group.href})` : mdLabel(localizer.entryTitle(tag, group)), group.children, tag);
90015
- }
90016
- if (groups.length === 0)
90017
- for (const article of articles)
90018
- card(lines, undefined, [article], tag);
90019
- else if (articles.length)
90020
- card(lines, undefined, articles, tag);
90004
+ const grouped = section.entries.some((entry) => entry.children.length > 0);
90005
+ let articles = [];
90006
+ const flush = () => {
90007
+ if (articles.length)
90008
+ card(lines, undefined, articles, tag);
90009
+ articles = [];
90010
+ };
90011
+ for (const entry of section.entries) {
90012
+ if (entry.children.length === 0) {
90013
+ articles.push(entry);
90014
+ if (!grouped)
90015
+ flush();
90016
+ continue;
90017
+ }
90018
+ flush();
90019
+ card(lines, entry.href ? `[${mdLabel(localizer.entryTitle(tag, entry))}](${entry.href})` : mdLabel(localizer.entryTitle(tag, entry)), entry.children, tag);
90020
+ }
90021
+ flush();
90021
90022
  lines.push("</div>");
90022
90023
  return lines.join(`
90023
90024
  `) + `
@@ -94280,6 +94281,35 @@ function normalizeSubpath2(value) {
94280
94281
  const normalized = value.replace(/\\/g, "/").split("/").filter((part) => part.length > 0 && part !== ".").join("/");
94281
94282
  return normalized.length > 0 ? normalized : undefined;
94282
94283
  }
94284
+ function explicitSubpath(value, sourceName) {
94285
+ const parts = value.replace(/\\/g, "/").split("/");
94286
+ if (isAbsolute16(value) || /^[A-Za-z]:/.test(value) || parts.includes("..")) {
94287
+ throw new ContextError(ExitCode.UserError, `repo source subpath must stay inside the repository: ${value}`, {
94288
+ category: ErrorCategory.UserInputInvalid,
94289
+ sourceName,
94290
+ subpath: value,
94291
+ next: "Pass --subpath as a repository-relative directory such as apps/web, or . for the repository root."
94292
+ });
94293
+ }
94294
+ return normalizeSubpath2(value);
94295
+ }
94296
+ function requestedSubpath(input) {
94297
+ if (input.value === undefined)
94298
+ return input.current;
94299
+ const { value, sourceName } = input;
94300
+ const localScope = input.localScoped ? input.current : undefined;
94301
+ const requested = explicitSubpath(value, sourceName);
94302
+ if (localScope !== undefined && localScope !== requested) {
94303
+ throw new ContextError(ExitCode.UserError, `repo source subpath ${requested ?? "."} conflicts with local path scope ${localScope}`, {
94304
+ category: ErrorCategory.UserInputInvalid,
94305
+ sourceName,
94306
+ subpath: value,
94307
+ localSubpath: localScope,
94308
+ next: "Pass --local at the repository root together with --subpath, or pass only --local pointing at the module directory."
94309
+ });
94310
+ }
94311
+ return requested;
94312
+ }
94283
94313
  function scopedLocalPath(rootAbs, subpath) {
94284
94314
  return subpath === undefined ? rootAbs : resolve30(rootAbs, subpath);
94285
94315
  }
@@ -94525,6 +94555,12 @@ async function normalizeAddInput(input, existing) {
94525
94555
  }
94526
94556
  }
94527
94557
  }
94558
+ subpath = requestedSubpath({
94559
+ value: input.subpath,
94560
+ sourceName,
94561
+ current: subpath,
94562
+ localScoped: localWasResolvedFromInput && gitRootAbs !== null
94563
+ });
94528
94564
  if (input.local !== undefined && (explicitRemote === null || explicitRef === null)) {
94529
94565
  if (originalLocalAbs === null || !existsSync22(originalLocalAbs)) {
94530
94566
  throw new ContextError(ExitCode.UserError, `repo source local path does not exist: ${input.local}`, {
@@ -115740,7 +115776,7 @@ async function readSourceBatchJournalStatus(input) {
115740
115776
 
115741
115777
  // src/project/sourceBatchRegistration.ts
115742
115778
  var ITEM_KEYS = {
115743
- repo: new Set(["type", "module", "local", "remote", "ref"]),
115779
+ repo: new Set(["type", "module", "local", "remote", "ref", "subpath"]),
115744
115780
  file: new Set(["type", "module", "local", "include"]),
115745
115781
  lark: new Set(["type", "module", "url", "docToken", "wikiToken", "title"])
115746
115782
  };
@@ -115784,7 +115820,12 @@ function optionalStringArray(record6, field, path3) {
115784
115820
  function assertAllowedKeys(record6, type, path3) {
115785
115821
  const unknown2 = Object.keys(record6).filter((key) => !ITEM_KEYS[type].has(key));
115786
115822
  if (unknown2.length > 0) {
115787
- throw inputError(`${path3} has unsupported field(s): ${unknown2.join(", ")}`, { path: path3, fields: unknown2 });
115823
+ const allowed = [...ITEM_KEYS[type]].join(", ");
115824
+ throw inputError(`${path3} has unsupported field(s): ${unknown2.join(", ")}; ${type} items accept ${allowed}`, {
115825
+ path: path3,
115826
+ fields: unknown2,
115827
+ allowed: [...ITEM_KEYS[type]]
115828
+ });
115788
115829
  }
115789
115830
  }
115790
115831
  function parseBatchItem(value, index2) {
@@ -115800,12 +115841,14 @@ function parseBatchItem(value, index2) {
115800
115841
  const local = optionalString(record6, "local", path3);
115801
115842
  const remote = optionalString(record6, "remote", path3);
115802
115843
  const ref2 = optionalString(record6, "ref", path3);
115844
+ const subpath = optionalString(record6, "subpath", path3);
115803
115845
  return {
115804
115846
  type,
115805
115847
  module: module2,
115806
115848
  ...local !== undefined ? { local } : {},
115807
115849
  ...remote !== undefined ? { remote } : {},
115808
- ...ref2 !== undefined ? { ref: ref2 } : {}
115850
+ ...ref2 !== undefined ? { ref: ref2 } : {},
115851
+ ...subpath !== undefined ? { subpath } : {}
115809
115852
  };
115810
115853
  }
115811
115854
  if (type === "file") {
@@ -117636,6 +117679,9 @@ repo.local is resolved from the Context project root. A valid local Git checkout
117636
117679
  lets the CLI infer origin and the current commit; remote/ref are needed only when
117637
117680
  that local identity cannot be resolved. If local is omitted, the CLI also accepts
117638
117681
  one uniquely named Git directory at <project-root>/<module> or ../<module>.
117682
+ repo.subpath is an optional repository-relative module directory. Use it with
117683
+ remote/ref, or with local pointing at the checkout root; a local module directory
117684
+ already sets the subpath.
117639
117685
  The current source-boundary Route requires the completed, presented work-start
117640
117686
  report shown above. A direct maintenance call outside that Route may omit it.
117641
117687
  For long batches, add --checkpoint --progress. Resume with --resume <job-id>;
@@ -117678,7 +117724,7 @@ Resume performs registration only unless --configure is explicitly supplied.
117678
117724
  }
117679
117725
  writeFormatted(result, format2);
117680
117726
  });
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) => {
117727
+ 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
117728
  const options = actionOptions(...args);
117683
117729
  const format2 = assertChoice(options.format, DATA_FORMATS, "--format");
117684
117730
  const projectRoot2 = requireProjectRoot3(process.cwd(), "source add repo");
@@ -117693,13 +117739,15 @@ Resume performs registration only unless --configure is explicitly supplied.
117693
117739
  const local = optionalString2(options.local);
117694
117740
  const remote = optionalString2(options.remote);
117695
117741
  const ref2 = optionalString2(options.ref);
117742
+ const subpath = optionalString2(options.subpath);
117696
117743
  const result = await addRepoSource({
117697
117744
  projectRoot: projectRoot2,
117698
117745
  namespace: sourceNamespace.name,
117699
117746
  module,
117700
117747
  ...local !== undefined ? { local } : {},
117701
117748
  ...remote !== undefined ? { remote } : {},
117702
- ...ref2 !== undefined ? { ref: ref2 } : {}
117749
+ ...ref2 !== undefined ? { ref: ref2 } : {},
117750
+ ...subpath !== undefined ? { subpath } : {}
117703
117751
  });
117704
117752
  writeFormatted(options.configure ? { ...result, configuration: await configureRegisteredSources(projectRoot2, [{ type: "repo", name: `${sourceNamespace.name}/${module}` }]) } : result, format2);
117705
117753
  });