docbrown/.gitdocs.js
Dmitry Maksyoma 12cb984e9a
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>
2020-06-25 21:02:45 -04:00

28 lines
647 B
JavaScript

/*
* This file is created so that it's possible to
* Run `gitdocs serve` from root
*/
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;
}
}