shadcn-nextjs-page-generator 1.0.4 → 1.0.5
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.cjs +57 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -385,21 +385,44 @@ var import_path = __toESM(require("path"), 1);
|
|
|
385
385
|
async function ensureDir(dirPath) {
|
|
386
386
|
await import_fs_extra.default.ensureDir(dirPath);
|
|
387
387
|
}
|
|
388
|
-
async function writeFile(filePath, content) {
|
|
388
|
+
async function writeFile(filePath, content, shouldOverwrite = true) {
|
|
389
389
|
const dir = import_path.default.dirname(filePath);
|
|
390
390
|
await ensureDir(dir);
|
|
391
|
-
|
|
391
|
+
const writeOptions = shouldOverwrite ? { encoding: "utf-8", flag: "w" } : { encoding: "utf-8", flag: "wx" };
|
|
392
|
+
await import_fs_extra.default.writeFile(filePath, content, writeOptions);
|
|
393
|
+
}
|
|
394
|
+
async function exists(pathToCheck) {
|
|
395
|
+
try {
|
|
396
|
+
await import_fs_extra.default.access(pathToCheck);
|
|
397
|
+
return true;
|
|
398
|
+
} catch {
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
392
401
|
}
|
|
393
402
|
async function createDirectories(dirs) {
|
|
394
403
|
for (const dir of dirs) {
|
|
395
404
|
await ensureDir(dir);
|
|
396
405
|
}
|
|
397
406
|
}
|
|
398
|
-
async function writeFiles(files) {
|
|
407
|
+
async function writeFiles(files, shouldOverwrite = true) {
|
|
399
408
|
for (const file of files) {
|
|
400
|
-
await
|
|
401
|
-
|
|
409
|
+
const fileExists = await exists(file.path);
|
|
410
|
+
await writeFile(file.path, file.content, shouldOverwrite);
|
|
411
|
+
if (fileExists) {
|
|
412
|
+
logger.dim(` Updated: ${file.path}`);
|
|
413
|
+
} else {
|
|
414
|
+
logger.dim(` Created: ${file.path}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async function checkExistingFiles(filePaths) {
|
|
419
|
+
const existingFiles = [];
|
|
420
|
+
for (const filePath of filePaths) {
|
|
421
|
+
if (await exists(filePath)) {
|
|
422
|
+
existingFiles.push(filePath);
|
|
423
|
+
}
|
|
402
424
|
}
|
|
425
|
+
return existingFiles;
|
|
403
426
|
}
|
|
404
427
|
|
|
405
428
|
// src/templates/ddd/entity.ts
|
|
@@ -1144,10 +1167,10 @@ import { motion } from 'framer-motion';
|
|
|
1144
1167
|
export default function Template({ children }: { children: React.ReactNode }) {
|
|
1145
1168
|
return (
|
|
1146
1169
|
<motion.div
|
|
1147
|
-
initial
|
|
1148
|
-
animate
|
|
1170
|
+
initial={${animConfig.initial}}
|
|
1171
|
+
animate={${animConfig.animate}}
|
|
1149
1172
|
exit={{ opacity: 0, y: -20 }}
|
|
1150
|
-
transition
|
|
1173
|
+
transition={${animConfig.transition}}
|
|
1151
1174
|
>
|
|
1152
1175
|
{children}
|
|
1153
1176
|
</motion.div>
|
|
@@ -1206,7 +1229,19 @@ var DDDGenerator = class {
|
|
|
1206
1229
|
content: generateTemplate(this.config)
|
|
1207
1230
|
});
|
|
1208
1231
|
}
|
|
1209
|
-
|
|
1232
|
+
const filePaths = files.map((f) => f.path);
|
|
1233
|
+
const existingFiles = await checkExistingFiles(filePaths);
|
|
1234
|
+
if (existingFiles.length > 0) {
|
|
1235
|
+
console.log("");
|
|
1236
|
+
logger.warning(`Found ${existingFiles.length} existing file(s):`);
|
|
1237
|
+
existingFiles.forEach((file) => {
|
|
1238
|
+
const relativePath = import_path2.default.relative(cwd, file);
|
|
1239
|
+
logger.dim(` - ${relativePath}`);
|
|
1240
|
+
});
|
|
1241
|
+
console.log("");
|
|
1242
|
+
logger.info("Overwriting existing files...");
|
|
1243
|
+
}
|
|
1244
|
+
await writeFiles(files, true);
|
|
1210
1245
|
const instructions = this.generateInstructions();
|
|
1211
1246
|
return { files, instructions };
|
|
1212
1247
|
}
|
|
@@ -1811,7 +1846,19 @@ var SimplifiedGenerator = class {
|
|
|
1811
1846
|
content: generateTemplate(this.config)
|
|
1812
1847
|
});
|
|
1813
1848
|
}
|
|
1814
|
-
|
|
1849
|
+
const filePaths = files.map((f) => f.path);
|
|
1850
|
+
const existingFiles = await checkExistingFiles(filePaths);
|
|
1851
|
+
if (existingFiles.length > 0) {
|
|
1852
|
+
console.log("");
|
|
1853
|
+
logger.warning(`Found ${existingFiles.length} existing file(s):`);
|
|
1854
|
+
existingFiles.forEach((file) => {
|
|
1855
|
+
const relativePath = import_path3.default.relative(cwd, file);
|
|
1856
|
+
logger.dim(` - ${relativePath}`);
|
|
1857
|
+
});
|
|
1858
|
+
console.log("");
|
|
1859
|
+
logger.info("Overwriting existing files...");
|
|
1860
|
+
}
|
|
1861
|
+
await writeFiles(files, true);
|
|
1815
1862
|
const instructions = this.generateInstructions();
|
|
1816
1863
|
return { files, instructions };
|
|
1817
1864
|
}
|