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

Use es6 exports, replace module.exports #12084

Merged
merged 24 commits into from
Jun 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions src/cli/cluster/cluster_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import BasePathProxy from './base_path_proxy';

process.env.kbnWorkerType = 'managr';

module.exports = class ClusterManager {
export default class ClusterManager {
constructor(opts = {}, settings = {}) {
this.log = new Log(opts.quiet, opts.silent);
this.addedCount = 0;
Expand Down Expand Up @@ -169,4 +169,4 @@ module.exports = class ClusterManager {
this.log.bad('failed to watch files!\n', err.stack);
process.exit(1); // eslint-disable-line no-process-exit
}
};
}
4 changes: 2 additions & 2 deletions src/cli/cluster/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const dead = fork => {
return fork.isDead() || fork.killed;
};

module.exports = class Worker extends EventEmitter {
export default class Worker extends EventEmitter {
constructor(opts) {
opts = opts || {};
super();
Expand Down Expand Up @@ -162,4 +162,4 @@ module.exports = class Worker extends EventEmitter {
// wait for the fork to report it is online before resolving
await new Promise(cb => this.once('fork:online', cb));
}
};
}
7 changes: 3 additions & 4 deletions src/cli/color.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

import _ from 'lodash';
import ansicolors from 'ansicolors';

exports.green = _.flow(ansicolors.black, ansicolors.bgGreen);
exports.red = _.flow(ansicolors.white, ansicolors.bgRed);
exports.yellow = _.flow(ansicolors.black, ansicolors.bgYellow);
export const green = _.flow(ansicolors.black, ansicolors.bgGreen);
export const red = _.flow(ansicolors.white, ansicolors.bgRed);
export const yellow = _.flow(ansicolors.black, ansicolors.bgYellow);
2 changes: 1 addition & 1 deletion src/cli/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ Command.prototype.action = _.wrap(Command.prototype.action, function (action, fn
});
});

module.exports = Command;
export default Command;
12 changes: 6 additions & 6 deletions src/cli/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const log = _.restParam(function (color, label, rest1) {
console.log.apply(console, [color(` ${_.trim(label)} `)].concat(rest1));
});

import color from './color';
import { green, yellow, red } from './color';

module.exports = class Log {
export default class Log {
constructor(quiet, silent) {
this.good = quiet || silent ? _.noop : _.partial(log, color.green);
this.warn = quiet || silent ? _.noop : _.partial(log, color.yellow);
this.bad = silent ? _.noop : _.partial(log, color.red);
this.good = quiet || silent ? _.noop : _.partial(log, green);
this.warn = quiet || silent ? _.noop : _.partial(log, yellow);
this.bad = silent ? _.noop : _.partial(log, red);
}
};
}
4 changes: 2 additions & 2 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function readServerSettings(opts, extraCliOptions) {
return settings;
}

module.exports = function (program) {
export default function (program) {
const command = program.command('serve');

command
Expand Down Expand Up @@ -170,7 +170,7 @@ module.exports = function (program) {

return kbnServer;
});
};
}

function logFatal(message, server) {
if (server) {
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/console/api_server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ function Api(name) {

}(Api.prototype));

module.exports = Api;
export default Api;
4 changes: 3 additions & 1 deletion src/core_plugins/console/api_server/es_5_0.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ ES_5_0.prototype = _.create(Api.prototype, { 'constructor': ES_5_0 });
};
})(ES_5_0.prototype);

module.exports = new ES_5_0();
const instance = new ES_5_0();

