create-nara 1.0.2 → 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/template.js +18 -17
- package/package.json +1 -1
package/dist/template.js
CHANGED
|
@@ -11,13 +11,27 @@ export async function setupProject(options) {
|
|
|
11
11
|
}
|
|
12
12
|
// 1. Copy base template (shared files like .gitignore, tsconfig, etc)
|
|
13
13
|
copyDir(path.join(templatesDir, 'base'), targetDir);
|
|
14
|
-
//
|
|
14
|
+
// 2. Copy mode-specific template
|
|
15
|
+
const modeTemplateDir = path.join(templatesDir, mode);
|
|
16
|
+
if (fs.existsSync(modeTemplateDir)) {
|
|
17
|
+
copyDir(modeTemplateDir, targetDir);
|
|
18
|
+
}
|
|
19
|
+
// 3. Copy feature-specific templates
|
|
20
|
+
const featuresDir = path.join(templatesDir, 'features');
|
|
21
|
+
for (const feature of features) {
|
|
22
|
+
const featureDir = path.join(featuresDir, feature);
|
|
23
|
+
if (fs.existsSync(featureDir)) {
|
|
24
|
+
copyDir(featureDir, targetDir);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// 4. Rename dotfiles (npm doesn't include them by default)
|
|
28
|
+
// Must happen AFTER all templates are copied
|
|
15
29
|
const gitignoreTemplate = path.join(targetDir, 'gitignore.template');
|
|
16
30
|
const gitignoreDest = path.join(targetDir, '.gitignore');
|
|
17
31
|
if (fs.existsSync(gitignoreTemplate)) {
|
|
18
32
|
fs.renameSync(gitignoreTemplate, gitignoreDest);
|
|
19
33
|
}
|
|
20
|
-
// Rename env files
|
|
34
|
+
// Rename env files
|
|
21
35
|
const envFiles = [
|
|
22
36
|
{ src: 'env.example', dest: '.env.example' },
|
|
23
37
|
{ src: 'env.production.example', dest: '.env.production.example' }
|
|
@@ -35,20 +49,7 @@ export async function setupProject(options) {
|
|
|
35
49
|
if (fs.existsSync(envExample)) {
|
|
36
50
|
fs.copyFileSync(envExample, envFile);
|
|
37
51
|
}
|
|
38
|
-
//
|
|
39
|
-
const modeTemplateDir = path.join(templatesDir, mode);
|
|
40
|
-
if (fs.existsSync(modeTemplateDir)) {
|
|
41
|
-
copyDir(modeTemplateDir, targetDir);
|
|
42
|
-
}
|
|
43
|
-
// 3. Copy feature-specific templates
|
|
44
|
-
const featuresDir = path.join(templatesDir, 'features');
|
|
45
|
-
for (const feature of features) {
|
|
46
|
-
const featureDir = path.join(featuresDir, feature);
|
|
47
|
-
if (fs.existsSync(featureDir)) {
|
|
48
|
-
copyDir(featureDir, targetDir);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// 4. Ensure required directories exist
|
|
52
|
+
// 5. Ensure required directories exist
|
|
52
53
|
fs.mkdirSync(path.join(targetDir, 'app/controllers'), { recursive: true });
|
|
53
54
|
fs.mkdirSync(path.join(targetDir, 'app/models'), { recursive: true });
|
|
54
55
|
// Create database directory if db feature is selected
|
|
@@ -59,7 +60,7 @@ export async function setupProject(options) {
|
|
|
59
60
|
if (features.includes('uploads')) {
|
|
60
61
|
fs.mkdirSync(path.join(targetDir, 'uploads'), { recursive: true });
|
|
61
62
|
}
|
|
62
|
-
//
|
|
63
|
+
// 6. Generate package.json (dynamic content)
|
|
63
64
|
const pkg = createPackageJson(projectName, mode, features);
|
|
64
65
|
fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2));
|
|
65
66
|
}
|