From 249ad9f0784e0f96acbb600549701ea430683d45 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Wed, 3 Apr 2024 13:02:24 +0200 Subject: [PATCH] feat: migrate to new Oclif versions (#1923) --- modelina-cli/.gitignore | 2 +- modelina-cli/bin/dev | 20 +- modelina-cli/bin/run | 11 +- modelina-cli/docs/usage.md | 124 +- modelina-cli/package-lock.json | 40074 ++++++++++++---- modelina-cli/package.json | 24 +- modelina-cli/scripts/updateUsageDocs.js | 73 - .../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 | 19 +- modelina-cli/src/models/Context.ts | 4 +- modelina-cli/test/integration/context.test.ts | 6 + .../mycompany/app/generic/AddressSpec.scala | 4 +- 16 files changed, 31545 insertions(+), 8880 deletions(-) delete mode 100644 modelina-cli/scripts/updateUsageDocs.js diff --git a/modelina-cli/.gitignore b/modelina-cli/.gitignore index 2df49f6450..d462e9a034 100644 --- a/modelina-cli/.gitignore +++ b/modelina-cli/.gitignore @@ -9,4 +9,4 @@ node_modules oclif.lock oclif.manifest.json -dist \ No newline at end of file +dist 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..b12be75d06 100644 --- a/modelina-cli/docs/usage.md +++ b/modelina-cli/docs/usage.md @@ -1,51 +1,33 @@ ---- -title: 'Usage' -weight: 40 ---- - - - The Modelina CLI makes it easier to generate AsyncAPI Models. - +# Table of contents + +* [Table of contents](#table-of-contents) +* [Usage](#usage) +* [Commands](#commands) + # Usage - ```sh-session $ 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 ... ``` - # Commands - * [`modelina config`](#modelina-config) * [`modelina config context`](#modelina-config-context) * [`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 +45,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 +59,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 +71,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 +81,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 +98,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 +110,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 +119,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 +142,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 +159,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 +179,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 +199,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 +219,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=