chore: Update version to 3.1.1 and modify CLI entry point
- Bumped package version to 3.1.1 in package.json to match the new release. - Changed the CLI entry point to use the new bin/openapi-mcp-generator.js file. - Updated build script to ensure the new CLI file has the correct permissions. - Refactored index.ts to streamline argument parsing and error handling.
This commit is contained in:
parent
0a3aeae2fb
commit
6141d2e8ae
6
bin/openapi-mcp-generator.js
Executable file
6
bin/openapi-mcp-generator.js
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { program } from '../dist/index.js';
|
||||
|
||||
// Parse CLI arguments and run the program
|
||||
program.parse(process.argv);
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-mcp-generator",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.1",
|
||||
"description": "Generates MCP server code from OpenAPI specifications",
|
||||
"license": "MIT",
|
||||
"author": "Harsha",
|
||||
@ -9,10 +9,11 @@
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"openapi-mcp-generator": "./dist/index.js"
|
||||
"openapi-mcp-generator": "./bin/openapi-mcp-generator.js"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"bin",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
@ -20,7 +21,7 @@
|
||||
"start": "node dist/index.js",
|
||||
"clean": "rimraf dist",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "tsc && chmod 755 dist/index.js",
|
||||
"build": "tsc && chmod 755 dist/index.js && chmod 755 bin/openapi-mcp-generator.js",
|
||||
"version:patch": "npm version patch",
|
||||
"version:minor": "npm version minor",
|
||||
"version:major": "npm version major"
|
||||
|
||||
25
src/index.ts
25
src/index.ts
@ -72,22 +72,17 @@ program
|
||||
(val) => parseInt(val, 10)
|
||||
)
|
||||
.option('--force', 'Overwrite existing files without prompting')
|
||||
.version('3.1.0'); // Match package.json version
|
||||
.version('3.1.1') // Match package.json version
|
||||
.action(options => {
|
||||
runGenerator(options)
|
||||
.catch((error) => {
|
||||
console.error('Unhandled error:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
// Check if module is being run directly (not imported)
|
||||
const isMainModule = process.argv[1] === new URL(import.meta.url).pathname;
|
||||
|
||||
if (isMainModule) {
|
||||
// Parse arguments explicitly from process.argv
|
||||
program.parse(process.argv);
|
||||
|
||||
// Run with the parsed options
|
||||
runGenerator(program.opts<CliOptions & { force?: boolean }>())
|
||||
.catch((error) => {
|
||||
console.error('Unhandled error:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
// Export the program object for use in bin stub
|
||||
export { program };
|
||||
|
||||
/**
|
||||
* Main function to run the generator
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user