From 2019ff968878f8d14df1ac96041e654ecdb0bd72 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 18 May 2022 15:41:38 -0400 Subject: [PATCH 1/4] [docs] Add dev_docs script for managing dev_docs deps and starting dev mode --- scripts/dev_docs.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 scripts/dev_docs.sh diff --git a/scripts/dev_docs.sh b/scripts/dev_docs.sh new file mode 100755 index 00000000000000..802f8ce5c0788f --- /dev/null +++ b/scripts/dev_docs.sh @@ -0,0 +1,92 @@ +#!/bin/bash +set -euo pipefail + +KIBANA_DIR=$(cd "$(dirname "$0")"/.. && pwd) +WORKSPACE=$(cd "$KIBANA_DIR/.." && pwd)/kibana-docs +export NVM_DIR="$WORKSPACE/.nvm" + +DOCS_DIR="$WORKSPACE/docs.elastic.dev" + +# These are the other repos with docs currently required to build the docs in this repo and not get errors +# For example, kibana docs link to docs in these repos, and if they aren't built, you'll get errors +DEV_DIR="$WORKSPACE/dev" +TEAM_DIR="$WORKSPACE/kibana-team" + +mkdir -p "$WORKSPACE" +cd "$WORKSPACE" + +if ! which nvm; then + if [[ ! -d "$NVM_DIR" ]]; then + echo "Installing a separate copy of nvm" + git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" + cd "$NVM_DIR" + git checkout "$(git describe --abbrev=0 --tags --match "v[0-9]*" "$(git rev-list --tags --max-count=1)")" + fi + source "$NVM_DIR/nvm.sh" +fi + +if [[ ! -d "$DOCS_DIR" ]]; then + echo "Cloning docs.elastic.dev repo..." + git clone --depth 1 git@github.com:elastic/docs.elastic.dev.git # TODO auto-detect ssh vs https +else + cd "$DOCS_DIR" + git pull + cd - +fi + +if [[ ! -d "$DEV_DIR" ]]; then + echo "Cloning dev repo..." + git clone --depth 1 git@github.com:elastic/dev.git +else + cd "$DEV_DIR" + git pull + cd - +fi + +if [[ ! -d "$TEAM_DIR" ]]; then + echo "Cloning kibana-team repo..." + git clone --depth 1 git@github.com:elastic/kibana-team.git # TODO auto-detect ssh vs https +else + cd "$TEAM_DIR" + git pull + cd - +fi + +# The minimum sources required to build kibana docs +cat << EOF > "$DOCS_DIR/sources-dev.json" +{ + "sources": [ + { + "type": "file", + "location": "$KIBANA_DIR" + }, + { + "type": "file", + "location": "$DEV_DIR" + }, + { + "type": "file", + "location": "$TEAM_DIR" + } + ] +} +EOF + +cd "$DOCS_DIR" +nvm install + +if ! which yarn; then + npm install -g yarn +fi + +yarn + +if [[ ! -d .docsmobile ]]; then + yarn init-docs +fi + +if [[ "${1:-}" ]]; then + yarn "$@" +else + yarn dev +fi From e353c84d525cc8ae04a31b1c8492b2583c105101 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 20 May 2022 14:10:53 -0400 Subject: [PATCH 2/4] Detect https vs ssh clone, add yarn command --- package.json | 1 + scripts/dev_docs.sh | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 2d3009b7b70997..cfacc513594f72 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", "debug": "node --nolazy --inspect scripts/kibana --dev", "debug-break": "node --nolazy --inspect-brk scripts/kibana --dev", + "dev-docs": "scripts/dev_docs.sh", "docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept", "es": "node scripts/es", "preinstall": "node ./preinstall_check", diff --git a/scripts/dev_docs.sh b/scripts/dev_docs.sh index 802f8ce5c0788f..33a99830f17d28 100755 --- a/scripts/dev_docs.sh +++ b/scripts/dev_docs.sh @@ -12,22 +12,27 @@ DOCS_DIR="$WORKSPACE/docs.elastic.dev" DEV_DIR="$WORKSPACE/dev" TEAM_DIR="$WORKSPACE/kibana-team" +cd "$KIBANA_DIR" +origin=$(git remote get-url origin || true) +GIT_PREFIX="git@github.com:" +if [[ "$origin" == "https"* ]]; then + GIT_PREFIX="https://github.com/" +fi + mkdir -p "$WORKSPACE" cd "$WORKSPACE" -if ! which nvm; then - if [[ ! -d "$NVM_DIR" ]]; then - echo "Installing a separate copy of nvm" - git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" - cd "$NVM_DIR" - git checkout "$(git describe --abbrev=0 --tags --match "v[0-9]*" "$(git rev-list --tags --max-count=1)")" - fi - source "$NVM_DIR/nvm.sh" +if [[ ! -d "$NVM_DIR" ]]; then + echo "Installing a separate copy of nvm" + git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" + cd "$NVM_DIR" + git checkout "$(git describe --abbrev=0 --tags --match "v[0-9]*" "$(git rev-list --tags --max-count=1)")" fi +source "$NVM_DIR/nvm.sh" if [[ ! -d "$DOCS_DIR" ]]; then echo "Cloning docs.elastic.dev repo..." - git clone --depth 1 git@github.com:elastic/docs.elastic.dev.git # TODO auto-detect ssh vs https + git clone --depth 1 "${GIT_PREFIX}elastic/docs.elastic.dev.git" else cd "$DOCS_DIR" git pull @@ -36,7 +41,7 @@ fi if [[ ! -d "$DEV_DIR" ]]; then echo "Cloning dev repo..." - git clone --depth 1 git@github.com:elastic/dev.git + git clone --depth 1 "${GIT_PREFIX}elastic/dev.git" else cd "$DEV_DIR" git pull @@ -45,7 +50,7 @@ fi if [[ ! -d "$TEAM_DIR" ]]; then echo "Cloning kibana-team repo..." - git clone --depth 1 git@github.com:elastic/kibana-team.git # TODO auto-detect ssh vs https + git clone --depth 1 "${GIT_PREFIX}elastic/kibana-team.git" else cd "$TEAM_DIR" git pull From d90739fef8d334a9b61228cfa3e68e5a873848ad Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 20 May 2022 14:22:53 -0400 Subject: [PATCH 3/4] Clean up logs and add log for location of docs project --- scripts/dev_docs.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/dev_docs.sh b/scripts/dev_docs.sh index 33a99830f17d28..8e6f10a6032472 100755 --- a/scripts/dev_docs.sh +++ b/scripts/dev_docs.sh @@ -36,7 +36,7 @@ if [[ ! -d "$DOCS_DIR" ]]; then else cd "$DOCS_DIR" git pull - cd - + cd "$WORKSPACE" fi if [[ ! -d "$DEV_DIR" ]]; then @@ -45,7 +45,7 @@ if [[ ! -d "$DEV_DIR" ]]; then else cd "$DEV_DIR" git pull - cd - + cd "$WORKSPACE" fi if [[ ! -d "$TEAM_DIR" ]]; then @@ -54,7 +54,7 @@ if [[ ! -d "$TEAM_DIR" ]]; then else cd "$TEAM_DIR" git pull - cd - + cd "$WORKSPACE" fi # The minimum sources required to build kibana docs @@ -90,6 +90,11 @@ if [[ ! -d .docsmobile ]]; then yarn init-docs fi +echo "" +echo "The docs.elastic.dev project is located at:" +echo "$DOCS_DIR" +echo "" + if [[ "${1:-}" ]]; then yarn "$@" else From 454cf2966e06f64e67526c07d121237d3892a271 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Fri, 20 May 2022 15:54:07 -0400 Subject: [PATCH 4/4] Working dir fix --- scripts/dev_docs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/dev_docs.sh b/scripts/dev_docs.sh index 8e6f10a6032472..55d8f4d51e8dcf 100755 --- a/scripts/dev_docs.sh +++ b/scripts/dev_docs.sh @@ -27,6 +27,7 @@ if [[ ! -d "$NVM_DIR" ]]; then git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" cd "$NVM_DIR" git checkout "$(git describe --abbrev=0 --tags --match "v[0-9]*" "$(git rev-list --tags --max-count=1)")" + cd "$WORKSPACE" fi source "$NVM_DIR/nvm.sh"