neon 2.47.0 → 3.1.0
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/README.md +54 -0
- package/dist/_shared/auth_selection.js +76 -79
- package/dist/_shared/credentials.js +166 -187
- package/dist/_shared/env-core/env.js +395 -0
- package/dist/_shared/env-core/reuse-secrets.js +179 -0
- package/dist/_shared/paths.js +129 -126
- package/dist/_shared/profiles.js +192 -242
- package/dist/_shared/secure_file.js +36 -38
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/analytics.js +163 -207
- package/dist/api.js +815 -758
- package/dist/auth.js +121 -141
- package/dist/auth_context.js +39 -53
- package/dist/cli.js +4 -7
- package/dist/commands/api.js +220 -250
- package/dist/commands/api_keys.js +251 -314
- package/dist/commands/auth.js +283 -328
- package/dist/commands/bootstrap.js +372 -437
- package/dist/commands/branches.js +304 -455
- package/dist/commands/bucket.js +374 -514
- package/dist/commands/checkout.js +213 -298
- package/dist/commands/config.js +575 -658
- package/dist/commands/connection_string.js +137 -165
- package/dist/commands/data_api.js +238 -260
- package/dist/commands/databases.js +67 -76
- package/dist/commands/deploy.js +31 -25
- package/dist/commands/dev.js +642 -681
- package/dist/commands/diff.js +156 -200
- package/dist/commands/env.js +243 -303
- package/dist/commands/functions.js +275 -341
- package/dist/commands/index.js +70 -65
- package/dist/commands/init.js +84 -119
- package/dist/commands/inspect.js +55 -55
- package/dist/commands/ip_allow.js +88 -120
- package/dist/commands/link.js +874 -1019
- package/dist/commands/logs.js +291 -0
- package/dist/commands/neon_auth.js +725 -933
- package/dist/commands/operations.js +34 -25
- package/dist/commands/orgs.js +28 -18
- package/dist/commands/profile.js +614 -845
- package/dist/commands/projects.js +313 -373
- package/dist/commands/psql.js +60 -58
- package/dist/commands/roles.js +55 -58
- package/dist/commands/schema_diff.js +87 -131
- package/dist/commands/set_context.js +34 -26
- package/dist/commands/snapshots.js +288 -413
- package/dist/commands/status.js +41 -37
- package/dist/commands/user.js +21 -10
- package/dist/commands/vpc_endpoints.js +85 -113
- package/dist/config.js +7 -6
- package/dist/config_format.js +50 -66
- package/dist/config_template.js +128 -157
- package/dist/context.js +183 -235
- package/dist/current_branch_fast_path.js +40 -49
- package/dist/dev/env.js +313 -394
- package/dist/dev/functions.js +54 -64
- package/dist/dev/inputs.js +46 -58
- package/dist/dev/runtime.js +135 -164
- package/dist/dev/websocket.js +766 -959
- package/dist/env.js +27 -33
- package/dist/env_file.js +118 -132
- package/dist/env_services.js +36 -38
- package/dist/errors.js +57 -68
- package/dist/functions_api.js +45 -43
- package/dist/help.js +189 -140
- package/dist/index.js +182 -257
- package/dist/init/agents.js +137 -118
- package/dist/init/auth.js +58 -68
- package/dist/init/bootstrap.js +325 -396
- package/dist/init/build_config.js +4 -2
- package/dist/init/detect_agent.js +56 -101
- package/dist/init/editors.js +35 -52
- package/dist/init/enrich_output.js +51 -66
- package/dist/init/extension.js +134 -171
- package/dist/init/inspect.js +179 -266
- package/dist/init/interactive.js +510 -622
- package/dist/init/neonctl.js +117 -168
- package/dist/init/orchestrate.js +157 -173
- package/dist/init/phases/auth.js +188 -202
- package/dist/init/phases/cleanup.js +23 -23
- package/dist/init/phases/db.js +251 -277
- package/dist/init/phases/getting_started.js +213 -223
- package/dist/init/phases/mcp.js +174 -224
- package/dist/init/phases/migrations.js +247 -248
- package/dist/init/phases/neon_auth.js +114 -133
- package/dist/init/phases/setup.js +546 -703
- package/dist/init/phases/skills.js +75 -86
- package/dist/init/phases/status.js +72 -67
- package/dist/init/resolve_context.js +102 -99
- package/dist/init/route_command.js +91 -98
- package/dist/init/skills.js +174 -218
- package/dist/init/vsix.js +77 -99
- package/dist/log.js +17 -16
- package/dist/neon_services.js +104 -129
- package/dist/parameters.gen.js +481 -471
- package/dist/pkg.js +17 -19
- package/dist/profile_keys.js +44 -47
- package/dist/psql/cli.js +44 -47
- package/dist/psql/command/cmd_cond.js +231 -406
- package/dist/psql/command/cmd_connect.js +557 -764
- package/dist/psql/command/cmd_copy.js +727 -983
- package/dist/psql/command/cmd_describe.js +1499 -1688
- package/dist/psql/command/cmd_format.js +733 -905
- package/dist/psql/command/cmd_io.js +1293 -2082
- package/dist/psql/command/cmd_lo.js +297 -359
- package/dist/psql/command/cmd_meta.js +727 -878
- package/dist/psql/command/cmd_misc.js +138 -172
- package/dist/psql/command/cmd_pipeline.js +547 -1099
- package/dist/psql/command/cmd_restrict.js +119 -155
- package/dist/psql/command/cmd_show.js +529 -688
- package/dist/psql/command/dispatch.js +261 -325
- package/dist/psql/command/inputQueue.js +35 -33
- package/dist/psql/command/shared.js +49 -63
- package/dist/psql/complete/filenames.js +90 -133
- package/dist/psql/complete/index.js +59 -97
- package/dist/psql/complete/matcher.js +236 -300
- package/dist/psql/complete/psqlVars.js +218 -223
- package/dist/psql/complete/queries.js +159 -177
- package/dist/psql/complete/rules.js +1493 -2299
- package/dist/psql/core/common.js +762 -1180
- package/dist/psql/core/help.js +456 -546
- package/dist/psql/core/mainloop.js +692 -1302
- package/dist/psql/core/prompt.js +391 -408
- package/dist/psql/core/settings.js +429 -644
- package/dist/psql/core/sqlHelp.js +480 -554
- package/dist/psql/core/startup.js +626 -815
- package/dist/psql/core/syncVars.js +67 -110
- package/dist/psql/core/variables.js +156 -278
- package/dist/psql/describe/formatters.js +884 -1285
- package/dist/psql/describe/processNamePattern.js +173 -260
- package/dist/psql/describe/queries.js +1368 -2403
- package/dist/psql/describe/versionGate.js +32 -41
- package/dist/psql/index.js +1414 -1927
- package/dist/psql/io/history.js +232 -271
- package/dist/psql/io/input.js +103 -108
- package/dist/psql/io/lineEditor/buffer.js +238 -319
- package/dist/psql/io/lineEditor/complete.js +135 -213
- package/dist/psql/io/lineEditor/filename.js +139 -148
- package/dist/psql/io/lineEditor/index.js +653 -870
- package/dist/psql/io/lineEditor/keymap.js +544 -702
- package/dist/psql/io/lineEditor/vt100.js +294 -341
- package/dist/psql/io/pgpass.js +158 -187
- package/dist/psql/io/pgservice.js +146 -183
- package/dist/psql/io/psqlrc.js +328 -403
- package/dist/psql/print/aligned.js +1020 -1683
- package/dist/psql/print/asciidoc.js +180 -214
- package/dist/psql/print/crosstab.js +281 -442
- package/dist/psql/print/csv.js +48 -70
- package/dist/psql/print/html.js +195 -226
- package/dist/psql/print/json.js +75 -88
- package/dist/psql/print/latex.js +291 -364
- package/dist/psql/print/pager.js +171 -242
- package/dist/psql/print/troff.js +194 -226
- package/dist/psql/print/unaligned.js +69 -95
- package/dist/psql/print/units.js +167 -169
- package/dist/psql/scanner/slash.js +428 -483
- package/dist/psql/scanner/sql.js +445 -889
- package/dist/psql/scanner/stringutils.js +309 -379
- package/dist/psql/types/index.js +2 -7
- package/dist/psql/types/scanner.js +25 -22
- package/dist/psql/wire/connection.js +2042 -2803
- package/dist/psql/wire/copy.js +84 -100
- package/dist/psql/wire/notify.js +39 -59
- package/dist/psql/wire/pipeline.js +305 -518
- package/dist/psql/wire/protocol.js +349 -417
- package/dist/psql/wire/sasl.js +180 -265
- package/dist/psql/wire/tls.js +400 -561
- package/dist/storage_api.js +115 -129
- package/dist/test_utils/fixtures.js +94 -113
- package/dist/test_utils/oauth_server.js +10 -7
- package/dist/test_utils/project_dir.js +33 -0
- package/dist/utils/ai_gateway_notice.js +131 -162
- package/dist/utils/api_enums.js +21 -28
- package/dist/utils/auth.js +10 -4
- package/dist/utils/branch_notice.js +20 -19
- package/dist/utils/branch_picker.js +83 -89
- package/dist/utils/cli_name.js +15 -12
- package/dist/utils/compute_units.js +20 -27
- package/dist/utils/config_diff.js +127 -158
- package/dist/utils/enrichers.js +95 -148
- package/dist/utils/esbuild.js +133 -147
- package/dist/utils/flags.js +35 -47
- package/dist/utils/formats.js +8 -15
- package/dist/utils/git_diff.js +69 -80
- package/dist/utils/inspect_db.js +101 -143
- package/dist/utils/inspect_queries.js +179 -142
- package/dist/utils/middlewares.js +37 -44
- package/dist/utils/openapi.js +87 -99
- package/dist/utils/package_manager.js +312 -110
- package/dist/utils/point_in_time.js +49 -53
- package/dist/utils/psql.js +89 -106
- package/dist/utils/service_picker.js +55 -58
- package/dist/utils/string.js +5 -5
- package/dist/utils/ui.js +38 -55
- package/dist/utils/write_sync.js +26 -35
- package/dist/utils/zip.js +4 -3
- package/dist/writer.js +67 -87
- package/package.json +9 -7
|
@@ -1,228 +1,218 @@
|
|
|
1
|
+
import { DO_NOT_SUBSTITUTE_HINT, MISSING_BINARY_HINT, formatExecCommand, formatInstallCommand, resolvePackageManager } from "../../utils/package_manager.js";
|
|
1
2
|
import { neonctlCmd } from "../neonctl.js";
|
|
2
|
-
import {
|
|
3
|
+
import { SKILL_REFERENCE_URLS, ensureSkillsUpToDate } from "../skills.js";
|
|
4
|
+
//#region src/init/phases/getting_started.ts
|
|
3
5
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// Verify the connection
|
|
192
|
-
steps.push({
|
|
193
|
-
id: "verify_connection",
|
|
194
|
-
description: [
|
|
195
|
-
"Verify the database connection works by running a SQL query against the Neon database.",
|
|
196
|
-
"Write and run a short script that connects using DATABASE_URL from the project's env file and executes `SELECT 1` (or queries a table from the migration if migrations were run).",
|
|
197
|
-
"Do NOT use the Neon CLI or MCP tools for this — use a direct database connection to verify end-to-end connectivity.",
|
|
198
|
-
].join(" "),
|
|
199
|
-
});
|
|
200
|
-
return {
|
|
201
|
-
phase: "setup",
|
|
202
|
-
status: "getting_started",
|
|
203
|
-
nextAction: {
|
|
204
|
-
type: "agent_action",
|
|
205
|
-
prerequisite: SKILL_REFERENCE_URLS.gettingStarted,
|
|
206
|
-
steps,
|
|
207
|
-
onComplete: buildOnComplete(options),
|
|
208
|
-
},
|
|
209
|
-
};
|
|
6
|
+
* Initiates the "Get started with Neon" workflow.
|
|
7
|
+
*
|
|
8
|
+
* Steps are concrete and executable — each has a CLI command to run
|
|
9
|
+
* or a specific file operation. The agent should attempt each step
|
|
10
|
+
* in order and actually perform the action using the Neon CLI.
|
|
11
|
+
*/
|
|
12
|
+
async function handleGettingStartedPhase(options) {
|
|
13
|
+
if (options.agent) await ensureSkillsUpToDate(options.agent);
|
|
14
|
+
const steps = [];
|
|
15
|
+
const installPm = resolvePackageManager(options.cwd);
|
|
16
|
+
if (!options.hasConnectionString) {
|
|
17
|
+
if (options.preview) steps.push({
|
|
18
|
+
id: "select_org",
|
|
19
|
+
description: [
|
|
20
|
+
"List the user's Neon organizations using the CLI command below.",
|
|
21
|
+
"If only one org exists, use it automatically.",
|
|
22
|
+
"If multiple orgs exist, ask the user which one to use.",
|
|
23
|
+
"Remember the selected org ID for the next steps."
|
|
24
|
+
].join(" "),
|
|
25
|
+
command: `${neonctlCmd()} orgs list --output json`
|
|
26
|
+
}, {
|
|
27
|
+
id: "select_or_create_project",
|
|
28
|
+
description: [
|
|
29
|
+
"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).",
|
|
30
|
+
"IMPORTANT: Neon features (Functions, Object Storage, and AI Gateway) are currently in beta and only available in the AWS us-east-2 region (more regions coming shortly). Projects must have region_id 'aws-us-east-2' and be created on or after 2026-06-15.",
|
|
31
|
+
"Filter the project list to ONLY show projects where region_id is 'aws-us-east-2' AND created_at is on or after '2026-06-15'.",
|
|
32
|
+
"If eligible projects exist, present them alongside a 'Create new project' option.",
|
|
33
|
+
"If no eligible projects exist, tell the user and proceed directly to creating a new one.",
|
|
34
|
+
"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts."
|
|
35
|
+
].join(" "),
|
|
36
|
+
command: `${neonctlCmd()} projects list --org-id <org-id> --output json`
|
|
37
|
+
}, {
|
|
38
|
+
id: "create_project_if_needed",
|
|
39
|
+
description: [
|
|
40
|
+
"If the user chose to create a new project, create it in the AWS us-east-2 region using the CLI command below (replace <org-id> and <project-name>).",
|
|
41
|
+
"Ask the user for a project name (suggest the current directory name).",
|
|
42
|
+
"If the user chose an existing eligible project, skip this step."
|
|
43
|
+
].join(" "),
|
|
44
|
+
command: `${neonctlCmd()} projects create --name <project-name> --org-id <org-id> --region-id aws-us-east-2 --output json`
|
|
45
|
+
});
|
|
46
|
+
else steps.push({
|
|
47
|
+
id: "select_org",
|
|
48
|
+
description: [
|
|
49
|
+
"List the user's Neon organizations using the CLI command below.",
|
|
50
|
+
"If only one org exists, use it automatically.",
|
|
51
|
+
"If multiple orgs exist, ask the user which one to use.",
|
|
52
|
+
"Remember the selected org ID for the next steps."
|
|
53
|
+
].join(" "),
|
|
54
|
+
command: `${neonctlCmd()} orgs list --output json`
|
|
55
|
+
}, {
|
|
56
|
+
id: "select_or_create_project",
|
|
57
|
+
description: [
|
|
58
|
+
"List existing Neon projects in the selected organization using the CLI command below (replace <org-id> with the selected org ID).",
|
|
59
|
+
"Ask the user whether they want to use an existing project or create a new one.",
|
|
60
|
+
"If creating new, ask the user for a project name (suggest the current directory name).",
|
|
61
|
+
"IMPORTANT: Always include --org-id when creating a project to avoid interactive prompts."
|
|
62
|
+
].join(" "),
|
|
63
|
+
command: `${neonctlCmd()} projects list --org-id <org-id> --output json`
|
|
64
|
+
}, {
|
|
65
|
+
id: "create_project_if_needed",
|
|
66
|
+
description: ["If the user chose to create a new project, create it using the CLI command below (replace <org-id> and <project-name>).", "If the user chose an existing project, skip this step."].join(" "),
|
|
67
|
+
command: `${neonctlCmd()} projects create --name <project-name> --org-id <org-id> --output json`
|
|
68
|
+
});
|
|
69
|
+
steps.push({
|
|
70
|
+
id: "create_neon_context",
|
|
71
|
+
description: [
|
|
72
|
+
"Update the .neon context file in the project root with the selected org and project IDs.",
|
|
73
|
+
"IMPORTANT: If a .neon file already exists, you MUST read it first, then merge the new orgId and projectId into the existing content. Do NOT overwrite the file — other fields (like _init, branch, etc.) must be preserved.",
|
|
74
|
+
"If no .neon file exists, create one.",
|
|
75
|
+
"The file is JSON. Add/update only the orgId and projectId fields: {\"orgId\": \"<org-id>\", \"projectId\": \"<project-id>\", ...existing fields}.",
|
|
76
|
+
"This file is safe to commit — it contains no secrets."
|
|
77
|
+
].join(" ")
|
|
78
|
+
});
|
|
79
|
+
steps.push({
|
|
80
|
+
id: "install_dependencies",
|
|
81
|
+
description: [
|
|
82
|
+
"Check if node_modules exists in the project root. If not, install the project's dependencies.",
|
|
83
|
+
DO_NOT_SUBSTITUTE_HINT,
|
|
84
|
+
"This must be done before `neon env pull` because the project's Neon config file may import packages that need to be installed first."
|
|
85
|
+
].join(" "),
|
|
86
|
+
command: formatInstallCommand(installPm)
|
|
87
|
+
});
|
|
88
|
+
steps.push({
|
|
89
|
+
id: "pull_env",
|
|
90
|
+
description: [
|
|
91
|
+
"Now that the .neon context file is in place and dependencies are installed, run `neon env pull` to populate the project's environment variables.",
|
|
92
|
+
"This automatically writes the database connection string (and any other Neon-managed env vars) to the correct env file.",
|
|
93
|
+
"It reads the .neon context file to determine the project, and writes to the appropriate env file for the project.",
|
|
94
|
+
"Ensure the target env file is listed in .gitignore."
|
|
95
|
+
].join(" "),
|
|
96
|
+
command: `${neonctlCmd()} env pull`
|
|
97
|
+
});
|
|
98
|
+
if (options.orm === "prisma") steps.push({
|
|
99
|
+
id: "install_driver",
|
|
100
|
+
description: [
|
|
101
|
+
"Install the @neondatabase/serverless driver adapter for Prisma.",
|
|
102
|
+
"This enables Prisma to use Neon's serverless driver for edge/serverless deployments.",
|
|
103
|
+
DO_NOT_SUBSTITUTE_HINT
|
|
104
|
+
].join(" "),
|
|
105
|
+
command: formatInstallCommand(installPm, ["@neondatabase/serverless", "@prisma/adapter-neon"])
|
|
106
|
+
});
|
|
107
|
+
else if (options.orm === "drizzle" || options.orm === "drizzle-orm") steps.push({
|
|
108
|
+
id: "install_driver",
|
|
109
|
+
description: `Install the Neon serverless driver for Drizzle. ${DO_NOT_SUBSTITUTE_HINT}`,
|
|
110
|
+
command: formatInstallCommand(installPm, ["@neondatabase/serverless"])
|
|
111
|
+
});
|
|
112
|
+
else if (!options.orm || options.orm === "none") steps.push({
|
|
113
|
+
id: "install_driver",
|
|
114
|
+
description: `Install the Neon serverless driver for direct database access. ${DO_NOT_SUBSTITUTE_HINT}`,
|
|
115
|
+
command: formatInstallCommand(installPm, ["@neondatabase/serverless"])
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (options.migrationTool && options.migrationTool !== "none") {
|
|
119
|
+
const tool = options.migrationTool.toLowerCase();
|
|
120
|
+
const migrationDir = options.migrationDir;
|
|
121
|
+
const hasMigrationDir = migrationDir && migrationDir !== "none";
|
|
122
|
+
if (tool === "drizzle") {
|
|
123
|
+
const migrate = formatExecCommand(installPm, "drizzle-kit", ["migrate"]);
|
|
124
|
+
const generate = formatExecCommand(installPm, "drizzle-kit", ["generate"]);
|
|
125
|
+
steps.push({
|
|
126
|
+
id: "run_migrations",
|
|
127
|
+
description: [
|
|
128
|
+
hasMigrationDir ? `Check if the ${migrationDir} directory contains .sql migration files.` : "Check if a drizzle migrations directory exists with .sql files.",
|
|
129
|
+
`If .sql files exist, apply them with \`${migrate}\`.`,
|
|
130
|
+
`If the directory is empty or missing but a drizzle schema file exists (e.g. src/db/schema.ts, drizzle/schema.ts), run \`${generate}\` first to create migrations, then \`${migrate}\` to apply them.`,
|
|
131
|
+
"If neither schema nor migrations exist, skip this step.",
|
|
132
|
+
MISSING_BINARY_HINT
|
|
133
|
+
].join(" "),
|
|
134
|
+
command: migrate
|
|
135
|
+
});
|
|
136
|
+
} else if (tool === "prisma") {
|
|
137
|
+
const deploy = formatExecCommand(installPm, "prisma", ["migrate", "deploy"]);
|
|
138
|
+
steps.push({
|
|
139
|
+
id: "run_migrations",
|
|
140
|
+
description: [
|
|
141
|
+
hasMigrationDir ? `Check if the ${migrationDir} directory contains migration folders.` : "Check if prisma/migrations contains migration folders.",
|
|
142
|
+
`If migrations exist, apply them with \`${deploy}\`.`,
|
|
143
|
+
`If the migrations directory is empty or missing but prisma/schema.prisma has models defined, run \`${formatExecCommand(installPm, "prisma", [
|
|
144
|
+
"migrate",
|
|
145
|
+
"dev",
|
|
146
|
+
"--name",
|
|
147
|
+
"init"
|
|
148
|
+
])}\` to create and apply the initial migration.`,
|
|
149
|
+
"If no models are defined, skip this step.",
|
|
150
|
+
MISSING_BINARY_HINT
|
|
151
|
+
].join(" "),
|
|
152
|
+
command: deploy
|
|
153
|
+
});
|
|
154
|
+
} else if (tool === "knex") steps.push({
|
|
155
|
+
id: "run_migrations",
|
|
156
|
+
description: `Apply existing knex migrations to the Neon database. ${MISSING_BINARY_HINT}`,
|
|
157
|
+
command: formatExecCommand(installPm, "knex", ["migrate:latest"])
|
|
158
|
+
});
|
|
159
|
+
} else if (options.preview) steps.push({
|
|
160
|
+
id: "run_migrations",
|
|
161
|
+
description: [
|
|
162
|
+
"Check the scaffolded project for a migration tool and schema.",
|
|
163
|
+
"Look for: drizzle.config.ts/js (Drizzle), prisma/schema.prisma (Prisma), or knexfile.ts/js (Knex).",
|
|
164
|
+
`If Drizzle is found: check if a drizzle migrations directory exists with .sql files. If .sql files exist, run \`${formatExecCommand(installPm, "drizzle-kit", ["migrate"])}\`. If the directory is empty or missing but a schema file exists, run \`${formatExecCommand(installPm, "drizzle-kit", ["generate"])}\` first, then \`${formatExecCommand(installPm, "drizzle-kit", ["migrate"])}\`.`,
|
|
165
|
+
`If Prisma is found: check if prisma/migrations contains migration folders. If yes, run \`${formatExecCommand(installPm, "prisma", ["migrate", "deploy"])}\`. If not but models exist, run \`${formatExecCommand(installPm, "prisma", [
|
|
166
|
+
"migrate",
|
|
167
|
+
"dev",
|
|
168
|
+
"--name",
|
|
169
|
+
"init"
|
|
170
|
+
])}\`.`,
|
|
171
|
+
"If no migration tool is found, skip this step.",
|
|
172
|
+
MISSING_BINARY_HINT
|
|
173
|
+
].join(" ")
|
|
174
|
+
});
|
|
175
|
+
steps.push({
|
|
176
|
+
id: "verify_connection",
|
|
177
|
+
description: [
|
|
178
|
+
"Verify the database connection works by running a SQL query against the Neon database.",
|
|
179
|
+
"Write and run a short script that connects using DATABASE_URL from the project's env file and executes `SELECT 1` (or queries a table from the migration if migrations were run).",
|
|
180
|
+
"Do NOT use the Neon CLI or MCP tools for this — use a direct database connection to verify end-to-end connectivity."
|
|
181
|
+
].join(" ")
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
phase: "setup",
|
|
185
|
+
status: "getting_started",
|
|
186
|
+
nextAction: {
|
|
187
|
+
type: "agent_action",
|
|
188
|
+
prerequisite: SKILL_REFERENCE_URLS.gettingStarted,
|
|
189
|
+
steps,
|
|
190
|
+
onComplete: buildOnComplete(options)
|
|
191
|
+
}
|
|
192
|
+
};
|
|
210
193
|
}
|
|
211
194
|
function buildOnComplete(options) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
195
|
+
const agentArgs = options.agent ? ["--agent", options.agent] : [];
|
|
196
|
+
const features = options.features ?? [];
|
|
197
|
+
const hasFeatureRequirements = features.length > 0;
|
|
198
|
+
if (hasFeatureRequirements && !features.includes("auth")) return {
|
|
199
|
+
type: "run_neon_init",
|
|
200
|
+
args: [
|
|
201
|
+
"finalize",
|
|
202
|
+
"--json",
|
|
203
|
+
...agentArgs
|
|
204
|
+
]
|
|
205
|
+
};
|
|
206
|
+
const authSetup = hasFeatureRequirements && features.includes("auth") ? ["--setup"] : [];
|
|
207
|
+
return {
|
|
208
|
+
type: "run_neon_init",
|
|
209
|
+
args: [
|
|
210
|
+
"neon-auth",
|
|
211
|
+
"--json",
|
|
212
|
+
...agentArgs,
|
|
213
|
+
...authSetup
|
|
214
|
+
]
|
|
215
|
+
};
|
|
228
216
|
}
|
|
217
|
+
//#endregion
|
|
218
|
+
export { handleGettingStartedPhase };
|