zyket 1.2.6 → 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/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();
|
|
@@ -63,11 +64,41 @@ const templateManager = new TemplateManager();
|
|
|
63
64
|
console.log('[ZYKET] Creating .env file...');
|
|
64
65
|
EnvManager.createEnvFile(envPath);
|
|
65
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
|
+
|
|
66
93
|
// Create index.js with boilerplate code
|
|
67
94
|
console.log('[ZYKET] Creating index.js...');
|
|
68
95
|
const indexContent = `const { Kernel } = require('zyket');
|
|
69
96
|
|
|
70
|
-
const kernel = new Kernel(
|
|
97
|
+
const kernel = new Kernel({
|
|
98
|
+
services: [
|
|
99
|
+
['auth', require('./src/services/auth'), ["@service_container"]],
|
|
100
|
+
]
|
|
101
|
+
});
|
|
71
102
|
|
|
72
103
|
kernel.boot().then(() => {
|
|
73
104
|
console.log('Kernel booted successfully!');
|
|
@@ -99,11 +130,68 @@ kernel.boot().then(() => {
|
|
|
99
130
|
}
|
|
100
131
|
|
|
101
132
|
console.log('\n[ZYKET] ✅ Project initialized successfully!');
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
}
|
|
107
195
|
},
|
|
108
196
|
'install-template': async () => {
|
|
109
197
|
const templates = templateManager.getTemplates();
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|