@leanmcp/cli 0.5.11-alpha.73.30c304f → 0.5.11-alpha.76.3c8ac68

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 (2) hide show
  1. package/dist/index.js +86 -68
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import path13 from "path";
8
8
  import ora9 from "ora";
9
9
  import { createRequire } from "module";
10
10
  import { confirm as confirm4 } from "@inquirer/prompts";
11
- import { spawn as spawn4 } from "child_process";
11
+ import { spawn as spawn3 } from "child_process";
12
12
 
13
13
  // src/commands/dev.ts
14
14
  import { spawn } from "child_process";
@@ -875,7 +875,7 @@ async function devCommand() {
875
875
  __name(devCommand, "devCommand");
876
876
 
877
877
  // src/commands/build.ts
878
- import { spawn as spawn2 } from "child_process";
878
+ import { execa } from "execa";
879
879
  import ora2 from "ora";
880
880
  import path6 from "path";
881
881
  import fs6 from "fs-extra";
@@ -1062,6 +1062,21 @@ function mapPrimitiveType(tsType) {
1062
1062
  __name(mapPrimitiveType, "mapPrimitiveType");
1063
1063
 
1064
1064
  // src/commands/build.ts
1065
+ async function runTypeScriptCompiler(cwd) {
1066
+ try {
1067
+ await execa("npx", [
1068
+ "tsc"
1069
+ ], {
1070
+ cwd,
1071
+ preferLocal: true,
1072
+ all: true
1073
+ });
1074
+ } catch (error) {
1075
+ const output = error.all || error.stdout || error.stderr || error.message;
1076
+ throw new Error(output || `tsc exited with code ${error.exitCode}`);
1077
+ }
1078
+ }
1079
+ __name(runTypeScriptCompiler, "runTypeScriptCompiler");
1065
1080
  async function buildCommand() {
1066
1081
  const cwd = process.cwd();
1067
1082
  if (!await fs6.pathExists(path6.join(cwd, "main.ts"))) {
@@ -1105,32 +1120,19 @@ async function buildCommand() {
1105
1120
  }
1106
1121
  const tscSpinner = ora2("Compiling TypeScript...").start();
1107
1122
  try {
1108
- await new Promise((resolve, reject) => {
1109
- const tsc = spawn2("npx", [
1110
- "tsc"
1111
- ], {
1112
- cwd,
1113
- stdio: "pipe",
1114
- shell: true
1115
- });
1116
- let stdout = "";
1117
- let stderr = "";
1118
- tsc.stdout?.on("data", (data) => {
1119
- stdout += data;
1120
- });
1121
- tsc.stderr?.on("data", (data) => {
1122
- stderr += data;
1123
- });
1124
- tsc.on("close", (code) => {
1125
- if (code === 0) resolve();
1126
- else reject(new Error(stdout || stderr || `tsc exited with code ${code}`));
1127
- });
1128
- tsc.on("error", reject);
1129
- });
1123
+ await runTypeScriptCompiler(cwd);
1130
1124
  tscSpinner.succeed("TypeScript compiled");
1131
1125
  } catch (error) {
1132
1126
  tscSpinner.fail("TypeScript compilation failed");
1133
- logger.error(error instanceof Error ? error.message : String(error));
1127
+ const errorMessage = error instanceof Error ? error.message : String(error);
1128
+ const lines = errorMessage.split("\n");
1129
+ for (const line of lines) {
1130
+ if (line.includes("error TS")) {
1131
+ logger.error(line);
1132
+ } else if (line.trim()) {
1133
+ logger.log(line);
1134
+ }
1135
+ }
1134
1136
  process.exit(1);
1135
1137
  }
1136
1138
  const schemaSpinner = ora2("Generating schema metadata...").start();
@@ -1148,7 +1150,7 @@ async function buildCommand() {
1148
1150
  __name(buildCommand, "buildCommand");
1149
1151
 
1150
1152
  // src/commands/start.ts
1151
- import { spawn as spawn3 } from "child_process";
1153
+ import { spawn as spawn2 } from "child_process";
1152
1154
  import ora3 from "ora";
1153
1155
  import path7 from "path";
1154
1156
  import fs7 from "fs-extra";
@@ -1200,7 +1202,7 @@ async function startCommand() {
1200
1202
  const tscSpinner = ora3("Compiling TypeScript...").start();
1201
1203
  try {
1202
1204
  await new Promise((resolve, reject) => {
1203
- const tsc = spawn3("npx", [
1205
+ const tsc = spawn2("npx", [
1204
1206
  "tsc"
1205
1207
  ], {
1206
1208
  cwd,
@@ -1224,7 +1226,7 @@ async function startCommand() {
1224
1226
  process.exit(1);
1225
1227
  }
1226
1228
  logger.info("\nStarting production server...\n");
1227
- const server = spawn3("node", [
1229
+ const server = spawn2("node", [
1228
1230
  "dist/main.js"
1229
1231
  ], {
1230
1232
  cwd,
@@ -2050,23 +2052,29 @@ async function deployCommand(folderPath, options = {}) {
2050
2052
  logger.gray(` URL: ${existingConfig.url}`);
2051
2053
  logger.gray(` Last deployed: ${existingConfig.lastDeployedAt}
2052
2054
  `);
2053
- const choice = await select({
2054
- message: "What would you like to do?",
2055
- choices: [
2056
- {
2057
- value: "update",
2058
- name: `Update existing deployment '${existingConfig.projectName}'`
2059
- },
2060
- {
2061
- value: "new",
2062
- name: "Create a new project with a random name"
2063
- },
2064
- {
2065
- value: "cancel",
2066
- name: "Cancel deployment"
2067
- }
2068
- ]
2069
- });
2055
+ let choice;
2056
+ if (options.skipConfirm) {
2057
+ choice = "update";
2058
+ logger.info("Auto-updating existing deployment (--yes flag)\n");
2059
+ } else {
2060
+ choice = await select({
2061
+ message: "What would you like to do?",
2062
+ choices: [
2063
+ {
2064
+ value: "update",
2065
+ name: `Update existing deployment '${existingConfig.projectName}'`
2066
+ },
2067
+ {
2068
+ value: "new",
2069
+ name: "Create a new project with a random name"
2070
+ },
2071
+ {
2072
+ value: "cancel",
2073
+ name: "Cancel deployment"
2074
+ }
2075
+ ]
2076
+ });
2077
+ }
2070
2078
  if (choice === "cancel") {
2071
2079
  logger.gray("\nDeployment cancelled.\n");
2072
2080
  return;
@@ -2079,8 +2087,10 @@ async function deployCommand(folderPath, options = {}) {
2079
2087
  projectName = existingConfig.projectName;
2080
2088
  subdomain = existingConfig.subdomain;
2081
2089
  isUpdate = true;
2082
- logger.warn("\nUpdating existing deployment...");
2083
- logger.gray("The previous version will be replaced.\n");
2090
+ if (!options.skipConfirm) {
2091
+ logger.warn("\nUpdating existing deployment...");
2092
+ logger.gray("The previous version will be replaced.\n");
2093
+ }
2084
2094
  } else {
2085
2095
  projectName = generateProjectName();
2086
2096
  logger.info(`
@@ -2115,23 +2125,29 @@ Generated project name: ${chalk.bold(projectName)}
2115
2125
  if (matchingProject) {
2116
2126
  logger.warn(`Project '${folderName}' already exists.
2117
2127
  `);
2118
- const choice = await select({
2119
- message: "What would you like to do?",
2120
- choices: [
2121
- {
2122
- value: "update",
2123
- name: `Update existing project '${folderName}'`
2124
- },
2125
- {
2126
- value: "new",
2127
- name: "Create a new project with a random name"
2128
- },
2129
- {
2130
- value: "cancel",
2131
- name: "Cancel deployment"
2132
- }
2133
- ]
2134
- });
2128
+ let choice;
2129
+ if (options.skipConfirm) {
2130
+ choice = "update";
2131
+ logger.info("Auto-updating existing project (--yes flag)\n");
2132
+ } else {
2133
+ choice = await select({
2134
+ message: "What would you like to do?",
2135
+ choices: [
2136
+ {
2137
+ value: "update",
2138
+ name: `Update existing project '${folderName}'`
2139
+ },
2140
+ {
2141
+ value: "new",
2142
+ name: "Create a new project with a random name"
2143
+ },
2144
+ {
2145
+ value: "cancel",
2146
+ name: "Cancel deployment"
2147
+ }
2148
+ ]
2149
+ });
2150
+ }
2135
2151
  if (choice === "cancel") {
2136
2152
  logger.gray("\nDeployment cancelled.\n");
2137
2153
  return;
@@ -2140,8 +2156,10 @@ Generated project name: ${chalk.bold(projectName)}
2140
2156
  existingProject = matchingProject;
2141
2157
  projectName = matchingProject.name;
2142
2158
  isUpdate = true;
2143
- logger.warn("\nWARNING: This will replace the existing deployment.");
2144
- logger.gray("The previous version will be overwritten.\n");
2159
+ if (!options.skipConfirm) {
2160
+ logger.warn("\nWARNING: This will replace the existing deployment.");
2161
+ logger.gray("The previous version will be overwritten.\n");
2162
+ }
2145
2163
  } else {
2146
2164
  projectName = generateProjectName();
2147
2165
  logger.info(`
@@ -4184,7 +4202,7 @@ NODE_ENV=development
4184
4202
  const installSpinner = ora9("Installing dependencies...").start();
4185
4203
  try {
4186
4204
  await new Promise((resolve, reject) => {
4187
- const npmInstall = spawn4("npm", [
4205
+ const npmInstall = spawn3("npm", [
4188
4206
  "install"
4189
4207
  ], {
4190
4208
  cwd: targetDir,
@@ -4217,7 +4235,7 @@ NODE_ENV=development
4217
4235
  });
4218
4236
  if (shouldStartDev) {
4219
4237
  logger.log("\nStarting development server...\n", chalk.cyan);
4220
- const devServer = spawn4("npm", [
4238
+ const devServer = spawn3("npm", [
4221
4239
  "run",
4222
4240
  "dev"
4223
4241
  ], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leanmcp/cli",
3
- "version": "0.5.11-alpha.73.30c304f",
3
+ "version": "0.5.11-alpha.76.3c8ac68",
4
4
  "description": "Command-line interface for scaffolding LeanMCP projects",
5
5
  "bin": {
6
6
  "leanmcp": "bin/leanmcp.js"
@@ -34,6 +34,7 @@
34
34
  "chalk": "^5.3.0",
35
35
  "chokidar": "^4.0.0",
36
36
  "commander": "^12.0.0",
37
+ "execa": "^9.5.0",
37
38
  "fs-extra": "^11.2.0",
38
39
  "glob": "^11.0.0",
39
40
  "ora": "^8.1.0",