Skip to content

Commit

Permalink
docs(gitbook): Integration Gitbook & Styleguidist part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
codedavinci committed Dec 8, 2017
1 parent 9bdfd3e commit a33a2b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions config/styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const path = require('path')
const { version } = require('../package.json')

const styleguidistEnv = process.env.STYLEGUIDIST_ENV || 'dev' // dev, staging, production
const getDirectory = env => (env === 'staging' ? 'guide/staging' : 'styleguide')
const isStaging = styleguidistEnv === 'staging'
const getDirectory = () => (isStaging ? 'guide/components' : 'styleguide')

// Append strings to this array to enable components in staging, e.g. `['Box', 'ExpandCollapse']`
const enabledInStaging = ['Image', 'Checkbox', 'Radio', 'Select', 'Textarea']
Expand Down Expand Up @@ -264,7 +265,7 @@ module.exports = {

template: styleguidistEnv === 'production' ? path.resolve('docs/index.html') : undefined,
assetsDir: path.resolve('docs/assets/'),
styleguideDir: path.resolve(getDirectory(styleguidistEnv), styleguidistEnv),
styleguideDir: path.resolve(getDirectory(), !isStaging ? styleguidistEnv : ''),

This comment has been minimized.

Copy link
@ryanoglesby08

ryanoglesby08 Dec 8, 2017

Contributor

It may be cleaner here to just extract all the logic for determining the value of styleguideDir into a single function so that all the logic is together. At the moment its scattered among 2 functions and an inline ternary statement, which means in order to understand it I have to look all over the place.

Maybe something like this, and the getStyleguideDir function does everything it needs to?

styleguideDir: getStyleguideDir(styleguidistEnv)
require: [path.resolve('src/scss/global.scss'), path.resolve('docs/scss/styleguide.scss')],
styleguideComponents: {
Logo: path.resolve('docs/components/Logo/Logo'),
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build-package": "yarn build:js && yarn build:css && yarn build:scss",
"build-styleguide": "styleguidist build --config config/styleguide.config.js",
"build:for-staging":
"yarn build-package && yarn build-styleguide && gitbook build guide guide/staging",
"yarn build-package && STYLEGUIDIST_ENV=staging yarn build-styleguide && gitbook build guide guide/staging",

This comment has been minimized.

Copy link
@ryanoglesby08

ryanoglesby08 Dec 8, 2017

Contributor

Hmmmm, I see the idea here, this may need to be massaged a little bit to work properly in the pipeline.

Based on changes I'm seeing, there may need to be changes to the Dockerfile too. Also, in the pipeline we only need to call build-package ONCE because we don't parameterize that at all.

For full context, here are the current assumptions of the pipeline and build process:

  1. Push to master triggers the "Build" stage of the CI pipeline:

Openshift builds a Docker image with the JS package and the static docs site for both staging and prod.
The Dockerfile in the root of the project contains the instructions for that. Of interest here are lines 36 - 37:

# build staging version of static docs into styleguide/staging folder
STYLEGUIDIST_ENV=staging yarn run build-styleguide 

# build production version of static docs into styleguide/production folder
STYLEGUIDIST_ENV=production yarn run build-styleguide 
  1. Pipeline runs tests

  2. Pipeline deploys to staging

Inside the Docker container now, we run the deploy-docs script with the "staging" parameter. Essentially this means:

Push styleguide/staging folder ==> AWS staging env location

  1. Pipeline deploys to prod (Manual trigger)

Inside the Docker container now, we run the deploy-docs script with the "production" parameter. Essentially this means:

Push styleguide/production folder ==> AWS production env location

"deploy:docs": "node ./scripts/deploy-docs.js",
"deploy:package": "scripts/publish.sh",
"dev": "styleguidist server --config config/styleguide.config.js",
Expand Down Expand Up @@ -137,8 +137,7 @@
"icons/scripts/icons.js",
"styleguide/**",
"**.tgz",
"guide/_book/**",
"guide/staging/**"
"guide/**"
]
}
}

0 comments on commit a33a2b6

Please sign in to comment.