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

[bin/kibana-plugin] support KP plugins instead #74604

Merged
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@
"url-loader": "2.2.0",
"uuid": "3.3.2",
"val-loader": "^1.1.1",
"validate-npm-package-name": "2.2.2",
"vega": "^5.13.0",
"vega-lite": "^4.13.1",
"vega-schema-url-parser": "^1.1.0",
Expand Down
72 changes: 0 additions & 72 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _production__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(511);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _production__WEBPACK_IMPORTED_MODULE_1__["buildProductionProjects"]; });

/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _production__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; });

/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(145);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getProjects", function() { return _utils_projects__WEBPACK_IMPORTED_MODULE_2__["getProjects"]; });

Expand Down Expand Up @@ -59477,9 +59475,6 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _build_production_projects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(512);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "buildProductionProjects", function() { return _build_production_projects__WEBPACK_IMPORTED_MODULE_0__["buildProductionProjects"]; });

/* harmony import */ var _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(748);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _prepare_project_dependencies__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; });

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
Expand All @@ -59500,7 +59495,6 @@ __webpack_require__.r(__webpack_exports__);
*/



/***/ }),
/* 512 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
Expand Down Expand Up @@ -90331,71 +90325,5 @@ NestedError.prototype.name = 'NestedError';
module.exports = NestedError;


/***/ }),
/* 748 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return prepareExternalProjectDependencies; });
/* harmony import */ var _utils_package_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(164);
/* harmony import */ var _utils_project__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(163);
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
* All external projects are located within `./plugins/{plugin}` relative
* to the Kibana root directory or `../kibana-extra/{plugin}` relative
* to Kibana itself.
*/

const isKibanaDep = depVersion => // For ../kibana-extra/ directory (legacy only)
depVersion.includes('../../kibana/packages/') || // For plugins/ directory
depVersion.includes('../../packages/');
/**
* This prepares the dependencies for an _external_ project.
*/


async function prepareExternalProjectDependencies(projectPath) {
const project = await _utils_project__WEBPACK_IMPORTED_MODULE_1__["Project"].fromPath(projectPath);

if (!project.hasDependencies()) {
return;
}

const deps = project.allDependencies;

for (const depName of Object.keys(deps)) {
const depVersion = deps[depName]; // Kibana currently only supports `link:` dependencies on Kibana's own
// packages, as these are packaged into the `node_modules` folder when
// Kibana is built, so we don't need to take any action to enable
// `require(...)` to resolve for these packages.

if (Object(_utils_package_json__WEBPACK_IMPORTED_MODULE_0__["isLinkDependency"])(depVersion) && !isKibanaDep(depVersion)) {
// For non-Kibana packages we need to set up symlinks during the
// installation process, but this is not something we support yet.
throw new Error('This plugin is using `link:` dependencies for non-Kibana packages');
}
}
}

/***/ })
/******/ ]);
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

export { run } from './cli';
export { buildProductionProjects, prepareExternalProjectDependencies } from './production';
export { buildProductionProjects } from './production';
export { getProjects } from './utils/projects';
export { Project } from './utils/project';
export { copyWorkspacePackages } from './utils/workspaces';
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-pm/src/production/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
*/

export { buildProductionProjects } from './build_production_projects';
export { prepareExternalProjectDependencies } from './prepare_project_dependencies';

This file was deleted.

59 changes: 0 additions & 59 deletions packages/kbn-pm/src/production/prepare_project_dependencies.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/cli_keystore/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';
import { confirm, question } from '../legacy/server/utils';
import { createPromiseFromStreams, createConcatStream } from '../legacy/utils';

Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { PassThrough } from 'stream';

import { Keystore } from '../legacy/server/keystore';
import { add } from './add';
import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';
import * as prompt from '../legacy/server/utils/prompt';

