@ooneex/command 0.3.0 → 0.5.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 +7 -2
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -117,6 +117,7 @@ var getCommand = (name) => {
|
|
|
117
117
|
import { parseArgs } from "util";
|
|
118
118
|
import { Exception as Exception2 } from "@ooneex/exception";
|
|
119
119
|
import { TerminalLogger } from "@ooneex/logger";
|
|
120
|
+
import { toKebabCase as toKebabCase2 } from "@ooneex/utils";
|
|
120
121
|
var run = async () => {
|
|
121
122
|
const { values, positionals } = parseArgs({
|
|
122
123
|
args: Bun.argv,
|
|
@@ -153,6 +154,9 @@ var run = async () => {
|
|
|
153
154
|
},
|
|
154
155
|
drop: {
|
|
155
156
|
type: "boolean"
|
|
157
|
+
},
|
|
158
|
+
target: {
|
|
159
|
+
type: "string"
|
|
156
160
|
}
|
|
157
161
|
},
|
|
158
162
|
strict: false,
|
|
@@ -172,9 +176,10 @@ var run = async () => {
|
|
|
172
176
|
channel: values.channel,
|
|
173
177
|
isSocket: values["is-socket"],
|
|
174
178
|
tableName: values["table-name"],
|
|
175
|
-
module: values.module,
|
|
179
|
+
module: typeof values.module === "string" ? toKebabCase2(values.module) : values.module,
|
|
176
180
|
destination: values.destination,
|
|
177
181
|
drop: values.drop,
|
|
182
|
+
target: values.target,
|
|
178
183
|
route: {
|
|
179
184
|
name: values["route-name"],
|
|
180
185
|
path: values["route-path"],
|
|
@@ -202,4 +207,4 @@ export {
|
|
|
202
207
|
COMMANDS_CONTAINER
|
|
203
208
|
};
|
|
204
209
|
|
|
205
|
-
//# debugId=
|
|
210
|
+
//# debugId=CFC776DCC5DFF24264756E2164756E21
|
package/dist/index.js.map
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
"import type { CommandClassType } from \"./types\";\n\nexport const COMMANDS_CONTAINER: CommandClassType[] = [];\n",
|
|
8
8
|
"import { container, EContainerScope } from \"@ooneex/container\";\nimport { COMMANDS_CONTAINER } from \"./container\";\nimport type { CommandClassType } from \"./types\";\n\nexport const decorator = {\n command: (scope: EContainerScope = EContainerScope.Singleton) => {\n return (command: CommandClassType): void => {\n container.add(command, scope);\n COMMANDS_CONTAINER.push(command);\n };\n },\n};\n",
|
|
9
9
|
"import { container } from \"@ooneex/container\";\nimport { COMMANDS_CONTAINER } from \"./container\";\nimport type { ICommand } from \"./types\";\n\nexport const getCommand = (name: string): ICommand | null => {\n let command: ICommand | null = null;\n\n COMMANDS_CONTAINER.find((CommandClass) => {\n command = container.get(CommandClass);\n\n return command.getName() === name;\n });\n\n return command;\n};\n",
|
|
10
|
-
"import { parseArgs } from \"node:util\";\nimport type { IException } from \"@ooneex/exception\";\nimport { Exception } from \"@ooneex/exception\";\nimport { TerminalLogger } from \"@ooneex/logger\";\nimport type { HttpMethodType } from \"@ooneex/types\";\nimport { getCommand } from \"./getCommand\";\n\nexport const run = async (): Promise<void> => {\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 drop: {\n type: \"boolean\",\n },\n },\n strict: false,\n allowPositionals: true,\n });\n\n const logger = new TerminalLogger();\n\n const commandName = positionals[2] ?? \"help\";\n\n const command = getCommand(commandName);\n\n if (!command) {\n logger.info(\"No commands found\\n\");\n process.exit(1);\n }\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 drop: values.drop,\n route: {\n name: values[\"route-name\"],\n path: values[\"route-path\"] as `/${string}` | undefined,\n method: values[\"route-method\"] as HttpMethodType | undefined,\n },\n };\n\n try {\n await command.run(parsedValues);\n } catch (error) {\n const exception: IException =\n error instanceof Exception ? error : new Exception(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"
|
|
10
|
+
"import { parseArgs } from \"node:util\";\nimport type { IException } from \"@ooneex/exception\";\nimport { Exception } from \"@ooneex/exception\";\nimport { TerminalLogger } from \"@ooneex/logger\";\nimport type { HttpMethodType } from \"@ooneex/types\";\nimport { toKebabCase } from \"@ooneex/utils\";\nimport { getCommand } from \"./getCommand\";\n\nexport const run = async (): Promise<void> => {\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 drop: {\n type: \"boolean\",\n },\n target: {\n type: \"string\",\n },\n },\n strict: false,\n allowPositionals: true,\n });\n\n const logger = new TerminalLogger();\n\n const commandName = positionals[2] ?? \"help\";\n\n const command = getCommand(commandName);\n\n if (!command) {\n logger.info(\"No commands found\\n\");\n process.exit(1);\n }\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: typeof values.module === \"string\" ? toKebabCase(values.module) : values.module,\n destination: values.destination,\n drop: values.drop,\n target: values.target,\n route: {\n name: values[\"route-name\"],\n path: values[\"route-path\"] as `/${string}` | undefined,\n method: values[\"route-method\"] as HttpMethodType | undefined,\n },\n };\n\n try {\n await command.run(parsedValues);\n } catch (error) {\n const exception: IException =\n error instanceof Exception ? error : new Exception(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"
|
|
11
11
|
],
|
|
12
|
-
"mappings": ";;AAAA;AACA;AAAA;AAEO,MAAM,yBAAyB,UAAU;AAAA,EAC9C,WAAW,CAAC,SAAiB,KAAa,OAAgC,CAAC,GAAG;AAAA,IAC5E,MAAM,SAAS;AAAA,MACb;AAAA,MACA,QAAQ,WAAW,KAAK;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,IAED,KAAK,OAAO;AAAA;AAEhB;;ACbA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAM,gBAAgB,OAAO,WAIsB;AAAA,EACxD,MAAM,OAAO,aAAa,OAAO,IAAI,EAAE,QAAQ,YAAY,EAAE;AAAA,EAC7D,MAAM,cAAc,YAAY,IAAI,EAAE,QAAQ,MAAM,GAAG;AAAA,EACvD,MAAM,aAAa,OAAO,cAAc,KAAK,OAAO,UAAU;AAAA,EAC9D,MAAM,WAAW,OAAO,YAAY,KAAK,SAAS,UAAU;AAAA,EAE5D,MAAM,UAAU,gBACb,QAAQ,iBAAiB,IAAI,EAC7B,QAAQ,yBAAyB,WAAW,EAC5C,QAAQ,gCAAgC,WAAW,qBAAqB;AAAA,EAE3E,MAAM,IAAI,MAAM,KAAK,QAAQ,IAAI,GAAG,YAAY,GAAG,gBAAgB,GAAG,OAAO;AAAA,EAE7E,MAAM,cAAc,qBAAa,QAAQ,iBAAiB,IAAI;AAAA,EAC9D,MAAM,IAAI,MAAM,KAAK,QAAQ,IAAI,GAAG,UAAU,GAAG,qBAAqB,GAAG,WAAW;AAAA,EAEpF,MAAM,UAAoB,CAAC;AAAA,EAC3B,MAAM,OAAO,IAAI,KAAK,gBAAgB;AAAA,EACtC,iBAAiB,QAAQ,KAAK,KAAK,KAAK,QAAQ,IAAI,GAAG,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AAC,SAAS;AAAA,IACZ,OAAO,KAAK;AAAA,CAAqB;AAAA,IACjC,QAAQ,KAAK,CAAC;AAAA,EAChB;AAAA,EAEA,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,OAAO,WAAW,WAAW,aAAY,OAAO,MAAM,IAAI,OAAO;AAAA,IAChF,aAAa,OAAO;AAAA,IACpB,MAAM,OAAO;AAAA,IACb,QAAQ,OAAO;AAAA,IACf,OAAO;AAAA,MACL,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,MACb,QAAQ,OAAO;AAAA,IACjB;AAAA,EACF;AAAA,EAEA,IAAI;AAAA,IACF,MAAM,QAAQ,IAAI,YAAY;AAAA,IAC9B,OAAO,OAAO;AAAA,IACd,MAAM,YACJ,iBAAiB,aAAY,QAAQ,IAAI,WAAU,iBAAiB,QAAQ,QAAQ,OAAO,KAAK,CAAC;AAAA,IACnG,OAAO,MAAM,WAAW,WAAW;AAAA,MACjC,WAAW;AAAA,MACX,eAAe;AAAA,MACf,WAAW;AAAA,IACb,CAAC;AAAA,IACD,QAAQ,KAAK,CAAC;AAAA;AAAA;",
|
|
13
|
+
"debugId": "CFC776DCC5DFF24264756E2164756E21",
|
|
14
14
|
"names": []
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ooneex/command",
|
|
3
3
|
"description": "Command framework for building CLI commands with dependency injection, argument parsing, and execution logging",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@ooneex/container": "^1.4.4",
|
|
32
32
|
"@ooneex/exception": "^1.2.7",
|
|
33
33
|
"@ooneex/http-status": "^1.1.9",
|
|
34
|
-
"@ooneex/logger": "^1.3.
|
|
34
|
+
"@ooneex/logger": "^1.3.3",
|
|
35
35
|
"@ooneex/utils": "^0.4.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|