create-reactivite 1.0.0 → 1.0.2

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/index.js +35 -7
  2. package/package.json +6 -5
package/index.js CHANGED
@@ -15,28 +15,56 @@ const __dirname = path.dirname(__filename);
15
15
  type: "text",
16
16
  name: "projectName",
17
17
  message: "Project name:",
18
- initial: "my-react-app"
18
+ initial: "my-react-app",
19
19
  });
20
20
 
21
- const targetPath = path.resolve(process.cwd(), projectName);
21
+ // 🧩 1. Target folderı müəyyən edirik
22
+ const isCurrentDir = projectName === "." || projectName === "./";
23
+ const targetPath = isCurrentDir
24
+ ? process.cwd()
25
+ : path.resolve(process.cwd(), projectName);
26
+
22
27
  const templatePath = path.resolve(__dirname, "template");
23
28
 
24
- if (fs.existsSync(targetPath)) {
29
+ // 🧩 2. Əgər current folderdirsə — içi boşdursa davam et, yoxsa xəbərdarlıq ver
30
+ if (isCurrentDir) {
31
+ const files = fs.readdirSync(targetPath).filter(
32
+ (f) => f !== "node_modules" && f !== ".git"
33
+ );
34
+
35
+ if (files.length > 0) {
36
+ const { overwrite } = await prompts({
37
+ type: "confirm",
38
+ name: "overwrite",
39
+ message: "⚠️ Current folder is not empty. Continue and overwrite?",
40
+ initial: false,
41
+ });
42
+
43
+ if (!overwrite) {
44
+ console.log("❌ Operation cancelled.");
45
+ process.exit(1);
46
+ }
47
+ }
48
+ } else if (fs.existsSync(targetPath)) {
25
49
  console.error(`❌ Folder "${projectName}" already exists!`);
26
50
  process.exit(1);
27
51
  }
28
52
 
53
+ // 🧩 3. Faylları kopyalayırıq
29
54
  console.log("📦 Creating project...");
30
55
  await copy(templatePath, targetPath);
31
56
 
57
+ // 🧩 4. Asılılıqları quraşdırırıq
32
58
  console.log("📥 Installing dependencies...");
33
- await execa("pnpm", ["install"], { cwd: targetPath, stdio: "inherit" }).catch(async () => {
59
+ try {
60
+ await execa("pnpm", ["install"], { cwd: targetPath, stdio: "inherit" });
61
+ } catch {
34
62
  console.log("⚠️ pnpm not found, trying npm...");
35
63
  await execa("npm", ["install"], { cwd: targetPath, stdio: "inherit" });
36
- });
64
+ }
37
65
 
66
+ // 🧩 5. Bitdi mesajı
38
67
  console.log(`✅ Done! Next steps:
39
- cd ${projectName}
40
- pnpm dev (or npm run dev)
68
+ ${isCurrentDir ? "" : `cd ${projectName}\n`}pnpm dev (or npm run dev)
41
69
  `);
42
70
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-reactivite",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "React + Vite + Tailwind boilerplate creator",
5
5
  "bin": {
6
6
  "create-reactivite": "./index.js"
@@ -10,8 +10,9 @@
10
10
  "index.js",
11
11
  "template/"
12
12
  ],
13
- "dependencies": {
14
- "prompts": "^2.4.2",
15
- "fs-extra": "^11.2.0"
16
- }
13
+ "dependencies": {
14
+ "prompts": "^2.4.2",
15
+ "fs-extra": "^11.2.0",
16
+ "execa": "^7.1.0"
17
+ }
17
18
  }