@codapult/cli 0.10.0 → 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 +40 -60
- 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}`));
|
|
@@ -605,60 +589,56 @@ function removeModules(root, config) {
|
|
|
605
589
|
pruneMarkedBlocksInFiles(root, config);
|
|
606
590
|
}
|
|
607
591
|
async function interactiveSetup() {
|
|
608
|
-
const iface =
|
|
592
|
+
const iface = createInterface({ input: process.stdin, output: process.stdout });
|
|
609
593
|
heading('Codapult Setup');
|
|
610
594
|
info('This wizard will configure your project.\n');
|
|
611
|
-
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:', [
|
|
612
598
|
'better-auth',
|
|
613
599
|
'kinde',
|
|
614
600
|
'none',
|
|
615
|
-
])
|
|
601
|
+
]);
|
|
616
602
|
const authEnabled = authProvider !== 'none';
|
|
617
603
|
const config = {
|
|
618
|
-
appName
|
|
619
|
-
appUrl
|
|
604
|
+
appName,
|
|
605
|
+
appUrl,
|
|
620
606
|
authProvider,
|
|
621
|
-
paymentProvider:
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
])),
|
|
625
|
-
storageProvider: (await selectPrompt(iface, 'Storage provider:', [
|
|
626
|
-
'local',
|
|
627
|
-
's3',
|
|
628
|
-
])),
|
|
629
|
-
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:', [
|
|
630
610
|
'memory',
|
|
631
611
|
'bullmq',
|
|
632
|
-
])
|
|
612
|
+
]),
|
|
633
613
|
enableAuth: authEnabled,
|
|
634
|
-
enableAI: await
|
|
635
|
-
enableBlog: await
|
|
636
|
-
enableTeams: authEnabled && (await
|
|
637
|
-
enableWaitlist: await
|
|
638
|
-
enableGraphQL: await
|
|
639
|
-
enableSSO: authEnabled && (await
|
|
640
|
-
enableApiDocs: await
|
|
641
|
-
enableHelpCenter: await
|
|
642
|
-
enableExperiments: await
|
|
643
|
-
enableFeatureRequests: await
|
|
644
|
-
enableCompare: await
|
|
645
|
-
enableConnect: authEnabled && (await
|
|
646
|
-
enableEventStore: await
|
|
647
|
-
enableOtel: await
|
|
648
|
-
enableDripCampaigns: await
|
|
649
|
-
enableOnboarding: authEnabled && (await
|
|
650
|
-
enableWorkflows: authEnabled && (await
|
|
651
|
-
enableReferrals: authEnabled && (await
|
|
652
|
-
enableAnalytics: await
|
|
653
|
-
enableChangelog: await
|
|
654
|
-
enableRAG: await
|
|
655
|
-
enableWebhooks: authEnabled && (await
|
|
656
|
-
enableAuditLog: authEnabled && (await
|
|
657
|
-
enableReports: authEnabled && (await
|
|
658
|
-
enableBranding: authEnabled && (await
|
|
659
|
-
enableTwoFactor: authEnabled && (await
|
|
660
|
-
enablePlugins: await
|
|
661
|
-
removeUnusedCode: 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),
|
|
662
642
|
};
|
|
663
643
|
iface.close();
|
|
664
644
|
return config;
|
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
|
}
|