mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Remove yeoman & yo (#82825)
This commit is contained in:
parent
0e8985c3fb
commit
6b60599cba
19 changed files with 1425 additions and 3499 deletions
|
@ -851,8 +851,6 @@
|
|||
"xml-crypto": "^2.0.0",
|
||||
"xmlbuilder": "13.0.2",
|
||||
"yargs": "^15.4.1",
|
||||
"yeoman-generator": "1.1.1",
|
||||
"yo": "2.0.6",
|
||||
"zlib": "^1.0.5"
|
||||
}
|
||||
}
|
||||
|
|
2854
packages/kbn-pm/dist/index.js
vendored
2854
packages/kbn-pm/dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const Generator = require('yeoman-generator');
|
||||
|
||||
const componentGenerator = require.resolve('../component/index.js');
|
||||
|
||||
module.exports = class extends Generator {
|
||||
prompting() {
|
||||
return this.prompt([
|
||||
{
|
||||
message: 'What do you want to create?',
|
||||
name: 'fileType',
|
||||
type: 'list',
|
||||
choices: [
|
||||
{
|
||||
name: 'Stateless function',
|
||||
value: 'function',
|
||||
},
|
||||
{
|
||||
name: 'Component class',
|
||||
value: 'component',
|
||||
},
|
||||
],
|
||||
},
|
||||
]).then((answers) => {
|
||||
this.config = answers;
|
||||
});
|
||||
}
|
||||
|
||||
writing() {
|
||||
this.composeWith(componentGenerator, {
|
||||
fileType: this.config.fileType,
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const Generator = require('yeoman-generator');
|
||||
|
||||
const documentationGenerator = require.resolve('../documentation/index.js');
|
||||
|
||||
module.exports = class extends Generator {
|
||||
prompting() {
|
||||
return this.prompt([
|
||||
{
|
||||
message: 'What do you want to create?',
|
||||
name: 'fileType',
|
||||
type: 'list',
|
||||
choices: [
|
||||
{
|
||||
name: 'Page',
|
||||
value: 'documentation',
|
||||
},
|
||||
{
|
||||
name: 'Page demo',
|
||||
value: 'demo',
|
||||
},
|
||||
{
|
||||
name: 'Sandbox',
|
||||
value: 'sandbox',
|
||||
},
|
||||
],
|
||||
},
|
||||
]).then((answers) => {
|
||||
this.config = answers;
|
||||
});
|
||||
}
|
||||
|
||||
writing() {
|
||||
this.composeWith(documentationGenerator, {
|
||||
fileType: this.config.fileType,
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,156 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const chalk = require('chalk');
|
||||
const { resolve } = require('path');
|
||||
const Generator = require('yeoman-generator');
|
||||
const utils = require('../utils');
|
||||
|
||||
module.exports = class extends Generator {
|
||||
constructor(args, options) {
|
||||
super(args, options);
|
||||
|
||||
this.fileType = options.fileType;
|
||||
}
|
||||
|
||||
prompting() {
|
||||
return this.prompt([
|
||||
{
|
||||
message: "What's the name of this component? Use snake_case, please.",
|
||||
name: 'name',
|
||||
type: 'input',
|
||||
},
|
||||
{
|
||||
message: `Where do you want to create this component's files?`,
|
||||
type: 'input',
|
||||
name: 'path',
|
||||
default: resolve(__dirname, '../../src/components'),
|
||||
store: true,
|
||||
},
|
||||
{
|
||||
message: 'Does it need its own directory?',
|
||||
name: 'shouldMakeDirectory',
|
||||
type: 'confirm',
|
||||
default: true,
|
||||
},
|
||||
]).then((answers) => {
|
||||
this.config = answers;
|
||||
|
||||
if (!answers.name || !answers.name.trim()) {
|
||||
this.log.error('Sorry, please run this generator again and provide a component name.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
writing() {
|
||||
const config = this.config;
|
||||
|
||||
const writeComponent = (isStatelessFunction) => {
|
||||
const componentName = utils.makeComponentName(config.name);
|
||||
const cssClassName = utils.lowerCaseFirstLetter(componentName);
|
||||
const fileName = config.name;
|
||||
|
||||
const path = utils.addDirectoryToPath(config.path, fileName, config.shouldMakeDirectory);
|
||||
|
||||
const vars = (config.vars = {
|
||||
componentName,
|
||||
cssClassName,
|
||||
fileName,
|
||||
});
|
||||
|
||||
const componentPath = (config.componentPath = `${path}/${fileName}.js`);
|
||||
const testPath = (config.testPath = `${path}/${fileName}.test.js`);
|
||||
const stylesPath = (config.stylesPath = `${path}/_${fileName}.scss`);
|
||||
config.stylesImportPath = `./_${fileName}.scss`;
|
||||
|
||||
// If it needs its own directory then it will need a root index file too.
|
||||
if (this.config.shouldMakeDirectory) {
|
||||
this.fs.copyTpl(
|
||||
this.templatePath('_index.scss'),
|
||||
this.destinationPath(`${path}/_index.scss`),
|
||||
vars
|
||||
);
|
||||
|
||||
this.fs.copyTpl(
|
||||
this.templatePath('index.js'),
|
||||
this.destinationPath(`${path}/index.js`),
|
||||
vars
|
||||
);
|
||||
}
|
||||
|
||||
// Create component file.
|
||||
this.fs.copyTpl(
|
||||
isStatelessFunction
|
||||
? this.templatePath('stateless_function.js')
|
||||
: this.templatePath('component.js'),
|
||||
this.destinationPath(componentPath),
|
||||
vars
|
||||
);
|
||||
|
||||
// Create component test file.
|
||||
this.fs.copyTpl(this.templatePath('test.js'), this.destinationPath(testPath), vars);
|
||||
|
||||
// Create component styles file.
|
||||
this.fs.copyTpl(this.templatePath('_component.scss'), this.destinationPath(stylesPath), vars);
|
||||
};
|
||||
|
||||
switch (this.fileType) {
|
||||
case 'component':
|
||||
writeComponent();
|
||||
break;
|
||||
|
||||
case 'function':
|
||||
writeComponent(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
end() {
|
||||
const showImportComponentSnippet = () => {
|
||||
const componentName = this.config.vars.componentName;
|
||||
|
||||
this.log(chalk.white(`\n// Export component (e.. from component's index.js).`));
|
||||
this.log(
|
||||
`${chalk.magenta('export')} {\n` +
|
||||
` ${componentName},\n` +
|
||||
`} ${chalk.magenta('from')} ${chalk.cyan(`'./${this.config.name}'`)};`
|
||||
);
|
||||
|
||||
this.log(chalk.white('\n// Import styles.'));
|
||||
this.log(`${chalk.magenta('@import')} ${chalk.cyan(`'${this.config.name}'`)};`);
|
||||
|
||||
this.log(chalk.white('\n// Import component styles into the root index.scss.'));
|
||||
this.log(`${chalk.magenta('@import')} ${chalk.cyan(`'${this.config.name}/index'`)};`);
|
||||
};
|
||||
|
||||
this.log('------------------------------------------------');
|
||||
this.log(chalk.bold('Handy snippets:'));
|
||||
switch (this.fileType) {
|
||||
case 'component':
|
||||
showImportComponentSnippet();
|
||||
break;
|
||||
|
||||
case 'function':
|
||||
showImportComponentSnippet();
|
||||
break;
|
||||
}
|
||||
this.log('------------------------------------------------');
|
||||
}
|
||||
};
|
|
@ -1,3 +0,0 @@
|
|||
.<%= cssClassName %> {
|
||||
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
@import '<%= fileName %>';
|
|
@ -1,35 +0,0 @@
|
|||
import React, {
|
||||
Component,
|
||||
} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export class <%= componentName %> extends Component {
|
||||
static propTypes = {
|
||||
children: PropTypes.node,
|
||||
className: PropTypes.string,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
children,
|
||||
className,
|
||||
...rest
|
||||
} = this.props;
|
||||
|
||||
const classes = classNames('<%= cssClassName %>', className);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classes}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
export {
|
||||
<%= componentName %>,
|
||||
} from './<%= fileName %>';
|
|
@ -1,25 +0,0 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
|
||||
export const <%= componentName %> = ({
|
||||
children,
|
||||
className,
|
||||
...rest
|
||||
}) => {
|
||||
const classes = classNames('<%= cssClassName %>', className);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classes}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
<%= componentName %>.propTypes = {
|
||||
children: PropTypes.node,
|
||||
className: PropTypes.string,
|
||||
};
|
|
@ -1,16 +0,0 @@
|
|||
import React from 'react';
|
||||
import { render } from 'enzyme';
|
||||
import { requiredProps } from '../../test/required_props';
|
||||
|
||||
import { <%= componentName %> } from './<%= fileName %>';
|
||||
|
||||
describe('<%= componentName %>', () => {
|
||||
test('is rendered', () => {
|
||||
const component = render(
|
||||
<<%= componentName %> {...requiredProps} />
|
||||
);
|
||||
|
||||
expect(component)
|
||||
.toMatchSnapshot();
|
||||
});
|
||||
});
|
|
@ -1,238 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const chalk = require('chalk');
|
||||
const { resolve } = require('path');
|
||||
const Generator = require('yeoman-generator');
|
||||
const utils = require('../utils');
|
||||
|
||||
const DOCUMENTATION_PAGE_PATH = resolve(__dirname, '../../doc_site/src/views');
|
||||
|
||||
module.exports = class extends Generator {
|
||||
constructor(args, options) {
|
||||
super(args, options);
|
||||
|
||||
this.fileType = options.fileType;
|
||||
}
|
||||
|
||||
prompting() {
|
||||
const prompts = [
|
||||
{
|
||||
message: "What's the name of the component you're documenting? Use snake_case, please.",
|
||||
name: 'name',
|
||||
type: 'input',
|
||||
store: true,
|
||||
},
|
||||
];
|
||||
|
||||
if (this.fileType === 'demo') {
|
||||
prompts.push({
|
||||
message: `What's the name of the directory this demo should go in? (Within ${DOCUMENTATION_PAGE_PATH}). Use snake_case, please.`,
|
||||
name: 'folderName',
|
||||
type: 'input',
|
||||
store: true,
|
||||
default: (answers) => answers.name,
|
||||
});
|
||||
|
||||
prompts.push({
|
||||
message: 'What would you like to name this demo? Use snake_case, please.',
|
||||
name: 'demoName',
|
||||
type: 'input',
|
||||
store: true,
|
||||
});
|
||||
}
|
||||
|
||||
return this.prompt(prompts).then((answers) => {
|
||||
this.config = answers;
|
||||
});
|
||||
}
|
||||
|
||||
writing() {
|
||||
const config = this.config;
|
||||
|
||||
const writeDocumentationPage = () => {
|
||||
const componentExampleName = utils.makeComponentName(config.name, false);
|
||||
const componentExamplePrefix = utils.lowerCaseFirstLetter(componentExampleName);
|
||||
const fileName = config.name;
|
||||
|
||||
const path = DOCUMENTATION_PAGE_PATH;
|
||||
|
||||
const vars = (config.documentationVars = {
|
||||
componentExampleName,
|
||||
componentExamplePrefix,
|
||||
fileName,
|
||||
});
|
||||
|
||||
const documentationPagePath = (config.documentationPagePath = `${path}/${config.name}/${config.name}_example.js`);
|
||||
|
||||
this.fs.copyTpl(
|
||||
this.templatePath('documentation_page.js'),
|
||||
this.destinationPath(documentationPagePath),
|
||||
vars
|
||||
);
|
||||
};
|
||||
|
||||
const writeDocumentationPageDemo = (fileName, folderName) => {
|
||||
const componentExampleName = utils.makeComponentName(fileName, false);
|
||||
const componentExamplePrefix = utils.lowerCaseFirstLetter(componentExampleName);
|
||||
const componentName = utils.makeComponentName(config.name);
|
||||
|
||||
const path = DOCUMENTATION_PAGE_PATH;
|
||||
|
||||
const vars = (config.documentationVars = {
|
||||
componentExampleName,
|
||||
componentExamplePrefix,
|
||||
componentName,
|
||||
fileName,
|
||||
});
|
||||
|
||||
const documentationPageDemoPath = (config.documentationPageDemoPath = `${path}/${folderName}/${fileName}.js`);
|
||||
|
||||
this.fs.copyTpl(
|
||||
this.templatePath('documentation_page_demo.js'),
|
||||
this.destinationPath(documentationPageDemoPath),
|
||||
vars
|
||||
);
|
||||
};
|
||||
|
||||
const writeSandbox = () => {
|
||||
const fileName = config.name;
|
||||
const componentExampleName = utils.makeComponentName(fileName, false);
|
||||
|
||||
const path = DOCUMENTATION_PAGE_PATH;
|
||||
|
||||
const vars = (config.documentationVars = {
|
||||
componentExampleName,
|
||||
fileName,
|
||||
});
|
||||
|
||||
const sandboxPath = (config.documentationPageDemoPath = `${path}/${config.name}/${fileName}`);
|
||||
|
||||
this.fs.copyTpl(
|
||||
this.templatePath('documentation_sandbox.html'),
|
||||
this.destinationPath(`${sandboxPath}_sandbox.html`)
|
||||
);
|
||||
|
||||
this.fs.copyTpl(
|
||||
this.templatePath('documentation_sandbox.js'),
|
||||
this.destinationPath(`${sandboxPath}_sandbox.js`),
|
||||
vars
|
||||
);
|
||||
};
|
||||
|
||||
switch (this.fileType) {
|
||||
case 'documentation':
|
||||
writeDocumentationPage();
|
||||
writeDocumentationPageDemo(config.name, config.name);
|
||||
break;
|
||||
|
||||
case 'demo':
|
||||
writeDocumentationPageDemo(config.demoName, config.folderName);
|
||||
break;
|
||||
|
||||
case 'sandbox':
|
||||
writeSandbox();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
end() {
|
||||
const showImportDemoSnippet = () => {
|
||||
const {
|
||||
componentExampleName,
|
||||
componentExamplePrefix,
|
||||
fileName,
|
||||
} = this.config.documentationVars;
|
||||
|
||||
this.log(chalk.white('\n// Import demo into example.'));
|
||||
this.log(
|
||||
`${chalk.magenta('import')} ${componentExampleName} from ${chalk.cyan(
|
||||
`'./${fileName}'`
|
||||
)};\n` +
|
||||
`${chalk.magenta('const')} ${componentExamplePrefix}Source = require(${chalk.cyan(
|
||||
`'!!raw-loader!./${fileName}'`
|
||||
)});\n` +
|
||||
`${chalk.magenta(
|
||||
'const'
|
||||
)} ${componentExamplePrefix}Html = renderToHtml(${componentExampleName});`
|
||||
);
|
||||
|
||||
this.log(chalk.white('\n// Render demo.'));
|
||||
this.log(
|
||||
`<GuideSection\n` +
|
||||
` title="${componentExampleName}"\n` +
|
||||
` source={[{\n` +
|
||||
` type: GuideSectionTypes.JS,\n` +
|
||||
` code: ${componentExamplePrefix}Source,\n` +
|
||||
` }, {\n` +
|
||||
` type: GuideSectionTypes.HTML,\n` +
|
||||
` code: ${componentExamplePrefix}Html,\n` +
|
||||
` }]}\n` +
|
||||
`>\n` +
|
||||
` <GuideText>\n` +
|
||||
` Description needed: how to use the ${componentExampleName} component.\n` +
|
||||
` </GuideText>\n` +
|
||||
`\n` +
|
||||
` <GuideDemo>\n` +
|
||||
` <${componentExampleName} />\n` +
|
||||
` </GuideDemo>\n` +
|
||||
`</GuideSection>\n`
|
||||
);
|
||||
};
|
||||
|
||||
const showImportRouteSnippet = (suffix, appendToRoute) => {
|
||||
const { componentExampleName, fileName } = this.config.documentationVars;
|
||||
|
||||
this.log(chalk.white('\n// Import example into routes.js.'));
|
||||
this.log(
|
||||
`${chalk.magenta('import')} ${componentExampleName}${suffix}\n` +
|
||||
` ${chalk.magenta('from')} ${chalk.cyan(
|
||||
`'../../views/${fileName}/${fileName}_${suffix.toLowerCase()}'`
|
||||
)};`
|
||||
);
|
||||
|
||||
this.log(chalk.white('\n// Import route definition into routes.js.'));
|
||||
this.log(
|
||||
`{\n` +
|
||||
` name: ${chalk.cyan(`'${componentExampleName}${appendToRoute ? suffix : ''}'`)},\n` +
|
||||
` component: ${componentExampleName}${suffix},\n` +
|
||||
` hasReact: ${chalk.magenta('true')},\n` +
|
||||
`}`
|
||||
);
|
||||
};
|
||||
|
||||
this.log('------------------------------------------------');
|
||||
this.log(chalk.bold('Import snippets:'));
|
||||
|
||||
switch (this.fileType) {
|
||||
case 'documentation':
|
||||
showImportRouteSnippet('Example');
|
||||
break;
|
||||
|
||||
case 'demo':
|
||||
showImportDemoSnippet();
|
||||
break;
|
||||
|
||||
case 'sandbox':
|
||||
showImportRouteSnippet('Sandbox', true);
|
||||
break;
|
||||
}
|
||||
this.log('------------------------------------------------');
|
||||
}
|
||||
};
|
|
@ -1,41 +0,0 @@
|
|||
/* eslint-disable import/no-duplicates */
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { renderToHtml } from '../../services';
|
||||
|
||||
import {
|
||||
GuideCode,
|
||||
GuideDemo,
|
||||
GuidePage,
|
||||
GuideSection,
|
||||
GuideSectionTypes,
|
||||
GuideText,
|
||||
} from '../../components';
|
||||
|
||||
import <%= componentExampleName %> from './<%= fileName %>';
|
||||
import <%= componentExamplePrefix %>Source from '!!raw-loader!./<%= fileName %>'; // eslint-disable-line import/default
|
||||
const <%= componentExamplePrefix %>Html = renderToHtml(<%= componentExampleName %>);
|
||||
|
||||
export default props => (
|
||||
<GuidePage title={props.route.name}>
|
||||
<GuideSection
|
||||
title="<%= componentExampleName %>"
|
||||
source={[{
|
||||
type: GuideSectionTypes.JS,
|
||||
code: <%= componentExamplePrefix %>Source,
|
||||
}, {
|
||||
type: GuideSectionTypes.HTML,
|
||||
code: <%= componentExamplePrefix %>Html,
|
||||
}]}
|
||||
>
|
||||
<GuideText>
|
||||
Description needed: how to use the <GuideCode><%= componentExampleName %></GuideCode> component.
|
||||
</GuideText>
|
||||
|
||||
<GuideDemo>
|
||||
<<%= componentExampleName %> />
|
||||
</GuideDemo>
|
||||
</GuideSection>
|
||||
</GuidePage>
|
||||
);
|
|
@ -1,11 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
import {
|
||||
<%= componentName %>,
|
||||
} from '../../../../components';
|
||||
|
||||
export default () => (
|
||||
<<%= componentName %>>
|
||||
|
||||
</<%= componentName %>>
|
||||
);
|
|
@ -1 +0,0 @@
|
|||
<p>Do whatever you want here!</p>
|
|
@ -1,27 +0,0 @@
|
|||
import React from 'react';
|
||||
|
||||
import {
|
||||
GuideDemo,
|
||||
GuideSandbox,
|
||||
GuideSandboxCodeToggle,
|
||||
GuideSectionTypes,
|
||||
} from '../../components';
|
||||
|
||||
import html from './<%= fileName %>_sandbox.html';
|
||||
|
||||
export default props => (
|
||||
<GuideSandbox>
|
||||
<GuideDemo
|
||||
isFullScreen={true}
|
||||
html={html}
|
||||
/>
|
||||
|
||||
<GuideSandboxCodeToggle
|
||||
source={[{
|
||||
type: GuideSectionTypes.HTML,
|
||||
code: html,
|
||||
}]}
|
||||
title={props.route.name}
|
||||
/>
|
||||
</GuideSandbox>
|
||||
);
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function makeComponentName(str, usePrefix = true) {
|
||||
const words = str.split('_');
|
||||
|
||||
const componentName = words
|
||||
.map(function (word) {
|
||||
return upperCaseFirstLetter(word);
|
||||
})
|
||||
.join('');
|
||||
|
||||
return `${usePrefix ? 'Kui' : ''}${componentName}`;
|
||||
}
|
||||
|
||||
function lowerCaseFirstLetter(str) {
|
||||
return str.replace(/\w\S*/g, function (txt) {
|
||||
return txt.charAt(0).toLowerCase() + txt.substr(1);
|
||||
});
|
||||
}
|
||||
|
||||
function upperCaseFirstLetter(str) {
|
||||
return str.replace(/\w\S*/g, function (txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1);
|
||||
});
|
||||
}
|
||||
|
||||
function addDirectoryToPath(path, dirName, shouldMakeDirectory) {
|
||||
if (shouldMakeDirectory) {
|
||||
return path + '/' + dirName;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
makeComponentName: makeComponentName,
|
||||
lowerCaseFirstLetter: lowerCaseFirstLetter,
|
||||
upperCaseFirstLetter: upperCaseFirstLetter,
|
||||
addDirectoryToPath: addDirectoryToPath,
|
||||
};
|
|
@ -5,9 +5,7 @@
|
|||
"scripts": {
|
||||
"build": "../../node_modules/.bin/grunt prodBuild",
|
||||
"docSiteStart": "../../node_modules/.bin/grunt docSiteStart",
|
||||
"docSiteBuild": "../../node_modules/.bin/grunt docSiteBuild",
|
||||
"createComponent": "../../node_modules/.bin/yo ./generator-kui/app/component.js",
|
||||
"documentComponent": "../../node_modules/.bin/yo ./generator-kui/app/documentation.js"
|
||||
"docSiteBuild": "../../node_modules/.bin/grunt docSiteBuild"
|
||||
},
|
||||
"kibana": {
|
||||
"build": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue