diff --git a/README.md b/README.md index 3ae938d..a936c11 100644 --- a/README.md +++ b/README.md @@ -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 - diff --git a/lib/build.js b/lib/build.js index d58a946..4641278 100644 --- a/lib/build.js +++ b/lib/build.js @@ -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) diff --git a/package.json b/package.json index ee8db3b..12414a5 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/build.js b/test/build.js index 1568e2e..7bdbb49 100644 --- a/test/build.js +++ b/test/build.js @@ -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() -}) diff --git a/test/snapshots/components.js.md b/test/snapshots/components.js.md index 72d2d06..ec1b0db 100644 --- a/test/snapshots/components.js.md +++ b/test/snapshots/components.js.md @@ -10,6 +10,27 @@ Generated by [AVA](https://ava.li). 'Catch' +## Catch renders error + +> Snapshot 1 + +
+      Error: nope
+    
+ ## CenteredLayout renders with active prop > Snapshot 1 @@ -26,7 +47,7 @@ Generated by [AVA](https://ava.li). [
-        /Users/bjackson/repos/x0/test
+        beep
       
, , - - -## LivePreview renders - -> Snapshot 1 - -
-
-
-

- Hello -

-
-
-
Snapshot 1 - - 'Hello + ] ## Library renders @@ -88,7 +83,33 @@ Generated by [AVA](https://ava.li). hello - + +## LivePreview renders + +> Snapshot 1 + +
+
+
+

+ Hello +

+
+
+
+ +## ScopeProvider renders + +> Snapshot 1 + + 'Hello' ## SidebarLayout renders @@ -99,7 +120,7 @@ Generated by [AVA](https://ava.li). className="sc-hEsumM dahmKO" >
,

, - + ] + +## scope.a renders + +> Snapshot 1 + + + +## scope.a renders a plain link for absolute URLs + +> Snapshot 1 + + + Hello + ## scope.blockquote renders @@ -342,46 +384,4 @@ Generated by [AVA](https://ava.li).
    Snapshot 1 - - Snapshot 1 - -
    -      Error: nope
    -    
    Snapshot 1 - -
    - Hello - \ No newline at end of file + /> diff --git a/test/snapshots/components.js.snap b/test/snapshots/components.js.snap index c410deb..f37a579 100644 Binary files a/test/snapshots/components.js.snap and b/test/snapshots/components.js.snap differ