Skip to content

Commit

Permalink
feat: add gatsby https flag to use in dev mode (#1569)
Browse files Browse the repository at this point in the history
* feat: add gatsby https flag to use in dev mode

* feat: add in certs
  • Loading branch information
csmets authored Jun 3, 2021
1 parent 1155df7 commit 9d91503
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 23 additions & 2 deletions core/docz-core/src/bundler/machine/services/exec-dev-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,36 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => {
const repoRootPath = get(args, 'repoRootPath', await findRootPath())
const gatsbyPath = path.join(repoRootPath, 'node_modules/.bin/gatsby')
// const cliArgs = process.argv.slice(3)

// Has --https flag to enable https in dev mode
const useHttps = args.https
const caFile = args.caFile
const keyFile = args.keyFile
const certFile = args.certFile
const caFileOption = caFile ? ['--ca-file', caFile] : []
const keyFileOption = keyFile ? ['--key-file', keyFile] : []
const certFileOption = certFile ? ['--cert-file', certFile] : []

spawn(
gatsbyPath,
['develop', '--host', `${args.host}`, '--port', `${args.port}`],
[
'develop',
'--host',
`${args.host}`,
'--port',
`${args.port}`,
useHttps ? '--https' : '',
...caFileOption,
...keyFileOption,
...certFileOption,
],
{
stdio: 'inherit',
cwd: paths.docz,
}
)
const url = `http://${args.host}:${args.port}`
const protocol = useHttps ? 'https' : 'http'
const url = `${protocol}://${args.host}:${args.port}`
console.log()
console.log('Building app')
await waitOn({
Expand Down
4 changes: 4 additions & 0 deletions core/docz-core/src/config/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export interface Argv {
description: string
/** slugify separator */
separator: string
https: boolean
certFile: string
keyFile: string
caFile: string
}

export interface Config extends Argv {
Expand Down

0 comments on commit 9d91503

Please sign in to comment.