Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 9d91503

Browse files
authored
feat: add gatsby https flag to use in dev mode (#1569)
* feat: add gatsby https flag to use in dev mode * feat: add in certs
1 parent 1155df7 commit 9d91503

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

core/docz-core/src/bundler/machine/services/exec-dev-command.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,36 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => {
3636
const repoRootPath = get(args, 'repoRootPath', await findRootPath())
3737
const gatsbyPath = path.join(repoRootPath, 'node_modules/.bin/gatsby')
3838
// const cliArgs = process.argv.slice(3)
39+
40+
// Has --https flag to enable https in dev mode
41+
const useHttps = args.https
42+
const caFile = args.caFile
43+
const keyFile = args.keyFile
44+
const certFile = args.certFile
45+
const caFileOption = caFile ? ['--ca-file', caFile] : []
46+
const keyFileOption = keyFile ? ['--key-file', keyFile] : []
47+
const certFileOption = certFile ? ['--cert-file', certFile] : []
48+
3949
spawn(
4050
gatsbyPath,
41-
['develop', '--host', `${args.host}`, '--port', `${args.port}`],
51+
[
52+
'develop',
53+
'--host',
54+
`${args.host}`,
55+
'--port',
56+
`${args.port}`,
57+
useHttps ? '--https' : '',
58+
...caFileOption,
59+
...keyFileOption,
60+
...certFileOption,
61+
],
4262
{
4363
stdio: 'inherit',
4464
cwd: paths.docz,
4565
}
4666
)
47-
const url = `http://${args.host}:${args.port}`
67+
const protocol = useHttps ? 'https' : 'http'
68+
const url = `${protocol}://${args.host}:${args.port}`
4869
console.log()
4970
console.log('Building app')
5071
await waitOn({

core/docz-core/src/config/argv.ts

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export interface Argv {
6565
description: string
6666
/** slugify separator */
6767
separator: string
68+
https: boolean
69+
certFile: string
70+
keyFile: string
71+
caFile: string
6872
}
6973

7074
export interface Config extends Argv {

0 commit comments

Comments
 (0)