Adapt "gitdocs serve" to work in a remote dev env (#8791)

* Adapt dev env to run on a remote box

* webpack-dev-server ignores CLI arguments, so switched to environment
  variables.
* Dynamically determine remote webpack host via APP_DOMAIN environment
  variable, defined in application.yml.
* Setup content security policy to allow connecting to webpack on a
  remote box, defined by APP_DOMAIN environment variable.

* Make Webpacker listen on 0.0.0.0

* Account for APP_DOMAIN port

* Add support for URI scheme and tests

* Fix a spec by disabling a Rubocop linter

* Add app_domain rake task

* Ensure "gitdocs serve" works for remote and local hosts

* Update .gitdocs.js

Co-authored-by: Michael Kohl <me@citizen428.net>

* Remove unnecessary rake task app_domain

* Fix gitdocs being broken due to quotes

Co-authored-by: Michael Kohl <me@citizen428.net>
This commit is contained in:
Dmitry Maksyoma 2020-06-26 13:02:45 +12:00 committed by GitHub
parent ea7d843f35
commit 12cb984e9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,5 +7,22 @@ var config = require('./docs/.gitdocs.json');
module.exports = new Promise((resolve, reject) => {
config.root = 'docs/';
setupHost(config);
resolve(config);
});
function fetchAppDomain() {
const { execSync } = require('child_process');
const appDomainGetCmd =
'rails runner "puts ApplicationConfig.app_domain_no_port"';
return execSync(appDomainGetCmd).toString().replace(/\s/g, '');
}
function setupHost(config) {
const appDomain = fetchAppDomain();
if (config.host === '0.0.0.0' && appDomain) {
config.host = appDomain;
}
}