@mastra/deployer 0.2.5 → 0.2.6-alpha.10

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 (40) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +95 -33
  2. package/dist/_tsup-dts-rollup.d.ts +95 -33
  3. package/dist/build/analyze.cjs +2 -2
  4. package/dist/build/analyze.js +1 -1
  5. package/dist/build/bundler.cjs +3 -3
  6. package/dist/build/bundler.js +1 -1
  7. package/dist/build/index.cjs +22 -24
  8. package/dist/build/index.d.cts +3 -4
  9. package/dist/build/index.d.ts +3 -4
  10. package/dist/build/index.js +6 -4
  11. package/dist/bundler/index.cjs +2 -2
  12. package/dist/bundler/index.js +1 -1
  13. package/dist/chunk-2ZPQX6BX.cjs +254 -0
  14. package/dist/chunk-4AYFLP6G.js +227 -0
  15. package/dist/chunk-5UBGPRKT.js +185 -0
  16. package/dist/{chunk-KLVSED7T.js → chunk-74KZVNKH.js} +8 -4
  17. package/dist/{chunk-OT6UKL2S.cjs → chunk-AE4CVAPK.cjs} +11 -0
  18. package/dist/{chunk-UTZ3434D.js → chunk-BDTZS3JM.js} +3 -0
  19. package/dist/chunk-DYQ225MJ.js +115 -0
  20. package/dist/chunk-I3UVE6EH.cjs +161 -0
  21. package/dist/{chunk-XEFBJH3T.js → chunk-IKPL4RGG.js} +11 -0
  22. package/dist/chunk-NCROGJGB.cjs +142 -0
  23. package/dist/{chunk-NWERLYTR.cjs → chunk-P5SATU7G.cjs} +3 -0
  24. package/dist/chunk-VFZVVUQE.cjs +198 -0
  25. package/dist/chunk-WB3T6NKI.js +133 -0
  26. package/dist/{chunk-NXBTVZHO.cjs → chunk-WFC3CUZ3.cjs} +14 -10
  27. package/dist/index.cjs +12 -11
  28. package/dist/index.js +7 -6
  29. package/dist/server/index.cjs +617 -2682
  30. package/dist/server/index.js +512 -2577
  31. package/dist/services/index.cjs +19 -0
  32. package/dist/services/index.d.cts +3 -0
  33. package/dist/services/index.d.ts +3 -0
  34. package/dist/services/index.js +2 -0
  35. package/dist/templates/instrumentation-template.js +25 -30
  36. package/package.json +15 -4
  37. package/dist/chunk-7GYBZLVN.cjs +0 -286
  38. package/dist/chunk-KFOGAPGX.cjs +0 -433
  39. package/dist/chunk-PUX2FDGX.js +0 -252
  40. package/dist/chunk-ZAXXMFXX.js +0 -399
@@ -74,6 +74,17 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform) {
74
74
  find: /^\#server$/,
75
75
  replacement: url.fileURLToPath(undefined("@mastra/deployer/server")).replaceAll("\\", "/")
76
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
+ },
77
88
  { find: /^\#mastra$/, replacement: normalizedEntryFile }
78
89
  ]
79
90
  }),
@@ -115,6 +115,9 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
115
115
  if (id === "#mastra") {
116
116
  return normalizedMastraEntry;
117
117
  }
118
+ if (id.startsWith("@mastra/server")) {
119
+ return fileURLToPath(import.meta.resolve(id));
120
+ }
118
121
  }
119
122
  },
120
123
  json(),
