@jxrstudios/jxr 1.2.11 → 1.2.15
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.
- package/bin/jxr.js +26 -2
- package/package.json +1 -1
package/bin/jxr.js
CHANGED
|
@@ -15,9 +15,28 @@ if (command === "init") {
|
|
|
15
15
|
const projectName = args[1] || "my-jxr-app";
|
|
16
16
|
const projectDir = path.resolve(process.cwd(), projectName);
|
|
17
17
|
|
|
18
|
+
// Safety check: never overwrite existing files
|
|
18
19
|
if (existsSync(projectDir)) {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const fs = await import("fs");
|
|
21
|
+
const existingFiles = fs.readdirSync(projectDir);
|
|
22
|
+
|
|
23
|
+
if (existingFiles.length > 0) {
|
|
24
|
+
console.error(`❌ Directory "${projectName}" already exists and contains files:`);
|
|
25
|
+
existingFiles.slice(0, 10).forEach(f => console.error(` - ${f}`));
|
|
26
|
+
if (existingFiles.length > 10) {
|
|
27
|
+
console.error(` ... and ${existingFiles.length - 10} more files`);
|
|
28
|
+
}
|
|
29
|
+
console.error("");
|
|
30
|
+
console.error("To protect your existing project, jxr init cannot proceed.");
|
|
31
|
+
console.error("Options:");
|
|
32
|
+
console.error(` 1. Use a different name: jxr init my-new-project`);
|
|
33
|
+
console.error(` 2. Create in a subdirectory: mkdir ${projectName}/jxr-app && cd ${projectName}/jxr-app && jxr init .`);
|
|
34
|
+
console.error(` 3. Manually backup and clear the directory first`);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Directory exists but is empty - safe to proceed
|
|
39
|
+
console.log(`📁 Using existing empty directory: ${projectName}`);
|
|
21
40
|
}
|
|
22
41
|
|
|
23
42
|
console.log(`🚀 Creating new JXR project: ${projectName}`);
|
|
@@ -38,6 +57,11 @@ if (command === "init") {
|
|
|
38
57
|
},
|
|
39
58
|
dependencies: {
|
|
40
59
|
"@jxrstudios/jxr": "^1.0.5"
|
|
60
|
+
},
|
|
61
|
+
devDependencies: {
|
|
62
|
+
"@types/react": "^19.0.0",
|
|
63
|
+
"@types/react-dom": "^19.0.0",
|
|
64
|
+
"typescript": "^5.5.0"
|
|
41
65
|
}
|
|
42
66
|
};
|
|
43
67
|
await writeFile(
|