@dev.aldrindc/zirr-cli 1.0.0 → 1.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.
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -62,19 +62,40 @@ async function createProject(projectName, options) {
|
|
|
62
62
|
// Create project directory
|
|
63
63
|
fs.ensureDirSync(projectDir);
|
|
64
64
|
|
|
65
|
-
// Read template files
|
|
65
|
+
// Read template files recursively (compatible with older Node versions)
|
|
66
66
|
const templateDir = path.join(__dirname, 'templates');
|
|
67
|
-
|
|
67
|
+
|
|
68
|
+
// Helper function to get all files recursively
|
|
69
|
+
function getAllFiles(dir) {
|
|
70
|
+
const files = [];
|
|
71
|
+
const items = fs.readdirSync(dir);
|
|
72
|
+
|
|
73
|
+
for (const item of items) {
|
|
74
|
+
const itemPath = path.join(dir, item);
|
|
75
|
+
const stat = fs.statSync(itemPath);
|
|
76
|
+
|
|
77
|
+
if (stat.isDirectory()) {
|
|
78
|
+
const subFiles = getAllFiles(itemPath);
|
|
79
|
+
for (const subFile of subFiles) {
|
|
80
|
+
files.push(path.join(item, subFile));
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
files.push(item);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return files;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const templateFiles = getAllFiles(templateDir);
|
|
68
91
|
|
|
69
92
|
// Process and copy each template file
|
|
70
93
|
for (const templateFile of templateFiles) {
|
|
71
94
|
const sourcePath = path.join(templateDir, templateFile);
|
|
72
95
|
const targetPath = path.join(projectDir, templateFile);
|
|
73
96
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
97
|
+
// Ensure target directory exists
|
|
98
|
+
fs.ensureDirSync(path.dirname(targetPath));
|
|
78
99
|
|
|
79
100
|
// Read template content
|
|
80
101
|
let content = fs.readFileSync(sourcePath, 'utf-8');
|
|
@@ -84,7 +105,6 @@ async function createProject(projectName, options) {
|
|
|
84
105
|
content = content.replace(/{{PROJECT_TITLE}}/g, projectDetails.title);
|
|
85
106
|
|
|
86
107
|
// Write to target
|
|
87
|
-
fs.ensureDirSync(path.dirname(targetPath));
|
|
88
108
|
fs.writeFileSync(targetPath, content);
|
|
89
109
|
|
|
90
110
|
console.log(chalk.gray(` ✓ ${templateFile}`));
|
|
File without changes
|