@codapult/cli 0.9.5 → 0.10.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.
- package/dist/commands/setup.js +54 -70
- package/dist/utils/ui.d.ts +3 -1
- package/dist/utils/ui.js +17 -12
- package/package.json +1 -1
package/dist/commands/setup.js
CHANGED
|
@@ -3,23 +3,7 @@ import { resolve, relative, join } from 'node:path';
|
|
|
3
3
|
import { createInterface } from 'node:readline';
|
|
4
4
|
import { findProjectRoot } from '../utils/project.js';
|
|
5
5
|
import { ENV_EXAMPLE_FILE_NAME, ENV_FILE_NAME, } from '../utils/project-env.js';
|
|
6
|
-
import { heading, success, fail, info, dim } from '../utils/ui.js';
|
|
7
|
-
const rl = () => createInterface({ input: process.stdin, output: process.stdout });
|
|
8
|
-
function ask(iface, question, defaultValue) {
|
|
9
|
-
const suffix = defaultValue ? ` (${defaultValue})` : '';
|
|
10
|
-
return new Promise((res) => {
|
|
11
|
-
iface.question(` ${question}${suffix}: `, (answer) => {
|
|
12
|
-
res(answer.trim() || defaultValue || '');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
async function confirmPrompt(iface, question, defaultYes = true) {
|
|
17
|
-
const hint = defaultYes ? 'Y/n' : 'y/N';
|
|
18
|
-
const answer = await ask(iface, `${question} [${hint}]`);
|
|
19
|
-
if (!answer)
|
|
20
|
-
return defaultYes;
|
|
21
|
-
return answer.toLowerCase().startsWith('y');
|
|
22
|
-
}
|
|
6
|
+
import { heading, success, fail, info, dim, ask, confirm } from '../utils/ui.js';
|
|
23
7
|
async function selectPrompt(iface, question, options) {
|
|
24
8
|
console.log(`\n ${question}`);
|
|
25
9
|
options.forEach((opt, i) => console.log(` ${i + 1}. ${opt}`));
|
|
@@ -31,8 +15,7 @@ async function selectPrompt(iface, question, options) {
|
|
|
31
15
|
// Built-in presets for non-interactive (CI/CD) setup via --preset flag.
|
|
32
16
|
// ---------------------------------------------------------------------------
|
|
33
17
|
const BUILT_IN_PRESETS = {
|
|
34
|
-
// Showcase / marketing-only site
|
|
35
|
-
// `enableHelpCenter` stays true (powers /docs).
|
|
18
|
+
// Showcase / marketing-only site.
|
|
36
19
|
marketing: {
|
|
37
20
|
authProvider: 'none',
|
|
38
21
|
enableAuth: false,
|
|
@@ -51,17 +34,19 @@ const BUILT_IN_PRESETS = {
|
|
|
51
34
|
enableDripCampaigns: false,
|
|
52
35
|
enableApiDocs: false,
|
|
53
36
|
enableChangelog: false,
|
|
54
|
-
enableBlog: true,
|
|
55
37
|
enableWaitlist: false,
|
|
56
38
|
enableFeatureRequests: false,
|
|
57
|
-
enableCompare: true,
|
|
58
39
|
enableWebhooks: false,
|
|
59
40
|
enableAuditLog: false,
|
|
60
41
|
enableReports: false,
|
|
61
42
|
enableBranding: false,
|
|
62
43
|
enableTwoFactor: false,
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
enableGraphQL: false,
|
|
45
|
+
enableHelpCenter: true,
|
|
46
|
+
enableBlog: true,
|
|
47
|
+
enablePlugins: true,
|
|
48
|
+
enableCompare: true,
|
|
49
|
+
removeUnusedCode: true,
|
|
65
50
|
},
|
|
66
51
|
demo: {
|
|
67
52
|
authProvider: 'better-auth',
|
|
@@ -102,6 +87,7 @@ const DEFAULT_CONFIG = {
|
|
|
102
87
|
enableBranding: true,
|
|
103
88
|
enableTwoFactor: true,
|
|
104
89
|
enablePlugins: true,
|
|
90
|
+
removeUnusedCode: false,
|
|
105
91
|
};
|
|
106
92
|
function parsePresetValue(raw) {
|
|
107
93
|
const parts = raw
|
|
@@ -476,6 +462,8 @@ const FEATURE_ENV_VARS = {
|
|
|
476
462
|
enableTwoFactor: 'ENABLE_TWO_FACTOR',
|
|
477
463
|
enablePlugins: 'ENABLE_PLUGINS',
|
|
478
464
|
};
|
|
465
|
+
// codapult:prune:start {key}
|
|
466
|
+
// codapult:prune:end {key}
|
|
479
467
|
const PRUNE_MARKER_FILES = [
|
|
480
468
|
'src/app/sitemap.ts',
|
|
481
469
|
'src/app/sitemap.test.ts',
|
|
@@ -601,63 +589,57 @@ function removeModules(root, config) {
|
|
|
601
589
|
pruneMarkedBlocksInFiles(root, config);
|
|
602
590
|
}
|
|
603
591
|
async function interactiveSetup() {
|
|
604
|
-
const iface =
|
|
592
|
+
const iface = createInterface({ input: process.stdin, output: process.stdout });
|
|
605
593
|
heading('Codapult Setup');
|
|
606
594
|
info('This wizard will configure your project.\n');
|
|
607
|
-
const
|
|
595
|
+
const appName = await ask(iface, 'App name', 'Codapult');
|
|
596
|
+
const appUrl = await ask(iface, 'App URL', 'http://localhost:3000');
|
|
597
|
+
const authProvider = await selectPrompt(iface, 'Auth provider:', [
|
|
608
598
|
'better-auth',
|
|
609
599
|
'kinde',
|
|
610
600
|
'none',
|
|
611
|
-
])
|
|
601
|
+
]);
|
|
612
602
|
const authEnabled = authProvider !== 'none';
|
|
613
603
|
const config = {
|
|
614
|
-
appName
|
|
615
|
-
appUrl
|
|
604
|
+
appName,
|
|
605
|
+
appUrl,
|
|
616
606
|
authProvider,
|
|
617
|
-
paymentProvider:
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
])),
|
|
621
|
-
storageProvider: (await selectPrompt(iface, 'Storage provider:', [
|
|
622
|
-
'local',
|
|
623
|
-
's3',
|
|
624
|
-
])),
|
|
625
|
-
jobProvider: (await selectPrompt(iface, 'Background jobs:', [
|
|
607
|
+
paymentProvider: await selectPrompt(iface, 'Payment provider:', ['stripe', 'lemonsqueezy']),
|
|
608
|
+
storageProvider: await selectPrompt(iface, 'Storage provider:', ['local', 's3']),
|
|
609
|
+
jobProvider: await selectPrompt(iface, 'Background jobs:', [
|
|
626
610
|
'memory',
|
|
627
611
|
'bullmq',
|
|
628
|
-
])
|
|
612
|
+
]),
|
|
629
613
|
enableAuth: authEnabled,
|
|
630
|
-
enableAI: await
|
|
631
|
-
enableBlog: await
|
|
632
|
-
enableTeams: authEnabled && (await
|
|
633
|
-
enableWaitlist: await
|
|
634
|
-
enableGraphQL: await
|
|
635
|
-
enableSSO: authEnabled && (await
|
|
636
|
-
enableApiDocs: await
|
|
637
|
-
enableHelpCenter: await
|
|
638
|
-
enableExperiments: await
|
|
639
|
-
enableFeatureRequests: await
|
|
640
|
-
enableCompare: false,
|
|
641
|
-
enableConnect: authEnabled && (await
|
|
642
|
-
enableEventStore: await
|
|
643
|
-
enableOtel: await
|
|
644
|
-
enableDripCampaigns: await
|
|
645
|
-
enableOnboarding: authEnabled && (await
|
|
646
|
-
enableWorkflows: authEnabled && (await
|
|
647
|
-
enableReferrals: authEnabled && (await
|
|
648
|
-
enableAnalytics: await
|
|
649
|
-
enableChangelog: await
|
|
650
|
-
enableRAG: await
|
|
651
|
-
enableWebhooks: authEnabled && (await
|
|
652
|
-
enableAuditLog: authEnabled && (await
|
|
653
|
-
enableReports: authEnabled && (await
|
|
654
|
-
enableBranding: authEnabled && (await
|
|
655
|
-
enableTwoFactor: authEnabled && (await
|
|
656
|
-
enablePlugins: await
|
|
614
|
+
enableAI: await confirm(iface, '\nEnable AI Chat module?'),
|
|
615
|
+
enableBlog: await confirm(iface, 'Enable Blog module?'),
|
|
616
|
+
enableTeams: authEnabled && (await confirm(iface, 'Enable Teams/Organizations?')),
|
|
617
|
+
enableWaitlist: await confirm(iface, 'Enable Waitlist page?'),
|
|
618
|
+
enableGraphQL: await confirm(iface, 'Enable GraphQL API layer?'),
|
|
619
|
+
enableSSO: authEnabled && (await confirm(iface, 'Enable Enterprise SSO (SAML)?')),
|
|
620
|
+
enableApiDocs: await confirm(iface, 'Enable interactive API docs?'),
|
|
621
|
+
enableHelpCenter: await confirm(iface, 'Enable Documentation module?'),
|
|
622
|
+
enableExperiments: await confirm(iface, 'Enable A/B Testing?'),
|
|
623
|
+
enableFeatureRequests: await confirm(iface, 'Enable Feature Request board?'),
|
|
624
|
+
enableCompare: await confirm(iface, 'Enable competitor comparison pages (/compare)?', false),
|
|
625
|
+
enableConnect: authEnabled && (await confirm(iface, 'Enable Stripe Connect (marketplace)?')),
|
|
626
|
+
enableEventStore: await confirm(iface, 'Enable Event Store (event sourcing)?'),
|
|
627
|
+
enableOtel: await confirm(iface, 'Enable OpenTelemetry tracing?'),
|
|
628
|
+
enableDripCampaigns: await confirm(iface, 'Enable email drip campaigns?'),
|
|
629
|
+
enableOnboarding: authEnabled && (await confirm(iface, 'Enable in-app onboarding tours?')),
|
|
630
|
+
enableWorkflows: authEnabled && (await confirm(iface, 'Enable workflow automation?')),
|
|
631
|
+
enableReferrals: authEnabled && (await confirm(iface, 'Enable referral program?')),
|
|
632
|
+
enableAnalytics: await confirm(iface, 'Enable built-in analytics?'),
|
|
633
|
+
enableChangelog: await confirm(iface, 'Enable Changelog page?'),
|
|
634
|
+
enableRAG: await confirm(iface, 'Enable RAG pipeline (vector search)?'),
|
|
635
|
+
enableWebhooks: authEnabled && (await confirm(iface, 'Enable outgoing webhooks?')),
|
|
636
|
+
enableAuditLog: authEnabled && (await confirm(iface, 'Enable audit log / activity feed?')),
|
|
637
|
+
enableReports: authEnabled && (await confirm(iface, 'Enable scheduled email reports?')),
|
|
638
|
+
enableBranding: authEnabled && (await confirm(iface, 'Enable per-org branding (white-label)?')),
|
|
639
|
+
enableTwoFactor: authEnabled && (await confirm(iface, 'Enable two-factor authentication (TOTP)?')),
|
|
640
|
+
enablePlugins: await confirm(iface, 'Enable plugin marketplace (/plugins)?'),
|
|
641
|
+
removeUnusedCode: await confirm(iface, '\nRemove unused module code?', false),
|
|
657
642
|
};
|
|
658
|
-
if (await confirmPrompt(iface, 'Remove unused module code?', false)) {
|
|
659
|
-
return config;
|
|
660
|
-
}
|
|
661
643
|
iface.close();
|
|
662
644
|
return config;
|
|
663
645
|
}
|
|
@@ -684,8 +666,10 @@ export async function setupCommand(options) {
|
|
|
684
666
|
else {
|
|
685
667
|
generateEnvFile(root, config);
|
|
686
668
|
}
|
|
687
|
-
|
|
688
|
-
|
|
669
|
+
if (config.removeUnusedCode) {
|
|
670
|
+
heading('Removing unused modules');
|
|
671
|
+
removeModules(root, config);
|
|
672
|
+
}
|
|
689
673
|
heading('Setting up MCP integration');
|
|
690
674
|
generateMcpConfig(root);
|
|
691
675
|
heading('Done!');
|
package/dist/utils/ui.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createInterface } from 'node:readline';
|
|
1
2
|
export declare const symbols: {
|
|
2
3
|
readonly check: string;
|
|
3
4
|
readonly cross: string;
|
|
@@ -14,5 +15,6 @@ export declare function info(text: string): void;
|
|
|
14
15
|
export declare function dim(text: string): void;
|
|
15
16
|
export declare function label(key: string, value: string): void;
|
|
16
17
|
export declare function table(rows: [string, string, string?][]): void;
|
|
17
|
-
|
|
18
|
+
export declare function ask(iface: ReturnType<typeof createInterface>, question: string, defaultValue?: string): Promise<string>;
|
|
18
19
|
export declare function confirm(question: string, defaultYes?: boolean): Promise<boolean>;
|
|
20
|
+
export declare function confirm(iface: ReturnType<typeof createInterface>, question: string, defaultYes?: boolean): Promise<boolean>;
|
package/dist/utils/ui.js
CHANGED
|
@@ -40,21 +40,26 @@ export function table(rows) {
|
|
|
40
40
|
console.log(` ${key.padEnd(maxKey)} ${value.padEnd(maxVal)} ${statusStr}`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
export function ask(iface, question, defaultValue) {
|
|
44
|
+
const suffix = defaultValue ? ` (${defaultValue})` : '';
|
|
45
|
+
return new Promise((res) => {
|
|
46
|
+
iface.question(` ${question}${suffix}: `, (answer) => {
|
|
47
|
+
res(answer.trim() || defaultValue || '');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
43
51
|
/** Prompt yes/no. Returns default when stdin is not a TTY (piped / CI). */
|
|
44
|
-
export function confirm(
|
|
52
|
+
export async function confirm(ifaceOrQuestion, questionOrDefault, defaultYes_) {
|
|
53
|
+
const defaultYes = (typeof questionOrDefault !== 'string' ? questionOrDefault : defaultYes_) ?? true;
|
|
45
54
|
if (!process.stdin.isTTY) {
|
|
46
55
|
return Promise.resolve(defaultYes);
|
|
47
56
|
}
|
|
48
|
-
const rl
|
|
57
|
+
const [rl, question, closeRl] = typeof ifaceOrQuestion === 'string'
|
|
58
|
+
? [createInterface({ input: process.stdin, output: process.stdout }), ifaceOrQuestion, true]
|
|
59
|
+
: [ifaceOrQuestion, String(questionOrDefault), false];
|
|
49
60
|
const hint = defaultYes ? 'Y/n' : 'y/N';
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
resolve(defaultYes);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
resolve(answer.trim().toLowerCase().startsWith('y'));
|
|
58
|
-
});
|
|
59
|
-
});
|
|
61
|
+
const answer = await ask(rl, `${question} [${hint}]`);
|
|
62
|
+
if (closeRl)
|
|
63
|
+
rl.close();
|
|
64
|
+
return !answer ? defaultYes : answer.toLowerCase().startsWith('y');
|
|
60
65
|
}
|