@codapult/cli 0.12.1 → 0.14.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.
- package/dist/commands/config-show.js +4 -4
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/generate.test.js +1 -1
- package/dist/commands/setup.js +34 -35
- package/dist/mcp/resources.js +12 -2
- package/dist/mcp/tools/db.js +2 -2
- package/dist/mcp/tools/db.test.js +4 -4
- package/dist/mcp/tools/env.test.js +4 -4
- package/dist/mcp/tools/project.test.js +1 -1
- package/dist/utils/env-config.js +1 -1
- package/dist/utils/manifest.d.ts +1 -1
- package/dist/utils/manifest.js +1 -1
- package/dist/utils/manifest.test.js +3 -3
- package/dist/utils/patchers.js +5 -5
- package/dist/utils/patchers.test.js +2 -2
- package/dist/utils/project-env.js +1 -1
- package/dist/utils/project.d.ts +3 -3
- package/dist/utils/project.js +3 -3
- package/dist/utils/project.test.js +4 -4
- package/package.json +10 -10
|
@@ -8,19 +8,19 @@ import { heading, success, fail, info, dim, label } from '../utils/ui.js';
|
|
|
8
8
|
function extractTsObjectField(content, field) {
|
|
9
9
|
const regex = new RegExp(`\\b${field}\\s*:\\s*['"\`]([^'"\`]+)['"\`]`);
|
|
10
10
|
const match = regex.exec(content);
|
|
11
|
-
return match?.[1] ??
|
|
11
|
+
return match?.[1] ?? undefined;
|
|
12
12
|
}
|
|
13
13
|
/** Extracts a numeric literal: `field: 123` or `field: 0.5`. */
|
|
14
14
|
function extractTsNumericField(content, field) {
|
|
15
15
|
const regex = new RegExp(`\\b${field}\\s*:\\s*([\\d.]+)`);
|
|
16
16
|
const match = regex.exec(content);
|
|
17
|
-
return match?.[1] ??
|
|
17
|
+
return match?.[1] ?? undefined;
|
|
18
18
|
}
|
|
19
19
|
/** Extracts a boolean literal: `field: true|false`. */
|
|
20
20
|
function extractTsBoolField(content, field) {
|
|
21
21
|
const regex = new RegExp(`\\b${field}\\s*:\\s*(true|false)`);
|
|
22
22
|
const match = regex.exec(content);
|
|
23
|
-
return match ? match[1] === 'true' :
|
|
23
|
+
return match ? match[1] === 'true' : undefined;
|
|
24
24
|
}
|
|
25
25
|
export function configShowCommand(options = {}) {
|
|
26
26
|
const root = findProjectRoot();
|
|
@@ -72,7 +72,7 @@ export function configShowCommand(options = {}) {
|
|
|
72
72
|
const ragMinScore = extractTsNumericField(content, 'ragMinScore');
|
|
73
73
|
if (defaultModel)
|
|
74
74
|
label(' Default model', defaultModel);
|
|
75
|
-
if (ragEnabled
|
|
75
|
+
if (ragEnabled != null)
|
|
76
76
|
label(' RAG', ragEnabled ? 'enabled' : 'disabled');
|
|
77
77
|
if (ragMaxChunks)
|
|
78
78
|
label(' RAG max chunks', ragMaxChunks);
|
package/dist/commands/doctor.js
CHANGED
|
@@ -22,7 +22,7 @@ function tryExec(cmd, cwd) {
|
|
|
22
22
|
return execSync(cmd, { cwd, encoding: 'utf-8', stdio: 'pipe' }).trim();
|
|
23
23
|
}
|
|
24
24
|
catch {
|
|
25
|
-
return
|
|
25
|
+
return undefined;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
export function doctorCommand(options = {}) {
|
|
@@ -134,7 +134,7 @@ export function doctorCommand(options = {}) {
|
|
|
134
134
|
// --- TypeScript ---
|
|
135
135
|
info('TypeScript');
|
|
136
136
|
const tscResult = tryExec('npx tsc --noEmit 2>&1 | tail -1', root);
|
|
137
|
-
if (tscResult
|
|
137
|
+
if (tscResult == null || tscResult.includes('error')) {
|
|
138
138
|
warn('TypeScript has errors — run: pnpm type-check');
|
|
139
139
|
warnings += 1;
|
|
140
140
|
}
|
|
@@ -198,7 +198,7 @@ export function doctorCommand(options = {}) {
|
|
|
198
198
|
if (gitStatus === '') {
|
|
199
199
|
success('Working tree clean');
|
|
200
200
|
}
|
|
201
|
-
else if (gitStatus
|
|
201
|
+
else if (gitStatus != null) {
|
|
202
202
|
const lines = gitStatus.split('\n').filter(Boolean);
|
|
203
203
|
warn(`${lines.length} uncommitted change(s)`);
|
|
204
204
|
}
|
|
@@ -50,7 +50,7 @@ describe('generatePageCommand', () => {
|
|
|
50
50
|
expect(mockedWrite).not.toHaveBeenCalled();
|
|
51
51
|
});
|
|
52
52
|
it('exits when not in a Codapult project', () => {
|
|
53
|
-
mockedFindRoot.mockReturnValue(
|
|
53
|
+
mockedFindRoot.mockReturnValue(undefined);
|
|
54
54
|
expect(() => generatePageCommand('test')).toThrow('process.exit');
|
|
55
55
|
expect(process.exit).toHaveBeenCalledWith(1);
|
|
56
56
|
});
|
package/dist/commands/setup.js
CHANGED
|
@@ -140,10 +140,10 @@ const MODULE_REMOVALS = [
|
|
|
140
140
|
{
|
|
141
141
|
key: 'enableAuth',
|
|
142
142
|
paths: [
|
|
143
|
-
`${APP}/(auth)`,
|
|
144
|
-
`${APP}/(
|
|
145
|
-
`${APP}/
|
|
146
|
-
`${APP}/
|
|
143
|
+
`${APP}/(public)/(auth)`,
|
|
144
|
+
`${APP}/(public)/invite`,
|
|
145
|
+
`${APP}/(protected)/(dashboard)`,
|
|
146
|
+
`${APP}/(protected)/(admin)`,
|
|
147
147
|
'src/app/api/auth',
|
|
148
148
|
'src/lib/auth/better-auth.ts',
|
|
149
149
|
'src/lib/auth/better-auth.test.ts',
|
|
@@ -161,14 +161,13 @@ const MODULE_REMOVALS = [
|
|
|
161
161
|
'src/lib/actions/admin.test.ts',
|
|
162
162
|
'src/lib/actions/impersonation.ts',
|
|
163
163
|
'src/lib/actions/impersonation.test.ts',
|
|
164
|
-
'src/components/ImpersonationBanner.tsx',
|
|
165
164
|
],
|
|
166
165
|
label: 'Authentication & Dashboard',
|
|
167
166
|
},
|
|
168
167
|
{
|
|
169
168
|
key: 'enableAI',
|
|
170
169
|
paths: [
|
|
171
|
-
`${APP}/(dashboard)/dashboard/ai-chat`,
|
|
170
|
+
`${APP}/(protected)/(dashboard)/dashboard/ai-chat`,
|
|
172
171
|
'src/app/api/chat',
|
|
173
172
|
'src/components/ai',
|
|
174
173
|
'src/lib/ai',
|
|
@@ -178,16 +177,15 @@ const MODULE_REMOVALS = [
|
|
|
178
177
|
{
|
|
179
178
|
key: 'enableBlog',
|
|
180
179
|
paths: [
|
|
181
|
-
`${APP}/(marketing)/blog`,
|
|
180
|
+
`${APP}/(public)/(marketing)/blog`,
|
|
182
181
|
'src/components/blog',
|
|
183
182
|
'src/components/seo/BlogPostJsonLd.tsx',
|
|
184
183
|
'src/lib/blog',
|
|
184
|
+
'content/blog',
|
|
185
185
|
'src/lib/rss.ts',
|
|
186
186
|
'src/lib/rss.test.ts',
|
|
187
|
-
'content/blog',
|
|
188
|
-
'src/app/rss.xml',
|
|
189
187
|
'src/app/(marketing)/rss.xml',
|
|
190
|
-
`${APP}/(marketing)/rss.xml`,
|
|
188
|
+
`${APP}/(public)/(marketing)/rss.xml`,
|
|
191
189
|
`${APP}/rss.xml`,
|
|
192
190
|
],
|
|
193
191
|
label: 'Blog',
|
|
@@ -195,8 +193,8 @@ const MODULE_REMOVALS = [
|
|
|
195
193
|
{
|
|
196
194
|
key: 'enableTeams',
|
|
197
195
|
paths: [
|
|
198
|
-
`${APP}/(dashboard)/dashboard/teams`,
|
|
199
|
-
`${APP}/invite`,
|
|
196
|
+
`${APP}/(protected)/(dashboard)/dashboard/teams`,
|
|
197
|
+
`${APP}/(public)/invite`,
|
|
200
198
|
'src/components/dashboard/TeamSwitcher.tsx',
|
|
201
199
|
'src/components/dashboard/TeamSettings.tsx',
|
|
202
200
|
'src/components/dashboard/AcceptInvitationButton.tsx',
|
|
@@ -214,8 +212,8 @@ const MODULE_REMOVALS = [
|
|
|
214
212
|
{
|
|
215
213
|
key: 'enableWaitlist',
|
|
216
214
|
paths: [
|
|
217
|
-
`${APP}/(marketing)/waitlist`,
|
|
218
|
-
`${APP}/admin/waitlist`,
|
|
215
|
+
`${APP}/(public)/(marketing)/waitlist`,
|
|
216
|
+
`${APP}/(protected)/(admin)/admin/waitlist`,
|
|
219
217
|
'src/components/marketing/WaitlistForm.tsx',
|
|
220
218
|
'src/lib/actions/waitlist.ts',
|
|
221
219
|
],
|
|
@@ -229,7 +227,7 @@ const MODULE_REMOVALS = [
|
|
|
229
227
|
{
|
|
230
228
|
key: 'enableSSO',
|
|
231
229
|
paths: [
|
|
232
|
-
`${APP}/admin/sso`,
|
|
230
|
+
`${APP}/(protected)/(admin)/admin/sso`,
|
|
233
231
|
'src/lib/sso',
|
|
234
232
|
'src/app/api/auth/sso',
|
|
235
233
|
'src/app/api/admin/sso',
|
|
@@ -240,7 +238,7 @@ const MODULE_REMOVALS = [
|
|
|
240
238
|
{
|
|
241
239
|
key: 'enableApiDocs',
|
|
242
240
|
paths: [
|
|
243
|
-
`${APP}/(marketing)/docs/api`,
|
|
241
|
+
`${APP}/(public)/(marketing)/docs/api`,
|
|
244
242
|
'src/lib/api-docs.ts',
|
|
245
243
|
'src/lib/openapi.ts',
|
|
246
244
|
'src/app/api/openapi',
|
|
@@ -251,7 +249,7 @@ const MODULE_REMOVALS = [
|
|
|
251
249
|
{
|
|
252
250
|
key: 'enableHelpCenter',
|
|
253
251
|
paths: [
|
|
254
|
-
`${APP}/(marketing)/docs`,
|
|
252
|
+
`${APP}/(public)/(marketing)/docs`,
|
|
255
253
|
'src/lib/docs',
|
|
256
254
|
'src/components/docs/HelpDocSearch.tsx',
|
|
257
255
|
'src/components/seo/DocArticleJsonLd.tsx',
|
|
@@ -262,7 +260,7 @@ const MODULE_REMOVALS = [
|
|
|
262
260
|
{
|
|
263
261
|
key: 'enableChangelog',
|
|
264
262
|
paths: [
|
|
265
|
-
`${APP}/(marketing)/changelog`,
|
|
263
|
+
`${APP}/(public)/(marketing)/changelog`,
|
|
266
264
|
'src/app/api/changelog',
|
|
267
265
|
'src/components/dashboard/ChangelogWidget.tsx',
|
|
268
266
|
],
|
|
@@ -271,7 +269,7 @@ const MODULE_REMOVALS = [
|
|
|
271
269
|
{
|
|
272
270
|
key: 'enableExperiments',
|
|
273
271
|
paths: [
|
|
274
|
-
`${APP}/admin/experiments`,
|
|
272
|
+
`${APP}/(protected)/(admin)/admin/experiments`,
|
|
275
273
|
'src/lib/experiments',
|
|
276
274
|
'src/app/api/admin/experiments',
|
|
277
275
|
'src/components/admin/ExperimentManager.tsx',
|
|
@@ -281,7 +279,7 @@ const MODULE_REMOVALS = [
|
|
|
281
279
|
{
|
|
282
280
|
key: 'enableFeatureRequests',
|
|
283
281
|
paths: [
|
|
284
|
-
`${APP}/(marketing)/feature-requests`,
|
|
282
|
+
`${APP}/(public)/(marketing)/feature-requests`,
|
|
285
283
|
'src/lib/feature-requests',
|
|
286
284
|
'src/app/api/feature-requests',
|
|
287
285
|
'src/components/feature-requests',
|
|
@@ -291,7 +289,7 @@ const MODULE_REMOVALS = [
|
|
|
291
289
|
{
|
|
292
290
|
key: 'enableCompare',
|
|
293
291
|
paths: [
|
|
294
|
-
`${APP}/(marketing)/compare`,
|
|
292
|
+
`${APP}/(public)/(marketing)/compare`,
|
|
295
293
|
'src/config/competitor-comparison.ts',
|
|
296
294
|
'src/components/marketing/ComparisonTable.tsx',
|
|
297
295
|
],
|
|
@@ -300,7 +298,7 @@ const MODULE_REMOVALS = [
|
|
|
300
298
|
{
|
|
301
299
|
key: 'enableConnect',
|
|
302
300
|
paths: [
|
|
303
|
-
`${APP}/(dashboard)/dashboard/connect`,
|
|
301
|
+
`${APP}/(protected)/(dashboard)/dashboard/connect`,
|
|
304
302
|
'src/lib/payments/connect.ts',
|
|
305
303
|
'src/lib/payments/connect.test.ts',
|
|
306
304
|
'src/app/api/connect',
|
|
@@ -317,7 +315,7 @@ const MODULE_REMOVALS = [
|
|
|
317
315
|
{
|
|
318
316
|
key: 'enableDripCampaigns',
|
|
319
317
|
paths: [
|
|
320
|
-
`${APP}/admin/drip-campaigns`,
|
|
318
|
+
`${APP}/(protected)/(admin)/admin/drip-campaigns`,
|
|
321
319
|
'src/lib/drip-campaigns',
|
|
322
320
|
'src/app/api/admin/drip-campaigns',
|
|
323
321
|
'src/components/admin/DripCampaignManager.tsx',
|
|
@@ -327,7 +325,7 @@ const MODULE_REMOVALS = [
|
|
|
327
325
|
{
|
|
328
326
|
key: 'enableOnboarding',
|
|
329
327
|
paths: [
|
|
330
|
-
`${APP}/(dashboard)/dashboard/onboarding`,
|
|
328
|
+
`${APP}/(protected)/(dashboard)/dashboard/onboarding`,
|
|
331
329
|
'src/lib/onboarding',
|
|
332
330
|
'src/app/api/onboarding',
|
|
333
331
|
'src/components/dashboard/OnboardingTour.tsx',
|
|
@@ -338,7 +336,7 @@ const MODULE_REMOVALS = [
|
|
|
338
336
|
{
|
|
339
337
|
key: 'enableWorkflows',
|
|
340
338
|
paths: [
|
|
341
|
-
`${APP}/(dashboard)/dashboard/workflows`,
|
|
339
|
+
`${APP}/(protected)/(dashboard)/dashboard/workflows`,
|
|
342
340
|
'src/lib/workflows',
|
|
343
341
|
'src/app/api/workflows',
|
|
344
342
|
'src/components/dashboard/WorkflowBuilder.tsx',
|
|
@@ -348,7 +346,7 @@ const MODULE_REMOVALS = [
|
|
|
348
346
|
{
|
|
349
347
|
key: 'enableReferrals',
|
|
350
348
|
paths: [
|
|
351
|
-
`${APP}/(dashboard)/dashboard/referrals`,
|
|
349
|
+
`${APP}/(protected)/(dashboard)/dashboard/referrals`,
|
|
352
350
|
'src/lib/referrals',
|
|
353
351
|
'src/app/api/referrals',
|
|
354
352
|
'src/components/dashboard/ReferralDashboard.tsx',
|
|
@@ -358,7 +356,7 @@ const MODULE_REMOVALS = [
|
|
|
358
356
|
{
|
|
359
357
|
key: 'enableAnalytics',
|
|
360
358
|
paths: [
|
|
361
|
-
`${APP}/(dashboard)/dashboard/analytics`,
|
|
359
|
+
`${APP}/(protected)/(dashboard)/dashboard/analytics`,
|
|
362
360
|
'src/lib/analytics',
|
|
363
361
|
'src/app/api/analytics',
|
|
364
362
|
'src/components/dashboard/AnalyticsDashboard.tsx',
|
|
@@ -380,8 +378,8 @@ const MODULE_REMOVALS = [
|
|
|
380
378
|
{
|
|
381
379
|
key: 'enableWebhooks',
|
|
382
380
|
paths: [
|
|
383
|
-
`${APP}/(dashboard)/dashboard/webhooks`,
|
|
384
|
-
`${APP}/admin/webhooks`,
|
|
381
|
+
`${APP}/(protected)/(dashboard)/dashboard/webhooks`,
|
|
382
|
+
`${APP}/(protected)/(admin)/admin/webhooks`,
|
|
385
383
|
'src/app/api/webhooks',
|
|
386
384
|
'src/lib/outgoing-webhooks',
|
|
387
385
|
'src/lib/webhook-log.ts',
|
|
@@ -393,8 +391,8 @@ const MODULE_REMOVALS = [
|
|
|
393
391
|
{
|
|
394
392
|
key: 'enableAuditLog',
|
|
395
393
|
paths: [
|
|
396
|
-
`${APP}/(dashboard)/dashboard/audit-log`,
|
|
397
|
-
`${APP}/admin/activity`,
|
|
394
|
+
`${APP}/(protected)/(dashboard)/dashboard/audit-log`,
|
|
395
|
+
`${APP}/(protected)/(admin)/admin/activity`,
|
|
398
396
|
'src/app/api/audit-log',
|
|
399
397
|
'src/lib/activity-log.ts',
|
|
400
398
|
'src/components/dashboard/AuditLog.tsx',
|
|
@@ -414,11 +412,12 @@ const MODULE_REMOVALS = [
|
|
|
414
412
|
{
|
|
415
413
|
key: 'enableBranding',
|
|
416
414
|
paths: [
|
|
417
|
-
`${APP}/(dashboard)/dashboard/branding`,
|
|
415
|
+
`${APP}/(protected)/(dashboard)/dashboard/branding`,
|
|
418
416
|
'src/app/api/branding',
|
|
419
|
-
'src/lib/
|
|
417
|
+
'src/lib/branding',
|
|
420
418
|
'src/components/dashboard/BrandingSettings.tsx',
|
|
421
419
|
'src/components/dashboard/BrandingProvider.tsx',
|
|
420
|
+
'src/components/dashboard/SidebarBrandLink.tsx',
|
|
422
421
|
],
|
|
423
422
|
label: 'White-label Branding',
|
|
424
423
|
},
|
|
@@ -433,8 +432,8 @@ const MODULE_REMOVALS = [
|
|
|
433
432
|
{
|
|
434
433
|
key: 'enablePlugins',
|
|
435
434
|
paths: [
|
|
436
|
-
`${APP}/(marketing)/plugins`,
|
|
437
|
-
`${APP}/(dashboard)/dashboard/plugins`,
|
|
435
|
+
`${APP}/(public)/(marketing)/plugins`,
|
|
436
|
+
`${APP}/(protected)/(dashboard)/dashboard/plugins`,
|
|
438
437
|
'src/lib/plugins/marketplace.ts',
|
|
439
438
|
'src/components/marketing/PluginsShowcase.tsx',
|
|
440
439
|
'src/components/marketing/PluginDetail.tsx',
|
package/dist/mcp/resources.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findProjectRoot, readProjectFile } from '../utils/project.js';
|
|
2
|
-
import { ENV_EXAMPLE_FILE_NAME
|
|
2
|
+
import { ENV_EXAMPLE_FILE_NAME } from '../utils/project-env.js';
|
|
3
3
|
function getRoot() {
|
|
4
4
|
const root = findProjectRoot();
|
|
5
5
|
if (!root)
|
|
@@ -17,7 +17,7 @@ export function registerResources(server) {
|
|
|
17
17
|
});
|
|
18
18
|
server.registerResource('codapult_app_config', 'codapult://config/app', {
|
|
19
19
|
title: 'App Configuration',
|
|
20
|
-
description: `Application config (src/config/app.ts) — brand, AI, company. Feature toggles and auth methods live in
|
|
20
|
+
description: `Application config (src/config/app.ts) — brand, AI, company. Feature toggles and auth methods live in src/lib/config.ts — see codapult://config/env.`,
|
|
21
21
|
mimeType: 'text/plain',
|
|
22
22
|
}, () => {
|
|
23
23
|
const content = readProjectFile(getRoot(), 'src/config/app.ts') ?? 'Config file not found';
|
|
@@ -25,6 +25,16 @@ export function registerResources(server) {
|
|
|
25
25
|
contents: [{ uri: 'codapult://config/app', text: content, mimeType: 'text/plain' }],
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
+
server.registerResource('codapult_env_config', 'codapult://config/env', {
|
|
29
|
+
title: 'Environment Configuration',
|
|
30
|
+
description: `Typed env access (src/lib/config.ts) — feature toggles (env.features), auth methods (env.auth), provider selection (dbProvider, paymentProvider, storageProvider, jobProvider), and checkout resolution. This is the source of truth for which modules are enabled — see also codapult://env-example or codapult_project_status.`,
|
|
31
|
+
mimeType: 'text/plain',
|
|
32
|
+
}, () => {
|
|
33
|
+
const content = readProjectFile(getRoot(), 'src/lib/config.ts') ?? 'Config file not found';
|
|
34
|
+
return {
|
|
35
|
+
contents: [{ uri: 'codapult://config/env', text: content, mimeType: 'text/plain' }],
|
|
36
|
+
};
|
|
37
|
+
});
|
|
28
38
|
server.registerResource('codapult_agents_md', 'codapult://agents', {
|
|
29
39
|
title: 'AGENTS.md',
|
|
30
40
|
description: 'AI agent guide — project structure, patterns, conventions, and rules',
|
package/dist/mcp/tools/db.js
CHANGED
|
@@ -14,7 +14,7 @@ function parseSchema(content) {
|
|
|
14
14
|
const tables = [];
|
|
15
15
|
const tableRegex = /export\s+const\s+(\w+)\s*=\s*(?:sqliteTable|pgTable)\(\s*['"](\w+)['"]\s*,\s*\{/g;
|
|
16
16
|
let match;
|
|
17
|
-
while ((match = tableRegex.exec(content))
|
|
17
|
+
while ((match = tableRegex.exec(content)) != null) {
|
|
18
18
|
const tableName = match[2];
|
|
19
19
|
const startIdx = match.index + match[0].length;
|
|
20
20
|
let depth = 1;
|
|
@@ -30,7 +30,7 @@ function parseSchema(content) {
|
|
|
30
30
|
const columns = [];
|
|
31
31
|
const colRegex = /(\w+)\s*:\s*(text|integer|real|blob|boolean|timestamp|serial)\(['"](\w+)['"]/g;
|
|
32
32
|
let colMatch;
|
|
33
|
-
while ((colMatch = colRegex.exec(body))
|
|
33
|
+
while ((colMatch = colRegex.exec(body)) != null) {
|
|
34
34
|
const colName = colMatch[1];
|
|
35
35
|
const colType = colMatch[2];
|
|
36
36
|
const constraints = [];
|
|
@@ -67,7 +67,7 @@ export const post = sqliteTable('post', {
|
|
|
67
67
|
it('returns error when schema file not found', () => {
|
|
68
68
|
const server = createMockServer();
|
|
69
69
|
registerDbTools(server);
|
|
70
|
-
mockedReadProject.mockReturnValue(
|
|
70
|
+
mockedReadProject.mockReturnValue(undefined);
|
|
71
71
|
const handler = server.tools.find((t) => t.name === 'codapult_db_get_tables').handler;
|
|
72
72
|
const result = handler({});
|
|
73
73
|
expect(result.isError).toBe(true);
|
|
@@ -123,7 +123,7 @@ export const user = sqliteTable('user', {
|
|
|
123
123
|
return envContent;
|
|
124
124
|
if (path === 'src/lib/db/schema.ts')
|
|
125
125
|
return schema;
|
|
126
|
-
return
|
|
126
|
+
return undefined;
|
|
127
127
|
});
|
|
128
128
|
mockedExists.mockReturnValue(true);
|
|
129
129
|
mockedReaddir.mockReturnValue(['0001.sql', '0002.sql', 'meta']);
|
|
@@ -142,7 +142,7 @@ export const user = sqliteTable('user', {
|
|
|
142
142
|
return '';
|
|
143
143
|
if (path === 'src/lib/db/schema.ts')
|
|
144
144
|
return '';
|
|
145
|
-
return
|
|
145
|
+
return undefined;
|
|
146
146
|
});
|
|
147
147
|
mockedExists.mockReturnValue(false);
|
|
148
148
|
const handler = server.tools.find((t) => t.name === 'codapult_db_status').handler;
|
|
@@ -157,7 +157,7 @@ export const user = sqliteTable('user', {
|
|
|
157
157
|
mockedReadProject.mockImplementation((_root, path) => {
|
|
158
158
|
if (path === 'src/lib/db/schema.ts')
|
|
159
159
|
return '';
|
|
160
|
-
return
|
|
160
|
+
return undefined;
|
|
161
161
|
});
|
|
162
162
|
mockedExists.mockReturnValue(false);
|
|
163
163
|
const handler = server.tools.find((t) => t.name === 'codapult_db_status').handler;
|
|
@@ -63,7 +63,7 @@ DATABASE_URL=sqlite://local.db
|
|
|
63
63
|
it(`returns error when ${ENV_EXAMPLE_FILE_NAME} not found`, () => {
|
|
64
64
|
const server = createMockServer();
|
|
65
65
|
registerEnvTools(server);
|
|
66
|
-
mockedReadProject.mockReturnValue(
|
|
66
|
+
mockedReadProject.mockReturnValue(undefined);
|
|
67
67
|
const handler = server.tools.find((t) => t.name === 'codapult_env_schema').handler;
|
|
68
68
|
const result = handler({});
|
|
69
69
|
expect(result.isError).toBe(true);
|
|
@@ -80,7 +80,7 @@ DATABASE_URL=sqlite://local.db
|
|
|
80
80
|
mockedReadProject.mockImplementation((_root, path) => {
|
|
81
81
|
if (path === ENV_EXAMPLE_FILE_NAME)
|
|
82
82
|
return envExample;
|
|
83
|
-
return
|
|
83
|
+
return undefined;
|
|
84
84
|
});
|
|
85
85
|
const handler = server.tools.find((t) => t.name === 'codapult_env_read').handler;
|
|
86
86
|
const result = handler({});
|
|
@@ -96,7 +96,7 @@ DATABASE_URL=sqlite://local.db
|
|
|
96
96
|
mockedReadProject.mockImplementation((_root, path) => {
|
|
97
97
|
if (path === ENV_EXAMPLE_FILE_NAME)
|
|
98
98
|
return `AUTH_PROVIDER=better-auth\nSTRIPE_SECRET_KEY=\nDATABASE_URL=\n`;
|
|
99
|
-
return
|
|
99
|
+
return undefined;
|
|
100
100
|
});
|
|
101
101
|
const handler = server.tools.find((t) => t.name === 'codapult_env_read').handler;
|
|
102
102
|
const result = handler({ env_source: 'process' });
|
|
@@ -106,7 +106,7 @@ DATABASE_URL=sqlite://local.db
|
|
|
106
106
|
it(`returns error when ${ENV_FILE_NAME} not found`, () => {
|
|
107
107
|
const server = createMockServer();
|
|
108
108
|
registerEnvTools(server);
|
|
109
|
-
mockedReadProject.mockReturnValue(
|
|
109
|
+
mockedReadProject.mockReturnValue(undefined);
|
|
110
110
|
const handler = server.tools.find((t) => t.name === 'codapult_env_read').handler;
|
|
111
111
|
const result = handler({});
|
|
112
112
|
expect(result.isError).toBe(true);
|
|
@@ -128,7 +128,7 @@ describe('registerProjectTools', () => {
|
|
|
128
128
|
it('returns fallback message when config not found', () => {
|
|
129
129
|
const server = createMockServer();
|
|
130
130
|
registerProjectTools(server);
|
|
131
|
-
mockedReadProject.mockReturnValue(
|
|
131
|
+
mockedReadProject.mockReturnValue(undefined);
|
|
132
132
|
const handler = server.tools.find((t) => t.name === 'codapult_project_config').handler;
|
|
133
133
|
const result = handler({});
|
|
134
134
|
expect(result.content[0].text).toContain('not found');
|
package/dist/utils/env-config.js
CHANGED
|
@@ -108,7 +108,7 @@ export function getOauthProviders(envContent) {
|
|
|
108
108
|
export function findProviderIssues(envContent) {
|
|
109
109
|
const issues = [];
|
|
110
110
|
const adapters = getAdapters(envContent);
|
|
111
|
-
const has = (k) => readEnvVar(envContent, k)
|
|
111
|
+
const has = (k) => readEnvVar(envContent, k) != null;
|
|
112
112
|
if (adapters.database === 'turso') {
|
|
113
113
|
if (!has('TURSO_DATABASE_URL')) {
|
|
114
114
|
issues.push({
|
package/dist/utils/manifest.d.ts
CHANGED
package/dist/utils/manifest.js
CHANGED
|
@@ -58,12 +58,12 @@ describe('resolveManifest', () => {
|
|
|
58
58
|
});
|
|
59
59
|
mockedRead.mockReturnValue(validManifest);
|
|
60
60
|
const result = resolveManifest(ROOT, 'bar');
|
|
61
|
-
expect(result).not.
|
|
61
|
+
expect(result).not.toBeNullable();
|
|
62
62
|
});
|
|
63
63
|
it('returns null when no manifest found', () => {
|
|
64
64
|
mockedExists.mockReturnValue(false);
|
|
65
65
|
const result = resolveManifest(ROOT, 'nonexistent');
|
|
66
|
-
expect(result).
|
|
66
|
+
expect(result).toBeNullable();
|
|
67
67
|
});
|
|
68
68
|
it('resolves manifest from .codapult/plugins/ cache directory', () => {
|
|
69
69
|
mockedExists.mockImplementation((p) => {
|
|
@@ -90,7 +90,7 @@ describe('resolveManifest', () => {
|
|
|
90
90
|
mockedExists.mockReturnValue(true);
|
|
91
91
|
mockedRead.mockReturnValue('not valid json {{{');
|
|
92
92
|
const result = resolveManifest(ROOT, 'broken');
|
|
93
|
-
expect(result).
|
|
93
|
+
expect(result).toBeNullable();
|
|
94
94
|
});
|
|
95
95
|
it('prioritizes direct path over sibling directories', () => {
|
|
96
96
|
mockedExists.mockImplementation((p) => {
|
package/dist/utils/patchers.js
CHANGED
|
@@ -64,7 +64,7 @@ function extractMarkedBlock(content, name) {
|
|
|
64
64
|
const startIdx = content.indexOf(start);
|
|
65
65
|
const endIdx = content.indexOf(end);
|
|
66
66
|
if (startIdx === -1 || endIdx === -1)
|
|
67
|
-
return
|
|
67
|
+
return undefined;
|
|
68
68
|
return content.slice(startIdx + start.length, endIdx);
|
|
69
69
|
}
|
|
70
70
|
function readPluginTables(pluginDir, tablesFile) {
|
|
@@ -75,7 +75,7 @@ function readPluginTables(pluginDir, tablesFile) {
|
|
|
75
75
|
throw new Error(`Path traversal detected: "${tablesFile}" resolves outside plugin directory`);
|
|
76
76
|
}
|
|
77
77
|
if (!existsSync(tablesPath))
|
|
78
|
-
return
|
|
78
|
+
return undefined;
|
|
79
79
|
let tables = readFileSync(tablesPath, 'utf-8');
|
|
80
80
|
// Strip import lines — host schema already has them
|
|
81
81
|
tables = tables.replace(/^import\s+.*;\s*\n/gm, '');
|
|
@@ -103,7 +103,7 @@ export function patchSchemaTables(projectRoot, pluginName, pluginDir, tablesFile
|
|
|
103
103
|
if (!hasMarker(content, pluginName))
|
|
104
104
|
return false;
|
|
105
105
|
const oldBlock = extractMarkedBlock(content, pluginName);
|
|
106
|
-
if (oldBlock
|
|
106
|
+
if (oldBlock?.trim() === tables)
|
|
107
107
|
return false;
|
|
108
108
|
content = removeMarkedBlock(content, pluginName);
|
|
109
109
|
}
|
|
@@ -311,7 +311,7 @@ const STUB_RE = /^\s*export\s*\{\s*default\s*\}\s*from\s*['"]([^'"]+)['"];?\s*$/
|
|
|
311
311
|
function parseStub(content) {
|
|
312
312
|
const match = STUB_RE.exec(content.trim());
|
|
313
313
|
if (!match)
|
|
314
|
-
return
|
|
314
|
+
return undefined;
|
|
315
315
|
return { exportFrom: match[1] };
|
|
316
316
|
}
|
|
317
317
|
function backupPathFor(filePath, pluginName) {
|
|
@@ -376,7 +376,7 @@ function collectConflictsForEntry(projectRoot, pagePath, exportFrom, extensions)
|
|
|
376
376
|
continue;
|
|
377
377
|
}
|
|
378
378
|
const stub = parseStub(content);
|
|
379
|
-
const isStub = stub
|
|
379
|
+
const isStub = stub != null;
|
|
380
380
|
const isOwnStub = isStub && (content === expectedStub || stub.exportFrom === exportFrom);
|
|
381
381
|
const isExactPath = ext === targetExt;
|
|
382
382
|
// Our own freshly-written stub is not a conflict. It's how idempotent
|
|
@@ -328,9 +328,9 @@ describe('patchPages', () => {
|
|
|
328
328
|
});
|
|
329
329
|
it('backs up a user-written page at a different extension before writing the stub', () => {
|
|
330
330
|
const pages = {
|
|
331
|
-
'src/app/[locale]/(marketing)/welcome/page.ts': '@codapult/plugin-onboarding/pages/welcome',
|
|
331
|
+
'src/app/[locale]/(public)/(marketing)/welcome/page.ts': '@codapult/plugin-onboarding/pages/welcome',
|
|
332
332
|
};
|
|
333
|
-
const userTsx = '/project/src/app/[locale]/(marketing)/welcome/page.tsx';
|
|
333
|
+
const userTsx = '/project/src/app/[locale]/(public)/(marketing)/welcome/page.tsx';
|
|
334
334
|
// Only the .tsx sibling exists on disk; no backup file yet.
|
|
335
335
|
mockedExists.mockImplementation((p) => p === userTsx);
|
|
336
336
|
mockedRead.mockReturnValue('export default function Welcome(): JSX.Element { return <div>old</div>; }');
|
|
@@ -13,7 +13,7 @@ export function getProjectEnvOptions(envSource) {
|
|
|
13
13
|
}
|
|
14
14
|
function serializeProcessEnv(env) {
|
|
15
15
|
return Object.entries(env)
|
|
16
|
-
.filter(([, value]) => value
|
|
16
|
+
.filter(([, value]) => value != null)
|
|
17
17
|
.map(([key, value]) => `${key}=${value}`)
|
|
18
18
|
.join('\n');
|
|
19
19
|
}
|
package/dist/utils/project.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Walk upward from cwd to find the Codapult project root
|
|
3
3
|
* (directory containing package.json with codapult-specific markers).
|
|
4
4
|
*/
|
|
5
|
-
export declare function findProjectRoot(from?: string): string |
|
|
5
|
+
export declare function findProjectRoot(from?: string): string | undefined;
|
|
6
6
|
/** Read and parse a JSON file, returning null on failure. */
|
|
7
|
-
export declare function readJsonFile(filePath: string): Record<string, unknown> |
|
|
7
|
+
export declare function readJsonFile(filePath: string): Record<string, unknown> | undefined;
|
|
8
8
|
/** Check if a file exists relative to the project root. */
|
|
9
9
|
export declare function projectFileExists(projectRoot: string, relativePath: string): boolean;
|
|
10
10
|
/** Read a file relative to the project root. */
|
|
11
|
-
export declare function readProjectFile(projectRoot: string, relativePath: string): string |
|
|
11
|
+
export declare function readProjectFile(projectRoot: string, relativePath: string): string | undefined;
|
package/dist/utils/project.js
CHANGED
|
@@ -25,7 +25,7 @@ export function findProjectRoot(from = process.cwd()) {
|
|
|
25
25
|
}
|
|
26
26
|
dir = dirname(dir);
|
|
27
27
|
}
|
|
28
|
-
return
|
|
28
|
+
return undefined;
|
|
29
29
|
}
|
|
30
30
|
/** Read and parse a JSON file, returning null on failure. */
|
|
31
31
|
export function readJsonFile(filePath) {
|
|
@@ -34,7 +34,7 @@ export function readJsonFile(filePath) {
|
|
|
34
34
|
return JSON.parse(content);
|
|
35
35
|
}
|
|
36
36
|
catch {
|
|
37
|
-
return
|
|
37
|
+
return undefined;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
/** Check if a file exists relative to the project root. */
|
|
@@ -45,6 +45,6 @@ export function projectFileExists(projectRoot, relativePath) {
|
|
|
45
45
|
export function readProjectFile(projectRoot, relativePath) {
|
|
46
46
|
const fullPath = resolve(projectRoot, relativePath);
|
|
47
47
|
if (!existsSync(fullPath))
|
|
48
|
-
return
|
|
48
|
+
return undefined;
|
|
49
49
|
return readFileSync(fullPath, 'utf-8');
|
|
50
50
|
}
|
|
@@ -48,7 +48,7 @@ describe('findProjectRoot', () => {
|
|
|
48
48
|
it('returns null when no project root found', () => {
|
|
49
49
|
mockedExists.mockReturnValue(false);
|
|
50
50
|
const root = findProjectRoot('/home/user/random');
|
|
51
|
-
expect(root).
|
|
51
|
+
expect(root).toBeNullable();
|
|
52
52
|
});
|
|
53
53
|
it('skips directories with invalid JSON in package.json', () => {
|
|
54
54
|
let callCount = 0;
|
|
@@ -82,14 +82,14 @@ describe('readJsonFile', () => {
|
|
|
82
82
|
it('returns null for invalid JSON', () => {
|
|
83
83
|
mockedRead.mockReturnValue('not json');
|
|
84
84
|
const result = readJsonFile('/some/file.json');
|
|
85
|
-
expect(result).
|
|
85
|
+
expect(result).toBeNullable();
|
|
86
86
|
});
|
|
87
87
|
it('returns null when file does not exist', () => {
|
|
88
88
|
mockedRead.mockImplementation(() => {
|
|
89
89
|
throw new Error('ENOENT');
|
|
90
90
|
});
|
|
91
91
|
const result = readJsonFile('/nonexistent.json');
|
|
92
|
-
expect(result).
|
|
92
|
+
expect(result).toBeNullable();
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
// ---------------------------------------------------------------------------
|
|
@@ -118,6 +118,6 @@ describe('readProjectFile', () => {
|
|
|
118
118
|
it('returns null when file does not exist', () => {
|
|
119
119
|
mockedExists.mockReturnValue(false);
|
|
120
120
|
const result = readProjectFile('/project', 'missing.ts');
|
|
121
|
-
expect(result).
|
|
121
|
+
expect(result).toBeNullable();
|
|
122
122
|
});
|
|
123
123
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codapult/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Codapult CLI — manage, update, and diagnose your Codapult SaaS project",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"packageManager": "pnpm@11.
|
|
6
|
+
"packageManager": "pnpm@11.15.0+sha512.266f8957a30d2be6e9468e5e66bcdedd35a794175f71b067ba8504d686cce1d0c0f429b33c323c3c569ad4891e667574a49ff71d1b89a22cc66f13c65818c578",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.19.0"
|
|
9
9
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
47
|
-
"commander": "^
|
|
47
|
+
"commander": "^15.0.0",
|
|
48
48
|
"picocolors": "^1.1.1",
|
|
49
49
|
"zod": "^4.4.3"
|
|
50
50
|
},
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
"@js-toolkit/eslint-config": "^1.1.4",
|
|
54
54
|
"@js-toolkit/prettier-config": "^1.0.1",
|
|
55
55
|
"@js-toolkit/tsconfig": "^1.0.1",
|
|
56
|
-
"@release-it/conventional-changelog": "^11.0.
|
|
57
|
-
"@types/node": "^
|
|
56
|
+
"@release-it/conventional-changelog": "^11.0.1",
|
|
57
|
+
"@types/node": "^26.1.1",
|
|
58
58
|
"eslint": "^9.39.4",
|
|
59
59
|
"eslint-config-prettier": "^10.1.8",
|
|
60
|
-
"eslint-plugin-prettier": "^5.5.
|
|
61
|
-
"prettier": "^3.
|
|
62
|
-
"release-it": "^20.
|
|
60
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
61
|
+
"prettier": "^3.9.5",
|
|
62
|
+
"release-it": "^20.2.1",
|
|
63
63
|
"typescript": "^6.0.3",
|
|
64
|
-
"typescript-eslint": "^8.
|
|
65
|
-
"vitest": "^4.1.
|
|
64
|
+
"typescript-eslint": "^8.64.0",
|
|
65
|
+
"vitest": "^4.1.10"
|
|
66
66
|
}
|
|
67
67
|
}
|