@@ -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 };
@@ -0,0 +1,161 @@
1
+ 'use strict';
2
+
3
+ var chunk2ZPQX6BX_cjs = require('./chunk-2ZPQX6BX.cjs');
4
+ var chunkP5SATU7G_cjs = require('./chunk-P5SATU7G.cjs');
5
+ var chunkAE4CVAPK_cjs = require('./chunk-AE4CVAPK.cjs');
6
+ var rollup = require('rollup');
7
+ var babel = require('@babel/core');
8
+ var esbuild = require('rollup-plugin-esbuild');
9
+ var commonjs = require('@rollup/plugin-commonjs');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
32
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
33
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
34
+
35
+ async function getInputOptions2(entryFile, platform) {
36
+ const inputOptions = await chunkAE4CVAPK_cjs.getInputOptions(
37
+ entryFile,
38
+ {
39
+ dependencies: /* @__PURE__ */ new Map(),
40
+ externalDependencies: /* @__PURE__ */ new Set(),
41
+ invalidChunks: /* @__PURE__ */ new Set()
42
+ },
43
+ platform
44
+ );
45
+ if (Array.isArray(inputOptions.plugins)) {
46
+ inputOptions.plugins = inputOptions.plugins.filter(
47
+ // @ts-ignore
48
+ (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
49
+ );
50
+ inputOptions.plugins.push(chunkP5SATU7G_cjs.aliasHono());
51
+ }
52
+ return inputOptions;
53
+ }
54
+ async function createWatcher(inputOptions, outputOptions) {
55
+ const watcher = await rollup.watch({
56
+ ...inputOptions,
57
+ output: {
58
+ ...outputOptions,
59
+ format: "esm",
60
+ entryFileNames: "[name].mjs",
61
+ chunkFileNames: "[name].mjs"
62
+ }
63
+ });
64
+ return watcher;
65
+ }
66
+
67
+ // src/build/babel/remove-all-options-server.ts
68
+ function removeAllOptionsExceptServer(result) {
69
+ return chunk2ZPQX6BX_cjs.removeAllOptionsFromMastraExcept(result, "server");
70
+ }
71
+ function getServerOptionsBundler(entryFile, result) {
72
+ return rollup.rollup({
73
+ logLevel: "silent",
74
+ input: {
75
+ "server-config": entryFile
76
+ },
77
+ treeshake: "smallest",
78
+ plugins: [
79
+ // transpile typescript to something we understand
80
+ esbuild__default.default({
81
+ target: "node20",
82
+ platform: "node",
83
+ minify: false
84
+ }),
85
+ commonjs__default.default({
86
+ extensions: [".js", ".ts"],
87
+ strictRequires: "strict",
88
+ transformMixedEsModules: true,
89
+ ignoreTryCatch: false
90
+ }),
91
+ {
92
+ name: "get-server-config",
93
+ transform(code, id) {
94
+ if (id !== entryFile) {
95
+ return;
96
+ }
97
+ return new Promise((resolve, reject) => {
98
+ babel__namespace.transform(
99
+ code,
100
+ {
101
+ babelrc: false,
102
+ configFile: false,
103
+ filename: id,
104
+ plugins: [removeAllOptionsExceptServer(result)]
105
+ },
106
+ (err, result2) => {
107
+ if (err) {
108
+ return reject(err);
109
+ }
110
+ resolve({
111
+ code: result2.code,
112
+ map: result2.map
113
+ });
114
+ }
115
+ );
116
+ });
117
+ }
118
+ },
119
+ // let esbuild remove all unused imports
120
+ esbuild__default.default({
121
+ target: "node20",
122
+ platform: "node",
123
+ minify: false
124
+ }),
125
+ {
126
+ name: "cleanup",
127
+ transform(code, id) {
128
+ if (id !== entryFile) {
129
+ return;
130
+ }
131
+ return chunk2ZPQX6BX_cjs.recursiveRemoveNonReferencedNodes(code);
132
+ }
133
+ },
134
+ // let esbuild remove all unused imports
135
+ esbuild__default.default({
136
+ target: "node20",
137
+ platform: "node",
138
+ minify: false
139
+ })
140
+ ]
141
+ });
142
+ }
143
+ async function getServerOptions(entryFile, outputDir) {
144
+ const result = {
145
+ hasCustomConfig: false
146
+ };
147
+ const bundle = await getServerOptionsBundler(entryFile, result);
148
+ await bundle.write({
149
+ dir: outputDir,
150
+ format: "es",
151
+ entryFileNames: "[name].mjs"
152
+ });
153
+ if (result.hasCustomConfig) {
154
+ return (await import(`file:${outputDir}/server-config.mjs`)).server;
155
+ }
156
+ return null;
157
+ }
158
+
159
+ exports.createWatcher = createWatcher;
160
+ exports.getInputOptions = getInputOptions2;
161
+ exports.getServerOptions = getServerOptions;
@@ -64,6 +64,17 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform) {
64
64
  find: /^\#server$/,
65
65
  replacement: fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/")
66
66
  },
