diff --git a/modelina-cli/bin/dev b/modelina-cli/bin/dev index 62068d62a6..d7e3550f4d 100644 --- a/modelina-cli/bin/dev +++ b/modelina-cli/bin/dev @@ -1,2 +1,17 @@ -import {execute} from '@oclif/core'; -await execute({development: true, dir: import.meta.url}); \ No newline at end of file +#!/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) diff --git a/modelina-cli/bin/run b/modelina-cli/bin/run index 3518fa0a62..e562c3b799 100755 --- a/modelina-cli/bin/run +++ b/modelina-cli/bin/run @@ -1,4 +1,12 @@ #!/usr/bin/env node -import {execute} from '@oclif/core'; -await execute({dir: import.meta.url}); +process.env.NODE_ENV = 'development'; + +const oclif = require('@oclif/core'); + +oclif.run() + .then(require('@oclif/core/flush')) + .catch((err) => { + const oclifHandler = require('@oclif/core/handle'); + return oclifHandler(err.message); + }); \ No newline at end of file diff --git a/modelina-cli/bin/run_bin b/modelina-cli/bin/run_bin new file mode 100755 index 0000000000..73466702f0 --- /dev/null +++ b/modelina-cli/bin/run_bin @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +// Only the binary installed through NPM is considered production environment. See "bin" in package.json. +process.env.NODE_ENV = 'production'; + +const oclif = require('@oclif/core'); + +oclif.run() + .then(require('@oclif/core/flush')) + .catch((err) => { + const oclifHandler = require('@oclif/core/handle'); + return oclifHandler(err.message); + }); diff --git a/modelina-cli/bin/run_bin.cmd b/modelina-cli/bin/run_bin.cmd new file mode 100644 index 0000000000..266f8ea61a --- /dev/null +++ b/modelina-cli/bin/run_bin.cmd @@ -0,0 +1,3 @@ +@echo off + +node "%~dp0\run_bin" %* diff --git a/modelina-cli/package-lock.json b/modelina-cli/package-lock.json index 93c3f5e02b..d3e6054136 100644 --- a/modelina-cli/package-lock.json +++ b/modelina-cli/package-lock.json @@ -9,7 +9,7 @@ "version": "4.0.0-next.45", "license": "Apache-2.0", "dependencies": { - "@asyncapi/modelina": "file:scripts/modelina-package/asyncapi-modelina.tgz", + "@asyncapi/modelina": "file://./scripts/modelina-package/asyncapi-modelina.tgz", "@oclif/core": "^3.26.0", "@oclif/errors": "^1.3.6", "@oclif/plugin-not-found": "^3.1.1", diff --git a/modelina-cli/package.json b/modelina-cli/package.json index 89e08f000b..e810973d6e 100644 --- a/modelina-cli/package.json +++ b/modelina-cli/package.json @@ -3,11 +3,11 @@ "description": "CLI to work with Modelina", "version": "4.0.0-next.45", "bin": { - "modelina": "./bin/run" + "modelina": "./bin/run_bin" }, "bugs": "https://github.com/asyncapi/modelina/issues", "dependencies": { - "@asyncapi/modelina": "file:scripts/modelina-package/asyncapi-modelina.tgz", + "@asyncapi/modelina": "file://./scripts/modelina-package/asyncapi-modelina.tgz", "@oclif/core": "^3.26.0", "@oclif/errors": "^1.3.6", "@oclif/plugin-not-found": "^3.1.1", diff --git a/modelina-cli/src/commands/generate.ts b/modelina-cli/src/commands/generate.ts index 92fb7f370a..3117df74d4 100644 --- a/modelina-cli/src/commands/generate.ts +++ b/modelina-cli/src/commands/generate.ts @@ -45,7 +45,5 @@ ${model.result} }); logger.info(`Successfully generated the following models: ${generatedModelsString.join('\n')}`); } - - } } \ No newline at end of file diff --git a/modelina-cli/tsconfig.json b/modelina-cli/tsconfig.json index 03f609613c..4a10a9ed04 100644 --- a/modelina-cli/tsconfig.json +++ b/modelina-cli/tsconfig.json @@ -23,4 +23,4 @@ "include": [ "src" ] -} \ No newline at end of file +}