├── .gitattributes ├── template ├── .gitattributes ├── gitignore ├── next.config.js ├── pages │ ├── index-default.js │ ├── index-emotion.js │ └── _document.js ├── README.md ├── now.json ├── .babelrc ├── .editorconfig ├── package.json └── LICENSE ├── .gitignore ├── .prettierrc ├── test ├── snapshots │ ├── test.js.snap │ └── test.js.md └── test.js ├── .editorconfig ├── package.json ├── circle.yml ├── LICENSE ├── README.md ├── saofile.js └── yarn.lock /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /template/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /template/gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .next 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | *.log 4 | -------------------------------------------------------------------------------- /template/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = () => ({}) 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true 4 | } 5 | -------------------------------------------------------------------------------- /template/pages/index-default.js: -------------------------------------------------------------------------------- 1 | export default () => ( 2 |

Hello SAO & Next.js!

3 | ) 4 | -------------------------------------------------------------------------------- /test/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saojs/sao-next/HEAD/test/snapshots/test.js.snap -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # <%= name %> 2 | 3 | > <%= description %> 4 | 5 | ## License 6 | 7 | MIT © <%= username %> 8 | -------------------------------------------------------------------------------- /template/now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "builds": [ 4 | { "src": "next.config.js", "use": "@now/next" } 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "next/babel" 4 | ]<% if (emotion) { %>, 5 | "plugins": [ 6 | ["emotion", { "inline": true }] 7 | ]<% } %> 8 | } 9 | -------------------------------------------------------------------------------- /template/pages/index-emotion.js: -------------------------------------------------------------------------------- 1 | import styled from 'react-emotion' 2 | 3 | const H1 = styled('h1')` 4 | color: pink; 5 | ` 6 | 7 | export default () => ( 8 |

Hello SAO & Next.js!

9 | ) 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /template/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= name %>", 3 | "private": true, 4 | "version": "1.0.0", 5 | "scripts": { 6 | "dev": "next", 7 | "start": "next start", 8 | "build": "next build", 9 | "deploy": "now" 10 | }, 11 | "dependencies": {<% if (emotion) { %> 12 | "emotion": "^9.0.0", 13 | "babel-plugin-emotion": "^9.0.0", 14 | "prop-types": "^15.6.1", 15 | "react-emotion": "^9.0.0", 16 | "emotion-server": "^9.0.0",<% } %> 17 | "next": "^7.0.0", 18 | "react": "^16.0.0", 19 | "react-dom": "^16.0.0" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sao-next", 3 | "version": "0.3.1", 4 | "description": "Scaffold out a Next.js project.", 5 | "repository": { 6 | "url": "saojs/sao-next", 7 | "type": "git" 8 | }, 9 | "scripts": { 10 | "test": "ava" 11 | }, 12 | "author": "egoist <0x142857@gmail.com> (https://github.com/egoist)", 13 | "license": "MIT", 14 | "files": [ 15 | "saofile.js", 16 | "template" 17 | ], 18 | "dependencies": { 19 | "superb": "^1.3.0" 20 | }, 21 | "devDependencies": { 22 | "ava": "^0.25.0", 23 | "sao": "^1.3.2" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: ~/project 5 | docker: 6 | - image: circleci/node:latest 7 | branches: 8 | ignore: 9 | - gh-pages # list of branches to ignore 10 | - /release\/.*/ # or ignore regexes 11 | steps: 12 | - checkout 13 | - restore_cache: 14 | key: dependency-cache-{{ checksum "yarn.lock" }} 15 | - run: 16 | name: install dependences 17 | command: yarn 18 | - save_cache: 19 | key: dependency-cache-{{ checksum "yarn.lock" }} 20 | paths: 21 | - ./node_modules 22 | - run: 23 | name: test 24 | command: yarn test 25 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import test from 'ava' 3 | import sao from 'sao' 4 | 5 | const generator = path.join(__dirname, '..') 6 | 7 | test('defaults', async t => { 8 | const stream = await sao.mock({ generator }) 9 | t.snapshot(stream.fileList, 'generated files') 10 | 11 | t.snapshot(await stream.readFile('pages/index.js'), 'content of index.js') 12 | t.snapshot(await stream.readFile('.babelrc'), '.babelrc') 13 | }) 14 | 15 | test('add emotion', async t => { 16 | const stream = await sao.mock({ generator }, { 17 | emotion: true 18 | }) 19 | t.snapshot(stream.fileList, 'generated files') 20 | 21 | t.snapshot(await stream.readFile('pages/index.js'), 'content of index.js') 22 | t.snapshot(await stream.readFile('.babelrc'), '.babelrc') 23 | }) 24 | -------------------------------------------------------------------------------- /template/pages/_document.js: -------------------------------------------------------------------------------- 1 | import Document, { Head, Main, NextScript } from 'next/document' 2 | import { extractCritical } from 'emotion-server' 3 | 4 | export default class MyDocument extends Document { 5 | static getInitialProps ({ renderPage }) { 6 | const page = renderPage() 7 | const styles = extractCritical(page.html) 8 | return { ...page, ...styles } 9 | } 10 | 11 | constructor (props) { 12 | super(props) 13 | const { __NEXT_DATA__, ids } = props 14 | if (ids) { 15 | __NEXT_DATA__.ids = ids 16 | } 17 | } 18 | 19 | render () { 20 | return ( 21 | 22 | 23 |