1
1
mirror of https://github.com/c8r/x0.git synced 2024-08-16 17:00:24 +03:00

Adjust build and test

This commit is contained in:
Brent Jackson 2018-06-23 12:50:38 -04:00
parent 8c5093859c
commit 207b0c932a
6 changed files with 85 additions and 154 deletions

View File

@ -362,61 +362,3 @@ See the [example](https://github.com/c8r/x0/tree/master/examples/webpack-config)
[webpack-merge]: https://github.com/survivejs/webpack-merge
[webpack]: https://webpack.js.org
---
## To Do
**REMOVE BEFORE MERGING**
- [ ] changelog/docs
## API Changes
- Supports nested routes
- Adds support for `.md` files, using MDX
- Configurable default styles for markdown and MDX files
- Adds LiveEditor and LivePreview capabilities to markdown
- Adds `--match` option for filtering files
- Adds `ignore` option for pages
- Optional layout component
- Optional Library component
- Support for 404 pages
## Internal Changes
- Uses mdx loader for md/mdx/jsx files
## Breaking Changes
- Specifying scope in JSX front matter is no longer supported
- [x] static 404 output
- [x] 404
- [x] Sidebar minHeight/pagination
- [x] Sidebar hidePagination option
- [x] bug: route.props from defaultProps
- [x] SidebarLayout
- [x] test getInitialProps
- [x] double check dynamic routing
- [x] pass RouterState props to view
- [x] props.children in custom app
- [x] require.context `_app`
- [x] peer deps
- [x] props.ignore
- [x] default layout for mdx/md
- [x] default route sorting
- [x] route dirname/full path
- [x] pass front-matter as props
- [x] markdown scope
- [x] deep require context
- [x] minimatch
- [x] move client modules to src
- [x] adjust resolve
- [x] props.Component in custom app?
- [ ] ~~Head component with react helmet~~ doesn't work
- [ ] ~~scope loader shim for jsx front matter~~
### Breaking
- .jsx imports/scope
- .jsx props
- custom app path option (must be `_app.js`) (undocumented)
- Remove support for glamor and glamorous

View File

@ -1,4 +1,4 @@
const fs = require('fs-extra')
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const MiniHTMLWebpackPlugin = require('mini-html-webpack-plugin')
@ -8,7 +8,7 @@ const React = require('react')
const { renderToString, renderToStaticMarkup } = require('react-dom/server')
const { StaticRouter } = require('react-router-dom')
const semver = require('semver')
const rimraf = require('rimraf')
const util = require('util')
const baseConfig = require('./config')
@ -100,7 +100,7 @@ const renderHTML = ({
}
const remove = filename => {
fs.remove(filename, err => {
rimraf(filename, err => {
if (err) console.log(err)
})
}
@ -210,13 +210,15 @@ module.exports = async (opts) => {
)
const compiler = webpack(config)
remove(opts.tempdir)
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
if (err) {
reject(err)
return
}
remove(opts.tempdir)
// remove(opts.tempdir)
if (opts.static) {
const bundle = path.join(opts.outDir, 'bundle.js')
remove(bundle)

View File

@ -9,7 +9,7 @@
"scripts": {
"start": "./cli.js docs -p 8888",
"build": "./cli.js build docs",
"test": "nyc ava -T 20s",
"test": "nyc ava -T 30s",
"test:components": "nyc ava test/components.js",
"cover": "nyc report --reporter=html --reporter=lcov"
},

View File

@ -20,7 +20,6 @@ const clean = () => {
if (fs.existsSync(output)) {
rimraf.sync(output)
}
// fs.remove(output)
}
test.before(clean)
@ -31,15 +30,3 @@ test('static renders', async t => {
const html = fs.readFileSync(htmlFile, 'utf8')
t.snapshot(html)
})
test('static uses getInitialProps method', async t => {
const res = await build(options)
const html = fs.readFileSync(propsFile, 'utf8')
t.snapshot(html)
})
test.skip('static makes a directory', async t => {
clean()
const res = await build(options)
t.pass()
})

View File

@ -10,6 +10,27 @@ Generated by [AVA](https://ava.li).
'Catch'
## Catch renders error
> Snapshot 1
<pre
style={
{
backgroundColor: 'red',
color: 'white',
fontFamily: 'Menlo, monospace',
fontSize: '14px',
margin: 0,
minHeight: '128px',
padding: '16px',
whiteSpace: 'prewrap',
}
}
>
Error: nope
</pre>
## CenteredLayout renders with active prop
> Snapshot 1
@ -26,7 +47,7 @@ Generated by [AVA](https://ava.li).
[
<pre>
/Users/bjackson/repos/x0/test
beep
</pre>,
<ul>
<li>
@ -38,33 +59,7 @@ Generated by [AVA](https://ava.li).
</a>
</li>
</ul>,
## LivePreview renders
> Snapshot 1
<div
className="sc-bdVaJa kdjLZs"
>
<div
className="react-live"
>
<div
className="react-live-preview"
>
<h1>
Hello
</h1>
</div>
</div>
</div
## ScopeProvider renders
> Snapshot 1
'Hello
]
## Library renders
@ -88,7 +83,33 @@ Generated by [AVA](https://ava.li).
hello
</pre>
</a>
</div
</div>
## LivePreview renders
> Snapshot 1
<div
className="sc-bdVaJa kdjLZs"
>
<div
className="react-live"
>
<div
className="react-live-preview"
>
<h1>
Hello
</h1>
</div>
</div>
</div>
## ScopeProvider renders
> Snapshot 1
'Hello'
## SidebarLayout renders
@ -99,7 +120,7 @@ Generated by [AVA](https://ava.li).
className="sc-hEsumM dahmKO"
>
<div
className="sc-fMiknA jgVkvN sc-bwzfXH pjOvZ"
className="sc-fMiknA jgVkvN sc-bwzfXH hKiLMS sc-bdVaJa iHZvIS"
>
<button
className="sc-gzVnrw ghjHJc sc-ifAKCX fFPXoq"
@ -131,15 +152,15 @@ Generated by [AVA](https://ava.li).
/>
</div>,
<div
className="sc-jnlKLf fQRDBU sc-bwzfXH pjOvZ"
className="sc-jnlKLf fQRDBU sc-bwzfXH hKiLMS sc-bdVaJa iHZvIS"
>
<div
className="sc-fYxtnH bIntzd"
className="sc-fYxtnH VTytv"
onClick={Function onClick {}}
open={false}
>
<div
className="sc-fMiknA fVCXKt sc-bwzfXH pjOvZ"
className="sc-fMiknA fVCXKt sc-bwzfXH hKiLMS sc-bdVaJa iHZvIS"
>
<h2
className="sc-VigVT gPiNJC"
@ -197,7 +218,7 @@ Generated by [AVA](https://ava.li).
Content
</div>
<div
className="sc-bwzfXH deiOzS"
className="sc-bwzfXH liBCIH sc-bdVaJa gkOtLU"
>
<div
className="sc-bdVaJa LbkC"
@ -222,7 +243,28 @@ Generated by [AVA](https://ava.li).
</div>
</main>
</div>,
]
## scope.a renders
> Snapshot 1
<a
className="sc-htoDjs gLCdRU"
href="/"
onClick={Function {}}
/>
## scope.a renders a plain link for absolute URLs
> Snapshot 1
<a
className="sc-htoDjs gLCdRU"
href="http://example.com"
>
Hello
</a>
## scope.blockquote renders
@ -342,46 +384,4 @@ Generated by [AVA](https://ava.li).
<ul
className="sc-htpNat houaHu"
/
## scope.a renders
> Snapshot 1
<a
className="sc-htoDjs gLCdRU"
href="/"
onClick={Function {}}
/
## Catch renders error
> Snapshot 1
<pre
style={
{
backgroundColor: 'red',
color: 'white',
fontFamily: 'Menlo, monospace',
fontSize: '14px',
margin: 0,
minHeight: '128px',
padding: '16px',
whiteSpace: 'prewrap',
}
}
>
Error: nope
</pre
## scope.a renders a plain link for absolute URLs
> Snapshot 1
<a
className="sc-htoDjs gLCdRU"
href="http://example.com"
>
Hello
</a>
/>

Binary file not shown.