@mastra/deployer-cloudflare 0.0.1-alpha.3 → 0.0.1-alpha.30
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 +216 -0
- package/README.md +99 -0
- package/dist/index.d.ts +18 -4
- package/dist/index.js +98 -6
- package/dist/secrets-manager/index.d.ts +3 -2
- package/dist/secrets-manager/index.js +87 -0
- package/package.json +14 -18
- package/src/index.ts +73 -26
- package/src/secrets-manager/index.ts +3 -3
- package/tsconfig.json +1 -6
- package/vitest.config.ts +1 -1
- package/dist/deployer-cloudflare.cjs.development.js +0 -451
- package/dist/deployer-cloudflare.cjs.development.js.map +0 -1
- package/dist/deployer-cloudflare.cjs.production.min.js +0 -2
- package/dist/deployer-cloudflare.cjs.production.min.js.map +0 -1
- package/dist/deployer-cloudflare.esm.js +0 -428
- package/dist/deployer-cloudflare.esm.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/secrets-manager/index.d.ts.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MastraDeployer } from '@mastra/core';
|
|
2
|
-
import
|
|
2
|
+
import { createChildProcessLogger } from '@mastra/deployer';
|
|
3
|
+
import { Cloudflare } from 'cloudflare';
|
|
3
4
|
import { writeFileSync } from 'fs';
|
|
4
5
|
import { join } from 'path';
|
|
5
6
|
|
|
@@ -10,52 +11,68 @@ interface CFRoute {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export class CloudflareDeployer extends MastraDeployer {
|
|
14
|
+
private cloudflare: Cloudflare | undefined;
|
|
13
15
|
routes?: CFRoute[] = [];
|
|
16
|
+
workerNamespace?: string;
|
|
14
17
|
constructor({
|
|
15
18
|
scope,
|
|
16
19
|
env,
|
|
17
20
|
projectName,
|
|
18
21
|
routes,
|
|
22
|
+
workerNamespace,
|
|
23
|
+
auth,
|
|
19
24
|
}: {
|
|
20
25
|
env?: Record<string, any>;
|
|
21
26
|
scope: string;
|
|
22
27
|
projectName: string;
|
|
23
28
|
routes?: CFRoute[];
|
|
29
|
+
workerNamespace?: string;
|
|
30
|
+
auth?: {
|
|
31
|
+
apiToken: string;
|
|
32
|
+
apiEmail: string;
|
|
33
|
+
};
|
|
24
34
|
}) {
|
|
25
35
|
super({ scope, env, projectName });
|
|
26
36
|
|
|
27
37
|
this.routes = routes;
|
|
38
|
+
this.workerNamespace = workerNamespace;
|
|
39
|
+
|
|
40
|
+
if (auth) {
|
|
41
|
+
this.cloudflare = new Cloudflare(auth);
|
|
42
|
+
}
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
writeFiles({ dir }: { dir: string }): void {
|
|
45
|
+
override writeFiles({ dir }: { dir: string }): void {
|
|
31
46
|
this.loadEnvVars();
|
|
32
47
|
|
|
33
48
|
this.writeIndex({ dir });
|
|
34
49
|
|
|
35
50
|
const cfWorkerName = this.projectName || 'mastra';
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
logs: {
|
|
49
|
-
enabled: true,
|
|
50
|
-
},
|
|
52
|
+
const wranglerConfig: Record<string, any> = {
|
|
53
|
+
name: cfWorkerName,
|
|
54
|
+
main: 'index.mjs',
|
|
55
|
+
compatibility_date: '2024-12-02',
|
|
56
|
+
compatibility_flags: ['nodejs_compat'],
|
|
57
|
+
build: {
|
|
58
|
+
command: 'npm install',
|
|
59
|
+
},
|
|
60
|
+
observability: {
|
|
61
|
+
logs: {
|
|
62
|
+
enabled: true,
|
|
51
63
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
},
|
|
65
|
+
vars: this.env,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (!this.workerNamespace && this.routes) {
|
|
69
|
+
wranglerConfig.routes = this.routes;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));
|
|
56
73
|
}
|
|
57
74
|
|
|
58
|
-
writeIndex({ dir }: { dir: string }): void {
|
|
75
|
+
override writeIndex({ dir }: { dir: string }): void {
|
|
59
76
|
writeFileSync(
|
|
60
77
|
join(dir, './index.mjs'),
|
|
61
78
|
`
|
|
@@ -72,16 +89,46 @@ export class CloudflareDeployer extends MastraDeployer {
|
|
|
72
89
|
);
|
|
73
90
|
}
|
|
74
91
|
|
|
75
|
-
async deploy({ dir, token }: { dir: string; token: string }): Promise<void> {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
override async deploy({ dir, token }: { dir: string; token: string }): Promise<void> {
|
|
93
|
+
const cmd = this.workerNamespace
|
|
94
|
+
? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`
|
|
95
|
+
: 'npm exec -- wrangler deploy';
|
|
96
|
+
|
|
97
|
+
const cpLogger = createChildProcessLogger({
|
|
98
|
+
logger: this.logger,
|
|
99
|
+
root: dir,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
await cpLogger({
|
|
103
|
+
cmd,
|
|
104
|
+
args: [],
|
|
79
105
|
env: {
|
|
80
106
|
CLOUDFLARE_API_TOKEN: token,
|
|
81
107
|
CLOUDFLARE_ACCOUNT_ID: this.scope,
|
|
82
108
|
...this.env,
|
|
83
|
-
PATH: process.env.PATH
|
|
109
|
+
PATH: process.env.PATH!,
|
|
84
110
|
},
|
|
85
111
|
});
|
|
86
112
|
}
|
|
113
|
+
|
|
114
|
+
async tagWorker({
|
|
115
|
+
workerName,
|
|
116
|
+
namespace,
|
|
117
|
+
tags,
|
|
118
|
+
scope,
|
|
119
|
+
}: {
|
|
120
|
+
scope: string;
|
|
121
|
+
workerName: string;
|
|
122
|
+
namespace: string;
|
|
123
|
+
tags: string[];
|
|
124
|
+
}): Promise<void> {
|
|
125
|
+
if (!this.cloudflare) {
|
|
126
|
+
throw new Error('Cloudflare Deployer not initialized');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
130
|
+
account_id: scope,
|
|
131
|
+
body: tags,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
87
134
|
}
|
|
@@ -33,7 +33,7 @@ export class CloudflareSecretsManager {
|
|
|
33
33
|
}),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
const data = await response.json();
|
|
36
|
+
const data = (await response.json()) as { success: boolean; result: any; errors: any[] };
|
|
37
37
|
|
|
38
38
|
if (!data.success) {
|
|
39
39
|
throw new Error(data.errors[0].message);
|
|
@@ -72,7 +72,7 @@ export class CloudflareSecretsManager {
|
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
const data = await response.json();
|
|
75
|
+
const data = (await response.json()) as { success: boolean; result: any; errors: any[] };
|
|
76
76
|
|
|
77
77
|
if (!data.success) {
|
|
78
78
|
throw new Error(data.errors[0].message);
|
|
@@ -95,7 +95,7 @@ export class CloudflareSecretsManager {
|
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
const data = await response.json();
|
|
98
|
+
const data = (await response.json()) as { success: boolean; result: any; errors: any[] };
|
|
99
99
|
|
|
100
100
|
if (!data.success) {
|
|
101
101
|
throw new Error(data.errors[0].message);
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"moduleResolution": "bundler",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"rootDir": "./src"
|
|
7
|
-
},
|
|
2
|
+
"extends": "../../tsconfig.node.json",
|
|
8
3
|
"include": ["src/**/*"],
|
|
9
4
|
"exclude": ["node_modules", "**/*.test.ts"]
|
|
10
5
|
}
|
package/vitest.config.ts
CHANGED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@mastra/core');
|
|
6
|
-
var child_process = require('child_process');
|
|
7
|
-
var fs = require('fs');
|
|
8
|
-
var path = require('path');
|
|
9
|
-
|
|
10
|
-
function _interopNamespaceDefault(e) {
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return n;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_process);
|
|
28
|
-
|
|
29
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
30
|
-
try {
|
|
31
|
-
var i = n[a](c),
|
|
32
|
-
u = i.value;
|
|
33
|
-
} catch (n) {
|
|
34
|
-
return void e(n);
|
|
35
|
-
}
|
|
36
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
37
|
-
}
|
|
38
|
-
function _asyncToGenerator(n) {
|
|
39
|
-
return function () {
|
|
40
|
-
var t = this,
|
|
41
|
-
e = arguments;
|
|
42
|
-
return new Promise(function (r, o) {
|
|
43
|
-
var a = n.apply(t, e);
|
|
44
|
-
function _next(n) {
|
|
45
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
46
|
-
}
|
|
47
|
-
function _throw(n) {
|
|
48
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
49
|
-
}
|
|
50
|
-
_next(void 0);
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function _extends() {
|
|
55
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
56
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
57
|
-
var t = arguments[e];
|
|
58
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
59
|
-
}
|
|
60
|
-
return n;
|
|
61
|
-
}, _extends.apply(null, arguments);
|
|
62
|
-
}
|
|
63
|
-
function _inheritsLoose(t, o) {
|
|
64
|
-
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
65
|
-
}
|
|
66
|
-
function _regeneratorRuntime() {
|
|
67
|
-
_regeneratorRuntime = function () {
|
|
68
|
-
return e;
|
|
69
|
-
};
|
|
70
|
-
var t,
|
|
71
|
-
e = {},
|
|
72
|
-
r = Object.prototype,
|
|
73
|
-
n = r.hasOwnProperty,
|
|
74
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
75
|
-
t[e] = r.value;
|
|
76
|
-
},
|
|
77
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
78
|
-
a = i.iterator || "@@iterator",
|
|
79
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
80
|
-
u = i.toStringTag || "@@toStringTag";
|
|
81
|
-
function define(t, e, r) {
|
|
82
|
-
return Object.defineProperty(t, e, {
|
|
83
|
-
value: r,
|
|
84
|
-
enumerable: !0,
|
|
85
|
-
configurable: !0,
|
|
86
|
-
writable: !0
|
|
87
|
-
}), t[e];
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
define({}, "");
|
|
91
|
-
} catch (t) {
|
|
92
|
-
define = function (t, e, r) {
|
|
93
|
-
return t[e] = r;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function wrap(t, e, r, n) {
|
|
97
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
98
|
-
a = Object.create(i.prototype),
|
|
99
|
-
c = new Context(n || []);
|
|
100
|
-
return o(a, "_invoke", {
|
|
101
|
-
value: makeInvokeMethod(t, r, c)
|
|
102
|
-
}), a;
|
|
103
|
-
}
|
|
104
|
-
function tryCatch(t, e, r) {
|
|
105
|
-
try {
|
|
106
|
-
return {
|
|
107
|
-
type: "normal",
|
|
108
|
-
arg: t.call(e, r)
|
|
109
|
-
};
|
|
110
|
-
} catch (t) {
|
|
111
|
-
return {
|
|
112
|
-
type: "throw",
|
|
113
|
-
arg: t
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
e.wrap = wrap;
|
|
118
|
-
var h = "suspendedStart",
|
|
119
|
-
l = "suspendedYield",
|
|
120
|
-
f = "executing",
|
|
121
|
-
s = "completed",
|
|
122
|
-
y = {};
|
|
123
|
-
function Generator() {}
|
|
124
|
-
function GeneratorFunction() {}
|
|
125
|
-
function GeneratorFunctionPrototype() {}
|
|
126
|
-
var p = {};
|
|
127
|
-
define(p, a, function () {
|
|
128
|
-
return this;
|
|
129
|
-
});
|
|
130
|
-
var d = Object.getPrototypeOf,
|
|
131
|
-
v = d && d(d(values([])));
|
|
132
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
133
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
134
|
-
function defineIteratorMethods(t) {
|
|
135
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
136
|
-
define(t, e, function (t) {
|
|
137
|
-
return this._invoke(e, t);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function AsyncIterator(t, e) {
|
|
142
|
-
function invoke(r, o, i, a) {
|
|
143
|
-
var c = tryCatch(t[r], t, o);
|
|
144
|
-
if ("throw" !== c.type) {
|
|
145
|
-
var u = c.arg,
|
|
146
|
-
h = u.value;
|
|
147
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
148
|
-
invoke("next", t, i, a);
|
|
149
|
-
}, function (t) {
|
|
150
|
-
invoke("throw", t, i, a);
|
|
151
|
-
}) : e.resolve(h).then(function (t) {
|
|
152
|
-
u.value = t, i(u);
|
|
153
|
-
}, function (t) {
|
|
154
|
-
return invoke("throw", t, i, a);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
a(c.arg);
|
|
158
|
-
}
|
|
159
|
-
var r;
|
|
160
|
-
o(this, "_invoke", {
|
|
161
|
-
value: function (t, n) {
|
|
162
|
-
function callInvokeWithMethodAndArg() {
|
|
163
|
-
return new e(function (e, r) {
|
|
164
|
-
invoke(t, n, e, r);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
function makeInvokeMethod(e, r, n) {
|
|
172
|
-
var o = h;
|
|
173
|
-
return function (i, a) {
|
|
174
|
-
if (o === f) throw Error("Generator is already running");
|
|
175
|
-
if (o === s) {
|
|
176
|
-
if ("throw" === i) throw a;
|
|
177
|
-
return {
|
|
178
|
-
value: t,
|
|
179
|
-
done: !0
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
for (n.method = i, n.arg = a;;) {
|
|
183
|
-
var c = n.delegate;
|
|
184
|
-
if (c) {
|
|
185
|
-
var u = maybeInvokeDelegate(c, n);
|
|
186
|
-
if (u) {
|
|
187
|
-
if (u === y) continue;
|
|
188
|
-
return u;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
192
|
-
if (o === h) throw o = s, n.arg;
|
|
193
|
-
n.dispatchException(n.arg);
|
|
194
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
195
|
-
o = f;
|
|
196
|
-
var p = tryCatch(e, r, n);
|
|
197
|
-
if ("normal" === p.type) {
|
|
198
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
199
|
-
return {
|
|
200
|
-
value: p.arg,
|
|
201
|
-
done: n.done
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function maybeInvokeDelegate(e, r) {
|
|
209
|
-
var n = r.method,
|
|
210
|
-
o = e.iterator[n];
|
|
211
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
212
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
213
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
214
|
-
var a = i.arg;
|
|
215
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
216
|
-
}
|
|
217
|
-
function pushTryEntry(t) {
|
|
218
|
-
var e = {
|
|
219
|
-
tryLoc: t[0]
|
|
220
|
-
};
|
|
221
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
222
|
-
}
|
|
223
|
-
function resetTryEntry(t) {
|
|
224
|
-
var e = t.completion || {};
|
|
225
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
226
|
-
}
|
|
227
|
-
function Context(t) {
|
|
228
|
-
this.tryEntries = [{
|
|
229
|
-
tryLoc: "root"
|
|
230
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
231
|
-
}
|
|
232
|
-
function values(e) {
|
|
233
|
-
if (e || "" === e) {
|
|
234
|
-
var r = e[a];
|
|
235
|
-
if (r) return r.call(e);
|
|
236
|
-
if ("function" == typeof e.next) return e;
|
|
237
|
-
if (!isNaN(e.length)) {
|
|
238
|
-
var o = -1,
|
|
239
|
-
i = function next() {
|
|
240
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
241
|
-
return next.value = t, next.done = !0, next;
|
|
242
|
-
};
|
|
243
|
-
return i.next = i;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
247
|
-
}
|
|
248
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
249
|
-
value: GeneratorFunctionPrototype,
|
|
250
|
-
configurable: !0
|
|
251
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
252
|
-
value: GeneratorFunction,
|
|
253
|
-
configurable: !0
|
|
254
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
255
|
-
var e = "function" == typeof t && t.constructor;
|
|
256
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
257
|
-
}, e.mark = function (t) {
|
|
258
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
259
|
-
}, e.awrap = function (t) {
|
|
260
|
-
return {
|
|
261
|
-
__await: t
|
|
262
|
-
};
|
|
263
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
264
|
-
return this;
|
|
265
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
266
|
-
void 0 === i && (i = Promise);
|
|
267
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
268
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
269
|
-
return t.done ? t.value : a.next();
|
|
270
|
-
});
|
|
271
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
272
|
-
return this;
|
|
273
|
-
}), define(g, "toString", function () {
|
|
274
|
-
return "[object Generator]";
|
|
275
|
-
}), e.keys = function (t) {
|
|
276
|
-
var e = Object(t),
|
|
277
|
-
r = [];
|
|
278
|
-
for (var n in e) r.push(n);
|
|
279
|
-
return r.reverse(), function next() {
|
|
280
|
-
for (; r.length;) {
|
|
281
|
-
var t = r.pop();
|
|
282
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
283
|
-
}
|
|
284
|
-
return next.done = !0, next;
|
|
285
|
-
};
|
|
286
|
-
}, e.values = values, Context.prototype = {
|
|
287
|
-
constructor: Context,
|
|
288
|
-
reset: function (e) {
|
|
289
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
290
|
-
},
|
|
291
|
-
stop: function () {
|
|
292
|
-
this.done = !0;
|
|
293
|
-
var t = this.tryEntries[0].completion;
|
|
294
|
-
if ("throw" === t.type) throw t.arg;
|
|
295
|
-
return this.rval;
|
|
296
|
-
},
|
|
297
|
-
dispatchException: function (e) {
|
|
298
|
-
if (this.done) throw e;
|
|
299
|
-
var r = this;
|
|
300
|
-
function handle(n, o) {
|
|
301
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
302
|
-
}
|
|
303
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
304
|
-
var i = this.tryEntries[o],
|
|
305
|
-
a = i.completion;
|
|
306
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
307
|
-
if (i.tryLoc <= this.prev) {
|
|
308
|
-
var c = n.call(i, "catchLoc"),
|
|
309
|
-
u = n.call(i, "finallyLoc");
|
|
310
|
-
if (c && u) {
|
|
311
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
312
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
313
|
-
} else if (c) {
|
|
314
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
315
|
-
} else {
|
|
316
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
317
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
abrupt: function (t, e) {
|
|
323
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
324
|
-
var o = this.tryEntries[r];
|
|
325
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
326
|
-
var i = o;
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
331
|
-
var a = i ? i.completion : {};
|
|
332
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
333
|
-
},
|
|
334
|
-
complete: function (t, e) {
|
|
335
|
-
if ("throw" === t.type) throw t.arg;
|
|
336
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
337
|
-
},
|
|
338
|
-
finish: function (t) {
|
|
339
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
340
|
-
var r = this.tryEntries[e];
|
|
341
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
catch: function (t) {
|
|
345
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
346
|
-
var r = this.tryEntries[e];
|
|
347
|
-
if (r.tryLoc === t) {
|
|
348
|
-
var n = r.completion;
|
|
349
|
-
if ("throw" === n.type) {
|
|
350
|
-
var o = n.arg;
|
|
351
|
-
resetTryEntry(r);
|
|
352
|
-
}
|
|
353
|
-
return o;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
throw Error("illegal catch attempt");
|
|
357
|
-
},
|
|
358
|
-
delegateYield: function (e, r, n) {
|
|
359
|
-
return this.delegate = {
|
|
360
|
-
iterator: values(e),
|
|
361
|
-
resultName: r,
|
|
362
|
-
nextLoc: n
|
|
363
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
364
|
-
}
|
|
365
|
-
}, e;
|
|
366
|
-
}
|
|
367
|
-
function _setPrototypeOf(t, e) {
|
|
368
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
369
|
-
return t.__proto__ = e, t;
|
|
370
|
-
}, _setPrototypeOf(t, e);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
374
|
-
function CloudflareDeployer(_ref) {
|
|
375
|
-
var _this;
|
|
376
|
-
var scope = _ref.scope,
|
|
377
|
-
env = _ref.env,
|
|
378
|
-
projectName = _ref.projectName,
|
|
379
|
-
routes = _ref.routes;
|
|
380
|
-
_this = _MastraDeployer.call(this, {
|
|
381
|
-
scope: scope,
|
|
382
|
-
env: env,
|
|
383
|
-
projectName: projectName
|
|
384
|
-
}) || this;
|
|
385
|
-
_this.routes = [];
|
|
386
|
-
_this.routes = routes;
|
|
387
|
-
return _this;
|
|
388
|
-
}
|
|
389
|
-
_inheritsLoose(CloudflareDeployer, _MastraDeployer);
|
|
390
|
-
var _proto = CloudflareDeployer.prototype;
|
|
391
|
-
_proto.writeFiles = function writeFiles(_ref2) {
|
|
392
|
-
var dir = _ref2.dir;
|
|
393
|
-
this.loadEnvVars();
|
|
394
|
-
this.writeIndex({
|
|
395
|
-
dir: dir
|
|
396
|
-
});
|
|
397
|
-
var cfWorkerName = this.projectName || 'mastra';
|
|
398
|
-
fs.writeFileSync(path.join(dir, 'wrangler.json'), JSON.stringify({
|
|
399
|
-
name: cfWorkerName,
|
|
400
|
-
main: 'index.mjs',
|
|
401
|
-
compatibility_date: '2024-12-02',
|
|
402
|
-
compatibility_flags: ['nodejs_compat'],
|
|
403
|
-
build: {
|
|
404
|
-
command: 'npm install'
|
|
405
|
-
},
|
|
406
|
-
observability: {
|
|
407
|
-
logs: {
|
|
408
|
-
enabled: true
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
routes: this.routes,
|
|
412
|
-
vars: this.env
|
|
413
|
-
}));
|
|
414
|
-
};
|
|
415
|
-
_proto.writeIndex = function writeIndex(_ref3) {
|
|
416
|
-
var dir = _ref3.dir;
|
|
417
|
-
fs.writeFileSync(path.join(dir, './index.mjs'), "\n export default {\n fetch: async (request, env, context) => {\n Object.keys(env).forEach(key => {\n process.env[key] = env[key]\n })\n const { app } = await import('./hono.mjs');\n return app.fetch(request, env, context);\n }\n }\n ");
|
|
418
|
-
};
|
|
419
|
-
_proto.deploy = /*#__PURE__*/function () {
|
|
420
|
-
var _deploy = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
|
|
421
|
-
var dir, token;
|
|
422
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
423
|
-
while (1) switch (_context.prev = _context.next) {
|
|
424
|
-
case 0:
|
|
425
|
-
dir = _ref4.dir, token = _ref4.token;
|
|
426
|
-
child_process__namespace.execSync("npm exec wrangler deploy", {
|
|
427
|
-
cwd: dir,
|
|
428
|
-
stdio: 'inherit',
|
|
429
|
-
env: _extends({
|
|
430
|
-
CLOUDFLARE_API_TOKEN: token,
|
|
431
|
-
CLOUDFLARE_ACCOUNT_ID: this.scope
|
|
432
|
-
}, this.env, {
|
|
433
|
-
PATH: process.env.PATH
|
|
434
|
-
})
|
|
435
|
-
});
|
|
436
|
-
case 2:
|
|
437
|
-
case "end":
|
|
438
|
-
return _context.stop();
|
|
439
|
-
}
|
|
440
|
-
}, _callee, this);
|
|
441
|
-
}));
|
|
442
|
-
function deploy(_x) {
|
|
443
|
-
return _deploy.apply(this, arguments);
|
|
444
|
-
}
|
|
445
|
-
return deploy;
|
|
446
|
-
}();
|
|
447
|
-
return CloudflareDeployer;
|
|
448
|
-
}(core.MastraDeployer);
|
|
449
|
-
|
|
450
|
-
exports.CloudflareDeployer = CloudflareDeployer;
|
|
451
|
-
//# sourceMappingURL=deployer-cloudflare.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deployer-cloudflare.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import { MastraDeployer } from '@mastra/core';\nimport * as child_process from 'child_process';\nimport { writeFileSync } from 'fs';\nimport { join } from 'path';\n\ninterface CFRoute {\n pattern: string;\n zone_name: string;\n custom_domain?: boolean;\n}\n\nexport class CloudflareDeployer extends MastraDeployer {\n routes?: CFRoute[] = [];\n constructor({\n scope,\n env,\n projectName,\n routes,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n }\n\n writeFiles({ dir }: { dir: string }): void {\n this.loadEnvVars();\n\n this.writeIndex({ dir });\n\n const cfWorkerName = this.projectName || 'mastra';\n\n writeFileSync(\n join(dir, 'wrangler.json'),\n JSON.stringify({\n name: cfWorkerName,\n main: 'index.mjs',\n compatibility_date: '2024-12-02',\n compatibility_flags: ['nodejs_compat'],\n build: {\n command: 'npm install',\n },\n observability: {\n logs: {\n enabled: true,\n },\n },\n routes: this.routes,\n vars: this.env,\n }),\n );\n }\n\n writeIndex({ dir }: { dir: string }): void {\n writeFileSync(\n join(dir, './index.mjs'),\n `\n export default {\n fetch: async (request, env, context) => {\n Object.keys(env).forEach(key => {\n process.env[key] = env[key]\n })\n const { app } = await import('./hono.mjs');\n return app.fetch(request, env, context);\n }\n }\n `,\n );\n }\n\n async deploy({ dir, token }: { dir: string; token: string }): Promise<void> {\n child_process.execSync(`npm exec wrangler deploy`, {\n cwd: dir,\n stdio: 'inherit',\n env: {\n CLOUDFLARE_API_TOKEN: token,\n CLOUDFLARE_ACCOUNT_ID: this.scope,\n ...this.env,\n PATH: process.env.PATH,\n },\n });\n }\n}\n"],"names":["CloudflareDeployer","_MastraDeployer","_ref","_this","scope","env","projectName","routes","call","_inheritsLoose","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","cfWorkerName","writeFileSync","join","JSON","stringify","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","_ref3","deploy","_deploy","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref4","token","wrap","_callee$","_context","prev","next","child_process","execSync","cwd","stdio","_extends","CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID","PATH","process","stop","_x","apply","arguments","MastraDeployer"],"mappings":"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"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@mastra/core"),e=require("child_process"),r=require("fs"),n=require("path");function o(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,e}var i=o(e);function a(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}function u(){return u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},u.apply(null,arguments)}function s(){s=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=Object.create((e&&e.prototype instanceof m?e:m).prototype),a=new S(n||[]);return o(i,"_invoke",{value:P(t,r,a)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",g={};function m(){}function w(){}function b(){}var x={};f(x,a,(function(){return this}));var j=Object.getPrototypeOf,O=j&&j(j(T([])));O&&O!==r&&n.call(O,a)&&(x=O);var L=b.prototype=m.prototype=Object.create(x);function E(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function _(t,e){function r(o,i,a,c){var u=h(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function P(e,r,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?d:y,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function F(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return w.prototype=b,o(L,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=f(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,f(t,u,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},E(_.prototype),f(_.prototype,c,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new _(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(L),f(L,u,"Generator"),f(L,a,(function(){return this})),f(L,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(F),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),F(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;F(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function f(t,e){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},f(t,e)}exports.CloudflareDeployer=function(t){function e(e){var r,n=e.routes;return(r=t.call(this,{scope:e.scope,env:e.env,projectName:e.projectName})||this).routes=[],r.routes=n,r}var o,a;a=t,(o=e).prototype=Object.create(a.prototype),o.prototype.constructor=o,f(o,a);var l=e.prototype;return l.writeFiles=function(t){var e=t.dir;this.loadEnvVars(),this.writeIndex({dir:e});var o=this.projectName||"mastra";r.writeFileSync(n.join(e,"wrangler.json"),JSON.stringify({name:o,main:"index.mjs",compatibility_date:"2024-12-02",compatibility_flags:["nodejs_compat"],build:{command:"npm install"},observability:{logs:{enabled:!0}},routes:this.routes,vars:this.env}))},l.writeIndex=function(t){r.writeFileSync(n.join(t.dir,"./index.mjs"),"\n export default {\n fetch: async (request, env, context) => {\n Object.keys(env).forEach(key => {\n process.env[key] = env[key]\n })\n const { app } = await import('./hono.mjs');\n return app.fetch(request, env, context);\n }\n }\n ")},l.deploy=function(){var t=c(s().mark((function t(e){return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i.execSync("npm exec wrangler deploy",{cwd:e.dir,stdio:"inherit",env:u({CLOUDFLARE_API_TOKEN:e.token,CLOUDFLARE_ACCOUNT_ID:this.scope},this.env,{PATH:process.env.PATH})});case 2:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(t.MastraDeployer);
|
|
2
|
-
//# sourceMappingURL=deployer-cloudflare.cjs.production.min.js.map
|