Skip to content

Commit f630f36

Browse files
committed
Massive update, goodies, and Redux drop
1 parent 23a15d2 commit f630f36

34 files changed

+10034
-12841
lines changed

.babelrc

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
{
2-
"plugins": [
3-
"transform-runtime",
4-
"react-hot-loader/babel"
5-
],
6-
"presets": [["env", {"modules": false}]],
2+
"plugins": ["react-hot-loader/babel"],
3+
"presets": [["@babel/preset-env", {"modules": false}]],
74
"env": {
85
"production": {
9-
"plugins": ["transform-react-inline-elements"]
10-
},
11-
"test": {
12-
"presets": ["env"]
6+
"plugins": ["@babel/plugin-transform-react-inline-elements"]
137
}
148
}
159
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.gitignore

+39-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
/story/
44

55
# Created by https://www.gitignore.io/api/node
6+
# Edit at https://www.gitignore.io/?templates=node
67

78
### Node ###
89
# Logs
910
logs
1011
*.log
1112
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
1215

1316
# Runtime data
1417
pids
@@ -25,18 +28,24 @@ coverage
2528
# nyc test coverage
2629
.nyc_output
2730

28-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
31+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
2932
.grunt
3033

34+
# Bower dependency directory (https://bower.io/)
35+
bower_components
36+
3137
# node-waf configuration
3238
.lock-wscript
3339

34-
# Compiled binary addons (http://nodejs.org/api/addons.html)
40+
# Compiled binary addons (https://nodejs.org/api/addons.html)
3541
build/Release
3642

3743
# Dependency directories
38-
node_modules
39-
jspm_packages
44+
node_modules/
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
4049

4150
# Optional npm cache directory
4251
.npm
@@ -49,3 +58,29 @@ jspm_packages
4958

5059
# Output of 'npm pack'
5160
*.tgz
61+
62+
# Yarn Integrity file
63+
.yarn-integrity
64+
65+
# dotenv environment variables file
66+
.env
67+
68+
# parcel-bundler cache (https://parceljs.org/)
69+
.cache
70+
71+
# next.js build output
72+
.next
73+
74+
# nuxt.js build output
75+
.nuxt
76+
77+
# vuepress build output
78+
.vuepress/dist
79+
80+
# Serverless directories
81+
.serverless
82+
83+
# FuseBox cache
84+
.fusebox/
85+
86+
# End of https://www.gitignore.io/api/node

.huskyrc.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"pre-commit": "lint-staged"
2+
"hooks": {
3+
"pre-commit": "lint-staged"
4+
}
35
}

.jest/shims.ts

-4
This file was deleted.

.jestrc.json

+7-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11
{
22
"coverageDirectory": "<rootDir>/.coverage",
3-
"coveragePathIgnorePatterns": [
4-
"/node_modules/",
5-
"<rootDir>/common/store.ts",
6-
"<rootDir>/.jest/"
7-
],
83
"globals": {
94
"ts-jest": {
10-
"useBabelrc": true
5+
"babelConfig": {
6+
"plugins": ["dynamic-import-node"]
7+
},
8+
"tsConfig": "<rootDir>/tsconfig.node.json"
119
}
1210
},
13-
"moduleFileExtensions": [
14-
"js",
15-
"json",
16-
"jsx",
17-
"ts",
18-
"tsx"
19-
],
20-
"setupFiles": [
21-
"<rootDir>/.jest/shims.ts"
22-
],
23-
"setupTestFrameworkScriptFile": "<rootDir>/.jest/setup.ts",
11+
"preset": "ts-jest",
12+
"setupTestFrameworkScriptFile": "<rootDir>/jest/setup.ts",
2413
"snapshotSerializers": [
2514
"enzyme-to-json/serializer"
26-
],
27-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.tsx?$",
28-
"transform": {
29-
".tsx?": "<rootDir>/node_modules/ts-jest/preprocessor.js"
30-
}
15+
]
3116
}

.lintstagedrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"*.{js,jsx,ts,tsx}": [
2+
"[!.]**/*.{js,jsx,ts,tsx}": [
33
"npm run lint -- --fix",
44
"git add"
55
]

.storybook/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'normalize.css'
33

44
// Load all stories defined in our codebase
55
function loadStories() {
6-
const scopedRequire = require.context('..', true, /^\.\/.+.stories$/)
6+
const scopedRequire = require.context('..', true, /^\.\/.+.stor(y|ies)$/)
77
scopedRequire.keys().forEach(scopedRequire)
88
}
99

.vscode/launch.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "chrome",
6+
"request": "launch",
7+
"name": "Debug",
8+
"url": "http://localhost:3000",
9+
"preLaunchTask": "Server"
10+
}
11+
]
12+
}

.vscode/tasks.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Server",
6+
"type": "npm",
7+
"script": "server",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "custom",
11+
"pattern": {
12+
"regexp": "_____"
13+
},
14+
"background": {
15+
"activeOnStart": true,
16+
"beginsPattern": "^.*Project is running at.*$",
17+
"endsPattern": "^.*Compiled successfully.*$"
18+
}
19+
}
20+
}
21+
]
22+
}

README.org

+24-37
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
#+HTML: <h1>Astraea <sub><sub><sub>TypeScript + React + Redux Boilerplate</sub></sub></sub></h1>
1+
e+HTML: <h1>Astraea <sub><sub><sub>TypeScript + React Boilerplate</sub></sub></sub></h1>
22
[[https://travis-ci.org/jupl/astraea][file:https://img.shields.io/travis/jupl/astraea/master.svg?label=travis&style=flat-square]]
33
[[https://david-dm.org/jupl/astraea/master][file:https://img.shields.io/david/jupl/astraea/master.svg?style=flat-square]]
44
[[https://david-dm.org/jupl/astraea/master?type=dev][file:https://img.shields.io/david/dev/jupl/astraea/master.svg?style=flat-square]]
55

6+
** Note
7+
Recently [[https://redux.js.org/][Redux]] support has been removed from this boilerplate. It can still be incorporated, but by default this boilerplate is focused more on React. There are many other options like [[https://mobx.js.org/][Mobx]], [[https://reactjs.org/docs/context.html][context]], and more.
8+
69
** Table of Contents
710
- [[#about][About]]
811
- [[#prerequisites][Prerequisites]]
@@ -12,57 +15,47 @@
1215
- [[#project-resources][Project Resources]]
1316

1417
** About
15-
This is a boilerplate project for developing a mid to large scale client-side application(s) using [[https://www.typescriptlang.org/][TypeScript]], [[https://facebook.github.io/react/][React]], and [[http://redux.js.org/][Redux]]. For an example project, visit the [[https://github.com/jupl/astraea/tree/example][example branch]].
18+
This is a boilerplate project for developing a mid to large scale client-side application(s) using [[https://www.typescriptlang.org/][TypeScript]] and [[https://facebook.github.io/react/][React]]. For an example project, visit the [[https://github.com/jupl/astraea/tree/example][example branch]].
1619

17-
^{[[#astraea-typescript--react--redux-boilerplate][Back to top]]}
20+
^{[[#astraea-typescript--react-boilerplate][Back to top]]}
1821

1922
** Prerequisites
2023
- [[https://nodejs.org/en/][Node.js]] (8.x minimum required)
2124
- [[https://docs.npmjs.com/cli/npm][npm CLI]] is usually included with Node.js
22-
- [[https://yarnpkg.com/en/docs/install][Yarn]] (recommended)
2325
- Editor with support for TypeScript, [[https://palantir.github.io/tslint/][TSLint]], and [[http://editorconfig.org/][EditorConfig]] (ex. [[https://code.visualstudio.com/][Visual Studio Code]])
2426

25-
^{[[#astraea-typescript--react--redux-boilerplate][Back to top]]}
27+
^{[[#astraea-typescript--react-boilerplate][Back to top]]}
2628

2729
** Getting Started
2830
1. Clone/download this repository.
2931
2. Install dependencies using npm *or* Yarn:
30-
- =npm install=
31-
- =yarn=
32+
- =npm install=
3233
3. Start running tasks as described below in the [[#tasks][tasks section]].
3334

34-
^{[[#astraea-typescript--react--redux-boilerplate][Back to top]]}
35+
^{[[#astraea-typescript--react-boilerplate][Back to top]]}
3536

3637
** Project structure
3738
*** Overview
3839
#+BEGIN_EXAMPLE
3940
astraea/
41+
├─ .coverage/ # Code coverage reports
4042
├─ .storybook/ # Storybook configuration
41-
├─ coverage/ # Code coverage reports
4243
├─ dist/assets/ # Result assets from build tasks
44+
├─ dist/story/ # Result storybook build
45+
├─ jest/ # Code that runs before tests are run
4346
├─ src/ # Source code
4447
│ ├─ app/ # Application domain
45-
│ │ ├─ components/root/ # Top level application view
46-
│ │ ├─ actions.test.ts # Test to ensure all actions are valid
47-
│ │ └─ reducer.ts # Reducer for whole application
48+
│ │ └─ components/root/ # Top level application view
4849
│ ├─ assets/ # Static files and entry points to include in builds
4950
│ │ └─ app.tsx # An application entry point
50-
│ ├─ common/ # Shared code used throughout project
51-
│ │ ├─ components/container/ # Application wrapper component
52-
│ │ └─ store.ts # Helper to create a Redux store
53-
│ └─ webpack/ # Webpack related code
54-
│ ├─ config/ # Webpack build configurations
55-
│ ├─ plugin/ # Webpack plugins
56-
│ └─ server.ts # Local development server
57-
├─ story/ # Result storybook build
58-
├─ declarations.d.ts # TypeScript declarations
51+
│ └─ common/ # Shared code used throughout project
52+
│ ├─ components/container/ # Application wrapper component
53+
│ └─ declarations/ # TypeScript declarations
5954
├─ package.json # Configuration, tasks, and dependencies
60-
├─ package-lock.json # Dependency pinning from NPM
61-
├─ setup-tests.ts # Code that runs before tests are run
55+
├─ package-lock.json # Dependency pinning
6256
├─ tsconfig.json # TypeScript configuration
6357
├─ tslint.json # TypeScript linting rules
64-
├─ webpack.config.ts # Webpack build configuration
65-
└─ yarn.lock # Dependency pinning from Yarn
58+
└─ webpack.config.ts # Webpack build configuration
6659
#+END_EXAMPLE
6760
*** Entry Points
6861
When TypeScript code is built, any files directly inside the =src/assets/= directory are used to create the output files. The boilerplate currently generates =app.js=, as there is a single entry point inside =src/assets/=. (=src/assets/index.js=) If there are more than one entry points more files generated as well as an additional file =common.js=, which contains shared code across all entry points. =common.js= must be loaded before you load an entry point. You can see what gets generated by running the =build:dev= / =build:prod= task. (see the [[#tasks][tasks section]])
@@ -73,8 +66,7 @@ domain/
7366
│ ├─ component1/ # See Component sections below
7467
│ ├─ component2/
7568
│ └─ componentX/
76-
├─ actions.ts # Redux actions for domain
77-
└─ reducer.ts # Domain reducer
69+
└─ ... # Other domain items (Redux, MobX, context, etc.)
7870
#+END_EXAMPLE
7971
Rather than group items by things like components/reducers/actions/etc., items are grouped by domain which can be a saner option as the project grows. Examples of domains can be things like resources (ex. =blog/=, =users/=) or other things. (ex. =ui/=) Domains may include things like components, actions, reducer, etc. but they don't have to include all of them. In fact, you can think of =app/= and =common/= as domains. Other files may be present as well.
8072
*** Components
@@ -84,7 +76,7 @@ component/
8476
└─ template.tsx
8577
#+END_EXAMPLE
8678
React components are grouped in a directory.
87-
- =template.tsx= defines the React component without any knowledge of Redux specifics or other things like React DnD. (sometimes referred as /dumb/ component)
79+
- =template.tsx= defines the React component without any knowledge of outside logic (ex: Redux) specifics or other things like React DnD. (sometimes referred as /dumb/ component)
8880
- =index.ts= is the entry point of the component when used by others.
8981
- If template does not require data/action bindings then it can just pass through the template. (see =src/app/components/root/index.ts=)
9082
- If template requires data/action bindings then it is done here. (sometimes refereed as /smart/ component)
@@ -94,13 +86,12 @@ Tests for components/domains/logic/etc. If code needs to be run before tests are
9486
- [[https://facebook.github.io/jest/docs/api.html][Jest]]
9587
- [[http://airbnb.io/enzyme/index.html#basic-usage][Enzyme]]
9688
- [[https://facebook.github.io/jest/docs/tutorial-react.html][React]]
97-
- [[http://redux.js.org/docs/recipes/WritingTests.html][Redux]]
9889
**** =*.stories.tsx=
9990
Defines a story to display in React Storybook. Typically this file is in a component. (ex. =index.stories.tsx=) [[https://getstorybook.io/docs/react-storybook/basics/writing-stories][This guide]] provides information on how to write stories.
10091
**** =__snapshots__=
10192
Generated files/directories when using Jest's [[https://facebook.github.io/jest/docs/tutorial-react.html#snapshot-testing][snapshot feature]]. These files should be left to Jest and not touched manually.
10293

103-
^{[[#astraea-typescript--react--redux-boilerplate][Back to top]]}
94+
^{[[#astraea-typescript--react-boilerplate][Back to top]]}
10495

10596
** Tasks
10697
Tasks can be executed in the following manner:
@@ -120,19 +111,18 @@ Alias for =server:hot=.
120111
*** =server:hot=
121112
Start a local development server with hot reloading. To override the port change the environment variable =PORT=. The following is provided:
122113
- [[https://webpack.js.org/concepts/hot-module-replacement][Hot reloading]] (including [[https://github.com/gaearon/react-hot-loader][React Hot Loader]])
123-
- [[http://zalmoxisus.github.io/redux-devtools-extension/][Redux DevTools Extension]] (if unavailable [[https://github.com/evgenyrodionov/redux-logger][Logger for Redux]] is used)
124114
*** =server:story=
125115
Start a local server for React Storybook on port 9001. For more information visit the [[https://getstorybook.io/docs][documentation for React Storybook]].
126116
*** =build:dev= / =build:prod=
127117
Build application and include assets into a packaged build in the =dist/assets/= directory. The build for =build:dev= is not minifed and includes source maps, making it ideal for development. The build for =build:prod= is minified (with dead code elimination) and does not include source maps, making it ideal for production.
128118
*** =build:story=
129-
Generate a static build of React Storybook in the =story/= disrectory.
119+
Generate a static build of React Storybook in the =dist/story/= disrectory.
130120
*** =test= / =test:watch= / =coverage= / =coverage:watch=
131121
Execute tests once or continuously on file changes. In addition, code coverage can be determined. For more information visit the [[https://facebook.github.io/jest/docs/configuration.html][documentation for Jest]].
132122
*** =lint= / =lint:fix=
133123
Check codebase against linting rules. Optionally, some errors can be fixed automatically.
134124

135-
^{[[#astraea-typescript--react--redux-boilerplate][Back to top]]}
125+
^{[[#astraea-typescript--react-boilerplate][Back to top]]}
136126

137127
** Project Resources
138128
- Language
@@ -141,17 +131,14 @@ Check codebase against linting rules. Optionally, some errors can be fixed autom
141131
- [[https://github.com/palantir/tslint-react][TSLint React]]
142132
- Libraries
143133
- [[https://facebook.github.io/react/][React]]
144-
- [[http://redux.js.org/][Redux]]
145-
- [[https://github.com/acdlite/redux-actions][Redux Actions]]
146134
- [[https://styled-components.com/][Styled Components]]
147135
- [[https://necolas.github.io/normalize.css/][normalize.css]]
148136
- Testing
149137
- [[https://facebook.github.io/jest/][Jest]]
150138
- [[https://github.com/airbnb/enzyme/][Enzyme]]
151139
- Development Tools
152140
- [[https://getstorybook.io/][React Storybook]]
153-
- [[https://github.com/zalmoxisus/redux-devtools-extension][Redux DevTools]]
154141
- Build Tools
155142
- [[https://webpack.js.org/][Webpack]]
156143

157-
^{[[#astraea-typescript--react--redux-boilerplate][Back to top]]}
144+
^{[[#astraea-typescript--react-boilerplate][Back to top]]}

declarations.d.ts

-5
This file was deleted.

.jest/setup.ts jest/setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {configure} from 'enzyme'
2-
import * as Adapter from 'enzyme-adapter-react-16'
2+
import Adapter from 'enzyme-adapter-react-16'
33
import 'jest-enzyme'
44

55
// Set up Enzyme

0 commit comments

Comments
 (0)