@codapult/cli 0.6.1 → 0.7.1
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ProjectEnvOptions } from '../utils/project-env.js';
|
|
2
|
-
|
|
2
|
+
interface PluginsAddCommandOptions extends ProjectEnvOptions {
|
|
3
3
|
from?: string;
|
|
4
4
|
ci?: boolean;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
export declare function pluginsAddCommand(name: string, options?: PluginsAddCommandOptions): Promise<void>;
|
|
6
7
|
export declare function pluginsRemoveCommand(name: string, options?: ProjectEnvOptions): Promise<void>;
|
|
7
8
|
export declare function pluginsMigrateCommand(name: string | undefined, options: {
|
|
8
9
|
push?: boolean;
|
|
9
10
|
}): Promise<void>;
|
|
10
11
|
export declare function pluginsListCommand(): void;
|
|
12
|
+
export {};
|
package/dist/commands/plugins.js
CHANGED
|
@@ -16,9 +16,6 @@ function execQuiet(cmd, cwd) {
|
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// codapult plugins add <name>
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
19
|
export async function pluginsAddCommand(name, options = {}) {
|
|
23
20
|
const root = findProjectRoot();
|
|
24
21
|
if (!root) {
|
|
@@ -43,10 +40,10 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
43
40
|
if (!result) {
|
|
44
41
|
fail(`Plugin "${name}" not found.`);
|
|
45
42
|
dim('Searched for codapult-plugin.json in:');
|
|
43
|
+
dim(` .codapult/plugins/codapult-plugin-${name}/`);
|
|
46
44
|
dim(` ../codapult-plugin-${name}/`);
|
|
47
45
|
dim(` ../codapult-${name}/`);
|
|
48
46
|
dim(` ../${name}/`);
|
|
49
|
-
dim(` .codapult/plugins/codapult-plugin-${name}/`);
|
|
50
47
|
if (!options.from) {
|
|
51
48
|
dim('');
|
|
52
49
|
dim('Tip: use --from <git-url> to install from a remote repository.');
|
|
@@ -159,14 +156,6 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
159
156
|
success(`Environment variables added to ${ENV_FILE_NAME}`);
|
|
160
157
|
}
|
|
161
158
|
}
|
|
162
|
-
if (options.ci) {
|
|
163
|
-
heading('Done!');
|
|
164
|
-
success(`Plugin "${manifest.name}" installed (CI mode).`);
|
|
165
|
-
dim('Skipped: pnpm install, db:push, env patching, optional deps.');
|
|
166
|
-
dim('Run pnpm install separately after this command.');
|
|
167
|
-
console.log();
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
159
|
// 10. pnpm install
|
|
171
160
|
info('Installing dependencies...');
|
|
172
161
|
if (!execQuiet('pnpm install --no-frozen-lockfile', root)) {
|
|
@@ -175,6 +164,14 @@ export async function pluginsAddCommand(name, options = {}) {
|
|
|
175
164
|
else {
|
|
176
165
|
success('Dependencies installed');
|
|
177
166
|
}
|
|
167
|
+
if (options.ci) {
|
|
168
|
+
heading('Done!');
|
|
169
|
+
success(`Plugin "${manifest.name}" installed (CI mode).`);
|
|
170
|
+
dim('Skipped: db:push, env patching, optional deps.');
|
|
171
|
+
dim('Run pnpm install separately after this command.');
|
|
172
|
+
console.log();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
178
175
|
// 11. pnpm db:push
|
|
179
176
|
if (manifest.install.schemaTables) {
|
|
180
177
|
info('Applying database schema...');
|
package/dist/commands/setup.js
CHANGED
|
@@ -153,8 +153,8 @@ const MODULE_REMOVALS = [
|
|
|
153
153
|
`${APP}/admin`,
|
|
154
154
|
`${APP}/invite`,
|
|
155
155
|
'src/app/api/auth',
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
'src/lib/auth/better-auth.ts',
|
|
157
|
+
'src/lib/auth/kinde.ts',
|
|
158
158
|
'src/components/auth',
|
|
159
159
|
'src/components/dashboard',
|
|
160
160
|
'src/components/admin',
|
|
@@ -177,7 +177,8 @@ const MODULE_REMOVALS = [
|
|
|
177
177
|
paths: [
|
|
178
178
|
`${APP}/(marketing)/blog`,
|
|
179
179
|
'src/components/blog',
|
|
180
|
-
|
|
180
|
+
'src/components/seo/BlogPostJsonLd.tsx',
|
|
181
|
+
'src/lib/blog',
|
|
181
182
|
'content/blog',
|
|
182
183
|
'src/app/rss.xml',
|
|
183
184
|
],
|
|
@@ -293,12 +294,12 @@ const MODULE_REMOVALS = [
|
|
|
293
294
|
paths: ['src/lib/event-store', 'src/app/api/admin/events'],
|
|
294
295
|
label: 'Event Store',
|
|
295
296
|
},
|
|
296
|
-
|
|
297
|
+
{ key: 'enableOtel', paths: ['src/lib/telemetry'], label: 'OpenTelemetry' },
|
|
297
298
|
{
|
|
298
299
|
key: 'enableDripCampaigns',
|
|
299
300
|
paths: [
|
|
300
301
|
`${APP}/admin/drip-campaigns`,
|
|
301
|
-
|
|
302
|
+
'src/lib/drip-campaigns',
|
|
302
303
|
'src/app/api/admin/drip-campaigns',
|
|
303
304
|
'src/components/admin/DripCampaignManager.tsx',
|
|
304
305
|
],
|
|
@@ -351,7 +352,7 @@ const MODULE_REMOVALS = [
|
|
|
351
352
|
'src/lib/ai/chunker.ts',
|
|
352
353
|
'src/lib/ai/embeddings.ts',
|
|
353
354
|
'src/lib/ai/vector-store.ts',
|
|
354
|
-
|
|
355
|
+
'src/lib/ai/rag.ts',
|
|
355
356
|
'src/app/api/ai',
|
|
356
357
|
],
|
|
357
358
|
label: 'RAG Pipeline',
|
|
@@ -362,7 +363,7 @@ const MODULE_REMOVALS = [
|
|
|
362
363
|
`${APP}/(dashboard)/dashboard/webhooks`,
|
|
363
364
|
`${APP}/admin/webhooks`,
|
|
364
365
|
'src/app/api/webhooks',
|
|
365
|
-
|
|
366
|
+
'src/lib/outgoing-webhooks',
|
|
366
367
|
'src/lib/webhook-log.ts',
|
|
367
368
|
'src/lib/webhook-log.test.ts',
|
|
368
369
|
'src/components/dashboard/OutgoingWebhooks.tsx',
|
|
@@ -385,7 +386,7 @@ const MODULE_REMOVALS = [
|
|
|
385
386
|
paths: [
|
|
386
387
|
`${APP}/(dashboard)/dashboard/reports`,
|
|
387
388
|
'src/app/api/reports',
|
|
388
|
-
|
|
389
|
+
'src/lib/scheduled-reports',
|
|
389
390
|
'src/components/dashboard/ReportSchedules.tsx',
|
|
390
391
|
],
|
|
391
392
|
label: 'Scheduled Reports',
|
|
@@ -454,6 +455,12 @@ const FEATURE_ENV_VARS = {
|
|
|
454
455
|
enableTwoFactor: 'ENABLE_TWO_FACTOR',
|
|
455
456
|
enablePlugins: 'ENABLE_PLUGINS',
|
|
456
457
|
};
|
|
458
|
+
const PRUNE_MARKER_FILES = [
|
|
459
|
+
'src/app/sitemap.ts',
|
|
460
|
+
'src/lib/auth/index.ts',
|
|
461
|
+
'src/lib/jobs/definitions.ts',
|
|
462
|
+
'src/instrumentation.ts',
|
|
463
|
+
];
|
|
457
464
|
function generateEnvFile(root, config) {
|
|
458
465
|
const envExamplePath = join(root, ENV_EXAMPLE_FILE_NAME);
|
|
459
466
|
const envLocalPath = join(root, ENV_FILE_NAME);
|
|
@@ -517,6 +524,33 @@ function generateMcpConfig(root) {
|
|
|
517
524
|
writeFileSync(mcpPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
518
525
|
success('Created .cursor/mcp.json — Codapult MCP server configured for Cursor');
|
|
519
526
|
}
|
|
527
|
+
function pruneMarkedBlocks(content, disabledKeys) {
|
|
528
|
+
let next = content;
|
|
529
|
+
for (const key of disabledKeys) {
|
|
530
|
+
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
531
|
+
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');
|
|
532
|
+
next = next.replace(pattern, '');
|
|
533
|
+
}
|
|
534
|
+
return next;
|
|
535
|
+
// return next.replace(/\n{3,}/g, '\n\n');
|
|
536
|
+
}
|
|
537
|
+
function pruneMarkedBlocksInFiles(root, config) {
|
|
538
|
+
const disabledKeys = Object.keys(config).filter((key) => key.startsWith('enable') && config[key] === false);
|
|
539
|
+
if (disabledKeys.length === 0)
|
|
540
|
+
return;
|
|
541
|
+
dim(`Pruning files...`);
|
|
542
|
+
for (const relativePath of PRUNE_MARKER_FILES) {
|
|
543
|
+
const fullPath = resolve(root, relativePath);
|
|
544
|
+
if (!existsSync(fullPath))
|
|
545
|
+
continue;
|
|
546
|
+
const original = readFileSync(fullPath, 'utf-8');
|
|
547
|
+
const pruned = pruneMarkedBlocks(original, disabledKeys);
|
|
548
|
+
if (pruned !== original) {
|
|
549
|
+
writeFileSync(fullPath, pruned, 'utf-8');
|
|
550
|
+
dim(` patched ${relativePath}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
520
554
|
function removeModules(root, config) {
|
|
521
555
|
for (const removal of MODULE_REMOVALS) {
|
|
522
556
|
if (config[removal.key])
|
|
@@ -541,6 +575,7 @@ function removeModules(root, config) {
|
|
|
541
575
|
dim(` no matching files found (expected ${missing.length} path(s))`);
|
|
542
576
|
}
|
|
543
577
|
}
|
|
578
|
+
pruneMarkedBlocksInFiles(root, config);
|
|
544
579
|
}
|
|
545
580
|
async function interactiveSetup() {
|
|
546
581
|
const iface = rl();
|
package/dist/utils/manifest.js
CHANGED
|
@@ -24,12 +24,12 @@ export function resolveManifest(projectRoot, nameOrPath) {
|
|
|
24
24
|
candidates.push(resolved);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
// 2.
|
|
28
|
-
const parentDir = resolve(projectRoot, '..');
|
|
29
|
-
candidates.push(join(parentDir, `codapult-plugin-${nameOrPath}`), join(parentDir, `codapult-${nameOrPath}`), join(parentDir, nameOrPath));
|
|
30
|
-
// 3. Local cache (.codapult/plugins/codapult-plugin-<name>, ../<name>)
|
|
27
|
+
// 2. Local cache (.codapult/plugins/codapult-plugin-<name>, ../<name>)
|
|
31
28
|
const cacheDir = join(projectRoot, '.codapult', 'plugins');
|
|
32
29
|
candidates.push(join(cacheDir, `codapult-plugin-${nameOrPath}`), join(cacheDir, `codapult-${nameOrPath}`), join(cacheDir, nameOrPath));
|
|
30
|
+
// 3. Sibling directories (../codapult-plugin-<name>, ../codapult-<name>, ../<name>)
|
|
31
|
+
const parentDir = resolve(projectRoot, '..');
|
|
32
|
+
candidates.push(join(parentDir, `codapult-plugin-${nameOrPath}`), join(parentDir, `codapult-${nameOrPath}`), join(parentDir, nameOrPath));
|
|
33
33
|
for (const dir of candidates) {
|
|
34
34
|
if (!isWithinAllowedScope(dir, projectRoot))
|
|
35
35
|
continue;
|
|
@@ -75,7 +75,7 @@ describe('resolveManifest', () => {
|
|
|
75
75
|
expect(result).not.toBeNull();
|
|
76
76
|
expect(result.pluginDir).toContain('.codapult/plugins/codapult-plugin-cached');
|
|
77
77
|
});
|
|
78
|
-
it('prefers
|
|
78
|
+
it('prefers .codapult/plugins/ cache over sibling directory', () => {
|
|
79
79
|
mockedExists.mockImplementation((p) => {
|
|
80
80
|
const path = p;
|
|
81
81
|
return (path === '/codapult-plugin-both/codapult-plugin.json' ||
|
|
@@ -84,7 +84,7 @@ describe('resolveManifest', () => {
|
|
|
84
84
|
mockedRead.mockReturnValue(validManifest);
|
|
85
85
|
const result = resolveManifest(ROOT, 'both');
|
|
86
86
|
expect(result).not.toBeNull();
|
|
87
|
-
expect(result.pluginDir).toBe('/codapult-plugin-both');
|
|
87
|
+
expect(result.pluginDir).toBe('/project/.codapult/plugins/codapult-plugin-both');
|
|
88
88
|
});
|
|
89
89
|
it('returns null for invalid JSON manifest', () => {
|
|
90
90
|
mockedExists.mockReturnValue(true);
|