diff --git a/core/docz-core/src/commands/dev.ts b/core/docz-core/src/commands/dev.ts index 5d547e819..845921e78 100644 --- a/core/docz-core/src/commands/dev.ts +++ b/core/docz-core/src/commands/dev.ts @@ -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) => { const env = envDotProp.get('node.env') @@ -17,7 +16,6 @@ export const dev = async (args: Arguments) => { 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) diff --git a/core/docz-core/src/machines/devServer/index.ts b/core/docz-core/src/machines/devServer/index.ts index fc15a68c1..622286854 100644 --- a/core/docz-core/src/machines/devServer/index.ts +++ b/core/docz-core/src/machines/devServer/index.ts @@ -42,7 +42,9 @@ const machine = Machine({ executingCommand: { invoke: { src: 'execDevCommand', - onDone: 'openBrowser', + // onDone: { + // actions: 'openBrowser', + // }, onError: 'exiting', }, }, diff --git a/core/docz-core/src/machines/devServer/services/createResources.ts b/core/docz-core/src/machines/devServer/services/createResources.ts index 979dea6d4..1e62c559c 100644 --- a/core/docz-core/src/machines/devServer/services/createResources.ts +++ b/core/docz-core/src/machines/devServer/services/createResources.ts @@ -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) => { @@ -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 () => { @@ -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) } @@ -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) { diff --git a/core/docz-core/src/utils/template.ts b/core/docz-core/src/utils/template.ts index d04946a70..de005e0c1 100644 --- a/core/docz-core/src/utils/template.ts +++ b/core/docz-core/src/utils/template.ts @@ -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) } diff --git a/core/docz-core/templates/404.tpl.js b/core/docz-core/templates/404.tpl.js index 045ca40fa..c3c518ee7 100644 --- a/core/docz-core/templates/404.tpl.js +++ b/core/docz-core/templates/404.tpl.js @@ -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', @@ -11,6 +11,8 @@ export default NotFound = () => { } return ( -
Not Found
+
Not Found
) } + +export default NotFound