@skalfa/skalfa-cli 1.0.3 → 1.0.4
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/add-extension.js +36 -11
- package/dist/commands/create-api.js +8 -1
- package/package.json +1 -1
- package/dist/bin/aluna.js +0 -44
- package/dist/bin/kava.js +0 -70
|
@@ -20,7 +20,6 @@ exports.extensions = {
|
|
|
20
20
|
cron: "@skalfa/skalfa-cron",
|
|
21
21
|
da: "@skalfa/skalfa-da",
|
|
22
22
|
socket: "@skalfa/skalfa-socket",
|
|
23
|
-
notification: "@skalfa/notification",
|
|
24
23
|
orm: "@skalfa/skalfa-orm"
|
|
25
24
|
};
|
|
26
25
|
exports.extensionNames = Object.keys(exports.extensions);
|
|
@@ -267,16 +266,6 @@ async function scaffoldUtilityExtension(projectRoot, ext) {
|
|
|
267
266
|
// Uncomment DA block
|
|
268
267
|
content = content.replace(/\/\/ if \(process\.env\.DA_HOST[\s\S]*?\/\/ }/g, (match) => match.replace(/^\/\/ ?/gm, ""));
|
|
269
268
|
}
|
|
270
|
-
if (ext === "cron") {
|
|
271
|
-
importsToAdd.push("cron");
|
|
272
|
-
// Uncomment Cron block
|
|
273
|
-
content = content.replace(/\/\/ cron\.worker\(\)/g, "cron.worker()");
|
|
274
|
-
}
|
|
275
|
-
if (ext === "socket") {
|
|
276
|
-
importsToAdd.push("socket");
|
|
277
|
-
// Uncomment Socket block
|
|
278
|
-
content = content.replace(/\/\/ if \(process\.env\.SOCKET_PORT[\s\S]*?\/\/ }/g, (match) => match.replace(/^\/\/ ?/gm, ""));
|
|
279
|
-
}
|
|
280
269
|
// Update import statement at the top of app.ts
|
|
281
270
|
if (importsToAdd.length > 0) {
|
|
282
271
|
const importRegex = /import\s*\{\s*([\s\S]*?)\s*\}\s*from\s*["']@utils["']/;
|
|
@@ -290,6 +279,42 @@ async function scaffoldUtilityExtension(projectRoot, ext) {
|
|
|
290
279
|
}
|
|
291
280
|
node_fs_1.default.writeFileSync(appTsPath, content, "utf8");
|
|
292
281
|
}
|
|
282
|
+
// 5. Update package.json scripts for workers
|
|
283
|
+
const packageJsonPath = node_path_1.default.join(projectRoot, "package.json");
|
|
284
|
+
if (node_fs_1.default.existsSync(packageJsonPath) && ["cron", "queue", "socket"].includes(ext)) {
|
|
285
|
+
const pkg = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
|
|
286
|
+
pkg.scripts = pkg.scripts || {};
|
|
287
|
+
let scriptKey = "";
|
|
288
|
+
let scriptVal = "";
|
|
289
|
+
if (ext === "cron") {
|
|
290
|
+
scriptKey = "start:cron";
|
|
291
|
+
scriptVal = "bun run app/jobs/crons/worker.cron.ts";
|
|
292
|
+
}
|
|
293
|
+
else if (ext === "queue") {
|
|
294
|
+
scriptKey = "start:queue";
|
|
295
|
+
scriptVal = "bun run app/jobs/queues/worker.queue.ts";
|
|
296
|
+
}
|
|
297
|
+
else if (ext === "socket") {
|
|
298
|
+
scriptKey = "start:socket";
|
|
299
|
+
scriptVal = "bun run app/jobs/sockets/worker.socket.ts";
|
|
300
|
+
}
|
|
301
|
+
if (scriptKey) {
|
|
302
|
+
pkg.scripts[scriptKey] = scriptVal;
|
|
303
|
+
// Update dev concurrently command
|
|
304
|
+
const devScript = pkg.scripts["dev"] || "";
|
|
305
|
+
const runCmd = `bun ${scriptKey}`;
|
|
306
|
+
if (devScript.includes("concurrently")) {
|
|
307
|
+
if (!devScript.includes(runCmd)) {
|
|
308
|
+
const cleanDev = devScript.trim();
|
|
309
|
+
pkg.scripts["dev"] = `${cleanDev} "${runCmd}"`;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
pkg.scripts["dev"] = `concurrently --raw "bun run --watch app/app.ts" "bun skalfa watch:barrels" "${runCmd}"`;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2), "utf8");
|
|
317
|
+
}
|
|
293
318
|
}
|
|
294
319
|
finally {
|
|
295
320
|
cleanup();
|
|
@@ -105,9 +105,16 @@ async function createApi(projectName) {
|
|
|
105
105
|
// Cleanup temp extract folder
|
|
106
106
|
node_fs_1.default.rmSync(tempExtractDir, { recursive: true, force: true });
|
|
107
107
|
}
|
|
108
|
-
// Cleanup git
|
|
108
|
+
// Cleanup git and github directories if present and rename package
|
|
109
109
|
(0, fs_1.removeDirectory)(node_path_1.default.join(target, ".git"));
|
|
110
|
+
(0, fs_1.removeDirectory)(node_path_1.default.join(target, ".github"));
|
|
110
111
|
renamePackage(target, packageName);
|
|
112
|
+
// Rename .npmignore to .gitignore if it exists (npm renames .gitignore to .npmignore during pack/publish)
|
|
113
|
+
const npmignorePath = node_path_1.default.join(target, ".npmignore");
|
|
114
|
+
const gitignorePath = node_path_1.default.join(target, ".gitignore");
|
|
115
|
+
if (node_fs_1.default.existsSync(npmignorePath) && !node_fs_1.default.existsSync(gitignorePath)) {
|
|
116
|
+
node_fs_1.default.renameSync(npmignorePath, gitignorePath);
|
|
117
|
+
}
|
|
111
118
|
// Customize project with selected options
|
|
112
119
|
customizeProject(target, {
|
|
113
120
|
redis: finalRedis,
|
package/package.json
CHANGED
package/dist/bin/aluna.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const add_extension_1 = require("../commands/add-extension");
|
|
6
|
-
const create_api_1 = require("../commands/create-api");
|
|
7
|
-
const pick_1 = require("../commands/pick");
|
|
8
|
-
const program = new commander_1.Command();
|
|
9
|
-
program
|
|
10
|
-
.name("aluna")
|
|
11
|
-
.description("Create Aluna API projects and install optional extensions.")
|
|
12
|
-
.version("0.1.0");
|
|
13
|
-
program
|
|
14
|
-
.command("create-api")
|
|
15
|
-
.description("Create a new API project from the local aluna-api template.")
|
|
16
|
-
.argument("<name>", "project folder and package name")
|
|
17
|
-
.action((name) => {
|
|
18
|
-
runCommand(() => (0, create_api_1.createApi)(name));
|
|
19
|
-
});
|
|
20
|
-
program
|
|
21
|
-
.command("add")
|
|
22
|
-
.description("Install an optional Aluna extension into the current project.")
|
|
23
|
-
.argument("<extension>", `extension name: ${add_extension_1.extensionNames.join(", ")}`)
|
|
24
|
-
.action((extension) => {
|
|
25
|
-
runCommand(() => (0, add_extension_1.addExtension)(extension));
|
|
26
|
-
});
|
|
27
|
-
program
|
|
28
|
-
.command("pick")
|
|
29
|
-
.description("Eject/copy a core utility from @aluna/aluna-api-core into your local utils folder for customization.")
|
|
30
|
-
.argument("<utility>", `utility name: ${pick_1.UTILITIES.join(", ")}`)
|
|
31
|
-
.action((utility) => {
|
|
32
|
-
runCommand(() => (0, pick_1.pickUtility)(utility));
|
|
33
|
-
});
|
|
34
|
-
program.parse(process.argv);
|
|
35
|
-
function runCommand(command) {
|
|
36
|
-
try {
|
|
37
|
-
command();
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
41
|
-
console.error(`Error: ${message}`);
|
|
42
|
-
process.exitCode = 1;
|
|
43
|
-
}
|
|
44
|
-
}
|
package/dist/bin/kava.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const commander_1 = require("commander");
|
|
8
|
-
const node_child_process_1 = require("node:child_process");
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
-
const add_extension_1 = require("../commands/add-extension");
|
|
12
|
-
const create_api_1 = require("../commands/create-api");
|
|
13
|
-
const pick_1 = require("../commands/pick");
|
|
14
|
-
const fs_1 = require("../utils/fs");
|
|
15
|
-
// Dynamic routing / forwarding logic
|
|
16
|
-
const args = process.argv.slice(2);
|
|
17
|
-
const knownCommands = ["create-api", "add", "pick"];
|
|
18
|
-
if (args.length > 0 && !knownCommands.includes(args[0]) && !["-h", "--help", "-v", "--version", "help"].includes(args[0])) {
|
|
19
|
-
const projectRoot = (0, fs_1.findProjectRoot)(process.cwd());
|
|
20
|
-
if (projectRoot) {
|
|
21
|
-
const localCliPath = node_path_1.default.join(projectRoot, "utils", "commands", "kava.ts");
|
|
22
|
-
if (node_fs_1.default.existsSync(localCliPath)) {
|
|
23
|
-
try {
|
|
24
|
-
// Forward arguments directly to local kava.ts using Bun
|
|
25
|
-
(0, node_child_process_1.execSync)(`bun run utils/commands/kava.ts ${args.join(" ")}`, { stdio: "inherit" });
|
|
26
|
-
process.exit(0);
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const program = new commander_1.Command();
|
|
35
|
-
program
|
|
36
|
-
.name("kava")
|
|
37
|
-
.description("Create Kava API projects and install optional extensions.")
|
|
38
|
-
.version("0.1.0");
|
|
39
|
-
program
|
|
40
|
-
.command("create-api")
|
|
41
|
-
.description("Create a new Kava API project.")
|
|
42
|
-
.argument("<name>", "project folder and package name")
|
|
43
|
-
.action(async (name) => {
|
|
44
|
-
await runCommand(() => (0, create_api_1.createApi)(name));
|
|
45
|
-
});
|
|
46
|
-
program
|
|
47
|
-
.command("add")
|
|
48
|
-
.description("Install an optional Kava extension into the current project.")
|
|
49
|
-
.argument("<extension>", `extension name: ${add_extension_1.extensionNames.join(", ")}`)
|
|
50
|
-
.action(async (extension) => {
|
|
51
|
-
await runCommand(() => (0, add_extension_1.addExtension)(extension));
|
|
52
|
-
});
|
|
53
|
-
program
|
|
54
|
-
.command("pick")
|
|
55
|
-
.description("Eject/copy a core utility from @kava/kava-api-core into your local utils folder for customization.")
|
|
56
|
-
.argument("<utility>", `utility name: ${pick_1.UTILITIES.join(", ")}`)
|
|
57
|
-
.action(async (utility) => {
|
|
58
|
-
await runCommand(() => (0, pick_1.pickUtility)(utility));
|
|
59
|
-
});
|
|
60
|
-
program.parse(process.argv);
|
|
61
|
-
async function runCommand(command) {
|
|
62
|
-
try {
|
|
63
|
-
await command();
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
-
console.error(`Error: ${message}`);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|