@mastra/deployer-netlify 0.0.1-alpha.30 → 0.0.1-alpha.32
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 +21 -0
- package/dist/index.d.ts +12 -12
- package/dist/index.js +66 -37
- package/package.json +4 -3
- package/src/index.ts +73 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @mastra/deployer-netlify
|
|
2
2
|
|
|
3
|
+
## 0.0.1-alpha.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e27fe69: Add dir to deployer
|
|
8
|
+
- Updated dependencies [e27fe69]
|
|
9
|
+
- @mastra/deployer@0.0.1-alpha.30
|
|
10
|
+
|
|
11
|
+
## 0.0.1-alpha.31
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 38b7f66: Update deployer logic
|
|
16
|
+
- Updated dependencies [2f17a5f]
|
|
17
|
+
- Updated dependencies [0696eeb]
|
|
18
|
+
- Updated dependencies [cb290ee]
|
|
19
|
+
- Updated dependencies [b4d7416]
|
|
20
|
+
- Updated dependencies [38b7f66]
|
|
21
|
+
- @mastra/core@0.2.0-alpha.84
|
|
22
|
+
- @mastra/deployer@0.0.1-alpha.29
|
|
23
|
+
|
|
3
24
|
## 0.0.1-alpha.30
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Deployer } from '@mastra/deployer';
|
|
2
2
|
|
|
3
|
-
declare class NetlifyDeployer extends
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
declare class NetlifyDeployer extends Deployer {
|
|
4
|
+
protected scope: string;
|
|
5
|
+
protected projectName: string;
|
|
6
|
+
protected token: string;
|
|
7
|
+
constructor({ scope, projectName, token }: {
|
|
7
8
|
scope: string;
|
|
9
|
+
projectName: string;
|
|
10
|
+
token: string;
|
|
8
11
|
});
|
|
9
12
|
writeFiles({ dir }: {
|
|
10
13
|
dir: string;
|
|
11
14
|
}): void;
|
|
12
|
-
deploy(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
writeIndex({ dir }: {
|
|
17
|
-
dir: string;
|
|
18
|
-
}): void;
|
|
15
|
+
deploy(outputDirectory: string): Promise<void>;
|
|
16
|
+
prepare(outputDirectory: string): Promise<void>;
|
|
17
|
+
bundle(mastraDir: string, outputDirectory: string): Promise<void>;
|
|
18
|
+
private getEntry;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export { NetlifyDeployer };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Deployer } from '@mastra/deployer';
|
|
2
|
+
import { getBundler } from '@mastra/deployer/build';
|
|
3
|
+
import virtual from '@rollup/plugin-virtual';
|
|
2
4
|
import { execa } from 'execa';
|
|
3
|
-
import { existsSync, mkdirSync, writeFileSync
|
|
5
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
4
6
|
import { join } from 'path';
|
|
5
7
|
|
|
6
8
|
// src/index.ts
|
|
@@ -60,9 +62,15 @@ async function getOrCreateSite({ token, name, scope }) {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
// src/index.ts
|
|
63
|
-
var NetlifyDeployer = class extends
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
66
74
|
}
|
|
67
75
|
writeFiles({ dir }) {
|
|
68
76
|
if (!existsSync(join(dir, "netlify/functions/api"))) {
|
|
@@ -70,49 +78,70 @@ var NetlifyDeployer = class extends MastraDeployer {
|
|
|
70
78
|
}
|
|
71
79
|
writeFileSync(
|
|
72
80
|
join(dir, "netlify.toml"),
|
|
73
|
-
`
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
directory = "/netlify/functions"
|
|
81
|
+
`[functions]
|
|
82
|
+
node_bundler = "esbuild"
|
|
83
|
+
directory = "netlify/functions"
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
[[redirects]]
|
|
86
|
+
force = true
|
|
87
|
+
from = "/*"
|
|
88
|
+
status = 200
|
|
89
|
+
to = "/.netlify/functions/api/:splat"
|
|
90
|
+
`
|
|
84
91
|
);
|
|
85
|
-
this.writeIndex({ dir });
|
|
86
92
|
}
|
|
87
|
-
async deploy(
|
|
88
|
-
const site = await getOrCreateSite({ token, name: this.projectName || `mastra`, scope: this.scope });
|
|
93
|
+
async deploy(outputDirectory) {
|
|
94
|
+
const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
|
|
89
95
|
const p2 = execa(
|
|
90
|
-
"
|
|
91
|
-
[
|
|
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
|
+
],
|
|
92
109
|
{
|
|
93
|
-
cwd:
|
|
110
|
+
cwd: outputDirectory
|
|
94
111
|
}
|
|
95
112
|
);
|
|
96
113
|
p2.stdout.pipe(process.stdout);
|
|
97
114
|
await p2;
|
|
98
115
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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() })]
|
|
102
128
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
await 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
|
+
`;
|
|
116
145
|
}
|
|
117
146
|
};
|
|
118
147
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-netlify",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.32",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@rollup/plugin-virtual": "^3.0.2",
|
|
19
20
|
"date-fns": "^4.1.0",
|
|
20
21
|
"dotenv": "^16.3.1",
|
|
21
22
|
"execa": "^9.3.1",
|
|
22
23
|
"netlify-cli": "^18.0.1",
|
|
23
24
|
"zod": "^3.24.1",
|
|
24
|
-
"@mastra/core": "0.2.0-alpha.
|
|
25
|
-
"@mastra/deployer": "0.0.1-alpha.
|
|
25
|
+
"@mastra/core": "0.2.0-alpha.84",
|
|
26
|
+
"@mastra/deployer": "0.0.1-alpha.30"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@babel/preset-env": "^7.26.0",
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Deployer } from '@mastra/deployer';
|
|
2
|
+
import { getBundler } from '@mastra/deployer/build';
|
|
3
|
+
import virtual from '@rollup/plugin-virtual';
|
|
2
4
|
import { execa } from 'execa';
|
|
3
|
-
import { existsSync, mkdirSync,
|
|
5
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
4
6
|
import { join } from 'path';
|
|
5
7
|
|
|
6
8
|
import { getOrCreateSite } from './helpers.js';
|
|
7
9
|
|
|
8
|
-
export class NetlifyDeployer extends
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export class NetlifyDeployer extends Deployer {
|
|
11
|
+
protected scope: string;
|
|
12
|
+
protected projectName: string;
|
|
13
|
+
protected token: string;
|
|
14
|
+
|
|
15
|
+
constructor({ scope, projectName, token }: { scope: string; projectName: string; token: string }) {
|
|
16
|
+
super({ name: 'NETLIFY' });
|
|
17
|
+
|
|
18
|
+
this.scope = scope;
|
|
19
|
+
this.projectName = projectName;
|
|
20
|
+
this.token = token;
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
writeFiles({ dir }: { dir: string }): void {
|
|
@@ -18,30 +28,38 @@ export class NetlifyDeployer extends MastraDeployer {
|
|
|
18
28
|
// TODO ENV KEYS
|
|
19
29
|
writeFileSync(
|
|
20
30
|
join(dir, 'netlify.toml'),
|
|
21
|
-
`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
directory = "/netlify/functions"
|
|
25
|
-
|
|
26
|
-
[[redirects]]
|
|
27
|
-
force = true
|
|
28
|
-
from = "/*"
|
|
29
|
-
status = 200
|
|
30
|
-
to = "/.netlify/functions/api/:splat"
|
|
31
|
-
`,
|
|
32
|
-
);
|
|
31
|
+
`[functions]
|
|
32
|
+
node_bundler = "esbuild"
|
|
33
|
+
directory = "netlify/functions"
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
[[redirects]]
|
|
36
|
+
force = true
|
|
37
|
+
from = "/*"
|
|
38
|
+
status = 200
|
|
39
|
+
to = "/.netlify/functions/api/:splat"
|
|
40
|
+
`,
|
|
41
|
+
);
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
async deploy(
|
|
38
|
-
const site = await getOrCreateSite({ token, name: this.projectName || `mastra`, scope: this.scope });
|
|
44
|
+
async deploy(outputDirectory: string): Promise<void> {
|
|
45
|
+
const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
|
|
39
46
|
|
|
40
47
|
const p2 = execa(
|
|
41
|
-
'
|
|
42
|
-
[
|
|
48
|
+
'npx',
|
|
49
|
+
[
|
|
50
|
+
'netlify-cli',
|
|
51
|
+
'deploy',
|
|
52
|
+
'--site',
|
|
53
|
+
site.id,
|
|
54
|
+
'--auth',
|
|
55
|
+
this.token,
|
|
56
|
+
'--dir',
|
|
57
|
+
'.',
|
|
58
|
+
'--functions',
|
|
59
|
+
'./netlify/functions',
|
|
60
|
+
],
|
|
43
61
|
{
|
|
44
|
-
cwd:
|
|
62
|
+
cwd: outputDirectory,
|
|
45
63
|
},
|
|
46
64
|
);
|
|
47
65
|
|
|
@@ -49,23 +67,39 @@ export class NetlifyDeployer extends MastraDeployer {
|
|
|
49
67
|
await p2;
|
|
50
68
|
}
|
|
51
69
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
async prepare(outputDirectory: string): Promise<void> {
|
|
71
|
+
await super.prepare(outputDirectory);
|
|
72
|
+
|
|
73
|
+
// Prepare the deployment directory
|
|
74
|
+
if (!existsSync(join(outputDirectory, 'netlify/functions/api'))) {
|
|
75
|
+
mkdirSync(join(outputDirectory, 'netlify/functions/api'), { recursive: true });
|
|
76
|
+
}
|
|
77
|
+
this.writeFiles({ dir: outputDirectory });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async bundle(mastraDir: string, outputDirectory: string): Promise<void> {
|
|
81
|
+
const bundler = await getBundler({
|
|
82
|
+
input: '#entry',
|
|
83
|
+
external: [/^@opentelemetry\//],
|
|
84
|
+
plugins: [virtual({ '#entry': this.getEntry() })],
|
|
55
85
|
});
|
|
56
86
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
await bundler.write({
|
|
88
|
+
inlineDynamicImports: true,
|
|
89
|
+
file: join(outputDirectory, 'netlify', 'functions', 'api', 'index.mjs'),
|
|
90
|
+
format: 'es',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private getEntry(): string {
|
|
95
|
+
return `
|
|
96
|
+
import { handle } from 'hono/netlify'
|
|
97
|
+
import { mastra } from '#mastra';
|
|
98
|
+
import { createHonoServer } from '#server';
|
|
99
|
+
|
|
100
|
+
const app = await createHonoServer(mastra);
|
|
101
|
+
|
|
102
|
+
export default handle(app)
|
|
103
|
+
`;
|
|
70
104
|
}
|
|
71
105
|
}
|