@ooneex/cli 1.12.0 → 1.13.0

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/index.js CHANGED
@@ -1,11 +1,104 @@
1
+ #!/usr/bin/env bun
1
2
  // @bun
2
- import {
3
- commandRun,
4
- decorator
5
- } from "./shared/chunk-qtg514z4.js";
6
- export {
7
- decorator,
8
- commandRun
3
+
4
+ // ../command/dist/index.js
5
+ import { Exception } from "@ooneex/exception";
6
+ import { HttpStatus } from "@ooneex/http-status";
7
+ import { toKebabCase, toPascalCase } from "@ooneex/utils";
8
+ import { parseArgs } from "util";
9
+ import { Exception as Exception2 } from "@ooneex/exception";
10
+ import { TerminalLogger } from "@ooneex/logger";
11
+ import { container } from "@ooneex/container";
12
+ import { container as container2, EContainerScope } from "@ooneex/container";
13
+ var { Glob } = globalThis.Bun;
14
+ var COMMANDS_CONTAINER = [];
15
+ var getCommand = (name) => {
16
+ let command = null;
17
+ COMMANDS_CONTAINER.find((CommandClass) => {
18
+ command = container.get(CommandClass);
19
+ return command.getName() === name;
20
+ });
21
+ return command;
22
+ };
23
+ var commandRun = async () => {
24
+ const { values, positionals } = parseArgs({
25
+ args: Bun.argv,
26
+ options: {
27
+ name: {
28
+ type: "string"
29
+ },
30
+ "route-name": {
31
+ type: "string"
32
+ },
33
+ "route-path": {
34
+ type: "string"
35
+ },
36
+ "route-method": {
37
+ type: "string"
38
+ },
39
+ "is-socket": {
40
+ type: "boolean"
41
+ },
42
+ dir: {
43
+ type: "string"
44
+ },
45
+ channel: {
46
+ type: "string"
47
+ },
48
+ "table-name": {
49
+ type: "string"
50
+ },
51
+ module: {
52
+ type: "string"
53
+ },
54
+ destination: {
55
+ type: "string"
56
+ }
57
+ },
58
+ strict: false,
59
+ allowPositionals: true
60
+ });
61
+ const logger = new TerminalLogger;
62
+ const commandName = positionals[2];
63
+ if (!commandName) {
64
+ logger.error(`Command name is required
65
+ `);
66
+ process.exit(1);
67
+ }
68
+ const command = getCommand(commandName);
69
+ if (!command) {
70
+ logger.info(`No commands found
71
+ `);
72
+ process.exit(1);
73
+ }
74
+ const parsedValues = {
75
+ name: values.name,
76
+ dir: values.dir,
77
+ channel: values.channel,
78
+ isSocket: values["is-socket"],
79
+ tableName: values["table-name"],
80
+ module: values.module,
81
+ destination: values.destination,
82
+ route: {
83
+ name: values["route-name"],
84
+ path: values["route-path"],
85
+ method: values["route-method"]
86
+ }
87
+ };
88
+ try {
89
+ await command.run(parsedValues);
90
+ } catch (error) {
91
+ const exception = error instanceof Exception2 ? error : new Exception2(error instanceof Error ? error : String(error));
92
+ logger.error(exception, undefined, {
93
+ showArrow: false,
94
+ showTimestamp: false,
95
+ showLevel: false
96
+ });
97
+ process.exit(1);
98
+ }
9
99
  };
10
100
 
11
- //# debugId=1F33EC9328E0B18E64756E2164756E21
101
+ // src/index.ts
102
+ await commandRun();
103
+
104
+ //# debugId=5BBF4E1B7ADDAAF964756E2164756E21
package/dist/index.js.map CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
3
+ "sources": ["../command/dist/index.js", "src/index.ts"],
4
4
  "sourcesContent": [
5
+ "// @bun\n// src/CommandException.ts\nimport { Exception } from \"@ooneex/exception\";\nimport { HttpStatus } from \"@ooneex/http-status\";\n\nclass CommandException extends Exception {\n constructor(message, key, data = {}) {\n super(message, {\n key,\n status: HttpStatus.Code.InternalServerError,\n data\n });\n this.name = \"CommandException\";\n }\n}\n// src/commandCreate.ts\nimport { join } from \"path\";\nimport { toKebabCase, toPascalCase } from \"@ooneex/utils\";\nvar {Glob } = globalThis.Bun;\n\n// src/command.test.txt\nvar command_test_default = `import { describe, expect, test } from \"bun:test\";\nimport { {{NAME}}Command } from \"@/commands/{{NAME}}Command\";\n\ndescribe(\"{{NAME}}Command\", () => {\n test(\"should have class name ending with 'Command'\", () => {\n expect({{NAME}}Command.name.endsWith(\"Command\")).toBe(true);\n });\n\n test(\"should have 'getName' method\", () => {\n expect({{NAME}}Command.prototype.getName).toBeDefined();\n expect(typeof {{NAME}}Command.prototype.getName).toBe(\"function\");\n });\n\n test(\"should have 'getDescription' method\", () => {\n expect({{NAME}}Command.prototype.getDescription).toBeDefined();\n expect(typeof {{NAME}}Command.prototype.getDescription).toBe(\"function\");\n });\n\n test(\"should have 'run' method\", () => {\n expect({{NAME}}Command.prototype.run).toBeDefined();\n expect(typeof {{NAME}}Command.prototype.run).toBe(\"function\");\n });\n});\n`;\n\n// src/command.txt\nvar command_default = `import { type ICommand, decorator } from \"@ooneex/command\";\n\ntype CommandOptionsType = {\n name?: string;\n};\n\n@decorator.command()\nexport class {{NAME}}Command<T extends CommandOptionsType = CommandOptionsType> implements ICommand<T> {\n public getName(): string {\n return \"{{COMMAND_NAME}}\";\n }\n\n public getDescription(): string {\n return \"{{COMMAND_DESCRIPTION}}\";\n }\n\n public async run(options: T): Promise<void> {\n // TODO: Implement command logic\n }\n}\n`;\n\n// src/commandCreate.ts\nvar commandCreate = async (config) => {\n const name = toPascalCase(config.name).replace(/Command$/, \"\");\n const commandName = toKebabCase(name).replace(/-/g, \":\");\n const commandDir = config.commandDir || join(\"src\", \"commands\");\n const testsDir = config.testsDir || join(\"tests\", \"commands\");\n const content = command_default.replace(/\\{\\{NAME\\}\\}/g, name).replace(/\\{\\{COMMAND_NAME\\}\\}/g, commandName).replace(/\\{\\{COMMAND_DESCRIPTION\\}\\}/g, `Execute ${commandName} command`);\n await Bun.write(join(process.cwd(), commandDir, `${name}Command.ts`), content);\n const testContent = command_test_default.replace(/\\{\\{NAME\\}\\}/g, name);\n await Bun.write(join(process.cwd(), testsDir, `${name}Command.spec.ts`), testContent);\n const imports = [];\n const glob = new Glob(\"**/*Command.ts\");\n for await (const file of glob.scan(join(process.cwd(), commandDir))) {\n const commandClassName = file.replace(/\\.ts$/, \"\");\n imports.push(`export { ${commandClassName} } from './${commandClassName}';`);\n }\n await Bun.write(join(process.cwd(), commandDir, \"commands.ts\"), `${imports.sort().join(`\n`)}\n`);\n return {\n commandPath: join(commandDir, `${name}Command.ts`),\n testPath: join(testsDir, `${name}Command.spec.ts`)\n };\n};\n// src/commandRun.ts\nimport { parseArgs } from \"util\";\nimport { Exception as Exception2 } from \"@ooneex/exception\";\nimport { TerminalLogger } from \"@ooneex/logger\";\n\n// src/getCommand.ts\nimport { container } from \"@ooneex/container\";\n\n// src/container.ts\nvar COMMANDS_CONTAINER = [];\n\n// src/getCommand.ts\nvar getCommand = (name) => {\n let command = null;\n COMMANDS_CONTAINER.find((CommandClass) => {\n command = container.get(CommandClass);\n return command.getName() === name;\n });\n return command;\n};\n\n// src/commandRun.ts\nvar commandRun = async () => {\n const { values, positionals } = parseArgs({\n args: Bun.argv,\n options: {\n name: {\n type: \"string\"\n },\n \"route-name\": {\n type: \"string\"\n },\n \"route-path\": {\n type: \"string\"\n },\n \"route-method\": {\n type: \"string\"\n },\n \"is-socket\": {\n type: \"boolean\"\n },\n dir: {\n type: \"string\"\n },\n channel: {\n type: \"string\"\n },\n \"table-name\": {\n type: \"string\"\n },\n module: {\n type: \"string\"\n },\n destination: {\n type: \"string\"\n }\n },\n strict: false,\n allowPositionals: true\n });\n const logger = new TerminalLogger;\n const commandName = positionals[2];\n if (!commandName) {\n logger.error(`Command name is required\n`);\n process.exit(1);\n }\n const command = getCommand(commandName);\n if (!command) {\n logger.info(`No commands found\n`);\n process.exit(1);\n }\n const parsedValues = {\n name: values.name,\n dir: values.dir,\n channel: values.channel,\n isSocket: values[\"is-socket\"],\n tableName: values[\"table-name\"],\n module: values.module,\n destination: values.destination,\n route: {\n name: values[\"route-name\"],\n path: values[\"route-path\"],\n method: values[\"route-method\"]\n }\n };\n try {\n await command.run(parsedValues);\n } catch (error) {\n const exception = error instanceof Exception2 ? error : new Exception2(error instanceof Error ? error : String(error));\n logger.error(exception, undefined, {\n showArrow: false,\n showTimestamp: false,\n showLevel: false\n });\n process.exit(1);\n }\n};\n// src/decorators.ts\nimport { container as container2, EContainerScope } from \"@ooneex/container\";\nvar decorator = {\n command: (scope = EContainerScope.Singleton) => {\n return (command) => {\n container2.add(command, scope);\n COMMANDS_CONTAINER.push(command);\n };\n }\n};\nexport {\n getCommand,\n decorator,\n commandRun,\n commandCreate,\n CommandException\n};\n\n//# debugId=86D9C789DBF8297E64756E2164756E21\n",
6
+ "#!/usr/bin/env bun\n\nimport { commandRun } from \"@ooneex/command\";\n\nawait commandRun();\n"
5
7
  ],
6
- "mappings": "",
7
- "debugId": "1F33EC9328E0B18E64756E2164756E21",
8
+ "mappings": ";;;;AAEA;AACA;AAcA;AA6EA;AACA,sBAAS;AACT;AAGA;AA8FA,sBAAS;AA/KT,MAAK,SAAS,WAAW;AAoFzB,IAAI,qBAAqB,CAAC;AAG1B,IAAI,aAAa,CAAC,SAAS;AAAA,EACzB,IAAI,UAAU;AAAA,EACd,mBAAmB,KAAK,CAAC,iBAAiB;AAAA,IACxC,UAAU,UAAU,IAAI,YAAY;AAAA,IACpC,OAAO,QAAQ,QAAQ,MAAM;AAAA,GAC9B;AAAA,EACD,OAAO;AAAA;AAIT,IAAI,aAAa,YAAY;AAAA,EAC3B,QAAQ,QAAQ,gBAAgB,UAAU;AAAA,IACxC,MAAM,IAAI;AAAA,IACV,SAAS;AAAA,MACP,MAAM;AAAA,QACJ,MAAM;AAAA,MACR;AAAA,MACA,cAAc;AAAA,QACZ,MAAM;AAAA,MACR;AAAA,MACA,cAAc;AAAA,QACZ,MAAM;AAAA,MACR;AAAA,MACA,gBAAgB;AAAA,QACd,MAAM;AAAA,MACR;AAAA,MACA,aAAa;AAAA,QACX,MAAM;AAAA,MACR;AAAA,MACA,KAAK;AAAA,QACH,MAAM;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACA,cAAc;AAAA,QACZ,MAAM;AAAA,MACR;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA,MACR;AAAA,MACA,aAAa;AAAA,QACX,MAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,IACR,kBAAkB;AAAA,EACpB,CAAC;AAAA,EACD,MAAM,SAAS,IAAI;AAAA,EACnB,MAAM,cAAc,YAAY;AAAA,EAChC,IAAI,CAAC,aAAa;AAAA,IAChB,OAAO,MAAM;AAAA,CAChB;AAAA,IACG,QAAQ,KAAK,CAAC;AAAA,EAChB;AAAA,EACA,MAAM,UAAU,WAAW,WAAW;AAAA,EACtC,IAAI,CAAC,SAAS;AAAA,IACZ,OAAO,KAAK;AAAA,CACf;AAAA,IACG,QAAQ,KAAK,CAAC;AAAA,EAChB;AAAA,EACA,MAAM,eAAe;AAAA,IACnB,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IACZ,SAAS,OAAO;AAAA,IAChB,UAAU,OAAO;AAAA,IACjB,WAAW,OAAO;AAAA,IAClB,QAAQ,OAAO;AAAA,IACf,aAAa,OAAO;AAAA,IACpB,OAAO;AAAA,MACL,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EACA,IAAI;AAAA,IACF,MAAM,QAAQ,IAAI,YAAY;AAAA,IAC9B,OAAO,OAAO;AAAA,IACd,MAAM,YAAY,iBAAiB,aAAa,QAAQ,IAAI,WAAW,iBAAiB,QAAQ,QAAQ,OAAO,KAAK,CAAC;AAAA,IACrH,OAAO,MAAM,WAAW,WAAW;AAAA,MACjC,WAAW;AAAA,MACX,eAAe;AAAA,MACf,WAAW;AAAA,IACb,CAAC;AAAA,IACD,QAAQ,KAAK,CAAC;AAAA;AAAA;;;ACzLlB,MAAM,WAAW;",
9
+ "debugId": "5BBF4E1B7ADDAAF964756E2164756E21",
8
10
  "names": []
9
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ooneex/cli",
3
3
  "description": "Interactive CLI toolkit for scaffolding Ooneex projects, modules, controllers, services, repositories, and more with customizable code generation templates",
4
- "version": "1.12.0",
4
+ "version": "1.13.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",
@@ -10,19 +10,15 @@
10
10
  "package.json"
11
11
  ],
