@mastra/deployer-vercel 0.0.1-alpha.27 → 0.0.1-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/dist/index.js CHANGED
@@ -1,140 +1,8 @@
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';
5
1
 
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
- };
2
+ 'use strict'
139
3
 
140
- export { VercelDeployer };
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./deployer-vercel.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./deployer-vercel.cjs.development.js')
8
+ }
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.1-alpha.27",
3
+ "version": "0.0.1-alpha.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
+ "module": "dist/deployer-vercel.esm.js",
7
8
  "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/deployer-vercel.esm.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ }
12
19
  },
13
20
  "./package.json": "./package.json"
14
21
  },
@@ -16,22 +23,23 @@
16
23
  "author": "",
17
24
  "license": "ISC",
18
25
  "dependencies": {
19
- "@mastra/core": "0.1.27-alpha.78",
20
- "@mastra/deployer": "0.0.1-alpha.22"
26
+ "@mastra/core": "0.1.27-alpha.66",
27
+ "@mastra/deployer": "0.0.1-alpha.1"
21
28
  },
22
29
  "devDependencies": {
23
30
  "@babel/preset-env": "^7.26.0",
24
31
  "@babel/preset-typescript": "^7.26.0",
25
32
  "@tsconfig/recommended": "^1.0.7",
33
+ "@types/jsdom": "^21.1.7",
26
34
  "@types/node": "^22.9.0",
27
- "tsup": "^8.0.1",
28
- "typescript": "^5.3.3",
29
- "vercel": "^39.3.0",
30
- "vitest": "^3.0.4"
35
+ "@types/pg": "^8.11.10",
36
+ "dts-cli": "^2.0.5",
37
+ "vitest": "^2.1.8",
38
+ "vercel": "^39.3.0"
31
39
  },
32
40
  "scripts": {
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",
41
+ "build": "dts build",
42
+ "build:dev": "dts watch",
35
43
  "test": "vitest run"
36
44
  }
37
45
  }
package/src/index.ts CHANGED
@@ -19,7 +19,6 @@ 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
-
23
22
  writeFiles({ dir }: { dir: string }): void {
24
23
  this.writeIndex({ dir });
25
24
 
@@ -124,6 +123,7 @@ export class VercelDeployer extends MastraDeployer {
124
123
 
125
124
  // Create the command array with base arguments
126
125
  const commandArgs = [
126
+ '--debug',
127
127
  '--scope',
128
128
  this.scope as string,
129
129
  '--cwd',
@@ -141,6 +141,9 @@ export class VercelDeployer extends MastraDeployer {
141
141
  }
142
142
 
143
143
  // Run the Vercel deploy command
144
+ // console.log('Running command:', 'vercel', commandArgs.join(' '));
145
+ console.log(`vercel ${commandArgs.join(' ')}`);
146
+
144
147
  child_process.execSync(`vercel ${commandArgs.join(' ')}`, {
145
148
  cwd: dir,
146
149
  env: {
package/tsconfig.json CHANGED
@@ -1,5 +1,10 @@
1
1
  {
2
- "extends": "../../tsconfig.node.json",
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "moduleResolution": "bundler",
5
+ "outDir": "./dist",
6
+ "rootDir": "./src"
7
+ },
3
8
  "include": ["src/**/*"],
4
9
  "exclude": ["node_modules", "**/*.test.ts"]
5
10
  }
package/vitest.config.ts CHANGED
@@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
- environment: 'node',
5
+ globals: true,
6
6
  include: ['src/**/*.test.ts'],
7
7
  },
8
8
  });