komplian 0.7.4 → 0.7.6

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.
@@ -8,6 +8,9 @@
8
8
  *
9
9
  * Bases de datos: primero cada repo `/.env.local`; luego ~/.komplian/dev-databases.json (npx komplian db:all:dev);
10
10
  * opcional en la sesión: KOMPLIAN_LOCALHOST_*_DATABASE_URL (sin archivos secretos en la raíz del monorepo).
11
+ *
12
+ * Logs: con KOMPLIAN_CLI_QUIET=1 se ocultan líneas ruidosas de Next/Sentry (salvo errores).
13
+ * Ver todo: KOMPLIAN_LOCALHOST_VERBOSE_DEV=1 o --verbose-dev. Forzar filtro: KOMPLIAN_LOCALHOST_FILTER_DEV_LOGS=1 o --filter-dev-logs.
11
14
  */
12
15
 
13
16
  import { randomBytes } from "node:crypto";
@@ -16,6 +19,7 @@ import { chmodSync, existsSync, readFileSync, writeFileSync } from "node:fs";
16
19
  import { dirname, join, resolve } from "node:path";
17
20
  import { fileURLToPath } from "node:url";
18
21
  import { createInterface } from "node:readline/promises";
22
+ import { createInterface as createLineReader } from "node:readline";
19
23
  import { stdin as input, stdout as output } from "node:process";
20
24
 
