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

fix: switch CLI run scripts to cjs #2015

Merged
merged 2 commits into from
Jun 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
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" %*
2 changes: 1 addition & 1 deletion 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.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",
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"
]
}
}
Loading