From eb50e609ad06bec5356dc60a678e12bc0de40912 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Wed, 3 Apr 2024 11:52:12 +0200 Subject: [PATCH] migrate to newer oclif --- modelina-cli/bin/dev | 20 +- modelina-cli/bin/run | 11 +- modelina-cli/docs/usage.md | 94 +- modelina-cli/package-lock.json | 40819 ++++++++++++---- modelina-cli/package.json | 28 +- modelina-cli/scripts/README.md | 257 + .../src/commands/config/context/add.ts | 14 +- .../src/commands/config/context/edit.ts | 14 +- .../src/commands/config/context/init.ts | 12 +- .../src/commands/config/context/remove.ts | 12 +- .../src/commands/config/context/use.ts | 12 +- modelina-cli/src/commands/generate.ts | 20 +- modelina-cli/src/models/Context.ts | 2 +- 13 files changed, 32606 insertions(+), 8709 deletions(-) create mode 100644 modelina-cli/scripts/README.md diff --git a/modelina-cli/bin/dev b/modelina-cli/bin/dev index b3a84cbba1..62068d62a6 100644 --- a/modelina-cli/bin/dev +++ b/modelina-cli/bin/dev @@ -1,18 +1,2 @@ -#!/usr/bin/env nod - -const oclif = require('@oclif/core') - -const path = require('path') -const project = path.join(__dirname, '..', 'tsconfig.json') - -// In dev mode -> use ts-node and dev plugins -process.env.NODE_ENV = 'development' - -require('ts-node').register({project}) - -// In dev mode, always show stack traces -oclif.settings.debug = true; - -// Start the CLI -oclif.run().then(oclif.flush).catch(oclif.Errors.handle) - +import {execute} from '@oclif/core'; +await execute({development: true, dir: import.meta.url}); \ No newline at end of file diff --git a/modelina-cli/bin/run b/modelina-cli/bin/run index 330b6c3998..3518fa0a62 100755 --- a/modelina-cli/bin/run +++ b/modelina-cli/bin/run @@ -1,11 +1,4 @@ #!/usr/bin/env node -const oclif = require('@oclif/core'); - -oclif.run() - .then(require('@oclif/core/flush')) - .catch((err) => { - const oclifHandler = require('@oclif/core/handle'); - return oclifHandler(err.message); - }); - +import {execute} from '@oclif/core'; +await execute({dir: import.meta.url}); diff --git a/modelina-cli/docs/usage.md b/modelina-cli/docs/usage.md index e86d7cb278..0129e24fcf 100644 --- a/modelina-cli/docs/usage.md +++ b/modelina-cli/docs/usage.md @@ -29,7 +29,7 @@ $ npm install -g @asyncapi/modelina-cli $ modelina COMMAND running command... $ modelina (--version) -@asyncapi/modelina-cli/4.0.0-next.22 linux-x64 node-v18.19.1 +@asyncapi/modelina-cli/4.0.0-next.23 darwin-x64 node-v18.19.0 $ modelina --help [COMMAND] USAGE $ modelina COMMAND @@ -45,7 +45,7 @@ USAGE * [`modelina config context add CONTEXT-NAME SPEC-FILE-PATH`](#modelina-config-context-add-context-name-spec-file-path) * [`modelina config context current`](#modelina-config-context-current) * [`modelina config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH`](#modelina-config-context-edit-context-name-new-spec-file-path) -* [`modelina config context init [CONTEXT-FILE-PATH]`](#modelina-config-context-init-context-file-path) +* [`modelina config context init CONTEXT-FILE-PATH`](#modelina-config-context-init-context-file-path) * [`modelina config context list`](#modelina-config-context-list) * [`modelina config context remove CONTEXT-NAME`](#modelina-config-context-remove-context-name) * [`modelina config context use CONTEXT-NAME`](#modelina-config-context-use-context-name) @@ -63,7 +63,7 @@ DESCRIPTION CLI config settings ``` -_See code: [src/commands/config/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/index.ts)_ +_See code: [src/commands/config/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/index.ts)_ ## `modelina config context` @@ -77,7 +77,7 @@ DESCRIPTION Manage short aliases for full paths to inputs ``` -_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/index.ts)_ +_See code: [src/commands/config/context/index.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/index.ts)_ ## `modelina config context add CONTEXT-NAME SPEC-FILE-PATH` @@ -89,7 +89,7 @@ USAGE ARGUMENTS CONTEXT-NAME context name - SPEC-FILE-PATH file path of the input document + SPEC-FILE-PATH file path of the spec file FLAGS -h, --help Show CLI help. @@ -99,7 +99,7 @@ DESCRIPTION Add a context to the store ``` -_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/add.ts)_ +_See code: [src/commands/config/context/add.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/add.ts)_ ## `modelina config context current` @@ -116,7 +116,7 @@ DESCRIPTION Shows the current context that is being used ``` -_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/current.ts)_ +_See code: [src/commands/config/context/current.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/current.ts)_ ## `modelina config context edit CONTEXT-NAME NEW-SPEC-FILE-PATH` @@ -128,7 +128,7 @@ USAGE ARGUMENTS CONTEXT-NAME context name - NEW-SPEC-FILE-PATH new file path of the input + NEW-SPEC-FILE-PATH file path of the spec file FLAGS -h, --help Show CLI help. @@ -137,15 +137,15 @@ DESCRIPTION Edit a context in the store ``` -_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/edit.ts)_ +_See code: [src/commands/config/context/edit.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/edit.ts)_ -## `modelina config context init [CONTEXT-FILE-PATH]` +## `modelina config context init CONTEXT-FILE-PATH` Initialize context ``` USAGE - $ modelina config context init [CONTEXT-FILE-PATH] [-h] + $ modelina config context init CONTEXT-FILE-PATH [-h] ARGUMENTS CONTEXT-FILE-PATH Specify directory in which context file should be created: @@ -160,7 +160,7 @@ DESCRIPTION Initialize context ``` -_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/init.ts)_ +_See code: [src/commands/config/context/init.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/init.ts)_ ## `modelina config context list` @@ -177,7 +177,7 @@ DESCRIPTION List all the stored contexts in the store ``` -_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/list.ts)_ +_See code: [src/commands/config/context/list.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/list.ts)_ ## `modelina config context remove CONTEXT-NAME` @@ -197,7 +197,7 @@ DESCRIPTION Delete a context from the store ``` -_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/remove.ts)_ +_See code: [src/commands/config/context/remove.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/remove.ts)_ ## `modelina config context use CONTEXT-NAME` @@ -217,7 +217,7 @@ DESCRIPTION Set a context as current ``` -_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/config/context/use.ts)_ +_See code: [src/commands/config/context/use.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/config/context/use.ts)_ ## `modelina generate LANGUAGE FILE` @@ -237,40 +237,42 @@ ARGUMENTS FILE Path or URL to the AsyncAPI document, or context-name FLAGS - -h, --help Show CLI help. - -o, --output= The output directory where the models should be written to. Omitting this flag will write - the models to `stdout`. - --csharpArrayType=