create-rst 0.0.1

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 (3) hide show
  1. package/README.md +52 -0
  2. package/bin/cli.js +138 -0
  3. package/package.json +84 -0
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # React + TypeScript Starter Pack (RSP)
2
+
3
+ A premium, production-ready starter template for React applications. Packed with modern tools like Vite, TypeScript, Tailwind CSS v4, Redux Toolkit, and Framer Motion.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ Initialize a new project instantly using `npx`:
8
+
9
+ ```bash
10
+ # Using npx
11
+ npx create-rst my-new-app
12
+
13
+ # OR using npm init
14
+ npm create rst my-new-app
15
+ ```
16
+
17
+ Or install globally:
18
+
19
+ ```bash
20
+ npm install -g create-rst
21
+ create-rst my-new-app
22
+ ```
23
+
24
+ Then navigate to your project and start coding:
25
+
26
+ ```bash
27
+ cd my-new-app
28
+ npm run dev
29
+ ```
30
+
31
+ ## ✨ Features
32
+
33
+ - **⚡ Vite**: Lightning fast build tool.
34
+ - **📘 TypeScript**: Type safety and better developer experience.
35
+ - **🎨 Tailwind CSS v4**: The latest utility-first CSS framework.
36
+ - **🛠️ Redux Toolkit**: Validated state management.
37
+ - **🎭 Framer Motion**: Production-ready animations.
38
+ - **🧩 Radix UI**: Accessible, unstyled UI primitives.
39
+ - **📝 React Hook Form + Zod**: Powerful forms with validation.
40
+ - **🌐 Axios**: HTTP client pre-configured.
41
+
42
+ ## 📦 Scripts
43
+
44
+ - `npm run dev`: Start the development server.
45
+ - `npm run build`: Build for production.
46
+ - `npm run lint`: Run ESLint.
47
+ - `npm run preview`: Preview the production build.
48
+
49
+ ## 📄 License
50
+
51
+ MIT © [naim0018](https://github.com/naim0018)
52
+
package/bin/cli.js ADDED
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawnSync } from "child_process";
4
+ import { existsSync, rmSync, readdirSync, readFileSync, writeFileSync } from "fs";
5
+ import { resolve, basename } from "path";
6
+ import chalk from "chalk";
7
+ import prompts from "prompts";
8
+ import tiged from "tiged";
9
+ import validateNpmName from "validate-npm-package-name";
10
+
11
+ const run = async () => {
12
+ let projectName = process.argv[2];
13
+
14
+ if (!projectName) {
15
+ const response = await prompts({
16
+ type: "text",
17
+ name: "projectName",
18
+ message: "What is the name of your project?",
19
+ initial: "my-app",
20
+ validate: (value) => {
21
+ const validation = validateNpmName(basename(resolve(value)));
22
+ if (!validation.validForNewPackages) {
23
+ return `Invalid project name: ${validation.errors ? validation.errors.join(', ') : ''} ${validation.warnings ? validation.warnings.join(', ') : ''}`;
24
+ }
25
+ return true;
26
+ },
27
+ });
28
+
29
+ if (!response.projectName) {
30
+ console.log(chalk.red("\nOperation cancelled"));
31
+ process.exit(1);
32
+ }
33
+ projectName = response.projectName;
34
+ }
35
+
36
+ const isCurrentDir = projectName === ".";
37
+ const projectPath = isCurrentDir
38
+ ? process.cwd()
39
+ : resolve(process.cwd(), projectName);
40
+ const appName = isCurrentDir ? basename(projectPath) : projectName;
41
+
42
+ // Validation
43
+ if (!isCurrentDir && existsSync(projectPath)) {
44
+ if (readdirSync(projectPath).length > 0) {
45
+ const { overwrite } = await prompts({
46
+ type: 'confirm',
47
+ name: 'overwrite',
48
+ message: `Target directory "${appName}" is not empty. Remove existing files and continue?`,
49
+ });
50
+
51
+ if (!overwrite) {
52
+ console.log(chalk.red('Operation cancelled'));
53
+ process.exit(1);
54
+ }
55
+ rmSync(projectPath, { recursive: true, force: true });
56
+ }
57
+ }
58
+
59
+ console.log(chalk.blue(`\nCreating a new React app in ${chalk.bold(projectPath)}...`));
60
+
61
+ // Download template using tiged
62
+ const emitter = tiged("naim0018/starter-template-react-typescript", {
63
+ disableCache: true,
64
+ force: true,
65
+ verbose: false,
66
+ });
67
+
68
+ try {
69
+ await emitter.clone(projectPath);
70
+ } catch (error) {
71
+ console.error(chalk.red("Failed to download template:"), error.message);
72
+ process.exit(1);
73
+ }
74
+
75
+ console.log(chalk.green("Template downloaded successfully."));
76
+
77
+ // Cleanup & Configuration
78
+ console.log(chalk.blue("Configuring project..."));
79
+
80
+ const packageJsonPath = resolve(projectPath, "package.json");
81
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
82
+
83
+ // Cleanup: Remove bin
84
+ delete packageJson.bin;
85
+
86
+ // Cleanup: Remove CLI dependencies (so the user project doesn't have them)
87
+ const cliDeps = ["tiged", "prompts", "chalk", "validate-npm-package-name"];
88
+ cliDeps.forEach(dep => {
89
+ if (packageJson.dependencies && packageJson.dependencies[dep]) delete packageJson.dependencies[dep];
90
+ if (packageJson.devDependencies && packageJson.devDependencies[dep]) delete packageJson.devDependencies[dep];
91
+ });
92
+
93
+ packageJson.name = appName;
94
+ packageJson.version = "0.1.0";
95
+
96
+ writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
97
+
98
+ // Remove bin folder
99
+ const binPath = resolve(projectPath, "bin");
100
+ if (existsSync(binPath)) {
101
+ rmSync(binPath, { recursive: true, force: true });
102
+ }
103
+
104
+ // Install dependencies
105
+ console.log(chalk.blue("Installing dependencies..."));
106
+
107
+ const installCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
108
+ const installResult = spawnSync(installCmd, ['install'], {
109
+ cwd: projectPath,
110
+ stdio: 'inherit'
111
+ });
112
+
113
+ if (installResult.status !== 0) {
114
+ console.error(chalk.red("Failed to install dependencies."));
115
+ // We don't exit here, just warn, so the user sees the output.
116
+ } else {
117
+ console.log(chalk.green("Dependencies installed successfully."));
118
+ }
119
+
120
+ // Success Message
121
+ console.log(chalk.green(`\nSuccess! Created ${appName} at ${projectPath}`));
122
+ console.log("\nInside that directory, you can run several commands:\n");
123
+ console.log(chalk.cyan(` npm run dev`));
124
+ console.log(" Starts the development server.\n");
125
+ console.log(chalk.cyan(` npm run build`));
126
+ console.log(" Bundles the app for production.\n");
127
+ console.log("\nWe suggest that you begin by typing:\n");
128
+ if (!isCurrentDir) {
129
+ console.log(chalk.cyan(` cd ${projectName}`));
130
+ }
131
+ console.log(chalk.cyan(` npm run dev`));
132
+ console.log("");
133
+ };
134
+
135
+ run().catch((err) => {
136
+ console.error(chalk.red("Unexpected error:"), err);
137
+ process.exit(1);
138
+ });
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "create-rst",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "bin": "./bin/cli.js",
6
+ "description": "React + TypeScript Starter Pack CLI",
7
+ "author": "naim0018",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/naim0018/starter-template-react-typescript.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/naim0018/starter-template-react-typescript/issues"
15
+ },
16
+ "homepage": "https://github.com/naim0018/starter-template-react-typescript#readme",
17
+ "keywords": [
18
+ "react",
19
+ "typescript",
20
+ "starter",
21
+ "template",
22
+ "rsp",
23
+ "vite",
24
+ "redux",
25
+ "tailwindcss"
26
+ ],
27
+ "files": [
28
+ "bin"
29
+ ],
30
+ "scripts": {
31
+ "dev": "vite",
32
+ "build": "tsc -b && vite build",
33
+ "lint": "eslint .",
34
+ "preview": "vite preview"
35
+ },
36
+ "dependencies": {
37
+ "@hookform/resolvers": "^4.1.3",
38
+ "@radix-ui/react-avatar": "^1.1.3",
39
+ "@radix-ui/react-hover-card": "^1.1.15",
40
+ "@radix-ui/react-navigation-menu": "^1.2.14",
41
+ "@radix-ui/react-popover": "^1.1.6",
42
+ "@radix-ui/react-slot": "^1.1.2",
43
+ "@reduxjs/toolkit": "^2.6.1",
44
+ "axios": "^1.8.2",
45
+ "chalk": "^5.6.2",
46
+ "class-variance-authority": "^0.7.1",
47
+ "clsx": "^2.1.1",
48
+ "framer-motion": "^12.23.26",
49
+ "jwt-decode": "^4.0.0",
50
+ "lucide-react": "^0.479.0",
51
+ "next-themes": "^0.4.6",
52
+ "prompts": "^2.4.2",
53
+ "react": "^19.0.0",
54
+ "react-dom": "^19.0.0",
55
+ "react-hook-form": "^7.54.2",
56
+ "react-icons": "^5.5.0",
57
+ "react-redux": "^9.2.0",
58
+ "react-router-dom": "^7.3.0",
59
+ "redux-persist": "^6.0.0",
60
+ "sonner": "^2.0.7",
61
+ "sweetalert2": "^11.26.17",
62
+ "tailwind-merge": "^3.0.2",
63
+ "tailwindcss-animate": "^1.0.7",
64
+ "tiged": "^2.12.7",
65
+ "validate-npm-package-name": "^7.0.2",
66
+ "zod": "^3.24.2"
67
+ },
68
+ "devDependencies": {
69
+ "@eslint/js": "^9.21.0",
70
+ "@types/node": "^22.13.10",
71
+ "@types/react": "^19.0.10",
72
+ "@types/react-dom": "^19.0.4",
73
+ "@vitejs/plugin-react": "^4.3.4",
74
+ "eslint": "^9.21.0",
75
+ "eslint-plugin-react-hooks": "^5.1.0",
76
+ "eslint-plugin-react-refresh": "^0.4.19",
77
+ "globals": "^15.15.0",
78
+ "typescript": "~5.7.2",
79
+ "typescript-eslint": "^8.24.1",
80
+ "tailwindcss": "^4.0.12",
81
+ "@tailwindcss/vite": "^4.0.12",
82
+ "vite": "^6.2.0"
83
+ }
84
+ }