@mastra/deployer-netlify 0.0.0-storage-20250225005900 → 0.0.0-vnextWorkflows-20250416071310

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.
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
package/README.md CHANGED
@@ -26,6 +26,7 @@ import { NetlifyDeployer } from '@mastra/deployer-netlify';
26
26
  const deployer = new NetlifyDeployer({
27
27
  scope: 'your-team-id',
28
28
  projectName: 'your-project-name',
29
+ token: 'your-netlify-token',
29
30
  });
30
31
 
31
32
  const mastra = new Mastra({
@@ -38,8 +39,9 @@ const mastra = new Mastra({
38
39
 
39
40
  ### Constructor Options
40
41
 
41
- - `scope` (required): Your Netlify team ID
42
+ - `scope` (required): Your Netlify team slug or ID
42
43
  - `projectName`: Name of your Netlify site (will be created if it doesn't exist)
44
+ - `token`: Your Netlify authentication token
43
45
 
44
46
  ## Project Structure
45
47
 
@@ -0,0 +1,39 @@
1
+ import { Deployer } from '@mastra/deployer';
2
+
3
+ export declare function getOrCreateSite({ token, name, scope }: {
4
+ token: string;
5
+ name: string;
6
+ scope: string;
7
+ }): Promise<{
8
+ id: string | undefined;
9
+ name: string | undefined;
10
+ url: string | undefined;
11
+ adminUrl: string | undefined;
12
+ } | {
13
+ id: string;
14
+ name: string;
15
+ ssl_url: string;
16
+ url: string;
17
+ admin_url: string;
18
+ }>;
19
+
20
+ export declare class NetlifyDeployer extends Deployer {
21
+ protected scope: string;
22
+ protected projectName: string;
23
+ protected token: string;
24
+ constructor({ scope, projectName, token }: {
25
+ scope: string;
26
+ projectName: string;
27
+ token: string;
28
+ });
29
+ writeFiles({ dir }: {
30
+ dir: string;
31
+ }): void;
32
+ protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
33
+ deploy(outputDirectory: string): Promise<void>;
34
+ prepare(outputDirectory: string): Promise<void>;
35
+ bundle(entryFile: string, outputDirectory: string): Promise<void>;
36
+ private getEntry;
37
+ }
38
+
39
+ export { }
@@ -29,6 +29,7 @@ export declare class NetlifyDeployer extends Deployer {
29
29
  writeFiles({ dir }: {
30
30
  dir: string;
31
31
  }): void;
32
+ protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
32
33
  deploy(outputDirectory: string): Promise<void>;
33
34
  prepare(outputDirectory: string): Promise<void>;
34
35
  bundle(entryFile: string, outputDirectory: string): Promise<void>;
package/dist/index.cjs ADDED
@@ -0,0 +1,153 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+ var deployer = require('@mastra/deployer');
6
+ var services = require('@mastra/deployer/services');
7
+ var execa = require('execa');
8
+
9
+ // src/index.ts
10
+
11
+ // src/helpers.ts
12
+ async function createNetlifySite({ 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
+ };
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 || !Array.isArray(data)) {
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 {
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.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 (!fs.existsSync(path.join(dir, "netlify/functions/api"))) {
77
+ fs.mkdirSync(path.join(dir, "netlify/functions/api"), { recursive: true });
78
+ }
79
+ fs.writeFileSync(
80
+ path.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 installDependencies(outputDirectory, rootDir = process.cwd()) {
94
+ const deps = new services.DepsService(rootDir);
95
+ deps.__setLogger(this.logger);
96
+ await deps.install({
97
+ dir: path.join(outputDirectory, this.outputDir),
98
+ architecture: {
99
+ os: ["linux"],
100
+ cpu: ["x64"],
101
+ libc: ["gnu"]
102
+ }
103
+ });
104
+ }
105
+ async deploy(outputDirectory) {
106
+ const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
107
+ const p2 = execa.execa(
108
+ "npx",
109
+ [
110
+ "netlify-cli",
111
+ "deploy",
112
+ "--site",
113
+ site.id,
114
+ "--auth",
115
+ this.token,
116
+ "--dir",
117
+ ".",
118
+ "--functions",
119
+ "./netlify/functions"
120
+ ],
121
+ {
122
+ cwd: path.join(outputDirectory, this.outputDir)
123
+ }
124
+ );
125
+ p2.stdout.pipe(process.stdout);
126
+ await p2;
127
+ }
128
+ async prepare(outputDirectory) {
129
+ await super.prepare(outputDirectory);
130
+ this.writeFiles({ dir: path.join(outputDirectory, this.outputDir) });
131
+ }
132
+ async bundle(entryFile, outputDirectory) {
133
+ return this._bundle(
134
+ this.getEntry(),
135
+ entryFile,
136
+ outputDirectory,
137
+ path.join(outputDirectory, this.outputDir, "netlify", "functions", "api")
138
+ );
139
+ }
140
+ getEntry() {
141
+ return `
142
+ import { handle } from 'hono/netlify'
143
+ import { mastra } from '#mastra';
144
+ import { createHonoServer } from '#server';
145
+
146
+ const app = await createHonoServer(mastra);
147
+
148
+ export default handle(app)
149
+ `;
150
+ }
151
+ };
152
+
153
+ exports.NetlifyDeployer = NetlifyDeployer;
@@ -0,0 +1 @@
1
+ export { NetlifyDeployer } from './_tsup-dts-rollup.cjs';
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { Deployer } from '@mastra/deployer';
2
- import { execa } from 'execa';
3
1
  import { existsSync, mkdirSync, writeFileSync } from 'fs';
4
2
  import { join } from 'path';
3
+ import { Deployer } from '@mastra/deployer';
4
+ import { DepsService } from '@mastra/deployer/services';
5
+ import { execa } from 'execa';
5
6
 
6
7
  // src/index.ts
7
8
 
@@ -50,7 +51,7 @@ async function getOrCreateSite({ token, name, scope }) {
50
51
  let existingSite;
51
52
  try {
52
53
  existingSite = await findNetlifySite({ token, name, scope });
53
- } catch (e) {
54
+ } catch {
54
55
  }
55
56
  if (existingSite) {
56
57
  return existingSite;
@@ -87,6 +88,18 @@ to = "/.netlify/functions/api/:splat"
87
88
  `
88
89
  );
89
90
  }
91
+ async installDependencies(outputDirectory, rootDir = process.cwd()) {
92
+ const deps = new DepsService(rootDir);
93
+ deps.__setLogger(this.logger);
94
+ await deps.install({
95
+ dir: join(outputDirectory, this.outputDir),
96
+ architecture: {
97
+ os: ["linux"],
98
+ cpu: ["x64"],
99
+ libc: ["gnu"]
100
+ }
101
+ });
102
+ }
90
103
  async deploy(outputDirectory) {
91
104
  const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
92
105
  const p2 = execa(
package/package.json CHANGED
@@ -1,39 +1,51 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.0.0-storage-20250225005900",
3
+ "version": "0.0.0-vnextWorkflows-20250416071310",
4
4
  "description": "",
5
5
  "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "main": "dist/index.js",
7
10
  "types": "dist/index.d.ts",
8
11
  "exports": {
9
12
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
13
+ "import": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./dist/index.d.cts",
19
+ "default": "./dist/index.cjs"
20
+ }
12
21
  },
13
22
  "./package.json": "./package.json"
14
23
  },
15
24
  "keywords": [],
16
25
  "author": "",
17
- "license": "ISC",
26
+ "license": "Elastic-2.0",
18
27
  "dependencies": {
19
28
  "@rollup/plugin-virtual": "^3.0.2",
20
29
  "date-fns": "^4.1.0",
21
- "execa": "^9.3.1",
22
- "netlify-cli": "^18.0.1",
23
- "zod": "^3.24.1",
24
- "@mastra/core": "^0.0.0-storage-20250225005900",
25
- "@mastra/deployer": "^0.0.0-storage-20250225005900"
30
+ "execa": "^9.5.2",
31
+ "netlify-cli": "^19.0.3",
32
+ "zod": "^3.24.2",
33
+ "@mastra/core": "0.0.0-vnextWorkflows-20250416071310",
34
+ "@mastra/deployer": "0.0.0-vnextWorkflows-20250416071310"
26
35
  },
27
36
  "devDependencies": {
28
- "@microsoft/api-extractor": "^7.49.2",
29
- "@types/node": "^22.13.1",
30
- "tsup": "^8.0.1",
31
- "typescript": "^5.7.3",
32
- "vitest": "^3.0.4"
37
+ "@microsoft/api-extractor": "^7.52.1",
38
+ "@types/node": "^20.17.27",
39
+ "eslint": "^9.23.0",
40
+ "tsup": "^8.4.0",
41
+ "typescript": "^5.8.2",
42
+ "vitest": "^3.0.9",
43
+ "@internal/lint": "0.0.2"
33
44
  },
34
45
  "scripts": {
35
- "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
46
+ "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
36
47
  "build:watch": "pnpm build --watch",
37
- "test": "vitest run"
48
+ "test": "vitest run",
49
+ "lint": "eslint ."
38
50
  }
39
51
  }
@@ -1,19 +0,0 @@
1
-
2
- 
3
- > @mastra/deployer-netlify@0.1.5-alpha.1 build /Users/ward/projects/mastra/mastra/deployers/netlify
4
- > tsup src/index.ts --format esm --experimental-dts --clean --treeshake
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.3.6
9
- TSC Build start
10
- TSC ⚡️ Build success in 1897ms
11
- DTS Build start
12
- CLI Target: es2022
13
- Analysis will use the bundled TypeScript version 5.7.3
14
- Writing package typings: /Users/ward/projects/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.ts
15
- DTS ⚡️ Build success in 1236ms
16
- CLI Cleaning output folder
17
- ESM Build start
18
- ESM dist/index.js 3.47 KB
19
- ESM ⚡️ Build success in 67ms