implemented entry point
parent
d597387286
commit
c4967af70d
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = function(args) {
|
||||
|
||||
let { name, description, version } = require('../package.json');
|
||||
console.log({ name, description, version });
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const argsparser = require('args-parser');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let required_command = process.argv[2]
|
||||
let args = argsparser(process.argv.slice(2));
|
||||
|
||||
|
||||
let cmds = fs.readdirSync(__dirname)
|
||||
.filter(file => file.startsWith("cmd"))
|
||||
.reduce((result, item) => {
|
||||
let name = item.replace(/^cmd\./, '').replace(/\.js$/, '');
|
||||
result[name] = path.join(__dirname, item);
|
||||
return result
|
||||
}, {})
|
||||
|
||||
if(!cmds[required_command]) {
|
||||
console.error(`Command '${required_command}' not found!`);
|
||||
console.log("Available commands:")
|
||||
Object.keys(cmds).forEach(item => console.log(`\t${item}`))
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
require(cmds[required_command])(args);
|
|
@ -1 +0,0 @@
|
|||
console.log("Generate a new Service")
|
|
@ -1,5 +1,13 @@
|
|||
{
|
||||
"name": "api-cli",
|
||||
"name": "@nclazz/apicli",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"args-parser": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://nexus.nclazz.de/repository/npm_public/args-parser/-/args-parser-1.2.0.tgz",
|
||||
"integrity": "sha512-PNV3dPBkPt6RC6nfpwAbaRbK4urZ6yPRQhS4cmMpa09t+Gqu4Hz6AlREFDvAxZ1DRBKkbIDhm+X/IPHW6cuaQQ=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
package.json
14
package.json
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"name": "api-cli",
|
||||
"name": "@nclazz/apicli",
|
||||
"version": "1.0.0",
|
||||
"description": "Commandline interface for generating and linting api-specs.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"generate": "node generate-service.js"
|
||||
"main": "./bin/index.js",
|
||||
"bin": "./bin/index.js",
|
||||
"scripts": {},
|
||||
"publishConfig": {
|
||||
"registry": "https://nexus.nclazz.de/repository/npm_releases/"
|
||||
},
|
||||
"keywords": [
|
||||
"api",
|
||||
|
@ -14,5 +16,7 @@
|
|||
],
|
||||
"author": "Niclas Thobaben",
|
||||
"license": "MIT",
|
||||
"dependencies": {}
|
||||
"dependencies": {
|
||||
"args-parser": "^1.2.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue