Merge pull request #18 from harsha-iiiv/fix/cli-path

chore: Update version to 3.1.1 and modify CLI entry point
This commit is contained in:
Harsha v 2025-05-26 08:55:21 +05:30 committed by GitHub
commit c607d9c759
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 18 deletions

6
bin/openapi-mcp-generator.js Executable file
View 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);

View File

@ -1,6 +1,6 @@
{ {
"name": "openapi-mcp-generator", "name": "openapi-mcp-generator",
"version": "3.1.0", "version": "3.1.1",
"description": "Generates MCP server code from OpenAPI specifications", "description": "Generates MCP server code from OpenAPI specifications",
"license": "MIT", "license": "MIT",
"author": "Harsha", "author": "Harsha",
@ -9,10 +9,11 @@
"node": ">=20.0.0" "node": ">=20.0.0"
}, },
"bin": { "bin": {
"openapi-mcp-generator": "./dist/index.js" "openapi-mcp-generator": "./bin/openapi-mcp-generator.js"
}, },
"files": [ "files": [
"dist", "dist",
"bin",
"README.md", "README.md",
"LICENSE" "LICENSE"
], ],
@ -20,7 +21,7 @@
"start": "node dist/index.js", "start": "node dist/index.js",
"clean": "rimraf dist", "clean": "rimraf dist",
"typecheck": "tsc --noEmit", "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:patch": "npm version patch",
"version:minor": "npm version minor", "version:minor": "npm version minor",
"version:major": "npm version major" "version:major": "npm version major"

View File

@ -72,22 +72,17 @@ program
(val) => parseInt(val, 10) (val) => parseInt(val, 10)
) )
.option('--force', 'Overwrite existing files without prompting') .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) // Export the program object for use in bin stub
const isMainModule = process.argv[1] === new URL(import.meta.url).pathname; export { program };
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);
});
}
/** /**
* Main function to run the generator * Main function to run the generator