@mastra/deployer-netlify 0.0.1-alpha.3 → 0.0.1-alpha.31

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 CHANGED
@@ -1,5 +1,238 @@
1
1
  # @mastra/deployer-netlify
2
2
 
3
+ ## 0.0.1-alpha.31
4
+
5
+ ### Patch Changes
6
+
7
+ - 38b7f66: Update deployer logic
8
+ - Updated dependencies [2f17a5f]
9
+ - Updated dependencies [0696eeb]
10
+ - Updated dependencies [cb290ee]
11
+ - Updated dependencies [b4d7416]
12
+ - Updated dependencies [38b7f66]
13
+ - @mastra/core@0.2.0-alpha.84
14
+ - @mastra/deployer@0.0.1-alpha.29
15
+
16
+ ## 0.0.1-alpha.30
17
+
18
+ ### Patch Changes
19
+
20
+ - 9625602: Use mastra core splitted bundles in other packages
21
+ - Updated dependencies [2ab57d6]
22
+ - Updated dependencies [30322ce]
23
+ - Updated dependencies [78eec7c]
24
+ - Updated dependencies [9625602]
25
+ - Updated dependencies [8769a62]
26
+ - @mastra/deployer@0.0.1-alpha.28
27
+ - @mastra/core@0.2.0-alpha.83
28
+
29
+ ## 0.0.1-alpha.29
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [73d112c]
34
+ - Updated dependencies [ac8c61a]
35
+ - @mastra/deployer@0.0.1-alpha.27
36
+ - @mastra/core@0.1.27-alpha.82
37
+
38
+ ## 0.0.1-alpha.28
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [9fb3039]
43
+ - @mastra/core@0.1.27-alpha.81
44
+ - @mastra/deployer@0.0.1-alpha.26
45
+
46
+ ## 0.0.1-alpha.27
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [327ece7]
51
+ - @mastra/core@0.1.27-alpha.80
52
+ - @mastra/deployer@0.0.1-alpha.25
53
+
54
+ ## 0.0.1-alpha.26
55
+
56
+ ### Patch Changes
57
+
58
+ - Updated dependencies [21fe536]
59
+ - @mastra/core@0.1.27-alpha.79
60
+ - @mastra/deployer@0.0.1-alpha.24
61
+
62
+ ## 0.0.1-alpha.25
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [88f18d7]
67
+ - @mastra/deployer@0.0.1-alpha.23
68
+
69
+ ## 0.0.1-alpha.24
70
+
71
+ ### Patch Changes
72
+
73
+ - 44c7c26: Rebuild
74
+
75
+ ## 0.0.1-alpha.23
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies [685108a]
80
+ - Updated dependencies [685108a]
81
+ - @mastra/deployer@0.0.1-alpha.22
82
+ - @mastra/core@0.1.27-alpha.78
83
+
84
+ ## 0.0.1-alpha.22
85
+
86
+ ### Patch Changes
87
+
88
+ - 2b75edf: mastra deployers tsup bundling
89
+ - Updated dependencies [8105fae]
90
+ - Updated dependencies [cfb966f]
91
+ - @mastra/core@0.1.27-alpha.77
92
+ - @mastra/deployer@0.0.1-alpha.21
93
+
94
+ ## 0.0.1-alpha.21
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [ae7bf94]
99
+ - Updated dependencies [ae7bf94]
100
+ - @mastra/deployer@0.0.1-alpha.20
101
+ - @mastra/core@0.1.27-alpha.76
102
+
103
+ ## 0.0.1-alpha.20
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [23dcb23]
108
+ - Updated dependencies [7064554]
109
+ - @mastra/core@0.1.27-alpha.75
110
+ - @mastra/deployer@0.0.1-alpha.19
111
+
112
+ ## 0.0.1-alpha.19
113
+
114
+ ### Patch Changes
115
+
116
+ - Updated dependencies [7b87567]
117
+ - @mastra/core@0.1.27-alpha.74
118
+ - @mastra/deployer@0.0.1-alpha.18
119
+
120
+ ## 0.0.1-alpha.18
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [3427b95]
125
+ - @mastra/core@0.1.27-alpha.73
126
+ - @mastra/deployer@0.0.1-alpha.17
127
+
128
+ ## 0.0.1-alpha.17
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies [e4d4ede]
133
+ - Updated dependencies [06b2c0a]
134
+ - @mastra/core@0.1.27-alpha.72
135
+ - @mastra/deployer@0.0.1-alpha.16
136
+
137
+ ## 0.0.1-alpha.16
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies [d9c8dd0]
142
+ - @mastra/deployer@0.0.1-alpha.15
143
+ - @mastra/core@0.1.27-alpha.71
144
+
145
+ ## 0.0.1-alpha.15
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies [ad2cd74]
150
+ - @mastra/deployer@0.0.1-alpha.14
151
+
152
+ ## 0.0.1-alpha.14
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies [a1774e7]
157
+ - @mastra/deployer@0.0.1-alpha.13
158
+
159
+ ## 0.0.1-alpha.13
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies [28dceab]
164
+ - @mastra/deployer@0.0.1-alpha.12
165
+
166
+ ## 0.0.1-alpha.12
167
+
168
+ ### Patch Changes
169
+
170
+ - bdaf834: publish packages
171
+ - Updated dependencies [bdaf834]
172
+ - @mastra/deployer@0.0.1-alpha.11
173
+
174
+ ## 0.0.1-alpha.11
175
+
176
+ ### Patch Changes
177
+
178
+ - Updated dependencies [dd6d87f]
179
+ - Updated dependencies [04434b6]
180
+ - @mastra/core@0.1.27-alpha.70
181
+ - @mastra/deployer@0.0.1-alpha.10
182
+
183
+ ## 0.0.1-alpha.10
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies [9066f95]
188
+ - @mastra/deployer@0.0.1-alpha.9
189
+
190
+ ## 0.0.1-alpha.9
191
+
192
+ ### Patch Changes
193
+
194
+ - 0d5a03d: Vector store modules
195
+
196
+ ## 0.0.1-alpha.8
197
+
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies [b425845]
201
+ - @mastra/deployer@0.0.1-alpha.8
202
+
203
+ ## 0.0.1-alpha.7
204
+
205
+ ### Patch Changes
206
+
207
+ - Updated dependencies [1944807]
208
+ - Updated dependencies [9ade36e]
209
+ - @mastra/deployer@0.0.1-alpha.7
210
+ - @mastra/core@0.1.27-alpha.69
211
+
212
+ ## 0.0.1-alpha.6
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [291fe57]
217
+ - Updated dependencies [1a41fbf]
218
+ - @mastra/deployer@0.0.1-alpha.6
219
+
220
+ ## 0.0.1-alpha.5
221
+
222
+ ### Patch Changes
223
+
224
+ - Updated dependencies [0be7181]
225
+ - Updated dependencies [0be7181]
226
+ - @mastra/core@0.1.27-alpha.68
227
+ - @mastra/deployer@0.0.1-alpha.5
228
+
229
+ ## 0.0.1-alpha.4
230
+
231
+ ### Patch Changes
232
+
233
+ - Updated dependencies [7babd5c]
234
+ - @mastra/deployer@0.0.1-alpha.4
235
+
3
236
  ## 0.0.1-alpha.3
