Skip to content

Commit a0c17df

Browse files
authoredJun 18, 2020
Merge pull request transitive-bullshit#253 from psyycker/master
2 parents a60f457 + cbe54de commit a0c17df

24 files changed

+396
-4
lines changed
 

‎lib/cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ module.exports = async () => {
2929
defaults.manager
3030
)
3131
.option(
32-
'-t, --template <default|typescript>',
32+
'-t, --template <default|typescript|flow>',
3333
'package template to use',
34-
/^(default|typescript|custom)$/,
34+
/^(default|typescript|flow|custom)$/,
3535
defaults.template
3636
)
3737
.option('-p, --template-path <string>', 'custom package template path')

‎lib/prompt-library-params.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module.exports = async (opts) => {
7373
type: 'list',
7474
name: 'template',
7575
message: 'Template',
76-
choices: ['default', 'typescript', 'custom'],
76+
choices: ['default', 'typescript', 'flow', 'custom'],
7777
default: opts.template
7878
},
7979
{

‎package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎template/flow/.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

‎template/flow/.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build/
2+
dist/
3+
node_modules/
4+
.snapshots/
5+
*.min.js

‎template/flow/.eslintrc

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": [
4+
"standard",
5+
"standard-react",
6+
"plugin:prettier/recommended",
7+
"prettier/standard",
8+
"prettier/react",
9+
"flowtype"
10+
],
11+
"env": {
12+
"node": true
13+
},
14+
"parserOptions": {
15+
"ecmaVersion": 2020,
16+
"ecmaFeatures": {
17+
"legacyDecorators": true,
18+
"jsx": true
19+
}
20+
},
21+
"settings": {
22+
"react": {
23+
"version": "16"
24+
}
25+
},
26+
"rules": {
27+
"space-before-function-paren": 0,
28+
"react/prop-types": 0,
29+
"react/jsx-handler-names": 0,
30+
"react/jsx-fragments": 0,
31+
"react/no-unused-prop-types": 0,
32+
"import/export": 0,
33+
"flowtype/boolean-style": [
34+
2,
35+
"boolean"
36+
],
37+
"flowtype/define-flow-type": 1,
38+
"flowtype/delimiter-dangle": [
39+
2,
40+
"never"
41+
],
42+
"flowtype/generic-spacing": [
43+
2,
44+
"never"
45+
],
46+
"flowtype/no-mixed": 2,
47+
"flowtype/no-primitive-constructor-types": 2,
48+
"flowtype/no-types-missing-file-annotation": 2,
49+
"flowtype/no-weak-types": 2,
50+
"flowtype/object-type-delimiter": [
51+
2,
52+
"comma"
53+
],
54+
"flowtype/require-parameter-type": 2,
55+
"flowtype/require-readonly-react-props": 0,
56+
"flowtype/require-return-type": [
57+
2,
58+
"always",
59+
{
60+
"annotateUndefined": "never"
61+
}
62+
],
63+
"flowtype/require-valid-file-annotation": 2,
64+
"flowtype/semi": [
65+
2,
66+
"always"
67+
],
68+
"flowtype/space-after-type-colon": [
69+
2,
70+
"always"
71+
],
72+
"flowtype/space-before-generic-bracket": [
73+
2,
74+
"never"
75+
],
76+
"flowtype/space-before-type-colon": [
77+
2,
78+
"never"
79+
],
80+
"flowtype/type-id-match": [
81+
2,
82+
"^([A-Z][a-z0-9]+)+Type$"
83+
],
84+
"flowtype/union-intersection-spacing": [
85+
2,
86+
"always"
87+
],
88+
"flowtype/use-flow-type": 1,
89+
"flowtype/valid-syntax": 1
90+
}
91+
}

‎template/flow/.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
6+
# builds
7+
build
8+
dist
9+
10+
# misc
11+
.DS_Store
12+
.env
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

