|
1 | 1 | import * as clack from '@clack/prompts'; |
2 | | -import { spawn } from 'node:child_process'; |
3 | 2 | import { realpathSync } from 'node:fs'; |
4 | 3 | import { basename, resolve } from 'node:path'; |
5 | 4 | import { fileURLToPath, pathToFileURL } from 'node:url'; |
6 | 5 | import { promptAppExtensions } from './prompts/appExtensions.js'; |
7 | 6 | import { promptDatabase } from './prompts/database.js'; |
8 | 7 | import { promptProjectName } from './prompts/projectName.js'; |
9 | | -import { promptWebhooks } from './prompts/webhooks.js'; |
10 | 8 | import { nodeGenerator } from './generators/node/index.js'; |
11 | | -import type { Database } from './generators/interface.js'; |
12 | 9 |
|
13 | 10 | interface NextStepOptions { |
14 | 11 | nameOrPath: string; |
15 | | - database: Database; |
16 | | - installDeps: boolean; |
17 | | - hasAppExtensions: boolean; |
18 | 12 | } |
19 | 13 |
|
20 | 14 | export function nextStepLines(options: NextStepOptions): string[] { |
21 | | - const needsDocker = options.database === 'postgres' || options.database === 'mysql'; |
22 | | - const runWithCompose = options.hasAppExtensions; |
23 | | - |
24 | | - const steps = [`cd ${options.nameOrPath}`, 'cp .env.example .env']; |
25 | | - |
26 | | - if (runWithCompose) { |
27 | | - steps.push('docker-compose up --watch'); |
28 | | - } else { |
29 | | - if (needsDocker) steps.push('docker-compose up -d db'); |
30 | | - if (!options.installDeps) steps.push('npm install'); |
31 | | - steps.push('npm run dev'); |
32 | | - } |
| 15 | + const steps = [ |
| 16 | + `cd ${options.nameOrPath}`, |
| 17 | + 'cp .env.example .env', |
| 18 | + '# fill in PIPEDRIVE_CLIENT_ID and PIPEDRIVE_CLIENT_SECRET', |
| 19 | + 'docker compose up', |
| 20 | + ]; |
33 | 21 |
|
34 | 22 | return ['', 'Next steps:', ...steps.map((s) => ` ${s}`)]; |
35 | 23 | } |
@@ -62,39 +50,20 @@ async function main(): Promise<void> { |
62 | 50 | const nameOrPath = await promptProjectName(process.argv[2]); |
63 | 51 | const database = await promptDatabase(); |
64 | 52 | const appExtensions = await promptAppExtensions(); |
65 | | - const webhooks = await promptWebhooks(); |
66 | 53 |
|
67 | 54 | const outputDir = resolve(process.cwd(), nameOrPath); |
68 | 55 | const projectName = basename(outputDir); |
69 | 56 |
|
70 | 57 | try { |
71 | | - await nodeGenerator.generate(outputDir, { projectName, database, appExtensions, webhooks }); |
| 58 | + await nodeGenerator.generate(outputDir, { projectName, database, appExtensions }); |
72 | 59 | } catch (error) { |
73 | 60 | clack.log.error(`Generation failed: ${error instanceof Error ? error.message : String(error)}`); |
74 | 61 | process.exit(1); |
75 | 62 | } |
76 | 63 |
|
77 | 64 | clack.outro(`✓ Created ${projectName}`); |
78 | 65 |
|
79 | | - const installDeps = await clack.confirm({ message: 'Install dependencies now?' }); |
80 | | - if (clack.isCancel(installDeps)) process.exit(0); |
81 | | - |
82 | | - if (installDeps) { |
83 | | - const spinner = clack.spinner(); |
84 | | - spinner.start('Installing dependencies'); |
85 | | - const ok = await new Promise<boolean>((resolve) => { |
86 | | - const child = spawn('npm', ['install'], { cwd: outputDir, stdio: 'ignore' }); |
87 | | - child.on('close', (code) => resolve(code === 0)); |
88 | | - }); |
89 | | - spinner.stop(ok ? 'Dependencies installed' : 'npm install failed — run it manually'); |
90 | | - } |
91 | | - |
92 | | - printNextSteps({ |
93 | | - nameOrPath, |
94 | | - database, |
95 | | - installDeps: Boolean(installDeps), |
96 | | - hasAppExtensions: appExtensions.length > 0, |
97 | | - }); |
| 66 | + printNextSteps({ nameOrPath }); |
98 | 67 | } |
99 | 68 |
|
100 | 69 | if (isCliEntrypoint(import.meta.url, process.argv[1])) { |
|
0 commit comments