@codapult/cli 0.10.0 → 0.10.2

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.
@@ -3,27 +3,13 @@ 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
- }
23
- async function selectPrompt(iface, question, options) {
6
+ import { heading, success, fail, info, dim, ask, confirm } from '../utils/ui.js';
7
+ async function selectPrompt(iface, question, options, lastEmptyLine = false) {
24
8
  console.log(`\n ${question}`);
25
9
  options.forEach((opt, i) => console.log(` ${i + 1}. ${opt}`));
26
10
  const answer = await ask(iface, 'Choose', '1');
11
+ if (lastEmptyLine)
12
+ console.log();
27
13
  const idx = parseInt(answer, 10) - 1;
28
14
  return options[Math.max(0, Math.min(idx, options.length - 1))];
29
15
  }
@@ -605,60 +591,53 @@ function removeModules(root, config) {
605
591
  pruneMarkedBlocksInFiles(root, config);
606
592
  }
607
593
  async function interactiveSetup() {
608
- const iface = rl();
594
+ const iface = createInterface({ input: process.stdin, output: process.stdout });
609
595
  heading('Codapult Setup');
610
596
  info('This wizard will configure your project.\n');
611
- const authProvider = (await selectPrompt(iface, 'Auth provider:', [
597
+ const appName = await ask(iface, 'App name', 'Codapult');
598
+ const appUrl = await ask(iface, 'App URL', 'http://localhost:3000');
599
+ const authProvider = await selectPrompt(iface, 'Auth provider:', [
612
600
  'better-auth',
613
601
  'kinde',
614
602
  'none',
615
- ]));
603
+ ]);
616
604
  const authEnabled = authProvider !== 'none';
617
605
  const config = {
618
- appName: await ask(iface, 'App name', 'Codapult'),
619
- appUrl: await ask(iface, 'App URL', 'http://localhost:3000'),
606
+ appName,
607
+ appUrl,
620
608
  authProvider,
621
- paymentProvider: (await selectPrompt(iface, 'Payment provider:', [
622
- 'stripe',
623
- 'lemonsqueezy',
624
- ])),
625
- storageProvider: (await selectPrompt(iface, 'Storage provider:', [
626
- 'local',
627
- 's3',
628
- ])),
629
- jobProvider: (await selectPrompt(iface, 'Background jobs:', [
630
- 'memory',
631
- 'bullmq',
632
- ])),
609
+ paymentProvider: await selectPrompt(iface, 'Payment provider:', ['stripe', 'lemonsqueezy']),
610
+ storageProvider: await selectPrompt(iface, 'Storage provider:', ['local', 's3']),
611
+ jobProvider: await selectPrompt(iface, 'Background jobs:', ['memory', 'bullmq'], true),
633
612
  enableAuth: authEnabled,
634
- enableAI: await confirmPrompt(iface, 'Enable AI Chat module?'),
635
- enableBlog: await confirmPrompt(iface, 'Enable Blog module?'),
636
- enableTeams: authEnabled && (await confirmPrompt(iface, 'Enable Teams/Organizations?')),
637
- enableWaitlist: await confirmPrompt(iface, 'Enable Waitlist page?'),
638
- enableGraphQL: await confirmPrompt(iface, 'Enable GraphQL API layer?'),
639
- enableSSO: authEnabled && (await confirmPrompt(iface, 'Enable Enterprise SSO (SAML)?')),
640
- enableApiDocs: await confirmPrompt(iface, 'Enable interactive API docs?'),
641
- enableHelpCenter: await confirmPrompt(iface, 'Enable Documentation module?'),
642
- enableExperiments: await confirmPrompt(iface, 'Enable A/B Testing?'),
643
- enableFeatureRequests: await confirmPrompt(iface, 'Enable Feature Request board?'),
644
- enableCompare: await confirmPrompt(iface, 'Enable competitor comparison pages (/compare)?', false),
645
- enableConnect: authEnabled && (await confirmPrompt(iface, 'Enable Stripe Connect (marketplace)?')),
646
- enableEventStore: await confirmPrompt(iface, 'Enable Event Store (event sourcing)?'),
647
- enableOtel: await confirmPrompt(iface, 'Enable OpenTelemetry tracing?'),
648
- enableDripCampaigns: await confirmPrompt(iface, 'Enable email drip campaigns?'),
649
- enableOnboarding: authEnabled && (await confirmPrompt(iface, 'Enable in-app onboarding tours?')),
650
- enableWorkflows: authEnabled && (await confirmPrompt(iface, 'Enable workflow automation?')),
651
- enableReferrals: authEnabled && (await confirmPrompt(iface, 'Enable referral program?')),
652
- enableAnalytics: await confirmPrompt(iface, 'Enable built-in analytics?'),
653
- enableChangelog: await confirmPrompt(iface, 'Enable Changelog page?'),
654
- enableRAG: await confirmPrompt(iface, 'Enable RAG pipeline (vector search)?'),
655
- enableWebhooks: authEnabled && (await confirmPrompt(iface, 'Enable outgoing webhooks?')),
656
- enableAuditLog: authEnabled && (await confirmPrompt(iface, 'Enable audit log / activity feed?')),
657
- enableReports: authEnabled && (await confirmPrompt(iface, 'Enable scheduled email reports?')),
658
- enableBranding: authEnabled && (await confirmPrompt(iface, 'Enable per-org branding (white-label)?')),
659
- enableTwoFactor: authEnabled && (await confirmPrompt(iface, 'Enable two-factor authentication (TOTP)?')),
660
- enablePlugins: await confirmPrompt(iface, 'Enable plugin marketplace (/plugins)?'),
661
- removeUnusedCode: await confirmPrompt(iface, 'Remove unused module code?', false),
613
+ enableAI: await confirm(iface, 'Enable AI Chat module?'),
614
+ enableBlog: await confirm(iface, 'Enable Blog module?'),
615
+ enableTeams: authEnabled && (await confirm(iface, 'Enable Teams/Organizations?')),
616
+ enableWaitlist: await confirm(iface, 'Enable Waitlist page?'),
617
+ enableGraphQL: await confirm(iface, 'Enable GraphQL API layer?'),
618
+ enableSSO: authEnabled && (await confirm(iface, 'Enable Enterprise SSO (SAML)?')),
619
+ enableApiDocs: await confirm(iface, 'Enable interactive API docs?'),
620
+ enableHelpCenter: await confirm(iface, 'Enable Documentation module?'),
621
+ enableExperiments: await confirm(iface, 'Enable A/B Testing?'),
622
+ enableFeatureRequests: await confirm(iface, 'Enable Feature Request board?'),
623
+ enableCompare: await confirm(iface, 'Enable competitor comparison pages (/compare)?', false),
624
+ enableConnect: authEnabled && (await confirm(iface, 'Enable Stripe Connect (marketplace)?')),
625
+ enableEventStore: await confirm(iface, 'Enable Event Store (event sourcing)?'),
626
+ enableOtel: await confirm(iface, 'Enable OpenTelemetry tracing?'),
627
+ enableDripCampaigns: await confirm(iface, 'Enable email drip campaigns?'),
628
+ enableOnboarding: authEnabled && (await confirm(iface, 'Enable in-app onboarding tours?')),
629
+ enableWorkflows: authEnabled && (await confirm(iface, 'Enable workflow automation?')),
630
+ enableReferrals: authEnabled && (await confirm(iface, 'Enable referral program?')),
631
+ enableAnalytics: await confirm(iface, 'Enable built-in analytics?'),
632
+ enableChangelog: await confirm(iface, 'Enable Changelog page?'),
633
+ enableRAG: await confirm(iface, 'Enable RAG pipeline (vector search)?'),
634
+ enableWebhooks: authEnabled && (await confirm(iface, 'Enable outgoing webhooks?')),
635
+ enableAuditLog: authEnabled && (await confirm(iface, 'Enable audit log / activity feed?')),
636
+ enableReports: authEnabled && (await confirm(iface, 'Enable scheduled email reports?')),
637
+ enableBranding: authEnabled && (await confirm(iface, 'Enable per-org branding (white-label)?')),
638
+ enableTwoFactor: authEnabled && (await confirm(iface, 'Enable two-factor authentication (TOTP)?')),
639
+ enablePlugins: await confirm(iface, 'Enable plugin marketplace (/plugins)?'),
640
+ removeUnusedCode: await confirm(iface, '\nRemove unused module code?', false),
662
641
  };
663
642
  iface.close();
664
643
  return config;
@@ -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
- /** Prompt yes/no. Returns default when stdin is not a TTY (piped / CI). */
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(question, defaultYes = true) {
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 = createInterface({ input: process.stdin, output: process.stdout });
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
- return new Promise((resolve) => {
51
- rl.question(` ${question} [${hint}]: `, (answer) => {
52
- rl.close();
53
- if (!answer.trim()) {
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codapult/cli",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Codapult CLI — manage, update, and diagnose your Codapult SaaS project",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@11.6.0",