create-kimchi-app 1.0.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 +44 -0
- package/index.js +214 -0
- package/package.json +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# create-kimchi-app
|
|
2
|
+
|
|
3
|
+
Bootstrap a new KimchiLang application with a single command.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-kimchi-app my-app
|
|
9
|
+
cd my-app
|
|
10
|
+
kimchi src.main
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## What's Included
|
|
14
|
+
|
|
15
|
+
The generated project includes:
|
|
16
|
+
|
|
17
|
+
- `project.static` - Project configuration
|
|
18
|
+
- `src/main.km` - Main entry point
|
|
19
|
+
- `lib/utils.km` - Example utility module
|
|
20
|
+
- `tests/utils.test.km` - Example tests
|
|
21
|
+
- `.gitignore` - Git ignore file
|
|
22
|
+
- `README.md` - Project documentation
|
|
23
|
+
|
|
24
|
+
## Project Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
my-app/
|
|
28
|
+
├── project.static
|
|
29
|
+
├── README.md
|
|
30
|
+
├── .gitignore
|
|
31
|
+
├── src/
|
|
32
|
+
│ └── main.km
|
|
33
|
+
├── lib/
|
|
34
|
+
│ └── utils.km
|
|
35
|
+
└── tests/
|
|
36
|
+
└── utils.test.km
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Options
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx create-kimchi-app --help # Show help
|
|
43
|
+
npx create-kimchi-app --version # Show version
|
|
44
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { mkdirSync, writeFileSync, existsSync, cpSync } from 'fs';
|
|
4
|
+
import { resolve, join, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
const TEMPLATE_DIR = join(__dirname, 'template');
|
|
11
|
+
|
|
12
|
+
const COLORS = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
bright: '\x1b[1m',
|
|
15
|
+
green: '\x1b[32m',
|
|
16
|
+
cyan: '\x1b[36m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
red: '\x1b[31m',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function log(message, color = '') {
|
|
22
|
+
console.log(color + message + COLORS.reset);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createProject(projectName) {
|
|
26
|
+
const projectPath = resolve(process.cwd(), projectName);
|
|
27
|
+
|
|
28
|
+
if (existsSync(projectPath)) {
|
|
29
|
+
log(`\nError: Directory "${projectName}" already exists.`, COLORS.red);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
log(`\n🌶️ Creating KimchiLang project: ${projectName}\n`, COLORS.bright + COLORS.cyan);
|
|
34
|
+
|
|
35
|
+
// Create project directory
|
|
36
|
+
mkdirSync(projectPath, { recursive: true });
|
|
37
|
+
|
|
38
|
+
// Create project structure
|
|
39
|
+
const dirs = ['src', 'lib', 'tests'];
|
|
40
|
+
for (const dir of dirs) {
|
|
41
|
+
mkdirSync(join(projectPath, dir), { recursive: true });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Create project.static
|
|
45
|
+
writeFileSync(join(projectPath, 'project.static'), `// KimchiLang Project Configuration
|
|
46
|
+
name "${projectName}"
|
|
47
|
+
version "1.0.0"
|
|
48
|
+
|
|
49
|
+
// External dependencies (uncomment to add)
|
|
50
|
+
// depend [
|
|
51
|
+
// "github.com/kimchilang/stdlib"
|
|
52
|
+
// ]
|
|
53
|
+
`);
|
|
54
|
+
|
|
55
|
+
// Create main entry point
|
|
56
|
+
writeFileSync(join(projectPath, 'src', 'main.km'), `// ${projectName} - Main Entry Point
|
|
57
|
+
|
|
58
|
+
// Example function
|
|
59
|
+
expose fn greet(name) {
|
|
60
|
+
return "Hello, \${name}! Welcome to KimchiLang 🌶️"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Run when executed directly
|
|
64
|
+
dec message = greet("World")
|
|
65
|
+
print message
|
|
66
|
+
`);
|
|
67
|
+
|
|
68
|
+
// Create a lib module
|
|
69
|
+
writeFileSync(join(projectPath, 'lib', 'utils.km'), `// Utility functions
|
|
70
|
+
|
|
71
|
+
expose fn add(a, b) {
|
|
72
|
+
return a + b
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
expose fn multiply(a, b) {
|
|
76
|
+
return a * b
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
expose fn range(start, end) {
|
|
80
|
+
return start..end
|
|
81
|
+
}
|
|
82
|
+
`);
|
|
83
|
+
|
|
84
|
+
// Create a test file
|
|
85
|
+
writeFileSync(join(projectPath, 'tests', 'utils.test.km'), `// Tests for lib/utils.km
|
|
86
|
+
as utils dep lib.utils
|
|
87
|
+
|
|
88
|
+
describe "Utils" {
|
|
89
|
+
test "add returns correct sum" {
|
|
90
|
+
expect(utils.add(2, 3)).toBe(5)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
test "multiply returns correct product" {
|
|
94
|
+
expect(utils.multiply(3, 4)).toBe(12)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
test "range creates array" {
|
|
98
|
+
dec nums = utils.range(1, 5)
|
|
99
|
+
expect(nums).toHaveLength(4)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`);
|
|
103
|
+
|
|
104
|
+
// Create README
|
|
105
|
+
writeFileSync(join(projectPath, 'README.md'), `# ${projectName}
|
|
106
|
+
|
|
107
|
+
A KimchiLang project.
|
|
108
|
+
|
|
109
|
+
## Getting Started
|
|
110
|
+
|
|
111
|
+
\`\`\`bash
|
|
112
|
+
# Run the main module
|
|
113
|
+
kimchi src.main
|
|
114
|
+
|
|
115
|
+
# Run tests
|
|
116
|
+
kimchi tests.utils.test
|
|
117
|
+
|
|
118
|
+
# Install dependencies (if any)
|
|
119
|
+
kimchi install
|
|
120
|
+
\`\`\`
|
|
121
|
+
|
|
122
|
+
## Project Structure
|
|
123
|
+
|
|
124
|
+
\`\`\`
|
|
125
|
+
${projectName}/
|
|
126
|
+
├── project.static # Project configuration
|
|
127
|
+
├── src/
|
|
128
|
+
│ └── main.km # Main entry point
|
|
129
|
+
├── lib/
|
|
130
|
+
│ └── utils.km # Utility functions
|
|
131
|
+
└── tests/
|
|
132
|
+
└── utils.test.km # Unit tests
|
|
133
|
+
\`\`\`
|
|
134
|
+
|
|
135
|
+
## Learn More
|
|
136
|
+
|
|
137
|
+
- [KimchiLang Documentation](https://github.com/kimchilang/kimchilang)
|
|
138
|
+
`);
|
|
139
|
+
|
|
140
|
+
// Create .gitignore
|
|
141
|
+
writeFileSync(join(projectPath, '.gitignore'), `# Dependencies
|
|
142
|
+
.km_modules/
|
|
143
|
+
|
|
144
|
+
# Compiled output
|
|
145
|
+
*.js
|
|
146
|
+
!*.config.js
|
|
147
|
+
|
|
148
|
+
# IDE
|
|
149
|
+
.idea/
|
|
150
|
+
.vscode/
|
|
151
|
+
*.swp
|
|
152
|
+
*.swo
|
|
153
|
+
|
|
154
|
+
# OS
|
|
155
|
+
.DS_Store
|
|
156
|
+
Thumbs.db
|
|
157
|
+
`);
|
|
158
|
+
|
|
159
|
+
log(' Created project structure:', COLORS.green);
|
|
160
|
+
log(` ${projectName}/`);
|
|
161
|
+
log(' ├── project.static');
|
|
162
|
+
log(' ├── README.md');
|
|
163
|
+
log(' ├── .gitignore');
|
|
164
|
+
log(' ├── src/');
|
|
165
|
+
log(' │ └── main.km');
|
|
166
|
+
log(' ├── lib/');
|
|
167
|
+
log(' │ └── utils.km');
|
|
168
|
+
log(' └── tests/');
|
|
169
|
+
log(' └── utils.test.km');
|
|
170
|
+
|
|
171
|
+
log('\n✨ Done! To get started:\n', COLORS.bright + COLORS.green);
|
|
172
|
+
log(` cd ${projectName}`, COLORS.cyan);
|
|
173
|
+
log(' kimchi src.main', COLORS.cyan);
|
|
174
|
+
log('');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function showHelp() {
|
|
178
|
+
log('\n🌶️ create-kimchi-app\n', COLORS.bright + COLORS.cyan);
|
|
179
|
+
log('Usage:');
|
|
180
|
+
log(' npx create-kimchi-app <project-name>');
|
|
181
|
+
log(' npx create-kimchi-app my-app\n');
|
|
182
|
+
log('Options:');
|
|
183
|
+
log(' --help, -h Show this help message');
|
|
184
|
+
log(' --version Show version\n');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Main
|
|
188
|
+
const args = process.argv.slice(2);
|
|
189
|
+
|
|
190
|
+
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
191
|
+
showHelp();
|
|
192
|
+
process.exit(0);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (args.includes('--version')) {
|
|
196
|
+
log('create-kimchi-app v1.0.0');
|
|
197
|
+
process.exit(0);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const projectName = args[0];
|
|
201
|
+
|
|
202
|
+
if (!projectName || projectName.startsWith('-')) {
|
|
203
|
+
log('\nError: Please provide a project name.', COLORS.red);
|
|
204
|
+
showHelp();
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Validate project name
|
|
209
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(projectName)) {
|
|
210
|
+
log('\nError: Project name must start with a letter and contain only letters, numbers, underscores, and hyphens.', COLORS.red);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
createProject(projectName);
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-kimchi-app",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create a new KimchiLang application",
|
|
5
|
+
"bin": {
|
|
6
|
+
"create-kimchi-app": "./index.js"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"kimchi",
|
|
11
|
+
"kimchilang",
|
|
12
|
+
"create",
|
|
13
|
+
"bootstrap",
|
|
14
|
+
"cli"
|
|
15
|
+
],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/kimchilang/kimchilang"
|
|
21
|
+
}
|
|
22
|
+
}
|