@mastra/deployer 1.58.0-alpha.0 → 1.58.0-alpha.12
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 +164 -0
- package/dist/_types/@hono_node-server/dist/index.d.mts +101 -0
- package/dist/_types/@mastra_hono/dist/index.d.ts +24 -1
- package/dist/{analyze-C6SiypMS.cjs → analyze-BIrkd7zx.cjs} +12 -5
- package/dist/{analyze-C6SiypMS.cjs.map → analyze-BIrkd7zx.cjs.map} +1 -1
- package/dist/{analyze-mZfLnmw2.js → analyze-CNv6Qdaz.js} +12 -5
- package/dist/{analyze-mZfLnmw2.js.map → analyze-CNv6Qdaz.js.map} +1 -1
- package/dist/build/analyze.cjs +1 -1
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +1 -1
- package/dist/build/bundler.d.ts +2 -1
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/fs-routing/codegen.d.ts +5 -4
- package/dist/build/fs-routing/codegen.d.ts.map +1 -1
- package/dist/build/fs-routing/discover.d.ts +12 -5
- package/dist/build/fs-routing/discover.d.ts.map +1 -1
- package/dist/build/index.cjs +5 -5
- package/dist/build/index.js +5 -5
- package/dist/build/types.d.ts +11 -0
- package/dist/build/types.d.ts.map +1 -1
- package/dist/build/watcher.d.ts.map +1 -1
- package/dist/{build-BEtx4cTU.cjs → build-BERX35Pi.cjs} +31 -19
- package/dist/build-BERX35Pi.cjs.map +1 -0
- package/dist/{build-C5mUjLVf.js → build-kZfvpuh9.js} +31 -19
- package/dist/build-kZfvpuh9.js.map +1 -0
- package/dist/bundler/entries.d.ts +12 -0
- package/dist/bundler/entries.d.ts.map +1 -0
- package/dist/bundler/index.cjs +6 -345
- package/dist/bundler/index.d.ts +52 -2
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +2 -340
- package/dist/bundler-Ct1ToG6x.js +565 -0
- package/dist/bundler-Ct1ToG6x.js.map +1 -0
- package/dist/{bundler-u9WOUtpl.cjs → bundler-DCGtF4jP.cjs} +7 -3
- package/dist/{bundler-u9WOUtpl.cjs.map → bundler-DCGtF4jP.cjs.map} +1 -1
- package/dist/bundler-DLXwkS7b.cjs +598 -0
- package/dist/bundler-DLXwkS7b.cjs.map +1 -0
- package/dist/{bundler-U9F2---r.js → bundler-gff4vn1T.js} +8 -4
- package/dist/bundler-gff4vn1T.js.map +1 -0
- package/dist/{bundlerOptions-CYRir4LE.cjs → bundlerOptions-CjjAPZYp.cjs} +2 -2
- package/dist/{bundlerOptions-CYRir4LE.cjs.map → bundlerOptions-CjjAPZYp.cjs.map} +1 -1
- package/dist/{bundlerOptions-9DigsVhY.js → bundlerOptions-NMtZPD7p.js} +2 -2
- package/dist/{bundlerOptions-9DigsVhY.js.map → bundlerOptions-NMtZPD7p.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/server/index.cjs +954 -167
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +955 -167
- package/dist/server/index.js.map +1 -1
- package/dist/services/deps.d.ts +3 -1
- package/dist/services/deps.d.ts.map +1 -1
- package/dist/services/index.cjs +1 -1
- package/dist/services/index.js +1 -1
- package/dist/{services-CHz7RuZ1.js → services-BRF1RRXB.js} +39 -4
- package/dist/services-BRF1RRXB.js.map +1 -0
- package/dist/{services-Cw3Ho44Z.cjs → services-_ksvysL5.cjs} +39 -4
- package/dist/services-_ksvysL5.cjs.map +1 -0
- package/package.json +9 -8
- package/dist/_types/@hono_node-server/dist/index.d.ts +0 -8
- package/dist/_types/@hono_node-server/dist/listener.d.ts +0 -13
- package/dist/_types/@hono_node-server/dist/request.d.ts +0 -25
- package/dist/_types/@hono_node-server/dist/server.d.ts +0 -10
- package/dist/_types/@hono_node-server/dist/types.d.ts +0 -44
- package/dist/build-BEtx4cTU.cjs.map +0 -1
- package/dist/build-C5mUjLVf.js.map +0 -1
- package/dist/bundler/index.cjs.map +0 -1
- package/dist/bundler/index.js.map +0 -1
- package/dist/bundler-U9F2---r.js.map +0 -1
- package/dist/services-CHz7RuZ1.js.map +0 -1
- package/dist/services-Cw3Ho44Z.cjs.map +0 -1
package/dist/bundler/index.js
CHANGED
|
@@ -1,340 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
3
|
-
import { i as DepsService, t as FileService } from "../services-CHz7RuZ1.js";
|
|
4
|
-
import { n as getInputOptions, t as createBundler } from "../bundler-U9F2---r.js";
|
|
5
|
-
import { t as getBundlerOptions } from "../bundlerOptions-9DigsVhY.js";
|
|
6
|
-
import { execSync } from "child_process";
|
|
7
|
-
import { existsSync } from "fs";
|
|
8
|
-
import { rm, stat, writeFile } from "fs/promises";
|
|
9
|
-
import { dirname, join, posix } from "path";
|
|
10
|
-
import { MastraBundler } from "@mastra/core/bundler";
|
|
11
|
-
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
12
|
-
import virtual from "@rollup/plugin-virtual";
|
|
13
|
-
import * as pkg from "empathic/package";
|
|
14
|
-
import fsExtra, { copy, emptyDir, ensureDir } from "fs-extra/esm";
|
|
15
|
-
import { glob } from "tinyglobby";
|
|
16
|
-
//#region src/bundler/index.ts
|
|
17
|
-
const IS_DEFAULT = Symbol("IS_DEFAULT");
|
|
18
|
-
var Bundler = class extends MastraBundler {
|
|
19
|
-
analyzeOutputDir = ".build";
|
|
20
|
-
outputDir = "output";
|
|
21
|
-
platform = "node";
|
|
22
|
-
constructor(name, component = "BUNDLER") {
|
|
23
|
-
super({
|
|
24
|
-
name,
|
|
25
|
-
component
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async prepare(outputDirectory) {
|
|
29
|
-
await emptyDir(outputDirectory);
|
|
30
|
-
await ensureDir(join(outputDirectory, this.analyzeOutputDir));
|
|
31
|
-
await ensureDir(join(outputDirectory, this.outputDir));
|
|
32
|
-
}
|
|
33
|
-
async writePackageJson(outputDirectory, dependencies, resolutions) {
|
|
34
|
-
this.logger.debug("Writing project's package.json");
|
|
35
|
-
await ensureDir(outputDirectory);
|
|
36
|
-
const pkgPath = join(outputDirectory, "package.json");
|
|
37
|
-
const dependenciesMap = /* @__PURE__ */ new Map();
|
|
38
|
-
for (const [key, value] of dependencies.entries()) {
|
|
39
|
-
const dependencyValue = typeof value === "string" ? value : value.packageSpec ?? value.version ?? "latest";
|
|
40
|
-
if (key.startsWith("@")) {
|
|
41
|
-
const pkgChunks = key.split("/");
|
|
42
|
-
dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);
|
|
43
|
-
} else {
|
|
44
|
-
const pkgName = key.split("/")[0] || key;
|
|
45
|
-
dependenciesMap.set(pkgName, dependencyValue);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
await writeFile(pkgPath, JSON.stringify({
|
|
49
|
-
name: "server",
|
|
50
|
-
version: "1.0.0",
|
|
51
|
-
private: true,
|
|
52
|
-
type: "module",
|
|
53
|
-
main: "index.mjs",
|
|
54
|
-
scripts: { start: "node ./index.mjs" },
|
|
55
|
-
dependencies: Object.fromEntries(dependenciesMap.entries()),
|
|
56
|
-
...Object.keys(resolutions ?? {}).length > 0 && { resolutions }
|
|
57
|
-
}, null, 2));
|
|
58
|
-
}
|
|
59
|
-
createBundler(inputOptions, outputOptions) {
|
|
60
|
-
return createBundler(inputOptions, outputOptions);
|
|
61
|
-
}
|
|
62
|
-
async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
|
|
63
|
-
const defaultBundlerOptions = {
|
|
64
|
-
externals: [],
|
|
65
|
-
sourcemap: false,
|
|
66
|
-
transpilePackages: [],
|
|
67
|
-
[IS_DEFAULT]: true
|
|
68
|
-
};
|
|
69
|
-
try {
|
|
70
|
-
return await getBundlerOptions(mastraEntryFile, outputDirectory) ?? defaultBundlerOptions;
|
|
71
|
-
} catch (error) {
|
|
72
|
-
this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
|
|
73
|
-
}
|
|
74
|
-
return defaultBundlerOptions;
|
|
75
|
-
}
|
|
76
|
-
async analyze(entry, mastraFile, outputDirectory) {
|
|
77
|
-
return await analyzeBundle([].concat(entry), mastraFile, {
|
|
78
|
-
outputDir: join(outputDirectory, this.analyzeOutputDir),
|
|
79
|
-
projectRoot: outputDirectory,
|
|
80
|
-
platform: this.platform
|
|
81
|
-
}, this.logger);
|
|
82
|
-
}
|
|
83
|
-
async installDependencies(outputDirectory, rootDir = process.cwd(), pnpmOverrides) {
|
|
84
|
-
const deps = new DepsService(rootDir);
|
|
85
|
-
deps.__setLogger(this.logger);
|
|
86
|
-
await deps.install({
|
|
87
|
-
dir: join(outputDirectory, this.outputDir),
|
|
88
|
-
pnpmOverrides
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Generate a package-lock.json for the output directory so that deploy targets
|
|
93
|
-
* can use `npm ci` instead of `npm install`, skipping version resolution entirely.
|
|
94
|
-
* This is a lockfile-only operation — no packages are downloaded.
|
|
95
|
-
*
|
|
96
|
-
* Temporarily moves node_modules out of the way because pnpm's symlink-based
|
|
97
|
-
* layout confuses npm's arborist, then restores it afterwards so that
|
|
98
|
-
* `mastra start` (or wrangler) can still resolve dependencies at runtime.
|
|
99
|
-
*/
|
|
100
|
-
async generateNpmLockfile(outputDir) {
|
|
101
|
-
const nodeModules = join(outputDir, "node_modules");
|
|
102
|
-
const nodeModulesTmp = join(outputDir, "node_modules.__tmp");
|
|
103
|
-
let movedNodeModules = false;
|
|
104
|
-
try {
|
|
105
|
-
if (await fsExtra.pathExists(nodeModules)) {
|
|
106
|
-
await fsExtra.move(nodeModules, nodeModulesTmp, { overwrite: true });
|
|
107
|
-
movedNodeModules = true;
|
|
108
|
-
}
|
|
109
|
-
execSync("npm install --package-lock-only --force", {
|
|
110
|
-
cwd: outputDir,
|
|
111
|
-
stdio: "pipe",
|
|
112
|
-
timeout: 6e4
|
|
113
|
-
});
|
|
114
|
-
} catch {
|
|
115
|
-
this.logger.warn("Failed to generate package-lock.json — deploy will fall back to npm install");
|
|
116
|
-
} finally {
|
|
117
|
-
if (movedNodeModules) {
|
|
118
|
-
await rm(nodeModules, {
|
|
119
|
-
recursive: true,
|
|
120
|
-
force: true
|
|
121
|
-
});
|
|
122
|
-
await fsExtra.move(nodeModulesTmp, nodeModules, { overwrite: true });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
async copyPublic(mastraDir, outputDirectory) {
|
|
127
|
-
const publicDir = join(mastraDir, "public");
|
|
128
|
-
try {
|
|
129
|
-
await stat(publicDir);
|
|
130
|
-
} catch {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
await copy(publicDir, join(outputDirectory, this.outputDir));
|
|
134
|
-
}
|
|
135
|
-
async copyDOTNPMRC({ rootDir = process.cwd(), outputDirectory }) {
|
|
136
|
-
const sourceDotNpmRcPath = join(rootDir, ".npmrc");
|
|
137
|
-
const targetDotNpmRcPath = join(outputDirectory, this.outputDir, ".npmrc");
|
|
138
|
-
try {
|
|
139
|
-
await stat(sourceDotNpmRcPath);
|
|
140
|
-
await copy(sourceDotNpmRcPath, targetDotNpmRcPath);
|
|
141
|
-
} catch {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Writes the `mastra-project.json` deployment marker for Software Factory
|
|
147
|
-
* projects after public assets have been copied. Verifies that the Factory
|
|
148
|
-
* SPA (`factory/index.html`) exists in the output before emitting the marker.
|
|
149
|
-
*/
|
|
150
|
-
async writeFactoryMarker(outputDirectory) {
|
|
151
|
-
const outputDir = join(outputDirectory, this.outputDir);
|
|
152
|
-
if (!existsSync(join(outputDir, "factory", "index.html"))) throw new MastraError({
|
|
153
|
-
id: "DEPLOYER_BUNDLER_FACTORY_UI_MISSING",
|
|
154
|
-
text: "Software Factory project detected but factory/index.html was not found after copying the prebuilt Factory UI.",
|
|
155
|
-
domain: ErrorDomain.DEPLOYER,
|
|
156
|
-
category: ErrorCategory.SYSTEM
|
|
157
|
-
});
|
|
158
|
-
await writeFile(join(outputDir, "mastra-project.json"), JSON.stringify({
|
|
159
|
-
schemaVersion: 1,
|
|
160
|
-
projectType: "factory",
|
|
161
|
-
assets: { ui: "factory" }
|
|
162
|
-
}, null, 2));
|
|
163
|
-
this.logger.info("Wrote mastra-project.json for Software Factory project");
|
|
164
|
-
}
|
|
165
|
-
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, { enableSourcemap, enableEsmShim, externals }) {
|
|
166
|
-
const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });
|
|
167
|
-
const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });
|
|
168
|
-
const projectRoot = closestPkgJson ? dirname(closestPkgJson) : process.cwd();
|
|
169
|
-
const inputOptions = await getInputOptions(mastraEntryFile, analyzedBundleInfo, this.platform, { "process.env.NODE_ENV": JSON.stringify("production") }, {
|
|
170
|
-
sourcemap: enableSourcemap,
|
|
171
|
-
workspaceRoot,
|
|
172
|
-
projectRoot,
|
|
173
|
-
enableEsmShim,
|
|
174
|
-
externalsPreset: externals === true
|
|
175
|
-
});
|
|
176
|
-
const isVirtual = serverFile.includes("\n") || !existsSync(serverFile);
|
|
177
|
-
const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);
|
|
178
|
-
if (isVirtual) {
|
|
179
|
-
inputOptions.input = {
|
|
180
|
-
index: "#entry",
|
|
181
|
-
...toolsInputOptions
|
|
182
|
-
};
|
|
183
|
-
if (Array.isArray(inputOptions.plugins)) inputOptions.plugins.unshift(virtual({ "#entry": serverFile }));
|
|
184
|
-
else inputOptions.plugins = [virtual({ "#entry": serverFile })];
|
|
185
|
-
} else inputOptions.input = {
|
|
186
|
-
index: serverFile,
|
|
187
|
-
...toolsInputOptions
|
|
188
|
-
};
|
|
189
|
-
return inputOptions;
|
|
190
|
-
}
|
|
191
|
-
getAllToolPaths(mastraDir, toolsPaths = []) {
|
|
192
|
-
const normalizedMastraDir = slash(mastraDir);
|
|
193
|
-
const defaultPaths = [posix.join(normalizedMastraDir, "tools/**/*.{js,ts}"), ...[`!${posix.join(normalizedMastraDir, "tools/**/*.{test,spec}.{js,ts}")}`, `!${posix.join(normalizedMastraDir, "tools/**/__tests__/**")}`]];
|
|
194
|
-
if (toolsPaths.length === 0) return [defaultPaths];
|
|
195
|
-
return [...toolsPaths, defaultPaths];
|
|
196
|
-
}
|
|
197
|
-
async listToolsInputOptions(toolsPaths) {
|
|
198
|
-
const inputs = {};
|
|
199
|
-
for (const toolPath of toolsPaths) {
|
|
200
|
-
const expandedPaths = await glob(toolPath, {
|
|
201
|
-
absolute: true,
|
|
202
|
-
expandDirectories: false
|
|
203
|
-
});
|
|
204
|
-
for (const path of expandedPaths) if (await fsExtra.pathExists(path)) {
|
|
205
|
-
const entryFile = new FileService().getFirstExistingFile([
|
|
206
|
-
join(path, "index.ts"),
|
|
207
|
-
join(path, "index.js"),
|
|
208
|
-
path
|
|
209
|
-
]);
|
|
210
|
-
if (!entryFile || (await stat(entryFile)).isDirectory()) {
|
|
211
|
-
this.logger.warn("No entry file found, skipping", { path });
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
const uniqueToolID = crypto.randomUUID();
|
|
215
|
-
const normalizedEntryFile = entryFile.replaceAll("\\", "/");
|
|
216
|
-
inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;
|
|
217
|
-
} else this.logger.warn("Tool path does not exist, skipping", { path });
|
|
218
|
-
}
|
|
219
|
-
return inputs;
|
|
220
|
-
}
|
|
221
|
-
async _bundle(serverFile, mastraEntryFile, { projectRoot, outputDirectory, enableEsmShim = true }, toolsPaths = [], bundleLocation = join(outputDirectory, this.outputDir)) {
|
|
222
|
-
const analyzeDir = join(outputDirectory, this.analyzeOutputDir);
|
|
223
|
-
const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);
|
|
224
|
-
const internalBundlerOptions = {
|
|
225
|
-
enableSourcemap: !!bundlerOptions.sourcemap,
|
|
226
|
-
externals: bundlerOptions.externals ?? [],
|
|
227
|
-
enableEsmShim,
|
|
228
|
-
dynamicPackages: bundlerOptions.dynamicPackages
|
|
229
|
-
};
|
|
230
|
-
let analyzedBundleInfo;
|
|
231
|
-
try {
|
|
232
|
-
const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);
|
|
233
|
-
analyzedBundleInfo = await analyzeBundle([serverFile, ...Object.values(resolvedToolsPaths)], mastraEntryFile, {
|
|
234
|
-
outputDir: analyzeDir,
|
|
235
|
-
projectRoot,
|
|
236
|
-
platform: this.platform,
|
|
237
|
-
bundlerOptions: internalBundlerOptions
|
|
238
|
-
}, this.logger);
|
|
239
|
-
} catch (error) {
|
|
240
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
241
|
-
if (error instanceof MastraError) throw error;
|
|
242
|
-
throw new MastraError({
|
|
243
|
-
id: "DEPLOYER_BUNDLER_ANALYZE_FAILED",
|
|
244
|
-
text: `Failed to analyze Mastra application: ${message}`,
|
|
245
|
-
domain: ErrorDomain.DEPLOYER,
|
|
246
|
-
category: ErrorCategory.SYSTEM
|
|
247
|
-
}, error);
|
|
248
|
-
}
|
|
249
|
-
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
250
|
-
for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {
|
|
251
|
-
if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) continue;
|
|
252
|
-
dependenciesToInstall.set(dep, depInfo);
|
|
253
|
-
}
|
|
254
|
-
const initialWorkspaceDependencies = /* @__PURE__ */ new Set();
|
|
255
|
-
for (const dep of analyzedBundleInfo.dependencies.keys()) {
|
|
256
|
-
const pkgName = getPackageName(dep);
|
|
257
|
-
if (pkgName && analyzedBundleInfo.workspaceMap.has(pkgName)) initialWorkspaceDependencies.add(pkgName);
|
|
258
|
-
}
|
|
259
|
-
const transitiveWorkspaceDependencies = collectTransitiveWorkspaceDependencies({
|
|
260
|
-
workspaceMap: analyzedBundleInfo.workspaceMap,
|
|
261
|
-
initialDependencies: initialWorkspaceDependencies,
|
|
262
|
-
logger: this.logger
|
|
263
|
-
});
|
|
264
|
-
for (const [dep, packageSpec] of Object.entries(transitiveWorkspaceDependencies.resolutions)) dependenciesToInstall.set(dep, {
|
|
265
|
-
version: analyzedBundleInfo.workspaceMap.get(dep)?.version,
|
|
266
|
-
packageSpec
|
|
267
|
-
});
|
|
268
|
-
try {
|
|
269
|
-
await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall, transitiveWorkspaceDependencies.resolutions);
|
|
270
|
-
if (transitiveWorkspaceDependencies.usedWorkspacePackages.size > 0) await packWorkspaceDependencies({
|
|
271
|
-
workspaceMap: analyzedBundleInfo.workspaceMap,
|
|
272
|
-
usedWorkspacePackages: transitiveWorkspaceDependencies.usedWorkspacePackages,
|
|
273
|
-
bundleOutputDir: join(outputDirectory, this.outputDir),
|
|
274
|
-
logger: this.logger
|
|
275
|
-
});
|
|
276
|
-
this.logger.info("Bundling Mastra application");
|
|
277
|
-
const inputOptions = await this.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, internalBundlerOptions);
|
|
278
|
-
await (await this.createBundler({
|
|
279
|
-
...inputOptions,
|
|
280
|
-
logLevel: inputOptions.logLevel === "silent" ? "warn" : inputOptions.logLevel,
|
|
281
|
-
onwarn: (warning) => {
|
|
282
|
-
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
|
283
|
-
if (warning.ids?.[0]?.includes("node_modules")) return;
|
|
284
|
-
this.logger.warn("Circular dependency found", { dependency: warning.message.replace("Circular dependency: ", "") });
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}, {
|
|
288
|
-
dir: bundleLocation,
|
|
289
|
-
manualChunks: { mastra: ["#mastra"] },
|
|
290
|
-
sourcemap: internalBundlerOptions.enableSourcemap
|
|
291
|
-
})).write();
|
|
292
|
-
const toolImports = [];
|
|
293
|
-
const toolsExports = [];
|
|
294
|
-
Array.from(Object.keys(inputOptions.input || {})).filter((key) => key.startsWith("tools/")).forEach((key, index) => {
|
|
295
|
-
const toolExport = `tool${index}`;
|
|
296
|
-
toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);
|
|
297
|
-
toolsExports.push(toolExport);
|
|
298
|
-
});
|
|
299
|
-
await writeFile(join(bundleLocation, "tools.mjs"), `${toolImports.join("\n")}
|
|
300
|
-
|
|
301
|
-
export const tools = [${toolsExports.join(", ")}]`);
|
|
302
|
-
this.logger.info("Bundling Mastra done");
|
|
303
|
-
this.logger.info("Copying public files");
|
|
304
|
-
await this.copyPublic(dirname(mastraEntryFile), outputDirectory);
|
|
305
|
-
this.logger.info("Done copying public files");
|
|
306
|
-
if (analyzedBundleInfo.projectType === "factory") await this.writeFactoryMarker(outputDirectory);
|
|
307
|
-
this.logger.info("Copying .npmrc file");
|
|
308
|
-
await this.copyDOTNPMRC({
|
|
309
|
-
outputDirectory,
|
|
310
|
-
rootDir: projectRoot
|
|
311
|
-
});
|
|
312
|
-
this.logger.info("Done copying .npmrc file");
|
|
313
|
-
this.logger.info("Installing dependencies");
|
|
314
|
-
await this.installDependencies(outputDirectory, projectRoot, transitiveWorkspaceDependencies.resolutions);
|
|
315
|
-
this.logger.info("Done installing dependencies");
|
|
316
|
-
if (Object.keys(transitiveWorkspaceDependencies.resolutions).length === 0) {
|
|
317
|
-
this.logger.info("Generating package-lock.json for deploy");
|
|
318
|
-
await this.generateNpmLockfile(join(outputDirectory, this.outputDir));
|
|
319
|
-
this.logger.info("Done generating package-lock.json");
|
|
320
|
-
} else this.logger.warn("Skipping package-lock.json generation because the output contains packed workspace dependencies");
|
|
321
|
-
} catch (error) {
|
|
322
|
-
if (error instanceof MastraError && error.id === "DEPLOYER_BUNDLER_FACTORY_UI_MISSING") throw error;
|
|
323
|
-
throw new MastraError({
|
|
324
|
-
id: "DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED",
|
|
325
|
-
text: `Failed during bundler bundle stage: ${error instanceof Error ? error.message : String(error)}`,
|
|
326
|
-
domain: ErrorDomain.DEPLOYER,
|
|
327
|
-
category: ErrorCategory.SYSTEM
|
|
328
|
-
}, error);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
async lint(_entryFile, _outputDirectory, toolsPaths) {
|
|
332
|
-
const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);
|
|
333
|
-
const toolsLength = Object.keys(toolsInputOptions).length;
|
|
334
|
-
if (toolsLength > 0) this.logger.info("Found tools", { count: toolsLength });
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
//#endregion
|
|
338
|
-
export { Bundler, IS_DEFAULT };
|
|
339
|
-
|
|
340
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { a as isRegistryVersionSpec, i as getSourceDependencyConstraints, n as IS_DEFAULT, r as applySourceDependencyRange, t as Bundler } from "../bundler-Ct1ToG6x.js";
|
|
2
|
+
export { Bundler, IS_DEFAULT, applySourceDependencyRange, getSourceDependencyConstraints, isRegistryVersionSpec };
|