‎template/flow/.prettierrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"singleQuote": true,
3+
"jsxSingleQuote": true,
4+
"semi": false,
5+
"tabWidth": 2,
6+
"bracketSpacing": true,
7+
"jsxBracketSameLine": false,
8+
"arrowParens": "always",
9+
"trailingComma": "none"
10+
}

‎template/flow/.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- 12
4+
- 10

‎template/flow/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# {{name}}
2+
3+
> {{description}}
4+
5+
[![NPM](https://img.shields.io/npm/v/{{name}}.svg)](https://www.npmjs.com/package/{{name}}) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
6+
7+
## Install
8+
9+
```bash
10+
npm install --save {{name}}
11+
```
12+
13+
## Usage
14+
15+
```jsx
16+
import React, { Component } from 'react'
17+
18+
import MyComponent from '{{name}}'
19+
import '{{name}}/dist/index.css'
20+
21+
class Example extends Component {
22+
render() {
23+
return <MyComponent />
24+
}
25+
}
26+
```
27+
28+
## License
29+
30+
{{license}} © [{{author}}](https://github.com/{{author}})

‎template/flow/example/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This example was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
It is linked to the {{name}} package in the parent directory for development purposes.
4+
5+
You can run `{{manager}} install` and then `{{manager}} start` to test your package.

‎template/flow/example/package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "{{name}}-example",
3+
"homepage": ".",
4+
"version": "0.0.0",
5+
"private": true,
6+
"scripts": {
7+
"start": "node ../node_modules/react-scripts/bin/react-scripts.js start",
8+
"build": "node ../node_modules/react-scripts/bin/react-scripts.js build",
9+
"test": "node ../node_modules/react-scripts/bin/react-scripts.js test",
10+
"eject": "node ../node_modules/react-scripts/bin/react-scripts.js eject"
11+
},
12+
"dependencies": {
13+
"react": "{{#if yarn}}link:..{{else}}file:..{{/if}}/node_modules/react",
14+
"react-dom": "{{#if yarn}}link:..{{else}}file:..{{/if}}/node_modules/react-dom",
15+
"react-scripts": "{{#if yarn}}link:..{{else}}file:..{{/if}}/node_modules/react-scripts",
16+
"{{name}}": "{{#if yarn}}link:..{{else}}file:..{{/if}}"
17+
},
18+
"devDependencies": {
19+
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
20+
},
21+
"eslintConfig": {
22+
"extends": "react-app"
23+
},
24+
"browserslist": [
25+
">0.2%",
26+
"not dead",
27+
"not ie <= 11",
28+
"not op_mini all"
29+
]
30+
}
3.78 KB
Binary file not shown.
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
9+
/>
10+
<meta name="theme-color" content="#000000" />
11+
12+
<!--
13+
manifest.json provides metadata used when your web app is added to the
14+
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
15+
-->
16+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
17+
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>{{name}}</title>
28+
</head>
29+
30+
<body>
31+
<noscript>
32+
You need to enable JavaScript to run this app.
33+
</noscript>
34+
35+
<div id="root"></div>
36+
37+
<!--
38+
This HTML file is a template.
39+
If you open it directly in the browser, you will see an empty page.
40+
41+
You can add webfonts, meta tags, or analytics to this file.
42+
The build step will place the bundled scripts into the <body> tag.
43+
44+
To begin the development, run `npm start` or `yarn start`.
45+
To create a production bundle, use `npm run build` or `yarn build`.
46+
-->
47+
</body>
48+
</html>
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "{{name}}",
3+
"name": "{{name}}",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
}
10+
],
11+
"start_url": ".",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}

‎template/flow/example/src/App.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
3+
import { ExampleComponent } from '{{name}}'
4+
import '{{name}}/dist/index.css'
5+
6+
const App = () => {
7+
return <ExampleComponent text="Create React Library Example 😄" />
8+
}
9+
10+
export default App

