Skip to content

Commit

Permalink
fix(docz-core): some adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed May 14, 2019
1 parent a8efb46 commit 86f95b5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 0 additions & 2 deletions core/docz-core/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as envDotProp from 'env-dot-prop'

import { parseConfig } from '../config/docz'
import { bundler as gatsby } from '../bundler'
import { openBrowser } from '../utils/open-browser'

export const dev = async (args: Arguments<any>) => {
const env = envDotProp.get('node.env')
Expand All @@ -17,7 +16,6 @@ export const dev = async (args: Arguments<any>) => {

try {
await app.start()
if (args.open || args.o) openBrowser(`http://${config.host}:${config.port}`)
} catch (err) {
logger.fatal('Failed to process data server')
logger.error(err)
Expand Down
4 changes: 3 additions & 1 deletion core/docz-core/src/machines/devServer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ const machine = Machine<ServerMachineCtx>({
executingCommand: {
invoke: {
src: 'execDevCommand',
onDone: 'openBrowser',
// onDone: {
// actions: 'openBrowser',
// },
onError: 'exiting',
},
},
Expand Down
20 changes: 10 additions & 10 deletions core/docz-core/src/machines/devServer/services/createResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ const copyAndModifyPkgJson = async (ctx: ServerMachineCtx) => {
await fs.outputJSON(movePath, newPkgJSON, { spaces: 2 })
}

export const writeNotFound = async () => {
const outputPath = path.join(paths.docz, 'src/404.js')
await outputFileFromTemplate('404.tpl.js', outputPath, {})
const writeEslintRc = async ({ isDoczRepo }: ServerMachineCtx) => {
if (!isDoczRepo) return
const filepath = path.join(paths.docz, '.eslintrc')
await fs.outputJSON(filepath, { extends: 'react-app' })
}

const writeConfigFile = async ({ args, isDoczRepo }: ServerMachineCtx) => {
Expand All @@ -108,10 +109,9 @@ const writeConfigFile = async ({ args, isDoczRepo }: ServerMachineCtx) => {
})
}

const writeEslintRc = async ({ isDoczRepo }: ServerMachineCtx) => {
if (!isDoczRepo) return
const filepath = path.join(paths.docz, '.eslintrc')
await fs.outputJSON(filepath, { extends: 'react-app' })
export const writeNotFound = async () => {
const outputPath = path.join(paths.docz, 'src/pages/404.js')
await outputFileFromTemplate('404.tpl.js', outputPath, {})
}

const writeGatsbyNode = async () => {
Expand All @@ -120,7 +120,7 @@ const writeGatsbyNode = async () => {
}

const writeGatsbyHTML = async () => {
const outputPath = path.join(paths.docz, 'gatsby-html.js')
const outputPath = path.join(paths.docz, 'src/html.js')
await outputFileFromTemplate('gatsby-html.tpl.js', outputPath)
}

Expand All @@ -135,9 +135,9 @@ export const createResources = async (ctx: ServerMachineCtx) => {
copyPkgJSON()
await copyDoczRc()
await copyAndModifyPkgJson(ctx)
await writeNotFound()
await writeConfigFile(ctx)
await writeEslintRc(ctx)
await writeConfigFile(ctx)
await writeNotFound()
await fixDuplicatedReact(ctx)
return Promise.resolve()
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion core/docz-core/src/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export const outputFileFromTemplate = async (
const filepath = fromTemplates(templatePath)
const template = await compiled(filepath, compileProps || { minimize: false })
const file = template(templateProps || {})
const raw = format(file)
const raw = await format(file)
await fs.outputFile(outputPath, raw)
}
8 changes: 5 additions & 3 deletions core/docz-core/templates/404.tpl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react'

export default NotFound = () => {
const NotFound = () => {
const style = {
display: 'flex';
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100vh',
Expand All @@ -11,6 +11,8 @@ export default NotFound = () => {
}

return (
<div style={}>Not Found</div>
<div style={style}>Not Found</div>
)
}

export default NotFound

0 comments on commit 86f95b5

Please sign in to comment.