@mastra/deployer 0.0.0-afterToolExecute-20250414225911

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.
Files changed (58) hide show
  1. package/LICENSE.md +46 -0
  2. package/README.md +159 -0
  3. package/dist/_tsup-dts-rollup.d.cts +479 -0
  4. package/dist/_tsup-dts-rollup.d.ts +479 -0
  5. package/dist/build/analyze.cjs +10 -0
  6. package/dist/build/analyze.d.cts +1 -0
  7. package/dist/build/analyze.d.ts +1 -0
  8. package/dist/build/analyze.js +1 -0
  9. package/dist/build/bundler.cjs +14 -0
  10. package/dist/build/bundler.d.cts +2 -0
  11. package/dist/build/bundler.d.ts +2 -0
  12. package/dist/build/bundler.js +1 -0
  13. package/dist/build/index.cjs +47 -0
  14. package/dist/build/index.d.cts +9 -0
  15. package/dist/build/index.d.ts +9 -0
  16. package/dist/build/index.js +6 -0
  17. package/dist/bundler/index.cjs +10 -0
  18. package/dist/bundler/index.d.cts +1 -0
  19. package/dist/bundler/index.d.ts +1 -0
  20. package/dist/bundler/index.js +1 -0
  21. package/dist/chunk-2ZPQX6BX.cjs +254 -0
  22. package/dist/chunk-4AYFLP6G.js +227 -0
  23. package/dist/chunk-54KOF3NB.cjs +137 -0
  24. package/dist/chunk-AE4CVAPK.cjs +151 -0
  25. package/dist/chunk-BDTZS3JM.js +299 -0
  26. package/dist/chunk-DYQ225MJ.js +115 -0
  27. package/dist/chunk-I3UVE6EH.cjs +161 -0
  28. package/dist/chunk-IKPL4RGG.js +140 -0
  29. package/dist/chunk-JDY6E7BT.cjs +152 -0
  30. package/dist/chunk-MYE33AKL.cjs +195 -0
  31. package/dist/chunk-NCROGJGB.cjs +142 -0
  32. package/dist/chunk-P5SATU7G.cjs +310 -0
  33. package/dist/chunk-SQQUYWPS.js +144 -0
  34. package/dist/chunk-WB3T6NKI.js +133 -0
  35. package/dist/chunk-WVBUOQT6.js +111 -0
  36. package/dist/chunk-YQB677IB.js +183 -0
  37. package/dist/index.cjs +191 -0
  38. package/dist/index.d.cts +6 -0
  39. package/dist/index.d.ts +6 -0
  40. package/dist/index.js +151 -0
  41. package/dist/server/index.cjs +3860 -0
  42. package/dist/server/index.d.cts +2 -0
  43. package/dist/server/index.d.ts +2 -0
  44. package/dist/server/index.js +3853 -0
  45. package/dist/services/index.cjs +19 -0
  46. package/dist/services/index.d.cts +3 -0
  47. package/dist/services/index.d.ts +3 -0
  48. package/dist/services/index.js +2 -0
  49. package/dist/templates/instrumentation-template.js +89 -0
  50. package/dist/validator/custom-resolver.cjs +52 -0
  51. package/dist/validator/custom-resolver.d.cts +1 -0
  52. package/dist/validator/custom-resolver.d.ts +1 -0
  53. package/dist/validator/custom-resolver.js +50 -0
  54. package/dist/validator/loader.cjs +7 -0
  55. package/dist/validator/loader.d.cts +1 -0
  56. package/dist/validator/loader.d.ts +1 -0
  57. package/dist/validator/loader.js +4 -0
  58. package/package.json +138 -0
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
4
+ var alias = require('@rollup/plugin-alias');
5
+ var commonjs = require('@rollup/plugin-commonjs');
6
+ var json = require('@rollup/plugin-json');
7
+ var nodeResolve = require('@rollup/plugin-node-resolve');
8
+ var url = require('url');
9
+ var rollup = require('rollup');
10
+ var esbuild = require('rollup-plugin-esbuild');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var alias__default = /*#__PURE__*/_interopDefault(alias);
15
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
16
+ var json__default = /*#__PURE__*/_interopDefault(json);
17
+ var nodeResolve__default = /*#__PURE__*/_interopDefault(nodeResolve);
18
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
19
+
20
+ async function getInputOptions(entryFile, analyzedBundleInfo, platform) {
21
+ let nodeResolvePlugin = platform === "node" ? nodeResolve__default.default({
22
+ preferBuiltins: true,
23
+ exportConditions: ["node", "import", "require"],
24
+ mainFields: ["module", "main"]
25
+ }) : nodeResolve__default.default({
26
+ preferBuiltins: false,
27
+ exportConditions: ["browser", "import", "require"],
28
+ mainFields: ["module", "main"],
29
+ browser: true
30
+ });
31
+ const externalsCopy = /* @__PURE__ */ new Set();
32
+ for (const external of analyzedBundleInfo.externalDependencies) {
33
+ if (external.startsWith("@")) {
34
+ const [scope, name] = external.split("/", 3);
35
+ externalsCopy.add(`${scope}/${name}`);
36
+ externalsCopy.add(`${scope}/${name}/*`);
37
+ } else {
38
+ externalsCopy.add(external);
39
+ externalsCopy.add(`${external}/*`);
40
+ }
41
+ }
42
+ const externals = Array.from(externalsCopy);
43
+ const normalizedEntryFile = entryFile.replaceAll("\\", "/");
44
+ return {
45
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
46
+ treeshake: "smallest",
47
+ preserveSymlinks: true,
48
+ external: externals,
49
+ plugins: [
50
+ chunk54KOF3NB_cjs.tsConfigPaths(),
51
+ {
52
+ name: "alias-optimized-deps",
53
+ // @ts-ignore
54
+ resolveId(id) {
55
+ if (!analyzedBundleInfo.dependencies.has(id)) {
56
+ return null;
57
+ }
58
+ const isInvalidChunk = analyzedBundleInfo.invalidChunks.has(analyzedBundleInfo.dependencies.get(id));
59
+ if (isInvalidChunk) {
60
+ return {
61
+ id,
62
+ external: true
63
+ };
64
+ }
65
+ return {
66
+ id: ".mastra/.build/" + analyzedBundleInfo.dependencies.get(id),
67
+ external: false
68
+ };
69
+ }
70
+ },
71
+ alias__default.default({
72
+ entries: [
73
+ {
74
+ find: /^\#server$/,
75
+ replacement: url.fileURLToPath(undefined("@mastra/deployer/server")).replaceAll("\\", "/")
76
+ },
77
+ {
78
+ find: /^\@mastra\/server\/(.*)/,
79
+ replacement: `@mastra/server/$1`,
80
+ customResolver: (id) => {
81
+ if (id.startsWith("@mastra/server")) {
82
+ return {
83
+ id: url.fileURLToPath(undefined(id))
84
+ };
85
+ }
86
+ }
87
+ },
88
+ { find: /^\#mastra$/, replacement: normalizedEntryFile }
89
+ ]
90
+ }),
91
+ esbuild__default.default({
92
+ target: "node20",
93
+ platform,
94
+ minify: false,
95
+ define: {
96
+ "process.env.NODE_ENV": JSON.stringify("production")
97
+ }
98
+ }),
99
+ commonjs__default.default({
100
+ extensions: [".js", ".ts"],
101
+ transformMixedEsModules: true,
102
+ esmExternals(id) {
103
+ return externals.includes(id);
104
+ }
105
+ }),
106
+ nodeResolvePlugin,
107
+ // for debugging
108
+ // {
109
+ // name: 'logger',
110
+ // //@ts-ignore
111
+ // resolveId(id, ...args) {
112
+ // console.log({ id, args });
113
+ // },
114
+ // // @ts-ignore
115
+ // transform(code, id) {
116
+ // if (code.includes('class Duplexify ')) {
117
+ // console.log({ duplex: id });
118
+ // }
119
+ // },
120
+ // },
121
+ json__default.default(),
122
+ chunk54KOF3NB_cjs.removeDeployer(entryFile),
123
+ // treeshake unused imports
124
+ esbuild__default.default({
125
+ include: entryFile,
126
+ target: "node20",
127
+ platform,
128
+ minify: false
129
+ })
130
+ ].filter(Boolean)
131
+ };
132
+ }
133
+ async function createBundler(inputOptions, outputOptions) {
134
+ const bundler = await rollup.rollup(inputOptions);
135
+ return {
136
+ write: () => {
137
+ return bundler.write({
138
+ ...outputOptions,
139
+ format: "esm",
140
+ entryFileNames: "[name].mjs",
141
+ chunkFileNames: "[name].mjs"
142
+ });
143
+ },
144
+ close: () => {
145
+ return bundler.close();
146
+ }
147
+ };
148
+ }
149
+
150
+ exports.createBundler = createBundler;
151
+ exports.getInputOptions = getInputOptions;
@@ -0,0 +1,299 @@
1
+ import { tsConfigPaths, removeDeployer } from './chunk-WVBUOQT6.js';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import json from '@rollup/plugin-json';
4
+ import nodeResolve from '@rollup/plugin-node-resolve';
5
+ import virtual from '@rollup/plugin-virtual';
6
+ import { existsSync } from 'node:fs';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { rollup } from 'rollup';
9
+ import esbuild from 'rollup-plugin-esbuild';
10
+ import { builtinModules } from 'node:module';
11
+ import { join, dirname } from 'node:path';
12
+ import { spawn as spawn$1 } from 'node:child_process';
13
+ import { writeFile } from 'node:fs/promises';
14
+
15
+ function isNodeBuiltin(dep) {
16
+ const [pkg] = dep.split("/");
17
+ return dep.startsWith("node:") || builtinModules.includes(dep) || builtinModules.includes(pkg);
18
+ }
19
+ function aliasHono() {
20
+ return {
21
+ name: "hono-alias",
22
+ resolveId(id) {
23
+ if (!id.startsWith("@hono/") && !id.startsWith("hono/") && id !== "hono" && id !== "hono-openapi") {
24
+ return;
25
+ }
26
+ const path = import.meta.resolve(id);
27
+ return fileURLToPath(path);
28
+ }
29
+ };
30
+ }
31
+ function spawn(command, args = [], options = {}) {
32
+ return new Promise((resolve, reject) => {
33
+ const childProcess = spawn$1(command, args, {
34
+ // stdio: 'inherit',
35
+ ...options
36
+ });
37
+ childProcess.on("error", (error) => {
38
+ reject(error);
39
+ });
40
+ let stderr = "";
41
+ childProcess.stderr?.on("data", (message) => {
42
+ stderr += message;
43
+ });
44
+ childProcess.on("close", (code) => {
45
+ if (code === 0) {
46
+ resolve();
47
+ } else {
48
+ reject(new Error(stderr));
49
+ }
50
+ });
51
+ });
52
+ }
53
+ function validate(file) {
54
+ return spawn(
55
+ "node",
56
+ [
57
+ "--import",
58
+ import.meta.resolve("@mastra/deployer/loader"),
59
+ "--input-type=module",
60
+ "-e",
61
+ `import('file://${file.replaceAll("\\", "/")}')`
62
+ ],
63
+ {
64
+ cwd: dirname(file)
65
+ }
66
+ );
67
+ }
68
+ var globalExternals = ["pino", "pino-pretty", "@libsql/client", "pg", "libsql", "jsdom", "sqlite3"];
69
+ function findExternalImporter(module, external, allOutputs) {
70
+ const capturedFiles = /* @__PURE__ */ new Set();
71
+ for (const id of module.imports) {
72
+ if (id === external) {
73
+ return module;
74
+ } else {
75
+ if (id.endsWith(".mjs")) {
76
+ capturedFiles.add(id);
77
+ }
78
+ }
79
+ }
80
+ for (const file of capturedFiles) {
81
+ const nextModule = allOutputs.find((o) => o.fileName === file);
82
+ if (nextModule) {
83
+ const importer = findExternalImporter(nextModule, external, allOutputs);
84
+ if (importer) {
85
+ return importer;
86
+ }
87
+ }
88
+ }
89
+ return null;
90
+ }
91
+ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
92
+ logger.info("Analyzing dependencies...");
93
+ let virtualPlugin = null;
94
+ if (isVirtualFile) {
95
+ virtualPlugin = virtual({
96
+ "#entry": entry
97
+ });
98
+ entry = "#entry";
99
+ }
100
+ const normalizedMastraEntry = mastraEntry.replaceAll("\\", "/");
101
+ const optimizerBundler = await rollup({
102
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
103
+ input: isVirtualFile ? "#entry" : entry,
104
+ treeshake: "smallest",
105
+ preserveSymlinks: true,
106
+ plugins: [
107
+ virtualPlugin,
108
+ tsConfigPaths(),
109
+ {
110
+ name: "custom-alias-resolver",
111
+ resolveId(id) {
112
+ if (id === "#server") {
113
+ return fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/");
114
+ }
115
+ if (id === "#mastra") {
116
+ return normalizedMastraEntry;
117
+ }
118
+ if (id.startsWith("@mastra/server")) {
119
+ return fileURLToPath(import.meta.resolve(id));
120
+ }
121
+ }
122
+ },
123
+ json(),
124
+ esbuild({
125
+ target: "node20",
126
+ platform,
127
+ minify: false
128
+ }),
129
+ commonjs({
130
+ strictRequires: "debug",
131
+ ignoreTryCatch: false,
132
+ transformMixedEsModules: true,
133
+ extensions: [".js", ".ts"]
134
+ }),
135
+ removeDeployer(normalizedMastraEntry),
136
+ esbuild({
137
+ target: "node20",
138
+ platform,
139
+ minify: false
140
+ })
141
+ ].filter(Boolean)
142
+ });
143
+ const { output } = await optimizerBundler.generate({
144
+ format: "esm",
145
+ inlineDynamicImports: true
146
+ });
147
+ await optimizerBundler.close();
148
+ const depsToOptimize = new Map(Object.entries(output[0].importedBindings));
149
+ for (const dep of depsToOptimize.keys()) {
150
+ if (isNodeBuiltin(dep)) {
151
+ depsToOptimize.delete(dep);
152
+ }
153
+ }
154
+ return depsToOptimize;
155
+ }
156
+ async function bundleExternals(depsToOptimize, outputDir, logger) {
157
+ logger.info("Optimizing dependencies...");
158
+ logger.debug(
159
+ `${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
160
+ );
161
+ const reverseVirtualReferenceMap = /* @__PURE__ */ new Map();
162
+ const virtualDependencies = /* @__PURE__ */ new Map();
163
+ for (const [dep, exports] of depsToOptimize.entries()) {
164
+ const name = dep.replaceAll("/", "-");
165
+ reverseVirtualReferenceMap.set(name, dep);
166
+ const virtualFile = [];
167
+ let exportStringBuilder = [];
168
+ for (const local of exports) {
169
+ if (local === "*") {
170
+ virtualFile.push(`export * from '${dep}';`);
171
+ } else if (local === "default") {
172
+ virtualFile.push(`export { default } from '${dep}';`);
173
+ } else {
174
+ exportStringBuilder.push(local);
175
+ }
176
+ }
177
+ if (exportStringBuilder.length > 0) {
178
+ virtualFile.push(`export { ${exportStringBuilder.join(", ")} } from '${dep}';`);
179
+ }
180
+ virtualDependencies.set(dep, {
181
+ name,
182
+ virtual: virtualFile.join("\n")
183
+ });
184
+ }
185
+ const bundler = await rollup({
186
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
187
+ input: Array.from(virtualDependencies.entries()).reduce(
188
+ (acc, [dep, virtualDep]) => {
189
+ acc[virtualDep.name] = `#virtual-${dep}`;
190
+ return acc;
191
+ },
192
+ {}
193
+ ),
194
+ // this dependency breaks the build, so we need to exclude it
195
+ // TODO actually fix this so we don't need to exclude it
196
+ external: globalExternals,
197
+ treeshake: "smallest",
198
+ plugins: [
199
+ virtual(
200
+ Array.from(virtualDependencies.entries()).reduce(
201
+ (acc, [dep, virtualDep]) => {
202
+ acc[`#virtual-${dep}`] = virtualDep.virtual;
203
+ return acc;
204
+ },
205
+ {}
206
+ )
207
+ ),
208
+ commonjs({
209
+ strictRequires: "strict",
210
+ transformMixedEsModules: true,
211
+ ignoreTryCatch: false
212
+ }),
213
+ nodeResolve({
214
+ preferBuiltins: true,
215
+ exportConditions: ["node", "import", "require"],
216
+ mainFields: ["module", "main"]
217
+ }),
218
+ // hono is imported from deployer, so we need to resolve from here instead of the project root
219
+ aliasHono(),
220
+ json()
221
+ ].filter(Boolean)
222
+ });
223
+ const { output } = await bundler.write({
224
+ format: "esm",
225
+ dir: outputDir,
226
+ entryFileNames: "[name].mjs",
227
+ chunkFileNames: "[name].mjs",
228
+ hoistTransitiveImports: false
229
+ });
230
+ const moduleResolveMap = {};
231
+ const filteredChunks = output.filter((o) => o.type === "chunk");
232
+ for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
233
+ for (const external of globalExternals) {
234
+ const importer = findExternalImporter(o, external, filteredChunks);
235
+ if (importer) {
236
+ const fullPath = join(outputDir, importer.fileName);
237
+ moduleResolveMap[fullPath] = moduleResolveMap[fullPath] || {};
238
+ if (importer.moduleIds.length) {
239
+ moduleResolveMap[fullPath][external] = importer.moduleIds[importer.moduleIds.length - 1]?.startsWith(
240
+ "\0virtual:#virtual"
241
+ ) ? importer.moduleIds[importer.moduleIds.length - 2] : importer.moduleIds[importer.moduleIds.length - 1];
242
+ }
243
+ }
244
+ }
245
+ }
246
+ await writeFile(join(outputDir, "module-resolve-map.json"), JSON.stringify(moduleResolveMap, null, 2));
247
+ await bundler.close();
248
+ return { output, reverseVirtualReferenceMap, usedExternals: moduleResolveMap };
249
+ }
250
+ async function validateOutput({
251
+ output,
252
+ reverseVirtualReferenceMap,
253
+ usedExternals,
254
+ outputDir
255
+ }, logger) {
256
+ const result = {
257
+ invalidChunks: /* @__PURE__ */ new Set(),
258
+ dependencies: /* @__PURE__ */ new Map(),
259
+ externalDependencies: /* @__PURE__ */ new Set()
260
+ };
261
+ for (const deps of Object.values(usedExternals)) {
262
+ for (const dep of Object.keys(deps)) {
263
+ result.externalDependencies.add(dep);
264
+ }
265
+ }
266
+ for (const file of output) {
267
+ if (file.type === "asset") {
268
+ continue;
269
+ }
270
+ try {
271
+ logger.debug(`Validating if ${file.fileName} is a valid module.`);
272
+ if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
273
+ result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
274
+ }
275
+ if (!file.isDynamicEntry && file.isEntry) {
276
+ await validate(join(outputDir, file.fileName));
277
+ }
278
+ } catch (err) {
279
+ result.invalidChunks.add(file.fileName);
280
+ if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
281
+ result.externalDependencies.add(reverseVirtualReferenceMap.get(file.name));
282
+ }
283
+ }
284
+ }
285
+ return result;
286
+ }
287
+ async function analyzeBundle(entry, mastraEntry, outputDir, platform, logger) {
288
+ const isVirtualFile = entry.includes("\n") || !existsSync(entry);
289
+ const depsToOptimize = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
290
+ const { output, reverseVirtualReferenceMap, usedExternals } = await bundleExternals(
291
+ depsToOptimize,
292
+ outputDir,
293
+ logger
294
+ );
295
+ const result = await validateOutput({ output, reverseVirtualReferenceMap, usedExternals, outputDir }, logger);
296
+ return result;
297
+ }
298
+
299
+ export { aliasHono, analyzeBundle };
@@ -0,0 +1,115 @@
1
+ import * as fs2 from 'fs';
2
+ import fs2__default from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import fsExtra from 'fs-extra/esm';
6
+
7
+ // src/services/env.ts
8
+ var EnvService = class {
9
+ };
10
+ var FileEnvService = class extends EnvService {
11
+ filePath;
12
+ constructor(filePath) {
13
+ super();
14
+ this.filePath = filePath;
15
+ }
16
+ readFile(filePath) {
17
+ return new Promise((resolve, reject) => {
18
+ fs2.readFile(filePath, "utf8", (err, data) => {
19
+ if (err) reject(err);
20
+ else resolve(data);
21
+ });
22
+ });
23
+ }
24
+ writeFile({ filePath, data }) {
25
+ return new Promise((resolve, reject) => {
26
+ fs2.writeFile(filePath, data, "utf8", (err) => {
27
+ if (err) reject(err);
28
+ else resolve();
29
+ });
30
+ });
31
+ }
32
+ async updateEnvData({
33
+ key,
34
+ value,
35
+ filePath = this.filePath,
36
+ data
37
+ }) {
38
+ const regex = new RegExp(`^${key}=.*$`, "m");
39
+ if (data.match(regex)) {
40
+ data = data.replace(regex, `${key}=${value}`);
41
+ } else {
42
+ data += `
43
+ ${key}=${value}`;
44
+ }
45
+ await this.writeFile({ filePath, data });
46
+ console.log(`${key} set to ${value} in ENV file.`);
47
+ return data;
48
+ }
49
+ async getEnvValue(key) {
50
+ try {
51
+ const data = await this.readFile(this.filePath);
52
+ const regex = new RegExp(`^${key}=(.*)$`, "m");
53
+ const match = data.match(regex);
54
+ return match?.[1] || null;
55
+ } catch (err) {
56
+ console.error(`Error reading ENV value: ${err}`);
57
+ return null;
58
+ }
59
+ }
60
+ async setEnvValue(key, value) {
61
+ try {
62
+ const data = await this.readFile(this.filePath);
63
+ await this.updateEnvData({ key, value, data });
64
+ } catch (err) {
65
+ console.error(`Error writing ENV value: ${err}`);
66
+ }
67
+ }
68
+ };
69
+ var FileService = class {
70
+ /**
71
+ *
72
+ * @param inputFile the file in the starter files directory to copy
73
+ * @param outputFilePath the destination path
74
+ * @param replaceIfExists flag to replace if it exists
75
+ * @returns
76
+ */
77
+ async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
78
+ const __filename = fileURLToPath(import.meta.url);
79
+ const __dirname = path.dirname(__filename);
80
+ const filePath = path.resolve(__dirname, "..", "starter-files", inputFile);
81
+ const fileString = fs2__default.readFileSync(filePath, "utf8");
82
+ if (fs2__default.existsSync(outputFilePath) && !replaceIfExists) {
83
+ console.log(`${outputFilePath} already exists`);
84
+ return false;
85
+ }
86
+ await fsExtra.outputFile(outputFilePath, fileString);
87
+ return true;
88
+ }
89
+ async setupEnvFile({ dbUrl }) {
90
+ const envPath = path.join(process.cwd(), ".env.development");
91
+ await fsExtra.ensureFile(envPath);
92
+ const fileEnvService = new FileEnvService(envPath);
93
+ await fileEnvService.setEnvValue("DB_URL", dbUrl);
94
+ }
95
+ getFirstExistingFile(files) {
96
+ for (const f of files) {
97
+ if (fs2__default.existsSync(f)) {
98
+ return f;
99
+ }
100
+ }
101
+ throw new Error("Missing required file, checked the following paths: " + files.join(", "));
102
+ }
103
+ replaceValuesInFile({
104
+ filePath,
105
+ replacements
106
+ }) {
107
+ let fileContent = fs2__default.readFileSync(filePath, "utf8");
108
+ replacements.forEach(({ search, replace }) => {
109
+ fileContent = fileContent.replaceAll(search, replace);
110
+ });
111
+ fs2__default.writeFileSync(filePath, fileContent);
112
+ }
113
+ };
114
+
115
+ export { EnvService, FileService };