@@ -12,13 +12,6 @@ import {
12
12
type EnvVariable ,
13
13
} from "../project-generation/env-setup" ;
14
14
15
- type NeonConfig = {
16
- connectionString : string ;
17
- projectId : string ;
18
- dbName : string ;
19
- roleName : string ;
20
- } ;
21
-
22
15
type NeonRegion = {
23
16
label : string ;
24
17
value : string ;
@@ -100,13 +93,13 @@ async function createNeonProject(
100
93
}
101
94
}
102
95
103
- async function writeEnvFile ( projectDir : string , config ?: NeonConfig ) {
96
+ async function writeEnvFile ( projectDir : string , connectionString ?: string ) {
104
97
const envPath = path . join ( projectDir , "apps/server" , ".env" ) ;
105
98
const variables : EnvVariable [ ] = [
106
99
{
107
100
key : "DATABASE_URL" ,
108
101
value :
109
- config ?. connectionString ??
102
+ connectionString ??
110
103
"postgresql://postgres:postgres@localhost:5432/mydb?schema=public" ,
111
104
condition : true ,
112
105
} ,
@@ -174,6 +167,11 @@ export async function setupNeonPostgres(config: ProjectConfig) {
174
167
value : "neonctl" ,
175
168
hint : "More control - choose project name and region" ,
176
169
} ,
170
+ {
171
+ label : "Manual setup" ,
172
+ value : "manual" ,
173
+ hint : "Enter connection string manually" ,
174
+ }
177
175
] ,
178
176
initialValue : "neondb" ,
179
177
} ) ;
@@ -182,7 +180,7 @@ export async function setupNeonPostgres(config: ProjectConfig) {
182
180
183
181
if ( setupMethod === "neondb" ) {
184
182
await setupWithNeonDb ( projectDir , packageManager ) ;
185
- } else {
183
+ } else if ( setupMethod === 'neonctl' ) {
186
184
const suggestedProjectName = path . basename ( projectDir ) ;
187
185
const projectName = await text ( {
188
186
message : "Enter a name for your Neon project:" ,
@@ -215,9 +213,21 @@ export async function setupNeonPostgres(config: ProjectConfig) {
215
213
finalSpinner . start ( "Configuring database connection" ) ;
216
214
217
215
await fs . ensureDir ( path . join ( projectDir , "apps/server" ) ) ;
218
- await writeEnvFile ( projectDir , neonConfig ) ;
216
+ await writeEnvFile ( projectDir , neonConfig . connectionString ) ;
219
217
220
218
finalSpinner . stop ( "Neon database configured!" ) ;
219
+ } else if ( setupMethod === "manual" ) {
220
+ const connectionString = await text ( {
221
+ message : "Enter your Neon connection string:" ,
222
+ validate ( value ) {
223
+ if ( ! value ) return "Please enter a connection string" ;
224
+ } ,
225
+ } ) ;
226
+
227
+ if ( isCancel ( connectionString ) ) return exitCancelled ( "Operation cancelled" ) ;
228
+
229
+ await fs . ensureDir ( path . join ( projectDir , "apps/server" ) ) ;
230
+ await writeEnvFile ( projectDir , connectionString ) ;
221
231
}
222
232
} catch ( error ) {
223
233
if ( error instanceof Error ) {
0 commit comments