@codapult/cli 0.23.2 → 0.23.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.
- package/dist/commands/env.js +3 -28
- package/dist/commands/plugins.js +7 -14
- package/dist/commands/setup.js +36 -13
- package/dist/mcp/tools/env.d.ts +0 -7
- package/dist/mcp/tools/env.js +7 -30
- package/dist/mcp/tools/plugins.js +2 -7
- package/dist/utils/plugin-workflows.d.ts +7 -0
- package/dist/utils/plugin-workflows.js +14 -0
- package/dist/utils/project-env.d.ts +7 -0
- package/dist/utils/project-env.js +24 -0
- package/package.json +1 -1
package/dist/commands/env.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { checkProjectRoot } from '../utils/project.js';
|
|
4
|
-
import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, getProjectEnvSource, loadProjectEnv, } from '../utils/project-env.js';
|
|
4
|
+
import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, getProjectEnvSource, loadProjectEnv, parseEnvFile, } from '../utils/project-env.js';
|
|
5
5
|
import { heading, success, fail, info, dim, warn, confirm } from '../utils/ui.js';
|
|
6
6
|
import { renderStructuredReport, summarizeChecks } from '../utils/check-report.js';
|
|
7
|
-
function parseEnvFile(content) {
|
|
8
|
-
const entries = [];
|
|
9
|
-
let lastComment = '';
|
|
10
|
-
for (const line of content.split('\n')) {
|
|
11
|
-
const trimmed = line.trim();
|
|
12
|
-
if (trimmed.startsWith('#') && !trimmed.startsWith('# ---') && !trimmed.startsWith('# ===')) {
|
|
13
|
-
lastComment = trimmed.slice(1).trim();
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
const match = /^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?\s*$/.exec(trimmed);
|
|
17
|
-
if (match) {
|
|
18
|
-
entries.push({
|
|
19
|
-
key: match[1],
|
|
20
|
-
value: match[2],
|
|
21
|
-
comment: lastComment || undefined,
|
|
22
|
-
required: !line.startsWith('#'),
|
|
23
|
-
});
|
|
24
|
-
lastComment = '';
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
lastComment = '';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return entries;
|
|
31
|
-
}
|
|
32
7
|
// ---------------------------------------------------------------------------
|
|
33
8
|
// codapult env check
|
|
34
9
|
// ---------------------------------------------------------------------------
|
|
@@ -47,7 +22,7 @@ export function envCheckCommand(options = {}) {
|
|
|
47
22
|
}
|
|
48
23
|
const exampleEntries = parseEnvFile(readFileSync(examplePath, 'utf-8'));
|
|
49
24
|
const localContent = env.content;
|
|
50
|
-
const localEntries = parseEnvFile(localContent);
|
|
25
|
+
const localEntries = parseEnvFile(localContent).filter((entry) => entry.required);
|
|
51
26
|
const localKeys = new Set(localEntries.map((e) => e.key));
|
|
52
27
|
const requiredKeys = exampleEntries.filter((e) => e.required);
|
|
53
28
|
const checks = [];
|
|
@@ -120,7 +95,7 @@ export async function envSyncCommand(options = {}) {
|
|
|
120
95
|
}
|
|
121
96
|
const exampleEntries = parseEnvFile(readFileSync(examplePath, 'utf-8'));
|
|
122
97
|
const localContent = readFileSync(localPath, 'utf-8');
|
|
123
|
-
const localEntries = parseEnvFile(localContent);
|
|
98
|
+
const localEntries = parseEnvFile(localContent).filter((entry) => entry.required);
|
|
124
99
|
const localKeys = new Set(localEntries.map((e) => e.key));
|
|
125
100
|
const newEntries = exampleEntries.filter((e) => e.required && !localKeys.has(e.key));
|
|
126
101
|
if (newEntries.length === 0) {
|
package/dist/commands/plugins.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ENV_FILE_NAME, getProjectEnvSource, } from '../utils/project-env.js';
|
|
|
6
6
|
import { getPluginCompatibilityIssues, resolveManifest } from '../utils/manifest.js';
|
|
7
7
|
import { clonePlugin } from '../utils/git.js';
|
|
8
8
|
import { patchSchemaImports, patchSchemaImportsPg, patchSchemaTables, patchSchemaTablesPg, patchDbReExports, patchNextConfig, createPluginRegistration, patchPages, findPageConflicts, patchEnvFile, patchPackageJson, } from '../utils/patchers.js';
|
|
9
|
+
import { updatePluginSchemaTables } from '../utils/plugin-workflows.js';
|
|
9
10
|
import { heading, success, fail, warn, info, dim, confirm } from '../utils/ui.js';
|
|
10
11
|
function execQuiet(args, cwd) {
|
|
11
12
|
try {
|
|
@@ -346,20 +347,12 @@ export async function pluginsMigrateCommand(name, options) {
|
|
|
346
347
|
dim(`${manifest.name}: no schema tables — skipping.`);
|
|
347
348
|
continue;
|
|
348
349
|
}
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
if (manifest.install.schemaTablesPg) {
|
|
357
|
-
const postgresUpdated = patchSchemaTablesPg(root, manifest.name, pluginDir, manifest.install.schemaTablesPg, 'update');
|
|
358
|
-
if (postgresUpdated)
|
|
359
|
-
success(`${manifest.name}: schema updated in schema-pg.ts`);
|
|
360
|
-
updated ||= postgresUpdated;
|
|
361
|
-
}
|
|
362
|
-
if (updated) {
|
|
350
|
+
const schemaUpdate = updatePluginSchemaTables(root, manifest, pluginDir);
|
|
351
|
+
if (schemaUpdate.sqliteUpdated)
|
|
352
|
+
success(`${manifest.name}: schema updated in schema.ts`);
|
|
353
|
+
if (schemaUpdate.postgresUpdated)
|
|
354
|
+
success(`${manifest.name}: schema updated in schema-pg.ts`);
|
|
355
|
+
if (schemaUpdate.updated) {
|
|
363
356
|
schemaUpdated = true;
|
|
364
357
|
}
|
|
365
358
|
else {
|
package/dist/commands/setup.js
CHANGED
|
@@ -262,6 +262,8 @@ const MODULE_REMOVALS = [
|
|
|
262
262
|
'src/components/dashboard',
|
|
263
263
|
'src/components/admin',
|
|
264
264
|
'src/app/api/admin',
|
|
265
|
+
'src/lib/jobs/contracts.ts',
|
|
266
|
+
'src/lib/perf/thresholds.ts',
|
|
265
267
|
'src/lib/actions/admin.ts',
|
|
266
268
|
'src/lib/actions/admin.test.ts',
|
|
267
269
|
'src/lib/actions/impersonation.ts',
|
|
@@ -298,7 +300,6 @@ const MODULE_REMOVALS = [
|
|
|
298
300
|
'src/lib/ai/embeddings',
|
|
299
301
|
'src/lib/ai/vector-store',
|
|
300
302
|
'src/lib/ai/rag.ts',
|
|
301
|
-
'src/lib/ai/rag.test.ts',
|
|
302
303
|
'src/app/api/ai/index',
|
|
303
304
|
'src/app/api/ai/search',
|
|
304
305
|
],
|
|
@@ -311,7 +312,7 @@ const MODULE_REMOVALS = [
|
|
|
311
312
|
'src/components/ai/AgentBuilder.tsx',
|
|
312
313
|
'src/components/ai/AgentSelector.tsx',
|
|
313
314
|
'src/lib/ai/tools/agent-runner.ts',
|
|
314
|
-
'src/lib/ai/tools
|
|
315
|
+
'src/lib/ai/tests/tools-agents.integration.test.ts',
|
|
315
316
|
'src/hooks/ai/useAgents.ts',
|
|
316
317
|
],
|
|
317
318
|
label: 'AI Agents',
|
|
@@ -322,6 +323,8 @@ const MODULE_REMOVALS = [
|
|
|
322
323
|
`${APP}/(protected)/(dashboard)/dashboard/ai/batch`,
|
|
323
324
|
'src/components/ai/BatchJobManager.tsx',
|
|
324
325
|
'src/lib/ai/batch',
|
|
326
|
+
'src/lib/ai/tests/batch-playground.integration.test.ts',
|
|
327
|
+
'src/hooks/ai/useBatchJobs.ts',
|
|
325
328
|
],
|
|
326
329
|
label: 'AI Batch',
|
|
327
330
|
},
|
|
@@ -331,7 +334,9 @@ const MODULE_REMOVALS = [
|
|
|
331
334
|
`${APP}/(protected)/(dashboard)/dashboard/ai/playground`,
|
|
332
335
|
'src/components/ai/AIPlayground.tsx',
|
|
333
336
|
'src/components/ai/PlaygroundComparison.tsx',
|
|
337
|
+
'src/hooks/ai/usePlayground.ts',
|
|
334
338
|
'src/lib/ai/playground',
|
|
339
|
+
'src/lib/ai/tests/batch-playground.integration.test.ts',
|
|
335
340
|
],
|
|
336
341
|
label: 'AI Playground',
|
|
337
342
|
},
|
|
@@ -347,7 +352,6 @@ const MODULE_REMOVALS = [
|
|
|
347
352
|
'src/lib/rss.test.ts',
|
|
348
353
|
'src/app/(marketing)/rss.xml',
|
|
349
354
|
`${APP}/(public)/(marketing)/rss.xml`,
|
|
350
|
-
`${APP}/rss.xml`,
|
|
351
355
|
],
|
|
352
356
|
label: 'Blog',
|
|
353
357
|
},
|
|
@@ -359,6 +363,9 @@ const MODULE_REMOVALS = [
|
|
|
359
363
|
'src/components/dashboard/TeamSwitcher.tsx',
|
|
360
364
|
'src/components/dashboard/TeamSettings.tsx',
|
|
361
365
|
'src/components/dashboard/AcceptInvitationButton.tsx',
|
|
366
|
+
'src/components/dashboard/OrganizationAvatar.tsx',
|
|
367
|
+
'src/components/dashboard/useActiveWorkspace.ts',
|
|
368
|
+
'src/components/dashboard/overview/DashboardWorkspaceChooser.tsx',
|
|
362
369
|
'src/lib/db/organizations.ts',
|
|
363
370
|
'src/lib/actions/organizations.ts',
|
|
364
371
|
'src/lib/actions/organizations.test.ts',
|
|
@@ -505,6 +512,7 @@ const MODULE_REMOVALS = [
|
|
|
505
512
|
'src/lib/workflows',
|
|
506
513
|
'src/app/api/workflows',
|
|
507
514
|
'src/components/dashboard/WorkflowBuilder.tsx',
|
|
515
|
+
'src/components/dashboard/overview/DashboardRecentRunsCard.tsx',
|
|
508
516
|
],
|
|
509
517
|
label: 'Workflow Automation',
|
|
510
518
|
},
|
|
@@ -514,7 +522,6 @@ const MODULE_REMOVALS = [
|
|
|
514
522
|
`${APP}/(protected)/(admin)/admin/promotions`,
|
|
515
523
|
'src/components/admin/PromotionDurationFields.tsx',
|
|
516
524
|
'src/lib/actions/promotions.ts',
|
|
517
|
-
'src/lib/actions/promotions.test.ts',
|
|
518
525
|
],
|
|
519
526
|
label: 'Promotions',
|
|
520
527
|
},
|
|
@@ -538,7 +545,7 @@ const MODULE_REMOVALS = [
|
|
|
538
545
|
'src/lib/promotions',
|
|
539
546
|
'src/lib/payments/promotion-checkout.ts',
|
|
540
547
|
'src/lib/payments/promotion-webhook.ts',
|
|
541
|
-
'src/lib/payments/
|
|
548
|
+
'src/lib/payments/payment-webhook-data.ts',
|
|
542
549
|
],
|
|
543
550
|
label: 'Promotions & Referral Program',
|
|
544
551
|
},
|
|
@@ -571,6 +578,7 @@ const MODULE_REMOVALS = [
|
|
|
571
578
|
'src/app/api/audit-log',
|
|
572
579
|
'src/lib/activity-log.ts',
|
|
573
580
|
'src/components/dashboard/AuditLog.tsx',
|
|
581
|
+
'src/components/admin/AdminRecentActivityCard.tsx',
|
|
574
582
|
],
|
|
575
583
|
label: 'Audit Log',
|
|
576
584
|
},
|
|
@@ -697,21 +705,27 @@ const PRUNE_MARKER_FILES = [
|
|
|
697
705
|
'src/components/MdxContent.tsx',
|
|
698
706
|
'src/components/dashboard/sidebar/Sidebar.tsx',
|
|
699
707
|
'src/components/dashboard/sidebar/SidebarContent.tsx',
|
|
708
|
+
'src/components/dashboard/overview/DashboardOverviewStats.tsx',
|
|
709
|
+
'src/components/dashboard/overview/DashboardOverviewCharts.tsx',
|
|
710
|
+
'src/components/admin/AdminGrowthChart.tsx',
|
|
700
711
|
'src/components/ai/ChatUI.tsx',
|
|
701
712
|
'src/components/ai/index.ts',
|
|
702
713
|
'src/proxy.ts',
|
|
703
714
|
'src/proxy.test.ts',
|
|
715
|
+
'src/lib/proxy/paths.ts',
|
|
704
716
|
`${APP}/(public)/layout.tsx`,
|
|
705
717
|
`${APP}/(public)/(auth)/layout.tsx`,
|
|
706
718
|
`${APP}/(public)/(auth)/sign-in/page.tsx`,
|
|
707
719
|
`${APP}/(public)/(auth)/sign-up/page.tsx`,
|
|
708
720
|
`${APP}/(public)/(marketing)/page.tsx`,
|
|
709
721
|
`${APP}/(protected)/(dashboard)/layout.tsx`,
|
|
722
|
+
`${APP}/(protected)/(dashboard)/dashboard/page.tsx`,
|
|
710
723
|
`${APP}/(protected)/(dashboard)/dashboard/analytics/page.tsx`,
|
|
711
724
|
`${APP}/(protected)/(dashboard)/dashboard/billing/page.tsx`,
|
|
712
725
|
`${APP}/(protected)/(dashboard)/dashboard/reports/page.tsx`,
|
|
713
726
|
`${APP}/(protected)/(dashboard)/dashboard/settings/page.tsx`,
|
|
714
727
|
`${APP}/(protected)/(admin)/layout.tsx`,
|
|
728
|
+
`${APP}/(protected)/(admin)/admin/page.tsx`,
|
|
715
729
|
'src/lib/validation.ts',
|
|
716
730
|
'src/lib/ai/api.ts',
|
|
717
731
|
'src/lib/ai/api-schemas.ts',
|
|
@@ -719,6 +733,7 @@ const PRUNE_MARKER_FILES = [
|
|
|
719
733
|
'src/lib/ai/tools/manager.ts',
|
|
720
734
|
'src/lib/ai/tools/types.ts',
|
|
721
735
|
'src/hooks/ai/useGateway.ts',
|
|
736
|
+
'src/hooks/ai/index.ts',
|
|
722
737
|
'src/lib/ai/metering/logger.ts',
|
|
723
738
|
'src/lib/ai/metering/types.ts',
|
|
724
739
|
'src/lib/ai/rag.ts',
|
|
@@ -754,18 +769,20 @@ const PRUNE_MARKER_FILES = [
|
|
|
754
769
|
'src/lib/usage.ts',
|
|
755
770
|
'src/lib/access-control.ts',
|
|
756
771
|
'src/lib/access-control.test.ts',
|
|
772
|
+
'src/lib/dashboard/contracts.ts',
|
|
773
|
+
'src/lib/dashboard/overview.ts',
|
|
757
774
|
'src/lib/db/schema.ts',
|
|
758
775
|
'src/lib/db/schema-pg.ts',
|
|
759
776
|
'src/lib/db/admin.ts',
|
|
777
|
+
'src/lib/db/dashboard.ts',
|
|
760
778
|
'src/lib/onboarding/checks.ts',
|
|
761
779
|
'src/lib/organizations/context.ts',
|
|
780
|
+
'src/lib/proxy/referrals.ts',
|
|
762
781
|
'src/config/env.ts',
|
|
763
782
|
'src/config/navigation.ts',
|
|
764
783
|
'src/config/marketing.test.ts',
|
|
765
784
|
'src/config/env-schema.ts',
|
|
766
785
|
'src/instrumentation.ts',
|
|
767
|
-
'src/proxy.ts',
|
|
768
|
-
'src/proxy.test.ts',
|
|
769
786
|
'scripts/seed.ts',
|
|
770
787
|
];
|
|
771
788
|
export function buildEnvContent(content, config, root) {
|
|
@@ -908,12 +925,18 @@ function pruneMarkedBlocks(content, disabledKeys, cleanMarkers) {
|
|
|
908
925
|
}
|
|
909
926
|
}
|
|
910
927
|
else {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
out.push(
|
|
928
|
+
if (replaceIndex !== undefined && cleanMarkers) {
|
|
929
|
+
out.push(lines[i]);
|
|
930
|
+
out.push(...processLines(lines.slice(i + 1, replaceIndex)));
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
out.push(lines[i]);
|
|
934
|
+
const bodyEnd = replaceIndex ?? endIndex;
|
|
935
|
+
out.push(...processLines(lines.slice(i + 1, bodyEnd)));
|
|
936
|
+
if (replaceIndex !== undefined) {
|
|
937
|
+
out.push(lines[replaceIndex]);
|
|
938
|
+
out.push(...processLines(lines.slice(replaceIndex + 1, endIndex)));
|
|
939
|
+
}
|
|
917
940
|
}
|
|
918
941
|
out.push(lines[endIndex]);
|
|
919
942
|
}
|
package/dist/mcp/tools/env.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
export interface EnvEntry {
|
|
3
|
-
key: string;
|
|
4
|
-
value: string;
|
|
5
|
-
comment?: string;
|
|
6
|
-
required: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function parseEnvFile(content: string): EnvEntry[];
|
|
9
2
|
export declare function registerEnvTools(server: McpServer): void;
|
package/dist/mcp/tools/env.js
CHANGED
|
@@ -2,34 +2,9 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { checkProjectRoot, readProjectFile } from '../../utils/project.js';
|
|
5
|
-
import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, getProjectEnvOptions, loadProjectEnv, } from '../../utils/project-env.js';
|
|
5
|
+
import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, getProjectEnvOptions, loadProjectEnv, parseEnvFile, } from '../../utils/project-env.js';
|
|
6
6
|
import { findEnvIssues, getAdapters, getAuthMethods, getFeatures, getOauthProviders, getProjectEnvValue, } from '../../utils/env-config.js';
|
|
7
7
|
import { envSourceSchema } from './schemas.js';
|
|
8
|
-
export function parseEnvFile(content) {
|
|
9
|
-
const entries = [];
|
|
10
|
-
let lastComment = '';
|
|
11
|
-
for (const line of content.split('\n')) {
|
|
12
|
-
const trimmed = line.trim();
|
|
13
|
-
if (trimmed.startsWith('#') && !trimmed.startsWith('# ---') && !trimmed.startsWith('# ===')) {
|
|
14
|
-
lastComment = trimmed.slice(1).trim();
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const match = /^([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?\s*$/.exec(trimmed);
|
|
18
|
-
if (match) {
|
|
19
|
-
entries.push({
|
|
20
|
-
key: match[1],
|
|
21
|
-
value: match[2],
|
|
22
|
-
comment: lastComment || undefined,
|
|
23
|
-
required: !line.startsWith('#'),
|
|
24
|
-
});
|
|
25
|
-
lastComment = '';
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
lastComment = '';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return entries;
|
|
32
|
-
}
|
|
33
8
|
const SENSITIVE_PATTERNS = [/SECRET/i, /KEY/i, /TOKEN/i, /PASSWORD/i, /CREDENTIAL/i];
|
|
34
9
|
function isSensitiveKey(key) {
|
|
35
10
|
return SENSITIVE_PATTERNS.some((p) => p.test(key));
|
|
@@ -57,7 +32,8 @@ export function registerEnvTools(server) {
|
|
|
57
32
|
}, ({ env_source }) => {
|
|
58
33
|
const root = checkProjectRoot('throw');
|
|
59
34
|
const example = parseEnvFile(readProjectFile(root, ENV_EXAMPLE_FILE_NAME) ?? '');
|
|
60
|
-
const
|
|
35
|
+
const envContent = loadProjectEnv(root, getProjectEnvOptions(env_source)).content;
|
|
36
|
+
const local = parseEnvFile(envContent).filter((entry) => entry.required);
|
|
61
37
|
const localKeys = new Set(local.map((entry) => entry.key));
|
|
62
38
|
const missing = example
|
|
63
39
|
.filter((entry) => entry.required && !localKeys.has(entry.key))
|
|
@@ -68,7 +44,6 @@ export function registerEnvTools(server) {
|
|
|
68
44
|
const extra = local
|
|
69
45
|
.filter((entry) => !example.some((candidate) => candidate.key === entry.key))
|
|
70
46
|
.map((entry) => entry.key);
|
|
71
|
-
const envContent = loadProjectEnv(root, getProjectEnvOptions(env_source)).content;
|
|
72
47
|
const validationIssues = findEnvIssues(envContent, root);
|
|
73
48
|
return {
|
|
74
49
|
content: [
|
|
@@ -109,7 +84,9 @@ export function registerEnvTools(server) {
|
|
|
109
84
|
const envPath = resolve(root, ENV_FILE_NAME);
|
|
110
85
|
const fileExisted = existsSync(envPath);
|
|
111
86
|
const currentContent = fileExisted ? readFileSync(envPath, 'utf-8') : '';
|
|
112
|
-
const currentKeys = new Set(parseEnvFile(currentContent)
|
|
87
|
+
const currentKeys = new Set(parseEnvFile(currentContent)
|
|
88
|
+
.filter((entry) => entry.required)
|
|
89
|
+
.map((entry) => entry.key));
|
|
113
90
|
const missing = parseEnvFile(exampleContent).filter((entry) => entry.required && !currentKeys.has(entry.key));
|
|
114
91
|
if (!dry_run && !existsSync(envPath))
|
|
115
92
|
writeFileSync(envPath, exampleContent, 'utf-8');
|
|
@@ -166,7 +143,7 @@ export function registerEnvTools(server) {
|
|
|
166
143
|
isError: true,
|
|
167
144
|
};
|
|
168
145
|
const exampleContent = readProjectFile(root, ENV_EXAMPLE_FILE_NAME) ?? '';
|
|
169
|
-
const localEntries = parseEnvFile(localContent);
|
|
146
|
+
const localEntries = parseEnvFile(localContent).filter((entry) => entry.required);
|
|
170
147
|
const exampleEntries = parseEnvFile(exampleContent);
|
|
171
148
|
const localKeys = new Set(localEntries.map((e) => e.key));
|
|
172
149
|
const missing = exampleEntries
|
|
@@ -5,6 +5,7 @@ import { checkProjectRoot } from '../../utils/project.js';
|
|
|
5
5
|
import { ENV_FILE_NAME } from '../../utils/project-env.js';
|
|
6
6
|
import { resolveManifest } from '../../utils/manifest.js';
|
|
7
7
|
import { patchSchemaImports, patchSchemaImportsPg, patchSchemaTables, patchSchemaTablesPg, patchDbReExports, patchNextConfig, createPluginRegistration, patchPages, findPageConflicts, patchEnvFile, patchPackageJson, } from '../../utils/patchers.js';
|
|
8
|
+
import { updatePluginSchemaTables } from '../../utils/plugin-workflows.js';
|
|
8
9
|
import { envSourceSchema } from './schemas.js';
|
|
9
10
|
export function registerPluginTools(server) {
|
|
10
11
|
server.registerTool('codapult_plugins_list', {
|
|
@@ -301,13 +302,7 @@ export function registerPluginTools(server) {
|
|
|
301
302
|
results.push({ plugin: pName, updated: false });
|
|
302
303
|
continue;
|
|
303
304
|
}
|
|
304
|
-
const
|
|
305
|
-
? patchSchemaTables(root, manifest.name, pluginDir, manifest.install.schemaTables, 'update')
|
|
306
|
-
: false;
|
|
307
|
-
const updatedPostgres = manifest.install.schemaTablesPg
|
|
308
|
-
? patchSchemaTablesPg(root, manifest.name, pluginDir, manifest.install.schemaTablesPg, 'update')
|
|
309
|
-
: false;
|
|
310
|
-
const updated = updatedSqlite || updatedPostgres;
|
|
305
|
+
const { updated } = updatePluginSchemaTables(root, manifest, pluginDir);
|
|
311
306
|
const imports = manifest.install.schemaImports;
|
|
312
307
|
if (updated && imports && imports.length > 0) {
|
|
313
308
|
patchSchemaImports(root, manifest.name, imports, 'add');
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginManifest } from './manifest.js';
|
|
2
|
+
export interface PluginSchemaUpdateResult {
|
|
3
|
+
sqliteUpdated: boolean;
|
|
4
|
+
postgresUpdated: boolean;
|
|
5
|
+
updated: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function updatePluginSchemaTables(root: string, manifest: PluginManifest, pluginDir: string): PluginSchemaUpdateResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { patchSchemaTables, patchSchemaTablesPg } from './patchers.js';
|
|
2
|
+
export function updatePluginSchemaTables(root, manifest, pluginDir) {
|
|
3
|
+
const sqliteUpdated = manifest.install.schemaTables
|
|
4
|
+
? patchSchemaTables(root, manifest.name, pluginDir, manifest.install.schemaTables, 'update')
|
|
5
|
+
: false;
|
|
6
|
+
const postgresUpdated = manifest.install.schemaTablesPg
|
|
7
|
+
? patchSchemaTablesPg(root, manifest.name, pluginDir, manifest.install.schemaTablesPg, 'update')
|
|
8
|
+
: false;
|
|
9
|
+
return {
|
|
10
|
+
sqliteUpdated,
|
|
11
|
+
postgresUpdated,
|
|
12
|
+
updated: sqliteUpdated || postgresUpdated,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -8,8 +8,15 @@ export interface LoadedProjectEnv {
|
|
|
8
8
|
filePath: string;
|
|
9
9
|
fileExists: boolean;
|
|
10
10
|
}
|
|
11
|
+
export interface EnvEntry {
|
|
12
|
+
key: string;
|
|
13
|
+
value: string;
|
|
14
|
+
comment?: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
}
|
|
11
17
|
export declare const ENV_EXAMPLE_FILE_NAME = ".env.example";
|
|
12
18
|
export declare const ENV_FILE_NAME = ".env.local";
|
|
19
|
+
export declare function parseEnvFile(content: string): EnvEntry[];
|
|
13
20
|
export declare function getProjectEnvFilePath(projectRoot: string): string;
|
|
14
21
|
export declare function getProjectEnvSource(options?: ProjectEnvOptions): ProjectEnvSource;
|
|
15
22
|
export declare function getProjectEnvOptions(envSource?: ProjectEnvSource): ProjectEnvOptions;
|
|
@@ -2,6 +2,30 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
export const ENV_EXAMPLE_FILE_NAME = '.env.example';
|
|
4
4
|
export const ENV_FILE_NAME = '.env.local';
|
|
5
|
+
export function parseEnvFile(content) {
|
|
6
|
+
const entries = [];
|
|
7
|
+
let lastComment = '';
|
|
8
|
+
for (const line of content.split('\n')) {
|
|
9
|
+
const trimmed = line.trim();
|
|
10
|
+
const match = /^(#\s*)?([A-Z_][A-Z0-9_]*)\s*=\s*"?(.*?)"?\s*$/.exec(trimmed);
|
|
11
|
+
if (match) {
|
|
12
|
+
entries.push({
|
|
13
|
+
key: match[2],
|
|
14
|
+
value: match[3],
|
|
15
|
+
comment: lastComment || undefined,
|
|
16
|
+
required: match[1] === undefined,
|
|
17
|
+
});
|
|
18
|
+
lastComment = '';
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (trimmed.startsWith('#') && !trimmed.startsWith('# ---') && !trimmed.startsWith('# ===')) {
|
|
22
|
+
lastComment = trimmed.slice(1).trim();
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
lastComment = '';
|
|
26
|
+
}
|
|
27
|
+
return entries;
|
|
28
|
+
}
|
|
5
29
|
export function getProjectEnvFilePath(projectRoot) {
|
|
6
30
|
return resolve(projectRoot, ENV_FILE_NAME);
|
|
7
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codapult/cli",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.3",
|
|
4
4
|
"description": "Next.js SaaS CLI and MCP server for Codapult boilerplate projects, with setup, plugins, database, deployment, and AI-agent architecture guardrails",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"packageManager": "pnpm@12.16.1+sha512.091d1dee7927575661b25dab3c2ae31cafc1c54d6b71ed6a6600cf0c1cb10434a447eae14015f1b23e2e6bedeed79df94a932e2164d2832280dce3fb32f656d1",
|