From f0cddd312ed6f22ba081e8def7c67a51cd51ca12 Mon Sep 17 00:00:00 2001 From: Rakan Nimer Date: Sun, 1 Sep 2019 10:15:52 +0300 Subject: [PATCH] fix(docz-core): use react from parent directory (#1053) * 2.0.0-rc.21 --- core/docz-core/package.json | 3 ++- .../src/bundler/machine/services/create-resources.ts | 12 +++++++++--- core/docz-core/src/utils/create-deps.ts | 4 ++-- core/docz-core/templates/gatsby-node.tpl.js | 11 +++++++++++ core/docz/package.json | 4 ++-- core/gatsby-theme-docz/package.json | 4 ++-- examples/basic/package.json | 2 +- examples/flow/package.json | 2 +- examples/images/package.json | 2 +- examples/now/package.json | 2 +- examples/react-native/package.json | 2 +- examples/styled-components/package.json | 2 +- examples/typescript/package.json | 2 +- 13 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 core/docz-core/templates/gatsby-node.tpl.js diff --git a/core/docz-core/package.json b/core/docz-core/package.json index b64c47209..f683eb9e5 100644 --- a/core/docz-core/package.json +++ b/core/docz-core/package.json @@ -1,6 +1,6 @@ { "name": "docz-core", - "version": "2.0.0-rc.12", + "version": "2.0.0-rc.21", "description": "All docz core logic of bundle and parsing is included on this package", "license": "MIT", "main": "dist/index.js", @@ -17,6 +17,7 @@ "fix": "yarn lint --fix", "lint": "yarn eslint . --ext .ts,.tsx", "precommit": "lint-staged", + "prepare": "yarn build", "test": "yarn jest" }, "dependencies": { diff --git a/core/docz-core/src/bundler/machine/services/create-resources.ts b/core/docz-core/src/bundler/machine/services/create-resources.ts index 08d0fea9a..b45f90a41 100644 --- a/core/docz-core/src/bundler/machine/services/create-resources.ts +++ b/core/docz-core/src/bundler/machine/services/create-resources.ts @@ -67,6 +67,11 @@ const writeGatsbyConfig = async ({ args, isDoczRepo }: ServerMachineCtx) => { }) } +const writeGatsbyConfigNode = async () => { + const outputPath = path.join(paths.docz, 'gatsby-node.js') + await outputFileFromTemplate('gatsby-node.tpl.js', outputPath) +} + const copyGatsbyConfigFile = async (from: string, to: string) => { const filepath = path.join(paths.root, from) const dest = path.join(paths.docz, to) @@ -78,8 +83,8 @@ const copyGatsbyConfigFile = async (from: string, to: string) => { const writeGatsbyConfigCustom = async () => copyGatsbyConfigFile('gatsby-config.js', 'gatsby-config.custom.js') -const writeGatsbyNode = async () => - copyGatsbyConfigFile('gatsby-node.js', 'gatsby-node.js') +const writeGatsbyNodeCustom = async () => + copyGatsbyConfigFile('gatsby-node.js', 'gatsby-node.custom.js') const writeGatsbySSR = async () => copyGatsbyConfigFile('gatsby-ssr.js', 'gatsby-ssr.js') @@ -95,8 +100,9 @@ export const createResources = async (ctx: ServerMachineCtx) => { await writeEslintRc(ctx) await writeNotFound() await writeGatsbyConfig(ctx) + await writeGatsbyConfigNode() await writeGatsbyConfigCustom() - await writeGatsbyNode() + await writeGatsbyNodeCustom() await writeGatsbyBrowser() await writeGatsbySSR() } catch (err) { diff --git a/core/docz-core/src/utils/create-deps.ts b/core/docz-core/src/utils/create-deps.ts index e01268908..1c70bcf89 100644 --- a/core/docz-core/src/utils/create-deps.ts +++ b/core/docz-core/src/utils/create-deps.ts @@ -51,9 +51,9 @@ const getCoreDeps = async ({ isDoczRepo }: ServerMachineCtx, pkg: any) => { export const createDeps = async (ctx: ServerMachineCtx) => { const filepath = path.join(paths.root, 'package.json') const pkg = await fs.readJSON(filepath, { throws: false }) - + const dependencies = pkg.dependencies return { - dependencies: pkg.dependencies, + dependencies, devDependencies: { ...pkg.devDependencies, ...(await getDeps(REQUIRED_DEV_DEPS, ctx, pkg)), diff --git a/core/docz-core/templates/gatsby-node.tpl.js b/core/docz-core/templates/gatsby-node.tpl.js new file mode 100644 index 000000000..8acb7619d --- /dev/null +++ b/core/docz-core/templates/gatsby-node.tpl.js @@ -0,0 +1,11 @@ +const path = require('path') + +exports.onCreateWebpackConfig = ({ actions }) => { + actions.setWebpackConfig({ + resolve: { + alias: { + react: path.resolve('../node_modules/react'), + }, + }, + }) +} diff --git a/core/docz/package.json b/core/docz/package.json index 47f6b28e7..d2d978ac4 100644 --- a/core/docz/package.json +++ b/core/docz/package.json @@ -1,6 +1,6 @@ { "name": "docz", - "version": "2.0.0-rc.12", + "version": "2.0.0-rc.21", "description": "It's has never been so easy to documents your things!", "license": "MIT", "main": "dist/index.js", @@ -28,7 +28,7 @@ "array-sort": "^1.0.0", "capitalize": "^2.0.0", "docz-components": "^2.0.0-rc.12", - "docz-core": "^2.0.0-rc.12", + "docz-core": "^2.0.0-rc.21", "fast-deep-equal": "^2.0.1", "gatsby": "^2.13.27", "lodash": "^4.17.14", diff --git a/core/gatsby-theme-docz/package.json b/core/gatsby-theme-docz/package.json index 893f86896..3618824c9 100644 --- a/core/gatsby-theme-docz/package.json +++ b/core/gatsby-theme-docz/package.json @@ -1,6 +1,6 @@ { "name": "gatsby-theme-docz", - "version": "2.0.0-rc.12", + "version": "2.0.0-rc.21", "description": "Gatsby theme created to use Docz", "license": "MIT", "author": "Pedro Nauck (pedronauck@gmail.com)", @@ -46,7 +46,7 @@ "rehype-slug": "^2.0.3", "remark-docz": "^2.0.0-rc.1", "remark-frontmatter": "^1.3.2", - "theme-ui": "^0.2.14", + "theme-ui": "^0.2.38", "typescript": "3.5.3", "typography-theme-moraga": "^0.16.19", "yargs": "^13.3.0" diff --git a/examples/basic/package.json b/examples/basic/package.json index b76fdcf41..75dd05c54 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -21,6 +21,6 @@ "scheduler": "^0.15.0" }, "devDependencies": { - "docz": "2.0.0-rc.9" + "docz": "next" } } diff --git a/examples/flow/package.json b/examples/flow/package.json index 776355d62..6003300a8 100644 --- a/examples/flow/package.json +++ b/examples/flow/package.json @@ -22,7 +22,7 @@ }, "devDependencies": { "@babel/preset-flow": "^7.0.0", - "docz": "2.0.0-rc.9", + "docz": "next", "flow-bin": "^0.102.0", "flow-typed": "^2.6.0" } diff --git a/examples/images/package.json b/examples/images/package.json index c1cb87b24..0ed6578e1 100644 --- a/examples/images/package.json +++ b/examples/images/package.json @@ -20,6 +20,6 @@ "scheduler": "^0.15.0" }, "devDependencies": { - "docz": "2.0.0-rc.9" + "docz": "next" } } diff --git a/examples/now/package.json b/examples/now/package.json index 00338bd23..892e6c5b0 100644 --- a/examples/now/package.json +++ b/examples/now/package.json @@ -23,7 +23,7 @@ "scheduler": "^0.15.0" }, "devDependencies": { - "docz": "2.0.0-rc.9", + "docz": "next", "now": "^16.1.2" } } diff --git a/examples/react-native/package.json b/examples/react-native/package.json index 17760c359..e24ccea2f 100644 --- a/examples/react-native/package.json +++ b/examples/react-native/package.json @@ -23,6 +23,6 @@ }, "devDependencies": { "@babel/core": "^7.5.5", - "docz": "2.0.0-rc.9" + "docz": "next" } } diff --git a/examples/styled-components/package.json b/examples/styled-components/package.json index 1f2dafcc8..11ff5bf94 100644 --- a/examples/styled-components/package.json +++ b/examples/styled-components/package.json @@ -18,6 +18,6 @@ "styled-components": "^4.3.2" }, "devDependencies": { - "docz": "2.0.0-rc.9" + "docz": "next" } } diff --git a/examples/typescript/package.json b/examples/typescript/package.json index 3b49a7e19..ba2e7dc52 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -22,6 +22,6 @@ "devDependencies": { "@types/react": "^16.8.23", "@types/react-dom": "^16.8.4", - "docz": "2.0.0-rc.9" + "docz": "next" } }