@mastra/deployer-cloud 1.54.0-alpha.1 → 1.54.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,54 +1,52 @@
1
- 'use strict';
2
-
3
- var path = require('path');
4
- var url = require('url');
5
- var deployer = require('@mastra/deployer');
6
- var esm = require('fs-extra/esm');
7
- var os = require('os');
8
- var fs = require('fs');
9
- var error = require('@mastra/core/error');
10
- var stream = require('stream');
11
- var execa = require('execa');
12
- var logger$1 = require('@mastra/core/logger');
13
- var loggers = require('@mastra/loggers');
14
- var redis = require('redis');
15
-
16
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
-
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
21
- var n = Object.create(null);
22
- if (e) {
23
- Object.keys(e).forEach(function (k) {
24
- if (k !== 'default') {
25
- var d = Object.getOwnPropertyDescriptor(e, k);
26
- Object.defineProperty(n, k, d.get ? d : {
27
- enumerable: true,
28
- get: function () { return e[k]; }
29
- });
30
- }
31
- });
32
- }
33
- n.default = e;
34
- return Object.freeze(n);
35
- }
36
-
37
- var os__default = /*#__PURE__*/_interopDefault(os);
38
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
39
-
40
- // src/index.ts
41
-
42
- // src/utils/auth.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let path = require("path");
25
+ let url = require("url");
26
+ let _mastra_deployer = require("@mastra/deployer");
27
+ let fs_extra_esm = require("fs-extra/esm");
28
+ let os = require("os");
29
+ os = __toESM(os, 1);
30
+ let fs = require("fs");
31
+ fs = __toESM(fs, 1);
32
+ let _mastra_core_error = require("@mastra/core/error");
33
+ let stream = require("stream");
34
+ let execa = require("execa");
35
+ let _mastra_core_logger = require("@mastra/core/logger");
36
+ let _mastra_loggers = require("@mastra/loggers");
37
+ let redis = require("redis");
38
+ //#region src/utils/auth.ts
43
39
  function getAuthEntrypoint() {
44
- const tokensObject = {};
45
- if (process.env.PLAYGROUND_JWT_TOKEN) {
46
- tokensObject[process.env.PLAYGROUND_JWT_TOKEN] = { id: "business-api", role: "api" };
47
- }
48
- if (process.env.BUSINESS_JWT_TOKEN) {
49
- tokensObject[process.env.BUSINESS_JWT_TOKEN] = { id: "business-api", role: "api" };
50
- }
51
- return `
40
+ const tokensObject = {};
41
+ if (process.env.PLAYGROUND_JWT_TOKEN) tokensObject[process.env.PLAYGROUND_JWT_TOKEN] = {
42
+ id: "business-api",
43
+ role: "api"
44
+ };
45
+ if (process.env.BUSINESS_JWT_TOKEN) tokensObject[process.env.BUSINESS_JWT_TOKEN] = {
46
+ id: "business-api",
47
+ role: "api"
48
+ };
49
+ return `
52
50
  import { SimpleAuth, CompositeAuth } from '@mastra/core/server';
53
51
  import { MastraCloudAuthProvider, MastraRBACCloud } from '@mastra/auth-cloud';
54
52
 
@@ -118,219 +116,210 @@ function getAuthEntrypoint() {
118
116
  }
119
117
  `;
120
118
  }
121
- var LOCAL = process.env.LOCAL === "true";
122
- var TEAM_ID = process.env.TEAM_ID ?? "";
123
- var PROJECT_ID = process.env.PROJECT_ID ?? "";
124
- var BUILD_ID = process.env.BUILD_ID ?? "";
125
- var BUILD_URL = process.env.BUILD_URL ?? "";
126
- var LOG_REDIS_URL = process.env.LOG_REDIS_URL ?? "redis://localhost:6379";
127
- var USER_IP_ADDRESS = process.env.USER_IP_ADDRESS ?? "";
128
- var MASTRA_DIRECTORY = process.env.MASTRA_DIRECTORY ?? "src/mastra";
129
- var PROJECT_ENV_VARS = safelyParseJson(process.env.PROJECT_ENV_VARS ?? "{}");
130
- LOCAL ? os__default.default.tmpdir() + "/project" : process.env.PROJECT_ROOT ?? "/project";
119
+ //#endregion
120
+ //#region src/utils/constants.ts
121
+ const LOCAL = process.env.LOCAL === "true";
122
+ const TEAM_ID = process.env.TEAM_ID ?? "";
123
+ const PROJECT_ID = process.env.PROJECT_ID ?? "";
124
+ const BUILD_ID = process.env.BUILD_ID ?? "";
125
+ const BUILD_URL = process.env.BUILD_URL ?? "";
126
+ const LOG_REDIS_URL = process.env.LOG_REDIS_URL ?? "redis://localhost:6379";
127
+ process.env.BUSINESS_JWT_TOKEN;
128
+ process.env.PLAYGROUND_JWT_TOKEN;
129
+ const USER_IP_ADDRESS = process.env.USER_IP_ADDRESS ?? "";
130
+ const MASTRA_DIRECTORY = process.env.MASTRA_DIRECTORY ?? "src/mastra";
131
+ const PROJECT_ENV_VARS = safelyParseJson(process.env.PROJECT_ENV_VARS ?? "{}");
132
+ LOCAL ? os.default.tmpdir() + "" : process.env.PROJECT_ROOT;
131
133
  function safelyParseJson(json) {
132
- try {
133
- return JSON.parse(json);
134
- } catch {
135
- return {};
136
- }
134
+ try {
135
+ return JSON.parse(json);
136
+ } catch {
137
+ return {};
138
+ }
137
139
  }
138
- var redisClient = redis.createClient({
139
- url: LOG_REDIS_URL
140
- });
141
- var RedisTransport = class extends logger$1.LoggerTransport {
142
- _transform(chunk, _encoding, callback) {
143
- chunk = chunk.toString();
144
- const logKey = `builder:logs:${TEAM_ID}:${PROJECT_ID}:${BUILD_ID}`;
145
- const ttl = 2 * 24 * 60 * 60;
146
- const logData = typeof chunk === "string" ? chunk : JSON.stringify(chunk);
147
- process.nextTick(async () => {
148
- try {
149
- if (!redisClient.isOpen) {
150
- await redisClient.connect().catch((err) => {
151
- console.error("Redis connection error:", err);
152
- });
153
- }
154
- const pipeline = redisClient.multi();
155
- pipeline.rPush(logKey, logData);
156
- pipeline.expire(logKey, ttl);
157
- await pipeline.exec();
158
- } catch (err) {
159
- console.error("Redis logging error:", err);
160
- }
161
- });
162
- callback(null, chunk);
163
- }
164
- _write(chunk, encoding, callback) {
165
- if (typeof callback === "function") {
166
- this._transform(chunk, encoding || "utf8", callback);
167
- return true;
168
- }
169
- this._transform(chunk, encoding || "utf8", (error) => {
170
- if (error) console.error("Transform error in write:", error);
171
- });
172
- return true;
173
- }
174
- async _flush() {
175
- await new Promise((resolve2) => setTimeout(resolve2, 10));
176
- }
177
- async _destroy(err, cb) {
178
- await closeLogger();
179
- cb(err);
180
- }
181
- listLogs(_args) {
182
- return Promise.resolve({
183
- logs: [],
184
- total: 0,
185
- page: _args?.page ?? 1,
186
- perPage: _args?.perPage ?? 100,
187
- hasMore: false
188
- });
189
- }
190
- listLogsByRunId(_args) {
191
- return Promise.resolve({
192
- logs: [],
193
- total: 0,
194
- page: _args?.page ?? 1,
195
- perPage: _args?.perPage ?? 100,
196
- hasMore: false
197
- });
198
- }
140
+ //#endregion
141
+ //#region src/utils/logger.ts
142
+ const redisClient = (0, redis.createClient)({ url: LOG_REDIS_URL });
143
+ var RedisTransport = class extends _mastra_core_logger.LoggerTransport {
144
+ _transform(chunk, _encoding, callback) {
145
+ chunk = chunk.toString();
146
+ const logKey = `builder:logs:${TEAM_ID}:${PROJECT_ID}:${BUILD_ID}`;
147
+ const ttl = 2880 * 60;
148
+ const logData = typeof chunk === "string" ? chunk : JSON.stringify(chunk);
149
+ process.nextTick(async () => {
150
+ try {
151
+ if (!redisClient.isOpen) await redisClient.connect().catch((err) => {
152
+ console.error("Redis connection error:", err);
153
+ });
154
+ const pipeline = redisClient.multi();
155
+ pipeline.rPush(logKey, logData);
156
+ pipeline.expire(logKey, ttl);
157
+ await pipeline.exec();
158
+ } catch (err) {
159
+ console.error("Redis logging error:", err);
160
+ }
161
+ });
162
+ callback(null, chunk);
163
+ }
164
+ _write(chunk, encoding, callback) {
165
+ if (typeof callback === "function") {
166
+ this._transform(chunk, encoding || "utf8", callback);
167
+ return true;
168
+ }
169
+ this._transform(chunk, encoding || "utf8", (error) => {
170
+ if (error) console.error("Transform error in write:", error);
171
+ });
172
+ return true;
173
+ }
174
+ async _flush() {
175
+ await new Promise((resolve) => setTimeout(resolve, 10));
176
+ }
177
+ async _destroy(err, cb) {
178
+ await closeLogger();
179
+ cb(err);
180
+ }
181
+ listLogs(_args) {
182
+ return Promise.resolve({
183
+ logs: [],
184
+ total: 0,
185
+ page: _args?.page ?? 1,
186
+ perPage: _args?.perPage ?? 100,
187
+ hasMore: false
188
+ });
189
+ }
190
+ listLogsByRunId(_args) {
191
+ return Promise.resolve({
192
+ logs: [],
193
+ total: 0,
194
+ page: _args?.page ?? 1,
195
+ perPage: _args?.perPage ?? 100,
196
+ hasMore: false
197
+ });
198
+ }
199
199
  };
200
- var transport = new RedisTransport();
201
- var closeLogger = async () => {
202
- if (redisClient.isOpen) {
203
- setTimeout(async () => {
204
- await redisClient.quit();
205
- }, 10);
206
- }
200
+ const transport = new RedisTransport();
201
+ const closeLogger = async () => {
202
+ if (redisClient.isOpen) setTimeout(async () => {
203
+ await redisClient.quit();
204
+ }, 10);
207
205
  };
208
- var logger = new loggers.PinoLogger({
209
- level: "info",
210
- transports: {
211
- redis: transport
212
- }
206
+ const logger = new _mastra_loggers.PinoLogger({
207
+ level: "info",
208
+ transports: { redis: transport }
213
209
  });
214
-
215
- // src/utils/execa.ts
216
- var createPinoStream = () => {
217
- return new stream.Writable({
218
- write(chunk, _encoding, callback) {
219
- const line = chunk.toString().trim();
220
- if (line) {
221
- logger.info(line);
222
- }
223
- callback();
224
- }
225
- });
210
+ //#endregion
211
+ //#region src/utils/execa.ts
212
+ const createPinoStream = () => {
213
+ return new stream.Writable({ write(chunk, _encoding, callback) {
214
+ const line = chunk.toString().trim();
215
+ if (line) logger.info(line);
216
+ callback();
217
+ } });
226
218
  };
227
- async function runWithExeca({
228
- cmd,
229
- args,
230
- cwd = process.cwd(),
231
- env = PROJECT_ENV_VARS
232
- }) {
233
- const pinoStream = createPinoStream();
234
- try {
235
- const subprocess = execa.execa(cmd, args, {
236
- cwd,
237
- stdin: "ignore",
238
- env: {
239
- ...process.env,
240
- ...env
241
- }
242
- });
243
- subprocess.stdout?.pipe(pinoStream, { end: false });
244
- subprocess.stderr?.pipe(pinoStream, { end: false });
245
- const { stdout, stderr, exitCode } = await subprocess;
246
- pinoStream.end();
247
- return { stdout, stderr, success: exitCode === 0 };
248
- } catch (error) {
249
- pinoStream.end();
250
- logger.error("Process failed", { error });
251
- return { success: false, error: error instanceof Error ? error : new Error(String(error)) };
252
- }
219
+ async function runWithExeca({ cmd, args, cwd = process.cwd(), env = PROJECT_ENV_VARS }) {
220
+ const pinoStream = createPinoStream();
221
+ try {
222
+ const subprocess = (0, execa.execa)(cmd, args, {
223
+ cwd,
224
+ stdin: "ignore",
225
+ env: {
226
+ ...process.env,
227
+ ...env
228
+ }
229
+ });
230
+ subprocess.stdout?.pipe(pinoStream, { end: false });
231
+ subprocess.stderr?.pipe(pinoStream, { end: false });
232
+ const { stdout, stderr, exitCode } = await subprocess;
233
+ pinoStream.end();
234
+ return {
235
+ stdout,
236
+ stderr,
237
+ success: exitCode === 0
238
+ };
239
+ } catch (error) {
240
+ pinoStream.end();
241
+ logger.error("Process failed", { error });
242
+ return {
243
+ success: false,
244
+ error: error instanceof Error ? error : new Error(String(error))
245
+ };
246
+ }
253
247
  }
254
-
255
- // src/utils/deps.ts
256
- var MEMOIZED = /* @__PURE__ */ new Map();
248
+ //#endregion
249
+ //#region src/utils/deps.ts
250
+ const MEMOIZED = /* @__PURE__ */ new Map();
257
251
  function findLockFile(dir) {
258
- const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
259
- for (const file of lockFiles) {
260
- if (fs__namespace.existsSync(path.join(dir, file))) {
261
- return file;
262
- }
263
- }
264
- const parentDir = path.resolve(dir, "..");
265
- if (parentDir !== dir) {
266
- return findLockFile(parentDir);
267
- }
268
- return null;
252
+ for (const file of [
253
+ "pnpm-lock.yaml",
254
+ "package-lock.json",
255
+ "yarn.lock",
256
+ "bun.lock"
257
+ ]) if (fs.existsSync((0, path.join)(dir, file))) return file;
258
+ const parentDir = (0, path.resolve)(dir, "..");
259
+ if (parentDir !== dir) return findLockFile(parentDir);
260
+ return null;
269
261
  }
270
- function detectPm({ path }) {
271
- const cached = MEMOIZED.get(path);
272
- if (cached) {
273
- return cached;
274
- }
275
- const lockFile = findLockFile(path);
276
- let pm = "npm";
277
- switch (lockFile) {
278
- case "pnpm-lock.yaml":
279
- pm = "pnpm";
280
- break;
281
- case "package-lock.json":
282
- pm = "npm";
283
- break;
284
- case "yarn.lock":
285
- pm = "yarn";
286
- break;
287
- case "bun.lock":
288
- pm = "bun";
289
- break;
290
- default:
291
- pm = "npm";
292
- }
293
- MEMOIZED.set(path, pm);
294
- return pm;
262
+ function detectPm({ path: path$1 }) {
263
+ const cached = MEMOIZED.get(path$1);
264
+ if (cached) return cached;
265
+ const lockFile = findLockFile(path$1);
266
+ let pm = "npm";
267
+ switch (lockFile) {
268
+ case "pnpm-lock.yaml":
269
+ pm = "pnpm";
270
+ break;
271
+ case "package-lock.json":
272
+ pm = "npm";
273
+ break;
274
+ case "yarn.lock":
275
+ pm = "yarn";
276
+ break;
277
+ case "bun.lock":
278
+ pm = "bun";
279
+ break;
280
+ default: pm = "npm";
281
+ }
282
+ MEMOIZED.set(path$1, pm);
283
+ return pm;
295
284
  }
296
- async function installDeps({ path, pm }) {
297
- pm = pm ?? detectPm({ path });
298
- logger.info("Installing dependencies", { pm, path });
299
- const args = ["install", "--legacy-peer-deps=false", "--force"];
300
- const { success, error: error$1 } = await runWithExeca({ cmd: pm, args, cwd: path });
301
- if (!success) {
302
- throw new error.MastraError(
303
- {
304
- id: "FAIL_INSTALL_DEPS",
305
- category: "USER",
306
- domain: "DEPLOYER"
307
- },
308
- error$1
309
- );
310
- }
285
+ async function installDeps({ path: path$3, pm }) {
286
+ pm = pm ?? detectPm({ path: path$3 });
287
+ logger.info("Installing dependencies", {
288
+ pm,
289
+ path: path$3
290
+ });
291
+ const { success, error } = await runWithExeca({
292
+ cmd: pm,
293
+ args: [
294
+ "install",
295
+ "--legacy-peer-deps=false",
296
+ "--force"
297
+ ],
298
+ cwd: path$3
299
+ });
300
+ if (!success) throw new _mastra_core_error.MastraError({
301
+ id: "FAIL_INSTALL_DEPS",
302
+ category: "USER",
303
+ domain: "DEPLOYER"
304
+ }, error);
311
305
  }
306
+ //#endregion
307
+ //#region src/utils/file.ts
312
308
  function getMastraEntryFile(mastraDir) {
313
- try {
314
- const fileService = new deployer.FileService();
315
- return fileService.getFirstExistingFile([
316
- path.join(mastraDir, MASTRA_DIRECTORY, "index.ts"),
317
- path.join(mastraDir, MASTRA_DIRECTORY, "index.js")
318
- ]);
319
- } catch (error$1) {
320
- throw new error.MastraError(
321
- {
322
- id: "MASTRA_ENTRY_FILE_NOT_FOUND",
323
- category: "USER",
324
- domain: "DEPLOYER"
325
- },
326
- error$1
327
- );
328
- }
309
+ try {
310
+ return new _mastra_deployer.FileService().getFirstExistingFile([(0, path.join)(mastraDir, MASTRA_DIRECTORY, "index.ts"), (0, path.join)(mastraDir, MASTRA_DIRECTORY, "index.js")]);
311
+ } catch (error) {
312
+ throw new _mastra_core_error.MastraError({
313
+ id: "MASTRA_ENTRY_FILE_NOT_FOUND",
314
+ category: "USER",
315
+ domain: "DEPLOYER"
316
+ }, error);
317
+ }
329
318
  }
330
-
331
- // src/utils/report.ts
319
+ //#endregion
320
+ //#region src/utils/report.ts
332
321
  function successEntrypoint() {
333
- return `
322
+ return `
334
323
  if (process.env.CI !== 'true') {
335
324
  await fetch('${process.env.REPORTER_API_URL}', {
336
325
  method: 'POST',
@@ -339,12 +328,12 @@ function successEntrypoint() {
339
328
  Authorization: 'Bearer ${process.env.REPORTER_API_URL_AUTH_TOKEN}',
340
329
  },
341
330
  body: JSON.stringify(${JSON.stringify({
342
- projectId: PROJECT_ID,
343
- buildId: BUILD_ID,
344
- status: "success",
345
- url: BUILD_URL,
346
- userIpAddress: USER_IP_ADDRESS
347
- })}),
331
+ projectId: PROJECT_ID,
332
+ buildId: BUILD_ID,
333
+ status: "success",
334
+ url: BUILD_URL,
335
+ userIpAddress: USER_IP_ADDRESS
336
+ })}),
348
337
  }).catch(err => {
349
338
  console.error('Failed to report build status to monitoring service', {
350
339
  error: err,
@@ -353,69 +342,59 @@ function successEntrypoint() {
353
342
  }
354
343
  `;
355
344
  }
