Created
October 16, 2017 18:16
-
-
Save erictherobot/98bb298c35702b57147f86d7ab3a0697 to your computer and use it in GitHub Desktop.
nextjs-installer.sh <yourappname>
This file contains hidden or 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
#!/bin/bash | |
# ./nextjs-installer <project-name> | |
# Create a new Next.js Project | |
echo "Creating Next.js Project: $1 ..." | |
mkdir $1 | |
cd $1 | |
mkdir pages | |
mkdir components | |
mkdir static | |
echo "Created directories pages, components, static" | |
cat <<'EOF' > package.json | |
{ | |
"name": "", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"scripts": { | |
"dev": "next | json-server --watch db.json --port 3004" | |
}, | |
"dependencies": { | |
"next": "*", | |
"react-bootstrap": "*" | |
} | |
} | |
EOF | |
cat <<'EOF' > db.json | |
{ | |
"posts": [ | |
{ "id": 1, "title": "json-server", "author": "typicode" } | |
], | |
"comments": [ | |
{ "id": 1, "body": "some comment", "postId": 1 } | |
], | |
"profile": { "name": "typicode" } | |
} | |
EOF | |
yarn | |
yarn add next | |
echo "import React from 'react' | |
import { Button } from 'react-bootstrap' | |
export default () => ( | |
<div>Welcome to next.js! <Button>Hello Bootstrap</Button></div> | |
)" > pages/index.js | |
yarn dev | |
echo "Completed install!" | |
atom . | |
open http://localhost:3000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment