@mastra/deployer-netlify 0.1.6-alpha.0 → 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.
@@ -1,18 +1,23 @@
1
1
 
2
- > @mastra/deployer-netlify@0.1.6-alpha.0 build /home/runner/work/mastra/mastra/deployers/netlify
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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.3.6
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 7236ms
9
+ TSC ⚡️ Build success in 8401ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.7.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.ts
14
- DTS ⚡️ Build success in 4289ms
14
+ Analysis will use the bundled TypeScript version 5.7.3
15
+ Writing package typings: /home/runner/work/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.cts
16
+ DTS ⚡️ Build success in 7613ms
15
17
  CLI Cleaning output folder
16
18
  ESM Build start
17
- ESM dist/index.js 3.47 KB
18
- ESM ⚡️ Build success in 215ms
19
+ CJS Build start
20
+ ESM dist/index.js 3.46 KB
21
+ ESM ⚡️ Build success in 328ms
22
+ CJS dist/index.cjs 3.51 KB
23
+ CJS ⚡️ Build success in 336ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
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
+
26
+ ## 0.1.6-alpha.1
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [0d185b1]
31
+ - Updated dependencies [ed55f1d]
32
+ - Updated dependencies [80cdd76]
33
+ - Updated dependencies [8d13b14]
34
+ - Updated dependencies [3ee4831]
35
+ - Updated dependencies [108793c]
36
+ - Updated dependencies [5f28f44]
37
+ - @mastra/core@0.4.3-alpha.1
38
+ - @mastra/deployer@0.1.6-alpha.1
39
+
3
40
  ## 0.1.6-alpha.0
4
41
 
5
42
  ### 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;
@@ -0,0 +1 @@
1
+ export { NetlifyDeployer } from './_tsup-dts-rollup.cjs';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
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 { execa } from 'execa';
5
5
 
6
6
  // src/index.ts
7
7
 
@@ -50,7 +50,7 @@ async function getOrCreateSite({ token, name, scope }) {
50
50
  let existingSite;
51
51
  try {
52
52
  existingSite = await findNetlifySite({ token, name, scope });
53
- } catch (e) {
53
+ } catch {
54
54
  }
55
55
  if (existingSite) {
56
56
  return existingSite;
@@ -0,0 +1,6 @@
1
+ import { createConfig } from '@internal/lint/eslint';
2
+
3
+ const config = await createConfig();
4
+
5
+ /** @type {import("eslint").Linter.Config[]} */
6
+ export default [...config];
package/package.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.1.6-alpha.0",
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
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
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,19 +27,22 @@
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.0",
25
- "@mastra/deployer": "^0.1.6-alpha.0"
30
+ "@mastra/core": "^0.4.3-alpha.3",
31
+ "@mastra/deployer": "^0.1.6-alpha.3"
26
32
  },
27
33
  "devDependencies": {
34
+ "eslint": "^9.20.1",
28
35
  "@microsoft/api-extractor": "^7.49.2",
29
36
  "@types/node": "^22.13.1",
30
37
  "tsup": "^8.0.1",
31
38
  "typescript": "^5.7.3",
32
- "vitest": "^3.0.4"
39
+ "vitest": "^3.0.4",
40
+ "@internal/lint": "0.0.0"
33
41
  },
34
42
  "scripts": {
35
- "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
43
+ "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake",
36
44
  "build:watch": "pnpm build --watch",
37
- "test": "vitest run"
45
+ "test": "vitest run",
46
+ "lint": "eslint ."
38
47
  }
39
48
  }
package/src/helpers.ts CHANGED
@@ -66,7 +66,7 @@ export async function getOrCreateSite({ token, name, scope }: { token: string; n
66
66
  let existingSite;
67
67
  try {
68
68
  existingSite = await findNetlifySite({ token, name, scope });
69
- } catch (e) {}
69
+ } catch {}
70
70
 
71
71
  if (existingSite) {
72
72
  return existingSite;
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
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';
5
3
 
4
+ import { Deployer } from '@mastra/deployer';
5
+ import { execa } from 'execa';
6
+
6
7
  import { getOrCreateSite } from './helpers.js';
7
8
 
8
9
  export class NetlifyDeployer extends Deployer {