create-zen 1.0.7 → 1.2.0
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/README.md +9 -16
- package/index.js +142 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,22 +47,15 @@ You can create a new project using `npm create`:
|
|
|
47
47
|
npm create zen@latest
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
cd zen-starter
|
|
61
|
-
```
|
|
62
|
-
3. Install the dependencies:
|
|
63
|
-
```bash
|
|
64
|
-
npm install
|
|
65
|
-
```
|
|
50
|
+
**Why `@latest`?** This ensures you always get the most recent version of the ZEN starter kit. Without it, npm might use a cached or outdated version.
|
|
51
|
+
|
|
52
|
+
The tool will interactively prompt you to:
|
|
53
|
+
1. **Enter your project name** (with a default fallback)
|
|
54
|
+
2. **Choose between two versions**:
|
|
55
|
+
- **Standard Version**: Full-featured with all components
|
|
56
|
+
- **Lite Version**: Lightweight for static sites
|
|
57
|
+
|
|
58
|
+
This makes it easy to get started without remembering command line arguments and gives you flexibility to choose the right version for your needs.
|
|
66
59
|
|
|
67
60
|
<img src="https://user-images.githubusercontent.com/73097560/115834477-dbab4500-a447-11eb-908a-139a6edaec5c.gif" alt="line" />
|
|
68
61
|
|
package/index.js
CHANGED
|
@@ -5,67 +5,169 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const readline = require('readline');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// Modern color palette matching the ZEN design
|
|
9
|
+
const colors = {
|
|
10
|
+
reset: '\x1b[0m',
|
|
11
|
+
bright: '\x1b[1m',
|
|
12
|
+
dim: '\x1b[2m',
|
|
13
|
+
|
|
14
|
+
// Primary colors from ZEN design
|
|
15
|
+
green: '\x1b[38;2;5;247;195m', // Bright green accent (#05F7C3)
|
|
16
|
+
white: '\x1b[37m', // Pure white text
|
|
17
|
+
lightGrey: '\x1b[38;2;156;163;175m', // Light grey (#9CA3AF)
|
|
18
|
+
darkGrey: '\x1b[38;2;55;65;81m', // Dark grey (#374151)
|
|
19
|
+
|
|
20
|
+
// Additional colors
|
|
21
|
+
red: '\x1b[31m',
|
|
22
|
+
yellow: '\x1b[33m',
|
|
23
|
+
blue: '\x1b[34m',
|
|
24
|
+
magenta: '\x1b[35m',
|
|
25
|
+
cyan: '\x1b[36m'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Elegant text styling functions
|
|
29
|
+
const logo = (text) => `${colors.bright}${colors.green}${text}${colors.reset}`;
|
|
30
|
+
const heading = (text) => `${colors.bright}${colors.white}${text}${colors.reset}`;
|
|
31
|
+
const accent = (text) => `${colors.green}${text}${colors.reset}`;
|
|
32
|
+
const body = (text) => `${colors.lightGrey}${text}${colors.reset}`;
|
|
33
|
+
const muted = (text) => `${colors.dim}${colors.lightGrey}${text}${colors.reset}`;
|
|
34
|
+
const error = (text) => `${colors.red}${text}${colors.reset}`;
|
|
35
|
+
const warning = (text) => `${colors.yellow}${text}${colors.reset}`;
|
|
36
|
+
const success = (text) => `${colors.green}${text}${colors.reset}`;
|
|
12
37
|
|
|
13
|
-
// Create readline interface
|
|
38
|
+
// Create readline interface
|
|
14
39
|
const rl = readline.createInterface({
|
|
15
40
|
input: process.stdin,
|
|
16
41
|
output: process.stdout
|
|
17
42
|
});
|
|
18
43
|
|
|
19
|
-
//
|
|
44
|
+
// Display elegant header
|
|
45
|
+
const displayHeader = () => {
|
|
46
|
+
console.clear();
|
|
47
|
+
console.log();
|
|
48
|
+
console.log(' ' + '─'.repeat(80));
|
|
49
|
+
console.log();
|
|
50
|
+
console.log(' ' + ' '.repeat(35) + logo('ZEN') + ' '.repeat(35));
|
|
51
|
+
console.log();
|
|
52
|
+
console.log(' ' + ' '.repeat(20) + body('Professional Starter Kit • MIT License') + ' '.repeat(20));
|
|
53
|
+
console.log();
|
|
54
|
+
console.log(' ' + '─'.repeat(80));
|
|
55
|
+
console.log();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Get project name with elegant styling
|
|
20
59
|
const getProjectName = () => {
|
|
21
60
|
return new Promise((resolve) => {
|
|
22
|
-
rl.question(
|
|
61
|
+
rl.question(' 📝 ' + body('Enter your project name: ') + muted(' (press Enter for zen-starter-app) '), (answer) => {
|
|
23
62
|
const projectName = answer.trim() || 'zen-starter-app';
|
|
24
|
-
rl.close();
|
|
25
63
|
resolve(projectName);
|
|
26
64
|
});
|
|
27
65
|
});
|
|
28
66
|
};
|
|
29
67
|
|
|
30
|
-
//
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
68
|
+
// Get project version choice with elegant styling
|
|
69
|
+
const getProjectVersion = () => {
|
|
70
|
+
return new Promise((resolve) => {
|
|
71
|
+
console.log();
|
|
72
|
+
console.log(' ' + heading('Choose your ZEN starter version:'));
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(' ' + muted('1.') + ' ' + accent('Standard Version') + ' ' + body('- Full-featured with all components'));
|
|
75
|
+
console.log(' ' + muted('2.') + ' ' + accent('Lite Version') + ' ' + body('- Lightweight for static sites'));
|
|
76
|
+
console.log();
|
|
77
|
+
|
|
78
|
+
rl.question(' 🎯 ' + body('Select version (1 or 2): ') + muted(' (default: 1) '), (answer) => {
|
|
79
|
+
const choice = answer.trim() || '1';
|
|
80
|
+
const isLite = choice === '2';
|
|
81
|
+
resolve(isLite);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
37
85
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
86
|
+
// Get repository URL based on choice
|
|
87
|
+
const getRepositoryUrl = (isLite) => {
|
|
88
|
+
if (isLite) {
|
|
89
|
+
return 'https://github.com/dmitry-conquer/zen-starter-lite.git';
|
|
41
90
|
}
|
|
91
|
+
return 'https://github.com/dmitry-conquer/zen-starter.git';
|
|
92
|
+
};
|
|
42
93
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.error(red('❌ Клонування не вдалося. Перевірте підключення до інтернету або права доступу.'));
|
|
48
|
-
process.exit(1);
|
|
94
|
+
// Get version description
|
|
95
|
+
const getVersionDescription = (isLite) => {
|
|
96
|
+
if (isLite) {
|
|
97
|
+
return 'Lite Version - Lightweight for static sites';
|
|
49
98
|
}
|
|
99
|
+
return 'Standard Version - Full-featured with all components';
|
|
100
|
+
};
|
|
50
101
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log();
|
|
55
|
-
console.log(green('✅ Все готово! Ваш проект створено.'));
|
|
56
|
-
console.log();
|
|
57
|
-
console.log('👉', cyan('Наступні кроки:'));
|
|
102
|
+
// Display project summary
|
|
103
|
+
const displaySummary = (projectName, versionDesc, repoUrl) => {
|
|
58
104
|
console.log();
|
|
59
|
-
console.log(
|
|
60
|
-
console.log('
|
|
61
|
-
console.log('
|
|
62
|
-
console.log();
|
|
63
|
-
console.log('
|
|
105
|
+
console.log(' ' + '─'.repeat(80));
|
|
106
|
+
console.log(' 📋 ' + heading('Project Summary'));
|
|
107
|
+
console.log(' ' + '─'.repeat(80));
|
|
108
|
+
console.log(' 🏷️ ' + accent('Project Name:') + ' ' + heading(projectName));
|
|
109
|
+
console.log(' 🎯 ' + accent('Version:') + ' ' + heading(versionDesc));
|
|
110
|
+
console.log(' 🔗 ' + accent('Repository:') + ' ' + muted(repoUrl));
|
|
111
|
+
console.log(' ' + '─'.repeat(80));
|
|
64
112
|
console.log();
|
|
65
113
|
};
|
|
66
114
|
|
|
115
|
+
// Main function
|
|
116
|
+
const main = async () => {
|
|
117
|
+
try {
|
|
118
|
+
displayHeader();
|
|
119
|
+
|
|
120
|
+
const PROJECT_NAME = await getProjectName();
|
|
121
|
+
const isLite = await getProjectVersion();
|
|
122
|
+
const REPO_URL = getRepositoryUrl(isLite);
|
|
123
|
+
const VERSION_DESC = getVersionDescription(isLite);
|
|
124
|
+
|
|
125
|
+
displaySummary(PROJECT_NAME, VERSION_DESC, REPO_URL);
|
|
126
|
+
|
|
127
|
+
if (fs.existsSync(PROJECT_NAME)) {
|
|
128
|
+
console.log(' ' + error('⛔ Directory "' + PROJECT_NAME + '" already exists!'));
|
|
129
|
+
console.log(' 💡 ' + body('Please choose a different name or remove the existing directory.'));
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(' 🚀 ' + warning(`Cloning ${VERSION_DESC} into "${PROJECT_NAME}"...`));
|
|
134
|
+
console.log();
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
execSync(`git clone --depth=1 "${REPO_URL}" "${PROJECT_NAME}"`, { stdio: 'inherit' });
|
|
138
|
+
} catch (err) {
|
|
139
|
+
console.log(' ' + error('❌ Clone failed. Please check your internet connection or permissions.'));
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Remove .git so the created project is not a git repo
|
|
144
|
+
fs.rmSync(path.join(PROJECT_NAME, '.git'), { recursive: true, force: true });
|
|
145
|
+
|
|
146
|
+
console.log();
|
|
147
|
+
console.log(' ' + '─'.repeat(80));
|
|
148
|
+
console.log(' ' + success('✅ SUCCESS! Your project is ready to go!') + ' 🎉');
|
|
149
|
+
console.log(' ' + '─'.repeat(80));
|
|
150
|
+
console.log();
|
|
151
|
+
console.log(' 🚀 ' + heading('Next steps:'));
|
|
152
|
+
console.log();
|
|
153
|
+
console.log(' 📁 ' + accent(`cd ${PROJECT_NAME}`));
|
|
154
|
+
console.log(' 📦 ' + accent('npm install'));
|
|
155
|
+
console.log(' 🧑💻 ' + accent('npm run dev'));
|
|
156
|
+
console.log();
|
|
157
|
+
console.log(' 🌟 ' + logo('Happy coding with ZEN!') + ' ✨');
|
|
158
|
+
console.log();
|
|
159
|
+
console.log(' ' + '─'.repeat(80));
|
|
160
|
+
console.log(' 💡 ' + muted('Need help? Check out the README.md file in your project!'));
|
|
161
|
+
console.log(' ' + '─'.repeat(80));
|
|
162
|
+
console.log();
|
|
163
|
+
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.log(' ' + error('❌ An error occurred:'), error.message);
|
|
166
|
+
process.exit(1);
|
|
167
|
+
} finally {
|
|
168
|
+
rl.close();
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
67
172
|
// Run the main function
|
|
68
|
-
main()
|
|
69
|
-
console.error(red('❌ Помилка:'), error.message);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
});
|
|
173
|
+
main();
|