Skip to content

Commit e098e78

Browse files
committed
Reactful 0.4.0
0 parents  commit e098e78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+4127
-0
lines changed

.eslintrc.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
"parser": 'babel-eslint',
3+
"env": {
4+
"browser": true,
5+
"commonjs": true,
6+
"es6": true,
7+
"node": true,
8+
"jest": true,
9+
},
10+
"extends": ["eslint:recommended"],
11+
"parserOptions": {
12+
"ecmaFeatures": {
13+
"experimentalObjectRestSpread": true,
14+
},
15+
"sourceType": "module"
16+
},
17+
"rules": {
18+
"indent": ["error", 2, { "SwitchCase": 1 }],
19+
"linebreak-style": ["error","unix"],
20+
"quotes": ["error","single"],
21+
"semi": ["error","always"],
22+
"no-console": ["warn", { "allow": ["info", "error"] }],
23+
"arrow-parens": ["error", "always"],
24+
}
25+
};

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lerna-debug.log

lerna.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"lerna": "2.0.0-rc.5",
3+
"packages": [
4+
"packages/*"
5+
],
6+
"version": "0.3.12"
7+
}

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"format": "prettier-eslint \"packages/**/*.js\" --write --trailing-comma es5",
5+
"precommit": "lint-staged",
6+
"prepush": "verify-tests"
7+
},
8+
"devDependencies": {
9+
"babel-eslint": "^7.2.3",
10+
"eslint": "^4.1.1",
11+
"eslint-plugin-react": "^7.1.0",
12+
"husky": "^0.14.1",
13+
"lerna": "^2.0.0-rc.5",
14+
"lint-staged": "^4.0.0",
15+
"prettier": "^1.5.0",
16+
"prettier-eslint-cli": "^4.1.1"
17+
},
18+
"lint-staged": {
19+
"*.js": ["format", "git add"]
20+
}
21+
}

packages/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
BSD License
2+
3+
For jsComplete software
4+
5+
Copyright (c) 2017, jsComplete, Inc. All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
* Neither the name jsComplete nor the names of its contributors may be used to
18+
endorse or promote products derived from this software without specific
19+
prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## Reactful
2+
3+
A very opinionated React CLI. You can use it to generate an independent full-stack react application that's fully-configured to render on both client and server.
4+
5+
[![npm version](https://badge.fury.io/js/reactful.svg)](https://badge.fury.io/js/reactful)
6+
7+
This CLI requires Node 8.0 or greater, and it would work better if you have [Yarn](https://yarnpkg.com/en/) and [Git](https://git-scm.com/) on the machine.
8+
9+
### Install
10+
11+
npm i -g reactful
12+
13+
Once installed, the package will have a global ```react``` command.
14+
15+
### Create New React App
16+
17+
react new my-awesome-react-app-name
18+
19+
Once created, you'll see instructions on how to start it:
20+
21+
cd my-awesome-react-app-name
22+
23+
### To start the app (for development):
24+
react start
25+
26+
# The start command starts a watcher process
27+
# which will restart node/webpack on save
28+
29+
### Open the app in browser:
30+
react open
31+
32+
# The app will be running on localhost:4242 by default
33+
34+
### To run tests:
35+
react test
36+
37+
### To build for production:
38+
react build
39+
40+
### To start the app for production:
41+
react prod
42+
43+
The generated app is completely independent from the reactful package. At this point you can part ways with the reactful package and do your own thing, but if you follow the patterns initialized by the package, you can use a few handy commands from the global react command.
44+
45+
### Create New Redux/React App
46+
47+
react new-full my-awesome-redux-app-name
48+
49+
This will generate a Redux-configured full-stack React application with a state managed by Immutable.js. It will also render on both client and server.
50+
51+
52+
### Update Existing React App
53+
54+
While in a React application that's created with this tool, you can always revert things back the default configurations with the init command. You can also use this command in an empty directory.
55+
56+
cd my-awesome-react-app-name
57+
react init
58+
59+
If that directory already has files, reactful will ask you if you want to override them.
60+
61+
You can also use init-full to update an existing Redux/React app.
62+
63+
### Creating Components
64+
65+
- Create a New Component: ```react c ComponentName```
66+
- Create a New Pure Component: ```react pc ComponentName```
67+
- Create a New Function Component: ```react fc ComponentName```
68+
69+
All of these commands will also create a jest snapshot test for the generated component.

packages/reactful-commands/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#! /usr/bin/env node
2+
const path = require('path');
3+
4+
const command = process.argv[2];
5+
const args = process.argv.slice(3);
6+
7+
async function openApp() {
8+
try {
9+
const { host, port } = require(path.resolve('.reactful.json'));
10+
await require('../lib/open-url')(`http://${host}:${port}`);
11+
} catch (err) {
12+
console.error(err);
13+
}
14+
}
15+
16+
async function runCommand(command) {
17+
try {
18+
await require('../lib/run-command')(command);
19+
} catch (err) {
20+
console.error(err);
21+
}
22+
}
23+
24+
async function createComponent(componentType, ...args) {
25+
try {
26+
await require('../lib/create-component')(componentType, ...args);
27+
} catch (err) {
28+
console.error(err);
29+
}
30+
}
31+
32+
switch (command) {
33+
case 'open':
34+
openApp();
35+
break;
36+
case 'start':
37+
case 'test':
38+
case 'build':
39+
case 'prod':
40+
runCommand(command);
41+
break;
42+
case 'pc':
43+
case 'pure-component':
44+
createComponent('pure', ...args);
45+
break;
46+
case 'c':
47+
case 'component':
48+
createComponent('full', ...args);
49+
break;
50+
case 'fc':
51+
case 'function-component':
52+
createComponent('function', ...args);
53+
break;
54+
default:
55+
console.error('Unsupported Command');
56+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
const { rcc, rfc, jestSnap } = require('../lib/text');
4+
5+
module.exports = function createComponent(componentType, componentName) {
6+
const componentCode =
7+
componentType === 'function'
8+
? rfc(componentName)
9+
: rcc(componentName, componentType === 'pure');
10+
11+
return new Promise((resolve, reject) => {
12+
try {
13+
const componentFile = path.resolve(
14+
'src',
15+
'components',
16+
`${componentName}.js`
17+
);
18+
console.info(`Generating ${path.relative('.', componentFile)}`);
19+
fs.writeFileSync(componentFile, componentCode);
20+
21+
const componentTestFile = path.resolve(
22+
'src',
23+
'components',
24+
'__tests__',
25+
`${componentName}Test.js`
26+
);
27+
console.info(`Generating ${path.relative('.', componentTestFile)}`);
28+
fs.writeFileSync(componentTestFile, jestSnap(componentName));
29+
30+
console.info('✨ Done.');
31+
resolve();
32+
} catch (err) {
33+
reject(err);
34+
}
35+
});
36+
};

0 commit comments

Comments
 (0)