Skip to content

Commit 5bd5ca7

Browse files
committed
Add project scaffolding utility and update package.json description
1 parent 30cde97 commit 5bd5ca7

File tree

3 files changed

+98
-44
lines changed

3 files changed

+98
-44
lines changed

lib/package.json

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
"author": "Mayank Kumar Chaudhari (https://mayank-chaudhari.vercel.app)",
44
"private": false,
55
"version": "0.0.0",
6-
"description": "",
6+
"description": "CLI utility to bootstrap new projects using the react18-tools turborepo template. Runs create-turbo with the template, auto-detects the project folder, and rebrands it for immediate development.",
77
"license": "MPL-2.0",
8-
"main": "./dist/index.js",
9-
"module": "./dist/index.mjs",
10-
"types": "./dist/index.d.ts",
118
"repository": "github:react18-tools/create-r18-turborepo",
129
"bugs": "https://github.com/react18-tools/create-r18-turborepo/issues",
1310
"homepage": "https://github.com/react18-tools/create-r18-turborepo/#readme",
1411
"sideEffects": false,
1512
"files": [
1613
"dist/**"
1714
],
18-
"exports": {
19-
".": {
20-
"types": "./dist/index.d.ts",
21-
"import": "./dist/index.mjs",
22-
"require": "./dist/index.js"
23-
}
15+
"bin": {
16+
"create-r18-turborepo": "dist/index.mjs",
17+
"create-r18-turbo": "dist/index.mjs",
18+
"create-r18": "dist/index.mjs"
2419
},
2520
"scripts": {
2621
"build": "tsup && tsc -p tsconfig-build.json && gzip -c dist/index.js | wc -c",
@@ -34,36 +29,14 @@
3429
"devDependencies": {
3530
"@repo/eslint-config": "workspace:*",
3631
"@repo/typescript-config": "workspace:*",
37-
"@testing-library/react": "^16.3.0",
3832
"@types/node": "^24.3.0",
39-
"@types/react": "^19.1.10",
40-
"@types/react-dom": "^19.1.7",
41-
"@vitejs/plugin-react": "^5.0.1",
4233
"@vitest/coverage-v8": "^3.2.4",
4334
"esbuild-plugin-rdi": "^0.0.0",
44-
"esbuild-plugin-react18": "0.2.6",
45-
"esbuild-plugin-react18-css": "^0.0.4",
46-
"jsdom": "^26.1.0",
47-
"react": "^19.1.1",
48-
"react-dom": "^19.1.1",
4935
"tsup": "^8.5.0",
5036
"typescript": "^5.9.2",
5137
"vite-tsconfig-paths": "^5.1.4",
5238
"vitest": "^3.2.4"
5339
},
54-
"dependencies": {
55-
"r18gs": "^3.0.1"
56-
},
57-
"peerDependencies": {
58-
"@types/react": ">=16.8",
59-
"next": ">=10",
60-
"react": ">=16.8"
61-
},
62-
"peerDependenciesMeta": {
63-
"next": {
64-
"optional": true
65-
}
66-
},
6740
"funding": [
6841
{
6942
"type": "github",
@@ -75,22 +48,25 @@
7548
}
7649
],
7750
"keywords": [
78-
"React",
79-
"React Loaders",
51+
"Turborepo",
52+
"Turborepo template",
53+
"Monorepo",
54+
"Monorepo setup",
55+
"Monorepo boilerplate",
56+
"React monorepo",
57+
"Next.js monorepo",
58+
"Pnpm",
59+
"Workspace",
60+
"Full-stack starter",
8061
"React 18",
8162
"React 19",
82-
"Next.js",
8363
"Next.js 14",
8464
"Next.js 15",
8565
"React server components",
86-
"Customizable",
87-
"Cutting-edge",
88-
"Compatibility",
8966
"Frontend development",
90-
"UI components",
9167
"Web development",
92-
"Progressive",
93-
"Modern",
94-
"Seamless integration"
68+
"Scaffolding tool",
69+
"Project generator",
70+
"Developer tooling"
9571
]
96-
}
72+
}

lib/src/index.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env node
2+
/**
3+
* turborepo-template bootstrapper
4+
*
5+
* This utility wraps `create-turbo` to scaffold a repo from the
6+
* react18-tools turborepo template and runs `pnpm rebrand` inside it.
7+
*
8+
* Usage:
9+
* npx r18-turborepo my-app
10+
*
11+
* Notes:
12+
* - If no `projectName` is given, user is prompted to enter one
13+
* - Defaults to `react18-tools-turborepo-template`
14+
*/
15+
16+
import { execSync } from "child_process";
17+
import { resolve } from "path";
18+
import { existsSync } from "fs";
19+
import readline from "readline";
20+
21+
const DEFAULT_NAME = "react18-tools-turborepo-template";
22+
23+
function askQuestion(query: string): Promise<string> {
24+
const rl = readline.createInterface({
25+
input: process.stdin,
26+
output: process.stdout,
27+
});
28+
return new Promise(resolve =>
29+
rl.question(query, ans => {
30+
rl.close();
31+
resolve(ans);
32+
}),
33+
);
34+
}
35+
36+
async function main(): Promise<void> {
37+
let projectName = process.argv[2];
38+
39+
if (!projectName) {
40+
const input = await askQuestion(`Project name (default: ${DEFAULT_NAME}): `);
41+
projectName = input.trim() || DEFAULT_NAME;
42+
}
43+
44+
const projectDir = resolve(process.cwd(), projectName);
45+
46+
// Step 1: Scaffold project using turborepo template
47+
console.log(`\n🔨 Creating turborepo project: ${projectName}\n`);
48+
const cmd = `pnpm dlx create-turbo@latest ${projectName} --example https://github.com/react18-tools/turborepo-template/ -m pnpm`;
49+
50+
try {
51+
execSync(cmd, { stdio: "inherit" });
52+
} catch (err: any) {
53+
console.error("❌ Error while running create-turbo:", err.message);
54+
process.exit(1);
55+
}
56+
57+
// Step 2: Verify directory exists
58+
if (!existsSync(projectDir)) {
59+
console.error(`❌ Expected directory not found: ${projectDir}`);
60+
process.exit(1);
61+
}
62+
63+
// Step 3: Run rebrand
64+
console.log(`\n🚀 Rebranding project in ${projectName}\n`);
65+
try {
66+
execSync("pnpm rebrand", {
67+
cwd: projectDir,
68+
stdio: "inherit",
69+
});
70+
} catch (err: any) {
71+
console.error("❌ Rebrand step failed:", err.message);
72+
process.exit(1);
73+
}
74+
75+
console.log(`\n✅ Done! Your project is ready in: ${projectDir}\n`);
76+
}
77+
78+
main();

scripts/publish-canonical.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { execSync } = require("child_process");
22

33
// Publish canonical packages
4-
[].forEach(pkg => {
4+
["create-r18", "create-r18-turbo"].forEach(pkg => {
55
execSync(`sed -i -e "s/name.*/name\\": \\"${pkg.replace(/\//g, "\\\\/")}\\",/" lib/package.json`);
66
execSync("cd lib && npm publish --provenance --access public");
77
});

0 commit comments

Comments
 (0)