@forgerapi/cli 0.0.1

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const codegen_1 = require("@forgerapi/codegen");
7
+ function loadConfig() {
8
+ const configPath = (0, node_path_1.resolve)(process.cwd(), "forger.config.json");
9
+ if (!(0, node_fs_1.existsSync)(configPath)) {
10
+ return {
11
+ outDir: "./src",
12
+ prismaSchema: "./prisma/schema.prisma",
13
+ swagger: true,
14
+ deleteOrphans: true,
15
+ };
16
+ }
17
+ return JSON.parse((0, node_fs_1.readFileSync)(configPath, "utf-8"));
18
+ }
19
+ async function main() {
20
+ const args = process.argv.slice(2);
21
+ const command = args[0];
22
+ if (command === "watch") {
23
+ const config = loadConfig();
24
+ if (!(0, node_fs_1.existsSync)((0, node_path_1.resolve)(process.cwd(), "forger.config.json"))) {
25
+ console.log("Using default config (forger.config.json not found)");
26
+ }
27
+ (0, codegen_1.watchForger)(config);
28
+ return;
29
+ }
30
+ if (!command || command === "generate") {
31
+ const config = loadConfig();
32
+ const noConfig = !(0, node_fs_1.existsSync)((0, node_path_1.resolve)(process.cwd(), "forger.config.json"));
33
+ const files = await (0, codegen_1.runForger)(config);
34
+ if (noConfig) {
35
+ console.log(`Generated with default config (forger.config.json not found) — ${files.length} files`);
36
+ }
37
+ else {
38
+ console.log(`Generated successfully — ${files.length} files`);
39
+ }
40
+ return;
41
+ }
42
+ console.log(`
43
+ ForgerAPI CLI
44
+
45
+ Usage:
46
+ forger generate Parse schema.forger and generate NestJS code
47
+ forger watch Watch schema.forger for changes and auto-regenerate
48
+ forger help Show this help
49
+ `);
50
+ }
51
+ main().catch((err) => {
52
+ console.error(err.message);
53
+ process.exit(1);
54
+ });
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@forgerapi/cli",
3
+ "version": "0.0.1",
4
+ "bin": {
5
+ "forger": "dist/index.js"
6
+ },
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/linecodesxx/forgerapi.git",
17
+ "directory": "packages/cli"
18
+ },
19
+ "scripts": {
20
+ "build": "tsc"
21
+ },
22
+ "dependencies": {
23
+ "@forgerapi/codegen": "^0.0.1"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^26.0.1"
27
+ }
28
+ }