export default instance;
5 changes: 3 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/aggregations.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,9 @@ var rules = {
}
}
};
module.exports = function (api) {

export default function (api) {

api.addGlobalAutocompleteRules('aggregations', rules);
api.addGlobalAutocompleteRules('aggs', rules);
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/aliases.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_post_aliases', {
methods: ['POST'],
patterns: [
Expand Down Expand Up @@ -68,4 +68,4 @@ module.exports = function (api) {
api.addGlobalAutocompleteRules('aliases', {
'*': aliasRules
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function addNodeattrsCat(api) {
});
}

module.exports = function (api) {
export default function (api) {
addSimpleCat('_cat/aliases', api);
addSimpleCat('_cat/allocation', api, null, ['_cat/allocation', '_cat/allocation/{nodes}']);
addSimpleCat('_cat/count', api);
Expand All @@ -53,4 +53,4 @@ module.exports = function (api) {
addSimpleCat('_cat/plugins', api);
addSimpleCat('_cat/segments', api);
addNodeattrsCat(api);
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/cluster.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_cluster/nodes/stats');
api.addEndpointDescription('_cluster/state', {
patterns: [
Expand Down Expand Up @@ -139,4 +139,4 @@ module.exports = function (api) {
dry_run: { __one_of: [true, false] }
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/count.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_count', {
methods: ['GET', 'POST'],
priority: 10, // collides with get doc by id
Expand All @@ -19,4 +19,4 @@ module.exports = function (api) {
}
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/document.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_get_doc', {
methods: ['GET'],
patterns: [
Expand Down Expand Up @@ -230,4 +230,4 @@ module.exports = function (api) {
}
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/field_stats.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_field_stats', {
methods: ['GET', 'POST'],
patterns: [
Expand Down Expand Up @@ -44,4 +44,4 @@ module.exports = function (api) {
}
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ filters.nested = {
_name: ''
};

module.exports = function (api) {
export default function (api) {
api.addGlobalAutocompleteRules('filter', filters);
};
}

4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/globals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addGlobalAutocompleteRules('highlight', {
pre_tags: {},
post_tags: {},
Expand All @@ -21,4 +21,4 @@ module.exports = function (api) {
lang: "",
params: {}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/indices.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_refresh', {
methods: ['POST'],
patterns: [
Expand Down Expand Up @@ -231,4 +231,4 @@ module.exports = function (api) {
"{indices}/_open"
]
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/ingest.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ const simulateUrlParamsDefinition = {
"verbose": "__flag__"
};

module.exports = function (api) {
export default function (api) {

// Note: this isn't an actual API endpoint. It exists so the forEach processor's "processor" field
// may recursively use the autocomplete rules for any processor.
Expand Down Expand Up @@ -383,4 +383,4 @@ module.exports = function (api) {
]
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var BOOLEAN = {
__one_of: [true, false]
};

module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_get_mapping', {
methods: ['GET'],
priority: 10, // collides with get doc by id
Expand Down Expand Up @@ -216,4 +216,4 @@ module.exports = function (api) {
}
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/nodes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_nodes/hot_threads', {
methods: ['GET'],
patterns: [
Expand Down Expand Up @@ -75,4 +75,4 @@ module.exports = function (api) {
]
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/percolator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_put_percolator', {
priority: 10, // to override doc
methods: ['PUT', 'POST'],
Expand Down Expand Up @@ -87,4 +87,4 @@ module.exports = function (api) {
filter: {}
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var DECAY_FUNC_DESC = {
}
};

module.exports = function (api) {
export default function (api) {
api.addGlobalAutocompleteRules('query', {
match: {
__template: {
Expand Down Expand Up @@ -624,4 +624,4 @@ module.exports = function (api) {


});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/reindex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {

api.addEndpointDescription('_post_reindex', {
methods: [ 'POST' ],
Expand Down Expand Up @@ -54,4 +54,4 @@ module.exports = function (api) {
'script': { __scope_link: 'GLOBAL.script' },
}
})
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_search', {
methods: ['GET', 'POST'],
priority: 10, // collides with get doc by id
Expand Down Expand Up @@ -252,4 +252,4 @@ module.exports = function (api) {
local: "__flag__"
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/settings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {

api.addEndpointDescription('_get_settings', {
patterns: [
Expand Down Expand Up @@ -83,4 +83,4 @@ module.exports = function (api) {
}
}
});
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('restore_snapshot', {
methods: ['POST'],
patterns: [
Expand Down Expand Up @@ -126,4 +126,4 @@ module.exports = function (api) {
}
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/es_5_0/templates.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (api) {
export default function (api) {
api.addEndpointDescription('_delete_template', {
methods: ['DELETE'],
patterns: [
Expand All @@ -24,4 +24,4 @@ module.exports = function (api) {
settings: { __scope_link: '_put_settings' }
}
});
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/api_server/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let _ = require("lodash");

module.exports.resolveApi = function (sense_version, apis, reply) {
export function resolveApi(sense_version, apis, reply) {
let result = {};
_.each(apis, function (name) {
{
Expand All @@ -11,4 +11,4 @@ module.exports.resolveApi = function (sense_version, apis, reply) {
});

return reply(result).type("application/json");
};
}
4 changes: 2 additions & 2 deletions src/core_plugins/console/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Boom from 'boom';
import apiServer from './api_server/server';
import { resolveApi } from './api_server/server';
import { existsSync } from 'fs';
import { resolve, join, sep } from 'path';
import { has, isEmpty } from 'lodash';
Expand Down Expand Up @@ -109,7 +109,7 @@ export default function (kibana) {
return;
}

return apiServer.resolveApi(sense_version, apis.split(','), reply);
return resolveApi(sense_version, apis.split(','), reply);
}
});

Expand Down
Loading