describe('Kibana keystore', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';
import { confirm } from '../legacy/server/utils';

export async function create(keystore, command, options) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import sinon from 'sinon';

import { Keystore } from '../legacy/server/keystore';
import { create } from './create';
import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';
import * as prompt from '../legacy/server/utils/prompt';

describe('Kibana keystore', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/get_keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { existsSync } from 'fs';
import { join } from 'path';

import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';
import { getConfigDirectory, getDataPath } from '../core/server/path';

export function getKeystore() {
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/get_keystore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { getKeystore } from './get_keystore';
import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';
import fs from 'fs';
import sinon from 'sinon';

Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';

export function list(keystore, command, options = {}) {
const logger = new Logger(options);
Expand Down
2 changes: 1 addition & 1 deletion src/cli_keystore/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jest.mock('fs', () => ({
import sinon from 'sinon';
import { Keystore } from '../legacy/server/keystore';
import { list } from './list';
import Logger from '../cli_plugin/lib/logger';
import { Logger } from '../cli_plugin/lib/logger';

describe('Kibana keystore', () => {
describe('list', () => {
Expand Down
15 changes: 9 additions & 6 deletions src/cli_plugin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
* under the License.
*/

import _ from 'lodash';
import { pkg } from '../core/server/utils';
import Command from '../cli/command';
import listCommand from './list';
import installCommand from './install';
import removeCommand from './remove';
import { listCommand } from './list';
import { installCommand } from './install';
import { removeCommand } from './remove';

const argv = process.env.kbnWorkerArgv
? JSON.parse(process.env.kbnWorkerArgv)
Expand All @@ -44,8 +43,12 @@ program
.command('help <command>')
.description('get the help for a specific command')
.action(function (cmdName) {
const cmd = _.find(program.commands, { _name: cmdName });
if (!cmd) return program.error(`unknown command ${cmdName}`);
const cmd = program.commands.find((c) => c._name === cmdName);

if (!cmd) {
return program.error(`unknown command ${cmdName}`);
}

cmd.help();
});

Expand Down
Binary file modified src/cli_plugin/install/__fixtures__/replies/invalid_name.zip
Binary file not shown.

This file was deleted.

Binary file modified src/cli_plugin/install/__fixtures__/replies/test_plugin.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion src/cli_plugin/install/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ export function cleanArtifacts(settings) {
// At this point we're bailing, so swallow any errors on delete.
try {
del.sync(settings.workingPath);
del.sync(settings.plugins[0].path);
} catch (e) {} // eslint-disable-line no-empty
}
2 changes: 1 addition & 1 deletion src/cli_plugin/install/cleanup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import fs from 'fs';
import del from 'del';

import { cleanPrevious, cleanArtifacts } from './cleanup';
import Logger from '../lib/logger';
import { Logger } from '../lib/logger';

describe('kibana cli', function () {
describe('plugin installer', function () {
Expand Down
7 changes: 4 additions & 3 deletions src/cli_plugin/install/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* under the License.
*/

import downloadHttpFile from './downloaders/http';
import downloadLocalFile from './downloaders/file';
import { UnsupportedProtocolError } from '../lib/errors';
import { parse } from 'url';

import { UnsupportedProtocolError } from '../lib/errors';
import { downloadHttpFile } from './downloaders/http';
import { downloadLocalFile } from './downloaders/file';

function _isWindows() {
return /^win/.test(process.platform);
}
Expand Down
10 changes: 6 additions & 4 deletions src/cli_plugin/install/download.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
* under the License.
*/

import Fs from 'fs';
import { join } from 'path';
import http from 'http';

import sinon from 'sinon';
import nock from 'nock';
import glob from 'glob-all';
import del from 'del';
import Fs from 'fs';
import Logger from '../lib/logger';

import { Logger } from '../lib/logger';
import { UnsupportedProtocolError } from '../lib/errors';
import { download, _downloadSingle, _getFilePath, _checkFilePathDeprecation } from './download';
import { join } from 'path';
import http from 'http';

describe('kibana cli', function () {
describe('plugin downloader', function () {
Expand Down
Loading