-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
7,871 additions
and
7,483 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
# RE-Tailwind | ||
# Create reason react app | ||
|
||
## Run Project | ||
Reason React Boiler Blate | ||
|
||
## Quick Start | ||
|
||
```sh | ||
npm install | ||
npm start | ||
# in another tab | ||
npm run webpack | ||
npm i -g create-reason-react-tailwind | ||
crra | ||
``` | ||
|
||
After you see the webpack compilation succeed (the `npm run webpack` step), open up `build/index.html` (**no server needed!**). Then modify whichever `.re` file in `src` and refresh the page to see the changes. | ||
|
||
## Run Project with Server | ||
#### What project template would you like to generate? (choose the template) | ||
|
||
To run with the webpack development server run `npm run server` and view in the browser at http://localhost:8000. Running in this environment provides hot reloading and support for routing; just edit and save the file and the browser will automatically refresh. | ||
```sh | ||
webpack-tailwind | ||
``` | ||
|
||
Note that any hot reload on a route will fall back to the root (`/`), so `ReasonReact.Router.dangerouslyGetInitialUrl` will likely be needed alongside the `ReasonReact.Router.watchUrl` logic to handle routing correctly on hot reload refreshes or simply opening the app at a URL that is not the root. | ||
#### Project Name - Add the project name | ||
|
||
To use a port other than 8000 set the `PORT` environment variable (`PORT=8080 npm run server`). | ||
```sh | ||
my-app | ||
``` | ||
|
||
## Build for Production | ||
| `crra` will create a new folder with the template project. | ||
|
||
```sh | ||
npm run clean | ||
npm run build | ||
npm run webpack:production | ||
cd my-app | ||
``` | ||
|
||
Follow the instructions in `README.md` |
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,63 @@ | ||
#!/usr/bin/env node | ||
|
||
const inquirer = require("inquirer"); | ||
const fs = require("fs"); | ||
|
||
const CHOICES = fs.readdirSync(`${__dirname}/templates`); | ||
const CURR_DIR = process.cwd(); | ||
|
||
const QUESTIONS = [ | ||
{ | ||
name: "project-choice", | ||
type: "list", | ||
message: "What project template would you like to generate?", | ||
choices: CHOICES | ||
}, | ||
{ | ||
name: "project-name", | ||
type: "input", | ||
message: "Project name:", | ||
validate: function(input) { | ||
if (/^([A-Za-z\-\_\d])+$/.test(input)) return true; | ||
else | ||
return "Project name may only include letters, numbers, underscores and hashes."; | ||
} | ||
} | ||
]; | ||
|
||
inquirer.prompt(QUESTIONS).then(answers => { | ||
const projectChoice = answers["project-choice"]; | ||
const projectName = answers["project-name"]; | ||
const templatePath = `${__dirname}/templates/${projectChoice}`; | ||
|
||
fs.mkdirSync(`${CURR_DIR}/${projectName}`); | ||
|
||
createDirectoryContents(templatePath, projectName); | ||
}); | ||
|
||
function createDirectoryContents(templatePath, newProjectPath) { | ||
const filesToCreate = fs.readdirSync(templatePath); | ||
|
||
filesToCreate.forEach(file => { | ||
const origFilePath = `${templatePath}/${file}`; | ||
|
||
// get stats about the current file | ||
const stats = fs.statSync(origFilePath); | ||
|
||
if (stats.isFile()) { | ||
const contents = fs.readFileSync(origFilePath, "utf8"); | ||
|
||
const writePath = `${CURR_DIR}/${newProjectPath}/${file}`; | ||
// fs.writeFileSync(writePath, contents, "utf8"); | ||
fs.copyFileSync(origFilePath, writePath); | ||
} else if (stats.isDirectory()) { | ||
fs.mkdirSync(`${CURR_DIR}/${newProjectPath}/${file}`); | ||
|
||
// recursive call | ||
createDirectoryContents( | ||
`${templatePath}/${file}`, | ||
`${newProjectPath}/${file}` | ||
); | ||
} | ||
}); | ||
} |
Oops, something went wrong.