67
+ {
68
+ find: /^\@mastra\/server\/(.*)/,
69
+ replacement: `@mastra/server/$1`,
70
+ customResolver: (id) => {
71
+ if (id.startsWith("@mastra/server")) {
72
+ return {
73
+ id: fileURLToPath(import.meta.resolve(id))
74
+ };
75
+ }
76
+ }
77
+ },
67
78
  { find: /^\#mastra$/, replacement: normalizedEntryFile }
68
79
  ]
69
80
  }),
@@ -0,0 +1,142 @@
1
+ 'use strict';
2
+
3
+ var fs2 = require('fs');
4
+ var path = require('path');
5
+ var url = require('url');
6
+ var fsExtra = require('fs-extra/esm');
7
+
8
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ function _interopNamespace(e) {
12
+ if (e && e.__esModule) return e;
13
+ var n = Object.create(null);
14
+ if (e) {
15
+ Object.keys(e).forEach(function (k) {
16
+ if (k !== 'default') {
17
+ var d = Object.getOwnPropertyDescriptor(e, k);
18
+ Object.defineProperty(n, k, d.get ? d : {
19
+ enumerable: true,
20
+ get: function () { return e[k]; }
21
+ });
22
+ }
23
+ });
24
+ }
25
+ n.default = e;
26
+ return Object.freeze(n);
27
+ }
28
+
29
+ var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
30
+ var path__default = /*#__PURE__*/_interopDefault(path);
31
+ var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
32
+
33
+ // src/services/env.ts
34
+ var EnvService = class {
35
+ };
36
+ var FileEnvService = class extends EnvService {
37
+ filePath;
38
+ constructor(filePath) {
39
+ super();
40
+ this.filePath = filePath;
41
+ }
42
+ readFile(filePath) {
43
+ return new Promise((resolve, reject) => {
44
+ fs2__namespace.readFile(filePath, "utf8", (err, data) => {
45
+ if (err) reject(err);
46
+ else resolve(data);
47
+ });
48
+ });
49
+ }
50
+ writeFile({ filePath, data }) {
51
+ return new Promise((resolve, reject) => {
52
+ fs2__namespace.writeFile(filePath, data, "utf8", (err) => {
53
+ if (err) reject(err);
54
+ else resolve();
55
+ });
56
+ });
57
+ }
58
+ async updateEnvData({
59
+ key,
60
+ value,
61
+ filePath = this.filePath,
62
+ data
63
+ }) {
64
+ const regex = new RegExp(`^${key}=.*$`, "m");
65
+ if (data.match(regex)) {
66
+ data = data.replace(regex, `${key}=${value}`);
67
+ } else {
68
+ data += `
69
+ ${key}=${value}`;
70
+ }
71
+ await this.writeFile({ filePath, data });
72
+ console.log(`${key} set to ${value} in ENV file.`);
73
+ return data;
74
+ }
75
+ async getEnvValue(key) {
76
+ try {
77
+ const data = await this.readFile(this.filePath);
78
+ const regex = new RegExp(`^${key}=(.*)$`, "m");
79
+ const match = data.match(regex);
80
+ return match?.[1] || null;
81
+ } catch (err) {
82
+ console.error(`Error reading ENV value: ${err}`);
83
+ return null;
84
+ }
85
+ }
86
+ async setEnvValue(key, value) {
87
+ try {
88
+ const data = await this.readFile(this.filePath);
89
+ await this.updateEnvData({ key, value, data });
90
+ } catch (err) {
91
+ console.error(`Error writing ENV value: ${err}`);
92
+ }
93
+ }
94
+ };
95
+ var FileService = class {
96
+ /**
97
+ *
98
+ * @param inputFile the file in the starter files directory to copy
99
+ * @param outputFilePath the destination path
100
+ * @param replaceIfExists flag to replace if it exists
101
+ * @returns
102
+ */
103
+ async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
104
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-NCROGJGB.cjs', document.baseURI).href)));
105
+ const __dirname = path__default.default.dirname(__filename);
106
+ const filePath = path__default.default.resolve(__dirname, "..", "starter-files", inputFile);
107
+ const fileString = fs2__namespace.default.readFileSync(filePath, "utf8");
108
+ if (fs2__namespace.default.existsSync(outputFilePath) && !replaceIfExists) {
109
+ console.log(`${outputFilePath} already exists`);
110
+ return false;
111
+ }
112
+ await fsExtra__default.default.outputFile(outputFilePath, fileString);
113
+ return true;
114
+ }
115
+ async setupEnvFile({ dbUrl }) {
116
+ const envPath = path__default.default.join(process.cwd(), ".env.development");
117
+ await fsExtra__default.default.ensureFile(envPath);
118
+ const fileEnvService = new FileEnvService(envPath);
119
+ await fileEnvService.setEnvValue("DB_URL", dbUrl);
120
+ }
121
+ getFirstExistingFile(files) {
122
+ for (const f of files) {
123
+ if (fs2__namespace.default.existsSync(f)) {
124
+ return f;
125
+ }
126
+ }
127
+ throw new Error("Missing required file, checked the following paths: " + files.join(", "));
128
+ }
129
+ replaceValuesInFile({
130
+ filePath,
131
+ replacements
132
+ }) {
133
+ let fileContent = fs2__namespace.default.readFileSync(filePath, "utf8");
134
+ replacements.forEach(({ search, replace }) => {
135
+ fileContent = fileContent.replaceAll(search, replace);
136
+ });
137
+ fs2__namespace.default.writeFileSync(filePath, fileContent);
138
+ }
139
+ };
140
+
141
+ exports.EnvService = EnvService;
142
+ exports.FileService = FileService;
@@ -125,6 +125,9 @@ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
125
125
  if (id === "#mastra") {
126
126
  return normalizedMastraEntry;
127
127
  }
