Skip to content

Commit

Permalink
fix cli setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed May 22, 2024
1 parent 1c83912 commit e8a5a75
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 12 deletions.
19 changes: 17 additions & 2 deletions modelina-cli/bin/dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
import {execute} from '@oclif/core';
await execute({development: true, dir: import.meta.url});
#!/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)
12 changes: 10 additions & 2 deletions modelina-cli/bin/run
Original file line number Diff line number Diff line change
@@ -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);
});
13 changes: 13 additions & 0 deletions modelina-cli/bin/run_bin
Original file line number Diff line number Diff line change
@@ -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);
});
3 changes: 3 additions & 0 deletions modelina-cli/bin/run_bin.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run_bin" %*
7 changes: 4 additions & 3 deletions modelina-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions modelina-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "CLI to work with Modelina",
"version": "4.0.0-next.43",
"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",
Expand Down
2 changes: 0 additions & 2 deletions modelina-cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,5 @@ ${model.result}
});
logger.info(`Successfully generated the following models: ${generatedModelsString.join('\n')}`);
}


}
}
2 changes: 1 addition & 1 deletion modelina-cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"include": [
"src"
]
}
}

0 comments on commit e8a5a75

Please sign in to comment.