@mastra/deployer-cloudflare 0.0.1-alpha.6 → 0.0.1-alpha.8
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 +19 -0
- package/dist/deployer-cloudflare.cjs.development.js +36 -1
- 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 +36 -1
- package/dist/deployer-cloudflare.esm.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @mastra/deployer-cloudflare
|
|
2
2
|
|
|
3
|
+
## 0.0.1-alpha.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1944807: Unified logger and major step in better logs
|
|
8
|
+
- c7abf8e: Optional CF worker tagging
|
|
9
|
+
- Updated dependencies [1944807]
|
|
10
|
+
- Updated dependencies [9ade36e]
|
|
11
|
+
- @mastra/deployer@0.0.1-alpha.7
|
|
12
|
+
- @mastra/core@0.1.27-alpha.69
|
|
13
|
+
|
|
14
|
+
## 0.0.1-alpha.7
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [291fe57]
|
|
19
|
+
- Updated dependencies [1a41fbf]
|
|
20
|
+
- @mastra/deployer@0.0.1-alpha.6
|
|
21
|
+
|
|
3
22
|
## 0.0.1-alpha.6
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@mastra/core');
|
|
6
6
|
var child_process = require('child_process');
|
|
7
|
+
var cloudflare = require('cloudflare');
|
|
7
8
|
var fs = require('fs');
|
|
8
9
|
var path = require('path');
|
|
9
10
|
|
|
@@ -377,16 +378,21 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
377
378
|
env = _ref.env,
|
|
378
379
|
projectName = _ref.projectName,
|
|
379
380
|
routes = _ref.routes,
|
|
380
|
-
workerNamespace = _ref.workerNamespace
|
|
381
|
+
workerNamespace = _ref.workerNamespace,
|
|
382
|
+
auth = _ref.auth;
|
|
381
383
|
_this = _MastraDeployer.call(this, {
|
|
382
384
|
scope: scope,
|
|
383
385
|
env: env,
|
|
384
386
|
projectName: projectName
|
|
385
387
|
}) || this;
|
|
388
|
+
_this.cloudflare = void 0;
|
|
386
389
|
_this.routes = [];
|
|
387
390
|
_this.workerNamespace = void 0;
|
|
388
391
|
_this.routes = routes;
|
|
389
392
|
_this.workerNamespace = workerNamespace;
|
|
393
|
+
if (auth) {
|
|
394
|
+
_this.cloudflare = new cloudflare.Cloudflare(auth);
|
|
395
|
+
}
|
|
390
396
|
return _this;
|
|
391
397
|
}
|
|
392
398
|
_inheritsLoose(CloudflareDeployer, _MastraDeployer);
|
|
@@ -451,6 +457,35 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
451
457
|
}
|
|
452
458
|
return deploy;
|
|
453
459
|
}();
|
|
460
|
+
_proto.tagWorker = /*#__PURE__*/function () {
|
|
461
|
+
var _tagWorker = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
|
|
462
|
+
var workerName, namespace, tags, scope;
|
|
463
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
464
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
465
|
+
case 0:
|
|
466
|
+
workerName = _ref5.workerName, namespace = _ref5.namespace, tags = _ref5.tags, scope = _ref5.scope;
|
|
467
|
+
if (this.cloudflare) {
|
|
468
|
+
_context2.next = 3;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
throw new Error('Cloudflare Deployer not initialized');
|
|
472
|
+
case 3:
|
|
473
|
+
_context2.next = 5;
|
|
474
|
+
return this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
475
|
+
account_id: scope,
|
|
476
|
+
body: tags
|
|
477
|
+
});
|
|
478
|
+
case 5:
|
|
479
|
+
case "end":
|
|
480
|
+
return _context2.stop();
|
|
481
|
+
}
|
|
482
|
+
}, _callee2, this);
|
|
483
|
+
}));
|
|
484
|
+
function tagWorker(_x2) {
|
|
485
|
+
return _tagWorker.apply(this, arguments);
|
|
486
|
+
}
|
|
487
|
+
return tagWorker;
|
|
488
|
+
}();
|
|
454
489
|
return CloudflareDeployer;
|
|
455
490
|
}(core.MastraDeployer);
|
|
456
491
|
|
|
@@ -1 +1 @@
|
|
|
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 workerNamespace?: string;\n constructor({\n scope,\n env,\n projectName,\n routes,\n workerNamespace,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n workerNamespace?: string;\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n this.workerNamespace = workerNamespace;\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 const wranglerConfig: Record<string, any> = {\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 vars: this.env,\n };\n\n if (!this.workerNamespace && this.routes) {\n wranglerConfig.routes = this.routes;\n }\n\n writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));\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 const cmd = this.workerNamespace\n ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`\n : 'npm exec -- wrangler deploy';\n child_process.execSync(cmd, {\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","workerNamespace","call","_inheritsLoose","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","cfWorkerName","wranglerConfig","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","writeFileSync","join","JSON","stringify","_ref3","deploy","_deploy","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref4","token","cmd","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":"
|
|
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 { Cloudflare } from 'cloudflare';\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 private cloudflare: Cloudflare | undefined;\n routes?: CFRoute[] = [];\n workerNamespace?: string;\n constructor({\n scope,\n env,\n projectName,\n routes,\n workerNamespace,\n auth,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n workerNamespace?: string;\n auth?: {\n apiToken: string;\n apiEmail: string;\n };\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n this.workerNamespace = workerNamespace;\n\n if (auth) {\n this.cloudflare = new Cloudflare(auth);\n }\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 const wranglerConfig: Record<string, any> = {\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 vars: this.env,\n };\n\n if (!this.workerNamespace && this.routes) {\n wranglerConfig.routes = this.routes;\n }\n\n writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));\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 const cmd = this.workerNamespace\n ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`\n : 'npm exec -- wrangler deploy';\n child_process.execSync(cmd, {\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 async tagWorker({\n workerName,\n namespace,\n tags,\n scope,\n }: {\n scope: string;\n workerName: string;\n namespace: string;\n tags: string[];\n }): Promise<void> {\n if (!this.cloudflare) {\n throw new Error('Cloudflare Deployer not initialized');\n }\n\n await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {\n account_id: scope,\n body: tags,\n });\n }\n}\n"],"names":["CloudflareDeployer","_MastraDeployer","_ref","_this","scope","env","projectName","routes","workerNamespace","auth","call","cloudflare","Cloudflare","_inheritsLoose","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","cfWorkerName","wranglerConfig","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","writeFileSync","join","JSON","stringify","_ref3","deploy","_deploy","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref4","token","cmd","wrap","_callee$","_context","prev","next","child_process","execSync","cwd","stdio","_extends","CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID","PATH","process","stop","_x","apply","arguments","tagWorker","_tagWorker","_callee2","_ref5","workerName","namespace","tags","_callee2$","_context2","Error","workersForPlatforms","dispatch","namespaces","scripts","update","account_id","body","_x2","MastraDeployer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYaA,IAAAA,kBAAmB,0BAAAC,eAAA,EAAA;EAI9B,SAAAD,kBAAAA,CAAAE,IAAA,EAiBC;AAAA,IAAA,IAAAC,KAAA,CAAA;AAAA,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A,OAATC,SAAS,CAAA;AAAA,GAAA,EAAA,CAAA;AAAA,EAAA,OAAAjE,kBAAA,CAAA;AAAA,CAAA,CA/FuBmF,mBAAc;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@mastra/core"),e=require("child_process"),r=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@mastra/core"),e=require("child_process"),r=require("cloudflare"),n=require("fs"),o=require("path");function i(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 a=i(e);function c(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 u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,u,"next",t)}function u(t){c(i,n,o,a,u,"throw",t)}a(void 0)}))}}function s(){return s=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},s.apply(null,arguments)}function l(){l=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 s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=Object.create((e&&e.prototype instanceof g?e:g).prototype),a=new S(n||[]);return o(i,"_invoke",{value:k(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=f;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",m={};function g(){}function w(){}function b(){}var x={};s(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=g.prototype=Object.create(x);function E(t){["next","throw","return"].forEach((function(e){s(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,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).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 k(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=N(c,n);if(u){if(u===m)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===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function N(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,N(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;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,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function P(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(P,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=s(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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},E(_.prototype),s(_.prototype,c,(function(){return this})),e.AsyncIterator=_,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new _(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},E(L),s(L,u,"Generator"),s(L,a,(function(){return this})),s(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,m):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),m},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),m}},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),m}},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 n,o=e.routes,i=e.workerNamespace,a=e.auth;return(n=t.call(this,{scope:e.scope,env:e.env,projectName:e.projectName})||this).cloudflare=void 0,n.routes=[],n.workerNamespace=void 0,n.routes=o,n.workerNamespace=i,a&&(n.cloudflare=new r.Cloudflare(a)),n}var i,c;c=t,(i=e).prototype=Object.create(c.prototype),i.prototype.constructor=i,f(i,c);var h=e.prototype;return h.writeFiles=function(t){var e=t.dir;this.loadEnvVars(),this.writeIndex({dir:e});var r={name:this.projectName||"mastra",main:"index.mjs",compatibility_date:"2024-12-02",compatibility_flags:["nodejs_compat"],build:{command:"npm install"},observability:{logs:{enabled:!0}},vars:this.env};!this.workerNamespace&&this.routes&&(r.routes=this.routes),n.writeFileSync(o.join(e,"wrangler.json"),JSON.stringify(r))},h.writeIndex=function(t){n.writeFileSync(o.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 ")},h.deploy=function(){var t=u(l().mark((function t(e){return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a.execSync(this.workerNamespace?"npm exec -- wrangler deploy --dispatch-namespace "+this.workerNamespace:"npm exec -- wrangler deploy",{cwd:e.dir,stdio:"inherit",env:s({CLOUDFLARE_API_TOKEN:e.token,CLOUDFLARE_ACCOUNT_ID:this.scope},this.env,{PATH:process.env.PATH})});case 3:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),h.tagWorker=function(){var t=u(l().mark((function t(e){var r,n,o,i;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.workerName,n=e.namespace,o=e.tags,i=e.scope,this.cloudflare){t.next=3;break}throw new Error("Cloudflare Deployer not initialized");case 3:return t.next=5,this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(n,r,{account_id:i,body:o});case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(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 * 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 workerNamespace?: string;\n constructor({\n scope,\n env,\n projectName,\n routes,\n workerNamespace,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n workerNamespace?: string;\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n this.workerNamespace = workerNamespace;\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 const wranglerConfig: Record<string, any> = {\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 vars: this.env,\n };\n\n if (!this.workerNamespace && this.routes) {\n wranglerConfig.routes = this.routes;\n }\n\n writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));\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 const cmd = this.workerNamespace\n ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`\n : 'npm exec -- wrangler deploy';\n child_process.execSync(cmd, {\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","workerNamespace","call","this","scope","env","projectName","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","wranglerConfig","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","writeFileSync","join","JSON","stringify","_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":"
|
|
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 { Cloudflare } from 'cloudflare';\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 private cloudflare: Cloudflare | undefined;\n routes?: CFRoute[] = [];\n workerNamespace?: string;\n constructor({\n scope,\n env,\n projectName,\n routes,\n workerNamespace,\n auth,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n workerNamespace?: string;\n auth?: {\n apiToken: string;\n apiEmail: string;\n };\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n this.workerNamespace = workerNamespace;\n\n if (auth) {\n this.cloudflare = new Cloudflare(auth);\n }\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 const wranglerConfig: Record<string, any> = {\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 vars: this.env,\n };\n\n if (!this.workerNamespace && this.routes) {\n wranglerConfig.routes = this.routes;\n }\n\n writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));\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 const cmd = this.workerNamespace\n ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`\n : 'npm exec -- wrangler deploy';\n child_process.execSync(cmd, {\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 async tagWorker({\n workerName,\n namespace,\n tags,\n scope,\n }: {\n scope: string;\n workerName: string;\n namespace: string;\n tags: string[];\n }): Promise<void> {\n if (!this.cloudflare) {\n throw new Error('Cloudflare Deployer not initialized');\n }\n\n await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {\n account_id: scope,\n body: tags,\n });\n }\n}\n"],"names":["_MastraDeployer","CloudflareDeployer","_ref","_this","routes","workerNamespace","auth","call","this","scope","env","projectName","cloudflare","Cloudflare","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","wranglerConfig","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","writeFileSync","join","JSON","stringify","_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","tagWorker","_tagWorker","_callee2","_ref5","workerName","namespace","tags","_context2","Error","workersForPlatforms","dispatch","namespaces","scripts","update","account_id","body","_x2","MastraDeployer"],"mappings":"28OAYgCA,GAI9B,SAAAC,EAAAC,GAiBC,IAAAC,EAbCC,EAAMF,EAANE,OACAC,EAAeH,EAAfG,gBACAC,EAAIJ,EAAJI,KAmBC,OAPDH,EAAAH,EAAAO,KAAMC,KAAA,CAAEC,MAjBHP,EAALO,MAiBeC,IAhBZR,EAAHQ,IAgBoBC,YAfTT,EAAXS,eAekCH,MArB5BI,gBAAU,EAAAT,EAClBC,OAAqB,GAAED,EACvBE,qBAAe,EAqBbF,EAAKC,OAASA,EACdD,EAAKE,gBAAkBA,EAEnBC,IACFH,EAAKS,WAAa,IAAIC,EAAUA,WAACP,IAClCH,CACH,WAACH,KAAAC,yEAAA,IAAAa,EAAAb,EAAAc,UAiEc,OAjEdD,EAEDE,WAAA,SAAUC,GAAyB,IAAtBC,EAAGD,EAAHC,IACXV,KAAKW,cAELX,KAAKY,WAAW,CAAEF,IAAAA,IAElB,IAEMG,EAAsC,CAC1CC,KAHmBd,KAAKG,aAAe,SAIvCY,KAAM,YACNC,mBAAoB,aACpBC,oBAAqB,CAAC,iBACtBC,MAAO,CACLC,QAAS,eAEXC,cAAe,CACbC,KAAM,CACJC,SAAS,IAGbC,KAAMvB,KAAKE,MAGRF,KAAKH,iBAAmBG,KAAKJ,SAChCiB,EAAejB,OAASI,KAAKJ,QAG/B4B,gBAAcC,EAAAA,KAAKf,EAAK,iBAAkBgB,KAAKC,UAAUd,KAC1DP,EAEDM,WAAA,SAAUgB,GACRJ,EAAAA,cACEC,EAAAA,KAFYG,EAAHlB,IAEC,0UAabJ,EAEKuB,OAAM,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,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ployer } from '@mastra/core';
|
|
2
2
|
import * as child_process from 'child_process';
|
|
3
|
+
import { Cloudflare } from 'cloudflare';
|
|
3
4
|
import { writeFileSync } from 'fs';
|
|
4
5
|
import { join } from 'path';
|
|
5
6
|
|
|
@@ -354,16 +355,21 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
354
355
|
env = _ref.env,
|
|
355
356
|
projectName = _ref.projectName,
|
|
356
357
|
routes = _ref.routes,
|
|
357
|
-
workerNamespace = _ref.workerNamespace
|
|
358
|
+
workerNamespace = _ref.workerNamespace,
|
|
359
|
+
auth = _ref.auth;
|
|
358
360
|
_this = _MastraDeployer.call(this, {
|
|
359
361
|
scope: scope,
|
|
360
362
|
env: env,
|
|
361
363
|
projectName: projectName
|
|
362
364
|
}) || this;
|
|
365
|
+
_this.cloudflare = void 0;
|
|
363
366
|
_this.routes = [];
|
|
364
367
|
_this.workerNamespace = void 0;
|
|
365
368
|
_this.routes = routes;
|
|
366
369
|
_this.workerNamespace = workerNamespace;
|
|
370
|
+
if (auth) {
|
|
371
|
+
_this.cloudflare = new Cloudflare(auth);
|
|
372
|
+
}
|
|
367
373
|
return _this;
|
|
368
374
|
}
|
|
369
375
|
_inheritsLoose(CloudflareDeployer, _MastraDeployer);
|
|
@@ -428,6 +434,35 @@ var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
|
428
434
|
}
|
|
429
435
|
return deploy;
|
|
430
436
|
}();
|
|
437
|
+
_proto.tagWorker = /*#__PURE__*/function () {
|
|
438
|
+
var _tagWorker = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
|
|
439
|
+
var workerName, namespace, tags, scope;
|
|
440
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
441
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
442
|
+
case 0:
|
|
443
|
+
workerName = _ref5.workerName, namespace = _ref5.namespace, tags = _ref5.tags, scope = _ref5.scope;
|
|
444
|
+
if (this.cloudflare) {
|
|
445
|
+
_context2.next = 3;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
throw new Error('Cloudflare Deployer not initialized');
|
|
449
|
+
case 3:
|
|
450
|
+
_context2.next = 5;
|
|
451
|
+
return this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
452
|
+
account_id: scope,
|
|
453
|
+
body: tags
|
|
454
|
+
});
|
|
455
|
+
case 5:
|
|
456
|
+
case "end":
|
|
457
|
+
return _context2.stop();
|
|
458
|
+
}
|
|
459
|
+
}, _callee2, this);
|
|
460
|
+
}));
|
|
461
|
+
function tagWorker(_x2) {
|
|
462
|
+
return _tagWorker.apply(this, arguments);
|
|
463
|
+
}
|
|
464
|
+
return tagWorker;
|
|
465
|
+
}();
|
|
431
466
|
return CloudflareDeployer;
|
|
432
467
|
}(MastraDeployer);
|
|
433
468
|
|
|
@@ -1 +1 @@
|
|
|
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 workerNamespace?: string;\n constructor({\n scope,\n env,\n projectName,\n routes,\n workerNamespace,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n workerNamespace?: string;\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n this.workerNamespace = workerNamespace;\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 const wranglerConfig: Record<string, any> = {\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 vars: this.env,\n };\n\n if (!this.workerNamespace && this.routes) {\n wranglerConfig.routes = this.routes;\n }\n\n writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));\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 const cmd = this.workerNamespace\n ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`\n : 'npm exec -- wrangler deploy';\n child_process.execSync(cmd, {\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","workerNamespace","call","_inheritsLoose","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","cfWorkerName","wranglerConfig","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","writeFileSync","join","JSON","stringify","_ref3","deploy","_deploy","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref4","token","cmd","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":"
|
|
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 { Cloudflare } from 'cloudflare';\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 private cloudflare: Cloudflare | undefined;\n routes?: CFRoute[] = [];\n workerNamespace?: string;\n constructor({\n scope,\n env,\n projectName,\n routes,\n workerNamespace,\n auth,\n }: {\n env?: Record<string, any>;\n scope: string;\n projectName: string;\n routes?: CFRoute[];\n workerNamespace?: string;\n auth?: {\n apiToken: string;\n apiEmail: string;\n };\n }) {\n super({ scope, env, projectName });\n\n this.routes = routes;\n this.workerNamespace = workerNamespace;\n\n if (auth) {\n this.cloudflare = new Cloudflare(auth);\n }\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 const wranglerConfig: Record<string, any> = {\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 vars: this.env,\n };\n\n if (!this.workerNamespace && this.routes) {\n wranglerConfig.routes = this.routes;\n }\n\n writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));\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 const cmd = this.workerNamespace\n ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`\n : 'npm exec -- wrangler deploy';\n child_process.execSync(cmd, {\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 async tagWorker({\n workerName,\n namespace,\n tags,\n scope,\n }: {\n scope: string;\n workerName: string;\n namespace: string;\n tags: string[];\n }): Promise<void> {\n if (!this.cloudflare) {\n throw new Error('Cloudflare Deployer not initialized');\n }\n\n await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {\n account_id: scope,\n body: tags,\n });\n }\n}\n"],"names":["CloudflareDeployer","_MastraDeployer","_ref","_this","scope","env","projectName","routes","workerNamespace","auth","call","cloudflare","Cloudflare","_inheritsLoose","_proto","prototype","writeFiles","_ref2","dir","loadEnvVars","writeIndex","cfWorkerName","wranglerConfig","name","main","compatibility_date","compatibility_flags","build","command","observability","logs","enabled","vars","writeFileSync","join","JSON","stringify","_ref3","deploy","_deploy","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref4","token","cmd","wrap","_callee$","_context","prev","next","child_process","execSync","cwd","stdio","_extends","CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID","PATH","process","stop","_x","apply","arguments","tagWorker","_tagWorker","_callee2","_ref5","workerName","namespace","tags","_callee2$","_context2","Error","workersForPlatforms","dispatch","namespaces","scripts","update","account_id","body","_x2","MastraDeployer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYaA,IAAAA,kBAAmB,0BAAAC,eAAA,EAAA;EAI9B,SAAAD,kBAAAA,CAAAE,IAA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C,SAAA,CAAA,CAAA;AAAA,KAAA;AAAA,IAAA,OAATC,SAAS,CAAA;AAAA,GAAA,EAAA,CAAA;AAAA,EAAA,OAAAjE,kBAAA,CAAA;AAAA,CAAA,CA/FuBmF,cAAc;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,14 +5,19 @@ interface CFRoute {
|
|
|
5
5
|
custom_domain?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare class CloudflareDeployer extends MastraDeployer {
|
|
8
|
+
private cloudflare;
|
|
8
9
|
routes?: CFRoute[];
|
|
9
10
|
workerNamespace?: string;
|
|
10
|
-
constructor({ scope, env, projectName, routes, workerNamespace, }: {
|
|
11
|
+
constructor({ scope, env, projectName, routes, workerNamespace, auth, }: {
|
|
11
12
|
env?: Record<string, any>;
|
|
12
13
|
scope: string;
|
|
13
14
|
projectName: string;
|
|
14
15
|
routes?: CFRoute[];
|
|
15
16
|
workerNamespace?: string;
|
|
17
|
+
auth?: {
|
|
18
|
+
apiToken: string;
|
|
19
|
+
apiEmail: string;
|
|
20
|
+
};
|
|
16
21
|
});
|
|
17
22
|
writeFiles({ dir }: {
|
|
18
23
|
dir: string;
|
|
@@ -24,6 +29,12 @@ export declare class CloudflareDeployer extends MastraDeployer {
|
|
|
24
29
|
dir: string;
|
|
25
30
|
token: string;
|
|
26
31
|
}): Promise<void>;
|
|
32
|
+
tagWorker({ workerName, namespace, tags, scope, }: {
|
|
33
|
+
scope: string;
|
|
34
|
+
workerName: string;
|
|
35
|
+
namespace: string;
|
|
36
|
+
tags: string[];
|
|
37
|
+
}): Promise<void>;
|
|
27
38
|
}
|
|
28
39
|
export {};
|
|
29
40
|
//# 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
|
+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ACnB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlB"}
|
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.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"cloudflare": "^4.0.0",
|
|
26
27
|
"date-fns": "^4.1.0",
|
|
27
28
|
"dotenv": "^16.3.1",
|
|
28
29
|
"execa": "^9.3.1",
|
|
29
30
|
"wrangler": "^3.103.2",
|
|
30
31
|
"zod": "^3.24.1",
|
|
31
|
-
"@mastra/core": "0.1.27-alpha.
|
|
32
|
-
"@mastra/deployer": "0.0.1-alpha.
|
|
32
|
+
"@mastra/core": "0.1.27-alpha.69",
|
|
33
|
+
"@mastra/deployer": "0.0.1-alpha.7"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@babel/preset-env": "^7.26.0",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MastraDeployer } from '@mastra/core';
|
|
2
2
|
import * as child_process from 'child_process';
|
|
3
|
+
import { Cloudflare } from 'cloudflare';
|
|
3
4
|
import { writeFileSync } from 'fs';
|
|
4
5
|
import { join } from 'path';
|
|
5
6
|
|
|
@@ -10,6 +11,7 @@ interface CFRoute {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export class CloudflareDeployer extends MastraDeployer {
|
|
14
|
+
private cloudflare: Cloudflare | undefined;
|
|
13
15
|
routes?: CFRoute[] = [];
|
|
14
16
|
workerNamespace?: string;
|
|
15
17
|
constructor({
|
|
@@ -18,17 +20,26 @@ export class CloudflareDeployer extends MastraDeployer {
|
|
|
18
20
|
projectName,
|
|
19
21
|
routes,
|
|
20
22
|
workerNamespace,
|
|
23
|
+
auth,
|
|
21
24
|
}: {
|
|
22
25
|
env?: Record<string, any>;
|
|
23
26
|
scope: string;
|
|
24
27
|
projectName: string;
|
|
25
28
|
routes?: CFRoute[];
|
|
26
29
|
workerNamespace?: string;
|
|
30
|
+
auth?: {
|
|
31
|
+
apiToken: string;
|
|
32
|
+
apiEmail: string;
|
|
33
|
+
};
|
|
27
34
|
}) {
|
|
28
35
|
super({ scope, env, projectName });
|
|
29
36
|
|
|
30
37
|
this.routes = routes;
|
|
31
38
|
this.workerNamespace = workerNamespace;
|
|
39
|
+
|
|
40
|
+
if (auth) {
|
|
41
|
+
this.cloudflare = new Cloudflare(auth);
|
|
42
|
+
}
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
writeFiles({ dir }: { dir: string }): void {
|
|
@@ -93,4 +104,25 @@ export class CloudflareDeployer extends MastraDeployer {
|
|
|
93
104
|
},
|
|
94
105
|
});
|
|
95
106
|
}
|
|
107
|
+
|
|
108
|
+
async tagWorker({
|
|
109
|
+
workerName,
|
|
110
|
+
namespace,
|
|
111
|
+
tags,
|
|
112
|
+
scope,
|
|
113
|
+
}: {
|
|
114
|
+
scope: string;
|
|
115
|
+
workerName: string;
|
|
116
|
+
namespace: string;
|
|
117
|
+
tags: string[];
|
|
118
|
+
}): Promise<void> {
|
|
119
|
+
if (!this.cloudflare) {
|
|
120
|
+
throw new Error('Cloudflare Deployer not initialized');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
124
|
+
account_id: scope,
|
|
125
|
+
body: tags,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
96
128
|
}
|