Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[kbn-plugin-generator] Fix plugin naming inconsistency (elastic#20808)
Browse files Browse the repository at this point in the history
<!--
Thank you for your interest in and contributing to Kibana! There
are a few simple things to check before submitting your pull request
that can help with the review process. You should delete these items
from your submission, but they are here to help bring them to your
attention.

- Have you signed the [contributor license agreement](https://www.elastic.co/contributor-agreement)?
- Have you followed the [contributor guidelines](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md)?
- If submitting code, have you included unit tests that cover the changes?
- If submitting code, have you tested and built your code locally prior to submission with `yarn test && yarn build`?
- If submitting code, is your pull request against master? Unless there is a good reason otherwise, we prefer pull requests against master and will backport as needed.
-->
Make relevant generated files use snakeCase instead of kebabCase
Closes elastic#20524
  • Loading branch information
aaronoah authored and spalger committed Jul 17, 2018
1 parent 2747d5e commit ade26f9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions packages/kbn-plugin-generator/sao_template/sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

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

const kebabCase = require('lodash.kebabcase');
const startCase = require('lodash.startcase');
const camelCase = require('lodash.camelcase');
const snakeCase = require('lodash.snakecase');
Expand Down Expand Up @@ -86,9 +85,9 @@ module.exports = function({ name }) {
Object.assign(
{
templateVersion: pkg.version,
kebabCase,
startCase,
camelCase,
snakeCase,
name,
},
answers
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-plugin-generator/sao_template/sao.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ describe('plugin generator sao integration', () => {
const nameLine = indexContents.match('name: (.*)')[1];
const mainLine = indexContents.match('main: (.*)')[1];

expect(nameLine).toContain('some-fancy-plugin');
expect(mainLine).toContain('plugins/some-fancy-plugin/app');
expect(nameLine).toContain('some_fancy_plugin');
expect(mainLine).toContain('plugins/some_fancy_plugin/app');
});

it('plugin package has correct name', async () => {
Expand All @@ -142,7 +142,7 @@ describe('plugin generator sao integration', () => {
const packageContents = getFileContents(res.files['package.json']);
const pkg = JSON.parse(packageContents);

expect(pkg.name).toBe('some-fancy-plugin');
expect(pkg.name).toBe('some_fancy_plugin');
});

it('package has version "kibana" with master', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ extends: "@elastic/kibana"
settings:
import/resolver:
'@elastic/eslint-import-resolver-kibana':
rootPackageName: '<%= kebabCase(name) %>'
rootPackageName: '<%= snakeCase(name) %>'
6 changes: 3 additions & 3 deletions packages/kbn-plugin-generator/sao_template/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import exampleRoute from './server/routes/example';
export default function (kibana) {
return new kibana.Plugin({
require: ['elasticsearch'],
name: '<%= kebabCase(name) %>',
name: '<%= snakeCase(name) %>',
uiExports: {
<%_ if (generateApp) { -%>
app: {
title: '<%= startCase(name) %>',
description: '<%= description %>',
main: 'plugins/<%= kebabCase(name) %>/app',
main: 'plugins/<%= snakeCase(name) %>/app',
<%_ if (generateScss) { -%>
styleSheetPath: require('path').resolve(__dirname, 'public/app.scss'),
<%_ } -%>
},
<%_ } -%>
<%_ if (generateHack) { -%>
hacks: [
'plugins/<%= kebabCase(name) %>/hack'
'plugins/<%= snakeCase(name) %>/hack'
]
<%_ } -%>
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "<%= kebabCase(name) %>",
"name": "<%= snakeCase(name) %>",
"version": "0.0.0",
"description": "<%= description %>",
"main": "index.js",
Expand Down

0 comments on commit ade26f9

Please sign in to comment.