create-medusa-app 2.22.5 → 2.22.6

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.22.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @medusajs/deps@2.22.6
9
+ - @medusajs/telemetry@2.22.6
10
+
3
11
  ## 2.22.5
4
12
 
5
13
  ### Patch Changes
@@ -0,0 +1,10 @@
1
+ import { ProjectCreatorFactory, } from "../utils/project-creator/index.js";
2
+ /**
3
+ * Command handler to create a Medusa project or plugin
4
+ */
5
+ export default async (args, options) => {
6
+ const projectCreator = await ProjectCreatorFactory.create(args, options);
7
+ await projectCreator.create({
8
+ verbose: options.verbose,
9
+ });
10
+ };
package/dist/index.js CHANGED
File without changes
@@ -0,0 +1,76 @@
1
+ import { spawnSync } from "child_process";
2
+ import fs from "fs";
3
+ import os from "os";
4
+ import path from "path";
5
+ import inquirer from "inquirer";
6
+ import logMessage from "./log-message.js";
7
+ import pkg from '@medusajs/telemetry';
8
+ const { Store, track } = pkg;
9
+ const CLAUDE_DIR = path.join(os.homedir(), ".claude");
10
+ const INSTALLED_PLUGINS_FILE = path.join(CLAUDE_DIR, "plugins", "installed_plugins.json");
11
+ const PLUGIN_ID = "medusa-dev@medusa";
12
+ const CONFIG_KEY = "claude-code-plugin.prompted";
13
+ function isClaudeCodePresent() {
14
+ return !!process.env.CLAUDE_CODE || fs.existsSync(CLAUDE_DIR);
15
+ }
16
+ function isNonInteractive() {
17
+ return process.env.CI === "true" || !process.stdout.isTTY;
18
+ }
19
+ function isPluginInstalled() {
20
+ if (!fs.existsSync(INSTALLED_PLUGINS_FILE)) {
21
+ return false;
22
+ }
23
+ try {
24
+ const data = JSON.parse(fs.readFileSync(INSTALLED_PLUGINS_FILE, "utf-8"));
25
+ return !!data?.plugins?.[PLUGIN_ID];
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ function runInstall() {
32
+ try {
33
+ const marketplace = spawnSync("claude", ["plugin", "marketplace", "add", "medusajs/medusa-agent-skills"], { stdio: "inherit" });
34
+ if (marketplace.error) {
35
+ return false;
36
+ }
37
+ const install = spawnSync("claude", ["plugin", "install", PLUGIN_ID], {
38
+ stdio: "inherit",
39
+ });
40
+ return !install.error;
41
+ }
42
+ catch {
43
+ return false;
44
+ }
45
+ }
46
+ export async function promptClaudeCodePlugin() {
47
+ if (isNonInteractive() || !isClaudeCodePresent() || isPluginInstalled()) {
48
+ return;
49
+ }
50
+ const configStore = new Store();
51
+ console.log(configStore.config_.path);
52
+ if (configStore.getConfig(CONFIG_KEY)) {
53
+ return;
54
+ }
55
+ configStore.setConfig(CONFIG_KEY, true);
56
+ const { install } = await inquirer.prompt([
57
+ {
58
+ type: "confirm",
59
+ name: "install",
60
+ message: "Working with Medusa is easier with the Medusa Plugin for Claude Code. Would you like to install it?",
61
+ default: true,
62
+ },
63
+ ]);
64
+ track("CMA_CLAUDE_CODE_PLUGIN_PROMPT", {
65
+ install,
66
+ });
67
+ if (!install) {
68
+ return;
69
+ }
70
+ const success = runInstall();
71
+ if (!success) {
72
+ logMessage({
73
+ message: `Could not auto-install. To install manually, open Claude Code in your project and run:\n\n /plugin marketplace add medusajs/medusa-agent-skills\n`,
74
+ });
75
+ }
76
+ }
@@ -0,0 +1,77 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { isAbortError } from "./create-abort-controller.js";
4
+ import execute from "./execute.js";
5
+ import logMessage from "./log-message.js";
6
+ import { execFileSync } from "child_process";
7
+ const DEFAULT_REPO = "https://github.com/medusajs/dtc-starter";
8
+ const DEFAULT_PLUGIN_REPO = "https://github.com/medusajs/medusa-starter-plugin";
9
+ const BRANCH = "main";
10
+ const PLUGIN_BRANCH = "main";
11
+ export default async function cloneRepo({ directoryName = "", repoUrl, abortController, verbose = false, isPlugin = false, }) {
12
+ const defaultRepo = isPlugin ? DEFAULT_PLUGIN_REPO : DEFAULT_REPO;
13
+ const branch = isPlugin ? PLUGIN_BRANCH : BRANCH;
14
+ await execute([
15
+ `git clone ${repoUrl || defaultRepo} -b ${branch} ${directoryName} --depth 1`,
16
+ {
17
+ signal: abortController?.signal,
18
+ },
19
+ ], { verbose });
20
+ }
21
+ export async function runCloneRepo({ projectName, repoUrl, abortController, spinner, verbose = false, isPlugin = false, }) {
22
+ try {
23
+ await cloneRepo({
24
+ directoryName: projectName,
25
+ repoUrl,
26
+ abortController,
27
+ verbose,
28
+ isPlugin,
29
+ });
30
+ deleteGitDirectory(projectName);
31
+ }
32
+ catch (e) {
33
+ if (isAbortError(e)) {
34
+ process.exit();
35
+ }
36
+ spinner.stop();
37
+ logMessage({
38
+ message: `An error occurred while setting up your project: ${e}`,
39
+ type: "error",
40
+ });
41
+ }
42
+ }
43
+ function deleteGitDirectory(projectDirectory) {
44
+ try {
45
+ fs.rmSync(path.join(projectDirectory, ".git"), {
46
+ recursive: true,
47
+ force: true,
48
+ });
49
+ }
50
+ catch (error) {
51
+ deleteWithCommand(projectDirectory, ".git");
52
+ }
53
+ try {
54
+ fs.rmSync(path.join(projectDirectory, ".github"), {
55
+ recursive: true,
56
+ force: true,
57
+ });
58
+ }
59
+ catch (error) {
60
+ deleteWithCommand(projectDirectory, ".github");
61
+ }
62
+ }
63
+ /**
64
+ * Useful for deleting directories when fs methods fail (e.g., with Yarn v3)
65
+ */
66
+ function deleteWithCommand(projectDirectory, dirName) {
67
+ const dirPath = path.normalize(path.join(projectDirectory, dirName));
68
+ if (!fs.existsSync(dirPath)) {
69
+ return;
70
+ }
71
+ if (process.platform === "win32") {
72
+ execFileSync("cmd", ["/c", "rmdir", "/s", "/q", dirPath]);
73
+ }
74
+ else {
75
+ execFileSync("rm", ["-rf", dirPath]);
76
+ }
77
+ }
@@ -0,0 +1,11 @@
1
+ export default (processManager) => {
2
+ const abortController = new AbortController();
3
+ processManager.onTerminated(() => abortController.abort());
4
+ return abortController;
5
+ };
6
+ export const isAbortError = (e) => e !== null && typeof e === "object" && "code" in e && e.code === "ABORT_ERR";
7
+ export const getAbortError = () => {
8
+ return {
9
+ code: "ABORT_ERR",
10
+ };
11
+ };
@@ -0,0 +1,188 @@
1
+ import { EOL } from "os";
2
+ import postgresClient, { DEFAULT_HOST, DEFAULT_PORT, } from "./postgres-client.js";
3
+ import inquirer from "inquirer";
4
+ import logMessage from "./log-message.js";
5
+ import formatConnectionString from "./format-connection-string.js";
6
+ import terminalLink from "terminal-link";
7
+ export default async function createDb({ client, db }) {
8
+ await client.query(`CREATE DATABASE "${db}"`);
9
+ }
10
+ async function doesDbExist(client, dbName) {
11
+ const result = await client.query(`SELECT datname FROM pg_catalog.pg_database WHERE datname='${dbName}';`);
12
+ return !!result.rowCount;
13
+ }
14
+ export async function runCreateDb({ client, dbName, spinner, }) {
15
+ let newClient = client;
16
+ try {
17
+ // create postgres database
18
+ await createDb({
19
+ client,
20
+ db: dbName,
21
+ });
22
+ // create a new connection with database selected
23
+ await client.end();
24
+ newClient = await postgresClient({
25
+ user: client.user,
26
+ password: client.password,
27
+ database: dbName,
28
+ });
29
+ }
30
+ catch (e) {
31
+ spinner.stop();
32
+ logMessage({
33
+ message: `An error occurred while trying to create your database: ${e}`,
34
+ type: "error",
35
+ });
36
+ }
37
+ return newClient;
38
+ }
39
+ /**
40
+ * Connects to the server's `postgres` maintenance database, falling back to the
41
+ * connection's default database (which Postgres resolves to the username).
42
+ */
43
+ async function connectToMaintenanceDb(connection) {
44
+ try {
45
+ return await postgresClient({
46
+ ...connection,
47
+ database: "postgres",
48
+ });
49
+ }
50
+ catch (e) {
51
+ return await postgresClient(connection);
52
+ }
53
+ }
54
+ async function getForDbName({ dbName, verbose = false, }) {
55
+ let client;
56
+ let postgresUsername = "postgres";
57
+ let postgresPassword = "";
58
+ const defaultConnectionOptions = {
59
+ host: DEFAULT_HOST,
60
+ port: DEFAULT_PORT,
61
+ };
62
+ try {
63
+ client = await postgresClient({
64
+ user: postgresUsername,
65
+ password: postgresPassword,
66
+ ...defaultConnectionOptions,
67
+ });
68
+ }
69
+ catch (e) {
70
+ if (verbose) {
71
+ logMessage({
72
+ message: `The following error occurred when connecting to the database: ${e}`,
73
+ type: "verbose",
74
+ });
75
+ }
76
+ logMessage({
77
+ message: `${EOL}Couldn't connect to PostgreSQL with the default credentials (user "postgres" without a password).${EOL}Medusa needs to connect to your PostgreSQL server to create the database of your project, so please enter your PostgreSQL credentials below.${EOL}`,
78
+ });
79
+ // ask for the user's postgres credentials
80
+ const answers = await inquirer.prompt([
81
+ {
82
+ type: "input",
83
+ name: "postgresUsername",
84
+ message: "Enter your Postgres username",
85
+ default: "postgres",
86
+ validate: (input) => {
87
+ return typeof input === "string" && input.length > 0;
88
+ },
89
+ },
90
+ {
91
+ type: "password",
92
+ name: "postgresPassword",
93
+ message: "Enter your Postgres password",
94
+ },
95
+ {
96
+ type: "input",
97
+ name: "newDbName",
98
+ message: "Enter the name of the database to create for your Medusa project",
99
+ default: dbName,
100
+ validate: (input) => {
101
+ return typeof input === "string" && input.length > 0;
102
+ },
103
+ },
104
+ ]);
105
+ postgresUsername = answers.postgresUsername;
106
+ postgresPassword = answers.postgresPassword;
107
+ dbName = answers.newDbName;
108
+ try {
109
+ client = await connectToMaintenanceDb({
110
+ user: postgresUsername,
111
+ password: postgresPassword,
112
+ ...defaultConnectionOptions,
113
+ });
114
+ }
115
+ catch (e) {
116
+ logMessage({
117
+ message: `Couldn't connect to PostgreSQL because of the following error: ${e}.${EOL}${EOL}Make sure you have PostgreSQL installed and the credentials you provided are correct.${EOL}${EOL}If you keep running into this issue despite having PostgreSQL installed, please check out our ${terminalLink("troubleshooting guides", "https://docs.medusajs.com/resources/troubleshooting/database-errors")}.`,
118
+ type: "error",
119
+ });
120
+ }
121
+ }
122
+ // check if database exists
123
+ if (await doesDbExist(client, dbName)) {
124
+ const { newDbName } = await inquirer.prompt([
125
+ {
126
+ type: "input",
127
+ name: "newDbName",
128
+ message: `A database already exists with the name ${dbName}, please enter a name for the database:`,
129
+ default: dbName,
130
+ validate: (input) => {
131
+ return (typeof input === "string" && input.length > 0 && input !== dbName);
132
+ },
133
+ },
134
+ ]);
135
+ dbName = newDbName;
136
+ }
137
+ // format connection string
138
+ const dbConnectionString = formatConnectionString({
139
+ user: postgresUsername,
140
+ password: postgresPassword,
141
+ host: client.host,
142
+ db: dbName,
143
+ });
144
+ return {
145
+ client,
146
+ dbConnectionString,
147
+ dbName,
148
+ };
149
+ }
150
+ async function getForDbUrl({ dbUrl, verbose = false, }) {
151
+ let client;
152
+ try {
153
+ client = await postgresClient({
154
+ connectionString: dbUrl,
155
+ });
156
+ }
157
+ catch (e) {
158
+ if (verbose) {
159
+ logMessage({
160
+ message: `The following error occurred when connecting to the database: ${e}`,
161
+ type: "verbose",
162
+ });
163
+ }
164
+ logMessage({
165
+ message: `Couldn't connect to PostgreSQL using the database URL you passed. Make sure it's correct and try again.`,
166
+ type: "error",
167
+ });
168
+ }
169
+ return {
170
+ client,
171
+ dbConnectionString: dbUrl,
172
+ };
173
+ }
174
+ export async function getDbClientAndCredentials({ dbName = "", dbUrl = "", verbose = false, }) {
175
+ // Check the db-url first, because the dbName is always defined in MedusaProjectCreator->create()->initializeProject()->setupDatabase()
176
+ if (dbUrl) {
177
+ return await getForDbUrl({
178
+ dbUrl,
179
+ verbose,
180
+ });
181
+ }
182
+ else {
183
+ return await getForDbName({
184
+ dbName,
185
+ verbose,
186
+ });
187
+ }
188
+ }
@@ -0,0 +1,51 @@
1
+ import { exec, spawnSync } from "child_process";
2
+ import util from "util";
3
+ import { getAbortError } from "./create-abort-controller.js";
4
+ const promiseExec = util.promisify(exec);
5
+ const execute = async (command, { verbose = false, needOutput = false }) => {
6
+ if (verbose) {
7
+ const [commandStr, options] = command;
8
+ const childProcess = spawnSync(commandStr, {
9
+ ...options,
10
+ shell: true,
11
+ stdio: needOutput
12
+ ? "pipe"
13
+ : [process.stdin, process.stdout, process.stderr],
14
+ env: {
15
+ ...process.env,
16
+ ...(options.env || {}),
17
+ },
18
+ });
19
+ if (childProcess.error || childProcess.status !== 0) {
20
+ throw (childProcess.error ||
21
+ childProcess.stderr?.toString() ||
22
+ `${commandStr} failed with status ${childProcess.status}`);
23
+ }
24
+ if (childProcess.signal &&
25
+ ["SIGINT", "SIGTERM"].includes(childProcess.signal)) {
26
+ throw getAbortError();
27
+ }
28
+ if (needOutput) {
29
+ console.log(childProcess.stdout?.toString() || childProcess.stderr?.toString());
30
+ }
31
+ return {
32
+ stdout: childProcess.stdout?.toString() || "",
33
+ stderr: childProcess.stderr?.toString() || "",
34
+ };
35
+ }
36
+ else {
37
+ const [commandStr, options] = command;
38
+ const childProcess = await promiseExec(commandStr, {
39
+ ...options,
40
+ env: {
41
+ ...process.env,
42
+ ...(options?.env || {}),
43
+ },
44
+ });
45
+ return {
46
+ stdout: childProcess.stdout,
47
+ stderr: childProcess.stderr,
48
+ };
49
+ }
50
+ };
51
+ export default execute;
@@ -0,0 +1,87 @@
1
+ import boxen from "boxen";
2
+ import chalk from "chalk";
3
+ import { emojify } from "node-emoji";
4
+ import terminalLink from "terminal-link";
5
+ const facts = [
6
+ "Specify a product's availability in one or more sales channels.",
7
+ "Payment providers can be configured per region.",
8
+ "Tax-inclusive pricing allows you to set prices for products and shipping options while delegating tax calculations to Medusa.",
9
+ "Medusa provides multi-currency and region support, with full control over prices for each currency and region.",
10
+ "Organize customers by customer groups and set special prices for them.",
11
+ "Specify the inventory of products per location and sales channel.",
12
+ "Publishable-API Keys allow you to send scoped requests to the server's store API routes.",
13
+ "API Routes expose business logic to clients, such as storefronts and admin customizations.",
14
+ "Subscribers are asynchronous functions that are executed when an event is emitted.",
15
+ "Data models represent tables in the database. They are created using Medusa's Data Modeling Language (DML).",
16
+ "Medusa's store API routes are prefixed by /store. The admin API routes are prefixed by /admin.",
17
+ "The JS SDK allows you to send requests to the Medusa server from your storefront or admin customizations.",
18
+ "Modules are reusable packages of functionalities related to a single commerce domain or integration.",
19
+ "Modules have a main service that provides data-management and integration functionalities.",
20
+ "Modules allow you to replace an entire functionality with your custom logic.",
21
+ "Infrastructure Modules are interchangeable modules that implement features and integrations related to the Medusa server's infrastructure.",
22
+ "Commerce Modules are built-in modules that provide core commerce logic specific to domains like Product, Cart and Order.",
23
+ "Workflows are a series of queries and actions, called steps, that complete a task.",
24
+ "A workflow's steps can be retried or rolled back in case of an error.",
25
+ `Medusa provides ${terminalLink("Claude Code plugins", "https://github.com/medusajs/medusa-claude-plugins")} to facilitate your development.`,
26
+ "Medusa provides an MCP server at https://docs.medusajs.com/mcp to support your learning and development experience with AI agents",
27
+ `Medusa is optimized to build custom commerce software with AI agents through its MCP server and ${terminalLink("Claude Code plugins", "https://github.com/medusajs/medusa-claude-plugins")}.`,
28
+ ];
29
+ export const getFact = () => {
30
+ const randIndex = Math.floor(Math.random() * facts.length);
31
+ return facts[randIndex];
32
+ };
33
+ export const showFact = ({ spinner, title, verbose, }) => {
34
+ const fact = getFact();
35
+ if (verbose) {
36
+ spinner.stopAndPersist({
37
+ symbol: chalk.cyan("⠋"),
38
+ text: title,
39
+ });
40
+ }
41
+ else {
42
+ spinner.text = `${title}\n${boxen(`${fact}`, {
43
+ title: chalk.cyan(`${emojify(":bulb:")} Medusa Tips`),
44
+ titleAlignment: "center",
45
+ textAlignment: "center",
46
+ padding: 1,
47
+ margin: 1,
48
+ })}`;
49
+ }
50
+ };
51
+ export const createFactBox = ({ spinner, title, processManager, verbose, }) => {
52
+ showFact({ spinner, title, verbose });
53
+ const interval = setInterval(() => {
54
+ showFact({ spinner, title, verbose });
55
+ }, 10000);
56
+ processManager.addInterval(interval);
57
+ return interval;
58
+ };
59
+ export const resetFactBox = ({ interval, spinner, successMessage, processManager, newTitle, verbose, }) => {
60
+ if (interval) {
61
+ clearInterval(interval);
62
+ }
63
+ spinner.succeed(chalk.green(successMessage)).start();
64
+ let newInterval = null;
65
+ if (newTitle) {
66
+ newInterval = createFactBox({
67
+ spinner,
68
+ title: newTitle,
69
+ processManager,
70
+ verbose,
71
+ });
72
+ }
73
+ return newInterval;
74
+ };
75
+ export function displayFactBox({ interval, spinner, processManager, title = "", message = "", verbose = false, }) {
76
+ if (!message) {
77
+ return createFactBox({ spinner, title, processManager, verbose });
78
+ }
79
+ return resetFactBox({
80
+ interval,
81
+ spinner,
82
+ successMessage: message,
83
+ processManager,
84
+ newTitle: title,
85
+ verbose,
86
+ });
87
+ }
@@ -0,0 +1,17 @@
1
+ export function encodeDbValue(value) {
2
+ return encodeURIComponent(value);
3
+ }
4
+ export default ({ user, password, host, db }) => {
5
+ let connection = `postgres://`;
6
+ if (user) {
7
+ connection += encodeDbValue(user);
8
+ }
9
+ if (password) {
10
+ connection += `:${encodeDbValue(password)}`;
11
+ }
12
+ if (user || password) {
13
+ connection += "@";
14
+ }
15
+ connection += `${host}/${db}`;
16
+ return connection;
17
+ };
@@ -0,0 +1,10 @@
1
+ export const getCurrentOs = () => {
2
+ switch (process.platform) {
3
+ case "darwin":
4
+ return "macos";
5
+ case "linux":
6
+ return "linux";
7
+ default:
8
+ return "windows";
9
+ }
10
+ };
@@ -0,0 +1,21 @@
1
+ import chalk from "chalk";
2
+ import { program } from "commander";
3
+ import { logger } from "./logger.js";
4
+ export default ({ message, type = "info", stack }) => {
5
+ switch (type) {
6
+ case "info":
7
+ logger.info(chalk.white(message));
8
+ break;
9
+ case "success":
10
+ logger.info(chalk.green(message));
11
+ break;
12
+ case "warn":
13
+ logger.warn(chalk.yellow(message));
14
+ break;
15
+ case "verbose":
16
+ logger.info(`${chalk.bgYellowBright("VERBOSE LOG:")} ${message}`);
17
+ break;
18
+ case "error":
19
+ program.error(chalk.bold.red(message.trim() + (stack || "")));
20
+ }
21
+ };
@@ -0,0 +1,8 @@
1
+ import winston from "winston";
2
+ const consoleTransport = new winston.transports.Console({
3
+ format: winston.format.printf((log) => log.message),
4
+ });
5
+ const options = {
6
+ transports: [consoleTransport],
7
+ };
8
+ export const logger = winston.createLogger(options);
@@ -0,0 +1,55 @@
1
+ import { exec } from "child_process";
2
+ import fs from "fs";
3
+ import inquirer from "inquirer";
4
+ import path from "path";
5
+ import { displayFactBox } from "./facts.js";
6
+ import { updatePackageVersions } from "./update-package-versions.js";
7
+ export async function askForNextjsStarter() {
8
+ const { installNextjs } = await inquirer.prompt([
9
+ {
10
+ type: "confirm",
11
+ name: "installNextjs",
12
+ message: `Would you like to install the storefront? You can also install it later.`,
13
+ default: false,
14
+ },
15
+ ]);
16
+ return installNextjs;
17
+ }
18
+ export async function installNextjsStarter({ storefrontDirectory, factBoxOptions, packageManager, version, }) {
19
+ factBoxOptions.interval = displayFactBox({
20
+ ...factBoxOptions,
21
+ title: "Setting up storefront...",
22
+ });
23
+ const packageJsonPath = path.join(storefrontDirectory, "package.json");
24
+ let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
25
+ if (version) {
26
+ packageJson = updatePackageVersions(packageJsonPath, version, {
27
+ applyChanges: false,
28
+ });
29
+ }
30
+ // Update packageManager field to match user's chosen package manager
31
+ const packageManagerString = await packageManager.getPackageManagerString();
32
+ if (packageManagerString) {
33
+ packageJson.packageManager = packageManagerString;
34
+ }
35
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
36
+ const envTemplatePath = path.join(storefrontDirectory, ".env.template");
37
+ if (fs.existsSync(envTemplatePath)) {
38
+ fs.renameSync(envTemplatePath, path.join(storefrontDirectory, ".env.local"));
39
+ }
40
+ displayFactBox({
41
+ ...factBoxOptions,
42
+ message: `Storefront is set up in the ${storefrontDirectory} directory.`,
43
+ });
44
+ }
45
+ export function startNextjsStarter({ directory, abortController, verbose = false, packageManager, }) {
46
+ const command = packageManager.getCommandStr(`dev`);
47
+ const childProcess = exec(command, {
48
+ cwd: directory,
49
+ signal: abortController?.signal,
50
+ });
51
+ if (verbose) {
52
+ childProcess.stdout?.pipe(process.stdout);
53
+ childProcess.stderr?.pipe(process.stderr);
54
+ }
55
+ }
@@ -0,0 +1,15 @@
1
+ export const MIN_SUPPORTED_NODE_VERSION = "22.22.0";
2
+ export function getNodeVersion() {
3
+ return process.versions.node;
4
+ }
5
+ export function isNodeVersionSupported(version = getNodeVersion()) {
6
+ const current = version.split(".").map(Number);
7
+ const minimum = MIN_SUPPORTED_NODE_VERSION.split(".").map(Number);
8
+ for (let i = 0; i < minimum.length; i++) {
9
+ const part = current[i] ?? 0;
10
+ if (part !== minimum[i]) {
11
+ return part > minimum[i];
12
+ }
13
+ }
14
+ return true;
15
+ }