fix(techdocs-cli): cross-platform build script
Co-authored-by: Emma Indal <emma.indahl@gmail.com> Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
"scripts": {
|
||||
"start": "nodemon --",
|
||||
"build": "./scripts/build.sh",
|
||||
"build:dev": "TECHDOCS_CLI_DEV_MODE=true yarn build",
|
||||
"clean": "backstage-cli clean",
|
||||
"lint": "backstage-cli lint",
|
||||
"test": "backstage-cli test --testPathIgnorePatterns src/e2e.test.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2020 The Backstage Authors
|
||||
# Copyright 2021 The Backstage Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -16,26 +16,29 @@
|
||||
|
||||
set -e
|
||||
|
||||
# Build the TechDocs CLI
|
||||
npx backstage-cli -- build --outputs cjs
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
TECHDOCS_CLI_DIR="$SCRIPT_DIR"/..
|
||||
TECHDOCS_CLI_EMBEDDED_APP_DIR="$TECHDOCS_CLI_DIR"/../embedded-techdocs-app
|
||||
|
||||
# Make sure to do `yarn run build` in packages/embedded-techdocs before building here.
|
||||
compile_and_build_cli() {
|
||||
echo "📄 Compiling..."
|
||||
yarn workspace @techdocs/cli tsc > /dev/null
|
||||
echo "📦️ Building..."
|
||||
pushd $TECHDOCS_CLI_DIR > /dev/null
|
||||
npx backstage-cli build --outputs cjs > /dev/null
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
EMBEDDED_TECHDOCS_APP_PATH=../embedded-techdocs-app
|
||||
TECHDOCS_PREVIEW_SOURCE=$EMBEDDED_TECHDOCS_APP_PATH/dist
|
||||
TECHDOCS_PREVIEW_DEST=dist/techdocs-preview-bundle
|
||||
build_and_embed_app() {
|
||||
echo "🚚 Embedding app..."
|
||||
if [ "$TECHDOCS_CLI_DEV_MODE" = "true" ] ; then
|
||||
yarn workspace embedded-techdocs-app build:dev > /dev/null
|
||||
else
|
||||
yarn workspace embedded-techdocs-app build > /dev/null
|
||||
fi
|
||||
cp -r "$TECHDOCS_CLI_EMBEDDED_APP_DIR"/dist "$TECHDOCS_CLI_DIR"/dist/techdocs-preview-bundle > /dev/null
|
||||
}
|
||||
|
||||
# Build the embedded-techdocs-app
|
||||
pushd $EMBEDDED_TECHDOCS_APP_PATH >/dev/null
|
||||
if [[ $TECHDOCS_CLI_DEV_MODE == "true" ]]; then
|
||||
yarn build:dev
|
||||
else
|
||||
yarn build
|
||||
fi
|
||||
popd >/dev/null
|
||||
|
||||
cp -r $TECHDOCS_PREVIEW_SOURCE $TECHDOCS_PREVIEW_DEST
|
||||
|
||||
# Write to console
|
||||
echo "[techdocs-cli]: Built the dist/ folder"
|
||||
echo "[techdocs-cli]: Imported @backstage/plugin-techdocs dist/ folder into techdocs-preview-bundle/"
|
||||
compile_and_build_cli
|
||||
build_and_embed_app
|
||||
echo "🏁 Ready!"
|
||||
|
||||
@@ -77,8 +77,8 @@ export default async function serve(cmd: Command) {
|
||||
|
||||
// Wait until mkdocs server has started so that Backstage starts with docs loaded
|
||||
// Takes 1-5 seconds
|
||||
for (let attempt = 0; attempt < 10; attempt++) {
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
for (let attempt = 0; attempt < 30; attempt++) {
|
||||
await new Promise(r => setTimeout(r, 3000));
|
||||
if (mkdocsServerHasStarted) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ const FIXTURE_DIR = path.resolve(PROJECT_ROOT_DIR, 'src/fixture');
|
||||
|
||||
describe('end-to-end', () => {
|
||||
it('shows help text', async () => {
|
||||
jest.setTimeout(10000);
|
||||
jest.setTimeout(30000);
|
||||
const proc = await executeTechDocsCliCommand(['--help']);
|
||||
|
||||
expect(proc.combinedStdOutErr).toContain('Usage: techdocs-cli [options]');
|
||||
@@ -30,10 +30,10 @@ describe('end-to-end', () => {
|
||||
});
|
||||
|
||||
it('can generate', async () => {
|
||||
jest.setTimeout(10000);
|
||||
jest.setTimeout(30000);
|
||||
const proc = await executeTechDocsCliCommand(['generate', '--no-docker'], {
|
||||
cwd: FIXTURE_DIR,
|
||||
killAfter: 8000,
|
||||
killAfter: 16000,
|
||||
});
|
||||
|
||||
expect(proc.combinedStdOutErr).toContain('Successfully generated docs');
|
||||
@@ -41,12 +41,12 @@ describe('end-to-end', () => {
|
||||
});
|
||||
|
||||
it('can serve in mkdocs', async () => {
|
||||
jest.setTimeout(10000);
|
||||
jest.setTimeout(30000);
|
||||
const proc = await executeTechDocsCliCommand(
|
||||
['serve:mkdocs', '--no-docker'],
|
||||
{
|
||||
cwd: FIXTURE_DIR,
|
||||
killAfter: 8000,
|
||||
killAfter: 16000,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -55,10 +55,10 @@ describe('end-to-end', () => {
|
||||
});
|
||||
|
||||
it('can serve in backstage', async () => {
|
||||
jest.setTimeout(10000);
|
||||
jest.setTimeout(30000);
|
||||
const proc = await executeTechDocsCliCommand(['serve', '--no-docker'], {
|
||||
cwd: FIXTURE_DIR,
|
||||
killAfter: 8000,
|
||||
killAfter: 16000,
|
||||
});
|
||||
|
||||
expect(proc.combinedStdOutErr).toContain('Starting mkdocs server');
|
||||
|
||||
@@ -40,6 +40,7 @@ export const runMkdocsServer = async (options: {
|
||||
`${process.cwd()}:/content`,
|
||||
'-p',
|
||||
`${port}:${port}`,
|
||||
'-it',
|
||||
dockerImage,
|
||||
'serve',
|
||||
'--dev-addr',
|
||||
|
||||
Reference in New Issue
Block a user