356
-
357
- // src/index.ts
358
- var CloudDeployer = class extends deployer.Deployer {
359
- studio;
360
- constructor({ studio } = {}) {
361
- super({ name: "cloud" });
362
- this.studio = studio ?? false;
363
- }
364
- async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
365
- const bundlerOptions = await super.getUserBundlerOptions(mastraEntryFile, outputDirectory);
366
- return {
367
- ...bundlerOptions,
368
- externals: true
369
- };
370
- }
371
- async deploy(_outputDirectory) {
372
- }
373
- async prepare(outputDirectory) {
374
- await super.prepare(outputDirectory);
375
- if (this.studio) {
376
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
377
- const __dirname = path.dirname(__filename);
378
- const studioServePath = path.join(outputDirectory, this.outputDir, "studio");
379
- await esm.copy(path.join(path.dirname(__dirname), path.join("dist", "studio")), studioServePath, {
380
- overwrite: true
381
- });
382
- }
383
- }
384
- async writePackageJson(outputDirectory, dependencies) {
385
- const versions = await esm.readJSON(path.join(path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))), "../versions.json"));
386
- for (const [pkgName, version] of Object.entries(versions || {})) {
387
- dependencies.set(pkgName, version);
388
- }
389
- return super.writePackageJson(outputDirectory, dependencies);
390
- }
391
- async lint() {
392
- }
393
- async installDependencies(outputDirectory, _rootDir = process.cwd()) {
394
- await installDeps({ path: path.join(outputDirectory, "output"), pm: "npm" });
395
- }
396
- async bundle(mastraDir, outputDirectory) {
397
- const currentCwd = process.cwd();
398
- process.chdir(mastraDir);
399
- const mastraEntryFile = getMastraEntryFile(mastraDir);
400
- const mastraAppDir = path.join(mastraDir, MASTRA_DIRECTORY);
401
- const discoveredTools = this.getAllToolPaths(mastraAppDir);
402
- await this.prepare(outputDirectory);
403
- await this._bundle(
404
- this.getEntry(),
405
- mastraEntryFile,
406
- {
407
- outputDirectory,
408
- projectRoot: mastraDir
409
- },
410
- discoveredTools
411
- );
412
- process.chdir(currentCwd);
413
- }
414
- getAuthEntrypoint() {
415
- return getAuthEntrypoint();
416
- }
417
- getEntry() {
418
- return `
345
+ //#endregion
346
+ //#region src/index.ts
347
+ var CloudDeployer = class extends _mastra_deployer.Deployer {
348
+ studio;
349
+ constructor({ studio } = {}) {
350
+ super({ name: "cloud" });
351
+ this.studio = studio ?? false;
352
+ }
353
+ async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
354
+ return {
355
+ ...await super.getUserBundlerOptions(mastraEntryFile, outputDirectory),
356
+ externals: true
357
+ };
358
+ }
359
+ async deploy(_outputDirectory) {}
360
+ async prepare(outputDirectory) {
361
+ await super.prepare(outputDirectory);
362
+ if (this.studio) {
363
+ const __dirname = (0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
364
+ const studioServePath = (0, path.join)(outputDirectory, this.outputDir, "studio");
365
+ await (0, fs_extra_esm.copy)((0, path.join)((0, path.dirname)(__dirname), (0, path.join)("dist", "studio")), studioServePath, { overwrite: true });
366
+ }
367
+ }
368
+ async writePackageJson(outputDirectory, dependencies) {
369
+ const versions = await (0, fs_extra_esm.readJSON)((0, path.join)((0, path.dirname)((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href)), "../versions.json"));
370
+ for (const [pkgName, version] of Object.entries(versions || {})) dependencies.set(pkgName, version);
371
+ return super.writePackageJson(outputDirectory, dependencies);
372
+ }
373
+ async lint() {}
374
+ async installDependencies(outputDirectory, _rootDir = process.cwd()) {
375
+ await installDeps({
376
+ path: (0, path.join)(outputDirectory, "output"),
377
+ pm: "npm"
378
+ });
379
+ }
380
+ async bundle(mastraDir, outputDirectory) {
381
+ const currentCwd = process.cwd();
382
+ process.chdir(mastraDir);
383
+ const mastraEntryFile = getMastraEntryFile(mastraDir);
384
+ const mastraAppDir = (0, path.join)(mastraDir, MASTRA_DIRECTORY);
385
+ const discoveredTools = this.getAllToolPaths(mastraAppDir);
386
+ await this.prepare(outputDirectory);
387
+ await this._bundle(this.getEntry(), mastraEntryFile, {
388
+ outputDirectory,
389
+ projectRoot: mastraDir
390
+ }, discoveredTools);
391
+ process.chdir(currentCwd);
392
+ }
393
+ getAuthEntrypoint() {
394
+ return getAuthEntrypoint();
395
+ }
396
+ getEntry() {
397
+ return `
419
398
  import { createNodeServer, getToolExports } from '#server';
420
399
  import { tools } from '#tools';
421
400
  import { mastra } from '#mastra';
@@ -523,9 +502,9 @@ console.log(JSON.stringify({
523
502
  },
524
503
  }));
525
504
  `;
526
- }
505
+ }
527
506
  };
528
-
507
+ //#endregion
529
508
  exports.CloudDeployer = CloudDeployer;
530
- //# sourceMappingURL=index.cjs.map
509
+
531
510
  //# sourceMappingURL=index.cjs.map