@mastra/deployer-cloudflare 0.0.1-alpha.34 → 0.0.1-alpha.4
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 -250
- package/dist/deployer-cloudflare.cjs.development.js +458 -0
- package/dist/deployer-cloudflare.cjs.development.js.map +1 -0
- package/dist/deployer-cloudflare.cjs.production.min.js +2 -0
- package/dist/deployer-cloudflare.cjs.production.min.js.map +1 -0
- package/dist/deployer-cloudflare.esm.js +435 -0
- package/dist/deployer-cloudflare.esm.js.map +1 -0
- package/dist/index.d.ts +15 -26
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -148
- package/dist/secrets-manager/index.d.ts +2 -3
- package/dist/secrets-manager/index.d.ts.map +1 -0
- package/package.json +18 -17
- package/src/index.ts +35 -131
- package/src/secrets-manager/index.ts +3 -3
- package/tsconfig.json +7 -2
- package/vitest.config.ts +1 -1
- package/README.md +0 -99
- package/dist/secrets-manager/index.js +0 -87
- package/global.d.ts +0 -1
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,KAAA;AAAA,IAAA,OAAN1B,MAAM,CAAA;AAAA,GAAA,EAAA,CAAA;AAAA,EAAA,OAAAnC,kBAAA,CAAA;AAAA,CAAA,CArE0B8D,mBAAc;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
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 l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=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={};l(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){l(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=l(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,l(t,u,"GeneratorFunction")),t.prototype=Object.create(L),t},e.awrap=function(t){return{__await:t}},E(_.prototype),l(_.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),l(L,u,"Generator"),l(L,a,(function(){return this})),l(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 l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}exports.CloudflareDeployer=function(t){function e(e){var r,n=e.routes,o=e.workerNamespace;return(r=t.call(this,{scope:e.scope,env:e.env,projectName:e.projectName})||this).routes=[],r.workerNamespace=void 0,r.routes=n,r.workerNamespace=o,r}var o,a;a=t,(o=e).prototype=Object.create(a.prototype),o.prototype.constructor=o,l(o,a);var f=e.prototype;return f.writeFiles=function(t){var e=t.dir;this.loadEnvVars(),this.writeIndex({dir:e});var o={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&&(o.routes=this.routes),r.writeFileSync(n.join(e,"wrangler.json"),JSON.stringify(o))},f.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 ")},f.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(this.workerNamespace?"npm exec -- wrangler deploy --dispatch-namespace "+this.workerNamespace:"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 3: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
|
|
@@ -0,0 +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":"m7OAWgCA,GAG9B,SAAAC,EAAAC,GAYC,IAAAC,EARCC,EAAMF,EAANE,OACAC,EAAeH,EAAfG,gBAWuC,OAHvCF,EAAAH,EAAAM,KAAMC,KAAA,CAAEC,MAZHN,EAALM,MAYeC,IAXZP,EAAHO,IAWoBC,YAVTR,EAAXQ,eAUkCH,MAfpCH,OAAqB,GAAED,EACvBE,qBAAe,EAgBbF,EAAKC,OAASA,EACdD,EAAKE,gBAAkBA,EAAgBF,CACzC,WAACH,KAAAC,yEAAA,IAAAU,EAAAV,EAAAW,UAiDW,OAjDXD,EAEDE,WAAA,SAAUC,GAAyB,IAAtBC,EAAGD,EAAHC,IACXR,KAAKS,cAELT,KAAKU,WAAW,CAAEF,IAAAA,IAElB,IAEMG,EAAsC,CAC1CC,KAHmBZ,KAAKG,aAAe,SAIvCU,KAAM,YACNC,mBAAoB,aACpBC,oBAAqB,CAAC,iBACtBC,MAAO,CACLC,QAAS,eAEXC,cAAe,CACbC,KAAM,CACJC,SAAS,IAGbC,KAAMrB,KAAKE,MAGRF,KAAKF,iBAAmBE,KAAKH,SAChCc,EAAed,OAASG,KAAKH,QAG/ByB,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,MAAZ,SAAAC,EAAAC,GAAA,OAAAH,IAAAI,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAIEC,EAAcC,SAHFvC,KAAKF,oEACuCE,KAAKF,gBACzD,8BACwB,CAC1B0C,IALcP,EAAHzB,IAMXiC,MAAO,UACPvC,IAAGwC,EAAA,CACDC,qBARmBV,EAALW,MASdC,sBAAuB7C,KAAKC,OACzBD,KAAKE,IAAG,CACX4C,KAAMC,QAAQ7C,IAAI4C,SAEnB,KAAA,EAAA,IAAA,MAAA,OAAAX,EAAAa,OAAA,GAAAhB,EAAAhC,KACJ,KAdW,OAcX,SAdWiD,GAAA,OAAArB,EAAAsB,MAAAlD,KAAAmD,UAAA,CAAA,CAAA,GAAAzD,CAAA,EArE0B0D,EAAcA"}
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { MastraDeployer } from '@mastra/core';
|
|
2
|
+
import * as child_process from 'child_process';
|
|
3
|
+
import { writeFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
7
|
+
try {
|
|
8
|
+
var i = n[a](c),
|
|
9
|
+
u = i.value;
|
|
10
|
+
} catch (n) {
|
|
11
|
+
return void e(n);
|
|
12
|
+
}
|
|
13
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(n) {
|
|
16
|
+
return function () {
|
|
17
|
+
var t = this,
|
|
18
|
+
e = arguments;
|
|
19
|
+
return new Promise(function (r, o) {
|
|
20
|
+
var a = n.apply(t, e);
|
|
21
|
+
function _next(n) {
|
|
22
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
23
|
+
}
|
|
24
|
+
function _throw(n) {
|
|
25
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
26
|
+
}
|
|
27
|
+
_next(void 0);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function _extends() {
|
|
32
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
33
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
34
|
+
var t = arguments[e];
|
|
35
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
36
|
+
}
|
|
37
|
+
return n;
|
|
38
|
+
}, _extends.apply(null, arguments);
|
|
39
|
+
}
|
|
40
|
+
function _inheritsLoose(t, o) {
|
|
41
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
42
|
+
}
|
|
43
|
+
function _regeneratorRuntime() {
|
|
44
|
+
_regeneratorRuntime = function () {
|
|
45
|
+
return e;
|
|
46
|
+
};
|
|
47
|
+
var t,
|
|
48
|
+
e = {},
|
|
49
|
+
r = Object.prototype,
|
|
50
|
+
n = r.hasOwnProperty,
|
|
51
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
52
|
+
t[e] = r.value;
|
|
53
|
+
},
|
|
54
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
55
|
+
a = i.iterator || "@@iterator",
|
|
56
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
57
|
+
u = i.toStringTag || "@@toStringTag";
|
|
58
|
+
function define(t, e, r) {
|
|
59
|
+
return Object.defineProperty(t, e, {
|
|
60
|
+
value: r,
|
|
61
|
+
enumerable: !0,
|
|
62
|
+
configurable: !0,
|
|
63
|
+
writable: !0
|
|
64
|
+
}), t[e];
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
define({}, "");
|
|
68
|
+
} catch (t) {
|
|
69
|
+
define = function (t, e, r) {
|
|
70
|
+
return t[e] = r;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function wrap(t, e, r, n) {
|
|
74
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
75
|
+
a = Object.create(i.prototype),
|
|
76
|
+
c = new Context(n || []);
|
|
77
|
+
return o(a, "_invoke", {
|
|
78
|
+
value: makeInvokeMethod(t, r, c)
|
|
79
|
+
}), a;
|
|
80
|
+
}
|
|
81
|
+
function tryCatch(t, e, r) {
|
|
82
|
+
try {
|
|
83
|
+
return {
|
|
84
|
+
type: "normal",
|
|
85
|
+
arg: t.call(e, r)
|
|
86
|
+
};
|
|
87
|
+
} catch (t) {
|
|
88
|
+
return {
|
|
89
|
+
type: "throw",
|
|
90
|
+
arg: t
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
e.wrap = wrap;
|
|
95
|
+
var h = "suspendedStart",
|
|
96
|
+
l = "suspendedYield",
|
|
97
|
+
f = "executing",
|
|
98
|
+
s = "completed",
|
|
99
|
+
y = {};
|
|
100
|
+
function Generator() {}
|
|
101
|
+
function GeneratorFunction() {}
|
|
102
|
+
function GeneratorFunctionPrototype() {}
|
|
103
|
+
var p = {};
|
|
104
|
+
define(p, a, function () {
|
|
105
|
+
return this;
|
|
106
|
+
});
|
|
107
|
+
var d = Object.getPrototypeOf,
|
|
108
|
+
v = d && d(d(values([])));
|
|
109
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
110
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
111
|
+
function defineIteratorMethods(t) {
|
|
112
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
113
|
+
define(t, e, function (t) {
|
|
114
|
+
return this._invoke(e, t);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function AsyncIterator(t, e) {
|
|
119
|
+
function invoke(r, o, i, a) {
|
|
120
|
+
var c = tryCatch(t[r], t, o);
|
|
121
|
+
if ("throw" !== c.type) {
|
|
122
|
+
var u = c.arg,
|
|
123
|
+
h = u.value;
|
|
124
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
125
|
+
invoke("next", t, i, a);
|
|
126
|
+
}, function (t) {
|
|
127
|
+
invoke("throw", t, i, a);
|
|
128
|
+
}) : e.resolve(h).then(function (t) {
|
|
129
|
+
u.value = t, i(u);
|
|
130
|
+
}, function (t) {
|
|
131
|
+
return invoke("throw", t, i, a);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
a(c.arg);
|
|
135
|
+
}
|
|
136
|
+
var r;
|
|
137
|
+
o(this, "_invoke", {
|
|
138
|
+
value: function (t, n) {
|
|
139
|
+
function callInvokeWithMethodAndArg() {
|
|
140
|
+
return new e(function (e, r) {
|
|
141
|
+
invoke(t, n, e, r);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function makeInvokeMethod(e, r, n) {
|
|
149
|
+
var o = h;
|
|
150
|
+
return function (i, a) {
|
|
151
|
+
if (o === f) throw Error("Generator is already running");
|
|
152
|
+
if (o === s) {
|
|
153
|
+
if ("throw" === i) throw a;
|
|
154
|
+
return {
|
|
155
|
+
value: t,
|
|
156
|
+
done: !0
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
for (n.method = i, n.arg = a;;) {
|
|
160
|
+
var c = n.delegate;
|
|
161
|
+
if (c) {
|
|
162
|
+
var u = maybeInvokeDelegate(c, n);
|
|
163
|
+
if (u) {
|
|
164
|
+
if (u === y) continue;
|
|
165
|
+
return u;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
169
|
+
if (o === h) throw o = s, n.arg;
|
|
170
|
+
n.dispatchException(n.arg);
|
|
171
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
172
|
+
o = f;
|
|
173
|
+
var p = tryCatch(e, r, n);
|
|
174
|
+
if ("normal" === p.type) {
|
|
175
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
176
|
+
return {
|
|
177
|
+
value: p.arg,
|
|
178
|
+
done: n.done
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function maybeInvokeDelegate(e, r) {
|
|
186
|
+
var n = r.method,
|
|
187
|
+
o = e.iterator[n];
|
|
188
|
+
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;
|
|
189
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
190
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
191
|
+
var a = i.arg;
|
|
192
|
+
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);
|
|
193
|
+
}
|
|
194
|
+
function pushTryEntry(t) {
|
|
195
|
+
var e = {
|
|
196
|
+
tryLoc: t[0]
|
|
197
|
+
};
|
|
198
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
199
|
+
}
|
|
200
|
+
function resetTryEntry(t) {
|
|
201
|
+
var e = t.completion || {};
|
|
202
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
203
|
+
}
|
|
204
|
+
function Context(t) {
|
|
205
|
+
this.tryEntries = [{
|
|
206
|
+
tryLoc: "root"
|
|
207
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
208
|
+
}
|
|
209
|
+
function values(e) {
|
|
210
|
+
if (e || "" === e) {
|
|
211
|
+
var r = e[a];
|
|
212
|
+
if (r) return r.call(e);
|
|
213
|
+
if ("function" == typeof e.next) return e;
|
|
214
|
+
if (!isNaN(e.length)) {
|
|
215
|
+
var o = -1,
|
|
216
|
+
i = function next() {
|
|
217
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
218
|
+
return next.value = t, next.done = !0, next;
|
|
219
|
+
};
|
|
220
|
+
return i.next = i;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
224
|
+
}
|
|
225
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
226
|
+
value: GeneratorFunctionPrototype,
|
|
227
|
+
configurable: !0
|
|
228
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
229
|
+
value: GeneratorFunction,
|
|
230
|
+
configurable: !0
|
|
231
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
232
|
+
var e = "function" == typeof t && t.constructor;
|
|
233
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
234
|
+
}, e.mark = function (t) {
|
|
235
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
236
|
+
}, e.awrap = function (t) {
|
|
237
|
+
return {
|
|
238
|
+
__await: t
|
|
239
|
+
};
|
|
240
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
241
|
+
return this;
|
|
242
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
243
|
+
void 0 === i && (i = Promise);
|
|
244
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
245
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
246
|
+
return t.done ? t.value : a.next();
|
|
247
|
+
});
|
|
248
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
249
|
+
return this;
|
|
250
|
+
}), define(g, "toString", function () {
|
|
251
|
+
return "[object Generator]";
|
|
252
|
+
}), e.keys = function (t) {
|
|
253
|
+
var e = Object(t),
|
|
254
|
+
r = [];
|
|
255
|
+
for (var n in e) r.push(n);
|
|
256
|
+
return r.reverse(), function next() {
|
|
257
|
+
for (; r.length;) {
|
|
258
|
+
var t = r.pop();
|
|
259
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
260
|
+
}
|
|
261
|
+
return next.done = !0, next;
|
|
262
|
+
};
|
|
263
|
+
}, e.values = values, Context.prototype = {
|
|
264
|
+
constructor: Context,
|
|
265
|
+
reset: function (e) {
|
|
266
|
+
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);
|
|
267
|
+
},
|
|
268
|
+
stop: function () {
|
|
269
|
+
this.done = !0;
|
|
270
|
+
var t = this.tryEntries[0].completion;
|
|
271
|
+
if ("throw" === t.type) throw t.arg;
|
|
272
|
+
return this.rval;
|
|
273
|
+
},
|
|
274
|
+
dispatchException: function (e) {
|
|
275
|
+
if (this.done) throw e;
|
|
276
|
+
var r = this;
|
|
277
|
+
function handle(n, o) {
|
|
278
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
279
|
+
}
|
|
280
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
281
|
+
var i = this.tryEntries[o],
|
|
282
|
+
a = i.completion;
|
|
283
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
284
|
+
if (i.tryLoc <= this.prev) {
|
|
285
|
+
var c = n.call(i, "catchLoc"),
|
|
286
|
+
u = n.call(i, "finallyLoc");
|
|
287
|
+
if (c && u) {
|
|
288
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
289
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
290
|
+
} else if (c) {
|
|
291
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
292
|
+
} else {
|
|
293
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
294
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
abrupt: function (t, e) {
|
|
300
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
301
|
+
var o = this.tryEntries[r];
|
|
302
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
303
|
+
var i = o;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
308
|
+
var a = i ? i.completion : {};
|
|
309
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
310
|
+
},
|
|
311
|
+
complete: function (t, e) {
|
|
312
|
+
if ("throw" === t.type) throw t.arg;
|
|
313
|
+
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;
|
|
314
|
+
},
|
|
315
|
+
finish: function (t) {
|
|
316
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
317
|
+
var r = this.tryEntries[e];
|
|
318
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
catch: function (t) {
|
|
322
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
323
|
+
var r = this.tryEntries[e];
|
|
324
|
+
if (r.tryLoc === t) {
|
|
325
|
+
var n = r.completion;
|
|
326
|
+
if ("throw" === n.type) {
|
|
327
|
+
var o = n.arg;
|
|
328
|
+
resetTryEntry(r);
|
|
329
|
+
}
|
|
330
|
+
return o;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
throw Error("illegal catch attempt");
|
|
334
|
+
},
|
|
335
|
+
delegateYield: function (e, r, n) {
|
|
336
|
+
return this.delegate = {
|
|
337
|
+
iterator: values(e),
|
|
338
|
+
resultName: r,
|
|
339
|
+
nextLoc: n
|
|
340
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
341
|
+
}
|
|
342
|
+
}, e;
|
|
343
|
+
}
|
|
344
|
+
function _setPrototypeOf(t, e) {
|
|
345
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
346
|
+
return t.__proto__ = e, t;
|
|
347
|
+
}, _setPrototypeOf(t, e);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
var CloudflareDeployer = /*#__PURE__*/function (_MastraDeployer) {
|
|
351
|
+
function CloudflareDeployer(_ref) {
|
|
352
|
+
var _this;
|
|
353
|
+
var scope = _ref.scope,
|
|
354
|
+
env = _ref.env,
|
|
355
|
+
projectName = _ref.projectName,
|
|
356
|
+
routes = _ref.routes,
|
|
357
|
+
workerNamespace = _ref.workerNamespace;
|
|
358
|
+
_this = _MastraDeployer.call(this, {
|
|
359
|
+
scope: scope,
|
|
360
|
+
env: env,
|
|
361
|
+
projectName: projectName
|
|
362
|
+
}) || this;
|
|
363
|
+
_this.routes = [];
|
|
364
|
+
_this.workerNamespace = void 0;
|
|
365
|
+
_this.routes = routes;
|
|
366
|
+
_this.workerNamespace = workerNamespace;
|
|
367
|
+
return _this;
|
|
368
|
+
}
|
|
369
|
+
_inheritsLoose(CloudflareDeployer, _MastraDeployer);
|
|
370
|
+
var _proto = CloudflareDeployer.prototype;
|
|
371
|
+
_proto.writeFiles = function writeFiles(_ref2) {
|
|
372
|
+
var dir = _ref2.dir;
|
|
373
|
+
this.loadEnvVars();
|
|
374
|
+
this.writeIndex({
|
|
375
|
+
dir: dir
|
|
376
|
+
});
|
|
377
|
+
var cfWorkerName = this.projectName || 'mastra';
|
|
378
|
+
var wranglerConfig = {
|
|
379
|
+
name: cfWorkerName,
|
|
380
|
+
main: 'index.mjs',
|
|
381
|
+
compatibility_date: '2024-12-02',
|
|
382
|
+
compatibility_flags: ['nodejs_compat'],
|
|
383
|
+
build: {
|
|
384
|
+
command: 'npm install'
|
|
385
|
+
},
|
|
386
|
+
observability: {
|
|
387
|
+
logs: {
|
|
388
|
+
enabled: true
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
vars: this.env
|
|
392
|
+
};
|
|
393
|
+
if (!this.workerNamespace && this.routes) {
|
|
394
|
+
wranglerConfig.routes = this.routes;
|
|
395
|
+
}
|
|
396
|
+
writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));
|
|
397
|
+
};
|
|
398
|
+
_proto.writeIndex = function writeIndex(_ref3) {
|
|
399
|
+
var dir = _ref3.dir;
|
|
400
|
+
writeFileSync(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 ");
|
|
401
|
+
};
|
|
402
|
+
_proto.deploy = /*#__PURE__*/function () {
|
|
403
|
+
var _deploy = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
|
|
404
|
+
var dir, token, cmd;
|
|
405
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
406
|
+
while (1) switch (_context.prev = _context.next) {
|
|
407
|
+
case 0:
|
|
408
|
+
dir = _ref4.dir, token = _ref4.token;
|
|
409
|
+
cmd = this.workerNamespace ? "npm exec -- wrangler deploy --dispatch-namespace " + this.workerNamespace : 'npm exec -- wrangler deploy';
|
|
410
|
+
child_process.execSync(cmd, {
|
|
411
|
+
cwd: dir,
|
|
412
|
+
stdio: 'inherit',
|
|
413
|
+
env: _extends({
|
|
414
|
+
CLOUDFLARE_API_TOKEN: token,
|
|
415
|
+
CLOUDFLARE_ACCOUNT_ID: this.scope
|
|
416
|
+
}, this.env, {
|
|
417
|
+
PATH: process.env.PATH
|
|
418
|
+
})
|
|
419
|
+
});
|
|
420
|
+
case 3:
|
|
421
|
+
case "end":
|
|
422
|
+
return _context.stop();
|
|
423
|
+
}
|
|
424
|
+
}, _callee, this);
|
|
425
|
+
}));
|
|
426
|
+
function deploy(_x) {
|
|
427
|
+
return _deploy.apply(this, arguments);
|
|
428
|
+
}
|
|
429
|
+
return deploy;
|
|
430
|
+
}();
|
|
431
|
+
return CloudflareDeployer;
|
|
432
|
+
}(MastraDeployer);
|
|
433
|
+
|
|
434
|
+
export { CloudflareDeployer };
|
|
435
|
+
//# sourceMappingURL=deployer-cloudflare.esm.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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|
|
1
|
+
import { MastraDeployer } from '@mastra/core';
|
|
3
2
|
interface CFRoute {
|
|
4
3
|
pattern: string;
|
|
5
4
|
zone_name: string;
|
|
6
5
|
custom_domain?: boolean;
|
|
7
6
|
}
|
|
8
|
-
declare class CloudflareDeployer extends
|
|
9
|
-
private cloudflare;
|
|
7
|
+
export declare class CloudflareDeployer extends MastraDeployer {
|
|
10
8
|
routes?: CFRoute[];
|
|
11
9
|
workerNamespace?: string;
|
|
12
|
-
scope:
|
|
13
|
-
env?: Record<string, any>;
|
|
14
|
-
projectName?: string;
|
|
15
|
-
constructor({ scope, env, projectName, routes, workerNamespace, auth, }: {
|
|
10
|
+
constructor({ scope, env, projectName, routes, workerNamespace, }: {
|
|
16
11
|
env?: Record<string, any>;
|
|
17
12
|
scope: string;
|
|
18
|
-
projectName
|
|
13
|
+
projectName: string;
|
|
19
14
|
routes?: CFRoute[];
|
|
20
15
|
workerNamespace?: string;
|
|
21
|
-
auth: {
|
|
22
|
-
apiToken: string;
|
|
23
|
-
apiEmail?: string;
|
|
24
|
-
};
|
|
25
16
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
namespace: string;
|
|
36
|
-
tags: string[];
|
|
17
|
+
writeFiles({ dir }: {
|
|
18
|
+
dir: string;
|
|
19
|
+
}): void;
|
|
20
|
+
writeIndex({ dir }: {
|
|
21
|
+
dir: string;
|
|
22
|
+
}): void;
|
|
23
|
+
deploy({ dir, token }: {
|
|
24
|
+
dir: string;
|
|
25
|
+
token: string;
|
|
37
26
|
}): Promise<void>;
|
|
38
27
|
}
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;gBACb,EACV,KAAK,EACL,GAAG,EACH,WAAW,EACX,MAAM,EACN,eAAe,GAChB,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;QACnB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B;IAOD,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IA8B1C,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiBpC,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAe5E"}
|