12
12
  "module": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
14
13
  "exports": {
15
14
  ".": {
16
- "import": {
17
- "types": "./dist/index.d.ts",
18
- "default": "./dist/index.js"
19
- }
15
+ "import": "./dist/index.js"
20
16
  },
21
17
  "./package.json": "./package.json"
22
18
  },
23
19
  "bin": {
24
- "ooneex": "./dist/cli.js",
25
- "oo": "./dist/cli.js"
20
+ "ooneex": "./dist/index.js",
21
+ "oo": "./dist/index.js"
26
22
  },
27
23
  "keywords": [
28
24
  "bun",
@@ -47,28 +43,29 @@
47
43
  "@ooneex/ai": "^1.1.2",
48
44
  "@ooneex/analytics": "^1.1.2",
49
45
  "@ooneex/cache": "^1.1.2",
50
- "@ooneex/container": "1.2.2",
46
+ "@ooneex/command": "0.0.1",
47
+ "@ooneex/container": "1.2.3",
51
48
  "@ooneex/controller": "^1.3.0",
52
49
  "@ooneex/cron": "^1.1.2",
53
50
  "@ooneex/database": "^1.1.2",
54
- "@ooneex/exception": "1.2.0",
55
- "@ooneex/http-status": "1.1.3",
51
+ "@ooneex/exception": "1.2.1",
52
+ "@ooneex/http-status": "1.1.4",
56
53
  "@ooneex/logger": "^1.2.2",
57
54
  "@ooneex/mailer": "^1.1.2",
58
55
  "@ooneex/middleware": "^1.2.2",
59
- "@ooneex/migrations": "1.2.4",
56
+ "@ooneex/migrations": "1.2.5",
60
57
  "@ooneex/module": "^1.2.2",
61
58
  "@ooneex/permission": "^1.1.2",
62
59
  "@ooneex/repository": "^1.1.2",
63
- "@ooneex/routing": "1.3.2",
64
- "@ooneex/seeds": "1.2.4",
60
+ "@ooneex/routing": "1.3.3",
61
+ "@ooneex/seeds": "1.2.5",
65
62
  "@ooneex/service": "^1.1.2",
66
63
  "@ooneex/storage": "^1.1.2",
67
- "@ooneex/translation": "1.1.4",
68
- "@ooneex/utils": "0.4.1",
69
- "@ooneex/validation": "1.1.3"
64
+ "@ooneex/translation": "1.1.5",
65
+ "@ooneex/utils": "0.4.2",
66
+ "@ooneex/validation": "1.1.4"
70
67
  },
