archbyte 0.4.0 → 0.4.2

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.
@@ -259,6 +259,67 @@ export function parseCustomRulesFromYaml(content) {
259
259
  flushItem();
260
260
  return rules;
261
261
  }
262
+ /**
263
+ * Parse the patrol.ignore list from archbyte.yaml.
264
+ * Returns user-defined glob patterns for watch mode to ignore.
265
+ *
266
+ * patrol:
267
+ * ignore:
268
+ * - "docs/"
269
+ * - "*.md"
270
+ * - "build/"
271
+ */
272
+ export function loadPatrolIgnore(configPath) {
273
+ const rootDir = process.cwd();
274
+ const yamlPath = configPath
275
+ ? path.resolve(rootDir, configPath)
276
+ : path.join(rootDir, ".archbyte", "archbyte.yaml");
277
+ if (!fs.existsSync(yamlPath))
278
+ return [];
279
+ try {
280
+ const lines = fs.readFileSync(yamlPath, "utf-8").split("\n");
281
+ const patterns = [];
282
+ let inPatrol = false;
283
+ let inIgnore = false;
284
+ for (const line of lines) {
285
+ const trimmed = line.trimEnd();
286
+ if (/^patrol:\s*$/.test(trimmed)) {
287
+ inPatrol = true;
288
+ continue;
289
+ }
290
+ // Another top-level section ends patrol
291
+ if (inPatrol && /^\S/.test(trimmed) && !trimmed.startsWith("#")) {
292
+ inPatrol = false;
293
+ inIgnore = false;
294
+ continue;
295
+ }
296
+ if (!inPatrol)
297
+ continue;
298
+ if (trimmed === "" || trimmed.trim().startsWith("#"))
299
+ continue;
300
+ if (/^ {2}ignore:\s*$/.test(trimmed)) {
301
+ inIgnore = true;
302
+ continue;
303
+ }
304
+ // Another patrol sub-key ends ignore
305
+ if (inIgnore && /^ {2}\S/.test(trimmed) && !/^ {2}ignore:/.test(trimmed)) {
306
+ inIgnore = false;
307
+ continue;
308
+ }
309
+ if (!inIgnore)
310
+ continue;
311
+ // List item: " - pattern"
312
+ const itemMatch = trimmed.match(/^ {4}-\s+"?([^"]+)"?\s*$/);
313
+ if (itemMatch) {
314
+ patterns.push(itemMatch[1].trim());
315
+ }
316
+ }
317
+ return patterns;
318
+ }
319
+ catch {
320
+ return [];
321
+ }
322
+ }
262
323
  export function getRuleLevel(config, rule, defaultLevel) {
263
324
  const entry = config[rule];
264
325
  if (!entry)
@@ -4,7 +4,6 @@ interface ValidateOptions {
4
4
  diagram?: string;
5
5
  config?: string;
6
6
  ci?: boolean;
7
- watch?: boolean;
8
7
  }
9
8
  export interface Violation {
10
9
  rule: string;
@@ -202,22 +202,6 @@ export async function handleValidate(options) {
202
202
  }
203
203
  // Human-readable output
204
204
  printValidationReport(result);
205
- // Watch mode: re-validate on file changes
206
- if (options.watch) {
207
- const chokidar = await import("chokidar");
208
- const diagramPath = resolveArchitecturePath(options);
209
- console.log(chalk.gray(` Watching ${diagramPath} for changes...`));
210
- console.log(chalk.gray(" Press Ctrl+C to stop."));
211
- const watcher = chokidar.watch(diagramPath, { ignoreInitial: true });
212
- watcher.on("change", () => {
213
- console.clear();
214
- const watchResult = runValidation(options);
215
- printValidationReport(watchResult);
216
- console.log(chalk.gray(` Watching ${diagramPath} for changes...`));
217
- console.log(chalk.gray(" Press Ctrl+C to stop."));
218
- });
219
- return;
220
- }
221
205
  if (result.errors > 0) {
222
206
  process.exit(1);
223
207
  }