-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Storybook template as well * Update README with info on running Storybook
- Loading branch information
1 parent
7c8481b
commit c487377
Showing
22 changed files
with
510 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Template } from './template'; | ||
|
||
const basicTemplate: Template = { | ||
name: 'basic', | ||
dependencies: ['@types/jest', 'husky', 'tsdx', 'tslib', 'typescript'], | ||
packageJson: { | ||
// name: safeName, | ||
version: '0.1.0', | ||
license: 'MIT', | ||
// author: author, | ||
main: 'dist/index.js', | ||
// module: `dist/${safeName}.esm.js`, | ||
typings: `dist/index.d.ts`, | ||
files: ['dist'], | ||
scripts: { | ||
start: 'tsdx watch', | ||
build: 'tsdx build', | ||
test: 'tsdx test', | ||
lint: 'tsdx lint', | ||
prepare: 'tsdx build', | ||
}, | ||
peerDependencies: {}, | ||
husky: { | ||
hooks: { | ||
'pre-commit': 'tsdx lint', | ||
}, | ||
}, | ||
prettier: { | ||
printWidth: 80, | ||
semi: true, | ||
singleQuote: true, | ||
trailingComma: 'es5', | ||
}, | ||
}, | ||
}; | ||
|
||
export default basicTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import reactTemplate from './react'; | ||
import basicTemplate from './basic'; | ||
import storybookTemplate from './react-with-storybook'; | ||
|
||
export const templates = { | ||
basic: basicTemplate, | ||
react: reactTemplate, | ||
'react-with-storybook': storybookTemplate, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Template } from './template'; | ||
import reactTemplate from './react'; | ||
import { PackageJson } from 'type-fest'; | ||
|
||
const storybookTemplate: Template = { | ||
dependencies: [ | ||
...reactTemplate.dependencies, | ||
'@babel/core', | ||
'@storybook/addon-actions', | ||
'@storybook/addon-links', | ||
'@storybook/addons', | ||
'@storybook/react', | ||
'babel-loader', | ||
'ts-loader', | ||
], | ||
name: 'react-with-storybook', | ||
packageJson: { | ||
...reactTemplate.packageJson, | ||
scripts: { | ||
...reactTemplate.packageJson.scripts, | ||
storybook: 'start-storybook -p 6006', | ||
'build-storybook': 'build-storybook', | ||
} as PackageJson['scripts'], | ||
}, | ||
}; | ||
|
||
export default storybookTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Template } from './template'; | ||
|
||
import basicTemplate from './basic'; | ||
import { PackageJson } from 'type-fest'; | ||
|
||
const reactTemplate: Template = { | ||
name: 'react', | ||
dependencies: [ | ||
...basicTemplate.dependencies, | ||
'@types/react', | ||
'@types/react-dom', | ||
'react', | ||
'react-dom', | ||
], | ||
packageJson: { | ||
...basicTemplate.packageJson, | ||
peerDependencies: { | ||
react: '>=16', | ||
}, | ||
scripts: { | ||
...basicTemplate.packageJson.scripts, | ||
test: 'tsdx test --env=jsdom --passWithNoTests', | ||
} as PackageJson['scripts'], | ||
}, | ||
}; | ||
|
||
export default reactTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PackageJson } from 'type-fest'; | ||
|
||
interface Template { | ||
dependencies: string[]; | ||
name: string; | ||
packageJson: PackageJson; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Template } from '../template'; | ||
|
||
interface ProjectArgs { | ||
name: string; | ||
author: string; | ||
} | ||
export const composePackageJson = (template: Template) => ({ | ||
name, | ||
author, | ||
}: ProjectArgs) => { | ||
return { | ||
...template.packageJson, | ||
name, | ||
author, | ||
module: `dist/${name}.esm.js`, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '@storybook/addon-actions/register'; | ||
import '@storybook/addon-links/register'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { configure } from '@storybook/react'; | ||
|
||
// automatically import all files ending in *.stories.js | ||
configure(require.context('../stories', true, /\.stories\.(js|ts)x?$/), module); |
17 changes: 17 additions & 0 deletions
17
templates/react-with-storybook/.storybook/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const path = require('path') | ||
module.exports = ({ config }) => { | ||
config.module.rules.push({ | ||
test: /\.tsx?$/, | ||
use: [ | ||
{ | ||
loader: require.resolve('ts-loader'), | ||
options: { | ||
reportFiles: ['stories/**/*.{ts|tsx}'] | ||
} | ||
} | ||
] | ||
}) | ||
config.resolve.extensions.push('.ts', '.tsx') | ||
config.resolve.alias = Object.assign(config.resolve.alias, { '@': path.resolve(__dirname, '..') }) | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) <year> <author> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.