mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Revert "Merge pull request #6906 from elastic/jasper/backport/6882/6895/4.5"
This reverts commitfab8b0815b
, reversing changes made to86ec090a2c
.
This commit is contained in:
parent
48fd8b5775
commit
abda88de5f
9 changed files with 74 additions and 74 deletions
|
@ -1,6 +1,6 @@
|
|||
const _ = require('lodash');
|
||||
var _ = require('lodash');
|
||||
var { join } = require('path');
|
||||
const autoload = require('./autoload');
|
||||
var autoload = require('./autoload');
|
||||
|
||||
class UiApp {
|
||||
constructor(uiExports, spec) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const _ = require('lodash');
|
||||
const UiApp = require('./UiApp');
|
||||
const Collection = require('requirefrom')('src')('utils/Collection');
|
||||
let _ = require('lodash');
|
||||
let UiApp = require('./UiApp');
|
||||
let Collection = require('requirefrom')('src')('utils/Collection');
|
||||
|
||||
const byIdCache = Symbol('byId');
|
||||
let byIdCache = Symbol('byId');
|
||||
|
||||
module.exports = class UiAppCollection extends Collection {
|
||||
|
||||
|
@ -25,7 +25,7 @@ module.exports = class UiAppCollection extends Collection {
|
|||
return this.hidden.new(spec);
|
||||
}
|
||||
|
||||
const app = new UiApp(this.uiExports, spec);
|
||||
let 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 + '.');
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
let { join } = require('path');
|
||||
let { promisify } = require('bluebird');
|
||||
const read = promisify(require('fs').readFile);
|
||||
const write = promisify(require('fs').writeFile);
|
||||
const unlink = promisify(require('fs').unlink);
|
||||
const stat = promisify(require('fs').stat);
|
||||
let read = promisify(require('fs').readFile);
|
||||
let write = promisify(require('fs').writeFile);
|
||||
let unlink = promisify(require('fs').unlink);
|
||||
let stat = promisify(require('fs').stat);
|
||||
|
||||
module.exports = class UiBundle {
|
||||
constructor(opts) {
|
||||
|
@ -15,7 +15,7 @@ module.exports = class UiBundle {
|
|||
this.template = opts.template;
|
||||
this.env = opts.env;
|
||||
|
||||
const pathBase = join(this.env.workingDir, this.id);
|
||||
let pathBase = join(this.env.workingDir, this.id);
|
||||
this.entryPath = `${pathBase}.entry.js`;
|
||||
this.outputPath = `${pathBase}.bundle.js`;
|
||||
|
||||
|
@ -30,7 +30,7 @@ module.exports = class UiBundle {
|
|||
|
||||
async readEntryFile() {
|
||||
try {
|
||||
const content = await read(this.entryPath);
|
||||
let content = await read(this.entryPath);
|
||||
return content.toString('utf8');
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
@ -2,14 +2,14 @@ let { pull, transform, pluck } = require('lodash');
|
|||
let { join } = require('path');
|
||||
let { resolve, promisify } = require('bluebird');
|
||||
let { makeRe } = require('minimatch');
|
||||
const rimraf = promisify(require('rimraf'));
|
||||
const mkdirp = promisify(require('mkdirp'));
|
||||
const unlink = promisify(require('fs').unlink);
|
||||
const readdir = promisify(require('fs').readdir);
|
||||
const readSync = require('fs').readFileSync;
|
||||
let rimraf = promisify(require('rimraf'));
|
||||
let mkdirp = promisify(require('mkdirp'));
|
||||
let unlink = promisify(require('fs').unlink);
|
||||
let readdir = promisify(require('fs').readdir);
|
||||
let readSync = require('fs').readFileSync;
|
||||
|
||||
const UiBundle = require('./UiBundle');
|
||||
const appEntryTemplate = require('./appEntryTemplate');
|
||||
let UiBundle = require('./UiBundle');
|
||||
let appEntryTemplate = require('./appEntryTemplate');
|
||||
|
||||
class UiBundleCollection {
|
||||
constructor(bundlerEnv, filter) {
|
||||
|
@ -48,9 +48,9 @@ class UiBundleCollection {
|
|||
case 1:
|
||||
return `bundle for ${this.each[0].id}`;
|
||||
default:
|
||||
const ids = this.getIds();
|
||||
const last = ids.pop();
|
||||
const commas = ids.join(', ');
|
||||
var ids = this.getIds();
|
||||
var last = ids.pop();
|
||||
var commas = ids.join(', ');
|
||||
return `bundles for ${commas} and ${last}`;
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ class UiBundleCollection {
|
|||
await this.ensureDir();
|
||||
|
||||
for (let bundle of this.each) {
|
||||
const existing = await bundle.readEntryFile();
|
||||
const expected = bundle.renderContent();
|
||||
let existing = await bundle.readEntryFile();
|
||||
let expected = bundle.renderContent();
|
||||
|
||||
if (existing !== expected) {
|
||||
await bundle.writeEntryFile();
|
||||
|
@ -74,10 +74,10 @@ class UiBundleCollection {
|
|||
}
|
||||
|
||||
async getInvalidBundles() {
|
||||
const invalids = new UiBundleCollection(this.env);
|
||||
let invalids = new UiBundleCollection(this.env);
|
||||
|
||||
for (let bundle of this.each) {
|
||||
const exists = await bundle.checkForExistingOutput();
|
||||
let exists = await bundle.checkForExistingOutput();
|
||||
if (!exists) {
|
||||
invalids.add(bundle);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
let { includes, flow, escapeRegExp } = require('lodash');
|
||||
let { isString, isArray, isPlainObject, get } = require('lodash');
|
||||
let { keys } = require('lodash');
|
||||
const fromRoot = require('../utils/fromRoot');
|
||||
let fromRoot = require('../utils/fromRoot');
|
||||
|
||||
const asRegExp = flow(
|
||||
let asRegExp = flow(
|
||||
escapeRegExp,
|
||||
function (path) {
|
||||
const last = path.slice(-1);
|
||||
let last = path.slice(-1);
|
||||
if (last === '/' || last === '\\') {
|
||||
// match a directory explicitly
|
||||
return path + '.*';
|
||||
|
@ -18,7 +18,7 @@ const asRegExp = flow(
|
|||
RegExp
|
||||
);
|
||||
|
||||
const arr = v => [].concat(v || []);
|
||||
let arr = v => [].concat(v || []);
|
||||
|
||||
module.exports = class UiBundlerEnv {
|
||||
constructor(workingDir) {
|
||||
|
@ -58,7 +58,7 @@ module.exports = class UiBundlerEnv {
|
|||
}
|
||||
|
||||
consumePlugin(plugin) {
|
||||
const tag = `${plugin.id}@${plugin.version}`;
|
||||
let tag = `${plugin.id}@${plugin.version}`;
|
||||
if (includes(this.pluginInfo, tag)) return;
|
||||
|
||||
if (plugin.publicDir) {
|
||||
|
@ -141,7 +141,7 @@ module.exports = class UiBundlerEnv {
|
|||
|
||||
this.aliases[id] = path;
|
||||
|
||||
const loader = [];
|
||||
let loader = [];
|
||||
if (imports) {
|
||||
loader.push(`imports?${imports}`);
|
||||
}
|
||||
|
@ -153,10 +153,10 @@ module.exports = class UiBundlerEnv {
|
|||
}
|
||||
|
||||
claim(id, pluginId) {
|
||||
const owner = pluginId ? `Plugin ${pluginId}` : 'Kibana Server';
|
||||
let owner = pluginId ? `Plugin ${pluginId}` : 'Kibana Server';
|
||||
|
||||
// TODO(spalger): we could do a lot more to detect colliding module defs
|
||||
const existingOwner = this.aliasOwners[id] || this.aliasOwners[`${id}$`];
|
||||
var existingOwner = this.aliasOwners[id] || this.aliasOwners[`${id}$`];
|
||||
|
||||
if (existingOwner) {
|
||||
throw new TypeError(`${owner} attempted to override export "${id}" from ${existingOwner}`);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const _ = require('lodash');
|
||||
const minimatch = require('minimatch');
|
||||
var _ = require('lodash');
|
||||
var minimatch = require('minimatch');
|
||||
|
||||
const UiAppCollection = require('./UiAppCollection');
|
||||
var UiAppCollection = require('./UiAppCollection');
|
||||
|
||||
class UiExports {
|
||||
constructor({ urlBasePath }) {
|
||||
|
@ -16,10 +16,10 @@ class UiExports {
|
|||
consumePlugin(plugin) {
|
||||
plugin.apps = new UiAppCollection(this);
|
||||
|
||||
const types = _.keys(plugin.uiExportsSpecs);
|
||||
var types = _.keys(plugin.uiExportsSpecs);
|
||||
if (!types) return false;
|
||||
|
||||
const unkown = _.reject(types, this.exportConsumer, this);
|
||||
var unkown = _.reject(types, this.exportConsumer, this);
|
||||
if (unkown.length) {
|
||||
throw new Error('unknown export types ' + unkown.join(', ') + ' in plugin ' + plugin.id);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class UiExports {
|
|||
exportConsumer(type) {
|
||||
for (let consumer of this.consumers) {
|
||||
if (!consumer.exportConsumer) continue;
|
||||
const fn = consumer.exportConsumer(type);
|
||||
let fn = consumer.exportConsumer(type);
|
||||
if (fn) return fn;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class UiExports {
|
|||
case 'apps':
|
||||
return (plugin, specs) => {
|
||||
for (let spec of [].concat(specs || [])) {
|
||||
const app = this.apps.new(_.defaults({}, spec, {
|
||||
let app = this.apps.new(_.defaults({}, spec, {
|
||||
id: plugin.id,
|
||||
urlBasePath: this.urlBasePath
|
||||
}));
|
||||
|
@ -80,9 +80,9 @@ class UiExports {
|
|||
}
|
||||
|
||||
find(patterns) {
|
||||
const aliases = this.aliases;
|
||||
const names = _.keys(aliases);
|
||||
const matcher = _.partialRight(minimatch.filter, { matchBase: true });
|
||||
var aliases = this.aliases;
|
||||
var names = _.keys(aliases);
|
||||
var matcher = _.partialRight(minimatch.filter, { matchBase: true });
|
||||
|
||||
return _.chain(patterns)
|
||||
.map(function (pattern) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
module.exports = function ({env, bundle}) {
|
||||
|
||||
const pluginSlug = env.pluginInfo.sort()
|
||||
let pluginSlug = env.pluginInfo.sort()
|
||||
.map(p => ' * - ' + p)
|
||||
.join('\n');
|
||||
|
||||
const requires = bundle.modules
|
||||
let requires = bundle.modules
|
||||
.map(m => `require('${m}');`)
|
||||
.join('\n');
|
||||
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
const _ = require('lodash');
|
||||
const resolve = require('path').resolve;
|
||||
const basename = require('path').basename;
|
||||
const readdir = require('fs').readdirSync;
|
||||
var _ = require('lodash');
|
||||
var resolve = require('path').resolve;
|
||||
var basename = require('path').basename;
|
||||
var readdir = require('fs').readdirSync;
|
||||
|
||||
const utils = require('requirefrom')('src/utils');
|
||||
const fromRoot = utils('fromRoot');
|
||||
var utils = require('requirefrom')('src/utils');
|
||||
var fromRoot = utils('fromRoot');
|
||||
|
||||
function scan(type) {
|
||||
const dir = fromRoot('src/ui/public', type);
|
||||
var dir = fromRoot('src/ui/public', type);
|
||||
|
||||
return _.chain(readdir(dir))
|
||||
.reject(function (name) {
|
||||
return name[0] === '.' || name[0] === '_';
|
||||
})
|
||||
.map(function (filename) {
|
||||
const path = resolve(dir, filename);
|
||||
const name = basename(filename, '.js');
|
||||
var path = resolve(dir, filename);
|
||||
var name = basename(filename, '.js');
|
||||
return `ui/${type}/${name}`;
|
||||
})
|
||||
.value();
|
||||
}
|
||||
|
||||
function findStyles() {
|
||||
const base = ['ui/styles/theme.less', 'ui/styles/base.less'];
|
||||
const exclude = ['ui/styles/mixins.less', 'ui/styles/variables.less'];
|
||||
const found = scan('styles', true);
|
||||
var base = ['ui/styles/theme.less', 'ui/styles/base.less'];
|
||||
var exclude = ['ui/styles/mixins.less', 'ui/styles/variables.less'];
|
||||
var found = scan('styles', true);
|
||||
|
||||
return _.difference(_.union(base, found), exclude);
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
module.exports = async (kbnServer, server, config) => {
|
||||
let { defaults } = require('lodash');
|
||||
const Boom = require('boom');
|
||||
const formatUrl = require('url').format;
|
||||
let Boom = require('boom');
|
||||
let formatUrl = require('url').format;
|
||||
let { resolve } = require('path');
|
||||
const readFile = require('fs').readFileSync;
|
||||
let readFile = require('fs').readFileSync;
|
||||
|
||||
const fromRoot = require('../utils/fromRoot');
|
||||
const UiExports = require('./UiExports');
|
||||
const UiBundle = require('./UiBundle');
|
||||
const UiBundleCollection = require('./UiBundleCollection');
|
||||
const UiBundlerEnv = require('./UiBundlerEnv');
|
||||
const loadingGif = readFile(fromRoot('src/ui/public/loading.gif'), { encoding: 'base64'});
|
||||
let fromRoot = require('../utils/fromRoot');
|
||||
let UiExports = require('./UiExports');
|
||||
let UiBundle = require('./UiBundle');
|
||||
let UiBundleCollection = require('./UiBundleCollection');
|
||||
let UiBundlerEnv = require('./UiBundlerEnv');
|
||||
let loadingGif = readFile(fromRoot('src/ui/public/loading.gif'), { encoding: 'base64'});
|
||||
|
||||
const uiExports = kbnServer.uiExports = new UiExports({
|
||||
let uiExports = kbnServer.uiExports = new UiExports({
|
||||
urlBasePath: config.get('server.basePath')
|
||||
});
|
||||
|
||||
const bundlerEnv = new UiBundlerEnv(config.get('optimize.bundleDir'));
|
||||
let 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'));
|
||||
|
@ -28,14 +28,14 @@ module.exports = async (kbnServer, server, config) => {
|
|||
uiExports.consumePlugin(plugin);
|
||||
}
|
||||
|
||||
const bundles = kbnServer.bundles = new UiBundleCollection(bundlerEnv, config.get('optimize.bundleFilter'));
|
||||
let 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()) {
|
||||
const bundle = await gen(UiBundle, bundlerEnv, uiExports.getAllApps());
|
||||
let bundle = await gen(UiBundle, bundlerEnv, uiExports.getAllApps());
|
||||
if (bundle) bundles.add(bundle);
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ module.exports = async (kbnServer, server, config) => {
|
|||
path: '/app/{id}',
|
||||
method: 'GET',
|
||||
handler: function (req, reply) {
|
||||
const id = req.params.id;
|
||||
const app = uiExports.apps.byId[id];
|
||||
let id = req.params.id;
|
||||
let app = uiExports.apps.byId[id];
|
||||
if (!app) return reply(Boom.notFound('Unknown app ' + id));
|
||||
|
||||
if (kbnServer.status.isGreen()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue