@mastra/deployer-vercel 0.1.6-alpha.0 → 0.1.6-alpha.3
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/.turbo/turbo-build.log +11 -6
- package/CHANGELOG.md +37 -0
- package/dist/_tsup-dts-rollup.d.cts +21 -0
- package/dist/index.cjs +167 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.js +2 -4
- package/eslint.config.js +6 -0
- package/package.json +17 -8
- package/src/index.ts +3 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/deployer-vercel@0.1.6-alpha.
|
|
3
|
-
> tsup src/index.ts --format esm --experimental-dts --clean --treeshake
|
|
2
|
+
> @mastra/deployer-vercel@0.1.6-alpha.3 build /home/runner/work/mastra/mastra/deployers/vercel
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.3.6
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 8212ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.7.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/deployers/vercel/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
-
|
|
14
|
+
Analysis will use the bundled TypeScript version 5.7.3
|
|
15
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/deployers/vercel/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 9544ms
|
|
15
17
|
[34mCLI[39m Cleaning output folder
|
|
16
18
|
[34mESM[39m Build start
|
|
17
|
-
[
|
|
18
|
-
[32mESM[39m
|
|
19
|
+
[34mCJS[39m Build start
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m4.01 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 225ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m4.73 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 231ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @mastra/deployer-vercel
|
|
2
2
|
|
|
3
|
+
## 0.1.6-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bb4f447: Add support for commonjs
|
|
8
|
+
- Updated dependencies [0fd78ac]
|
|
9
|
+
- Updated dependencies [0d25b75]
|
|
10
|
+
- Updated dependencies [fd14a3f]
|
|
11
|
+
- Updated dependencies [3f369a2]
|
|
12
|
+
- Updated dependencies [4d4e1e1]
|
|
13
|
+
- Updated dependencies [bb4f447]
|
|
14
|
+
- @mastra/deployer@0.1.6-alpha.3
|
|
15
|
+
- @mastra/core@0.4.3-alpha.3
|
|
16
|
+
|
|
17
|
+
## 0.1.6-alpha.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [2512a93]
|
|
22
|
+
- Updated dependencies [e62de74]
|
|
23
|
+
- @mastra/core@0.4.3-alpha.2
|
|
24
|
+
- @mastra/deployer@0.1.6-alpha.2
|
|
25
|
+
|
|
26
|
+
## 0.1.6-alpha.1
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [0d185b1]
|
|
31
|
+
- Updated dependencies [ed55f1d]
|
|
32
|
+
- Updated dependencies [80cdd76]
|
|
33
|
+
- Updated dependencies [8d13b14]
|
|
34
|
+
- Updated dependencies [3ee4831]
|
|
35
|
+
- Updated dependencies [108793c]
|
|
36
|
+
- Updated dependencies [5f28f44]
|
|
37
|
+
- @mastra/core@0.4.3-alpha.1
|
|
38
|
+
- @mastra/deployer@0.1.6-alpha.1
|
|
39
|
+
|
|
3
40
|
## 0.1.6-alpha.0
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Deployer } from '@mastra/deployer';
|
|
2
|
+
|
|
3
|
+
export declare class VercelDeployer extends Deployer {
|
|
4
|
+
private teamId;
|
|
5
|
+
private projectName;
|
|
6
|
+
private token;
|
|
7
|
+
constructor({ teamId, projectName, token }: {
|
|
8
|
+
teamId: string;
|
|
9
|
+
projectName: string;
|
|
10
|
+
token: string;
|
|
11
|
+
});
|
|
12
|
+
writeFiles(outputDirectory: string): void;
|
|
13
|
+
private getProjectId;
|
|
14
|
+
private syncEnv;
|
|
15
|
+
prepare(outputDirectory: string): Promise<void>;
|
|
16
|
+
private getEntry;
|
|
17
|
+
bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
18
|
+
deploy(outputDirectory: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { }
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var child_process = require('child_process');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var process = require('process');
|
|
7
|
+
var deployer = require('@mastra/deployer');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
|
|
30
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
31
|
+
|
|
32
|
+
// src/index.ts
|
|
33
|
+
var VercelDeployer = class extends deployer.Deployer {
|
|
34
|
+
teamId;
|
|
35
|
+
projectName;
|
|
36
|
+
token;
|
|
37
|
+
constructor({ teamId, projectName, token }) {
|
|
38
|
+
super({ name: "VERCEL" });
|
|
39
|
+
this.teamId = teamId;
|
|
40
|
+
this.projectName = projectName;
|
|
41
|
+
this.token = token;
|
|
42
|
+
}
|
|
43
|
+
writeFiles(outputDirectory) {
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
path.join(outputDirectory, this.outputDir, "vercel.json"),
|
|
46
|
+
JSON.stringify(
|
|
47
|
+
{
|
|
48
|
+
version: 2,
|
|
49
|
+
installCommand: "npm install --omit=dev",
|
|
50
|
+
builds: [
|
|
51
|
+
{
|
|
52
|
+
src: "index.mjs",
|
|
53
|
+
use: "@vercel/node",
|
|
54
|
+
config: { includeFiles: ["**"] }
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
routes: [
|
|
58
|
+
{
|
|
59
|
+
src: "/(.*)",
|
|
60
|
+
dest: "index.mjs"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
null,
|
|
65
|
+
2
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
getProjectId({ dir }) {
|
|
70
|
+
const projectJsonPath = path.join(dir, ".vercel", "project.json");
|
|
71
|
+
try {
|
|
72
|
+
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, "utf-8"));
|
|
73
|
+
return projectJson.projectId;
|
|
74
|
+
} catch {
|
|
75
|
+
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async syncEnv(envVars) {
|
|
79
|
+
console.log("Syncing environment variables...");
|
|
80
|
+
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
81
|
+
if (!key || !value) {
|
|
82
|
+
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
key,
|
|
86
|
+
value,
|
|
87
|
+
target: ["production", "preview", "development"],
|
|
88
|
+
type: "plain"
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
const projectId = this.getProjectId({ dir: process__default.default.cwd() });
|
|
93
|
+
const response = await fetch(
|
|
94
|
+
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${this.teamId}&upsert=true`,
|
|
95
|
+
{
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
Authorization: `Bearer ${this.token}`,
|
|
99
|
+
"Content-Type": "application/json"
|
|
100
|
+
},
|
|
101
|
+
body: JSON.stringify(vercelEnvVars)
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
if (!response.ok) {
|
|
105
|
+
const error = await response.json();
|
|
106
|
+
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
107
|
+
}
|
|
108
|
+
console.log("\u2713 Successfully synced environment variables");
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (error instanceof Error) {
|
|
111
|
+
console.error("Failed to sync environment variables:", error.message);
|
|
112
|
+
} else {
|
|
113
|
+
console.error("Failed to sync environment variables:", error);
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async prepare(outputDirectory) {
|
|
119
|
+
await super.prepare(outputDirectory);
|
|
120
|
+
await this.writeFiles(outputDirectory);
|
|
121
|
+
}
|
|
122
|
+
getEntry() {
|
|
123
|
+
return `
|
|
124
|
+
import { handle } from 'hono/vercel'
|
|
125
|
+
import { mastra } from '#mastra';
|
|
126
|
+
import { createHonoServer } from '#server';
|
|
127
|
+
|
|
128
|
+
const app = await createHonoServer(mastra);
|
|
129
|
+
|
|
130
|
+
export const GET = handle(app);
|
|
131
|
+
export const POST = handle(app);
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
async bundle(entryFile, outputDirectory) {
|
|
135
|
+
return this._bundle(this.getEntry(), entryFile, outputDirectory);
|
|
136
|
+
}
|
|
137
|
+
async deploy(outputDirectory) {
|
|
138
|
+
const envVars = await this.loadEnvVars();
|
|
139
|
+
const commandArgs = [
|
|
140
|
+
"--scope",
|
|
141
|
+
this.teamId,
|
|
142
|
+
"--cwd",
|
|
143
|
+
path.join(outputDirectory, this.outputDir),
|
|
144
|
+
"--token",
|
|
145
|
+
this.token,
|
|
146
|
+
"deploy",
|
|
147
|
+
"--yes",
|
|
148
|
+
...this.projectName ? ["--name", this.projectName] : []
|
|
149
|
+
];
|
|
150
|
+
child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
151
|
+
cwd: path.join(outputDirectory, this.outputDir),
|
|
152
|
+
env: {
|
|
153
|
+
// ...this.env,
|
|
154
|
+
PATH: process__default.default.env.PATH
|
|
155
|
+
},
|
|
156
|
+
stdio: "inherit"
|
|
157
|
+
});
|
|
158
|
+
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
159
|
+
if (envVars.size > 0) {
|
|
160
|
+
await this.syncEnv(envVars);
|
|
161
|
+
} else {
|
|
162
|
+
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
exports.VercelDeployer = VercelDeployer;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VercelDeployer } from './_tsup-dts-rollup.cjs';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Deployer } from '@mastra/deployer';
|
|
2
|
-
import '@mastra/deployer/build';
|
|
3
|
-
import '@rollup/plugin-virtual';
|
|
4
1
|
import * as child_process from 'child_process';
|
|
5
2
|
import { writeFileSync, readFileSync } from 'fs';
|
|
6
3
|
import { join } from 'path';
|
|
7
4
|
import process from 'process';
|
|
5
|
+
import { Deployer } from '@mastra/deployer';
|
|
8
6
|
|
|
9
7
|
// src/index.ts
|
|
10
8
|
var VercelDeployer = class extends Deployer {
|
|
@@ -48,7 +46,7 @@ var VercelDeployer = class extends Deployer {
|
|
|
48
46
|
try {
|
|
49
47
|
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
50
48
|
return projectJson.projectId;
|
|
51
|
-
} catch
|
|
49
|
+
} catch {
|
|
52
50
|
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
53
51
|
}
|
|
54
52
|
}
|
package/eslint.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.1.6-alpha.
|
|
3
|
+
"version": "0.1.6-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
12
18
|
},
|
|
13
19
|
"./package.json": "./package.json"
|
|
14
20
|
},
|
|
@@ -18,20 +24,23 @@
|
|
|
18
24
|
"dependencies": {
|
|
19
25
|
"@rollup/plugin-virtual": "^3.0.2",
|
|
20
26
|
"fs-extra": "^11.2.0",
|
|
21
|
-
"@mastra/core": "^0.4.3-alpha.
|
|
22
|
-
"@mastra/deployer": "^0.1.6-alpha.
|
|
27
|
+
"@mastra/core": "^0.4.3-alpha.3",
|
|
28
|
+
"@mastra/deployer": "^0.1.6-alpha.3"
|
|
23
29
|
},
|
|
24
30
|
"devDependencies": {
|
|
31
|
+
"eslint": "^9.20.1",
|
|
25
32
|
"@microsoft/api-extractor": "^7.49.2",
|
|
26
33
|
"@types/node": "^22.13.1",
|
|
27
34
|
"tsup": "^8.0.1",
|
|
28
35
|
"typescript": "^5.7.3",
|
|
29
36
|
"vercel": "^39.3.0",
|
|
30
|
-
"vitest": "^3.0.4"
|
|
37
|
+
"vitest": "^3.0.4",
|
|
38
|
+
"@internal/lint": "0.0.0"
|
|
31
39
|
},
|
|
32
40
|
"scripts": {
|
|
33
|
-
"build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
|
|
41
|
+
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake",
|
|
34
42
|
"build:watch": "pnpm build --watch",
|
|
35
|
-
"test": "vitest run"
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"lint": "eslint ."
|
|
36
45
|
}
|
|
37
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Deployer } from '@mastra/deployer';
|
|
2
|
-
import { getBundler } from '@mastra/deployer/build';
|
|
3
|
-
import virtual from '@rollup/plugin-virtual';
|
|
4
1
|
import * as child_process from 'child_process';
|
|
5
2
|
import { readFileSync, writeFileSync } from 'fs';
|
|
6
3
|
import { join } from 'path';
|
|
7
4
|
import process from 'process';
|
|
8
5
|
|
|
6
|
+
import { Deployer } from '@mastra/deployer';
|
|
7
|
+
|
|
9
8
|
interface EnvVar {
|
|
10
9
|
key: string;
|
|
11
10
|
value: string;
|
|
@@ -63,7 +62,7 @@ export class VercelDeployer extends Deployer {
|
|
|
63
62
|
try {
|
|
64
63
|
const projectJson = JSON.parse(readFileSync(projectJsonPath, 'utf-8'));
|
|
65
64
|
return projectJson.projectId;
|
|
66
|
-
} catch
|
|
65
|
+
} catch {
|
|
67
66
|
throw new Error('Could not find project ID. Make sure the project has been deployed first.');
|
|
68
67
|
}
|
|
69
68
|
}
|