MXS-1300: Make the MaxCtrl core a Node.js module
The core is now a module that is loaded by the command line client. This allows the core library to be reused for testing.
This commit is contained in:
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var maxctrl = require('./core.js')
|
var maxctrl = require('maxctrl-core')
|
||||||
|
|
||||||
// Mangle the arguments if we are being called from the command line
|
// Mangle the arguments if we are being called from the command line
|
||||||
if (process.argv[0] == process.execPath) {
|
if (process.argv[0] == process.execPath) {
|
||||||
|
|||||||
@ -16,8 +16,6 @@ var program = require('yargs');
|
|||||||
|
|
||||||
const maxctrl_version = '1.0.0';
|
const maxctrl_version = '1.0.0';
|
||||||
|
|
||||||
require('./common.js')()
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.version(maxctrl_version)
|
.version(maxctrl_version)
|
||||||
.group(['u', 'p', 'h', 's', 't', 'q', 'tsv'], 'Global Options:')
|
.group(['u', 'p', 'h', 's', 't', 'q', 'tsv'], 'Global Options:')
|
||||||
20
maxctrl/maxctrl_core/package.json
Normal file
20
maxctrl/maxctrl_core/package.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "maxctrl-core",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "MaxScale Administrative Client Core Library",
|
||||||
|
"repository": "https://github.com/mariadb-corporation/MaxScale",
|
||||||
|
"main": "core.js",
|
||||||
|
"keywords": [
|
||||||
|
"maxscale"
|
||||||
|
],
|
||||||
|
"author": "MariaDB Corporation Ab",
|
||||||
|
"license": "SEE LICENSE IN ../../LICENSE.TXT",
|
||||||
|
"dependencies": {
|
||||||
|
"cli-table": "^0.3.1",
|
||||||
|
"lodash": "^4.17.4",
|
||||||
|
"lodash-getpath": "^0.2.4",
|
||||||
|
"request": "^2.81.0",
|
||||||
|
"request-promise-native": "^1.0.3",
|
||||||
|
"yargs": "^8.0.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,12 +16,7 @@
|
|||||||
"author": "MariaDB Corporation Ab",
|
"author": "MariaDB Corporation Ab",
|
||||||
"license": "SEE LICENSE IN ../../LICENSE.TXT",
|
"license": "SEE LICENSE IN ../../LICENSE.TXT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cli-table": "^0.3.1",
|
"maxscale-core": "file:./maxctrl_core"
|
||||||
"lodash": "^4.17.4",
|
|
||||||
"lodash-getpath": "^0.2.4",
|
|
||||||
"request": "^2.81.0",
|
|
||||||
"request-promise-native": "^1.0.3",
|
|
||||||
"yargs": "^8.0.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
|
|||||||
@ -3,7 +3,7 @@ require('../test_utils.js')()
|
|||||||
describe("Diagnostic commands", function() {
|
describe("Diagnostic commands", function() {
|
||||||
before(startMaxScale)
|
before(startMaxScale)
|
||||||
|
|
||||||
var ctrl = require('../core.js')
|
var ctrl = require('maxctrl-core')
|
||||||
var tests = [
|
var tests = [
|
||||||
'list servers',
|
'list servers',
|
||||||
'list services',
|
'list services',
|
||||||
|
|||||||
@ -8,10 +8,8 @@ describe("Server states", function() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
var ctrl = require('../core.js')
|
var ctrl = require('maxctrl-core')
|
||||||
var opts = {
|
var opts = { extra_args: [ '--quiet'] }
|
||||||
extra_args: [ '--quiet']
|
|
||||||
}
|
|
||||||
|
|
||||||
it('set correct state', function() {
|
it('set correct state', function() {
|
||||||
return ctrl.execute('set server server2 master'.split(' '), opts)
|
return ctrl.execute('set server server2 master'.split(' '), opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user