Skip to content

Commit

Permalink
Merge branch 'master' into alexwizp-reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Feb 3, 2020
2 parents 54a27af + 4aa7275 commit c9318ff
Show file tree
Hide file tree
Showing 296 changed files with 6,130 additions and 2,462 deletions.
23 changes: 14 additions & 9 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
/src/plugins/dev_tools/ @elastic/kibana-app

# App Architecture
/src/plugins/data/ @elastic/kibana-app-arch
/src/plugins/embeddable/ @elastic/kibana-app-arch
/src/plugins/expressions/ @elastic/kibana-app-arch
/src/plugins/kibana_react/ @elastic/kibana-app-arch
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
/src/plugins/navigation/ @elastic/kibana-app-arch
/src/plugins/ui_actions/ @elastic/kibana-app-arch
/src/plugins/visualizations/ @elastic/kibana-app-arch
/x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch
/packages/kbn-interpreter/ @elastic/kibana-app-arch
/src/legacy/core_plugins/data/ @elastic/kibana-app-arch
/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js @elastic/kibana-app-arch
/src/legacy/core_plugins/embeddable_api/ @elastic/kibana-app-arch
Expand All @@ -48,6 +40,19 @@
/src/legacy/core_plugins/kibana/server/routes/api/suggestions/ @elastic/kibana-app-arch
/src/legacy/core_plugins/visualizations/ @elastic/kibana-app-arch
/src/legacy/server/index_patterns/ @elastic/kibana-app-arch
/src/plugins/bfetch/ @elastic/kibana-app-arch
/src/plugins/dashboard_embeddable_container/ @elastic/kibana-app-arch
/src/plugins/data/ @elastic/kibana-app-arch
/src/plugins/embeddable/ @elastic/kibana-app-arch
/src/plugins/expressions/ @elastic/kibana-app-arch
/src/plugins/inspector/ @elastic/kibana-app-arch
/src/plugins/kibana_react/ @elastic/kibana-app-arch
/src/plugins/kibana_utils/ @elastic/kibana-app-arch
/src/plugins/management/ @elastic/kibana-app-arch
/src/plugins/navigation/ @elastic/kibana-app-arch
/src/plugins/ui_actions/ @elastic/kibana-app-arch
/src/plugins/visualizations/ @elastic/kibana-app-arch
/x-pack/plugins/advanced_ui_actions/ @elastic/kibana-app-arch

# APM
/x-pack/legacy/plugins/apm/ @elastic/apm-ui
Expand Down
16 changes: 12 additions & 4 deletions packages/kbn-plugin-generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ exports.run = function run(argv) {
const options = getopts(argv, {
alias: {
h: 'help',
i: 'internal',
},
});

Expand All @@ -40,24 +41,31 @@ exports.run = function run(argv) {
if (options.help) {
console.log(
dedent(chalk`
{dim usage:} node scripts/generate-plugin {bold [name]}
generate a fresh Kibana plugin in the plugins/ directory
# {dim Usage:}
node scripts/generate-plugin {bold [name]}
Generate a fresh Kibana plugin in the plugins/ directory
# {dim Core Kibana plugins:}
node scripts/generate-plugin {bold [name]} -i
To generate a core Kibana plugin inside the src/plugins/ directory, add the -i flag.
`) + '\n'
);
process.exit(1);
}

const name = options._[0];
const isKibanaPlugin = options.internal;
const template = resolve(__dirname, './sao_template');
const kibanaPlugins = resolve(__dirname, '../../plugins');
const kibanaPlugins = resolve(__dirname, isKibanaPlugin ? '../../src/plugins' : '../../plugins');
const targetPath = resolve(kibanaPlugins, snakeCase(name));

sao({
template: template,
targetPath: targetPath,
configOptions: {
name,
isKibanaPlugin,
targetPath,
},
}).catch(error => {
console.error(chalk`{red fatal error}!`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/

export { EsArchiver } from './es_archiver';
interface PluginGenerator {
/**
* Run plugin generator.
*/
run: (...args: any[]) => any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ describe(`running the plugin-generator via 'node scripts/generate_plugin.js plug
expect(stats.isDirectory()).toBe(true);
});

it(`should create an internationalization config file with a blank line appended to satisfy the parser`, async () => {
// skipped until internationalization is re-introduced
it.skip(`should create an internationalization config file with a blank line appended to satisfy the parser`, async () => {
// Link to the error that happens when the blank line is not there:
// https://github.com/elastic/kibana/pull/45044#issuecomment-530092627
const intlFile = `${generatedPath}/.i18nrc.json`;
Expand All @@ -78,16 +79,7 @@ describe(`running the plugin-generator via 'node scripts/generate_plugin.js plug
});
});

it(`'yarn test:server' should exit 0`, async () => {
await execa('yarn', ['test:server'], {
cwd: generatedPath,
env: {
DISABLE_JUNIT_REPORTER: '1',
},
});
});

it(`'yarn build' should exit 0`, async () => {
it.skip(`'yarn build' should exit 0`, async () => {
await execa('yarn', ['build'], { cwd: generatedPath });
});

Expand All @@ -109,7 +101,7 @@ describe(`running the plugin-generator via 'node scripts/generate_plugin.js plug
'--migrations.skip=true',
],
cwd: generatedPath,
wait: /ispec_plugin.+Status changed from uninitialized to green - Ready/,
wait: new RegExp('\\[ispecPlugin\\]\\[plugins\\] Setting up plugin'),
});
await proc.stop('kibana');
});
Expand All @@ -120,7 +112,7 @@ describe(`running the plugin-generator via 'node scripts/generate_plugin.js plug
await execa('yarn', ['preinstall'], { cwd: generatedPath });
});

it(`'yarn lint' should exit 0`, async () => {
it.skip(`'yarn lint' should exit 0`, async () => {
await execa('yarn', ['lint'], { cwd: generatedPath });
});

Expand Down
69 changes: 33 additions & 36 deletions packages/kbn-plugin-generator/sao_template/sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@
* under the License.
*/

const { resolve, relative, dirname } = require('path');
const { relative } = require('path');

const startCase = require('lodash.startcase');
const camelCase = require('lodash.camelcase');
const snakeCase = require('lodash.snakecase');
const execa = require('execa');
const chalk = require('chalk');
const execa = require('execa');

const pkg = require('../package.json');
const kibanaPkgPath = require.resolve('../../../package.json');
const kibanaPkg = require(kibanaPkgPath); // eslint-disable-line import/no-dynamic-require

const KBN_DIR = dirname(kibanaPkgPath);

module.exports = function({ name }) {
module.exports = function({ name, targetPath, isKibanaPlugin }) {
return {
prompts: {
description: {
Expand All @@ -47,41 +45,38 @@ module.exports = function({ name }) {
message: 'Should an app component be generated?',
default: true,
},
generateTranslations: {
type: 'confirm',
message: 'Should translation files be generated?',
default: true,
},
generateHack: {
type: 'confirm',
message: 'Should a hack component be generated?',
default: true,
},
generateApi: {
type: 'confirm',
message: 'Should a server API be generated?',
default: true,
},
// generateTranslations: {
// type: 'confirm',
// message: 'Should translation files be generated?',
// default: true,
// },
generateScss: {
type: 'confirm',
message: 'Should SCSS be used?',
when: answers => answers.generateApp,
default: true,
},
generateEslint: {
type: 'confirm',
message: 'Would you like to use a custom eslint file?',
default: !isKibanaPlugin,
},
},
filters: {
'public/**/index.scss': 'generateScss',
'public/**/*': 'generateApp',
'translations/**/*': 'generateTranslations',
'.i18nrc.json': 'generateTranslations',
'public/hack.js': 'generateHack',
'server/**/*': 'generateApi',
'public/app.scss': 'generateScss',
'.kibana-plugin-helpers.json': 'generateScss',
// 'translations/**/*': 'generateTranslations',
// '.i18nrc.json': 'generateTranslations',
'eslintrc.js': 'generateEslint',
},
move: {
gitignore: '.gitignore',
'eslintrc.js': '.eslintrc.js',
'package_template.json': 'package.json',
},
data: answers =>
Object.assign(
Expand All @@ -91,34 +86,36 @@ module.exports = function({ name }) {
camelCase,
snakeCase,
name,
isKibanaPlugin,
kbnVersion: answers.kbnVersion,
upperCamelCaseName: name.charAt(0).toUpperCase() + camelCase(name).slice(1),
hasUi: !!answers.generateApp,
hasServer: !!answers.generateApi,
hasScss: !!answers.generateScss,
relRoot: isKibanaPlugin ? '../../../..' : '../../..',
},
answers
),
enforceNewFolder: true,
installDependencies: false,
gitInit: true,
gitInit: !isKibanaPlugin,
async post({ log }) {
await execa('yarn', ['kbn', 'bootstrap'], {
cwd: KBN_DIR,
stdio: 'inherit',
});

const dir = relative(process.cwd(), resolve(KBN_DIR, 'plugins', snakeCase(name)));
const dir = relative(process.cwd(), targetPath);

// Apply eslint to the generated plugin
try {
await execa('yarn', ['lint', '--fix'], {
cwd: dir,
all: true,
});
await execa('yarn', ['lint:es', `./${dir}/**/*.ts*`, '--no-ignore', '--fix']);
} catch (error) {
throw new Error(`Failure when running prettier on the generated output: ${error.all}`);
console.error(error);
throw new Error(
`Failure when running prettier on the generated output: ${error.all || error}`
);
}

log.success(chalk`🎉
Your plugin has been created in {bold ${dir}}. Move into that directory to run it:
Your plugin has been created in {bold ${dir}}.
{bold cd "${dir}"}
{bold yarn start}
`);
},
Expand Down
Loading

0 comments on commit c9318ff

Please sign in to comment.