‎template/flow/example/src/App.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import App from './App'
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div')
7+
ReactDOM.render(<App />, div)
8+
ReactDOM.unmountComponentAtNode(div)
9+
})

‎template/flow/example/src/index.css

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
body {
2+
margin: 0;
3+
padding: 0;
4+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
5+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
6+
sans-serif;
7+
-webkit-font-smoothing: antialiased;
8+
-moz-osx-font-smoothing: grayscale;
9+
}
10+
11+
code {
12+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
13+
monospace;
14+
}

‎template/flow/example/src/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import './index.css'
2+
3+
import React from 'react'
4+
import ReactDOM from 'react-dom'
5+
import App from './App'
6+
7+
ReactDOM.render(<App />, document.getElementById('root'))

‎template/flow/package.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "{{name}}",
3+
"version": "1.0.0",
4+
"description": "{{description}}",
5+
"author": "{{author}}",
6+
"license": "{{license}}",
7+
"repository": "{{repo}}",
8+
"main": "dist/index.js",
9+
"module": "dist/index.modern.js",
10+
"source": "src/index.js",
11+
"engines": {
12+
"node": ">=10"
13+
},
14+
"scripts": {
15+
"build": "microbundle-crl --no-compress --format modern,cjs",
16+
"start": "microbundle-crl watch --no-compress --format modern,cjs",
17+
"prepare": "run-s build",
18+
"test": "run-s test:unit test:lint test:build",
19+
"test:build": "run-s build",
20+
"test:lint": "eslint .",
21+
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
22+
"test:watch": "react-scripts test --env=jsdom",
23+
"predeploy": "cd example && {{manager}} install && {{manager}} run build",
24+
"deploy": "gh-pages -d example/build"
25+
},
26+
"peerDependencies": {
27+
"react": "^16.0.0"
28+
},
29+
"devDependencies": {
30+
"microbundle-crl": "^0.13.10",
31+
"babel-eslint": "^10.0.3",
32+
"cross-env": "^7.0.2",
33+
"eslint": "^6.8.0",
34+
"eslint-config-prettier": "^6.7.0",
35+
"eslint-config-standard": "^14.1.0",
36+
"eslint-config-standard-react": "^9.2.0",
37+
"eslint-plugin-import": "^2.18.2",
38+
"eslint-plugin-node": "^11.0.0",
39+
"eslint-plugin-prettier": "^3.1.1",
40+
"eslint-plugin-promise": "^4.2.1",
41+
"eslint-plugin-react": "^7.17.0",
42+
"eslint-plugin-standard": "^4.0.1",
43+
"gh-pages": "^2.2.0",
44+
"npm-run-all": "^4.1.5",
45+
"prettier": "^2.0.4",
46+
"react": "^16.13.1",
47+
"react-dom": "^16.13.1",
48+
"react-scripts": "^3.4.1",
49+
"@babel/preset-flow": "^7.10.1",
50+
"eslint-plugin-flowtype": "^5.1.3"
51+
},
52+
"files": [
53+
"dist"
54+
]
55+
}

‎template/flow/src/.eslintrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"jest": true
4+
}
5+
}

‎template/flow/src/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// @flow
2+
3+
import React from 'react'
4+
import type { Element } from 'react'
5+
import styles from './styles.module.css'
6+
7+
export const ExampleComponent = ({ text }): Element => {
8+
return <div className={styles.test}>Example Component: {text}</div>
9+
}

‎template/flow/src/index.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { ExampleComponent } from '.'
2+
3+
describe('ExampleComponent', () => {
4+
it('is truthy', () => {
5+
expect(ExampleComponent).toBeTruthy()
6+
})
7+
})

‎template/flow/src/styles.module.css

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* add css module styles here (optional) */
2+
3+
.test {
4+
margin: 2em;
5+
padding: 0.5em;
6+
border: 2px solid #000;
7+
font-size: 2em;
8+
text-align: center;
9+
}

0 commit comments

Comments
 (0)
Please sign in to comment.