@mastra/deployer-netlify 0.1.0-alpha.52 → 0.1.0-alpha.54

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,23 @@
1
1
  # @mastra/deployer-netlify
2
2
 
3
+ ## 0.1.0-alpha.54
4
+
5
+ ### Patch Changes
6
+
7
+ - 4f1d1a1: Enforce types ann cleanup package.json
8
+ - Updated dependencies [66a03ec]
9
+ - Updated dependencies [4f1d1a1]
10
+ - @mastra/core@0.2.0-alpha.101
11
+ - @mastra/deployer@0.1.0-alpha.51
12
+
13
+ ## 0.1.0-alpha.53
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [9d1796d]
18
+ - @mastra/deployer@0.1.0-alpha.50
19
+ - @mastra/core@0.2.0-alpha.100
20
+
3
21
  ## 0.1.0-alpha.52
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.1.0-alpha.52",
3
+ "version": "0.1.0-alpha.54",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,23 +18,20 @@
18
18
  "dependencies": {
19
19
  "@rollup/plugin-virtual": "^3.0.2",
20
20
  "date-fns": "^4.1.0",
21
- "dotenv": "^16.3.1",
22
21
  "execa": "^9.3.1",
23
22
  "netlify-cli": "^18.0.1",
24
23
  "zod": "^3.24.1",
25
- "@mastra/core": "^0.2.0-alpha.99",
26
- "@mastra/deployer": "^0.1.0-alpha.49"
24
+ "@mastra/core": "^0.2.0-alpha.101",
25
+ "@mastra/deployer": "^0.1.0-alpha.51"
27
26
  },
28
27
  "devDependencies": {
29
- "@babel/preset-env": "^7.26.0",
30
- "@babel/preset-typescript": "^7.26.0",
31
- "@tsconfig/recommended": "^1.0.7",
32
- "@types/node": "^22.9.0",
28
+ "@microsoft/api-extractor": "^7.49.2",
29
+ "@types/node": "^22.13.1",
33
30
  "tsup": "^8.0.1",
34
31
  "vitest": "^3.0.4"
35
32
  },
36
33
  "scripts": {
37
- "build": "tsup src/index.ts --format esm --dts --clean --treeshake",
34
+ "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
38
35
  "build:watch": "pnpm build --watch",
39
36
  "test": "vitest run"
40
37
  }
package/src/helpers.ts CHANGED
@@ -12,7 +12,16 @@ async function createNetlifySite({ token, name, scope }: { token: string; name:
12
12
  }),
13
13
  });
14
14
 
15
- const data = await response.json();
15
+ const data = (await response.json()) as
16
+ | {
17
+ id: string;
18
+ name: string;
19
+ ssl_url: string;
20
+ url: string;
21
+ admin_url: string;
22
+ message?: never;
23
+ }
24
+ | { message: string; id?: never; name?: never; ssl_url?: never; url?: never; admin_url?: never };
16
25
 
17
26
  if (!response.ok) {
18
27
  console.error(JSON.stringify(data));
@@ -35,14 +44,22 @@ async function findNetlifySite({ token, name, scope }: { token: string; name: st
35
44
  },
36
45
  });
37
46
 
38
- const data = await response.json();
47
+ const data = (await response.json()) as
48
+ | {
49
+ id: string;
50
+ name: string;
51
+ ssl_url: string;
52
+ url: string;
53
+ admin_url: string;
54
+ }[]
55
+ | { message: string };
39
56
 
40
- if (!response.ok) {
41
- throw new Error(`Failed to search sites: ${data.message || 'Unknown error'}`);
57
+ if (!response.ok || !Array.isArray(data)) {
58
+ throw new Error(`Failed to search sites: ${(data as { message: string }).message || 'Unknown error'}`);
42
59
  }
43
60
 
44
61
  // Find exact match (filter can return partial matches)
45
- return data.find((site: any) => site.name === name);
62
+ return data.find(site => site.name === name);
46
63
  }
47
64
 
