From 2c84a8dfe334814aa7ed518a1b2ee1f9b8fd05f3 Mon Sep 17 00:00:00 2001 From: csmets Date: Tue, 8 Sep 2020 11:15:45 +1000 Subject: [PATCH 1/2] feat: add gatsby https flag to use in dev mode --- .../bundler/machine/services/exec-dev-command.ts | 14 ++++++++++++-- core/docz-core/src/config/argv.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/docz-core/src/bundler/machine/services/exec-dev-command.ts b/core/docz-core/src/bundler/machine/services/exec-dev-command.ts index 0fbab28e0..294934c87 100644 --- a/core/docz-core/src/bundler/machine/services/exec-dev-command.ts +++ b/core/docz-core/src/bundler/machine/services/exec-dev-command.ts @@ -36,15 +36,25 @@ 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 spawn( gatsbyPath, - ['develop', '--host', `${args.host}`, '--port', `${args.port}`], + [ + 'develop', + '--host', + `${args.host}`, + '--port', + `${args.port}`, + useHttps ? '--https' : '', + ], { 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({ diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index d18a8280e..7a75596a0 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -65,6 +65,7 @@ export interface Argv { description: string /** slugify separator */ separator: string + https: boolean } export interface Config extends Argv { From 7ba26b5217cef0ff697835810070e28766a63ba8 Mon Sep 17 00:00:00 2001 From: csmets Date: Tue, 8 Sep 2020 15:37:40 +1000 Subject: [PATCH 2/2] feat: add in certs --- .../src/bundler/machine/services/exec-dev-command.ts | 11 +++++++++++ core/docz-core/src/config/argv.ts | 3 +++ 2 files changed, 14 insertions(+) diff --git a/core/docz-core/src/bundler/machine/services/exec-dev-command.ts b/core/docz-core/src/bundler/machine/services/exec-dev-command.ts index 294934c87..3fd015086 100644 --- a/core/docz-core/src/bundler/machine/services/exec-dev-command.ts +++ b/core/docz-core/src/bundler/machine/services/exec-dev-command.ts @@ -36,8 +36,16 @@ 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, [ @@ -47,6 +55,9 @@ export const execDevCommand = async ({ args }: ServerMachineCtx) => { '--port', `${args.port}`, useHttps ? '--https' : '', + ...caFileOption, + ...keyFileOption, + ...certFileOption, ], { stdio: 'inherit', diff --git a/core/docz-core/src/config/argv.ts b/core/docz-core/src/config/argv.ts index 7a75596a0..1cea82a04 100644 --- a/core/docz-core/src/config/argv.ts +++ b/core/docz-core/src/config/argv.ts @@ -66,6 +66,9 @@ export interface Argv { /** slugify separator */ separator: string https: boolean + certFile: string + keyFile: string + caFile: string } export interface Config extends Argv {