zyket 1.2.5 → 1.2.7
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
CHANGED
|
@@ -18,12 +18,9 @@ cd my-zyket-app
|
|
|
18
18
|
# Install zyket
|
|
19
19
|
npm install zyket
|
|
20
20
|
|
|
21
|
-
# Initialize the project
|
|
21
|
+
# Initialize the project (one command!)
|
|
22
22
|
npx zyket init
|
|
23
23
|
|
|
24
|
-
# Install dependencies (if not already done)
|
|
25
|
-
npm install
|
|
26
|
-
|
|
27
24
|
# Start your application
|
|
28
25
|
npm run dev
|
|
29
26
|
```
|
|
@@ -34,6 +31,8 @@ The `init` command will:
|
|
|
34
31
|
- Create a `package.json` if one doesn't exist
|
|
35
32
|
- Set up your project ready to run
|
|
36
33
|
|
|
34
|
+
You can also run `npx zyket` without arguments for an interactive menu with more options.
|
|
35
|
+
|
|
37
36
|
### Manual Setup (Alternative)
|
|
38
37
|
|
|
39
38
|
If you prefer to set up manually, install Zyket in your project:
|
package/bin/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const prompts = require('prompts');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const { spawn } = require('child_process');
|
|
5
6
|
const TemplateManager = require('../src/services/template-manager');
|
|
6
7
|
const EnvManager = require('../src/utils/EnvManager');
|
|
7
8
|
const templateManager = new TemplateManager();
|
|
@@ -9,17 +10,35 @@ const templateManager = new TemplateManager();
|
|
|
9
10
|
(async () => {
|
|
10
11
|
process.stdout.write("\u001b[2J\u001b[0;0H");
|
|
11
12
|
await templateManager.boot();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
|
|
14
|
+
// Check for direct command (e.g., npx zyket init)
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
const directCommand = args[0];
|
|
17
|
+
|
|
18
|
+
let actionToRun = null;
|
|
19
|
+
|
|
20
|
+
if (directCommand === 'init') {
|
|
21
|
+
actionToRun = 'init-project';
|
|
22
|
+
} else {
|
|
23
|
+
// Show interactive menu
|
|
24
|
+
const response = await prompts({
|
|
25
|
+
type: 'select',
|
|
26
|
+
name: 'value',
|
|
27
|
+
message: '[ZYKET] What do you want to do?',
|
|
28
|
+
choices: [
|
|
29
|
+
{ title: 'Initialize Project', value: 'init-project', description: 'Set up a new Zyket project', disabled: false },
|
|
30
|
+
{ title: 'Install Template', value: 'install-template', description: 'Install a new template', disabled: false },
|
|
31
|
+
/*{ title: 'Remove Template', value: 'remove-template', description: 'Remove an existing template', disabled: false },*/
|
|
32
|
+
],
|
|
33
|
+
initial: 0
|
|
34
|
+
});
|
|
35
|
+
actionToRun = response.value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!actionToRun) {
|
|
39
|
+
console.log('[ZYKET] No action selected. Exiting.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
23
42
|
|
|
24
43
|
const actions = {
|
|
25
44
|
'init-project': async () => {
|
|
@@ -45,11 +64,41 @@ const templateManager = new TemplateManager();
|
|
|
45
64
|
console.log('[ZYKET] Creating .env file...');
|
|
46
65
|
EnvManager.createEnvFile(envPath);
|
|
47
66
|
|
|
67
|
+
// Install default backend template files (src and config)
|
|
68
|
+
console.log('[ZYKET] Installing default backend template files...');
|
|
69
|
+
const defaultTemplate = templateManager.getTemplate('default');
|
|
70
|
+
const backendFiles = defaultTemplate.filter(file => {
|
|
71
|
+
const route = file.route;
|
|
72
|
+
// Only install src and config files, not frontend
|
|
73
|
+
return route.startsWith('default/src/') || route.startsWith('default/config/');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
for (const file of backendFiles) {
|
|
77
|
+
const fileName = file.route.split('/').slice(1).join('/');
|
|
78
|
+
const fileLocation = path.join(process.cwd(), fileName);
|
|
79
|
+
const folderLocation = path.dirname(fileLocation);
|
|
80
|
+
|
|
81
|
+
// Create directory if it doesn't exist
|
|
82
|
+
if (!fs.existsSync(folderLocation)) {
|
|
83
|
+
fs.mkdirSync(folderLocation, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Write file if it doesn't exist
|
|
87
|
+
if (!fs.existsSync(fileLocation)) {
|
|
88
|
+
fs.writeFileSync(fileLocation, file.content);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
console.log('[ZYKET] ✅ Backend template files installed');
|
|
92
|
+
|
|
48
93
|
// Create index.js with boilerplate code
|
|
49
94
|
console.log('[ZYKET] Creating index.js...');
|
|
50
95
|
const indexContent = `const { Kernel } = require('zyket');
|
|
51
96
|
|
|
52
|
-
const kernel = new Kernel(
|
|
97
|
+
const kernel = new Kernel({
|
|
98
|
+
services: [
|
|
99
|
+
['auth', require('./src/services/auth'), ["@service_container"]],
|
|
100
|
+
]
|
|
101
|
+
});
|
|
53
102
|
|
|
54
103
|
kernel.boot().then(() => {
|
|
55
104
|
console.log('Kernel booted successfully!');
|
|
@@ -81,11 +130,68 @@ kernel.boot().then(() => {
|
|
|
81
130
|
}
|
|
82
131
|
|
|
83
132
|
console.log('\n[ZYKET] ✅ Project initialized successfully!');
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
133
|
+
|
|
134
|
+
// Ask if user wants to install dependencies
|
|
135
|
+
const installDeps = await prompts({
|
|
136
|
+
type: 'confirm',
|
|
137
|
+
name: 'value',
|
|
138
|
+
message: '[ZYKET] Install dependencies now?',
|
|
139
|
+
initial: true
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
if (installDeps.value) {
|
|
143
|
+
console.log('\n[ZYKET] Installing dependencies...');
|
|
144
|
+
await new Promise((resolve, reject) => {
|
|
145
|
+
const npmInstall = spawn('npm', ['install'], {
|
|
146
|
+
cwd: process.cwd(),
|
|
147
|
+
stdio: 'inherit',
|
|
148
|
+
shell: true
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
npmInstall.on('close', (code) => {
|
|
152
|
+
if (code === 0) {
|
|
153
|
+
console.log('[ZYKET] ✅ Dependencies installed successfully!');
|
|
154
|
+
resolve();
|
|
155
|
+
} else {
|
|
156
|
+
reject(new Error(`npm install exited with code ${code}`));
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
npmInstall.on('error', (error) => {
|
|
161
|
+
reject(error);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Ask if user wants to start the project
|
|
166
|
+
const startProject = await prompts({
|
|
167
|
+
type: 'confirm',
|
|
168
|
+
name: 'value',
|
|
169
|
+
message: '[ZYKET] Start the project now?',
|
|
170
|
+
initial: true
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (startProject.value) {
|
|
174
|
+
console.log('\n[ZYKET] Starting project...\n');
|
|
175
|
+
const nodeStart = spawn('node', ['index.js'], {
|
|
176
|
+
cwd: process.cwd(),
|
|
177
|
+
stdio: 'inherit',
|
|
178
|
+
shell: true
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
nodeStart.on('error', (error) => {
|
|
182
|
+
console.error('[ZYKET] Error starting project:', error);
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
console.log('\n[ZYKET] Run "npm run dev" to start your application.');
|
|
186
|
+
console.log('\n[ZYKET] Happy coding! 🚀\n');
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
console.log('\n[ZYKET] Next steps:');
|
|
190
|
+
console.log(' 1. Run: npm install');
|
|
191
|
+
console.log(' 2. Review and update your .env file');
|
|
192
|
+
console.log(' 3. Run: npm run dev');
|
|
193
|
+
console.log('\n[ZYKET] Happy coding! 🚀\n');
|
|
194
|
+
}
|
|
89
195
|
},
|
|
90
196
|
'install-template': async () => {
|
|
91
197
|
const templates = templateManager.getTemplates();
|
|
@@ -116,5 +222,5 @@ kernel.boot().then(() => {
|
|
|
116
222
|
}*/
|
|
117
223
|
};
|
|
118
224
|
|
|
119
|
-
await actions[
|
|
225
|
+
await actions[actionToRun]();
|
|
120
226
|
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zyket",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"@tailwindcss/vite": "^4.2.2",
|
|
18
18
|
"@vitejs/plugin-react": "^6.0.1",
|
|
19
19
|
"better-auth": "^1.5.6",
|
|
20
|
+
"better-sqlite3": "^12.8.0",
|
|
20
21
|
"bullmq": "^5.71.0",
|
|
21
22
|
"colors": "^1.4.0",
|
|
22
23
|
"cors": "^2.8.6",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { AuthService } = require('zyket');
|
|
2
|
+
|
|
3
|
+
module.exports = class CustomAuthService extends AuthService {
|
|
4
|
+
#container;
|
|
5
|
+
client;
|
|
6
|
+
|
|
7
|
+
constructor(container) {
|
|
8
|
+
super(container);
|
|
9
|
+
this.#container = container;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get userAdditionalFields() {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get organizationAdditionalFields() {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async sendResetPasswordEmail({ user, url, token }, request) {
|
|
19
|
+
throw new Error("sendResetPasswordEmail method not implemented");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async sendVerificationEmail({ user, url, token }, request) {
|
|
23
|
+
throw new Error("sendVerificationEmail method not implemented");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async sendInvitationEmail(data) {
|
|
27
|
+
throw new Error("sendInvitationEmail method not implemented");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async allowUserToCreateOrganization(user) {
|
|
31
|
+
throw new Error("allowUserToCreateOrganization method not implemented");
|
|
32
|
+
}
|
|
33
|
+
}
|