21
25
  import {
@@ -377,27 +381,84 @@ function writeDocsEnv(root, opts) {
377
381
  return { path: p, skipped: false, label: "docs" };
378
382
  }
379
383
 
380
- function printLocalUrls(minimal) {
381
- if (cliQuiet()) {
382
- logAlways(
383
- `${c.dim}dev ·${c.reset} ${!minimal ? "4000 " : ""}3001${!minimal ? " 3002 3003" : " 3003"} 3004`
384
- );
385
- return;
386
- }
387
- log("");
388
- log(`${c.bold}Local${c.reset}`);
384
+ /** One line per service (same spirit as the API boot line). Always printed. */
385
+ function printDevUrlSummary(minimal) {
386
+ const rows = [];
389
387
  if (!minimal) {
390
- log(` ${c.cyan}api${c.reset} http://localhost:4000`);
388
+ rows.push(["Komplian API", "http://localhost:4000"]);
391
389
  }
392
- log(` ${c.cyan}app${c.reset} http://localhost:3001`);
390
+ rows.push(["Dashboard (app)", "http://localhost:3001"]);
393
391
  if (!minimal) {
394
- log(` ${c.cyan}admin${c.reset} http://localhost:3002`);
395
- log(` ${c.cyan}web${c.reset} http://localhost:3003`);
392
+ rows.push(["Admin panel", "http://localhost:3002"]);
393
+ rows.push(["Marketing (web)", "http://localhost:3003"]);
396
394
  } else {
397
- log(` ${c.cyan}web${c.reset} http://localhost:3003`);
395
+ rows.push(["Marketing (web)", "http://localhost:3003"]);
398
396
  }
399
- log(` ${c.cyan}docs${c.reset} http://localhost:3004`);
400
- log("");
397
+ rows.push(["Documentation (docs)", "http://localhost:3004"]);
398
+ logAlways("");
399
+ for (const [name, url] of rows) {
400
+ logAlways(`🚀 ${name} running on ${url}`);
401
+ }
402
+ logAlways("");
403
+ }
404
+
405
+ /**
406
+ * Drop noisy framework lines when stdout/stderr are piped (quiet setup / opt-in).
407
+ * Override: --verbose-dev or KOMPLIAN_LOCALHOST_VERBOSE_DEV=1
408
+ * Force on (non-quiet): --filter-dev-logs or KOMPLIAN_LOCALHOST_FILTER_DEV_LOGS=1
409
+ */
410
+ const DEV_LOG_NOISE_RES = [
411
+ /^\s*>\s+[^\s]+\@[^\s]+\s+dev\s*$/,
412
+ /^\s*>\s+next dev\b/,
413
+ /^\s*>\s+tsx watch\b/,
414
+ /^\s*▲ Next\.js/,
415
+ /^\s*-\s+Local:\s+/,
416
+ /^\s*-\s+Network:\s+/,
417
+ /^\s*-\s+Environments:/,
418
+ /^\s*-\s+Experiments /,
419
+ /^\s*✓ Starting\.\.\.\s*$/,
420
+ /^\s*✓ Ready in \d/,
421
+ /^\s*○ Compiling /,
422
+ /^\s*✓ Compiled /,
423
+ /\[@sentry\/nextjs\]/,
424
+ /DEPRECATION WARNING/,
425
+ /\[EmailStore\] No DB connection/,
426
+ /No SENTRY_DSN configured/,
427
+ /^\s*Routes:\s*$/,
428
+ /^\s*[│├└]/,
429
+ /^\s*🚀 Komplian API running on http:\/\/localhost/,
430
+ /^\s*Environment:\s+development\s*$/,
431
+ /^\s*Health check:\s+http/,
432
+ ];
433
+
434
+ function shouldDropDevLogLine(line) {
435
+ const s = String(line);
436
+ if (
437
+ /npm ERR!|ERR!|EADDRINUSE| ⨯ |^Error:\s|Unhandled|FATAL|ECONNREFUSED/i.test(
438
+ s
439
+ )
440
+ ) {
441
+ return false;
442
+ }
443
+ return DEV_LOG_NOISE_RES.some((re) => re.test(s));
444
+ }
445
+
446
+ function wantFilterDevLogs(opts) {
447
+ if (opts.verboseDev || process.env.KOMPLIAN_LOCALHOST_VERBOSE_DEV === "1") {
448
+ return false;
449
+ }
450
+ if (opts.filterDevLogs || process.env.KOMPLIAN_LOCALHOST_FILTER_DEV_LOGS === "1") {
451
+ return true;
452
+ }
453
+ return cliQuiet();
454
+ }
455
+
456
+ function attachFilteredChildStream(stream, writeLine) {
457
+ if (!stream) return;
458
+ const rl = createLineReader({ input: stream, crlfDelay: Infinity });
459
+ rl.on("line", (line) => {
460
+ if (!shouldDropDevLogLine(line)) writeLine(line);
461
+ });
401
462
  }
402
463
 
403
464
  async function confirmOverwrite(yes) {
@@ -418,6 +479,8 @@ function parseLocalhostArgs(argv) {
418
479
  workspace: "",
419
480
  minimal: false,
420
481
  help: false,
482
+ verboseDev: false,
483
+ filterDevLogs: false,
421
484
  };
422
485
  const rest = [];
423
486
  for (let i = 0; i < argv.length; i++) {
@@ -426,6 +489,8 @@ function parseLocalhostArgs(argv) {
426
489
  else if (a === "--force") opts.force = true;
427
490
  else if (a === "--env-only") opts.envOnly = true;
428
491
  else if (a === "--minimal") opts.minimal = true;
492
+ else if (a === "--verbose-dev") opts.verboseDev = true;
493
+ else if (a === "--filter-dev-logs") opts.filterDevLogs = true;
429
494
  else if (a === "-h" || a === "--help") opts.help = true;
430
495
  else if (a === "--workspace" || a === "-w") opts.workspace = argv[++i] || "";
431
496
  else if (a.startsWith("-")) {
@@ -447,6 +512,8 @@ function usageLocalhost() {
447
512
  logAlways(` --force Regenerate .env.local`);
448
513
  logAlways(` --minimal app + web + docs only`);
449
514
  logAlways(` --env-only Write .env.local only`);
515
+ logAlways(` --verbose-dev Full dev server logs (when filter is on)`);
516
+ logAlways(` --filter-dev-logs Hide noisy Next/Sentry lines (default with KOMPLIAN_CLI_QUIET)`);
450
517
  logAlways(` -w, --workspace Monorepo root`);
451
518
  logAlways(` -h, --help`);
452
519
  }
@@ -532,7 +599,7 @@ export async function runLocalhost(argv) {
532
599
  }
533
600
  }
534
601
 
535
- printLocalUrls(opts.minimal);
602
+ printDevUrlSummary(opts.minimal);
536
603
 
537
604
  if (!db.hasReal && !opts.minimal) {
538
605
  logAlways(
@@ -567,30 +634,44 @@ export async function runLocalhost(argv) {
567
634
  return `npm run dev --prefix ${dir}`;
568
635
  });
569
636
 
637
+ const filterLogs = wantFilterDevLogs(opts);
570
638
  if (cliQuiet()) {
571
- logAlways(`${c.dim}dev servers · Ctrl+C stop${c.reset}`);
639
+ logAlways(
640
+ `${c.dim}${filterLogs ? "Starting dev servers (noisy lines hidden) · " : ""}Ctrl+C stop${c.reset}`
641
+ );
572
642
  } else {
573
- log(`${c.cyan}━━ dev servers (${services.length}) ━━${c.reset} ${c.dim}Ctrl+C stop${c.reset}`);
643
+ log(
644
+ `${c.cyan}━━ dev servers (${services.length}) ━━${c.reset} ${c.dim}Ctrl+C stop${filterLogs ? " · filtered logs" : ""}${c.reset}`
645
+ );
574
646
  log("");
575
647
  }
576
648
 
577
649
  const npx = process.platform === "win32" ? "npx.cmd" : "npx";
578
650
  const useShell = process.platform === "win32";
579
- /** --raw avoids concurrently prefix logger bugs (e.g. prev.replace on Windows / npx). */
580
- const concArgs = cliQuiet()
651
+ /**
652
+ * --raw avoids concurrently prefix logger bugs: TypeError prev.replace is not a function
653
+ * in Logger.getPrefixContent (Windows + npx.cmd/shell, and some npx arg splits).
654
+ */
655
+ const useRaw = cliQuiet() || process.platform === "win32";
656
+ const concArgs = useRaw
581
657
  ? ["--yes", "concurrently@9", "--raw", ...scripts]
582
658
  : ["--yes", "concurrently@9", "-c", colors, "-n", names, ...scripts];
583
- const child = spawn(
584
- npx,
585
- concArgs,
586
- {
587
- cwd: workspaceRoot,
588
- stdio: "inherit",
589
- shell: useShell,
590
- windowsHide: true,
591
- env: { ...process.env },
592
- }
593
- );
659
+ const childEnv = {
660
+ ...process.env,
661
+ NEXT_TELEMETRY_DISABLED: process.env.NEXT_TELEMETRY_DISABLED || "1",
662
+ };
663
+ const child = spawn(npx, concArgs, {
664
+ cwd: workspaceRoot,
665
+ stdio: filterLogs ? ["inherit", "pipe", "pipe"] : "inherit",
666
+ shell: useShell,
667
+ windowsHide: true,
668
+ env: childEnv,
669
+ });
670
+
671
+ if (filterLogs) {
672
+ attachFilteredChildStream(child.stdout, (line) => console.log(line));
673
+ attachFilteredChildStream(child.stderr, (line) => console.error(line));
674
+ }
594
675
 
595
676
  const killAll = () => {
596
677
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "komplian",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "Komplian CLI: setup (all-in-one), onboard, Postman, localhost, mcp-tools, db (psql). Node 18+.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -24,7 +24,8 @@
24
24
  "access": "public"
25
25
  },
26
26
  "scripts": {
27
- "prepublishOnly": "node --check komplian-onboard.mjs && node --check komplian-setup.mjs && node --check komplian-postman.mjs && node --check komplian-localhost.mjs && node --check komplian-mcp-tools.mjs && node --check komplian-db.mjs && node --check komplian-db-all-dev.mjs"
27
+ "prepublishOnly": "node check-publish-version.mjs && node --check komplian-onboard.mjs && node --check komplian-setup.mjs && node --check komplian-postman.mjs && node --check komplian-localhost.mjs && node --check komplian-mcp-tools.mjs && node --check komplian-db.mjs && node --check komplian-db-all-dev.mjs",
28
+ "release": "npm version patch --no-git-tag-version && npm publish --access public"
28
29
  },
29
30
  "keywords": [
30
31
  "komplian",