Skip to content

Commit

Permalink
feat(docz-core): remove installation step in .docz πŸŽ‰
Browse files Browse the repository at this point in the history
  • Loading branch information
rakannimer committed Sep 4, 2019
1 parent b24fa6e commit 6790179
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 117 deletions.
3 changes: 1 addition & 2 deletions core/docz-core/src/bundler/machine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ const machine = Machine<ServerMachineCtx>({
},
},
ensuringDirs: asyncState('ensureDirs', 'creatingResources'),
creatingResources: asyncState('createResources', 'installingDeps'),
installingDeps: asyncState('installDeps', 'executingCommand'),
creatingResources: asyncState('createResources', 'executingCommand'),
executingCommand: asyncState('execDevCommand'),
exit: {
type: 'final',
Expand Down
17 changes: 8 additions & 9 deletions core/docz-core/src/bundler/machine/services/create-resources.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as path from 'path'
import * as fs from 'fs-extra'
import { finds } from 'load-cfg'
import { omit, merge } from 'lodash/fp'
import { omit } from 'lodash/fp'
import findUp from 'find-up'
import sh from 'shelljs'

import * as paths from '../../../config/paths'
import { createDeps } from '../../../utils/create-deps'
import { ServerMachineCtx } from '../context'
import { outputFileFromTemplate } from '../../../utils/template'

Expand All @@ -16,12 +15,13 @@ export const copyDoczRc = async () => {
}

const copyAndModifyPkgJson = async (ctx: ServerMachineCtx) => {
const filepath = path.join(paths.root, 'package.json')
const movePath = path.join(paths.docz, 'package.json')
const pkg = await fs.readJSON(filepath, { throws: false })
const deps = await createDeps(ctx)
const newPkg = merge(pkg, {
...deps,
// const pkg = await fs.readJSON(filepath, { throws: false })
const newPkg = {
name: 'docz-app',
dependencies: {
gatsby: 'just-to-fool-cli-never-installed',
},
scripts: {
dev: 'gatsby develop',
build: 'gatsby build',
Expand All @@ -31,8 +31,7 @@ const copyAndModifyPkgJson = async (ctx: ServerMachineCtx) => {
private: true,
workspaces: ['../../../core/**', '../../../other-packages/**'],
}),
})

}
await fs.outputJSON(movePath, newPkg, { spaces: 2 })
}

Expand Down
38 changes: 3 additions & 35 deletions core/docz-core/src/bundler/machine/services/install-deps.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,4 @@
import { pipe } from 'lodash/fp'
import spawn from 'cross-spawn'
import chalk from 'chalk'
import sh from 'shelljs'
import ora from 'ora'

import * as paths from '../../../config/paths'
import { ServerMachineCtx } from '../context'

const warn: Function = pipe(
chalk.yellow,
console.log
)

export const installDeps = async ({ firstInstall }: ServerMachineCtx) => {
if (firstInstall) {
warn('\n----------------')
warn(`We need to install some dependencies in order to run your bundler.`)
warn('This just happens the first time you run docz.')
warn('This could take a while !')
warn('----------------\n')
}

return new Promise(async (resolve, reject) => {
sh.cd(paths.docz)

const checking = !firstInstall && ora('Checking dependencies...').start()
const result = spawn.sync('yarn', ['--production=false'], {
stdio: 'inherit',
})

if (checking) checking.succeed('Dependencies checked!')
if (result.error) return reject(result.error)
return resolve()
})
export const installDeps = async () => {
// No need to install dependencies
return
}
7 changes: 1 addition & 6 deletions core/docz-core/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import findUp from 'find-up'

import { parseConfig } from '../config/docz'
import { getIsFirstInstall, getIsDoczRepo } from '../bundler/machine/actions'
import {
ensureDirs,
createResources,
installDeps,
} from '../bundler/machine/services'
import { ensureDirs, createResources } from '../bundler/machine/services'

export const init = async (args: Arguments<any>) => {
const doczrcFilepath = await findUp(finds('docz'))
Expand All @@ -25,7 +21,6 @@ export const init = async (args: Arguments<any>) => {
doczrcFilepath,
}
await createResources(serverMachineContext)
await installDeps(serverMachineContext)
console.log()
console.log(`βœ… Docz is ready to go `)
console.log()
Expand Down
65 changes: 0 additions & 65 deletions core/docz-core/src/utils/create-deps.ts

This file was deleted.

3 changes: 3 additions & 0 deletions core/docz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"docz-core": "2.0.0-rc.32",
"fast-deep-equal": "^2.0.1",
"gatsby": "^2.13.27",
"gatsby-plugin-eslint": "^2.0.5",
"gatsby-plugin-typescript": "^2.1.6",
"gatsby-theme-docz": "2.0.0-rc.32",
"lodash": "^4.17.14",
"marksy": "^8.0.0",
"match-sorter": "^3.1.1",
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5584,6 +5584,11 @@ babel-plugin-remove-graphql-queries@^2.7.5:
resolved "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.7.5.tgz#841631756b95c6919a0db37d26530c7b2174b3b8"
integrity sha512-cc2EGIp+bMZmpTg4+zO8LEiCP/+x+4rQpH8ekaGrpu7IkyDL07nrhdOBTmVs+Xwx8coFIdCU6RUvRv2RwmCxtg==

babel-plugin-remove-graphql-queries@^2.7.6:
version "2.7.6"
resolved "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.7.6.tgz#ac4abf3a9f109499bf1b970d8c10f7515aa832b2"
integrity sha512-0ZFyTwK/f2i9xH6mwiwBG/Zl/IHgevsJANTnUMsHS21yYcHcjGSwiiHZKgrzooIksz+dzhCQRpcAECMtq0Jx4Q==

"babel-plugin-styled-components@>= 1":
version "1.10.0"
resolved "https://registry.npmjs.org/babel-plugin-styled-components/-/babel-plugin-styled-components-1.10.0.tgz#ff1f42ad2cc78c21f26b62266b8f564dbc862939"
Expand Down Expand Up @@ -10997,6 +11002,11 @@ gatsby-plugin-emotion@^4.1.2:
"@babel/runtime" "^7.0.0"
"@emotion/babel-preset-css-prop" "^10.0.5"

gatsby-plugin-eslint@^2.0.5:
version "2.0.5"
resolved "https://registry.npmjs.org/gatsby-plugin-eslint/-/gatsby-plugin-eslint-2.0.5.tgz#be02f5aff9b7f4a37927f3f917e82ad9f3d67f09"
integrity sha512-7dgcNtFOGgPLseDA55DDjqqnSW+2Pe91erL6nFjLFs/vlFlT9+GbR/4zkQH9WjWOHSfCtgrUzi59cxM1rBm4kw==

gatsby-plugin-manifest@^2.2.3:
version "2.2.3"
resolved "https://registry.npmjs.org/gatsby-plugin-manifest/-/gatsby-plugin-manifest-2.2.3.tgz#f701620c11132bfbff20929fa632e326cdd9b9b8"
Expand Down Expand Up @@ -11113,6 +11123,15 @@ gatsby-plugin-sharp@^2.2.18:
sharp "^0.23.0"
svgo "^1.3.0"

gatsby-plugin-typescript@^2.1.6:
version "2.1.6"
resolved "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-2.1.6.tgz#6079812bc60004f93c565c0083da1c64107a7b19"
integrity sha512-RPLj1dwJjzcMOdyRzzVN5nlpSbaY81RS8xQxNUGE1BGnqLo4T5z4M/QqSetf8klrhzd0E/Z5ArZ1DecI95Vkkw==
dependencies:
"@babel/preset-typescript" "^7.3.3"
"@babel/runtime" "^7.5.5"
babel-plugin-remove-graphql-queries "^2.7.6"

gatsby-react-router-scroll@^2.1.3:
version "2.1.3"
resolved "https://registry.npmjs.org/gatsby-react-router-scroll/-/gatsby-react-router-scroll-2.1.3.tgz#4f1654555da14b4860386fab711b3bac0e177ac5"
Expand Down

0 comments on commit 6790179

Please sign in to comment.