Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gatsby https flag to use in dev mode #1569

Merged
merged 2 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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