rigjs 4.0.2 → 4.0.3

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.
@@ -29,26 +29,51 @@ export default function wikiRegister(givenPath: string | undefined, opts: Regist
29
29
  process.exit(1);
30
30
  }
31
31
 
32
+ // Read project-local overrides (include / exclude / ingestRules / schedule)
33
+ // from package.rig.json5 if present. The user is the authoritative voice for
34
+ // what gets scanned. Falls back to safe defaults only when fields are absent.
35
+ const projectWiki = project ? readProjectWikiBlock(project) : null;
36
+ const wikiBasename = path.basename(wikiPath);
32
37
  const entry: WikiEntry = {
33
38
  name,
34
39
  path: wikiPath,
35
40
  project: project || undefined,
36
- include: ['**/*.md'],
37
- exclude: [`${path.basename(wikiPath)}/**`, 'node_modules/**', '.git/**'],
38
- schedule: { scan: '0 */6 * * *', lint: '0 3 * * *' },
39
- ingestRules: [{ match: 'raw/**/*.md', mode: 'auto-on-new' }],
41
+ include: projectWiki?.include ?? ['**/*.md'],
42
+ exclude: projectWiki?.exclude ?? [`${wikiBasename}/**`, 'node_modules/**', '.git/**'],
43
+ schedule: projectWiki?.schedule ?? { scan: '0 */6 * * *', lint: '0 3 * * *' },
44
+ ingestRules: projectWiki?.ingestRules ?? [{ match: 'raw/**/*.md', mode: 'auto-on-new' }],
40
45
  };
41
46
 
42
47
  if (existing >= 0) cfg.wikis[existing] = entry;
43
48
  else cfg.wikis.push(entry);
44
49
  saveWikiConfig(cfg);
45
50
 
46
- // bidirectional: also write to project's package.rig.json5 if present
47
- if (project) writeProjectWikiBlock(project, name, wikiPath);
51
+ // bidirectional: write back to project's package.rig.json5 preserve any
52
+ // existing include/exclude/ingestRules/schedule fields the user authored.
53
+ if (project) writeProjectWikiBlock(project, name, wikiPath, projectWiki);
48
54
 
49
55
  print.succeed(`registered wiki "${name}" -> ${wikiPath}`);
50
56
  }
51
57
 
58
+ interface ProjectWikiBlock {
59
+ name?: string;
60
+ path?: string;
61
+ include?: string[];
62
+ exclude?: string[];
63
+ schedule?: { scan?: string; lint?: string; ingest?: string | null };
64
+ ingestRules?: { match: string; mode: 'auto-on-new' | 'propose-only' }[];
65
+ }
66
+
67
+ function readProjectWikiBlock(project: string): ProjectWikiBlock | null {
68
+ const file = path.join(project, 'package.rig.json5');
69
+ if (!fs.existsSync(file)) return null;
70
+ try {
71
+ const cfg = JSON5.parse(fs.readFileSync(file, 'utf8'));
72
+ const wiki = cfg && typeof cfg === 'object' && cfg.wiki;
73
+ return wiki && typeof wiki === 'object' ? wiki as ProjectWikiBlock : null;
74
+ } catch { return null; }
75
+ }
76
+
52
77
  function detectWikiPath(start: string): string | undefined {
53
78
  const candidates = ['harness/llm-wiki', 'wiki'];
54
79
  let dir = start;
@@ -83,12 +108,24 @@ function detectName(project: string | undefined, wikiPath: string): string {
83
108
  return path.basename(path.dirname(wikiPath));
84
109
  }
85
110
 
86
- function writeProjectWikiBlock(project: string, name: string, wikiPath: string): void {
111
+ function writeProjectWikiBlock(
112
+ project: string,
113
+ name: string,
114
+ wikiPath: string,
115
+ existingWiki: ProjectWikiBlock | null,
116
+ ): void {
87
117
  const file = path.join(project, 'package.rig.json5');
88
118
  let cfg: Record<string, unknown> = {};
89
119
  if (fs.existsSync(file)) {
90
120
  try { cfg = JSON5.parse(fs.readFileSync(file, 'utf8')); } catch { cfg = {}; }
91
121
  }
92
- cfg.wiki = { name, path: path.relative(project, wikiPath) };
122
+ // Always update name + path (those are derived from invocation). Preserve
123
+ // every other field the user authored (include / exclude / schedule /
124
+ // ingestRules / anything else they put in there).
125
+ cfg.wiki = {
126
+ ...(existingWiki || {}),
127
+ name,
128
+ path: path.relative(project, wikiPath),
129
+ };
93
130
  fs.writeFileSync(file, JSON5.stringify(cfg, null, 2) + '\n', 'utf8');
94
131
  }
package/lib/wiki/scan.ts CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rigjs",
3
- "version": "4.0.2",
4
- "versionCode": 26052409,
3
+ "version": "4.0.3",
4
+ "versionCode": 26052410,
5
5
  "description": "A multi-repos dev tool based on yarn and git.Rigjs is intended to be the simplest way to develop,share and deliver codes between different developers or different projects.",
6
6
  "keywords": [
7
7
  "modular",