71
68
  "devDependencies": {
72
- "@ooneex/types": "1.1.3"
69
+ "@ooneex/types": "1.2.0"
73
70
  }
74
71
  }
package/dist/cli.js DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
- import {
4
- commandRun
5
- } from "./shared/chunk-qtg514z4.js";
6
-
7
- // src/cli.ts
8
- await commandRun();
9
-
10
- //# debugId=38E2DE079B57DA6164756E2164756E21
package/dist/cli.js.map DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["src/cli.ts"],
4
- "sourcesContent": [
5
- "#!/usr/bin/env bun\n\nimport { commandRun } from \"./commandRun\";\n\nawait commandRun();\n"
6
- ],
7
- "mappings": ";;;;;;;AAIA,MAAM,WAAW;",
8
- "debugId": "38E2DE079B57DA6164756E2164756E21",
9
- "names": []
10
- }
package/dist/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- declare const commandRun: unknown;
2
- import { EContainerScope } from "@ooneex/container";
3
- type CommandClassType = new (...args: any[]) => ICommand;
4
- interface ICommand<Options extends Record<string, unknown> = Record<string, unknown>> {
5
- run: (options: Options) => Promise<void> | void;
6
- getName: () => string;
7
- getDescription: () => string;
8
- }
9
- declare const decorator: {
10
- command: (scope?: EContainerScope) => (command: CommandClassType) => void;
11
- };
12
- export { decorator, commandRun, ICommand, CommandClassType };