Skip to content

Commit

Permalink
chore(generator): update generator to support typescript files (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored and dlabaj committed Jan 14, 2019
1 parent 75b6709 commit 080658f
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 34 deletions.
33 changes: 28 additions & 5 deletions scripts/generators/patternfly-4-component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,40 @@ function setPF4Generators(plop) {
};
return [
{
base,
data,
type: 'addMany',
destination: join(reactCoreRoot, './src/{{typeDir}}/{{componentName}}/'),
templateFiles: join(base, '**/*.js')
type: 'add',
templateFile: join(base, 'component.tsx.hbs'),
path: join(reactCoreRoot, './src/{{typeDir}}/{{componentName}}/{{componentName}}.tsx')
},
{
data,
type: 'add',
templateFile: join(base, 'component.test.tsx.hbs'),
path: join(reactCoreRoot, './src/{{typeDir}}/{{componentName}}/{{componentName}}.test.tsx')
},
{
data,
type: 'add',
templateFile: join(base, 'component.docs.js.hbs'),
path: join(reactCoreRoot, './src/{{typeDir}}/{{componentName}}/{{componentName}}.docs.js')
},
{
data,
type: 'add',
templateFile: join(base, 'index.ts.hbs'),
path: join(reactCoreRoot, './src/{{typeDir}}/{{componentName}}/index.ts')
},
{
data,
type: 'add',
templateFile: join(base, 'example.js.hbs'),
path: join(reactCoreRoot, './src/{{typeDir}}/{{componentName}}/example/Simple{{componentName}}.ts')
},
{
data,
type: ADD_TO_BARREL_FILE,
template: `export * from './{{componentName}}';`,
path: join(reactCoreRoot, './src/{{typeDir}}/index.js')
path: join(reactCoreRoot, './src/{{typeDir}}/index.ts')
}
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { DetailedHTMLProps } from 'react';
import styles from '@patternfly/patternfly-next/{{typeDir}}/{{componentName}}/styles.css';
import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';

const defaultProps = {
children: null,
className: ''
};

interface {{ componentName }}Props {
children?: any;
className?: string;
}

const {{componentName}}: React.SFC<{{componentName}}Props> = (props) => (
<div {...props} className={css(styles.{{ camelCase componentName }}, props.className)}>
{props.children}
</div>
);

{{ componentName }}.defaultProps = defaultProps;

export default {{ componentName }};

This file was deleted.

15 changes: 11 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@
"compilerOptions": {
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": ["es6", "dom"],
"lib": [
"es6",
"dom"
],
"module": "es2015",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": false,
"target": "esnext",
"allowJs": true,
"paths": {
"*": ["./packages/patternfly-4/react-core/dist/esm/*"]
"*": [
"./packages/patternfly-4/react-core/dist/esm/*"
]
}
},
"include": ["packages/**/src/**/*"]
"include": [
"packages/**/src/**/*"
]
}

0 comments on commit 080658f

Please sign in to comment.