zyket 1.2.4 → 1.2.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/README.md +31 -1
- package/bin/cli.js +69 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,37 @@ Upon initial boot, Zyket automatically scaffolds a default project structure, in
|
|
|
6
6
|
|
|
7
7
|
## Getting Started
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Quick Start (Recommended)
|
|
10
|
+
|
|
11
|
+
The easiest way to get started with Zyket is to use the CLI initialization command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Create a new directory for your project
|
|
15
|
+
mkdir my-zyket-app
|
|
16
|
+
cd my-zyket-app
|
|
17
|
+
|
|
18
|
+
# Install zyket
|
|
19
|
+
npm install zyket
|
|
20
|
+
|
|
21
|
+
# Initialize the project
|
|
22
|
+
npx zyket init
|
|
23
|
+
|
|
24
|
+
# Install dependencies (if not already done)
|
|
25
|
+
npm install
|
|
26
|
+
|
|
27
|
+
# Start your application
|
|
28
|
+
npm run dev
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The `init` command will:
|
|
32
|
+
- Create an `index.js` file with the kernel boilerplate
|
|
33
|
+
- Generate a `.env` file with sensible defaults
|
|
34
|
+
- Create a `package.json` if one doesn't exist
|
|
35
|
+
- Set up your project ready to run
|
|
36
|
+
|
|
37
|
+
### Manual Setup (Alternative)
|
|
38
|
+
|
|
39
|
+
If you prefer to set up manually, install Zyket in your project:
|
|
10
40
|
|
|
11
41
|
```bash
|
|
12
42
|
npm i zyket
|
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const prompts = require('prompts');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
3
5
|
const TemplateManager = require('../src/services/template-manager');
|
|
6
|
+
const EnvManager = require('../src/utils/EnvManager');
|
|
4
7
|
const templateManager = new TemplateManager();
|
|
5
8
|
|
|
6
9
|
(async () => {
|
|
@@ -11,6 +14,7 @@ const templateManager = new TemplateManager();
|
|
|
11
14
|
name: 'value',
|
|
12
15
|
message: '[ZYKET] What do you want to do?',
|
|
13
16
|
choices: [
|
|
17
|
+
{ title: 'Initialize Project', value: 'init-project', description: 'Set up a new Zyket project', disabled: false },
|
|
14
18
|
{ title: 'Install Template', value: 'install-template', description: 'Install a new template', disabled: false },
|
|
15
19
|
/*{ title: 'Remove Template', value: 'remove-template', description: 'Remove an existing template', disabled: false },*/
|
|
16
20
|
],
|
|
@@ -18,6 +22,71 @@ const templateManager = new TemplateManager();
|
|
|
18
22
|
});
|
|
19
23
|
|
|
20
24
|
const actions = {
|
|
25
|
+
'init-project': async () => {
|
|
26
|
+
const indexPath = path.join(process.cwd(), 'index.js');
|
|
27
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
28
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json');
|
|
29
|
+
|
|
30
|
+
// Check if index.js already exists
|
|
31
|
+
if (fs.existsSync(indexPath)) {
|
|
32
|
+
const overwrite = await prompts({
|
|
33
|
+
type: 'confirm',
|
|
34
|
+
name: 'value',
|
|
35
|
+
message: '[ZYKET] index.js already exists. Overwrite?',
|
|
36
|
+
initial: false
|
|
37
|
+
});
|
|
38
|
+
if (!overwrite.value) {
|
|
39
|
+
console.log('[ZYKET] Initialization cancelled.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Create .env file
|
|
45
|
+
console.log('[ZYKET] Creating .env file...');
|
|
46
|
+
EnvManager.createEnvFile(envPath);
|
|
47
|
+
|
|
48
|
+
// Create index.js with boilerplate code
|
|
49
|
+
console.log('[ZYKET] Creating index.js...');
|
|
50
|
+
const indexContent = `const { Kernel } = require('zyket');
|
|
51
|
+
|
|
52
|
+
const kernel = new Kernel();
|
|
53
|
+
|
|
54
|
+
kernel.boot().then(() => {
|
|
55
|
+
console.log('Kernel booted successfully!');
|
|
56
|
+
}).catch((error) => {
|
|
57
|
+
console.error('Error booting kernel:', error);
|
|
58
|
+
});
|
|
59
|
+
`;
|
|
60
|
+
fs.writeFileSync(indexPath, indexContent);
|
|
61
|
+
|
|
62
|
+
// Create package.json if it doesn't exist
|
|
63
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
64
|
+
console.log('[ZYKET] Creating package.json...');
|
|
65
|
+
const packageJson = {
|
|
66
|
+
name: path.basename(process.cwd()),
|
|
67
|
+
version: "1.0.0",
|
|
68
|
+
description: "Zyket application",
|
|
69
|
+
main: "index.js",
|
|
70
|
+
scripts: {
|
|
71
|
+
dev: "node index.js"
|
|
72
|
+
},
|
|
73
|
+
keywords: [],
|
|
74
|
+
author: "",
|
|
75
|
+
license: "ISC",
|
|
76
|
+
dependencies: {
|
|
77
|
+
zyket: "^1.2.3"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log('\n[ZYKET] ✅ Project initialized successfully!');
|
|
84
|
+
console.log('\n[ZYKET] Next steps:');
|
|
85
|
+
console.log(' 1. Review and update your .env file');
|
|
86
|
+
console.log(' 2. Run: npm install (if you haven\'t already)');
|
|
87
|
+
console.log(' 3. Run: npm run dev');
|
|
88
|
+
console.log('\n[ZYKET] Happy coding! 🚀\n');
|
|
89
|
+
},
|
|
21
90
|
'install-template': async () => {
|
|
22
91
|
const templates = templateManager.getTemplates();
|
|
23
92
|
const response = await prompts({
|