4
237
 
5
238
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @mastra/deployer-netlify
2
+
3
+ A Netlify deployer for Mastra applications.
4
+
5
+ ## Features
6
+
7
+ - Deploy Mastra applications to Netlify Functions
8
+ - Automatic site creation and configuration
9
+ - Serverless function support with Edge Functions
10
+ - Zero-configuration deployments
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pnpm add @mastra/deployer-netlify
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ The Netlify deployer is used as part of the Mastra framework:
21
+
22
+ ```typescript
23
+ import { Mastra } from '@mastra/core';
24
+ import { NetlifyDeployer } from '@mastra/deployer-netlify';
25
+
26
+ const deployer = new NetlifyDeployer({
27
+ scope: 'your-team-id',
28
+ projectName: 'your-project-name',
29
+ });
30
+
31
+ const mastra = new Mastra({
32
+ deployer,
33
+ // ... other Mastra configuration options
34
+ });
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ ### Constructor Options
40
+
41
+ - `scope` (required): Your Netlify team ID
42
+ - `projectName`: Name of your Netlify site (will be created if it doesn't exist)
43
+
44
+ ## Project Structure
45
+
46
+ The deployer automatically creates the following structure:
47
+
48
+ ```
49
+ your-project/
50
+ ├── netlify/
51
+ │ └── functions/
52
+ │ └── api/
53
+ └── netlify.toml
54
+ ```
55
+
56
+ ### netlify.toml Configuration
57
+
58
+ The deployer creates a `netlify.toml` with the following defaults:
59
+
60
+ ```toml
61
+ [functions]
62
+ node_bundler = "esbuild"
63
+ directory = "/netlify/functions"
64
+
65
+ [[redirects]]
66
+ force = true
67
+ from = "/*"
68
+ status = 200
69
+ to = "/.netlify/functions/api/:splat"
70
+ ```
71
+
72
+ ## Environment Variables
73
+
74
+ Environment variables are handled automatically through:
75
+
76
+ - `.env` files in your project
77
+ - Environment variables passed through the Mastra configuration
78
+ - Netlify's environment variable UI
79
+
80
+ ## Deployment Process
81
+
82
+ The deployer will:
83
+
84
+ 1. Create a new site if it doesn't exist
85
+ 2. Configure the site with your environment variables
86
+ 3. Deploy your application to Netlify Functions
package/dist/index.d.ts CHANGED
@@ -1,19 +1,21 @@
1
- import { MastraDeployer } from '@mastra/core';
2
- export declare class NetlifyDeployer extends MastraDeployer {
3
- constructor({ scope, env, projectName }: {
4
- projectName: string;
5
- env?: Record<string, any>;
1
+ import { Deployer } from '@mastra/deployer';
2
+
3
+ declare class NetlifyDeployer extends Deployer {
4
+ protected scope: string;
5
+ protected projectName: string;
6
+ protected token: string;
7
+ constructor({ scope, projectName, token }: {
6
8
  scope: string;
9
+ projectName: string;
10
+ token: string;
7
11
  });
8
12
  writeFiles({ dir }: {
9
13
  dir: string;
10
14
  }): void;
11
- deploy({ dir, token }: {
12
- dir: string;
13
- token: string;
14
- }): Promise<void>;
15
- writeIndex({ dir }: {
16
- dir: string;
17
- }): void;
15
+ deploy(outputDirectory: string): Promise<void>;
16
+ prepare(outputDirectory: string): Promise<void>;
17
+ bundle(mastraDir: string, outputDirectory: string): Promise<void>;
18
+ private getEntry;
18
19
  }
19
- //# sourceMappingURL=index.d.ts.map
20
+
21
+ export { NetlifyDeployer };
package/dist/index.js CHANGED
@@ -1,8 +1,148 @@
1
+ import { Deployer } from '@mastra/deployer';
2
+ import { getBundler } from '@mastra/deployer/build';
3
+ import virtual from '@rollup/plugin-virtual';
4
+ import { execa } from 'execa';
5
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
6
+ import { join } from 'path';
1
7
 
2
- 'use strict'
8
+ // src/index.ts
3
9
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./deployer-netlify.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./deployer-netlify.cjs.development.js')
10
+ // src/helpers.ts
11
+ async function createNetlifySite({ token, name, scope }) {
12
+ console.log(token, name, scope);
13
+ const response = await fetch("https://api.netlify.com/api/v1/sites", {
14
+ method: "POST",
15
+ headers: {
16
+ Authorization: `Bearer ${token}`,
17
+ "Content-Type": "application/json"
18
+ },
19
+ body: JSON.stringify({
20
+ name,
21
+ account_slug: scope,
22
+ // Optional - if not provided, creates in user's default account
23
+ force_ssl: true
24
+ // Enable HTTPS
25
+ })
26
+ });
27
+ const data = await response.json();
28
+ if (!response.ok) {
29
+ console.error(JSON.stringify(data));
30
+ throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
31
+ }
32
+ return {
33
+ id: data.id,
34
+ name: data.name,
35
+ url: data.ssl_url || data.url,
36
+ adminUrl: data.admin_url
37
+ };
8
38
  }
39
+ async function findNetlifySite({ token, name, scope }) {
40
+ const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
41
+ headers: {
42
+ Authorization: `Bearer ${token}`,
43
+ "Content-Type": "application/json"
44
+ }
45
+ });
46
+ const data = await response.json();
47
+ if (!response.ok) {
48
+ throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
49
+ }
50
+ return data.find((site) => site.name === name);
51
+ }
52
+ async function getOrCreateSite({ token, name, scope }) {
53
+ let existingSite;
54
+ try {
55
+ existingSite = await findNetlifySite({ token, name, scope });
56
+ } catch (e) {
57
+ }
58
+ if (existingSite) {
59
+ return existingSite;
60
+ }
61
+ return createNetlifySite({ token, name, scope });
62
+ }
63
+
64
+ // src/index.ts
65
+ var NetlifyDeployer = class extends Deployer {
66
+ scope;
67
+ projectName;
68
+ token;
69
+ constructor({ scope, projectName, token }) {
70
+ super({ name: "NETLIFY" });
71
+ this.scope = scope;
72
+ this.projectName = projectName;
73
+ this.token = token;
74
+ }
75
+ writeFiles({ dir }) {
76
+ if (!existsSync(join(dir, "netlify/functions/api"))) {
77
+ mkdirSync(join(dir, "netlify/functions/api"), { recursive: true });
78
+ }
79
+ writeFileSync(
80
+ join(dir, "netlify.toml"),
81
+ `[functions]
82
+ node_bundler = "esbuild"
83
+ directory = "netlify/functions"
84
+
85
+ [[redirects]]
86
+ force = true
87
+ from = "/*"
88
+ status = 200
89
+ to = "/.netlify/functions/api/:splat"
90
+ `
91
+ );
92
+ }
93
+ async deploy(outputDirectory) {
94
+ const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
95
+ const p2 = execa(
96
+ "npx",
97
+ [
98
+ "netlify-cli",
99
+ "deploy",
100
+ "--site",
101
+ site.id,
102
+ "--auth",
103
+ this.token,
104
+ "--dir",
105
+ ".",
106
+ "--functions",
107
+ "./netlify/functions"
108
+ ],
109
+ {
110
+ cwd: outputDirectory
111
+ }
112
+ );
113
+ p2.stdout.pipe(process.stdout);
114
+ await p2;
115
+ }
116
+ async prepare(outputDirectory) {
117
+ await super.prepare(outputDirectory);
118
+ if (!existsSync(join(outputDirectory, "netlify/functions/api"))) {
119
+ mkdirSync(join(outputDirectory, "netlify/functions/api"), { recursive: true });
120
+ }
121
+ this.writeFiles({ dir: outputDirectory });
122
+ }
123
+ async bundle(mastraDir, outputDirectory) {
124
+ const bundler = await getBundler({
125
+ input: "#entry",
126
+ external: [/^@opentelemetry\//],
127
+ plugins: [virtual({ "#entry": this.getEntry() })]
128
+ });
129
+ bundler.write({
130
+ inlineDynamicImports: true,
131
+ file: join(outputDirectory, "netlify", "functions", "api", "index.mjs"),
132
+ format: "es"
133
+ });
134
+ }
135
+ getEntry() {
136
+ return `
137
+ import { handle } from 'hono/netlify'
138
+ import { mastra } from '#mastra';
139
+ import { createHonoServer } from '#server';
140
+
141
+ const app = await createHonoServer(mastra);
142
+
143
+ export default handle(app)
144
+ `;
145
+ }
146
+ };
147
+
148
+ export { NetlifyDeployer };
package/package.json CHANGED
@@ -1,21 +1,14 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.0.1-alpha.3",
3
+ "version": "0.0.1-alpha.31",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
- "module": "dist/deployer-netlify.esm.js",
8
7
  "types": "dist/index.d.ts",
9
8
  "exports": {
10
9
  ".": {
11
- "import": {
12
- "types": "./dist/index.d.ts",
13
- "default": "./dist/deployer-netlify.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,27 +16,26 @@
23
16
  "author": "",
24
17
  "license": "ISC",
25
18
  "dependencies": {
19
+ "@rollup/plugin-virtual": "^3.0.2",
26
20
  "date-fns": "^4.1.0",
27
21
  "dotenv": "^16.3.1",
28
22
  "execa": "^9.3.1",
29
23
  "netlify-cli": "^18.0.1",
30
24
  "zod": "^3.24.1",
31
- "@mastra/core": "0.1.27-alpha.67",
32
- "@mastra/deployer": "0.0.1-alpha.3"
25
+ "@mastra/core": "0.2.0-alpha.84",
26
+ "@mastra/deployer": "0.0.1-alpha.29"
33
27
  },
34
28
  "devDependencies": {
35
29
  "@babel/preset-env": "^7.26.0",
36
30
  "@babel/preset-typescript": "^7.26.0",
37
31
  "@tsconfig/recommended": "^1.0.7",
38
- "@types/jsdom": "^21.1.7",
39
32
  "@types/node": "^22.9.0",
40
- "@types/pg": "^8.11.10",
41
- "dts-cli": "^2.0.5",
42
- "vitest": "^2.1.8"
33
+ "tsup": "^8.0.1",
34
+ "vitest": "^3.0.4"
43
35
  },
44
36
  "scripts": {
45
- "build": "dts build",
46
- "build:dev": "dts watch",
37
+ "build": "tsup-node src/index.ts --format esm --dts --clean --treeshake",
38
+ "dev": "tsup-node src/index.ts --format esm --dts --clean --treeshake --watch",
47
39
  "test": "vitest run"
48
40
  }
49
41
  }