Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ui/app_entry_template.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = function ({env, bundle}) {

let pluginSlug = env.pluginInfo.sort()
const pluginSlug = env.pluginInfo.sort()
.map(p => ' * - ' + p)
.join('\n');

let requires = bundle.modules
const requires = bundle.modules
.map(m => `require('${m}');`)
.join('\n');

Expand Down
14 changes: 7 additions & 7 deletions src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import UiBundleCollection from './ui_bundle_collection';
import UiBundlerEnv from './ui_bundler_env';
module.exports = async (kbnServer, server, config) => {

let loadingGif = readFile(fromRoot('src/ui/public/loading.gif'), { encoding: 'base64'});
const loadingGif = readFile(fromRoot('src/ui/public/loading.gif'), { encoding: 'base64'});

let uiExports = kbnServer.uiExports = new UiExports({
const uiExports = kbnServer.uiExports = new UiExports({
urlBasePath: config.get('server.basePath')
});

let bundlerEnv = new UiBundlerEnv(config.get('optimize.bundleDir'));
const bundlerEnv = new UiBundlerEnv(config.get('optimize.bundleDir'));
bundlerEnv.addContext('env', config.get('env.name'));
bundlerEnv.addContext('urlBasePath', config.get('server.basePath'));
bundlerEnv.addContext('sourceMaps', config.get('optimize.sourceMaps'));
Expand All @@ -28,14 +28,14 @@ module.exports = async (kbnServer, server, config) => {
uiExports.consumePlugin(plugin);
}

let bundles = kbnServer.bundles = new UiBundleCollection(bundlerEnv, config.get('optimize.bundleFilter'));
const bundles = kbnServer.bundles = new UiBundleCollection(bundlerEnv, config.get('optimize.bundleFilter'));

for (let app of uiExports.getAllApps()) {
bundles.addApp(app);
}

for (let gen of uiExports.getBundleProviders()) {
let bundle = await gen(UiBundle, bundlerEnv, uiExports.getAllApps(), kbnServer.plugins);
const bundle = await gen(UiBundle, bundlerEnv, uiExports.getAllApps(), kbnServer.plugins);
if (bundle) bundles.add(bundle);
}

Expand All @@ -47,8 +47,8 @@ module.exports = async (kbnServer, server, config) => {
path: '/app/{id}',
method: 'GET',
handler: function (req, reply) {
let id = req.params.id;
let app = uiExports.apps.byId[id];
const id = req.params.id;
const app = uiExports.apps.byId[id];
if (!app) return reply(Boom.notFound('Unknown app ' + id));

if (kbnServer.status.isGreen()) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/ui_app_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import UiApp from './ui_app';
import Collection from '../utils/collection';

let byIdCache = Symbol('byId');
const byIdCache = Symbol('byId');

module.exports = class UiAppCollection extends Collection {

Expand All @@ -25,7 +25,7 @@ module.exports = class UiAppCollection extends Collection {
return this.hidden.new(spec);
}

let app = new UiApp(this.uiExports, spec);
const app = new UiApp(this.uiExports, spec);

if (_.includes(this.claimedIds, app.id)) {
throw new Error('Unable to create two apps with the id ' + app.id + '.');
Expand Down
12 changes: 6 additions & 6 deletions src/ui/ui_bundle.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { join } from 'path';
import { promisify } from 'bluebird';

let read = promisify(require('fs').readFile);
let write = promisify(require('fs').writeFile);
let unlink = promisify(require('fs').unlink);
let stat = promisify(require('fs').stat);
const read = promisify(require('fs').readFile);
const write = promisify(require('fs').writeFile);
const unlink = promisify(require('fs').unlink);
const stat = promisify(require('fs').stat);

module.exports = class UiBundle {
constructor(opts) {
Expand All @@ -15,7 +15,7 @@ module.exports = class UiBundle {
this.template = opts.template;
this.env = opts.env;

let pathBase = join(this.env.workingDir, this.id);
const pathBase = join(this.env.workingDir, this.id);
this.entryPath = `${pathBase}.entry.js`;
this.outputPath = `${pathBase}.bundle.js`;

Expand All @@ -30,7 +30,7 @@ module.exports = class UiBundle {

async readEntryFile() {
try {
let content = await read(this.entryPath);
const content = await read(this.entryPath);
return content.toString('utf8');
}
catch (e) {
Expand Down
22 changes: 11 additions & 11 deletions src/ui/ui_bundle_collection.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let rimraf = promisify(require('rimraf'));
let mkdirp = promisify(require('mkdirp'));
let unlink = promisify(require('fs').unlink);
let readdir = promisify(require('fs').readdir);
const rimraf = promisify(require('rimraf'));
const mkdirp = promisify(require('mkdirp'));
const unlink = promisify(require('fs').unlink);
const readdir = promisify(require('fs').readdir);

import UiBundle from './ui_bundle';
import appEntryTemplate from './app_entry_template';
Expand Down Expand Up @@ -48,9 +48,9 @@ class UiBundleCollection {
case 1:
return `bundle for ${this.each[0].id}`;
default:
var ids = this.getIds();
var last = ids.pop();
var commas = ids.join(', ');
const ids = this.getIds();
const last = ids.pop();
const commas = ids.join(', ');
return `bundles for ${commas} and ${last}`;
}
}
Expand All @@ -63,8 +63,8 @@ class UiBundleCollection {
await this.ensureDir();

for (let bundle of this.each) {
let existing = await bundle.readEntryFile();
let expected = bundle.renderContent();
const existing = await bundle.readEntryFile();
const expected = bundle.renderContent();

if (existing !== expected) {
await bundle.writeEntryFile();
Expand All @@ -74,10 +74,10 @@ class UiBundleCollection {
}

async getInvalidBundles() {
let invalids = new UiBundleCollection(this.env);
const invalids = new UiBundleCollection(this.env);

for (let bundle of this.each) {
let exists = await bundle.checkForExistingOutput();
const exists = await bundle.checkForExistingOutput();
if (!exists) {
invalids.add(bundle);
}
Expand Down
14 changes: 7 additions & 7 deletions src/ui/ui_bundler_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { includes, flow, escapeRegExp } from 'lodash';
import { isString, isArray, isPlainObject, get } from 'lodash';
import { keys } from 'lodash';

let asRegExp = flow(
const asRegExp = flow(
escapeRegExp,
function (path) {
let last = path.slice(-1);
const last = path.slice(-1);
if (last === '/' || last === '\\') {
// match a directory explicitly
return path + '.*';
Expand All @@ -18,7 +18,7 @@ let asRegExp = flow(
RegExp
);

let arr = v => [].concat(v || []);
const arr = v => [].concat(v || []);

module.exports = class UiBundlerEnv {
constructor(workingDir) {
Expand Down Expand Up @@ -58,7 +58,7 @@ module.exports = class UiBundlerEnv {
}

consumePlugin(plugin) {
let tag = `${plugin.id}@${plugin.version}`;
const tag = `${plugin.id}@${plugin.version}`;
if (includes(this.pluginInfo, tag)) return;

if (plugin.publicDir) {
Expand Down Expand Up @@ -141,7 +141,7 @@ module.exports = class UiBundlerEnv {

this.aliases[id] = path;

let loader = [];
const loader = [];
if (imports) {
loader.push(`imports?${imports}`);
}
Expand All @@ -153,10 +153,10 @@ module.exports = class UiBundlerEnv {
}

claim(id, pluginId) {
let owner = pluginId ? `Plugin ${pluginId}` : 'Kibana Server';
const owner = pluginId ? `Plugin ${pluginId}` : 'Kibana Server';

// TODO(spalger): we could do a lot more to detect colliding module defs
var existingOwner = this.aliasOwners[id] || this.aliasOwners[`${id}$`];
const existingOwner = this.aliasOwners[id] || this.aliasOwners[`${id}$`];

if (existingOwner) {
throw new TypeError(`${owner} attempted to override export "${id}" from ${existingOwner}`);
Expand Down
14 changes: 7 additions & 7 deletions src/ui/ui_exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class UiExports {
consumePlugin(plugin) {
plugin.apps = new UiAppCollection(this);

var types = _.keys(plugin.uiExportsSpecs);
const types = _.keys(plugin.uiExportsSpecs);
if (!types) return false;

var unkown = _.reject(types, this.exportConsumer, this);
const unkown = _.reject(types, this.exportConsumer, this);
if (unkown.length) {
throw new Error('unknown export types ' + unkown.join(', ') + ' in plugin ' + plugin.id);
}
Expand All @@ -43,7 +43,7 @@ class UiExports {
exportConsumer(type) {
for (let consumer of this.consumers) {
if (!consumer.exportConsumer) continue;
let fn = consumer.exportConsumer(type);
const fn = consumer.exportConsumer(type);
if (fn) return fn;
}

Expand All @@ -54,7 +54,7 @@ class UiExports {
const id = plugin.id;
for (let spec of [].concat(specs || [])) {

let app = this.apps.new(_.defaults({}, spec, {
const app = this.apps.new(_.defaults({}, spec, {
id: plugin.id,
urlBasePath: this.urlBasePath
}));
Expand Down Expand Up @@ -110,9 +110,9 @@ class UiExports {
}

find(patterns) {
var aliases = this.aliases;
var names = _.keys(aliases);
var matcher = _.partialRight(minimatch.filter, { matchBase: true });
const aliases = this.aliases;
const names = _.keys(aliases);
const matcher = _.partialRight(minimatch.filter, { matchBase: true });

return _.chain(patterns)
.map(function (pattern) {
Expand Down