@mastra/deployer-vercel 0.0.1-alpha.0

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 ADDED
@@ -0,0 +1,9 @@
1
+ # @mastra/deployer-vercel
2
+
3
+ ## 0.0.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4139b43]
8
+ - Updated dependencies [a5604c4]
9
+ - @mastra/deployer@0.0.1-alpha.0
package/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ **Acceptance**
4
+ By using the software, you agree to all of the terms and conditions below.
5
+
6
+ **Copyright License**
7
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
+
9
+ **Limitations**
10
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
+
12
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
+
14
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
+
16
+ **Patents**
17
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
+
19
+ **Notices**
20
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
+
22
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
+
24
+ **No Other Rights**
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ **Termination**
28
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
+
30
+ **No Liability**
31
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
+
33
+ **Definitions**
34
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
+
36
+ _you_ refers to the individual or entity agreeing to these terms.
37
+
38
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
+
40
+ _your licenses_ are all the licenses granted to you for the software under these terms.
41
+
42
+ _use_ means anything you do with the software requiring one of your licenses.
43
+
44
+ _trademark_ means trademarks, service marks, and similar rights.
@@ -0,0 +1,559 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@mastra/core');
6
+ var execa = require('execa');
7
+ var fs = require('fs');
8
+ var path = require('path');
9
+
10
+ function _arrayLikeToArray(r, a) {
11
+ (null == a || a > r.length) && (a = r.length);
12
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
13
+ return n;
14
+ }
15
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
16
+ try {
17
+ var i = n[a](c),
18
+ u = i.value;
19
+ } catch (n) {
20
+ return void e(n);
21
+ }
22
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
23
+ }
24
+ function _asyncToGenerator(n) {
25
+ return function () {
26
+ var t = this,
27
+ e = arguments;
28
+ return new Promise(function (r, o) {
29
+ var a = n.apply(t, e);
30
+ function _next(n) {
31
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
32
+ }
33
+ function _throw(n) {
34
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
35
+ }
36
+ _next(void 0);
37
+ });
38
+ };
39
+ }
40
+ function _createForOfIteratorHelperLoose(r, e) {
41
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
42
+ if (t) return (t = t.call(r)).next.bind(t);
43
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
44
+ t && (r = t);
45
+ var o = 0;
46
+ return function () {
47
+ return o >= r.length ? {
48
+ done: !0
49
+ } : {
50
+ done: !1,
51
+ value: r[o++]
52
+ };
53
+ };
54
+ }
55
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
56
+ }
57
+ function _inheritsLoose(t, o) {
58
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
59
+ }
60
+ function _regeneratorRuntime() {
61
+ _regeneratorRuntime = function () {
62
+ return e;
63
+ };
64
+ var t,
65
+ e = {},
66
+ r = Object.prototype,
67
+ n = r.hasOwnProperty,
68
+ o = Object.defineProperty || function (t, e, r) {
69
+ t[e] = r.value;
70
+ },
71
+ i = "function" == typeof Symbol ? Symbol : {},
72
+ a = i.iterator || "@@iterator",
73
+ c = i.asyncIterator || "@@asyncIterator",
74
+ u = i.toStringTag || "@@toStringTag";
75
+ function define(t, e, r) {
76
+ return Object.defineProperty(t, e, {
77
+ value: r,
78
+ enumerable: !0,
79
+ configurable: !0,
80
+ writable: !0
81
+ }), t[e];
82
+ }
83
+ try {
84
+ define({}, "");
85
+ } catch (t) {
86
+ define = function (t, e, r) {
87
+ return t[e] = r;
88
+ };
89
+ }
90
+ function wrap(t, e, r, n) {
91
+ var i = e && e.prototype instanceof Generator ? e : Generator,
92
+ a = Object.create(i.prototype),
93
+ c = new Context(n || []);
94
+ return o(a, "_invoke", {
95
+ value: makeInvokeMethod(t, r, c)
96
+ }), a;
97
+ }
98
+ function tryCatch(t, e, r) {
99
+ try {
100
+ return {
101
+ type: "normal",
102
+ arg: t.call(e, r)
103
+ };
104
+ } catch (t) {
105
+ return {
106
+ type: "throw",
107
+ arg: t
108
+ };
109
+ }
110
+ }
111
+ e.wrap = wrap;
112
+ var h = "suspendedStart",
113
+ l = "suspendedYield",
114
+ f = "executing",
115
+ s = "completed",
116
+ y = {};
117
+ function Generator() {}
118
+ function GeneratorFunction() {}
119
+ function GeneratorFunctionPrototype() {}
120
+ var p = {};
121
+ define(p, a, function () {
122
+ return this;
123
+ });
124
+ var d = Object.getPrototypeOf,
125
+ v = d && d(d(values([])));
126
+ v && v !== r && n.call(v, a) && (p = v);
127
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
128
+ function defineIteratorMethods(t) {
129
+ ["next", "throw", "return"].forEach(function (e) {
130
+ define(t, e, function (t) {
131
+ return this._invoke(e, t);
132
+ });
133
+ });
134
+ }
135
+ function AsyncIterator(t, e) {
136
+ function invoke(r, o, i, a) {
137
+ var c = tryCatch(t[r], t, o);
138
+ if ("throw" !== c.type) {
139
+ var u = c.arg,
140
+ h = u.value;
141
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
142
+ invoke("next", t, i, a);
143
+ }, function (t) {
144
+ invoke("throw", t, i, a);
145
+ }) : e.resolve(h).then(function (t) {
146
+ u.value = t, i(u);
147
+ }, function (t) {
148
+ return invoke("throw", t, i, a);
149
+ });
150
+ }
151
+ a(c.arg);
152
+ }
153
+ var r;
154
+ o(this, "_invoke", {
155
+ value: function (t, n) {
156
+ function callInvokeWithMethodAndArg() {
157
+ return new e(function (e, r) {
158
+ invoke(t, n, e, r);
159
+ });
160
+ }
161
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
162
+ }
163
+ });
164
+ }
165
+ function makeInvokeMethod(e, r, n) {
166
+ var o = h;
167
+ return function (i, a) {
168
+ if (o === f) throw Error("Generator is already running");
169
+ if (o === s) {
170
+ if ("throw" === i) throw a;
171
+ return {
172
+ value: t,
173
+ done: !0
174
+ };
175
+ }
176
+ for (n.method = i, n.arg = a;;) {
177
+ var c = n.delegate;
178
+ if (c) {
179
+ var u = maybeInvokeDelegate(c, n);
180
+ if (u) {
181
+ if (u === y) continue;
182
+ return u;
183
+ }
184
+ }
185
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
186
+ if (o === h) throw o = s, n.arg;
187
+ n.dispatchException(n.arg);
188
+ } else "return" === n.method && n.abrupt("return", n.arg);
189
+ o = f;
190
+ var p = tryCatch(e, r, n);
191
+ if ("normal" === p.type) {
192
+ if (o = n.done ? s : l, p.arg === y) continue;
193
+ return {
194
+ value: p.arg,
195
+ done: n.done
196
+ };
197
+ }
198
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
199
+ }
200
+ };
201
+ }
202
+ function maybeInvokeDelegate(e, r) {
203
+ var n = r.method,
204
+ o = e.iterator[n];
205
+ 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;
206
+ var i = tryCatch(o, e.iterator, r.arg);
207
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
208
+ var a = i.arg;
209
+ 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);
210
+ }
211
+ function pushTryEntry(t) {
212
+ var e = {
213
+ tryLoc: t[0]
214
+ };
215
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
216
+ }
217
+ function resetTryEntry(t) {
218
+ var e = t.completion || {};
219
+ e.type = "normal", delete e.arg, t.completion = e;
220
+ }
221
+ function Context(t) {
222
+ this.tryEntries = [{
223
+ tryLoc: "root"
224
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
225
+ }
226
+ function values(e) {
227
+ if (e || "" === e) {
228
+ var r = e[a];
229
+ if (r) return r.call(e);
230
+ if ("function" == typeof e.next) return e;
231
+ if (!isNaN(e.length)) {
232
+ var o = -1,
233
+ i = function next() {
234
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
235
+ return next.value = t, next.done = !0, next;
236
+ };
237
+ return i.next = i;
238
+ }
239
+ }
240
+ throw new TypeError(typeof e + " is not iterable");
241
+ }
242
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
243
+ value: GeneratorFunctionPrototype,
244
+ configurable: !0
245
+ }), o(GeneratorFunctionPrototype, "constructor", {
246
+ value: GeneratorFunction,
247
+ configurable: !0
248
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
249
+ var e = "function" == typeof t && t.constructor;
250
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
251
+ }, e.mark = function (t) {
252
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
253
+ }, e.awrap = function (t) {
254
+ return {
255
+ __await: t
256
+ };
257
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
258
+ return this;
259
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
260
+ void 0 === i && (i = Promise);
261
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
262
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
263
+ return t.done ? t.value : a.next();
264
+ });
265
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
266
+ return this;
267
+ }), define(g, "toString", function () {
268
+ return "[object Generator]";
269
+ }), e.keys = function (t) {
270
+ var e = Object(t),
271
+ r = [];
272
+ for (var n in e) r.push(n);
273
+ return r.reverse(), function next() {
274
+ for (; r.length;) {
275
+ var t = r.pop();
276
+ if (t in e) return next.value = t, next.done = !1, next;
277
+ }
278
+ return next.done = !0, next;
279
+ };
280
+ }, e.values = values, Context.prototype = {
281
+ constructor: Context,
282
+ reset: function (e) {
283
+ 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);
284
+ },
285
+ stop: function () {
286
+ this.done = !0;
287
+ var t = this.tryEntries[0].completion;
288
+ if ("throw" === t.type) throw t.arg;
289
+ return this.rval;
290
+ },
291
+ dispatchException: function (e) {
292
+ if (this.done) throw e;
293
+ var r = this;
294
+ function handle(n, o) {
295
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
296
+ }
297
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
298
+ var i = this.tryEntries[o],
299
+ a = i.completion;
300
+ if ("root" === i.tryLoc) return handle("end");
301
+ if (i.tryLoc <= this.prev) {
302
+ var c = n.call(i, "catchLoc"),
303
+ u = n.call(i, "finallyLoc");
304
+ if (c && u) {
305
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
306
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
307
+ } else if (c) {
308
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
309
+ } else {
310
+ if (!u) throw Error("try statement without catch or finally");
311
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
312
+ }
313
+ }
314
+ }
315
+ },
316
+ abrupt: function (t, e) {
317
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
318
+ var o = this.tryEntries[r];
319
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
320
+ var i = o;
321
+ break;
322
+ }
323
+ }
324
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
325
+ var a = i ? i.completion : {};
326
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
327
+ },
328
+ complete: function (t, e) {
329
+ if ("throw" === t.type) throw t.arg;
330
+ 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;
331
+ },
332
+ finish: function (t) {
333
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
334
+ var r = this.tryEntries[e];
335
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
336
+ }
337
+ },
338
+ catch: function (t) {
339
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
340
+ var r = this.tryEntries[e];
341
+ if (r.tryLoc === t) {
342
+ var n = r.completion;
343
+ if ("throw" === n.type) {
344
+ var o = n.arg;
345
+ resetTryEntry(r);
346
+ }
347
+ return o;
348
+ }
349
+ }
350
+ throw Error("illegal catch attempt");
351
+ },
352
+ delegateYield: function (e, r, n) {
353
+ return this.delegate = {
354
+ iterator: values(e),
355
+ resultName: r,
356
+ nextLoc: n
357
+ }, "next" === this.method && (this.arg = t), y;
358
+ }
359
+ }, e;
360
+ }
361
+ function _setPrototypeOf(t, e) {
362
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
363
+ return t.__proto__ = e, t;
364
+ }, _setPrototypeOf(t, e);
365
+ }
366
+ function _unsupportedIterableToArray(r, a) {
367
+ if (r) {
368
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
369
+ var t = {}.toString.call(r).slice(8, -1);
370
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
371
+ }
372
+ }
373
+
374
+ var VercelDeployer = /*#__PURE__*/function (_MastraDeployer) {
375
+ function VercelDeployer(_ref) {
376
+ var scope = _ref.scope,
377
+ env = _ref.env,
378
+ projectName = _ref.projectName;
379
+ return _MastraDeployer.call(this, {
380
+ scope: scope,
381
+ env: env,
382
+ projectName: projectName
383
+ }) || this;
384
+ }
385
+ _inheritsLoose(VercelDeployer, _MastraDeployer);
386
+ var _proto = VercelDeployer.prototype;
387
+ _proto.writeFiles = function writeFiles(_ref2) {
388
+ var dir = _ref2.dir;
389
+ this.writeIndex({
390
+ dir: dir
391
+ });
392
+ fs.writeFileSync(path.join(dir, 'vercel.json'), JSON.stringify({
393
+ version: 2,
394
+ builds: [{
395
+ src: 'index.mjs',
396
+ use: '@vercel/node',
397
+ config: {
398
+ includeFiles: ['**']
399
+ }
400
+ }],
401
+ routes: [{
402
+ src: '/(.*)',
403
+ dest: 'index.mjs'
404
+ }]
405
+ }, null, 2));
406
+ };
407
+ _proto.getProjectId = function getProjectId(_ref3) {
408
+ var dir = _ref3.dir;
409
+ var projectJsonPath = path.join(dir, '.vercel', 'project.json');
410
+ try {
411
+ var projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf-8'));
412
+ return projectJson.projectId;
413
+ } catch (error) {
414
+ throw new Error('Could not find project ID. Make sure the project has been deployed first.');
415
+ }
416
+ };
417
+ _proto.syncEnv = /*#__PURE__*/function () {
418
+ var _syncEnv = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref4) {
419
+ var scope, dir, token, envFiles, envVars, _iterator, _step, file, vars, vercelEnvVars, projectId, response, error;
420
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
421
+ while (1) switch (_context.prev = _context.next) {
422
+ case 0:
423
+ scope = _ref4.scope, dir = _ref4.dir, token = _ref4.token;
424
+ envFiles = this.getEnvFiles();
425
+ envVars = [];
426
+ for (_iterator = _createForOfIteratorHelperLoose(envFiles); !(_step = _iterator()).done;) {
427
+ file = _step.value;
428
+ vars = this.parseEnvFile(file);
429
+ envVars.push.apply(envVars, vars);
430
+ }
431
+ console.log('Syncing environment variables...');
432
+ // Transform env vars into the format expected by Vercel API
433
+ vercelEnvVars = envVars.map(function (envVar) {
434
+ var _envVar$split = envVar.split('='),
435
+ key = _envVar$split[0],
436
+ value = _envVar$split[1];
437
+ if (!key || !value) {
438
+ throw new Error("Invalid environment variable format: " + envVar);
439
+ }
440
+ return {
441
+ key: key,
442
+ value: value,
443
+ target: ['production', 'preview', 'development'],
444
+ type: 'plain'
445
+ };
446
+ });
447
+ _context.prev = 6;
448
+ projectId = this.getProjectId({
449
+ dir: dir
450
+ });
451
+ _context.next = 10;
452
+ return fetch("https://api.vercel.com/v10/projects/" + projectId + "/env?teamId=" + scope + "&upsert=true", {
453
+ method: 'POST',
454
+ headers: {
455
+ Authorization: "Bearer " + token,
456
+ 'Content-Type': 'application/json'
457
+ },
458
+ body: JSON.stringify(vercelEnvVars)
459
+ });
460
+ case 10:
461
+ response = _context.sent;
462
+ if (response.ok) {
463
+ _context.next = 16;
464
+ break;
465
+ }
466
+ _context.next = 14;
467
+ return response.json();
468
+ case 14:
469
+ error = _context.sent;
470
+ throw new Error("Failed to sync environment variables: " + error.message);
471
+ case 16:
472
+ console.log('✓ Successfully synced environment variables');
473
+ _context.next = 23;
474
+ break;
475
+ case 19:
476
+ _context.prev = 19;
477
+ _context.t0 = _context["catch"](6);
478
+ if (_context.t0 instanceof Error) {
479
+ console.error('Failed to sync environment variables:', _context.t0.message);
480
+ } else {
481
+ console.error('Failed to sync environment variables:', _context.t0);
482
+ }
483
+ throw _context.t0;
484
+ case 23:
485
+ case "end":
486
+ return _context.stop();
487
+ }
488
+ }, _callee, this, [[6, 19]]);
489
+ }));
490
+ function syncEnv(_x) {
491
+ return _syncEnv.apply(this, arguments);
492
+ }
493
+ return syncEnv;
494
+ }();
495
+ _proto.deploy = /*#__PURE__*/function () {
496
+ var _deploy = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
497
+ var dir, token, envFiles, envVars, _iterator2, _step2, file, vars, commandArgs, _i, _envVars, envVar, p2;
498
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
499
+ while (1) switch (_context2.prev = _context2.next) {
500
+ case 0:
501
+ dir = _ref5.dir, token = _ref5.token;
502
+ // Get env vars for initial deployment
503
+ envFiles = this.getEnvFiles();
504
+ envVars = [];
505
+ for (_iterator2 = _createForOfIteratorHelperLoose(envFiles); !(_step2 = _iterator2()).done;) {
506
+ file = _step2.value;
507
+ vars = this.parseEnvFile(file);
508
+ envVars.push.apply(envVars, vars);
509
+ }
510
+ // Create the command array with base arguments
511
+ commandArgs = ['--scope', this.scope, '--cwd', dir, 'deploy', '--token', token, '--yes'].concat(this.projectName ? ['--name', this.projectName] : []); // Add env vars to initial deployment
512
+ for (_i = 0, _envVars = envVars; _i < _envVars.length; _i++) {
513
+ envVar = _envVars[_i];
514
+ commandArgs.push('--env', envVar);
515
+ }
516
+ // Run the Vercel deploy command
517
+ // console.log('Running command:', 'vercel', commandArgs.join(' '));
518
+ p2 = execa.execa('vercel', commandArgs);
519
+ p2.stdout.pipe(process.stdout);
520
+ p2.stderr.pipe(process.stderr);
521
+ console.log('Deployment started on Vercel. You can wait for it to finish or exit this command.');
522
+ _context2.next = 12;
523
+ return p2;
524
+ case 12:
525
+ if (!(envVars.length > 0)) {
526
+ _context2.next = 17;
527
+ break;
528
+ }
529
+ _context2.next = 15;
530
+ return this.syncEnv({
531
+ scope: this.scope,
532
+ dir: dir,
533
+ token: token
534
+ });
535
+ case 15:
536
+ _context2.next = 18;
537
+ break;
538
+ case 17:
539
+ console.log('\nAdd your ENV vars to .env or your vercel dashboard.\n');
540
+ case 18:
541
+ case "end":
542
+ return _context2.stop();
543
+ }
544
+ }, _callee2, this);
545
+ }));
546
+ function deploy(_x2) {
547
+ return _deploy.apply(this, arguments);
548
+ }
549
+ return deploy;
550
+ }();
551
+ _proto.writeIndex = function writeIndex(_ref6) {
552
+ var dir = _ref6.dir;
553
+ fs.writeFileSync(path.join(dir, 'index.mjs'), "\n import { handle } from 'hono/vercel'\n import { app } from './hono.mjs';\n export const GET = handle(app);\n export const POST = handle(app);\n ");
554
+ };
555
+ return VercelDeployer;
556
+ }(core.MastraDeployer);
557
+
558
+ exports.VercelDeployer = VercelDeployer;
559
+ //# sourceMappingURL=deployer-vercel.cjs.development.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployer-vercel.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import { MastraDeployer } from '@mastra/core';\nimport { execa } from 'execa';\nimport { readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\ninterface EnvVar {\n key: string;\n value: string;\n target: ('production' | 'preview' | 'development')[];\n type: 'plain' | 'secret';\n}\n\ninterface VercelError {\n message: string;\n code: string;\n}\n\nexport class VercelDeployer extends MastraDeployer {\n constructor({ scope, env, projectName }: { env?: Record<string, any>; scope: string; projectName: string }) {\n super({ scope, env, projectName });\n }\n writeFiles({ dir }: { dir: string }): void {\n this.writeIndex({ dir });\n\n writeFileSync(\n join(dir, 'vercel.json'),\n JSON.stringify(\n {\n version: 2,\n builds: [\n {\n src: 'index.mjs',\n use: '@vercel/node',\n config: { includeFiles: ['**'] },\n },\n ],\n routes: [\n {\n src: '/(.*)',\n dest: 'index.mjs',\n },\n ],\n },\n null,\n 2,\n ),\n );\n }\n\n private getProjectId({ dir }: { dir: string }): string {\n const projectJsonPath = join(dir, '.vercel', 'project.json');\n try {\n const projectJson = JSON.parse(readFileSync(projectJsonPath, 'utf-8'));\n return projectJson.projectId;\n } catch (error) {\n throw new Error('Could not find project ID. Make sure the project has been deployed first.');\n }\n }\n\n async syncEnv({ scope, dir, token }: { token: string; dir: string; scope: string }) {\n const envFiles = this.getEnvFiles();\n const envVars: string[] = [];\n\n for (const file of envFiles) {\n const vars = this.parseEnvFile(file);\n envVars.push(...vars);\n }\n\n console.log('Syncing environment variables...');\n\n // Transform env vars into the format expected by Vercel API\n const vercelEnvVars: EnvVar[] = envVars.map(envVar => {\n const [key, value] = envVar.split('=');\n if (!key || !value) {\n throw new Error(`Invalid environment variable format: ${envVar}`);\n }\n return {\n key,\n value,\n target: ['production', 'preview', 'development'],\n type: 'plain',\n };\n });\n\n try {\n const projectId = this.getProjectId({ dir });\n\n const response = await fetch(`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${scope}&upsert=true`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(vercelEnvVars),\n });\n\n if (!response.ok) {\n const error = (await response.json()) as VercelError;\n throw new Error(`Failed to sync environment variables: ${error.message}`);\n }\n\n console.log('✓ Successfully synced environment variables');\n } catch (error) {\n if (error instanceof Error) {\n console.error('Failed to sync environment variables:', error.message);\n } else {\n console.error('Failed to sync environment variables:', error);\n }\n throw error;\n }\n }\n\n async deploy({ dir, token }: { dir: string; token: string }): Promise<void> {\n // Get env vars for initial deployment\n const envFiles = this.getEnvFiles();\n const envVars: string[] = [];\n\n for (const file of envFiles) {\n const vars = this.parseEnvFile(file);\n envVars.push(...vars);\n }\n\n // Create the command array with base arguments\n const commandArgs = [\n '--scope',\n this.scope as string,\n '--cwd',\n dir,\n 'deploy',\n '--token',\n token,\n '--yes',\n ...(this.projectName ? ['--name', this.projectName] : []),\n ];\n\n // Add env vars to initial deployment\n for (const envVar of envVars) {\n commandArgs.push('--env', envVar);\n }\n\n // Run the Vercel deploy command\n // console.log('Running command:', 'vercel', commandArgs.join(' '));\n const p2 = execa('vercel', commandArgs);\n\n p2.stdout.pipe(process.stdout);\n p2.stderr.pipe(process.stderr);\n\n console.log('Deployment started on Vercel. You can wait for it to finish or exit this command.');\n await p2;\n\n if (envVars.length > 0) {\n // Sync environment variables for future deployments\n await this.syncEnv({ scope: this.scope, dir, token });\n } else {\n console.log('\\nAdd your ENV vars to .env or your vercel dashboard.\\n');\n }\n }\n\n writeIndex({ dir }: { dir: string }): void {\n writeFileSync(\n join(dir, 'index.mjs'),\n `\n import { handle } from 'hono/vercel'\n import { app } from './hono.mjs';\n export const GET = handle(app);\n export const POST = handle(app);\n `,\n );\n }\n}\n"],"names":["VercelDeployer","_MastraDeployer","_ref","scope","env","projectName","call","_inheritsLoose","_proto","prototype","writeFiles","_ref2","dir","writeIndex","writeFileSync","join","JSON","stringify","version","builds","src","use","config","includeFiles","routes","dest","getProjectId","_ref3","projectJsonPath","projectJson","parse","readFileSync","projectId","error","Error","syncEnv","_syncEnv","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref4","token","envFiles","envVars","_iterator","_step","file","vars","vercelEnvVars","response","wrap","_callee$","_context","prev","next","getEnvFiles","_createForOfIteratorHelperLoose","done","value","parseEnvFile","push","apply","console","log","map","envVar","_envVar$split","split","key","target","type","fetch","method","headers","Authorization","body","sent","ok","json","message","t0","stop","_x","arguments","deploy","_deploy","_callee2","_ref5","_iterator2","_step2","commandArgs","_i","_envVars","p2","_callee2$","_context2","concat","length","execa","stdout","pipe","process","stderr","_x2","_ref6","MastraDeployer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBaA,IAAAA,cAA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,GAAG,EAAE,WAAW,CAAC,8NAMf,CACR,CAAA;GACF,CAAA;AAAA,EAAA,OAAAZ,cAAA,CAAA;AAAA,CAAA,CAvJiC0G,mBAAc;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@mastra/core"),e=require("execa"),r=require("fs"),n=require("path");function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function c(t){i(a,n,o,c,s,"next",t)}function s(t){i(a,n,o,c,s,"throw",t)}c(void 0)}))}}function c(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}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 P(n||[]);return o(i,"_invoke",{value:S(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",v="suspendedYield",y="executing",d="completed",m={};function g(){}function w(){}function b(){}var x={};l(x,a,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(I([])));E&&E!==r&&n.call(E,a)&&(x=E);var L=b.prototype=g.prototype=Object.create(x);function O(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,i,a,c){var s=h(t[o],t,i);if("throw"!==s.type){var u=s.arg,l=u.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){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.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 S(e,r,n){var o=p;return function(i,a){if(o===y)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 s=_(c,n);if(s){if(s===m)continue;return s}}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=y;var u=h(e,r,n);if("normal"===u.type){if(o=n.done?d:v,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=d,n.method="throw",n.arg=u.arg)}}}function _(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,_(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 F(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 N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(F,this),this.reset(!0)}function I(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}},O(k.prototype),l(k.prototype,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(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=I,P.prototype={constructor:P,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(N),!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 s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)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),N(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;N(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}exports.VercelDeployer=function(t){function o(e){return t.call(this,{scope:e.scope,env:e.env,projectName:e.projectName})||this}var i,l;l=t,(i=o).prototype=Object.create(l.prototype),i.prototype.constructor=i,u(i,l);var f=o.prototype;return f.writeFiles=function(t){var e=t.dir;this.writeIndex({dir:e}),r.writeFileSync(n.join(e,"vercel.json"),JSON.stringify({version:2,builds:[{src:"index.mjs",use:"@vercel/node",config:{includeFiles:["**"]}}],routes:[{src:"/(.*)",dest:"index.mjs"}]},null,2))},f.getProjectId=function(t){var e=n.join(t.dir,".vercel","project.json");try{return JSON.parse(r.readFileSync(e,"utf-8")).projectId}catch(t){throw new Error("Could not find project ID. Make sure the project has been deployed first.")}},f.syncEnv=function(){var t=a(s().mark((function t(e){var r,n,o,i,a,u,l,f,h,p,v;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=e.scope,n=e.dir,o=e.token,i=this.getEnvFiles(),a=[],u=c(i);!(l=u()).done;)f=this.parseEnvFile(l.value),a.push.apply(a,f);return console.log("Syncing environment variables..."),h=a.map((function(t){var e=t.split("="),r=e[0],n=e[1];if(!r||!n)throw new Error("Invalid environment variable format: "+t);return{key:r,value:n,target:["production","preview","development"],type:"plain"}})),t.prev=6,p=this.getProjectId({dir:n}),t.next=10,fetch("https://api.vercel.com/v10/projects/"+p+"/env?teamId="+r+"&upsert=true",{method:"POST",headers:{Authorization:"Bearer "+o,"Content-Type":"application/json"},body:JSON.stringify(h)});case 10:if((v=t.sent).ok){t.next=16;break}return t.next=14,v.json();case 14:throw new Error("Failed to sync environment variables: "+t.sent.message);case 16:console.log("✓ Successfully synced environment variables"),t.next=23;break;case 19:throw t.prev=19,t.t0=t.catch(6),t.t0 instanceof Error?console.error("Failed to sync environment variables:",t.t0.message):console.error("Failed to sync environment variables:",t.t0),t.t0;case 23:case"end":return t.stop()}}),t,this,[[6,19]])})));return function(e){return t.apply(this,arguments)}}(),f.deploy=function(){var t=a(s().mark((function t(r){var n,o,i,a,u,l,f,h,p,v,y;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=r.dir,o=r.token,i=this.getEnvFiles(),a=[],u=c(i);!(l=u()).done;)f=this.parseEnvFile(l.value),a.push.apply(a,f);for(h=["--scope",this.scope,"--cwd",n,"deploy","--token",o,"--yes"].concat(this.projectName?["--name",this.projectName]:[]),p=0,v=a;p<v.length;p++)h.push("--env",v[p]);return(y=e.execa("vercel",h)).stdout.pipe(process.stdout),y.stderr.pipe(process.stderr),console.log("Deployment started on Vercel. You can wait for it to finish or exit this command."),t.next=12,y;case 12:if(!(a.length>0)){t.next=17;break}return t.next=15,this.syncEnv({scope:this.scope,dir:n,token:o});case 15:t.next=18;break;case 17:console.log("\nAdd your ENV vars to .env or your vercel dashboard.\n");case 18:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),f.writeIndex=function(t){r.writeFileSync(n.join(t.dir,"index.mjs"),"\n import { handle } from 'hono/vercel'\n import { app } from './hono.mjs';\n export const GET = handle(app);\n export const POST = handle(app);\n ")},o}(t.MastraDeployer);
2
+ //# sourceMappingURL=deployer-vercel.cjs.production.min.js.map