Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # -*- coding: utf-8 -*-
- """Create a react app based on create-react-app. python create_react_app.py yourapp."""
- import os
- import sys
- PROJECT_NAME = sys.argv[1]
- if PROJECT_NAME is None or len(PROJECT_NAME) == 0:
- raise ValueError("The project name must be valid.")
- ROOT_PATH = "./{}/".format(PROJECT_NAME)
- print("Creating the project...")
- os.system("npm i -g create-react-app @storybook/cli")
- os.system("create-react-app {}".format(PROJECT_NAME))
- os.system("cd {} && git init && git flow init && cd ..".format(PROJECT_NAME))
- os.system("cd {} && getstorybook && cd ..".format(PROJECT_NAME))
- print("Preparing the project structure...")
- with open("{}CHANGELOG.md".format(ROOT_PATH), "w") as f:
- cl = """
- ---
- ## v0.1.0
- **Author**: Guillaume Mousnier, Jeremy Raffin, Jerome Raffin.
- **Type**: Feature
- **Changes**:
- - Init the repo
- ---
- """
- f.write(cl)
- with open("{}.travis.yml".format(ROOT_PATH), "w") as f:
- cl = """
- ---
- language: node_js
- node_js:
- - 6
- cache:
- directories:
- - node_modules
- script:
- - npm test
- - npm run build
- ---
- """
- f.write(cl)
- os.mkdir("{}src/__tests__".format(ROOT_PATH))
- os.mkdir("{}src/components".format(ROOT_PATH))
- os.mkdir("{}src/containers".format(ROOT_PATH))
- os.mkdir("{}src/assets".format(ROOT_PATH))
- os.mkdir("{}src/css".format(ROOT_PATH))
- with open("{}src/router.js".format(ROOT_PATH), "w") as f:
- router = """
- import React from 'react'
- import ReactDOM from 'react-dom'
- import { createStore, combineReducers } from 'redux'
- import { Provider } from 'react-redux'
- import { Router, Route, browserHistory } from 'react-router'
- import { syncHistoryWithStore, routerReducer } from 'react-router-redux'
- import App from ./containers/App.js
- import MyContainer from ./containers/container
- import mycontainerReducer from './containers/mycontainer/reducer'
- const store = createStore(
- combineReducers({
- mycontainer: mycontainerReducer,
- routing: routerReducer
- })
- )
- const history = syncHistoryWithStore(browserHistory, store)
- export default () => (
- <Provider store={store}>
- <Router history={history}>
- <Route path="/" component={App}>
- <Route path="mycontainer" component={MyContainer}/>
- </Route>
- </Router>
- </Provider>
- )
- """
- print("Installing last dependencies...")
- os.system("cd {} && npm i --save redux react-router react-redux react-router-redux styled-components redux-thunk"
- .format(ROOT_PATH))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement