@mastra/deployer-cloudflare 0.0.1-alpha.18 → 0.0.1-alpha.2
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 +0 -127
- package/dist/deployer-cloudflare.cjs.development.js +30 -58
- package/dist/deployer-cloudflare.cjs.development.js.map +1 -1
- package/dist/deployer-cloudflare.cjs.production.min.js +1 -1
- package/dist/deployer-cloudflare.cjs.production.min.js.map +1 -1
- package/dist/deployer-cloudflare.esm.js +11 -58
- package/dist/deployer-cloudflare.esm.js.map +1 -1
- package/dist/index.d.ts +1 -14
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +26 -76
package/CHANGELOG.md
CHANGED
|
@@ -1,132 +1,5 @@
|
|
|
1
1
|
# @mastra/deployer-cloudflare
|
|
2
2
|
|
|
3
|
-
## 0.0.1-alpha.18
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [e4d4ede]
|
|
8
|
-
- Updated dependencies [06b2c0a]
|
|
9
|
-
- @mastra/core@0.1.27-alpha.72
|
|
10
|
-
- @mastra/deployer@0.0.1-alpha.16
|
|
11
|
-
|
|
12
|
-
## 0.0.1-alpha.17
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- Updated dependencies [d9c8dd0]
|
|
17
|
-
- @mastra/deployer@0.0.1-alpha.15
|
|
18
|
-
- @mastra/core@0.1.27-alpha.71
|
|
19
|
-
|
|
20
|
-
## 0.0.1-alpha.16
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- Updated dependencies [ad2cd74]
|
|
25
|
-
- @mastra/deployer@0.0.1-alpha.14
|
|
26
|
-
|
|
27
|
-
## 0.0.1-alpha.15
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- Updated dependencies [a1774e7]
|
|
32
|
-
- @mastra/deployer@0.0.1-alpha.13
|
|
33
|
-
|
|
34
|
-
## 0.0.1-alpha.14
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- Updated dependencies [28dceab]
|
|
39
|
-
- @mastra/deployer@0.0.1-alpha.12
|
|
40
|
-
|
|
41
|
-
## 0.0.1-alpha.13
|
|
42
|
-
|
|
43
|
-
### Patch Changes
|
|
44
|
-
|
|
45
|
-
- bdaf834: publish packages
|
|
46
|
-
- Updated dependencies [bdaf834]
|
|
47
|
-
- @mastra/deployer@0.0.1-alpha.11
|
|
48
|
-
|
|
49
|
-
## 0.0.1-alpha.12
|
|
50
|
-
|
|
51
|
-
### Patch Changes
|
|
52
|
-
|
|
53
|
-
- Updated dependencies [dd6d87f]
|
|
54
|
-
- Updated dependencies [04434b6]
|
|
55
|
-
- @mastra/core@0.1.27-alpha.70
|
|
56
|
-
- @mastra/deployer@0.0.1-alpha.10
|
|
57
|
-
|
|
58
|
-
## 0.0.1-alpha.11
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- 9066f95: CF deployer fixes
|
|
63
|
-
- Updated dependencies [9066f95]
|
|
64
|
-
- @mastra/deployer@0.0.1-alpha.9
|
|
65
|
-
|
|
66
|
-
## 0.0.1-alpha.10
|
|
67
|
-
|
|
68
|
-
### Patch Changes
|
|
69
|
-
|
|
70
|
-
- 0d5a03d: Vector store modules
|
|
71
|
-
|
|
72
|
-
## 0.0.1-alpha.9
|
|
73
|
-
|
|
74
|
-
### Patch Changes
|
|
75
|
-
|
|
76
|
-
- Updated dependencies [b425845]
|
|
77
|
-
- @mastra/deployer@0.0.1-alpha.8
|
|
78
|
-
|
|
79
|
-
## 0.0.1-alpha.8
|
|
80
|
-
|
|
81
|
-
### Patch Changes
|
|
82
|
-
|
|
83
|
-
- 1944807: Unified logger and major step in better logs
|
|
84
|
-
- c7abf8e: Optional CF worker tagging
|
|
85
|
-
- Updated dependencies [1944807]
|
|
86
|
-
- Updated dependencies [9ade36e]
|
|
87
|
-
- @mastra/deployer@0.0.1-alpha.7
|
|
88
|
-
- @mastra/core@0.1.27-alpha.69
|
|
89
|
-
|
|
90
|
-
## 0.0.1-alpha.7
|
|
91
|
-
|
|
92
|
-
### Patch Changes
|
|
93
|
-
|
|
94
|
-
- Updated dependencies [291fe57]
|
|
95
|
-
- Updated dependencies [1a41fbf]
|
|
96
|
-
- @mastra/deployer@0.0.1-alpha.6
|
|
97
|
-
|
|
98
|
-
## 0.0.1-alpha.6
|
|
99
|
-
|
|
100
|
-
### Patch Changes
|
|
101
|
-
|
|
102
|
-
- Updated dependencies [0be7181]
|
|
103
|
-
- Updated dependencies [0be7181]
|
|
104
|
-
- @mastra/core@0.1.27-alpha.68
|
|
105
|
-
- @mastra/deployer@0.0.1-alpha.5
|
|
106
|
-
|
|
107
|
-
## 0.0.1-alpha.5
|
|
108
|
-
|
|
109
|
-
### Patch Changes
|
|
110
|
-
|
|
111
|
-
- Updated dependencies [7babd5c]
|
|
112
|
-
- @mastra/deployer@0.0.1-alpha.4
|
|
113
|
-
|
|
114
|
-
## 0.0.1-alpha.4
|
|
115
|
-
|
|
116
|
-
### Patch Changes
|
|
117
|
-
|
|
118
|
-
- 026ca5d: Optional dispatcher namespace configuration for cloudflare deployments
|
|
119
|
-
|
|
120
|
-
## 0.0.1-alpha.3
|
|
121
|
-
|
|
122
|
-
### Patch Changes
|
|
123
|
-
|
|
124
|
-
- a291824: Deployer fixes
|
|
125
|
-
- Updated dependencies [c8ff2f5]
|
|
126
|
-
- Updated dependencies [a291824]
|
|
127
|
-
- @mastra/core@0.1.27-alpha.67
|
|
128
|
-
- @mastra/deployer@0.0.1-alpha.3
|
|
129
|
-
|
|
130
3
|
## 0.0.1-alpha.2
|
|
131
4
|
|
|
132
5
|
### Patch Changes
|
|
@@ -3,11 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@mastra/core');
|
|
6
|
-
var
|
|
7
|
-
var cloudflare = require('cloudflare');
|
|
6
|
+
var child_process = require('child_process');
|
|
8
7
|
var fs = require('fs');
|
|
9
8
|
var path = require('path');
|
|
10
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
|
+
|
|
11
29
|
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
12
30
|
try {
|
|
13
31
|
var i = n[a](c),
|
|
@@ -358,22 +376,14 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
358
376
|
var scope = _ref.scope,
|
|
359
377
|
env = _ref.env,
|
|
360
378
|
projectName = _ref.projectName,
|
|
361
|
-
routes = _ref.routes
|
|
362
|
-
workerNamespace = _ref.workerNamespace,
|
|
363
|
-
auth = _ref.auth;
|
|
379
|
+
routes = _ref.routes;
|
|
364
380
|
_this = _MastraDeployer.call(this, {
|
|
365
381
|
scope: scope,
|
|
366
382
|
env: env,
|
|
367
383
|
projectName: projectName
|
|
368
384
|
}) || this;
|
|
369
|
-
_this.cloudflare = void 0;
|
|
370
385
|
_this.routes = [];
|
|
371
|
-
_this.workerNamespace = void 0;
|
|
372
386
|
_this.routes = routes;
|
|
373
|
-
_this.workerNamespace = workerNamespace;
|
|
374
|
-
if (auth) {
|
|
375
|
-
_this.cloudflare = new cloudflare.Cloudflare(auth);
|
|
376
|
-
}
|
|
377
387
|
return _this;
|
|
378
388
|
}
|
|
379
389
|
_inheritsLoose(CloudflareDeployer, _MastraDeployer);
|
|
@@ -385,7 +395,7 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
385
395
|
dir: dir
|
|
386
396
|
});
|
|
387
397
|
var cfWorkerName = this.projectName || 'mastra';
|
|
388
|
-
|
|
398
|
+
fs.writeFileSync(path.join(dir, 'wrangler.json'), JSON.stringify({
|
|
389
399
|
name: cfWorkerName,
|
|
390
400
|
main: 'index.mjs',
|
|
391
401
|
compatibility_date: '2024-12-02',
|
|
@@ -398,33 +408,24 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
398
408
|
enabled: true
|
|
399
409
|
}
|
|
400
410
|
},
|
|
411
|
+
routes: this.routes,
|
|
401
412
|
vars: this.env
|
|
402
|
-
};
|
|
403
|
-
if (!this.workerNamespace && this.routes) {
|
|
404
|
-
wranglerConfig.routes = this.routes;
|
|
405
|
-
}
|
|
406
|
-
fs.writeFileSync(path.join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));
|
|
413
|
+
}));
|
|
407
414
|
};
|
|
408
415
|
_proto.writeIndex = function writeIndex(_ref3) {
|
|
409
416
|
var dir = _ref3.dir;
|
|
410
|
-
fs.writeFileSync(path.join(dir, './index.mjs'), "\n export default {\n fetch: async (
|
|
417
|
+
fs.writeFileSync(path.join(dir, './index.mjs'), "\n export default {\n fetch: async (event, context) => {\n const { app } = await import('./hono.mjs');\n return app.fetch(event, context);\n }\n }\n ");
|
|
411
418
|
};
|
|
412
419
|
_proto.deploy = /*#__PURE__*/function () {
|
|
413
420
|
var _deploy = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
|
|
414
|
-
var dir, token
|
|
421
|
+
var dir, token;
|
|
415
422
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
416
423
|
while (1) switch (_context.prev = _context.next) {
|
|
417
424
|
case 0:
|
|
418
425
|
dir = _ref4.dir, token = _ref4.token;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
root: dir
|
|
423
|
-
});
|
|
424
|
-
_context.next = 5;
|
|
425
|
-
return cpLogger({
|
|
426
|
-
cmd: cmd,
|
|
427
|
-
args: [],
|
|
426
|
+
child_process__namespace.execSync("npm exec wrangler deploy", {
|
|
427
|
+
cwd: dir,
|
|
428
|
+
stdio: 'inherit',
|
|
428
429
|
env: _extends({
|
|
429
430
|
CLOUDFLARE_API_TOKEN: token,
|
|
430
431
|
CLOUDFLARE_ACCOUNT_ID: this.scope
|
|
@@ -432,7 +433,7 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
432
433
|
PATH: process.env.PATH
|
|
433
434
|
})
|
|
434
435
|
});
|
|
435
|
-
case
|
|
436
|
+
case 2:
|
|
436
437
|
case "end":
|
|
437
438
|
return _context.stop();
|
|
438
439
|
}
|
|
@@ -443,35 +444,6 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
443
444
|
}
|
|
444
445
|
return deploy;
|
|
445
446
|
}();
|
|
446
|
-
_proto.tagWorker = /*#__PURE__*/function () {
|
|
447
|
-
var _tagWorker = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
|
|
448
|
-
var workerName, namespace, tags, scope;
|
|
449
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
450
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
451
|
-
case 0:
|
|
452
|
-
workerName = _ref5.workerName, namespace = _ref5.namespace, tags = _ref5.tags, scope = _ref5.scope;
|
|
453
|
-
if (this.cloudflare) {
|
|
454
|
-
_context2.next = 3;
|
|
455
|
-
break;
|
|
456
|
-
}
|
|
457
|
-
throw new Error('Cloudflare Deployer not initialized');
|
|
458
|
-
case 3:
|
|
459
|
-
_context2.next = 5;
|
|
460
|
-
return this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
461
|
-
account_id: scope,
|
|
462
|
-
body: tags
|
|
463
|
-
});
|
|
464
|
-
case 5:
|
|
465
|
-
case "end":
|
|
466
|
-
return _context2.stop();
|
|
467
|
-
}
|
|
468
|
-
}, _callee2, this);
|
|
469
|
-
}));
|
|
470
|
-
function tagWorker(_x2) {
|
|
471
|
-
return _tagWorker.apply(this, arguments);
|
|
472
|
-
}
|
|
473
|
-
return tagWorker;
|
|
474
|
-
}();
|
|
475
447
|
return CloudflareDeployer;
|
|
476
448
|
}(core.MastraDeployer);
|
|
477
449
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployer-cloudflare.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import { MastraDeployer } from '@mastra/core';\nimport
|
|
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 (event, context) => {\n const { app } = await import('./hono.mjs');\n return app.fetch(event, 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWaA,IAAAA,kBAAmB,0BAAAC,eAAA,EAAA;EAE9B,SAAAD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,CAACC,GAAG,EAAA;AACXgD,gBAAAA,IAAI,EAAEC,OAAO,CAACjD,GAAG,CAACgD,IAAAA;AAAI,eAAA,CAAA;AAEzB,aAAA,CAAC,CAAA;AAAC,UAAA,KAAA,CAAA,CAAA;AAAA,UAAA,KAAA,KAAA;YAAA,OAAAV,QAAA,CAAAY,IAAA,EAAA,CAAA;AAAA,SAAA;AAAA,OAAA,EAAAjB,OAAA,EAAA,IAAA,CAAA,CAAA;KACJ,CAAA,CAAA,CAAA;IAAA,SAXKL,MAAMA,CAAAuB,EAAA,EAAA;AAAA,MAAA,OAAAtB,OAAA,CAAAuB,KAAA,CAAA,IAAA,EAAAC,SAAA,CAAA,CAAA;AAAA,KAAA;AAAA,IAAA,OAANzB,MAAM,CAAA;AAAA,GAAA,EAAA,CAAA;AAAA,EAAA,OAAAjC,kBAAA,CAAA;AAAA,CAAA,CA5D0B2D,mBAAc;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@mastra/core"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@mastra/core"),r=require("child_process"),e=require("fs"),n=require("path");function o(t){var r=Object.create(null);return t&&Object.keys(t).forEach((function(e){if("default"!==e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}})),r.default=t,r}var i=o(r);function a(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function c(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var i=t.apply(r,e);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 r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)({}).hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},u.apply(null,arguments)}function s(){s=function(){return r};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function f(t,r,e,n){var i=Object.create((r&&r.prototype instanceof m?r:m).prototype),a=new S(n||[]);return o(i,"_invoke",{value:P(t,e,a)}),i}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=f;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",g={};function m(){}function w(){}function b(){}var x={};l(x,a,(function(){return this}));var j=Object.getPrototypeOf,O=j&&j(j(T([])));O&&O!==e&&n.call(O,a)&&(x=O);var L=b.prototype=m.prototype=Object.create(x);function _(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function E(t,r){function e(o,i,a,c){var u=h(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return i=i?i.then(o,o):o()}})}function P(r,e,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=N(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(r,e,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 N(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,N(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function k(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function F(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(r){if(r||""===r){var e=r[a];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function e(){for(;++o<r.length;)if(n.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return w.prototype=b,o(L,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:w,configurable:!0}),w.displayName=l(b,u,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,u,"GeneratorFunction")),t.prototype=Object.create(L),t},r.awrap=function(t){return{__await:t}},_(E.prototype),l(E.prototype,c,(function(){return this})),r.AsyncIterator=E,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new E(f(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(L),l(L,u,"Generator"),l(L,a,(function(){return this})),l(L,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,S.prototype={constructor:S,reset:function(r){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),!r)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function o(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.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,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,r){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&&r&&(this.next=r),g},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),F(e),g}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;F(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:T(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}function l(t,r){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},l(t,r)}exports.CloudflareDeployer=function(t){function r(r){var e,n=r.routes;return(e=t.call(this,{scope:r.scope,env:r.env,projectName:r.projectName})||this).routes=[],e.routes=n,e}var o,a;a=t,(o=r).prototype=Object.create(a.prototype),o.prototype.constructor=o,l(o,a);var f=r.prototype;return f.writeFiles=function(t){var r=t.dir;this.loadEnvVars(),this.writeIndex({dir:r});var o=this.projectName||"mastra";e.writeFileSync(n.join(r,"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}))},f.writeIndex=function(t){e.writeFileSync(n.join(t.dir,"./index.mjs"),"\n export default {\n fetch: async (event, context) => {\n const { app } = await import('./hono.mjs');\n return app.fetch(event, context);\n }\n }\n ")},f.deploy=function(){var t=c(s().mark((function t(r){return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i.execSync("npm exec wrangler deploy",{cwd:r.dir,stdio:"inherit",env:u({CLOUDFLARE_API_TOKEN:r.token,CLOUDFLARE_ACCOUNT_ID:this.scope},this.env,{PATH:process.env.PATH})});case 2:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),r}(t.MastraDeployer);
|
|
2
2
|
//# sourceMappingURL=deployer-cloudflare.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployer-cloudflare.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import { MastraDeployer } from '@mastra/core';\nimport
|
|
1
|
+
{"version":3,"file":"deployer-cloudflare.cjs.production.min.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 (event, context) => {\n const { app } = await import('./hono.mjs');\n return app.fetch(event, 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":["_MastraDeployer","CloudflareDeployer","_ref","_this","routes","call","this","scope","env","projectName","_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","wrap","_context","prev","next","child_process","execSync","cwd","stdio","_extends","CLOUDFLARE_API_TOKEN","token","CLOUDFLARE_ACCOUNT_ID","PATH","process","stop","_x","apply","arguments","MastraDeployer"],"mappings":"m7OAWgCA,GAE9B,SAAAC,EAAAC,GAUC,IAAAC,EANCC,EAAMF,EAANE,OASqB,OAFrBD,EAAAH,EAAAK,KAAMC,KAAA,CAAEC,MAVHL,EAALK,MAUeC,IATZN,EAAHM,IASoBC,YARTP,EAAXO,eAQkCH,MAZpCF,OAAqB,GAcnBD,EAAKC,OAASA,EAAOD,CACvB,WAACH,KAAAC,yEAAA,IAAAS,EAAAT,EAAAU,UA4CW,OA5CXD,EAEDE,WAAA,SAAUC,GAAyB,IAAtBC,EAAGD,EAAHC,IACXR,KAAKS,cAELT,KAAKU,WAAW,CAAEF,IAAAA,IAElB,IAAMG,EAAeX,KAAKG,aAAe,SAEzCS,EAAaA,cACXC,EAAIA,KAACL,EAAK,iBACVM,KAAKC,UAAU,CACbC,KAAML,EACNM,KAAM,YACNC,mBAAoB,aACpBC,oBAAqB,CAAC,iBACtBC,MAAO,CACLC,QAAS,eAEXC,cAAe,CACbC,KAAM,CACJC,SAAS,IAGb1B,OAAQE,KAAKF,OACb2B,KAAMzB,KAAKE,QAGhBE,EAEDM,WAAA,SAAUgB,GACRd,EAAAA,cACEC,EAAAA,KAFYa,EAAHlB,IAEC,oOAUbJ,EAEKuB,OAAM,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,MAAZ,SAAAC,EAAAC,GAAA,OAAAH,IAAAI,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EACEC,EAAcC,SAAqC,2BAAA,CACjDC,IAFcP,EAAHzB,IAGXiC,MAAO,UACPvC,IAAGwC,EAAA,CACDC,qBALmBV,EAALW,MAMdC,sBAAuB7C,KAAKC,OACzBD,KAAKE,IAAG,CACX4C,KAAMC,QAAQ7C,IAAI4C,SAEnB,KAAA,EAAA,IAAA,MAAA,OAAAX,EAAAa,OAAA,GAAAhB,EAAAhC,KACJ,KAXW,OAWX,SAXWiD,GAAA,OAAArB,EAAAsB,MAAAlD,KAAAmD,UAAA,CAAA,CAAA,GAAAxD,CAAA,EA5D0ByD,EAAcA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MastraDeployer } from '@mastra/core';
|
|
2
|
-
import
|
|
3
|
-
import { Cloudflare } from 'cloudflare';
|
|
2
|
+
import * as child_process from 'child_process';
|
|
4
3
|
import { writeFileSync } from 'fs';
|
|
5
4
|
import { join } from 'path';
|
|
6
5
|
|
|
@@ -354,22 +353,14 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
354
353
|
var scope = _ref.scope,
|
|
355
354
|
env = _ref.env,
|
|
356
355
|
projectName = _ref.projectName,
|
|
357
|
-
routes = _ref.routes
|
|
358
|
-
workerNamespace = _ref.workerNamespace,
|
|
359
|
-
auth = _ref.auth;
|
|
356
|
+
routes = _ref.routes;
|
|
360
357
|
_this = _MastraDeployer.call(this, {
|
|
361
358
|
scope: scope,
|
|
362
359
|
env: env,
|
|
363
360
|
projectName: projectName
|
|
364
361
|
}) || this;
|
|
365
|
-
_this.cloudflare = void 0;
|
|
366
362
|
_this.routes = [];
|
|
367
|
-
_this.workerNamespace = void 0;
|
|
368
363
|
_this.routes = routes;
|
|
369
|
-
_this.workerNamespace = workerNamespace;
|
|
370
|
-
if (auth) {
|
|
371
|
-
_this.cloudflare = new Cloudflare(auth);
|
|
372
|
-
}
|
|
373
364
|
return _this;
|
|
374
365
|
}
|
|
375
366
|
_inheritsLoose(CloudflareDeployer, _MastraDeployer);
|
|
@@ -381,7 +372,7 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
381
372
|
dir: dir
|
|
382
373
|
});
|
|
383
374
|
var cfWorkerName = this.projectName || 'mastra';
|
|
384
|
-
|
|
375
|
+
writeFileSync(join(dir, 'wrangler.json'), JSON.stringify({
|
|
385
376
|
name: cfWorkerName,
|
|
386
377
|
main: 'index.mjs',
|
|
387
378
|
compatibility_date: '2024-12-02',
|
|
@@ -394,33 +385,24 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
394
385
|
enabled: true
|
|
395
386
|
}
|
|
396
387
|
},
|
|
388
|
+
routes: this.routes,
|
|
397
389
|
vars: this.env
|
|
398
|
-
};
|
|
399
|
-
if (!this.workerNamespace && this.routes) {
|
|
400
|
-
wranglerConfig.routes = this.routes;
|
|
401
|
-
}
|
|
402
|
-
writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));
|
|
390
|
+
}));
|
|
403
391
|
};
|
|
404
392
|
_proto.writeIndex = function writeIndex(_ref3) {
|
|
405
393
|
var dir = _ref3.dir;
|
|
406
|
-
writeFileSync(join(dir, './index.mjs'), "\n export default {\n fetch: async (
|
|
394
|
+
writeFileSync(join(dir, './index.mjs'), "\n export default {\n fetch: async (event, context) => {\n const { app } = await import('./hono.mjs');\n return app.fetch(event, context);\n }\n }\n ");
|
|
407
395
|
};
|
|
408
396
|
_proto.deploy = /*#__PURE__*/function () {
|
|
409
397
|
var _deploy = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
|
|
410
|
-
var dir, token
|
|
398
|
+
var dir, token;
|
|
411
399
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
412
400
|
while (1) switch (_context.prev = _context.next) {
|
|
413
401
|
case 0:
|
|
414
402
|
dir = _ref4.dir, token = _ref4.token;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
root: dir
|
|
419
|
-
});
|
|
420
|
-
_context.next = 5;
|
|
421
|
-
return cpLogger({
|
|
422
|
-
cmd: cmd,
|
|
423
|
-
args: [],
|
|
403
|
+
child_process.execSync("npm exec wrangler deploy", {
|
|
404
|
+
cwd: dir,
|
|
405
|
+
stdio: 'inherit',
|
|
424
406
|
env: _extends({
|
|
425
407
|
CLOUDFLARE_API_TOKEN: token,
|
|
426
408
|
CLOUDFLARE_ACCOUNT_ID: this.scope
|
|
@@ -428,7 +410,7 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
428
410
|
PATH: process.env.PATH
|
|
429
411
|
})
|
|
430
412
|
});
|
|
431
|
-
case
|
|
413
|
+
case 2:
|
|
432
414
|
case "end":
|
|
433
415
|
return _context.stop();
|
|
434
416
|
}
|
|
@@ -439,35 +421,6 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
439
421
|
}
|
|
440
422
|
return deploy;
|
|
441
423
|
}();
|
|
442
|
-
_proto.tagWorker = /*#__PURE__*/function () {
|
|
443
|
-
var _tagWorker = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
|
|
444
|
-
var workerName, namespace, tags, scope;
|
|
445
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
446
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
447
|
-
case 0:
|
|
448
|
-
workerName = _ref5.workerName, namespace = _ref5.namespace, tags = _ref5.tags, scope = _ref5.scope;
|
|
449
|
-
if (this.cloudflare) {
|
|
450
|
-
_context2.next = 3;
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
throw new Error('Cloudflare Deployer not initialized');
|
|
454
|
-
case 3:
|
|
455
|
-
_context2.next = 5;
|
|
456
|
-
return this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
457
|
-
account_id: scope,
|
|
458
|
-
body: tags
|
|
459
|
-
});
|
|
460
|
-
case 5:
|
|
461
|
-
case "end":
|
|
462
|
-
return _context2.stop();
|
|
463
|
-
}
|
|
464
|
-
}, _callee2, this);
|
|
465
|
-
}));
|
|
466
|
-
function tagWorker(_x2) {
|
|
467
|
-
return _tagWorker.apply(this, arguments);
|
|
468
|
-
}
|
|
469
|
-
return tagWorker;
|
|
470
|
-
}();
|
|
471
424
|
return CloudflareDeployer;
|
|
472
425
|
}(MastraDeployer);
|
|
473
426
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployer-cloudflare.esm.js","sources":["../src/index.ts"],"sourcesContent":["import { MastraDeployer } from '@mastra/core';\nimport
|
|
1
|
+
{"version":3,"file":"deployer-cloudflare.esm.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 (event, context) => {\n const { app } = await import('./hono.mjs');\n return app.fetch(event, 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWaA,IAAAA,kBAAmB,0BAAAC,eAAA,EAAA;EAE9B,SAAAD,kBAAAA,CAAAE,IAAA,EAUC;AAAA,IAAA,IAAAC,KAAA,CAAA;AAAA,IAAA,IATCC,KAAK,GAAAF,IAAA,CAALE,KAAK;MACLC,GAAG,GAAAH,IAAA,CAAHG,GAAG;MACHC,WAAW,GAAAJ,IAAA,CAAXI,W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AAAV,QAAA,CAAAY,IAAA,EAAA,CAAA;AAAA,SAAA;AAAA,OAAA,EAAAjB,OAAA,EAAA,IAAA,CAAA,CAAA;KACJ,CAAA,CAAA,CAAA;IAAA,SAXKL,MAAMA,CAAAuB,EAAA,EAAA;AAAA,MAAA,OAAAtB,OAAA,CAAAuB,KAAA,CAAA,IAAA,EAAAC,SAAA,CAAA,CAAA;AAAA,KAAA;AAAA,IAAA,OAANzB,MAAM,CAAA;AAAA,GAAA,EAAA,CAAA;AAAA,EAAA,OAAAjC,kBAAA,CAAA;AAAA,CAAA,CA5D0B2D,cAAc;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,19 +5,12 @@ interface CFRoute {
|
|
|
5
5
|
custom_domain?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare class CloudflareDeployer extends MastraDeployer {
|
|
8
|
-
private cloudflare;
|
|
9
8
|
routes?: CFRoute[];
|
|
10
|
-
|
|
11
|
-
constructor({ scope, env, projectName, routes, workerNamespace, auth, }: {
|
|
9
|
+
constructor({ scope, env, projectName, routes, }: {
|
|
12
10
|
env?: Record<string, any>;
|
|
13
11
|
scope: string;
|
|
14
12
|
projectName: string;
|
|
15
13
|
routes?: CFRoute[];
|
|
16
|
-
workerNamespace?: string;
|
|
17
|
-
auth?: {
|
|
18
|
-
apiToken: string;
|
|
19
|
-
apiEmail: string;
|
|
20
|
-
};
|
|
21
14
|
});
|
|
22
15
|
writeFiles({ dir }: {
|
|
23
16
|
dir: string;
|
|
@@ -29,12 +22,6 @@ export declare class CloudflareDeployer extends MastraDeployer {
|
|
|
29
22
|
dir: string;
|
|
30
23
|
token: string;
|
|
31
24
|
}): Promise<void>;
|
|
32
|
-
tagWorker({ workerName, namespace, tags, scope, }: {
|
|
33
|
-
scope: string;
|
|
34
|
-
workerName: string;
|
|
35
|
-
namespace: string;
|
|
36
|
-
tags: string[];
|
|
37
|
-
}): Promise<void>;
|
|
38
25
|
}
|
|
39
26
|
export {};
|
|
40
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAK9C,UAAU,OAAO;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,kBAAmB,SAAQ,cAAc;IACpD,MAAM,CAAC,EAAE,OAAO,EAAE,CAAM;gBACZ,EACV,KAAK,EACL,GAAG,EACH,WAAW,EACX,MAAM,GACP,EAAE;QACD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;KACpB;IAMD,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IA4B1C,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAcpC,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAY5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-cloudflare",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,14 +23,13 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"cloudflare": "^4.0.0",
|
|
27
26
|
"date-fns": "^4.1.0",
|
|
28
27
|
"dotenv": "^16.3.1",
|
|
29
28
|
"execa": "^9.3.1",
|
|
30
29
|
"wrangler": "^3.103.2",
|
|
31
30
|
"zod": "^3.24.1",
|
|
32
|
-
"@mastra/core": "0.1.27-alpha.
|
|
33
|
-
"@mastra/deployer": "0.0.1-alpha.
|
|
31
|
+
"@mastra/core": "0.1.27-alpha.66",
|
|
32
|
+
"@mastra/deployer": "0.0.1-alpha.2"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -38,6 +37,7 @@
|
|
|
38
37
|
"@tsconfig/recommended": "^1.0.7",
|
|
39
38
|
"@types/jsdom": "^21.1.7",
|
|
40
39
|
"@types/node": "^22.9.0",
|
|
40
|
+
"@types/pg": "^8.11.10",
|
|
41
41
|
"dts-cli": "^2.0.5",
|
|
42
42
|
"vitest": "^2.1.8"
|
|
43
43
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MastraDeployer } from '@mastra/core';
|
|
2
|
-
import
|
|
3
|
-
import { Cloudflare } from 'cloudflare';
|
|
2
|
+
import * as child_process from 'child_process';
|
|
4
3
|
import { writeFileSync } from 'fs';
|
|
5
4
|
import { join } from 'path';
|
|
6
5
|
|
|
@@ -11,35 +10,21 @@ interface CFRoute {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export class CloudflareDeployer extends MastraDeployer {
|
|
14
|
-
private cloudflare: Cloudflare | undefined;
|
|
15
13
|
routes?: CFRoute[] = [];
|
|
16
|
-
workerNamespace?: string;
|
|
17
14
|
constructor({
|
|
18
15
|
scope,
|
|
19
16
|
env,
|
|
20
17
|
projectName,
|
|
21
18
|
routes,
|
|
22
|
-
workerNamespace,
|
|
23
|
-
auth,
|
|
24
19
|
}: {
|
|
25
20
|
env?: Record<string, any>;
|
|
26
21
|
scope: string;
|
|
27
22
|
projectName: string;
|
|
28
23
|
routes?: CFRoute[];
|
|
29
|
-
workerNamespace?: string;
|
|
30
|
-
auth?: {
|
|
31
|
-
apiToken: string;
|
|
32
|
-
apiEmail: string;
|
|
33
|
-
};
|
|
34
24
|
}) {
|
|
35
25
|
super({ scope, env, projectName });
|
|
36
26
|
|
|
37
27
|
this.routes = routes;
|
|
38
|
-
this.workerNamespace = workerNamespace;
|
|
39
|
-
|
|
40
|
-
if (auth) {
|
|
41
|
-
this.cloudflare = new Cloudflare(auth);
|
|
42
|
-
}
|
|
43
28
|
}
|
|
44
29
|
|
|
45
30
|
writeFiles({ dir }: { dir: string }): void {
|
|
@@ -49,27 +34,25 @@ export class CloudflareDeployer extends MastraDeployer {
|
|
|
49
34
|
|
|
50
35
|
const cfWorkerName = this.projectName || 'mastra';
|
|
51
36
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
logs: {
|
|
62
|
-
enabled: true,
|
|
37
|
+
writeFileSync(
|
|
38
|
+
join(dir, 'wrangler.json'),
|
|
39
|
+
JSON.stringify({
|
|
40
|
+
name: cfWorkerName,
|
|
41
|
+
main: 'index.mjs',
|
|
42
|
+
compatibility_date: '2024-12-02',
|
|
43
|
+
compatibility_flags: ['nodejs_compat'],
|
|
44
|
+
build: {
|
|
45
|
+
command: 'npm install',
|
|
63
46
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
observability: {
|
|
48
|
+
logs: {
|
|
49
|
+
enabled: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
routes: this.routes,
|
|
53
|
+
vars: this.env,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
73
56
|
}
|
|
74
57
|
|
|
75
58
|
writeIndex({ dir }: { dir: string }): void {
|
|
@@ -77,12 +60,9 @@ export class CloudflareDeployer extends MastraDeployer {
|
|
|
77
60
|
join(dir, './index.mjs'),
|
|
78
61
|
`
|
|
79
62
|
export default {
|
|
80
|
-
fetch: async (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
84
|
-
const { app } = await import('./hono.mjs');
|
|
85
|
-
return app.fetch(request, env, context);
|
|
63
|
+
fetch: async (event, context) => {
|
|
64
|
+
const { app } = await import('./hono.mjs');
|
|
65
|
+
return app.fetch(event, context);
|
|
86
66
|
}
|
|
87
67
|
}
|
|
88
68
|
`,
|
|
@@ -90,45 +70,15 @@ export class CloudflareDeployer extends MastraDeployer {
|
|
|
90
70
|
}
|
|
91
71
|
|
|
92
72
|
async deploy({ dir, token }: { dir: string; token: string }): Promise<void> {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
: '
|
|
96
|
-
|
|
97
|
-
const cpLogger = createChildProcessLogger({
|
|
98
|
-
logger: this.logger,
|
|
99
|
-
root: dir,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
await cpLogger({
|
|
103
|
-
cmd,
|
|
104
|
-
args: [],
|
|
73
|
+
child_process.execSync(`npm exec wrangler deploy`, {
|
|
74
|
+
cwd: dir,
|
|
75
|
+
stdio: 'inherit',
|
|
105
76
|
env: {
|
|
106
77
|
CLOUDFLARE_API_TOKEN: token,
|
|
107
78
|
CLOUDFLARE_ACCOUNT_ID: this.scope,
|
|
108
79
|
...this.env,
|
|
109
|
-
PATH: process.env.PATH
|
|
80
|
+
PATH: process.env.PATH,
|
|
110
81
|
},
|
|
111
82
|
});
|
|
112
83
|
}
|
|
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
|
-
}
|
|
134
84
|
}
|