@skalfa/skalfa-cli 1.0.2 → 1.0.3
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/dist/commands/create-api.js +11 -11
- package/package.json +1 -1
|
@@ -139,27 +139,33 @@ function customizeProject(target, opts) {
|
|
|
139
139
|
const utilsIndexPath = node_path_1.default.join(target, "utils", "index.ts");
|
|
140
140
|
const appTsPath = node_path_1.default.join(target, "app", "app.ts");
|
|
141
141
|
const isDev = !!process.env[TEMPLATE_ENV_KEY];
|
|
142
|
-
// 1. Update dependencies in package.json
|
|
142
|
+
// 1. Update dependencies and scripts in package.json
|
|
143
143
|
if (node_fs_1.default.existsSync(packageJsonPath)) {
|
|
144
144
|
const pkg = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
145
145
|
pkg.dependencies = pkg.dependencies || {};
|
|
146
|
+
pkg.scripts = pkg.scripts || {};
|
|
146
147
|
// Base ORM integration (always included)
|
|
147
148
|
pkg.dependencies["@skalfa/skalfa-orm"] = isDev ? "file:../skalfa-orm" : "^1.0.0";
|
|
148
149
|
if (isDev) {
|
|
149
150
|
pkg.dependencies["@skalfa/skalfa-api-core"] = "file:../skalfa-api-core";
|
|
150
151
|
}
|
|
152
|
+
const devCommands = ["bun run --watch app/app.ts", "bun skalfa watch:barrels"];
|
|
151
153
|
if (opts.redis) {
|
|
152
154
|
pkg.dependencies["@skalfa/skalfa-redis"] = isDev ? "file:../skalfa-redis" : "^1.0.0";
|
|
153
155
|
pkg.dependencies["ioredis"] = "^5.4.1";
|
|
154
156
|
}
|
|
155
157
|
if (opts.queue) {
|
|
156
158
|
pkg.dependencies["@skalfa/skalfa-queue"] = isDev ? "file:../skalfa-queue" : "^1.0.0";
|
|
159
|
+
pkg.scripts["start:queue"] = "bun run app/jobs/queues/worker.queue.ts";
|
|
160
|
+
devCommands.push("bun start:queue");
|
|
157
161
|
}
|
|
158
162
|
if (opts.cache) {
|
|
159
163
|
pkg.dependencies["@skalfa/skalfa-cache"] = isDev ? "file:../skalfa-cache" : "^1.0.0";
|
|
160
164
|
}
|
|
161
165
|
if (opts.cron) {
|
|
162
166
|
pkg.dependencies["@skalfa/skalfa-cron"] = isDev ? "file:../skalfa-cron" : "^1.0.0";
|
|
167
|
+
pkg.scripts["start:cron"] = "bun run app/jobs/crons/worker.cron.ts";
|
|
168
|
+
devCommands.push("bun start:cron");
|
|
163
169
|
}
|
|
164
170
|
if (opts.da) {
|
|
165
171
|
pkg.dependencies["@skalfa/skalfa-da"] = isDev ? "file:../skalfa-da" : "^1.0.0";
|
|
@@ -168,7 +174,11 @@ function customizeProject(target, opts) {
|
|
|
168
174
|
if (opts.socket) {
|
|
169
175
|
pkg.dependencies["@skalfa/skalfa-socket"] = isDev ? "file:../skalfa-socket" : "^1.0.0";
|
|
170
176
|
pkg.dependencies["socket.io"] = "^4.7.5";
|
|
177
|
+
pkg.scripts["start:socket"] = "bun run app/jobs/sockets/worker.socket.ts";
|
|
178
|
+
devCommands.push("bun start:socket");
|
|
171
179
|
}
|
|
180
|
+
// Update dev script with concurrently
|
|
181
|
+
pkg.scripts["dev"] = `concurrently --raw ${devCommands.map(cmd => `\\"${cmd}\\"`).join(" ")}`;
|
|
172
182
|
node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2), "utf8");
|
|
173
183
|
}
|
|
174
184
|
// 2. Add path mappings in tsconfig.json
|
|
@@ -252,16 +262,6 @@ function customizeProject(target, opts) {
|
|
|
252
262
|
// Uncomment DA block
|
|
253
263
|
content = content.replace(/\/\/ if \(process\.env\.DA_HOST[\s\S]*?\/\/ }/g, (match) => match.replace(/^\/\/ ?/gm, ""));
|
|
254
264
|
}
|
|
255
|
-
if (opts.cron) {
|
|
256
|
-
importsToAdd.push("cron");
|
|
257
|
-
// Uncomment Cron block
|
|
258
|
-
content = content.replace(/\/\/ cron\.worker\(\)/g, "cron.worker()");
|
|
259
|
-
}
|
|
260
|
-
if (opts.socket) {
|
|
261
|
-
importsToAdd.push("socket");
|
|
262
|
-
// Uncomment Socket block
|
|
263
|
-
content = content.replace(/\/\/ if \(process\.env\.SOCKET_PORT[\s\S]*?\/\/ }/g, (match) => match.replace(/^\/\/ ?/gm, ""));
|
|
264
|
-
}
|
|
265
265
|
// Update import statement at the top of app.ts
|
|
266
266
|
if (importsToAdd.length > 0) {
|
|
267
267
|
const baseImports = ["controller", "db", "logger", "middleware", "storage", "registry"];
|