@mastra/deployer-vercel 0.0.1-alpha.24 → 0.0.1-alpha.27
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/CHANGELOG.md +25 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +138 -6
- package/package.json +11 -18
- package/src/index.ts +1 -0
- package/tsconfig.json +1 -6
- package/vitest.config.ts +1 -1
- package/dist/deployer-vercel.cjs.development.js +0 -588
- package/dist/deployer-vercel.cjs.development.js.map +0 -1
- package/dist/deployer-vercel.cjs.production.min.js +0 -2
- package/dist/deployer-vercel.cjs.production.min.js.map +0 -1
- package/dist/deployer-vercel.esm.js +0 -565
- package/dist/deployer-vercel.esm.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @mastra/deployer-vercel
|
|
2
2
|
|
|
3
|
+
## 0.0.1-alpha.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 44c7c26: Rebuild
|
|
8
|
+
|
|
9
|
+
## 0.0.1-alpha.26
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [685108a]
|
|
14
|
+
- Updated dependencies [685108a]
|
|
15
|
+
- @mastra/deployer@0.0.1-alpha.22
|
|
16
|
+
- @mastra/core@0.1.27-alpha.78
|
|
17
|
+
|
|
18
|
+
## 0.0.1-alpha.25
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 2b75edf: mastra deployers tsup bundling
|
|
23
|
+
- Updated dependencies [8105fae]
|
|
24
|
+
- Updated dependencies [cfb966f]
|
|
25
|
+
- @mastra/core@0.1.27-alpha.77
|
|
26
|
+
- @mastra/deployer@0.0.1-alpha.21
|
|
27
|
+
|
|
3
28
|
## 0.0.1-alpha.24
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MastraDeployer } from '@mastra/core';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
declare class VercelDeployer extends MastraDeployer {
|
|
3
4
|
constructor({ scope, env, projectName }: {
|
|
4
5
|
env?: Record<string, any>;
|
|
5
6
|
scope: string;
|
|
@@ -22,4 +23,5 @@ export declare class VercelDeployer extends MastraDeployer {
|
|
|
22
23
|
dir: string;
|
|
23
24
|
}): void;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
export { VercelDeployer };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,140 @@
|
|
|
1
|
+
import { MastraDeployer } from '@mastra/core';
|
|
2
|
+
import * as child_process from 'child_process';
|
|
3
|
+
import { writeFileSync, readFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
1
5
|
|
|
2
|
-
|
|
6
|
+
// src/index.ts
|
|
7
|
+
var VercelDeployer = class extends MastraDeployer {
|
|
8
|
+
constructor({ scope, env, projectName }) {
|
|
9
|
+
super({ scope, env, projectName });
|
|
10
|
+
}
|
|
11
|
+
writeFiles({ dir }) {
|
|
12
|
+
this.writeIndex({ dir });
|
|
13
|
+
writeFileSync(
|
|
14
|
+
join(dir, "vercel.json"),
|
|
15
|
+
JSON.stringify(
|
|
16
|
+
{
|
|
17
|
+
version: 2,
|
|
18
|
+
installCommand: "npm install --omit=dev",
|
|
19
|
+
builds: [
|
|
20
|
+
{
|
|
21
|
+
src: "index.mjs",
|
|
22
|
+
use: "@vercel/node",
|
|
23
|
+
config: { includeFiles: ["**"] }
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
routes: [
|
|
27
|
+
{
|
|
28
|
+
src: "/(.*)",
|
|
29
|
+
dest: "index.mjs"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
null,
|
|
34
|
+
2
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
getProjectId({ dir }) {
|
|
39
|
+
const projectJsonPath = join(dir, ".vercel", "project.json");
|
|
40
|
+
try {
|
|
41
|
+
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
42
|
+
return projectJson.projectId;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async syncEnv({ scope, dir, token }) {
|
|
48
|
+
const envFiles = this.getEnvFiles();
|
|
49
|
+
const envVars = [];
|
|
50
|
+
for (const file of envFiles) {
|
|
51
|
+
const vars = this.parseEnvFile(file);
|
|
52
|
+
envVars.push(...vars);
|
|
53
|
+
}
|
|
54
|
+
console.log("Syncing environment variables...");
|
|
55
|
+
const vercelEnvVars = envVars.map((envVar) => {
|
|
56
|
+
const [key, value] = envVar.split("=");
|
|
57
|
+
if (!key || !value) {
|
|
58
|
+
throw new Error(`Invalid environment variable format: ${envVar}`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
key,
|
|
62
|
+
value,
|
|
63
|
+
target: ["production", "preview", "development"],
|
|
64
|
+
type: "plain"
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
const projectId = this.getProjectId({ dir });
|
|
69
|
+
const response = await fetch(`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${scope}&upsert=true`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
Authorization: `Bearer ${token}`,
|
|
73
|
+
"Content-Type": "application/json"
|
|
74
|
+
},
|
|
75
|
+
body: JSON.stringify(vercelEnvVars)
|
|
76
|
+
});
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
const error = await response.json();
|
|
79
|
+
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
80
|
+
}
|
|
81
|
+
console.log("\u2713 Successfully synced environment variables");
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if (error instanceof Error) {
|
|
84
|
+
console.error("Failed to sync environment variables:", error.message);
|
|
85
|
+
} else {
|
|
86
|
+
console.error("Failed to sync environment variables:", error);
|
|
87
|
+
}
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async deploy({ dir, token }) {
|
|
92
|
+
const envFiles = this.getEnvFiles();
|
|
93
|
+
const envVars = [];
|
|
94
|
+
for (const file of envFiles) {
|
|
95
|
+
const vars = this.parseEnvFile(file);
|
|
96
|
+
envVars.push(...vars);
|
|
97
|
+
}
|
|
98
|
+
const commandArgs = [
|
|
99
|
+
"--scope",
|
|
100
|
+
this.scope,
|
|
101
|
+
"--cwd",
|
|
102
|
+
dir,
|
|
103
|
+
"deploy",
|
|
104
|
+
"--token",
|
|
105
|
+
token,
|
|
106
|
+
"--yes",
|
|
107
|
+
...this.projectName ? ["--name", this.projectName] : []
|
|
108
|
+
];
|
|
109
|
+
for (const envVar of envVars) {
|
|
110
|
+
commandArgs.push("--env", envVar);
|
|
111
|
+
}
|
|
112
|
+
child_process.execSync(`vercel ${commandArgs.join(" ")}`, {
|
|
113
|
+
cwd: dir,
|
|
114
|
+
env: {
|
|
115
|
+
...this.env,
|
|
116
|
+
PATH: process.env.PATH
|
|
117
|
+
},
|
|
118
|
+
stdio: "inherit"
|
|
119
|
+
});
|
|
120
|
+
console.log("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
121
|
+
if (envVars.length > 0) {
|
|
122
|
+
await this.syncEnv({ scope: this.scope, dir, token });
|
|
123
|
+
} else {
|
|
124
|
+
console.log("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
writeIndex({ dir }) {
|
|
128
|
+
writeFileSync(
|
|
129
|
+
join(dir, "index.mjs"),
|
|
130
|
+
`
|
|
131
|
+
import { handle } from 'hono/vercel'
|
|
132
|
+
import { app } from './hono.mjs';
|
|
133
|
+
export const GET = handle(app);
|
|
134
|
+
export const POST = handle(app);
|
|
135
|
+
`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
3
139
|
|
|
4
|
-
|
|
5
|
-
module.exports = require('./deployer-vercel.cjs.production.min.js')
|
|
6
|
-
} else {
|
|
7
|
-
module.exports = require('./deployer-vercel.cjs.development.js')
|
|
8
|
-
}
|
|
140
|
+
export { VercelDeployer };
|
package/package.json
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
-
"module": "dist/deployer-vercel.esm.js",
|
|
8
7
|
"types": "dist/index.d.ts",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"default": "./dist/deployer-vercel.esm.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"default": "./dist/index.js"
|
|
18
|
-
}
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
19
12
|
},
|
|
20
13
|
"./package.json": "./package.json"
|
|
21
14
|
},
|
|
@@ -23,22 +16,22 @@
|
|
|
23
16
|
"author": "",
|
|
24
17
|
"license": "ISC",
|
|
25
18
|
"dependencies": {
|
|
26
|
-
"@mastra/core": "0.1.27-alpha.
|
|
27
|
-
"@mastra/deployer": "0.0.1-alpha.
|
|
19
|
+
"@mastra/core": "0.1.27-alpha.78",
|
|
20
|
+
"@mastra/deployer": "0.0.1-alpha.22"
|
|
28
21
|
},
|
|
29
22
|
"devDependencies": {
|
|
30
23
|
"@babel/preset-env": "^7.26.0",
|
|
31
24
|
"@babel/preset-typescript": "^7.26.0",
|
|
32
25
|
"@tsconfig/recommended": "^1.0.7",
|
|
33
|
-
"@types/jsdom": "^21.1.7",
|
|
34
26
|
"@types/node": "^22.9.0",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"vercel": "^39.3.0"
|
|
27
|
+
"tsup": "^8.0.1",
|
|
28
|
+
"typescript": "^5.3.3",
|
|
29
|
+
"vercel": "^39.3.0",
|
|
30
|
+
"vitest": "^3.0.4"
|
|
38
31
|
},
|
|
39
32
|
"scripts": {
|
|
40
|
-
"build": "dts
|
|
41
|
-
"
|
|
33
|
+
"build": "tsup-node src/index.ts --format esm --dts --clean --treeshake",
|
|
34
|
+
"dev": "tsup-node src/index.ts --format esm --dts --clean --treeshake --watch",
|
|
42
35
|
"test": "vitest run"
|
|
43
36
|
}
|
|
44
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ export class VercelDeployer extends MastraDeployer {
|
|
|
19
19
|
constructor({ scope, env, projectName }: { env?: Record<string, any>; scope: string; projectName: string }) {
|
|
20
20
|
super({ scope, env, projectName });
|
|
21
21
|
}
|
|
22
|
+
|
|
22
23
|
writeFiles({ dir }: { dir: string }): void {
|
|
23
24
|
this.writeIndex({ dir });
|
|
24
25
|
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"moduleResolution": "bundler",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"rootDir": "./src"
|
|
7
|
-
},
|
|
2
|
+
"extends": "../../tsconfig.node.json",
|
|
8
3
|
"include": ["src/**/*"],
|
|
9
4
|
"exclude": ["node_modules", "**/*.test.ts"]
|
|
10
5
|
}
|