@codapult/cli 0.10.3 → 0.12.0

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.
@@ -11,7 +11,7 @@ async function selectPrompt(iface, question, options) {
11
11
  const idx = parseInt(answer, 10) - 1;
12
12
  return options[Math.max(0, Math.min(idx, options.length - 1))];
13
13
  }
14
- function line() {
14
+ function emptyLine() {
15
15
  console.log();
16
16
  return true;
17
17
  }
@@ -167,7 +167,12 @@ const MODULE_REMOVALS = [
167
167
  },
168
168
  {
169
169
  key: 'enableAI',
170
- paths: [`${APP}/(dashboard)/dashboard/ai-chat`, 'src/app/api/chat', 'src/components/ai'],
170
+ paths: [
171
+ `${APP}/(dashboard)/dashboard/ai-chat`,
172
+ 'src/app/api/chat',
173
+ 'src/components/ai',
174
+ 'src/lib/ai',
175
+ ],
171
176
  label: 'AI Chat',
172
177
  },
173
178
  {
@@ -181,7 +186,9 @@ const MODULE_REMOVALS = [
181
186
  'src/lib/rss.test.ts',
182
187
  'content/blog',
183
188
  'src/app/rss.xml',
184
- 'src/app/[locale]/rss.xml',
189
+ 'src/app/(marketing)/rss.xml',
190
+ `${APP}/(marketing)/rss.xml`,
191
+ `${APP}/rss.xml`,
185
192
  ],
186
193
  label: 'Blog',
187
194
  },
@@ -247,6 +254,7 @@ const MODULE_REMOVALS = [
247
254
  `${APP}/(marketing)/docs`,
248
255
  'src/lib/docs',
249
256
  'src/components/docs/HelpDocSearch.tsx',
257
+ 'src/components/seo/DocArticleJsonLd.tsx',
250
258
  'content/docs',
251
259
  ],
252
260
  label: 'Documentation',
@@ -294,6 +302,7 @@ const MODULE_REMOVALS = [
294
302
  paths: [
295
303
  `${APP}/(dashboard)/dashboard/connect`,
296
304
  'src/lib/payments/connect.ts',
305
+ 'src/lib/payments/connect.test.ts',
297
306
  'src/app/api/connect',
298
307
  'src/components/dashboard/ConnectDashboard.tsx',
299
308
  ],
@@ -360,6 +369,7 @@ const MODULE_REMOVALS = [
360
369
  key: 'enableRAG',
361
370
  paths: [
362
371
  'src/lib/ai/chunker.ts',
372
+ 'src/lib/ai/chunker.test.ts',
363
373
  'src/lib/ai/embeddings.ts',
364
374
  'src/lib/ai/vector-store.ts',
365
375
  'src/lib/ai/rag.ts',
@@ -425,11 +435,11 @@ const MODULE_REMOVALS = [
425
435
  paths: [
426
436
  `${APP}/(marketing)/plugins`,
427
437
  `${APP}/(dashboard)/dashboard/plugins`,
428
- 'src/app/api/plugins',
429
- 'src/lib/plugins',
438
+ 'src/lib/plugins/marketplace.ts',
430
439
  'src/components/marketing/PluginsShowcase.tsx',
431
440
  'src/components/marketing/PluginDetail.tsx',
432
441
  'src/components/dashboard/PluginMarketplace.tsx',
442
+ 'plugins/example-analytics',
433
443
  ],
434
444
  label: 'Plugin Marketplace',
435
445
  },
@@ -467,14 +477,21 @@ const FEATURE_ENV_VARS = {
467
477
  enablePlugins: 'ENABLE_PLUGINS',
468
478
  };
469
479
  // codapult:prune:start {key}
480
+ // codapult:prune:replace
470
481
  // codapult:prune:end {key}
471
482
  const PRUNE_MARKER_FILES = [
472
483
  'src/app/sitemap.ts',
473
484
  'src/app/sitemap.test.ts',
485
+ 'src/app/(marketing)/llms.txt/route.ts',
486
+ 'src/components/marketing/Footer.tsx',
474
487
  'src/lib/auth/index.ts',
475
488
  'src/lib/auth/client-adapter.ts',
476
489
  'src/lib/jobs/definitions.ts',
490
+ 'src/lib/actions/admin.ts',
491
+ 'src/lib/actions/impersonation.ts',
492
+ 'src/lib/scheduled-reports/index.ts',
477
493
  'src/config/marketing.test.ts',
494
+ 'src/config/app.ts',
478
495
  'src/instrumentation.ts',
479
496
  ];
480
497
  function generateEnvFile(root, config) {
@@ -540,14 +557,61 @@ function generateMcpConfig(root) {
540
557
  success('Created .cursor/mcp.json — Codapult MCP server configured for Cursor');
541
558
  }
542
559
  function pruneMarkedBlocks(content, disabledKeys) {
543
- let next = content;
544
- for (const key of disabledKeys) {
545
- const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
546
- const pattern = new RegExp(`^[ \\t]*\\/\\/\\s*codapult:prune:start\\s+${escapedKey}\\s*\\n[\\s\\S]*?^[ \\t]*\\/\\/\\s*codapult:prune:end\\s+${escapedKey}[ \\t]*\\n?`, 'gm');
547
- next = next.replace(pattern, '');
560
+ const keySet = new Set(disabledKeys.map(String));
561
+ const lines = content.split('\n');
562
+ const out = [];
563
+ const startRe = /^[ \t]*\/\/\s*codapult:prune:start\s+(\S+)\s*$/;
564
+ const replaceRe = /^[ \t]*\/\/\s*codapult:prune:replace\s*$/;
565
+ const endRe = /^[ \t]*\/\/\s*codapult:prune:end\s+(\S+)[ \t]*$/;
566
+ const commentRe = /^([ \t]*)\/\/ ?(.*)$/;
567
+ // Ищет ближайший terminator (replace или end с нужным key) начиная с индекса i.
568
+ // Бросает при вложенном start того же формата. Возвращает индекс ПОСЛЕ terminator-строки.
569
+ const seekTo = (i, key) => {
570
+ for (let j = i; j < lines.length; j += 1) {
571
+ if (replaceRe.test(lines[j]))
572
+ return { i: j + 1, kind: 'replace' };
573
+ const end = endRe.exec(lines[j]);
574
+ if (end?.[1] === key)
575
+ return { i: j + 1, kind: 'end' };
576
+ if (startRe.test(lines[j])) {
577
+ throw new Error(`Nested "codapult:prune:start" before closing "${key}" (line ${j + 1}).`);
578
+ }
579
+ }
580
+ throw new Error(`Unclosed "codapult:prune:start ${key}" — no matching end found.`);
581
+ };
582
+ for (let i = 0; i < lines.length;) {
583
+ const start = startRe.exec(lines[i]);
584
+ if (!start || !keySet.has(start[1])) {
585
+ out.push(lines[i]);
586
+ i += 1;
587
+ continue;
588
+ }
589
+ const key = start[1];
590
+ const body = seekTo(i + 1, key);
591
+ if (body.kind === 'end') {
592
+ i = body.i; // тело отбрасываем целиком
593
+ continue;
594
+ }
595
+ // body.kind === 'replace': строки от body.i до end — это закомментированный replacement
596
+ const replEnd = seekTo(body.i, key);
597
+ if (replEnd.kind !== 'end') {
598
+ throw new Error(`Expected "end" after "replace" for key "${key}".`);
599
+ }
600
+ for (let r = body.i; r < replEnd.i - 1; r++) {
601
+ const line = lines[r];
602
+ if (line.trim() === '') {
603
+ out.push('');
604
+ continue;
605
+ }
606
+ const m = commentRe.exec(line);
607
+ if (!m) {
608
+ throw new Error(`Line ${r + 1} in "replace" section for "${key}" is not commented out: ${JSON.stringify(line)}`);
609
+ }
610
+ out.push(m[1] + m[2]);
611
+ }
612
+ i = replEnd.i;
548
613
  }
549
- return next;
550
- // return next.replace(/\n{3,}/g, '\n\n');
614
+ return out.join('\n');
551
615
  }
552
616
  function pruneMarkedBlocksInFiles(root, config) {
553
617
  const disabledKeys = Object.keys(config).filter((key) => key.startsWith('enable') && config[key] === false);
@@ -567,6 +631,7 @@ function pruneMarkedBlocksInFiles(root, config) {
567
631
  }
568
632
  }
569
633
  function removeModules(root, config) {
634
+ let totalRemoved = 0;
570
635
  for (const removal of MODULE_REMOVALS) {
571
636
  if (config[removal.key])
572
637
  continue;
@@ -584,6 +649,7 @@ function removeModules(root, config) {
584
649
  missing.push(p);
585
650
  }
586
651
  }
652
+ totalRemoved += removed;
587
653
  // Surface stale paths so removals don't silently no-op when the host
588
654
  // project's file layout changes (e.g. moving routes under [locale]).
589
655
  if (removed === 0 && missing.length > 0) {
@@ -591,6 +657,9 @@ function removeModules(root, config) {
591
657
  }
592
658
  }
593
659
  pruneMarkedBlocksInFiles(root, config);
660
+ if (totalRemoved > 0) {
661
+ dim(`Total removed: ${totalRemoved}`);
662
+ }
594
663
  }
595
664
  async function interactiveSetup() {
596
665
  const iface = createInterface({ input: process.stdin, output: process.stdout });
@@ -615,7 +684,7 @@ async function interactiveSetup() {
615
684
  'bullmq',
616
685
  ]),
617
686
  enableAuth: authEnabled,
618
- enableAI: line() && (await confirm(iface, 'Enable AI Chat module?')),
687
+ enableAI: emptyLine() && (await confirm(iface, 'Enable AI Chat module?')),
619
688
  enableBlog: await confirm(iface, 'Enable Blog module?'),
620
689
  enableTeams: authEnabled && (await confirm(iface, 'Enable Teams/Organizations?')),
621
690
  enableWaitlist: await confirm(iface, 'Enable Waitlist page?'),
@@ -642,7 +711,7 @@ async function interactiveSetup() {
642
711
  enableBranding: authEnabled && (await confirm(iface, 'Enable per-org branding (white-label)?')),
643
712
  enableTwoFactor: authEnabled && (await confirm(iface, 'Enable two-factor authentication (TOTP)?')),
644
713
  enablePlugins: await confirm(iface, 'Enable plugin marketplace (/plugins)?'),
645
- removeUnusedCode: line() && (await confirm(iface, 'Remove unused module code?', false)),
714
+ removeUnusedCode: emptyLine() && (await confirm(iface, 'Remove unused module code?', false)),
646
715
  };
647
716
  iface.close();
648
717
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codapult/cli",
3
- "version": "0.10.3",
3
+ "version": "0.12.0",
4
4
  "description": "Codapult CLI — manage, update, and diagnose your Codapult SaaS project",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@11.6.0",