techdocs-cli: unified dev and production build through config detection

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-02-05 11:18:43 +01:00
parent bbd59ed355
commit b70c186194
8 changed files with 94 additions and 38 deletions
+1 -5
View File
@@ -31,11 +31,7 @@ compile_and_build_cli() {
build_and_embed_app() {
echo "🚚 Embedding app..."
if [ "$TECHDOCS_CLI_DEV_MODE" = "true" ] ; then
yarn workspace techdocs-cli-embedded-app build:dev > /dev/null
else
yarn workspace techdocs-cli-embedded-app build > /dev/null
fi
yarn workspace techdocs-cli-embedded-app build > /dev/null
cp -r "$TECHDOCS_CLI_EMBEDDED_APP_DIR"/dist "$TECHDOCS_CLI_DIR"/dist/techdocs-preview-bundle > /dev/null
}
+10 -2
View File
@@ -71,10 +71,18 @@ export default class HTTPServer {
response.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');
request.url = forwardPath;
return proxy.web(request, response);
proxy.web(request, response);
return;
}
return serveHandler(request, response, {
// This endpoint is used by the frontend to detect where the backend is running.
if (request.url === '/.detect') {
response.setHeader('Content-Type', 'text/plain');
response.end('techdocs-cli-server');
return;
}
serveHandler(request, response, {
public: this.backstageBundleDir,
trailingSlash: true,
rewrites: [{ source: '**', destination: 'index.html' }],