react-apps-ui 1.0.1 → 1.0.3
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/dist/index.js +11 -8
- package/package.json +1 -1
- package/src/index.ts +11 -8
package/dist/index.js
CHANGED
|
@@ -61,13 +61,16 @@ program
|
|
|
61
61
|
const hasSrcDir = fs_1.default.existsSync(path_1.default.join(process.cwd(), "src"));
|
|
62
62
|
// 4. Loop through the files and write them smartly
|
|
63
63
|
for (const file of themeComponent.files) {
|
|
64
|
-
|
|
64
|
+
// DEFENSIVE FALLBACK: If 'target' is missing from the JSON, use the file.name
|
|
65
|
+
// This ensures path.join() never receives 'undefined' again.
|
|
66
|
+
const safeTarget = file.target || file.name;
|
|
67
|
+
let finalTargetPath = path_1.default.join(process.cwd(), safeTarget);
|
|
65
68
|
// SMART ROUTING: If they use 'src/' and it's not a root config file, put it inside src/
|
|
66
|
-
const isRootConfig =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const isRootConfig = safeTarget.includes("tailwind") ||
|
|
70
|
+
safeTarget.endsWith(".config.js") ||
|
|
71
|
+
safeTarget.endsWith(".json");
|
|
69
72
|
if (hasSrcDir && !isRootConfig) {
|
|
70
|
-
finalTargetPath = path_1.default.join(process.cwd(), "src",
|
|
73
|
+
finalTargetPath = path_1.default.join(process.cwd(), "src", safeTarget);
|
|
71
74
|
}
|
|
72
75
|
// Ensure the folder exists
|
|
73
76
|
fs_1.default.mkdirSync(path_1.default.dirname(finalTargetPath), {
|
|
@@ -77,7 +80,7 @@ program
|
|
|
77
80
|
if (fs_1.default.existsSync(finalTargetPath)) {
|
|
78
81
|
if (file.type === "css" ||
|
|
79
82
|
finalTargetPath.endsWith(".css")) {
|
|
80
|
-
console.log(chalk_1.default.yellow(
|
|
83
|
+
console.log(chalk_1.default.yellow(` ⚠️ ${file.target} already exists. Appending theme variables safely...`));
|
|
81
84
|
const existingContent = fs_1.default.readFileSync(finalTargetPath, "utf-8");
|
|
82
85
|
// Only append if it doesn't already contain our theme variables to prevent infinite duplication
|
|
83
86
|
if (!existingContent.includes("--background:")) {
|
|
@@ -85,13 +88,13 @@ program
|
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
else {
|
|
88
|
-
console.log(chalk_1.default.yellow(
|
|
91
|
+
console.log(chalk_1.default.yellow(` ⚠️ ${file.target} already exists. Skipping to prevent overwrite.`));
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
else {
|
|
92
95
|
// File doesn't exist, safe to write normally
|
|
93
96
|
fs_1.default.writeFileSync(finalTargetPath, file.content, "utf-8");
|
|
94
|
-
console.log(chalk_1.default.green(` Created ${
|
|
97
|
+
console.log(chalk_1.default.green(` Created ${safeTarget}`));
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
console.log(chalk_1.default.blue("\n🎉 Initialization complete!"));
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -75,18 +75,21 @@ program
|
|
|
75
75
|
|
|
76
76
|
// 4. Loop through the files and write them smartly
|
|
77
77
|
for (const file of themeComponent.files) {
|
|
78
|
-
|
|
78
|
+
// DEFENSIVE FALLBACK: If 'target' is missing from the JSON, use the file.name
|
|
79
|
+
// This ensures path.join() never receives 'undefined' again.
|
|
80
|
+
const safeTarget = file.target || file.name;
|
|
81
|
+
let finalTargetPath = path.join(process.cwd(), safeTarget);
|
|
79
82
|
|
|
80
83
|
// SMART ROUTING: If they use 'src/' and it's not a root config file, put it inside src/
|
|
81
84
|
const isRootConfig =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
safeTarget.includes("tailwind") ||
|
|
86
|
+
safeTarget.endsWith(".config.js") ||
|
|
87
|
+
safeTarget.endsWith(".json");
|
|
85
88
|
if (hasSrcDir && !isRootConfig) {
|
|
86
89
|
finalTargetPath = path.join(
|
|
87
90
|
process.cwd(),
|
|
88
91
|
"src",
|
|
89
|
-
|
|
92
|
+
safeTarget,
|
|
90
93
|
);
|
|
91
94
|
}
|
|
92
95
|
|
|
@@ -103,7 +106,7 @@ program
|
|
|
103
106
|
) {
|
|
104
107
|
console.log(
|
|
105
108
|
chalk.yellow(
|
|
106
|
-
|
|
109
|
+
` ⚠️ ${file.target} already exists. Appending theme variables safely...`,
|
|
107
110
|
),
|
|
108
111
|
);
|
|
109
112
|
const existingContent = fs.readFileSync(
|
|
@@ -122,14 +125,14 @@ program
|
|
|
122
125
|
} else {
|
|
123
126
|
console.log(
|
|
124
127
|
chalk.yellow(
|
|
125
|
-
|
|
128
|
+
` ⚠️ ${file.target} already exists. Skipping to prevent overwrite.`,
|
|
126
129
|
),
|
|
127
130
|
);
|
|
128
131
|
}
|
|
129
132
|
} else {
|
|
130
133
|
// File doesn't exist, safe to write normally
|
|
131
134
|
fs.writeFileSync(finalTargetPath, file.content, "utf-8");
|
|
132
|
-
console.log(chalk.green(` Created ${
|
|
135
|
+
console.log(chalk.green(` Created ${safeTarget}`));
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
|