@depup/vercel 50.32.5-depup.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/LICENSE +202 -0
- package/README.md +38 -0
- package/changes.json +38 -0
- package/dist/chunks/chunk-2DLBVZWU.js +197 -0
- package/dist/chunks/chunk-2HSQ7YUK.js +93 -0
- package/dist/chunks/chunk-2IQTNMUG.js +86 -0
- package/dist/chunks/chunk-3FRG2XGZ.js +466 -0
- package/dist/chunks/chunk-3KMKI2FP.js +34 -0
- package/dist/chunks/chunk-3XFFP2BA.js +110 -0
- package/dist/chunks/chunk-4S3Y3ATR.js +5383 -0
- package/dist/chunks/chunk-7EHTK7LP.js +359 -0
- package/dist/chunks/chunk-7YHZDJ4G.js +116 -0
- package/dist/chunks/chunk-A3NYPUKZ.js +17 -0
- package/dist/chunks/chunk-AA7QEJFB.js +5204 -0
- package/dist/chunks/chunk-AHU7WNL2.js +24 -0
- package/dist/chunks/chunk-AKQZ7KG3.js +4172 -0
- package/dist/chunks/chunk-AQLVWVEN.js +39155 -0
- package/dist/chunks/chunk-BQ3DXZNT.js +968 -0
- package/dist/chunks/chunk-E65JE2CC.js +102 -0
- package/dist/chunks/chunk-EKPSCRJZ.js +26 -0
- package/dist/chunks/chunk-EOZFDJSY.js +18 -0
- package/dist/chunks/chunk-FDJURQMQ.js +4676 -0
- package/dist/chunks/chunk-FLKHKWZV.js +1854 -0
- package/dist/chunks/chunk-G6BUEBF5.js +192 -0
- package/dist/chunks/chunk-GBNIO3KP.js +771 -0
- package/dist/chunks/chunk-GGP5R3FU.js +129 -0
- package/dist/chunks/chunk-H5XJSH37.js +91 -0
- package/dist/chunks/chunk-IB5L4LKZ.js +1082 -0
- package/dist/chunks/chunk-IE7MNZ56.js +149 -0
- package/dist/chunks/chunk-IK7DLK2T.js +16112 -0
- package/dist/chunks/chunk-IUGPWINM.js +104 -0
- package/dist/chunks/chunk-J7HDA5GH.js +54 -0
- package/dist/chunks/chunk-JLYZNGYY.js +293 -0
- package/dist/chunks/chunk-JQ4NA5MX.js +250 -0
- package/dist/chunks/chunk-LL26LVRR.js +81 -0
- package/dist/chunks/chunk-LW5ZNGW7.js +127 -0
- package/dist/chunks/chunk-LWBSOTJP.js +1772 -0
- package/dist/chunks/chunk-MBGJBHYD.js +388 -0
- package/dist/chunks/chunk-NUKAG3YM.js +168 -0
- package/dist/chunks/chunk-O7I4ZOCC.js +58 -0
- package/dist/chunks/chunk-OWR3XNE3.js +48 -0
- package/dist/chunks/chunk-P3SKP5WM.js +27 -0
- package/dist/chunks/chunk-P4I4DMEU.js +342 -0
- package/dist/chunks/chunk-P5Q6F5IA.js +107 -0
- package/dist/chunks/chunk-PMSMUMUO.js +30 -0
- package/dist/chunks/chunk-QXRJ52T4.js +2977 -0
- package/dist/chunks/chunk-RQXPRFRM.js +90 -0
- package/dist/chunks/chunk-S7KYDPEM.js +1564 -0
- package/dist/chunks/chunk-SGGLJFUZ.js +68 -0
- package/dist/chunks/chunk-SOTR4CXR.js +34 -0
- package/dist/chunks/chunk-TEVP63TU.js +1717 -0
- package/dist/chunks/chunk-TNBMKNET.js +323 -0
- package/dist/chunks/chunk-TZ2YI2VH.js +87 -0
- package/dist/chunks/chunk-U6XOC6E4.js +903 -0
- package/dist/chunks/chunk-V5P25P7F.js +22 -0
- package/dist/chunks/chunk-WQ5CUZWR.js +333 -0
- package/dist/chunks/chunk-WU2BPWRP.js +12237 -0
- package/dist/chunks/chunk-XPKWKPWA.js +44 -0
- package/dist/chunks/chunk-XR53KVJD.js +33 -0
- package/dist/chunks/chunk-Y4JJYHUG.js +16 -0
- package/dist/chunks/chunk-YPQSDAEW.js +29 -0
- package/dist/chunks/chunk-ZB2UO4V2.js +135 -0
- package/dist/chunks/chunk-ZLCMHY2G.js +1528 -0
- package/dist/chunks/compile-vercel-config-XU3YY2CZ.js +32 -0
- package/dist/chunks/delete-EJ2V7KQO.js +144 -0
- package/dist/chunks/disable-BKRFMX4U.js +122 -0
- package/dist/chunks/discard-4WF34DXK.js +118 -0
- package/dist/chunks/edit-FQE7JGU3.js +509 -0
- package/dist/chunks/emit-flags-datafiles-QYKPNWPX.js +17 -0
- package/dist/chunks/enable-VCNMX63U.js +122 -0
- package/dist/chunks/export-3KNVJCQR.js +133 -0
- package/dist/chunks/list-43XQCGKH.js +382 -0
- package/dist/chunks/list-DUL6PHUR.js +394 -0
- package/dist/chunks/publish-CF7GVZK3.js +128 -0
- package/dist/chunks/query-KWKO7VWO.js +954 -0
- package/dist/chunks/reorder-GU65YMIN.js +259 -0
- package/dist/chunks/restore-Q7ENGWVJ.js +158 -0
- package/dist/chunks/routes-Q5CWG44T.js +20 -0
- package/dist/chunks/schema-PJKLO2K2.js +176 -0
- package/dist/chunks/stamp-RTPE2EBB.js +15 -0
- package/dist/chunks/types-563KUQRV.js +108 -0
- package/dist/chunks/update-route-version-E3V47KNI.js +13 -0
- package/dist/commands/build/index.js +1597 -0
- package/dist/commands/deploy/index.js +1711 -0
- package/dist/commands/dev/builder-worker.cjs +95 -0
- package/dist/commands/dev/index.js +20810 -0
- package/dist/commands/env/index.js +2154 -0
- package/dist/commands/link/index.js +225 -0
- package/dist/commands/list/index.js +528 -0
- package/dist/commands-bulk.js +29627 -0
- package/dist/get-latest-worker.cjs +272 -0
- package/dist/help.js +14 -0
- package/dist/index.js +24274 -0
- package/dist/vc.js +36 -0
- package/dist/version.mjs +1 -0
- package/package.json +254 -0
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import {
|
|
8
|
+
getLocalPathConfig
|
|
9
|
+
} from "./chunk-OWR3XNE3.js";
|
|
10
|
+
import {
|
|
11
|
+
compileVercelConfig
|
|
12
|
+
} from "./chunk-MBGJBHYD.js";
|
|
13
|
+
import {
|
|
14
|
+
VERCEL_DIR_PROJECT,
|
|
15
|
+
VERCEL_DIR_README,
|
|
16
|
+
checkExistsAndConnect,
|
|
17
|
+
createProject,
|
|
18
|
+
detectProjects,
|
|
19
|
+
getLinkedProject,
|
|
20
|
+
getProjectByNameOrId,
|
|
21
|
+
getVercelDirectory,
|
|
22
|
+
humanizePath,
|
|
23
|
+
isDirectory,
|
|
24
|
+
linkFolderToProject,
|
|
25
|
+
parseGitConfig,
|
|
26
|
+
pluckRemoteUrls,
|
|
27
|
+
readJSONFile,
|
|
28
|
+
require_frameworks,
|
|
29
|
+
require_lib,
|
|
30
|
+
require_slugify,
|
|
31
|
+
selectAndParseRemoteUrl,
|
|
32
|
+
selectOrg,
|
|
33
|
+
tryDetectServices
|
|
34
|
+
} from "./chunk-AQLVWVEN.js";
|
|
35
|
+
import {
|
|
36
|
+
table
|
|
37
|
+
} from "./chunk-LWBSOTJP.js";
|
|
38
|
+
import {
|
|
39
|
+
CantParseJSONFile,
|
|
40
|
+
ProjectNotFound,
|
|
41
|
+
isAPIError,
|
|
42
|
+
printError
|
|
43
|
+
} from "./chunk-ZLCMHY2G.js";
|
|
44
|
+
import {
|
|
45
|
+
output_manager_default
|
|
46
|
+
} from "./chunk-FDJURQMQ.js";
|
|
47
|
+
import {
|
|
48
|
+
require_source
|
|
49
|
+
} from "./chunk-S7KYDPEM.js";
|
|
50
|
+
import {
|
|
51
|
+
__toESM
|
|
52
|
+
} from "./chunk-TZ2YI2VH.js";
|
|
53
|
+
|
|
54
|
+
// src/util/validate-paths.ts
|
|
55
|
+
var import_fs_extra = __toESM(require_lib(), 1);
|
|
56
|
+
var import_chalk = __toESM(require_source(), 1);
|
|
57
|
+
import { homedir } from "os";
|
|
58
|
+
async function validateRootDirectory(cwd, path2, errorSuffix = "") {
|
|
59
|
+
const pathStat = await (0, import_fs_extra.lstat)(path2).catch(() => null);
|
|
60
|
+
const suffix = errorSuffix ? ` ${errorSuffix}` : "";
|
|
61
|
+
if (!pathStat) {
|
|
62
|
+
output_manager_default.error(
|
|
63
|
+
`The provided path ${import_chalk.default.cyan(
|
|
64
|
+
`\u201C${humanizePath(path2)}\u201D`
|
|
65
|
+
)} does not exist.${suffix}`
|
|
66
|
+
);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (!pathStat.isDirectory()) {
|
|
70
|
+
output_manager_default.error(
|
|
71
|
+
`The provided path ${import_chalk.default.cyan(
|
|
72
|
+
`\u201C${humanizePath(path2)}\u201D`
|
|
73
|
+
)} is a file, but expected a directory.${suffix}`
|
|
74
|
+
);
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!path2.startsWith(cwd)) {
|
|
78
|
+
output_manager_default.error(
|
|
79
|
+
`The provided path ${import_chalk.default.cyan(
|
|
80
|
+
`\u201C${humanizePath(path2)}\u201D`
|
|
81
|
+
)} is outside of the project.${suffix}`
|
|
82
|
+
);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
async function validatePaths(client, paths) {
|
|
88
|
+
if (paths.length > 1) {
|
|
89
|
+
output_manager_default.error(`Can't deploy more than one path.`);
|
|
90
|
+
return { valid: false, exitCode: 1 };
|
|
91
|
+
}
|
|
92
|
+
const path2 = paths[0];
|
|
93
|
+
const pathStat = await (0, import_fs_extra.lstat)(path2).catch(() => null);
|
|
94
|
+
if (!pathStat) {
|
|
95
|
+
output_manager_default.error(`Could not find ${import_chalk.default.cyan(`\u201C${humanizePath(path2)}\u201D`)}`);
|
|
96
|
+
return { valid: false, exitCode: 1 };
|
|
97
|
+
}
|
|
98
|
+
if (!pathStat.isDirectory()) {
|
|
99
|
+
output_manager_default.prettyError({
|
|
100
|
+
message: "Support for single file deployments has been removed.",
|
|
101
|
+
link: "https://vercel.link/no-single-file-deployments"
|
|
102
|
+
});
|
|
103
|
+
return { valid: false, exitCode: 1 };
|
|
104
|
+
}
|
|
105
|
+
if (path2 === homedir()) {
|
|
106
|
+
const shouldDeployHomeDirectory = await client.input.confirm(
|
|
107
|
+
`You are deploying your home directory. Do you want to continue?`,
|
|
108
|
+
false
|
|
109
|
+
);
|
|
110
|
+
if (!shouldDeployHomeDirectory) {
|
|
111
|
+
output_manager_default.print(`Canceled
|
|
112
|
+
`);
|
|
113
|
+
return { valid: false, exitCode: 0 };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { valid: true, path: path2 };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/util/config/read-config.ts
|
|
120
|
+
async function readConfig(dir) {
|
|
121
|
+
let pkgFilePath;
|
|
122
|
+
try {
|
|
123
|
+
const compileResult = await compileVercelConfig(dir);
|
|
124
|
+
pkgFilePath = compileResult.configPath || getLocalPathConfig(dir);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
if (err instanceof Error) {
|
|
127
|
+
return err;
|
|
128
|
+
}
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
const result = await readJSONFile(pkgFilePath);
|
|
132
|
+
if (result instanceof CantParseJSONFile) {
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
if (result) {
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/util/input/display-services.ts
|
|
142
|
+
var import_frameworks = __toESM(require_frameworks(), 1);
|
|
143
|
+
var chalk2 = require_source();
|
|
144
|
+
var frameworksBySlug = new Map(import_frameworks.frameworkList.map((f) => [f.slug, f]));
|
|
145
|
+
var frameworkColors = {
|
|
146
|
+
// JavaScript/TypeScript frameworks
|
|
147
|
+
nextjs: chalk2.white,
|
|
148
|
+
vite: chalk2.magenta,
|
|
149
|
+
nuxtjs: chalk2.green,
|
|
150
|
+
remix: chalk2.cyan,
|
|
151
|
+
astro: chalk2.magenta,
|
|
152
|
+
gatsby: chalk2.magenta,
|
|
153
|
+
svelte: chalk2.red,
|
|
154
|
+
sveltekit: chalk2.red,
|
|
155
|
+
solidstart: chalk2.blue,
|
|
156
|
+
angular: chalk2.red,
|
|
157
|
+
vue: chalk2.green,
|
|
158
|
+
ember: chalk2.red,
|
|
159
|
+
preact: chalk2.magenta,
|
|
160
|
+
// Python frameworks
|
|
161
|
+
fastapi: chalk2.green,
|
|
162
|
+
flask: chalk2.cyan,
|
|
163
|
+
// Node frameworks
|
|
164
|
+
express: chalk2.yellow,
|
|
165
|
+
nest: chalk2.red,
|
|
166
|
+
hono: chalk2.yellowBright
|
|
167
|
+
};
|
|
168
|
+
var runtimeColors = {
|
|
169
|
+
node: chalk2.green,
|
|
170
|
+
python: chalk2.blue,
|
|
171
|
+
go: chalk2.cyan,
|
|
172
|
+
ruby: chalk2.red,
|
|
173
|
+
rust: chalk2.yellowBright
|
|
174
|
+
};
|
|
175
|
+
function getFrameworkName(slug) {
|
|
176
|
+
if (!slug)
|
|
177
|
+
return void 0;
|
|
178
|
+
return frameworksBySlug.get(slug)?.name;
|
|
179
|
+
}
|
|
180
|
+
function formatRoutePrefix(routePrefix) {
|
|
181
|
+
if (routePrefix === "/") {
|
|
182
|
+
return "/";
|
|
183
|
+
}
|
|
184
|
+
const normalized = routePrefix.startsWith("/") ? routePrefix : `/${routePrefix}`;
|
|
185
|
+
return `${normalized}/*`;
|
|
186
|
+
}
|
|
187
|
+
function getServiceDescriptionInfo(service) {
|
|
188
|
+
const frameworkName = getFrameworkName(service.framework);
|
|
189
|
+
if (frameworkName && service.framework) {
|
|
190
|
+
const colorFn = frameworkColors[service.framework] || chalk2.cyan;
|
|
191
|
+
return { label: frameworkName, colorFn };
|
|
192
|
+
} else if (service.runtime) {
|
|
193
|
+
const normalizedRuntime = service.runtime.toLowerCase().replace(/@.*$/, "");
|
|
194
|
+
const colorFn = runtimeColors[normalizedRuntime] || chalk2.yellow;
|
|
195
|
+
return { label: service.runtime, colorFn };
|
|
196
|
+
} else if (service.builder?.use) {
|
|
197
|
+
return { label: service.builder.use, colorFn: chalk2.magenta };
|
|
198
|
+
}
|
|
199
|
+
return { label: "unknown", colorFn: chalk2.dim };
|
|
200
|
+
}
|
|
201
|
+
function getServiceTarget(service) {
|
|
202
|
+
switch (service.type) {
|
|
203
|
+
case "cron":
|
|
204
|
+
return `schedule: ${service.schedule ?? "none"}`;
|
|
205
|
+
case "worker":
|
|
206
|
+
return `topic: ${service.topic ?? "none"}`;
|
|
207
|
+
default:
|
|
208
|
+
return service.routePrefix ? formatRoutePrefix(service.routePrefix) : "no route";
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function displayDetectedServices(services) {
|
|
212
|
+
output_manager_default.print(`Multiple services detected. Project Settings:
|
|
213
|
+
`);
|
|
214
|
+
const rows = services.map((service) => {
|
|
215
|
+
const descInfo = getServiceDescriptionInfo(service);
|
|
216
|
+
const target = getServiceTarget(service);
|
|
217
|
+
return [
|
|
218
|
+
`\u2022 ${service.name}`,
|
|
219
|
+
descInfo.colorFn(`[${descInfo.label}]`),
|
|
220
|
+
chalk2.dim("\u2192"),
|
|
221
|
+
target
|
|
222
|
+
];
|
|
223
|
+
});
|
|
224
|
+
const tableOutput = table(rows, { align: ["l", "l", "l", "l"], hsep: 2 });
|
|
225
|
+
output_manager_default.print(`${tableOutput}
|
|
226
|
+
`);
|
|
227
|
+
}
|
|
228
|
+
function displayServicesConfigNote() {
|
|
229
|
+
output_manager_default.print(
|
|
230
|
+
`
|
|
231
|
+
${chalk2.dim("Services (experimental) are configured via vercel.json.")}
|
|
232
|
+
`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function displayServiceErrors(errors) {
|
|
236
|
+
for (const error of errors) {
|
|
237
|
+
output_manager_default.warn(error.message);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/util/link/setup-and-link.ts
|
|
242
|
+
var import_chalk6 = __toESM(require_source(), 1);
|
|
243
|
+
var import_fs_extra2 = __toESM(require_lib(), 1);
|
|
244
|
+
import { join, basename } from "path";
|
|
245
|
+
|
|
246
|
+
// src/util/input/input-project.ts
|
|
247
|
+
var import_chalk2 = __toESM(require_source(), 1);
|
|
248
|
+
var import_slugify = __toESM(require_slugify(), 1);
|
|
249
|
+
async function inputProject(client, org, detectedProjectName, autoConfirm = false) {
|
|
250
|
+
const slugifiedName = (0, import_slugify.default)(detectedProjectName);
|
|
251
|
+
let detectedProject = null;
|
|
252
|
+
output_manager_default.spinner("Searching for existing projects\u2026", 1e3);
|
|
253
|
+
const [project, slugifiedProject] = await Promise.all([
|
|
254
|
+
getProjectByNameOrId(client, detectedProjectName, org.id),
|
|
255
|
+
slugifiedName !== detectedProjectName ? getProjectByNameOrId(client, slugifiedName, org.id) : null
|
|
256
|
+
]);
|
|
257
|
+
detectedProject = !(project instanceof ProjectNotFound) ? project : !(slugifiedProject instanceof ProjectNotFound) ? slugifiedProject : null;
|
|
258
|
+
if (detectedProject && !detectedProject.id) {
|
|
259
|
+
throw new Error(`Detected linked project does not have "id".`);
|
|
260
|
+
}
|
|
261
|
+
output_manager_default.stopSpinner();
|
|
262
|
+
if (autoConfirm) {
|
|
263
|
+
return detectedProject || detectedProjectName;
|
|
264
|
+
}
|
|
265
|
+
if (client.nonInteractive) {
|
|
266
|
+
const err = new Error("Confirmation required");
|
|
267
|
+
err.code = "HEADLESS";
|
|
268
|
+
throw err;
|
|
269
|
+
}
|
|
270
|
+
let shouldLinkProject;
|
|
271
|
+
if (!detectedProject) {
|
|
272
|
+
shouldLinkProject = await client.input.confirm(
|
|
273
|
+
`Link to existing project?`,
|
|
274
|
+
false
|
|
275
|
+
);
|
|
276
|
+
} else {
|
|
277
|
+
if (await client.input.confirm(
|
|
278
|
+
`Found project ${import_chalk2.default.cyan(
|
|
279
|
+
`\u201C${org.slug}/${detectedProject.name}\u201D`
|
|
280
|
+
)}. Link to it?`,
|
|
281
|
+
true
|
|
282
|
+
)) {
|
|
283
|
+
return detectedProject;
|
|
284
|
+
}
|
|
285
|
+
shouldLinkProject = await client.input.confirm(
|
|
286
|
+
`Link to different existing project?`,
|
|
287
|
+
true
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (shouldLinkProject) {
|
|
291
|
+
const firstPage = await client.fetch(`/v9/projects?limit=100`, { accountId: org.id });
|
|
292
|
+
const projects = firstPage.projects;
|
|
293
|
+
const hasMoreProjects = firstPage.pagination.next !== null;
|
|
294
|
+
if (projects.length === 0) {
|
|
295
|
+
output_manager_default.log(
|
|
296
|
+
`No existing projects found under ${import_chalk2.default.bold(org.slug)}. Creating new project.`
|
|
297
|
+
);
|
|
298
|
+
} else if (hasMoreProjects) {
|
|
299
|
+
let toLink;
|
|
300
|
+
await client.input.text({
|
|
301
|
+
message: "What's the name of your existing project?",
|
|
302
|
+
validate: async (val) => {
|
|
303
|
+
if (!val) {
|
|
304
|
+
return "Project name cannot be empty";
|
|
305
|
+
}
|
|
306
|
+
const project2 = await getProjectByNameOrId(client, val, org.id);
|
|
307
|
+
if (project2 instanceof ProjectNotFound) {
|
|
308
|
+
return "Project not found";
|
|
309
|
+
}
|
|
310
|
+
toLink = project2;
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
return toLink;
|
|
315
|
+
} else {
|
|
316
|
+
const choices = projects.sort((a, b) => b.updatedAt - a.updatedAt).map((project2) => ({
|
|
317
|
+
name: project2.name,
|
|
318
|
+
value: project2
|
|
319
|
+
}));
|
|
320
|
+
const toLink = await client.input.select({
|
|
321
|
+
message: "Which existing project do you want to link?",
|
|
322
|
+
choices
|
|
323
|
+
});
|
|
324
|
+
return toLink;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return await client.input.text({
|
|
328
|
+
message: `What\u2019s your project\u2019s name?`,
|
|
329
|
+
default: !detectedProject ? slugifiedName : void 0,
|
|
330
|
+
validate: async (val) => {
|
|
331
|
+
if (!val) {
|
|
332
|
+
return "Project name cannot be empty";
|
|
333
|
+
}
|
|
334
|
+
const project2 = await getProjectByNameOrId(client, val, org.id);
|
|
335
|
+
if (!(project2 instanceof ProjectNotFound)) {
|
|
336
|
+
return "Project already exists";
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/util/input/input-root-directory.ts
|
|
344
|
+
var import_chalk3 = __toESM(require_source(), 1);
|
|
345
|
+
import path from "path";
|
|
346
|
+
async function inputRootDirectory(client, cwd, autoConfirm = false) {
|
|
347
|
+
if (autoConfirm) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
while (true) {
|
|
351
|
+
const rootDirectory = await client.input.text({
|
|
352
|
+
message: `In which directory is your code located?`,
|
|
353
|
+
transformer: (input) => {
|
|
354
|
+
return `${import_chalk3.default.dim(`./`)}${input}`;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
if (!rootDirectory) {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
const normal = path.normalize(rootDirectory);
|
|
361
|
+
if (normal === "." || normal === "./") {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
const fullPath = path.join(cwd, normal);
|
|
365
|
+
if (await validateRootDirectory(
|
|
366
|
+
cwd,
|
|
367
|
+
fullPath,
|
|
368
|
+
"Please choose a different one."
|
|
369
|
+
) === false) {
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
return normal;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/util/input/edit-project-settings.ts
|
|
377
|
+
var import_chalk4 = __toESM(require_source(), 1);
|
|
378
|
+
var import_frameworks2 = __toESM(require_frameworks(), 1);
|
|
379
|
+
|
|
380
|
+
// src/util/is-setting-value.ts
|
|
381
|
+
function isSettingValue(setting) {
|
|
382
|
+
return setting && typeof setting.value === "string";
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// src/util/input/edit-project-settings.ts
|
|
386
|
+
var settingMap = {
|
|
387
|
+
buildCommand: "Build Command",
|
|
388
|
+
devCommand: "Development Command",
|
|
389
|
+
commandForIgnoringBuildStep: "Ignore Command",
|
|
390
|
+
installCommand: "Install Command",
|
|
391
|
+
outputDirectory: "Output Directory",
|
|
392
|
+
framework: "Framework"
|
|
393
|
+
};
|
|
394
|
+
var settingKeys = Object.keys(settingMap).sort();
|
|
395
|
+
async function editProjectSettings(client, projectSettings, framework, autoConfirm, localConfigurationOverrides) {
|
|
396
|
+
const settings = Object.assign(
|
|
397
|
+
{
|
|
398
|
+
buildCommand: null,
|
|
399
|
+
devCommand: null,
|
|
400
|
+
framework: null,
|
|
401
|
+
commandForIgnoringBuildStep: null,
|
|
402
|
+
installCommand: null,
|
|
403
|
+
outputDirectory: null
|
|
404
|
+
},
|
|
405
|
+
projectSettings
|
|
406
|
+
);
|
|
407
|
+
const hasLocalConfigurationOverrides = localConfigurationOverrides && Object.values(localConfigurationOverrides ?? {}).some(Boolean);
|
|
408
|
+
if (hasLocalConfigurationOverrides) {
|
|
409
|
+
for (const setting of settingKeys) {
|
|
410
|
+
const localConfigValue = localConfigurationOverrides[setting];
|
|
411
|
+
if (localConfigValue)
|
|
412
|
+
settings[setting] = localConfigValue;
|
|
413
|
+
}
|
|
414
|
+
output_manager_default.print("Local settings detected in vercel.json:\n");
|
|
415
|
+
for (const setting of settingKeys) {
|
|
416
|
+
const override = localConfigurationOverrides[setting];
|
|
417
|
+
if (override) {
|
|
418
|
+
output_manager_default.print(
|
|
419
|
+
`${import_chalk4.default.dim(
|
|
420
|
+
`- ${import_chalk4.default.bold(`${settingMap[setting]}:`)} ${override}`
|
|
421
|
+
)}
|
|
422
|
+
`
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (localConfigurationOverrides.framework) {
|
|
427
|
+
const overrideFramework = import_frameworks2.frameworkList.find(
|
|
428
|
+
(f) => f.slug === localConfigurationOverrides.framework
|
|
429
|
+
);
|
|
430
|
+
if (overrideFramework) {
|
|
431
|
+
framework = overrideFramework;
|
|
432
|
+
output_manager_default.print(
|
|
433
|
+
`Merging default Project Settings for ${framework.name}. Previously listed overrides are prioritized.
|
|
434
|
+
`
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (!framework) {
|
|
440
|
+
settings.framework = null;
|
|
441
|
+
return settings;
|
|
442
|
+
}
|
|
443
|
+
const styledFramework = (frameworkName) => {
|
|
444
|
+
const frameworkStyle = {
|
|
445
|
+
text: frameworkName,
|
|
446
|
+
color: import_chalk4.default.blue
|
|
447
|
+
};
|
|
448
|
+
if (frameworkName === "Hono") {
|
|
449
|
+
frameworkStyle.text = "\u{1F525} Hono";
|
|
450
|
+
frameworkStyle.color = import_chalk4.default.hex("#FFA500");
|
|
451
|
+
}
|
|
452
|
+
return import_chalk4.default.bold(frameworkStyle.color(frameworkStyle.text));
|
|
453
|
+
};
|
|
454
|
+
output_manager_default.log(
|
|
455
|
+
!framework.slug ? `No framework detected. Default Project Settings:
|
|
456
|
+
` : `Auto-detected Project Settings for ${styledFramework(framework.name)}
|
|
457
|
+
`
|
|
458
|
+
);
|
|
459
|
+
settings.framework = framework.slug;
|
|
460
|
+
if (!framework.slug) {
|
|
461
|
+
for (const setting of settingKeys) {
|
|
462
|
+
if (setting === "framework" || setting === "commandForIgnoringBuildStep") {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const defaultSetting = framework.settings[setting];
|
|
466
|
+
const override = localConfigurationOverrides?.[setting];
|
|
467
|
+
if (!override && defaultSetting) {
|
|
468
|
+
output_manager_default.print(
|
|
469
|
+
`${import_chalk4.default.dim(
|
|
470
|
+
`- ${import_chalk4.default.bold(`${settingMap[setting]}:`)} ${isSettingValue(defaultSetting) ? defaultSetting.value : import_chalk4.default.italic(`${defaultSetting.placeholder}`)}`
|
|
471
|
+
)}
|
|
472
|
+
`
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (autoConfirm || !await client.input.confirm("Want to modify these settings?", false)) {
|
|
478
|
+
return settings;
|
|
479
|
+
}
|
|
480
|
+
const choices = settingKeys.reduce(
|
|
481
|
+
(acc, setting) => {
|
|
482
|
+
const skip = setting === "framework" || setting === "commandForIgnoringBuildStep" || setting === "installCommand" || localConfigurationOverrides?.[setting];
|
|
483
|
+
if (skip)
|
|
484
|
+
return acc;
|
|
485
|
+
return [...acc, { name: settingMap[setting], value: setting }];
|
|
486
|
+
},
|
|
487
|
+
[]
|
|
488
|
+
);
|
|
489
|
+
const settingFields = await client.input.checkbox({
|
|
490
|
+
message: "Which settings would you like to overwrite (select multiple)?",
|
|
491
|
+
choices
|
|
492
|
+
});
|
|
493
|
+
for (const setting of settingFields) {
|
|
494
|
+
const field = settingMap[setting];
|
|
495
|
+
settings[setting] = await client.input.text({
|
|
496
|
+
message: `What's your ${import_chalk4.default.bold(field)}?`
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return settings;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// src/util/link/setup-and-link.ts
|
|
503
|
+
var import_frameworks3 = __toESM(require_frameworks(), 1);
|
|
504
|
+
|
|
505
|
+
// src/util/input/vercel-auth.ts
|
|
506
|
+
var import_chalk5 = __toESM(require_source(), 1);
|
|
507
|
+
var DEFAULT_VERCEL_AUTH_SETTING = "standard";
|
|
508
|
+
var OPTIONS = {
|
|
509
|
+
message: `What setting do you want to use for Vercel Authentication?`,
|
|
510
|
+
default: DEFAULT_VERCEL_AUTH_SETTING,
|
|
511
|
+
choices: [
|
|
512
|
+
{
|
|
513
|
+
description: "Standard Protection (recommended)",
|
|
514
|
+
name: "standard",
|
|
515
|
+
value: "standard"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
description: "No Protection (all deployments will be public)",
|
|
519
|
+
name: "none",
|
|
520
|
+
value: "none"
|
|
521
|
+
}
|
|
522
|
+
]
|
|
523
|
+
};
|
|
524
|
+
async function vercelAuth(client, {
|
|
525
|
+
autoConfirm = false
|
|
526
|
+
}) {
|
|
527
|
+
if (autoConfirm || await client.input.confirm(
|
|
528
|
+
`Want to use the default Deployment Protection settings? ${import_chalk5.default.dim(`(Vercel Authentication: Standard Protection)`)}`,
|
|
529
|
+
true
|
|
530
|
+
)) {
|
|
531
|
+
return DEFAULT_VERCEL_AUTH_SETTING;
|
|
532
|
+
}
|
|
533
|
+
const vercelAuth2 = await client.input.select(OPTIONS);
|
|
534
|
+
return vercelAuth2;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// src/util/link/setup-and-link.ts
|
|
538
|
+
async function setupAndLink(client, path2, {
|
|
539
|
+
autoConfirm = false,
|
|
540
|
+
forceDelete = false,
|
|
541
|
+
link,
|
|
542
|
+
successEmoji = "link",
|
|
543
|
+
setupMsg = "Set up",
|
|
544
|
+
projectName = basename(path2),
|
|
545
|
+
nonInteractive = false,
|
|
546
|
+
pullEnv = true,
|
|
547
|
+
v0
|
|
548
|
+
}) {
|
|
549
|
+
const { config } = client;
|
|
550
|
+
if (!isDirectory(path2)) {
|
|
551
|
+
output_manager_default.error(`Expected directory but found file: ${path2}`);
|
|
552
|
+
return { status: "error", exitCode: 1, reason: "PATH_IS_FILE" };
|
|
553
|
+
}
|
|
554
|
+
if (!link) {
|
|
555
|
+
link = await getLinkedProject(client, path2);
|
|
556
|
+
}
|
|
557
|
+
const isTTY = client.stdin.isTTY;
|
|
558
|
+
let rootDirectory = null;
|
|
559
|
+
let newProjectName;
|
|
560
|
+
let org;
|
|
561
|
+
if (!forceDelete && link.status === "linked") {
|
|
562
|
+
return link;
|
|
563
|
+
}
|
|
564
|
+
if (forceDelete) {
|
|
565
|
+
const vercelDir = getVercelDirectory(path2);
|
|
566
|
+
(0, import_fs_extra2.remove)(join(vercelDir, VERCEL_DIR_README));
|
|
567
|
+
(0, import_fs_extra2.remove)(join(vercelDir, VERCEL_DIR_PROJECT));
|
|
568
|
+
}
|
|
569
|
+
if (!isTTY && !autoConfirm && !nonInteractive) {
|
|
570
|
+
return { status: "error", exitCode: 1, reason: "HEADLESS" };
|
|
571
|
+
}
|
|
572
|
+
const shouldStartSetup = autoConfirm || nonInteractive || await client.input.confirm(
|
|
573
|
+
`${setupMsg} ${import_chalk6.default.cyan(`\u201C${humanizePath(path2)}\u201D`)}?`,
|
|
574
|
+
true
|
|
575
|
+
);
|
|
576
|
+
if (!shouldStartSetup) {
|
|
577
|
+
output_manager_default.print(`Canceled. Project not set up.
|
|
578
|
+
`);
|
|
579
|
+
return { status: "not_linked", org: null, project: null };
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
org = await selectOrg(
|
|
583
|
+
client,
|
|
584
|
+
"Which scope should contain your project?",
|
|
585
|
+
autoConfirm
|
|
586
|
+
);
|
|
587
|
+
} catch (err) {
|
|
588
|
+
if (isAPIError(err)) {
|
|
589
|
+
if (err.code === "NOT_AUTHORIZED") {
|
|
590
|
+
output_manager_default.prettyError(err);
|
|
591
|
+
return { status: "error", exitCode: 1, reason: "NOT_AUTHORIZED" };
|
|
592
|
+
}
|
|
593
|
+
if (err.code === "TEAM_DELETED") {
|
|
594
|
+
output_manager_default.prettyError(err);
|
|
595
|
+
return { status: "error", exitCode: 1, reason: "TEAM_DELETED" };
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
throw err;
|
|
599
|
+
}
|
|
600
|
+
let projectOrNewProjectName;
|
|
601
|
+
try {
|
|
602
|
+
projectOrNewProjectName = await inputProject(
|
|
603
|
+
client,
|
|
604
|
+
org,
|
|
605
|
+
projectName,
|
|
606
|
+
autoConfirm
|
|
607
|
+
);
|
|
608
|
+
} catch (err) {
|
|
609
|
+
if (err instanceof Error && err.code === "HEADLESS") {
|
|
610
|
+
return { status: "error", exitCode: 1, reason: "HEADLESS" };
|
|
611
|
+
}
|
|
612
|
+
throw err;
|
|
613
|
+
}
|
|
614
|
+
if (typeof projectOrNewProjectName === "string") {
|
|
615
|
+
newProjectName = projectOrNewProjectName;
|
|
616
|
+
rootDirectory = await inputRootDirectory(client, path2, autoConfirm);
|
|
617
|
+
} else {
|
|
618
|
+
const project = projectOrNewProjectName;
|
|
619
|
+
await linkFolderToProject(
|
|
620
|
+
client,
|
|
621
|
+
path2,
|
|
622
|
+
{
|
|
623
|
+
projectId: project.id,
|
|
624
|
+
orgId: org.id
|
|
625
|
+
},
|
|
626
|
+
project.name,
|
|
627
|
+
org.slug,
|
|
628
|
+
successEmoji,
|
|
629
|
+
autoConfirm,
|
|
630
|
+
pullEnv
|
|
631
|
+
);
|
|
632
|
+
return { status: "linked", org, project };
|
|
633
|
+
}
|
|
634
|
+
if (rootDirectory && !await validateRootDirectory(path2, join(path2, rootDirectory))) {
|
|
635
|
+
return { status: "error", exitCode: 1, reason: "INVALID_ROOT_DIRECTORY" };
|
|
636
|
+
}
|
|
637
|
+
config.currentTeam = org.type === "team" ? org.id : void 0;
|
|
638
|
+
const pathWithRootDirectory = rootDirectory ? join(path2, rootDirectory) : path2;
|
|
639
|
+
const localConfig = await readConfig(pathWithRootDirectory);
|
|
640
|
+
if (localConfig instanceof CantParseJSONFile) {
|
|
641
|
+
output_manager_default.prettyError(localConfig);
|
|
642
|
+
return { status: "error", exitCode: 1 };
|
|
643
|
+
}
|
|
644
|
+
const isZeroConfig = !localConfig || !localConfig.builds || localConfig.builds.length === 0;
|
|
645
|
+
const servicesResult = await tryDetectServices(pathWithRootDirectory);
|
|
646
|
+
try {
|
|
647
|
+
let settings = {};
|
|
648
|
+
if (servicesResult) {
|
|
649
|
+
displayDetectedServices(servicesResult.services);
|
|
650
|
+
if (servicesResult.errors.length > 0) {
|
|
651
|
+
displayServiceErrors(servicesResult.errors);
|
|
652
|
+
}
|
|
653
|
+
displayServicesConfigNote();
|
|
654
|
+
settings.framework = "services";
|
|
655
|
+
} else if (isZeroConfig) {
|
|
656
|
+
const localConfigurationOverrides = {
|
|
657
|
+
buildCommand: localConfig?.buildCommand,
|
|
658
|
+
devCommand: localConfig?.devCommand,
|
|
659
|
+
framework: localConfig?.framework,
|
|
660
|
+
commandForIgnoringBuildStep: localConfig?.ignoreCommand,
|
|
661
|
+
installCommand: localConfig?.installCommand,
|
|
662
|
+
outputDirectory: localConfig?.outputDirectory
|
|
663
|
+
};
|
|
664
|
+
const detectedProjectsForWorkspace = await detectProjects(
|
|
665
|
+
pathWithRootDirectory
|
|
666
|
+
);
|
|
667
|
+
const detectedProjects = detectedProjectsForWorkspace.get("") || [];
|
|
668
|
+
const framework = detectedProjects[0] ?? import_frameworks3.frameworkList.find((f) => f.slug === null);
|
|
669
|
+
settings = await editProjectSettings(
|
|
670
|
+
client,
|
|
671
|
+
{},
|
|
672
|
+
framework,
|
|
673
|
+
autoConfirm,
|
|
674
|
+
localConfigurationOverrides
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
let changeAdditionalSettings = false;
|
|
678
|
+
if (!autoConfirm) {
|
|
679
|
+
changeAdditionalSettings = await client.input.confirm(
|
|
680
|
+
"Do you want to change additional project settings?",
|
|
681
|
+
false
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
let vercelAuthSetting = DEFAULT_VERCEL_AUTH_SETTING;
|
|
685
|
+
if (changeAdditionalSettings) {
|
|
686
|
+
vercelAuthSetting = await vercelAuth(client, {
|
|
687
|
+
autoConfirm
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
if (rootDirectory) {
|
|
691
|
+
settings.rootDirectory = rootDirectory;
|
|
692
|
+
}
|
|
693
|
+
const project = await createProject(client, {
|
|
694
|
+
...settings,
|
|
695
|
+
name: newProjectName,
|
|
696
|
+
vercelAuth: vercelAuthSetting,
|
|
697
|
+
v0
|
|
698
|
+
});
|
|
699
|
+
await linkFolderToProject(
|
|
700
|
+
client,
|
|
701
|
+
path2,
|
|
702
|
+
{
|
|
703
|
+
projectId: project.id,
|
|
704
|
+
orgId: org.id
|
|
705
|
+
},
|
|
706
|
+
project.name,
|
|
707
|
+
org.slug,
|
|
708
|
+
successEmoji,
|
|
709
|
+
autoConfirm,
|
|
710
|
+
false
|
|
711
|
+
// don't prompt to pull env for newly created projects
|
|
712
|
+
);
|
|
713
|
+
await connectGitRepository(client, path2, project, autoConfirm, org);
|
|
714
|
+
return { status: "linked", org, project };
|
|
715
|
+
} catch (err) {
|
|
716
|
+
if (isAPIError(err) && err.code === "too_many_projects") {
|
|
717
|
+
output_manager_default.prettyError(err);
|
|
718
|
+
return { status: "error", exitCode: 1, reason: "TOO_MANY_PROJECTS" };
|
|
719
|
+
}
|
|
720
|
+
if (err instanceof Error && err.code === "HEADLESS") {
|
|
721
|
+
return { status: "error", exitCode: 1, reason: "HEADLESS" };
|
|
722
|
+
}
|
|
723
|
+
printError(err);
|
|
724
|
+
return { status: "error", exitCode: 1 };
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
async function connectGitRepository(client, path2, project, autoConfirm, org) {
|
|
728
|
+
try {
|
|
729
|
+
const gitConfig = await parseGitConfig(join(path2, ".git/config"));
|
|
730
|
+
if (!gitConfig) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const remoteUrls = pluckRemoteUrls(gitConfig);
|
|
734
|
+
if (!remoteUrls || Object.keys(remoteUrls).length === 0) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const shouldConnect = autoConfirm || await client.input.confirm(
|
|
738
|
+
`Detected a repository. Connect it to this project?`,
|
|
739
|
+
true
|
|
740
|
+
);
|
|
741
|
+
if (!shouldConnect) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
const repoInfo = await selectAndParseRemoteUrl(client, remoteUrls);
|
|
745
|
+
if (!repoInfo) {
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
await checkExistsAndConnect({
|
|
749
|
+
client,
|
|
750
|
+
confirm: autoConfirm,
|
|
751
|
+
gitProviderLink: project.link,
|
|
752
|
+
org,
|
|
753
|
+
gitOrg: repoInfo.org,
|
|
754
|
+
project,
|
|
755
|
+
// Type assertion since we only need the id
|
|
756
|
+
provider: repoInfo.provider,
|
|
757
|
+
repo: repoInfo.repo,
|
|
758
|
+
repoPath: `${repoInfo.org}/${repoInfo.repo}`
|
|
759
|
+
});
|
|
760
|
+
} catch (error) {
|
|
761
|
+
output_manager_default.debug(`Failed to connect git repository: ${error}`);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export {
|
|
766
|
+
validateRootDirectory,
|
|
767
|
+
validatePaths,
|
|
768
|
+
readConfig,
|
|
769
|
+
displayDetectedServices,
|
|
770
|
+
setupAndLink
|
|
771
|
+
};
|