@mastra/deployer-netlify 0.1.6-alpha.1 → 0.1.6-alpha.3
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/.turbo/turbo-build.log +10 -5
- package/CHANGELOG.md +23 -0
- package/dist/_tsup-dts-rollup.d.cts +38 -0
- package/dist/index.cjs +140 -0
- package/dist/index.d.cts +1 -0
- package/package.json +12 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/deployer-netlify@0.1.6-alpha.
|
|
3
|
-
> tsup src/index.ts --format esm --experimental-dts --clean --treeshake
|
|
2
|
+
> @mastra/deployer-netlify@0.1.6-alpha.3 build /home/runner/work/mastra/mastra/deployers/netlify
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.3.6
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 8401ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.7.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
-
|
|
14
|
+
Analysis will use the bundled TypeScript version 5.7.3
|
|
15
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 7613ms
|
|
15
17
|
[34mCLI[39m Cleaning output folder
|
|
16
18
|
[34mESM[39m Build start
|
|
19
|
+
[34mCJS[39m Build start
|
|
17
20
|
[32mESM[39m [1mdist/index.js [22m[32m3.46 KB[39m
|
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 328ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m3.51 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 336ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @mastra/deployer-netlify
|
|
2
2
|
|
|
3
|
+
## 0.1.6-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bb4f447: Add support for commonjs
|
|
8
|
+
- Updated dependencies [0fd78ac]
|
|
9
|
+
- Updated dependencies [0d25b75]
|
|
10
|
+
- Updated dependencies [fd14a3f]
|
|
11
|
+
- Updated dependencies [3f369a2]
|
|
12
|
+
- Updated dependencies [4d4e1e1]
|
|
13
|
+
- Updated dependencies [bb4f447]
|
|
14
|
+
- @mastra/deployer@0.1.6-alpha.3
|
|
15
|
+
- @mastra/core@0.4.3-alpha.3
|
|
16
|
+
|
|
17
|
+
## 0.1.6-alpha.2
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [2512a93]
|
|
22
|
+
- Updated dependencies [e62de74]
|
|
23
|
+
- @mastra/core@0.4.3-alpha.2
|
|
24
|
+
- @mastra/deployer@0.1.6-alpha.2
|
|
25
|
+
|
|
3
26
|
## 0.1.6-alpha.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
deploy(outputDirectory: string): Promise<void>;
|
|
33
|
+
prepare(outputDirectory: string): Promise<void>;
|
|
34
|
+
bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
35
|
+
private getEntry;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { }
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var deployer = require('@mastra/deployer');
|
|
6
|
+
var execa = require('execa');
|
|
7
|
+
|
|
8
|
+
// src/index.ts
|
|
9
|
+
|
|
10
|
+
// src/helpers.ts
|
|
11
|
+
async function createNetlifySite({ token, name, scope }) {
|
|
12
|
+
const response = await fetch("https://api.netlify.com/api/v1/sites", {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${token}`,
|
|
16
|
+
"Content-Type": "application/json"
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
name,
|
|
20
|
+
account_slug: scope,
|
|
21
|
+
// Optional - if not provided, creates in user's default account
|
|
22
|
+
force_ssl: true
|
|
23
|
+
// Enable HTTPS
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
const data = await response.json();
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
console.error(JSON.stringify(data));
|
|
29
|
+
throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
|
|
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
|
+
async function findNetlifySite({ token, name, scope }) {
|
|
39
|
+
const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${token}`,
|
|
42
|
+
"Content-Type": "application/json"
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
if (!response.ok || !Array.isArray(data)) {
|
|
47
|
+
throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
|
|
48
|
+
}
|
|
49
|
+
return data.find((site) => site.name === name);
|
|
50
|
+
}
|
|
51
|
+
async function getOrCreateSite({ token, name, scope }) {
|
|
52
|
+
let existingSite;
|
|
53
|
+
try {
|
|
54
|
+
existingSite = await findNetlifySite({ token, name, scope });
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
if (existingSite) {
|
|
58
|
+
return existingSite;
|
|
59
|
+
}
|
|
60
|
+
return createNetlifySite({ token, name, scope });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/index.ts
|
|
64
|
+
var NetlifyDeployer = class extends deployer.Deployer {
|
|
65
|
+
scope;
|
|
66
|
+
projectName;
|
|
67
|
+
token;
|
|
68
|
+
constructor({ scope, projectName, token }) {
|
|
69
|
+
super({ name: "NETLIFY" });
|
|
70
|
+
this.scope = scope;
|
|
71
|
+
this.projectName = projectName;
|
|
72
|
+
this.token = token;
|
|
73
|
+
}
|
|
74
|
+
writeFiles({ dir }) {
|
|
75
|
+
if (!fs.existsSync(path.join(dir, "netlify/functions/api"))) {
|
|
76
|
+
fs.mkdirSync(path.join(dir, "netlify/functions/api"), { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
fs.writeFileSync(
|
|
79
|
+
path.join(dir, "netlify.toml"),
|
|
80
|
+
`[functions]
|
|
81
|
+
node_bundler = "esbuild"
|
|
82
|
+
directory = "netlify/functions"
|
|
83
|
+
|
|
84
|
+
[[redirects]]
|
|
85
|
+
force = true
|
|
86
|
+
from = "/*"
|
|
87
|
+
status = 200
|
|
88
|
+
to = "/.netlify/functions/api/:splat"
|
|
89
|
+
`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
async deploy(outputDirectory) {
|
|
93
|
+
const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
|
|
94
|
+
const p2 = execa.execa(
|
|
95
|
+
"npx",
|
|
96
|
+
[
|
|
97
|
+
"netlify-cli",
|
|
98
|
+
"deploy",
|
|
99
|
+
"--site",
|
|
100
|
+
site.id,
|
|
101
|
+
"--auth",
|
|
102
|
+
this.token,
|
|
103
|
+
"--dir",
|
|
104
|
+
".",
|
|
105
|
+
"--functions",
|
|
106
|
+
"./netlify/functions"
|
|
107
|
+
],
|
|
108
|
+
{
|
|
109
|
+
cwd: path.join(outputDirectory, this.outputDir)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
p2.stdout.pipe(process.stdout);
|
|
113
|
+
await p2;
|
|
114
|
+
}
|
|
115
|
+
async prepare(outputDirectory) {
|
|
116
|
+
await super.prepare(outputDirectory);
|
|
117
|
+
this.writeFiles({ dir: path.join(outputDirectory, this.outputDir) });
|
|
118
|
+
}
|
|
119
|
+
async bundle(entryFile, outputDirectory) {
|
|
120
|
+
return this._bundle(
|
|
121
|
+
this.getEntry(),
|
|
122
|
+
entryFile,
|
|
123
|
+
outputDirectory,
|
|
124
|
+
path.join(outputDirectory, this.outputDir, "netlify", "functions", "api")
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
getEntry() {
|
|
128
|
+
return `
|
|
129
|
+
import { handle } from 'hono/netlify'
|
|
130
|
+
import { mastra } from '#mastra';
|
|
131
|
+
import { createHonoServer } from '#server';
|
|
132
|
+
|
|
133
|
+
const app = await createHonoServer(mastra);
|
|
134
|
+
|
|
135
|
+
export default handle(app)
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.NetlifyDeployer = NetlifyDeployer;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NetlifyDeployer } from './_tsup-dts-rollup.cjs';
|
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-netlify",
|
|
3
|
-
"version": "0.1.6-alpha.
|
|
3
|
+
"version": "0.1.6-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
12
18
|
},
|
|
13
19
|
"./package.json": "./package.json"
|
|
14
20
|
},
|
|
@@ -21,8 +27,8 @@
|
|
|
21
27
|
"execa": "^9.3.1",
|
|
22
28
|
"netlify-cli": "^18.0.1",
|
|
23
29
|
"zod": "^3.24.1",
|
|
24
|
-
"@mastra/core": "^0.4.3-alpha.
|
|
25
|
-
"@mastra/deployer": "^0.1.6-alpha.
|
|
30
|
+
"@mastra/core": "^0.4.3-alpha.3",
|
|
31
|
+
"@mastra/deployer": "^0.1.6-alpha.3"
|
|
26
32
|
},
|
|
27
33
|
"devDependencies": {
|
|
28
34
|
"eslint": "^9.20.1",
|
|
@@ -34,7 +40,7 @@
|
|
|
34
40
|
"@internal/lint": "0.0.0"
|
|
35
41
|
},
|
|
36
42
|
"scripts": {
|
|
37
|
-
"build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
|
|
43
|
+
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake",
|
|
38
44
|
"build:watch": "pnpm build --watch",
|
|
39
45
|
"test": "vitest run",
|
|
40
46
|
"lint": "eslint ."
|