48
65
  export async function getOrCreateSite({ token, name, scope }: { token: string; name: string; scope: string }) {
package/src/index.ts CHANGED
@@ -42,6 +42,7 @@ to = "/.netlify/functions/api/:splat"
42
42
  async deploy(outputDirectory: string): Promise<void> {
43
43
  const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
44
44
 
45
+ // @ts-expect-error - seems to be fine
45
46
  const p2 = execa(
46
47
  'npx',
47
48
  [
package/dist/index.d.ts DELETED
@@ -1,21 +0,0 @@
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 }: {
8
- scope: string;
9
- projectName: string;
10
- token: string;
11
- });
12
- writeFiles({ dir }: {
13
- dir: string;
14
- }): void;
15
- deploy(outputDirectory: string): Promise<void>;
16
- prepare(outputDirectory: string): Promise<void>;
17
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
18
- private getEntry;
19
- }
20
-
21
- export { NetlifyDeployer };
package/dist/index.js DELETED
@@ -1,138 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
- import { execa } from 'execa';
3
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
4
- import { join } from 'path';
5
-
6
- // src/index.ts
7
-
8
- // src/helpers.ts
9
- async function createNetlifySite({ token, name, scope }) {
10
- const response = await fetch("https://api.netlify.com/api/v1/sites", {
11
- method: "POST",
12
- headers: {
13
- Authorization: `Bearer ${token}`,
14
- "Content-Type": "application/json"
15
- },
16
- body: JSON.stringify({
17
- name,
18
- account_slug: scope,
19
- // Optional - if not provided, creates in user's default account
20
- force_ssl: true
21
- // Enable HTTPS
22
- })
23
- });
24
- const data = await response.json();
25
- if (!response.ok) {
26
- console.error(JSON.stringify(data));
27
- throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
28
- }
29
- return {
30
- id: data.id,
31
- name: data.name,
32
- url: data.ssl_url || data.url,
33
- adminUrl: data.admin_url
34
- };
35
- }
36
- async function findNetlifySite({ token, name, scope }) {
37
- const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
38
- headers: {
39
- Authorization: `Bearer ${token}`,
40
- "Content-Type": "application/json"
41
- }
42
- });
43
- const data = await response.json();
44
- if (!response.ok) {
45
- throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
46
- }
47
- return data.find((site) => site.name === name);
48
- }
49
- async function getOrCreateSite({ token, name, scope }) {
50
- let existingSite;
51
- try {
52
- existingSite = await findNetlifySite({ token, name, scope });
53
- } catch (e) {
54
- }
55
- if (existingSite) {
56
- return existingSite;
57
- }
58
- return createNetlifySite({ token, name, scope });
59
- }
60
-
61
- // src/index.ts
62
- var NetlifyDeployer = class extends Deployer {
63
- scope;
64
- projectName;
65
- token;
66
- constructor({ scope, projectName, token }) {
67
- super({ name: "NETLIFY" });
68
- this.scope = scope;
69
- this.projectName = projectName;
70
- this.token = token;
71
- }
72
- writeFiles({ dir }) {
73
- if (!existsSync(join(dir, "netlify/functions/api"))) {
74
- mkdirSync(join(dir, "netlify/functions/api"), { recursive: true });
75
- }
76
- writeFileSync(
77
- join(dir, "netlify.toml"),
78
- `[functions]
79
- node_bundler = "esbuild"
80
- directory = "netlify/functions"
81
-
82
- [[redirects]]
83
- force = true
84
- from = "/*"
85
- status = 200
86
- to = "/.netlify/functions/api/:splat"
87
- `
88
- );
89
- }
90
- async deploy(outputDirectory) {
91
- const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
92
- const p2 = execa(
93
- "npx",
94
- [
95
- "netlify-cli",
96
- "deploy",
97
- "--site",
98
- site.id,
99
- "--auth",
100
- this.token,
101
- "--dir",
102
- ".",
103
- "--functions",
104
- "./netlify/functions"
105
- ],
106
- {
107
- cwd: join(outputDirectory, this.outputDir)
108
- }
109
- );
110
- p2.stdout.pipe(process.stdout);
111
- await p2;
112
- }
113
- async prepare(outputDirectory) {
114
- await super.prepare(outputDirectory);
115
- this.writeFiles({ dir: join(outputDirectory, this.outputDir) });
116
- }
117
- async bundle(entryFile, outputDirectory) {
118
- return this._bundle(
119
- this.getEntry(),
120
- entryFile,
121
- outputDirectory,
122
- join(outputDirectory, this.outputDir, "netlify", "functions", "api")
123
- );
124
- }
125
- getEntry() {
126
- return `
127
- import { handle } from 'hono/netlify'
128
- import { mastra } from '#mastra';
129
- import { createHonoServer } from '#server';
130
-
131
- const app = await createHonoServer(mastra);
132
-
133
- export default handle(app)
134
- `;
135
- }
136
- };
137
-
138
- export { NetlifyDeployer };