128
+ if (id.startsWith("@mastra/server")) {
129
+ return url.fileURLToPath(undefined(id));
130
+ }
128
131
  }
129
132
  },
130
133
  json__default.default(),
@@ -0,0 +1,198 @@
1
+ 'use strict';
2
+
3
+ var child_process = require('child_process');
4
+ var stream = require('stream');
5
+ var fs = require('fs');
6
+ var fsPromises = require('fs/promises');
7
+ var path = require('path');
8
+ var url = require('url');
9
+ var base = require('@mastra/core/base');
10
+ var fsExtra = require('fs-extra/esm');
11
+
12
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
16
+ var fsPromises__default = /*#__PURE__*/_interopDefault(fsPromises);
17
+ var path__default = /*#__PURE__*/_interopDefault(path);
18
+ var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
19
+
20
+ // src/deploy/log.ts
21
+ var createPinoStream = (logger) => {
22
+ return new stream.Transform({
23
+ transform(chunk, _encoding, callback) {
24
+ const line = chunk.toString().trim();
25
+ if (line) {
26
+ console.log(line);
27
+ logger.info(line);
28
+ }
29
+ callback(null, chunk);
30
+ }
31
+ });
32
+ };
33
+ function createChildProcessLogger({ logger, root }) {
34
+ const pinoStream = createPinoStream(logger);
35
+ return async ({ cmd, args, env }) => {
36
+ try {
37
+ const subprocess = child_process.spawn(cmd, args, {
38
+ cwd: root,
39
+ shell: true,
40
+ env
41
+ });
42
+ subprocess.stdout?.pipe(pinoStream);
43
+ subprocess.stderr?.pipe(pinoStream);
44
+ return new Promise((resolve, reject) => {
45
+ subprocess.on("close", (code) => {
46
+ pinoStream.end();
47
+ if (code === 0) {
48
+ resolve({ success: true });
49
+ } else {
50
+ reject(new Error(`Process exited with code ${code}`));
51
+ }
52
+ });
53
+ subprocess.on("error", (error) => {
54
+ pinoStream.end();
55
+ logger.error("Process failed", { error });
56
+ reject(error);
57
+ });
58
+ });
59
+ } catch (error) {
60
+ console.log(error);
61
+ logger.error("Process failed", { error });
62
+ pinoStream.end();
63
+ return { success: false, error };
64
+ }
65
+ };
66
+ }
67
+ var Deps = class extends base.MastraBase {
68
+ packageManager;
69
+ rootDir;
70
+ constructor(rootDir = process.cwd()) {
71
+ super({ component: "DEPLOYER", name: "DEPS" });
72
+ this.rootDir = rootDir;
73
+ this.packageManager = this.getPackageManager();
74
+ }
75
+ findLockFile(dir) {
76
+ const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
77
+ for (const file of lockFiles) {
78
+ if (fs__default.default.existsSync(path__default.default.join(dir, file))) {
79
+ return file;
80
+ }
81
+ }
82
+ const parentDir = path__default.default.resolve(dir, "..");
83
+ if (parentDir !== dir) {
84
+ return this.findLockFile(parentDir);
85
+ }
86
+ return null;
87
+ }
88
+ getPackageManager() {
89
+ const lockFile = this.findLockFile(this.rootDir);
90
+ switch (lockFile) {
91
+ case "pnpm-lock.yaml":
92
+ return "pnpm";
93
+ case "package-lock.json":
94
+ return "npm";
95
+ case "yarn.lock":
96
+ return "yarn";
97
+ case "bun.lock":
98
+ return "bun";
99
+ default:
100
+ return "npm";
101
+ }
102
+ }
103
+ async install({ dir = this.rootDir, packages = [] }) {
104
+ let runCommand = this.packageManager;
105
+ switch (this.packageManager) {
106
+ case "npm":
107
+ runCommand = `${this.packageManager} i`;
108
+ break;
109
+ case "pnpm":
110
+ runCommand = `${this.packageManager} --ignore-workspace install`;
111
+ break;
112
+ default:
113
+ runCommand = `${this.packageManager} ${packages?.length > 0 ? `add` : `install`}`;
114
+ }
115
+ const cpLogger = createChildProcessLogger({
116
+ logger: this.logger,
117
+ root: dir
118
+ });
119
+ return cpLogger({
120
+ cmd: runCommand,
121
+ args: packages,
122
+ env: {
123
+ PATH: process.env.PATH
124
+ }
125
+ });
126
+ }
127
+ async installPackages(packages) {
128
+ let runCommand = this.packageManager;
129
+ if (this.packageManager === "npm") {
130
+ runCommand = `${this.packageManager} i`;
131
+ } else {
132
+ runCommand = `${this.packageManager} add`;
133
+ }
134
+ const cpLogger = createChildProcessLogger({
135
+ logger: this.logger,
136
+ root: ""
137
+ });
138
+ return cpLogger({
139
+ cmd: `${runCommand}`,
140
+ args: packages,
141
+ env: {
142
+ PATH: process.env.PATH
143
+ }
144
+ });
145
+ }
146
+ async checkDependencies(dependencies) {
147
+ try {
148
+ const packageJsonPath = path__default.default.join(this.rootDir, "package.json");
149
+ try {
150
+ await fsPromises__default.default.access(packageJsonPath);
151
+ } catch {
152
+ return "No package.json file found in the current directory";
153
+ }
154
+ const packageJson = JSON.parse(await fsPromises__default.default.readFile(packageJsonPath, "utf-8"));
155
+ for (const dependency of dependencies) {
156
+ if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
157
+ return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
158
+ }
159
+ }
160
+ return "ok";
161
+ } catch (err) {
162
+ console.error(err);
163
+ return "Could not check dependencies";
164
+ }
165
+ }
166
+ async getProjectName() {
167
+ try {
168
+ const packageJsonPath = path__default.default.join(this.rootDir, "package.json");
169
+ const packageJson = await fsPromises__default.default.readFile(packageJsonPath, "utf-8");
170
+ const pkg = JSON.parse(packageJson);
171
+ return pkg.name;
172
+ } catch (err) {
173
+ throw err;
174
+ }
175
+ }
176
+ async getPackageVersion() {
177
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-VFZVVUQE.cjs', document.baseURI).href)));
178
+ const __dirname = path.dirname(__filename);
179
+ const pkgJsonPath = path__default.default.join(__dirname, "..", "..", "package.json");
180
+ const content = await fsExtra__default.default.readJSON(pkgJsonPath);
181
+ return content.version;
182
+ }
183
+ async addScriptsToPackageJson(scripts) {
184
+ const packageJson = JSON.parse(await fsPromises__default.default.readFile("package.json", "utf-8"));
185
+ packageJson.scripts = {
186
+ ...packageJson.scripts,
187
+ ...scripts
188
+ };
189
+ await fsPromises__default.default.writeFile("package.json", JSON.stringify(packageJson, null, 2));
190
+ }
191
+ };
192
+ var DepsService = class extends Deps {
193
+ };
194
+
195
+ exports.Deps = Deps;
196
+ exports.DepsService = DepsService;
197
+ exports.createChildProcessLogger = createChildProcessLogger;
198
+ exports.createPinoStream = createPinoStream;