Skip to content

Commit b96c650

Browse files
committed
chore(cli): upgrade init templates to TS 6 and auto-inject mcp version
- typescript ^5.0.0 → ^6.0.0 (tsconfig: drop deprecated baseUrl) - tailwind-merge ^2.5.2 → ^3.0.0 - add @types/bun ^1.3.0 (replaces unavailable bun-types reference) - @mandujs/mcp "latest" → {{MCP_VERSION}} template token, resolved at init time via a shared resolveSibling() helper alongside core/cli versions Verified end-to-end: mandu init → bun install (184 pkgs) → tsc --noEmit exits 0 under TS 6.0.2 strict.
1 parent 640c541 commit b96c650

5 files changed

Lines changed: 38 additions & 24 deletions

File tree

packages/cli/src/commands/init.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ interface CopyOptions {
7070
theme: boolean;
7171
coreVersion: string;
7272
cliVersion: string;
73+
mcpVersion: string;
7374
}
7475

7576
function shouldSkipFile(relativePath: string, options: CopyOptions): boolean {
@@ -129,6 +130,7 @@ async function copyDir(
129130
content = content.replace(/\{\{PROJECT_NAME\}\}/g, options.projectName);
130131
content = content.replace(/\{\{CORE_VERSION\}\}/g, options.coreVersion);
131132
content = content.replace(/\{\{CLI_VERSION\}\}/g, options.cliVersion);
133+
content = content.replace(/\{\{MCP_VERSION\}\}/g, options.mcpVersion);
132134

133135
// Add dark mode CSS variables if theme is enabled
134136
if (options.theme && currentRelativePath === "app/globals.css") {
@@ -182,31 +184,42 @@ function getTemplatesDir(): string {
182184
* Reads CLI/Core package versions at runtime and returns them as ^major.minor.0
183185
* Used to replace {{CORE_VERSION}}, {{CLI_VERSION}} in template package.json
184186
*/
185-
async function resolvePackageVersions(): Promise<{ coreVersion: string; cliVersion: string }> {
187+
async function resolvePackageVersions(): Promise<{
188+
coreVersion: string;
189+
cliVersion: string;
190+
mcpVersion: string;
191+
}> {
186192
const cliPkgPath = path.resolve(import.meta.dir, "../../package.json");
187193
const cliPkg = JSON.parse(await fs.readFile(cliPkgPath, "utf-8"));
188194
const cliVersion = cliPkg.version ?? "0.0.0";
189195

190-
// Read core from CLI's node_modules or workspace
191-
let coreVersion = cliVersion; // fallback: same as CLI version
192-
try {
193-
const corePkgPath = require.resolve("@mandujs/core/package.json", { paths: [path.resolve(import.meta.dir, "../..")] });
194-
const corePkg = JSON.parse(await fs.readFile(corePkgPath, "utf-8"));
195-
coreVersion = corePkg.version ?? coreVersion;
196-
} catch {
197-
// workspace environment: try direct path
196+
const resolveSibling = async (pkgName: string, workspaceDir: string): Promise<string> => {
198197
try {
199-
const workspacePath = path.resolve(import.meta.dir, "../../../core/package.json");
200-
const corePkg = JSON.parse(await fs.readFile(workspacePath, "utf-8"));
201-
coreVersion = corePkg.version ?? coreVersion;
198+
const pkgPath = require.resolve(`${pkgName}/package.json`, {
199+
paths: [path.resolve(import.meta.dir, "../..")],
200+
});
201+
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
202+
if (pkg.version) return pkg.version;
203+
} catch {
204+
// fall through to workspace lookup
205+
}
206+
try {
207+
const workspacePath = path.resolve(import.meta.dir, "../../../", workspaceDir, "package.json");
208+
const pkg = JSON.parse(await fs.readFile(workspacePath, "utf-8"));
209+
if (pkg.version) return pkg.version;
202210
} catch {
203211
// keep fallback
204212
}
205-
}
213+
return cliVersion;
214+
};
215+
216+
const coreVersion = await resolveSibling("@mandujs/core", "core");
217+
const mcpVersion = await resolveSibling("@mandujs/mcp", "mcp");
206218

207219
return {
208220
coreVersion: `^${coreVersion}`,
209221
cliVersion: `^${cliVersion}`,
222+
mcpVersion: `^${mcpVersion}`,
210223
};
211224
}
212225

@@ -331,7 +344,7 @@ export async function init(options: InitOptions = {}): Promise<boolean> {
331344
return false;
332345
}
333346

334-
const { coreVersion, cliVersion } = await resolvePackageVersions();
347+
const { coreVersion, cliVersion, mcpVersion } = await resolvePackageVersions();
335348

336349
const copyOptions: CopyOptions = {
337350
projectName,
@@ -340,6 +353,7 @@ export async function init(options: InitOptions = {}): Promise<boolean> {
340353
theme: themeEnabled,
341354
coreVersion,
342355
cliVersion,
356+
mcpVersion,
343357
};
344358

345359
// Run structured steps with progress

packages/cli/templates/default/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
"clsx": "^2.1.1",
2525
"react": "^19.2.0",
2626
"react-dom": "^19.2.0",
27-
"tailwind-merge": "^2.5.2"
27+
"tailwind-merge": "^3.0.0"
2828
},
2929
"devDependencies": {
3030
"@mandujs/cli": "{{CLI_VERSION}}",
31-
"@mandujs/mcp": "latest",
31+
"@mandujs/mcp": "{{MCP_VERSION}}",
3232
"@tailwindcss/cli": "^4.1.0",
33+
"@types/bun": "^1.3.0",
3334
"@types/react": "^19.2.0",
3435
"@types/react-dom": "^19.2.0",
3536
"tailwindcss": "^4.1.0",
36-
"typescript": "^5.0.0"
37+
"typescript": "^6.0.0"
3738
}
3839
}

packages/cli/templates/default/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"strict": true,
88
"skipLibCheck": true,
99
"jsx": "react-jsx",
10-
"types": ["bun-types"],
11-
"baseUrl": ".",
10+
"types": ["bun"],
1211
"paths": {
1312
"@/*": ["./src/*"]
1413
}

packages/cli/templates/realtime-chat/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
"clsx": "^2.1.1",
2222
"react": "^19.2.0",
2323
"react-dom": "^19.2.0",
24-
"tailwind-merge": "^2.5.2"
24+
"tailwind-merge": "^3.0.0"
2525
},
2626
"devDependencies": {
2727
"@mandujs/cli": "{{CLI_VERSION}}",
28-
"@mandujs/mcp": "latest",
28+
"@mandujs/mcp": "{{MCP_VERSION}}",
2929
"@tailwindcss/cli": "^4.1.0",
30+
"@types/bun": "^1.3.0",
3031
"@types/react": "^19.2.0",
3132
"@types/react-dom": "^19.2.0",
3233
"tailwindcss": "^4.1.0",
33-
"typescript": "^5.0.0"
34+
"typescript": "^6.0.0"
3435
}
3536
}

packages/cli/templates/realtime-chat/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"strict": true,
88
"skipLibCheck": true,
99
"jsx": "react-jsx",
10-
"types": ["bun-types"],
11-
"baseUrl": ".",
10+
"types": ["bun"],
1211
"paths": {
1312
"@/*": ["./src/*"]
1413
}

0 commit comments

Comments
 (0)