@ooneex/cli 1.13.0 → 1.13.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.
- package/dist/index.js +2 -98
- package/dist/index.js.map +3 -4
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,104 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
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
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
4
|
// src/index.ts
|
|
5
|
+
import { commandRun } from "@ooneex/command";
|
|
102
6
|
await commandRun();
|
|
103
7
|
|
|
104
|
-
//# debugId=
|
|
8
|
+
//# debugId=04BA925698F1F76F64756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["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
5
|
"#!/usr/bin/env bun\n\nimport { commandRun } from \"@ooneex/command\";\n\nawait commandRun();\n"
|
|
7
6
|
],
|
|
8
|
-
"mappings": ";;;;AAEA;
|
|
9
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;AAEA;AAEA,MAAM,WAAW;",
|
|
8
|
+
"debugId": "04BA925698F1F76F64756E2164756E21",
|
|
10
9
|
"names": []
|
|
11
10
|
}
|
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.13.
|
|
4
|
+
"version": "1.13.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -43,29 +43,29 @@
|
|
|
43
43
|
"@ooneex/ai": "^1.1.2",
|
|
44
44
|
"@ooneex/analytics": "^1.1.2",
|
|
45
45
|
"@ooneex/cache": "^1.1.2",
|
|
46
|
-
"@ooneex/command": "0.
|
|
47
|
-
"@ooneex/container": "1.2.
|
|
46
|
+
"@ooneex/command": "0.1.1",
|
|
47
|
+
"@ooneex/container": "1.2.4",
|
|
48
48
|
"@ooneex/controller": "^1.3.0",
|
|
49
49
|
"@ooneex/cron": "^1.1.2",
|
|
50
50
|
"@ooneex/database": "^1.1.2",
|
|
51
|
-
"@ooneex/exception": "1.2.
|
|
52
|
-
"@ooneex/http-status": "1.1.
|
|
51
|
+
"@ooneex/exception": "1.2.2",
|
|
52
|
+
"@ooneex/http-status": "1.1.5",
|
|
53
53
|
"@ooneex/logger": "^1.2.2",
|
|
54
54
|
"@ooneex/mailer": "^1.1.2",
|
|
55
55
|
"@ooneex/middleware": "^1.2.2",
|
|
56
|
-
"@ooneex/migrations": "1.
|
|
56
|
+
"@ooneex/migrations": "1.3.0",
|
|
57
57
|
"@ooneex/module": "^1.2.2",
|
|
58
58
|
"@ooneex/permission": "^1.1.2",
|
|
59
59
|
"@ooneex/repository": "^1.1.2",
|
|
60
|
-
"@ooneex/routing": "1.3.
|
|
61
|
-
"@ooneex/seeds": "1.
|
|
60
|
+
"@ooneex/routing": "1.3.4",
|
|
61
|
+
"@ooneex/seeds": "1.3.0",
|
|
62
62
|
"@ooneex/service": "^1.1.2",
|
|
63
63
|
"@ooneex/storage": "^1.1.2",
|
|
64
|
-
"@ooneex/translation": "1.1.
|
|
65
|
-
"@ooneex/utils": "0.4.
|
|
66
|
-
"@ooneex/validation": "1.1.
|
|
64
|
+
"@ooneex/translation": "1.1.6",
|
|
65
|
+
"@ooneex/utils": "0.4.3",
|
|
66
|
+
"@ooneex/validation": "1.1.5"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@ooneex/types": "1.
|
|
69
|
+
"@ooneex/types": "1.3.0"
|
|
70
70
|
}
|
|
71
71
|
}
|