@mastra/deployer-cloud 1.54.0-alpha.0 → 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/CHANGELOG.md +16 -0
- package/dist/index.cjs +300 -321
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +271 -291
- package/dist/index.js.map +1 -1
- package/dist/studio/assets/{core-B1F0sc8J.js → core-8vVR2ij5.js} +1 -1
- package/dist/studio/assets/{index-6hF5Bju_.js → index-BAJaF9UY.js} +2 -2
- package/dist/studio/assets/{main-CL2W-UZZ.js → main-3o2-IcPy.js} +243 -243
- package/dist/studio/index.html +1 -1
- package/package.json +7 -7
- package/versions.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,54 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
try {
|
|
135
|
+
return JSON.parse(json);
|
|
136
|
+
} catch {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
137
139
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
141
|
-
var RedisTransport = class extends
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
redis: transport
|
|
212
|
-
}
|
|
206
|
+
const logger = new _mastra_loggers.PinoLogger({
|
|
207
|
+
level: "info",
|
|
208
|
+
transports: { redis: transport }
|
|
213
209
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
256
|
-
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/utils/deps.ts
|
|
250
|
+
const MEMOIZED = /* @__PURE__ */ new Map();
|
|
257
251
|
function findLockFile(dir) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/utils/report.ts
|
|
332
321
|
function successEntrypoint() {
|
|
333
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
358
|
-
var CloudDeployer = class extends
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
|
|
509
|
+
|
|
531
510
|
//# sourceMappingURL=index.cjs.map
|