Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to new Oclif versions #1923

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modelina-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
node_modules
oclif.lock
oclif.manifest.json
dist
dist
20 changes: 2 additions & 18 deletions modelina-cli/bin/dev
Original file line number Diff line number Diff line change
@@ -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});
11 changes: 2 additions & 9 deletions modelina-cli/bin/run
Original file line number Diff line number Diff line change
@@ -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});
124 changes: 54 additions & 70 deletions modelina-cli/docs/usage.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,33 @@
---
title: 'Usage'
weight: 40
---

<!--

This file is automatically generated from updateUsageDocs.js script. In package.json in line 158-161 lines the following steps has been executed in order to run this script successfully -

* generate:readme:create: It creates the initial content for the README file by printing the usage and commands tags using printf and redirects the output to scripts/README.md file.
* generate:readme:commands: It changes the directory to the scripts folder and executes the oclif readme command. This command generates the usage and commands sections based on the CLI commands and updates the content in the scripts/README.md file.
* generate:assets: This script combines the two previously mentioned scripts (generate:readme:toc and generate:commands) to generate the necessary assets, such as the README file and usage documentation.
* generate:commands: This script executes the following steps:
- Runs the generate:readme:create script to create the initial content for the README file.
- Executes the generate:readme:commands script to generate the usage and commands sections based on the CLI commands.
- Runs the updateUsageDocs.js script using Node.js to update the usage documentation file with the contents of the generated README file.
- Deletes the scripts/README.md file using the rimraf command.

-->

The Modelina CLI makes it easier to generate AsyncAPI Models.


# Table of contents
<!-- toc -->
* [Table of contents](#table-of-contents)
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage

<!-- 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
...
```
<!-- usagestop -->

# Commands

<!-- 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)
Expand All @@ -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`

Expand All @@ -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`

Expand All @@ -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.
Expand All @@ -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`

Expand All @@ -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`

Expand All @@ -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.
Expand All @@ -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:
Expand All @@ -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`

Expand All @@ -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`

Expand All @@ -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`

Expand All @@ -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`

Expand All @@ -237,40 +219,42 @@ ARGUMENTS
FILE Path or URL to the AsyncAPI document, or context-name

FLAGS
-h, --help Show CLI help.
-o, --output=<value> The output directory where the models should be written to. Omitting this flag will write
the models to `stdout`.
--csharpArrayType=<option> [default: Array] C# specific, define which type of array needs to be generated.
<options: Array|List>
--csharpAutoImplement C# specific, define whether to generate auto-implemented properties or not.
--csharpEqual C# specific, generate the models with the Equal method overwritten
--csharpHashcode C# specific, generate the models with the GetHashCode method overwritten
--csharpNewtonsoft C# specific, generate the models with newtonsoft serialization support
--csharpSystemJson C# specific, generate the models with System.Text.Json serialization support
--javaConstraints Java specific, generate the models with constraints
--javaIncludeComments Java specific, if enabled add comments while generating models.
--javaJackson Java specific, generate the models with Jackson serialization support
--namespace=<value> C#, C++ and PHP specific, define the namespace to use for the generated models. This is
required when language is `csharp`,`c++` or `php`.
--packageName=<value> Go, Java and Kotlin specific, define the package to use for the generated models. This is
required when language is `go`, `java` or `kotlin`.
--tsEnumType=<option> [default: enum] TypeScript specific, define which type of enums needs to be generated.
<options: enum|union>
--tsExampleInstance Typescript specific, generate example of the model.
--tsExportType=<option> [default: default] TypeScript specific, define which type of export needs to be generated.
<options: default|named>
--tsIncludeComments TypeScript specific, if enabled add comments while generating models.
--tsJsonBinPack TypeScript specific, define basic support for serializing to and from binary with
jsonbinpack.
--tsMarshalling TypeScript specific, generate the models with marshalling functions.
--tsModelType=<option> [default: class] TypeScript specific, define which type of model needs to be generated.
<options: class|interface>
--tsModuleSystem=<option> [default: ESM] TypeScript specific, define the module system to be used.
<options: ESM|CJS>
-h, --help Show CLI help.
-o, --output=<value> The output directory where the models should be written to. Omitting this flag will
write the models to `stdout`.
--csharpArrayType=<option> [default: Array] C# specific, define which type of array needs to be generated.
<options: Array|List>
--csharpAutoImplement C# specific, define whether to generate auto-implemented properties or not.
--csharpEqual C# specific, generate the models with the Equal method overwritten
--csharpHashcode C# specific, generate the models with the GetHashCode method overwritten
--csharpNewtonsoft C# specific, generate the models with newtonsoft serialization support
--csharpSystemJson C# specific, generate the models with System.Text.Json serialization support
--javaConstraints Java specific, generate the models with constraints
--javaIncludeComments Java specific, if enabled add comments while generating models.
--javaJackson Java specific, generate the models with Jackson serialization support
--namespace=<value> C#, C++ and PHP specific, define the namespace to use for the generated models. This
is required when language is `csharp`,`c++` or `php`.
--packageName=<value> Go, Java and Kotlin specific, define the package to use for the generated models. This
is required when language is `go`, `java` or `kotlin`.
--tsEnumType=<option> [default: enum] TypeScript specific, define which type of enums needs to be generated.
<options: enum|union>
--tsExampleInstance Typescript specific, generate example of the model.
--tsExportType=<option> [default: default] TypeScript specific, define which type of export needs to be
generated.
<options: default|named>
--tsIncludeComments TypeScript specific, if enabled add comments while generating models.
--tsJsonBinPack TypeScript specific, define basic support for serializing to and from binary with
jsonbinpack.
--tsMarshalling TypeScript specific, generate the models with marshalling functions.
--tsModelType=<option> [default: class] TypeScript specific, define which type of model needs to be
generated.
<options: class|interface>
--tsModuleSystem=<option> [default: ESM] TypeScript specific, define the module system to be used.
<options: ESM|CJS>

DESCRIPTION
Generates typed models
```

_See code: [src/commands/generate.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.22/src/commands/generate.ts)_
_See code: [src/commands/generate.ts](https://github.com/asyncapi/modelina/blob/v4.0.0-next.23/src/commands/generate.ts)_
<!-- commandsstop -->
Loading
Loading