@mastra/deployer-vercel 0.10.6-alpha.3 → 0.10.6-alpha.4
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/dist/_tsup-dts-rollup.d.cts +1 -11
- package/dist/_tsup-dts-rollup.d.ts +1 -11
- package/dist/index.cjs +32 -96
- package/dist/index.js +33 -97
- package/package.json +4 -4
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
2
|
|
|
3
3
|
export declare class VercelDeployer extends Deployer {
|
|
4
|
-
|
|
5
|
-
private projectName;
|
|
6
|
-
private token;
|
|
7
|
-
constructor({ teamSlug, projectName, token }: {
|
|
8
|
-
teamSlug: string;
|
|
9
|
-
projectName: string;
|
|
10
|
-
token: string;
|
|
11
|
-
});
|
|
12
|
-
private getProjectId;
|
|
13
|
-
private getTeamId;
|
|
14
|
-
private syncEnv;
|
|
4
|
+
constructor();
|
|
15
5
|
prepare(outputDirectory: string): Promise<void>;
|
|
16
6
|
private getEntry;
|
|
17
7
|
private writeVercelJSON;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
2
|
|
|
3
3
|
export declare class VercelDeployer extends Deployer {
|
|
4
|
-
|
|
5
|
-
private projectName;
|
|
6
|
-
private token;
|
|
7
|
-
constructor({ teamSlug, projectName, token }: {
|
|
8
|
-
teamSlug: string;
|
|
9
|
-
projectName: string;
|
|
10
|
-
token: string;
|
|
11
|
-
});
|
|
12
|
-
private getProjectId;
|
|
13
|
-
private getTeamId;
|
|
14
|
-
private syncEnv;
|
|
4
|
+
constructor();
|
|
15
5
|
prepare(outputDirectory: string): Promise<void>;
|
|
16
6
|
private getEntry;
|
|
17
7
|
private writeVercelJSON;
|
package/dist/index.cjs
CHANGED
|
@@ -11,77 +11,13 @@ var process__default = /*#__PURE__*/_interopDefault(process);
|
|
|
11
11
|
|
|
12
12
|
// src/index.ts
|
|
13
13
|
var VercelDeployer = class extends deployer.Deployer {
|
|
14
|
-
|
|
15
|
-
projectName;
|
|
16
|
-
token;
|
|
17
|
-
constructor({ teamSlug, projectName, token }) {
|
|
14
|
+
constructor() {
|
|
18
15
|
super({ name: "VERCEL" });
|
|
19
|
-
this.
|
|
20
|
-
this.projectName = projectName;
|
|
21
|
-
this.token = token;
|
|
22
|
-
}
|
|
23
|
-
getProjectId({ dir }) {
|
|
24
|
-
const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
|
|
25
|
-
try {
|
|
26
|
-
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, "utf-8"));
|
|
27
|
-
return projectJson.projectId;
|
|
28
|
-
} catch {
|
|
29
|
-
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
async getTeamId() {
|
|
33
|
-
const response = await fetch(`https://api.vercel.com/v2/teams`, {
|
|
34
|
-
headers: {
|
|
35
|
-
Authorization: `Bearer ${this.token}`
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
const res = await response.json();
|
|
39
|
-
const teams = res.teams;
|
|
40
|
-
return teams.find((team) => team.slug === this.teamSlug)?.id;
|
|
41
|
-
}
|
|
42
|
-
async syncEnv(envVars, { outputDirectory }) {
|
|
43
|
-
console.log("Syncing environment variables...");
|
|
44
|
-
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
45
|
-
if (!key || !value) {
|
|
46
|
-
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
key,
|
|
50
|
-
value,
|
|
51
|
-
target: ["production", "preview", "development"],
|
|
52
|
-
type: "plain"
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
try {
|
|
56
|
-
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
57
|
-
const teamId = await this.getTeamId();
|
|
58
|
-
const response = await fetch(
|
|
59
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
60
|
-
{
|
|
61
|
-
method: "POST",
|
|
62
|
-
headers: {
|
|
63
|
-
Authorization: `Bearer ${this.token}`,
|
|
64
|
-
"Content-Type": "application/json"
|
|
65
|
-
},
|
|
66
|
-
body: JSON.stringify(vercelEnvVars)
|
|
67
|
-
}
|
|
68
|
-
);
|
|
69
|
-
if (!response.ok) {
|
|
70
|
-
const error = await response.json();
|
|
71
|
-
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
72
|
-
}
|
|
73
|
-
console.log("\u2713 Successfully synced environment variables");
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (error instanceof Error) {
|
|
76
|
-
console.error("Failed to sync environment variables:", error.message);
|
|
77
|
-
} else {
|
|
78
|
-
console.error("Failed to sync environment variables:", error);
|
|
79
|
-
}
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
16
|
+
this.outputDir = path.join(this.outputDir, ".vercel", "output", "functions", "index.func");
|
|
82
17
|
}
|
|
83
18
|
async prepare(outputDirectory) {
|
|
84
19
|
await super.prepare(outputDirectory);
|
|
20
|
+
this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
|
|
85
21
|
}
|
|
86
22
|
getEntry() {
|
|
87
23
|
return `
|
|
@@ -141,48 +77,48 @@ export const OPTIONS = handle(app);
|
|
|
141
77
|
export const HEAD = handle(app);
|
|
142
78
|
`;
|
|
143
79
|
}
|
|
144
|
-
writeVercelJSON(outputDirectory
|
|
80
|
+
writeVercelJSON(outputDirectory) {
|
|
145
81
|
fs.writeFileSync(
|
|
146
|
-
path.join(outputDirectory,
|
|
82
|
+
path.join(outputDirectory, "config.json"),
|
|
83
|
+
JSON.stringify({
|
|
84
|
+
version: 3,
|
|
85
|
+
routes: [
|
|
86
|
+
{
|
|
87
|
+
src: "/(.*)",
|
|
88
|
+
dest: "/"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
95
|
+
const result = await this._bundle(
|
|
96
|
+
this.getEntry(),
|
|
97
|
+
entryFile,
|
|
98
|
+
outputDirectory,
|
|
99
|
+
toolsPaths,
|
|
100
|
+
path.join(outputDirectory, this.outputDir)
|
|
101
|
+
);
|
|
102
|
+
const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
|
|
103
|
+
fs.writeFileSync(
|
|
104
|
+
path.join(outputDirectory, this.outputDir, ".vc-config.json"),
|
|
147
105
|
JSON.stringify(
|
|
148
106
|
{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
src: "index.mjs",
|
|
154
|
-
use: "@vercel/node",
|
|
155
|
-
config: { includeFiles: files }
|
|
156
|
-
}
|
|
157
|
-
],
|
|
158
|
-
routes: [
|
|
159
|
-
{
|
|
160
|
-
src: "/(.*)",
|
|
161
|
-
dest: "index.mjs"
|
|
162
|
-
}
|
|
163
|
-
]
|
|
107
|
+
handler: "index.mjs",
|
|
108
|
+
launcherType: "Nodejs",
|
|
109
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
110
|
+
shouldAddHelpers: true
|
|
164
111
|
},
|
|
165
112
|
null,
|
|
166
113
|
2
|
|
167
114
|
)
|
|
168
115
|
);
|
|
169
|
-
}
|
|
170
|
-
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
171
|
-
const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
|
|
172
|
-
const files = fs.readdirSync(path.join(outputDirectory, this.outputDir), {
|
|
173
|
-
recursive: true
|
|
174
|
-
});
|
|
175
|
-
const filesWithoutNodeModules = files.filter(
|
|
176
|
-
(file) => typeof file === "string" && !file.startsWith("node_modules")
|
|
177
|
-
);
|
|
178
|
-
this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
|
|
179
116
|
return result;
|
|
180
117
|
}
|
|
181
118
|
async deploy() {
|
|
182
|
-
this.logger?.info("Deploying to Vercel
|
|
119
|
+
this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
|
|
183
120
|
}
|
|
184
121
|
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
185
|
-
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
186
122
|
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
187
123
|
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
188
124
|
if (hasLibsql) {
|
package/dist/index.js
CHANGED
|
@@ -1,81 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { writeFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import process from 'process';
|
|
4
4
|
import { Deployer } from '@mastra/deployer';
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
7
|
var VercelDeployer = class extends Deployer {
|
|
8
|
-
|
|
9
|
-
projectName;
|
|
10
|
-
token;
|
|
11
|
-
constructor({ teamSlug, projectName, token }) {
|
|
8
|
+
constructor() {
|
|
12
9
|
super({ name: "VERCEL" });
|
|
13
|
-
this.
|
|
14
|
-
this.projectName = projectName;
|
|
15
|
-
this.token = token;
|
|
16
|
-
}
|
|
17
|
-
getProjectId({ dir }) {
|
|
18
|
-
const projectJsonPath = join(dir, "output", ".vercel", "project.json");
|
|
19
|
-
try {
|
|
20
|
-
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
21
|
-
return projectJson.projectId;
|
|
22
|
-
} catch {
|
|
23
|
-
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async getTeamId() {
|
|
27
|
-
const response = await fetch(`https://api.vercel.com/v2/teams`, {
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${this.token}`
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const res = await response.json();
|
|
33
|
-
const teams = res.teams;
|
|
34
|
-
return teams.find((team) => team.slug === this.teamSlug)?.id;
|
|
35
|
-
}
|
|
36
|
-
async syncEnv(envVars, { outputDirectory }) {
|
|
37
|
-
console.log("Syncing environment variables...");
|
|
38
|
-
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
39
|
-
if (!key || !value) {
|
|
40
|
-
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
key,
|
|
44
|
-
value,
|
|
45
|
-
target: ["production", "preview", "development"],
|
|
46
|
-
type: "plain"
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
try {
|
|
50
|
-
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
51
|
-
const teamId = await this.getTeamId();
|
|
52
|
-
const response = await fetch(
|
|
53
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
54
|
-
{
|
|
55
|
-
method: "POST",
|
|
56
|
-
headers: {
|
|
57
|
-
Authorization: `Bearer ${this.token}`,
|
|
58
|
-
"Content-Type": "application/json"
|
|
59
|
-
},
|
|
60
|
-
body: JSON.stringify(vercelEnvVars)
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
if (!response.ok) {
|
|
64
|
-
const error = await response.json();
|
|
65
|
-
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
66
|
-
}
|
|
67
|
-
console.log("\u2713 Successfully synced environment variables");
|
|
68
|
-
} catch (error) {
|
|
69
|
-
if (error instanceof Error) {
|
|
70
|
-
console.error("Failed to sync environment variables:", error.message);
|
|
71
|
-
} else {
|
|
72
|
-
console.error("Failed to sync environment variables:", error);
|
|
73
|
-
}
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
10
|
+
this.outputDir = join(this.outputDir, ".vercel", "output", "functions", "index.func");
|
|
76
11
|
}
|
|
77
12
|
async prepare(outputDirectory) {
|
|
78
13
|
await super.prepare(outputDirectory);
|
|
14
|
+
this.writeVercelJSON(join(outputDirectory, this.outputDir, "..", ".."));
|
|
79
15
|
}
|
|
80
16
|
getEntry() {
|
|
81
17
|
return `
|
|
@@ -135,48 +71,48 @@ export const OPTIONS = handle(app);
|
|
|
135
71
|
export const HEAD = handle(app);
|
|
136
72
|
`;
|
|
137
73
|
}
|
|
138
|
-
writeVercelJSON(outputDirectory
|
|
74
|
+
writeVercelJSON(outputDirectory) {
|
|
139
75
|
writeFileSync(
|
|
140
|
-
join(outputDirectory,
|
|
76
|
+
join(outputDirectory, "config.json"),
|
|
77
|
+
JSON.stringify({
|
|
78
|
+
version: 3,
|
|
79
|
+
routes: [
|
|
80
|
+
{
|
|
81
|
+
src: "/(.*)",
|
|
82
|
+
dest: "/"
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
89
|
+
const result = await this._bundle(
|
|
90
|
+
this.getEntry(),
|
|
91
|
+
entryFile,
|
|
92
|
+
outputDirectory,
|
|
93
|
+
toolsPaths,
|
|
94
|
+
join(outputDirectory, this.outputDir)
|
|
95
|
+
);
|
|
96
|
+
const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
|
|
97
|
+
writeFileSync(
|
|
98
|
+
join(outputDirectory, this.outputDir, ".vc-config.json"),
|
|
141
99
|
JSON.stringify(
|
|
142
100
|
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
src: "index.mjs",
|
|
148
|
-
use: "@vercel/node",
|
|
149
|
-
config: { includeFiles: files }
|
|
150
|
-
}
|
|
151
|
-
],
|
|
152
|
-
routes: [
|
|
153
|
-
{
|
|
154
|
-
src: "/(.*)",
|
|
155
|
-
dest: "index.mjs"
|
|
156
|
-
}
|
|
157
|
-
]
|
|
101
|
+
handler: "index.mjs",
|
|
102
|
+
launcherType: "Nodejs",
|
|
103
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
104
|
+
shouldAddHelpers: true
|
|
158
105
|
},
|
|
159
106
|
null,
|
|
160
107
|
2
|
|
161
108
|
)
|
|
162
109
|
);
|
|
163
|
-
}
|
|
164
|
-
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
165
|
-
const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
|
|
166
|
-
const files = readdirSync(join(outputDirectory, this.outputDir), {
|
|
167
|
-
recursive: true
|
|
168
|
-
});
|
|
169
|
-
const filesWithoutNodeModules = files.filter(
|
|
170
|
-
(file) => typeof file === "string" && !file.startsWith("node_modules")
|
|
171
|
-
);
|
|
172
|
-
this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
|
|
173
110
|
return result;
|
|
174
111
|
}
|
|
175
112
|
async deploy() {
|
|
176
|
-
this.logger?.info("Deploying to Vercel
|
|
113
|
+
this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
|
|
177
114
|
}
|
|
178
115
|
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
179
|
-
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
180
116
|
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
181
117
|
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
182
118
|
if (hasLibsql) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.10.6-alpha.
|
|
3
|
+
"version": "0.10.6-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@rollup/plugin-virtual": "^3.0.2",
|
|
29
29
|
"fs-extra": "^11.3.0",
|
|
30
|
-
"@mastra/deployer": "^0.10.6-alpha.
|
|
30
|
+
"@mastra/deployer": "^0.10.6-alpha.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@microsoft/api-extractor": "^7.52.8",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"tsup": "^8.5.0",
|
|
37
37
|
"typescript": "^5.8.3",
|
|
38
38
|
"vitest": "^3.2.3",
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
39
|
+
"@internal/lint": "0.0.12",
|
|
40
|
+
"@mastra/core": "0.10.6-alpha.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@mastra/core": "^0.10.1-alpha.0"
|