@mastra/deployer-netlify 0.0.0-storage-20250225005900 → 0.0.0-support-monorepos-20250415183219
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/{LICENSE → LICENSE.md} +3 -1
- package/README.md +3 -1
- package/dist/_tsup-dts-rollup.d.cts +39 -0
- package/dist/_tsup-dts-rollup.d.ts +1 -0
- package/dist/index.cjs +153 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.js +16 -3
- package/package.json +28 -16
- package/.turbo/turbo-build.log +0 -19
- package/CHANGELOG.md +0 -917
- package/src/helpers.ts +0 -76
- package/src/index.ts +0 -95
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -8
package/{LICENSE → LICENSE.md}
RENAMED
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;
|
package/dist/index.d.cts
ADDED
|
@@ -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
|
|
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-
|
|
3
|
+
"version": "0.0.0-support-monorepos-20250415183219",
|
|
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
|
-
"
|
|
11
|
-
|
|
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": "
|
|
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.
|
|
22
|
-
"netlify-cli": "^
|
|
23
|
-
"zod": "^3.24.
|
|
24
|
-
"@mastra/core": "
|
|
25
|
-
"@mastra/deployer": "
|
|
30
|
+
"execa": "^9.5.2",
|
|
31
|
+
"netlify-cli": "^19.0.3",
|
|
32
|
+
"zod": "^3.24.2",
|
|
33
|
+
"@mastra/core": "0.8.3",
|
|
34
|
+
"@mastra/deployer": "0.0.0-support-monorepos-20250415183219"
|
|
26
35
|
},
|
|
27
36
|
"devDependencies": {
|
|
28
|
-
"@microsoft/api-extractor": "^7.
|
|
29
|
-
"@types/node": "^
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
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
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -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
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
-
[34mCLI[39m tsup v8.3.6
|
|
9
|
-
[34mTSC[39m Build start
|
|
10
|
-
[32mTSC[39m ⚡️ Build success in 1897ms
|
|
11
|
-
[34mDTS[39m Build start
|
|
12
|
-
[34mCLI[39m Target: es2022
|
|
13
|
-
Analysis will use the bundled TypeScript version 5.7.3
|
|
14
|
-
[36mWriting package typings: /Users/ward/projects/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.ts[39m
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in 1236ms
|
|
16
|
-
[34mCLI[39m Cleaning output folder
|
|
17
|
-
[34mESM[39m Build start
|
|
18
|
-
[32mESM[39m [1mdist/index.js [22m[32m3.47 KB[39m
|
|
19
|
-
[32mESM[39m ⚡️ Build success in 67ms
|