@mastra/deployer-netlify 0.0.0-storage-20250225005900 → 0.0.0-stream-vnext-usage-20250908171242

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/src/helpers.ts DELETED
@@ -1,76 +0,0 @@
1
- async function createNetlifySite({ token, name, scope }: { token: string; name: string; scope?: string }) {
2
- const response = await fetch('https://api.netlify.com/api/v1/sites', {
3
- method: 'POST',
4
- headers: {
5
- Authorization: `Bearer ${token}`,
6
- 'Content-Type': 'application/json',
7
- },
8
- body: JSON.stringify({
9
- name: name,
10
- account_slug: scope, // Optional - if not provided, creates in user's default account
11
- force_ssl: true, // Enable HTTPS
12
- }),
13
- });
14
-
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 };
25
-
26
- if (!response.ok) {
27
- console.error(JSON.stringify(data));
28
- throw new Error(`Failed to create site: ${data.message || 'Unknown error'}`);
29
- }
30
-
31
- return {
32
- id: data.id,
33
- name: data.name,
34
- url: data.ssl_url || data.url,
35
- adminUrl: data.admin_url,
36
- };
37
- }
38
-
39
- async function findNetlifySite({ token, name, scope }: { token: string; name: string; scope: string }) {
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
-
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 };
56
-
57
- if (!response.ok || !Array.isArray(data)) {
58
- throw new Error(`Failed to search sites: ${(data as { message: string }).message || 'Unknown error'}`);
59
- }
60
-
61
- // Find exact match (filter can return partial matches)
62
- return data.find(site => site.name === name);
63
- }
64
-
65
- export async function getOrCreateSite({ token, name, scope }: { token: string; name: string; scope: string }) {
66
- let existingSite;
67
- try {
68
- existingSite = await findNetlifySite({ token, name, scope });
69
- } catch (e) {}
70
-
71
- if (existingSite) {
72
- return existingSite;
73
- }
74
-
75
- return createNetlifySite({ token, name, scope });
76
- }
package/src/index.ts DELETED
@@ -1,95 +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
- import { getOrCreateSite } from './helpers.js';
7
-
8
- export class NetlifyDeployer extends Deployer {
9
- protected scope: string;
10
- protected projectName: string;
11
- protected token: string;
12
-
13
- constructor({ scope, projectName, token }: { scope: string; projectName: string; token: string }) {
14
- super({ name: 'NETLIFY' });
15
-
16
- this.scope = scope;
17
- this.projectName = projectName;
18
- this.token = token;
19
- }
20
-
21
- writeFiles({ dir }: { dir: string }): void {
22
- if (!existsSync(join(dir, 'netlify/functions/api'))) {
23
- mkdirSync(join(dir, 'netlify/functions/api'), { recursive: true });
24
- }
25
-
26
- // TODO ENV KEYS
27
- writeFileSync(
28
- join(dir, 'netlify.toml'),
29
- `[functions]
30
- node_bundler = "esbuild"
31
- directory = "netlify/functions"
32
-
33
- [[redirects]]
34
- force = true
35
- from = "/*"
36
- status = 200
37
- to = "/.netlify/functions/api/:splat"
38
- `,
39
- );
40
- }
41
-
42
- async deploy(outputDirectory: string): Promise<void> {
43
- const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
44
-
45
- // @ts-expect-error - seems to be fine
46
- const p2 = execa(
47
- 'npx',
48
- [
49
- 'netlify-cli',
50
- 'deploy',
51
- '--site',
52
- site.id,
53
- '--auth',
54
- this.token,
55
- '--dir',
56
- '.',
57
- '--functions',
58
- './netlify/functions',
59
- ],
60
- {
61
- cwd: join(outputDirectory, this.outputDir),
62
- },
63
- );
64
-
65
- p2.stdout.pipe(process.stdout);
66
- await p2;
67
- }
68
-
69
- async prepare(outputDirectory: string): Promise<void> {
70
- await super.prepare(outputDirectory);
71
-
72
- this.writeFiles({ dir: join(outputDirectory, this.outputDir) });
73
- }
74
-
75
- async bundle(entryFile: string, outputDirectory: string): Promise<void> {
76
- return this._bundle(
77
- this.getEntry(),
78
- entryFile,
79
- outputDirectory,
80
- join(outputDirectory, this.outputDir, 'netlify', 'functions', 'api'),
81
- );
82
- }
83
-
84
- private getEntry(): string {
85
- return `
86
- import { handle } from 'hono/netlify'
87
- import { mastra } from '#mastra';
88
- import { createHonoServer } from '#server';
89
-
90
- const app = await createHonoServer(mastra);
91
-
92
- export default handle(app)
93
- `;
94
- }
95
- }
package/tsconfig.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
4
- "exclude": ["node_modules", "**/*.test.ts"]
5
- }
package/vitest.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: 'node',
6
- include: ['src/**/*.test.ts'],
7
- },
8
- });