diff --git a/packages/cursorless-org-docs/src/docs/contributing/CONTRIBUTING.mdx b/packages/cursorless-org-docs/src/docs/contributing/CONTRIBUTING.mdx index 138dddc06e..47ab04de71 100644 --- a/packages/cursorless-org-docs/src/docs/contributing/CONTRIBUTING.mdx +++ b/packages/cursorless-org-docs/src/docs/contributing/CONTRIBUTING.mdx @@ -190,9 +190,22 @@ Once you have your package then you can install it into the sandbox using the fo You can install a local build of the Cursorless extension by running the following command: -```bash -pnpm -F cursorless-vscode install-local -``` + + + + ```bash + pnpm -F cursorless-vscode install-local + ``` + + + + + ```bash + pnpm -F cursorless-vscode install-local codium + ``` + + + This will bundle and install a local version of Cursorless, uninstalling production Cursorless first and using a special extension id to break the update chain. @@ -201,15 +214,41 @@ use `install-from-pr` instead, and pass a PR number to the command and it will download and install the artifact from the PR build. This requires the [`gh` cli](https://cli.github.com/). For example: -```bash -pnpm -F cursorless-vscode install-from-pr 1281 -``` + + + + ```bash + pnpm -F cursorless-vscode install-from-pr 1281 + ``` + + + + + ```bash + pnpm -F cursorless-vscode install-from-pr 1281 codium + ``` + + + To uninstall the local build and revert to production cursorless, run the following command: -```bash -pnpm -F cursorless-vscode uninstall-local -``` + + + + ```bash + pnpm -F cursorless-vscode uninstall-local + ``` + + + + + ```bash + pnpm -F cursorless-vscode uninstall-local codium + ``` + + + ## Regular manual maintenance tasks diff --git a/packages/cursorless-vscode/scripts/install-from-pr.sh b/packages/cursorless-vscode/scripts/install-from-pr.sh index 097baa4ef5..f74ab10a61 100755 --- a/packages/cursorless-vscode/scripts/install-from-pr.sh +++ b/packages/cursorless-vscode/scripts/install-from-pr.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash -set -euo pipefail +set -eo pipefail # Installs a version of Cursorless from a PR branch, uninstalling production # Cursorless first and using a special extension id to break update chain. # Requires gh cli to be installed (https://cli.github.com/). -# Ensure we have a PR number -if [ $# -ne 1 ]; then - echo "Usage: $0 " +# Ensure we have a variable at $1 (the pr number) +if [ -z "$1" ]; then + echo "Usage: install-from-pr $1 $2 " # I'm sure there's a better way to specifiy this argument is optional than this but idk what it is exit 1 fi @@ -16,10 +16,13 @@ if ! command -v gh &>/dev/null; then exit 1 fi -# Ensure VSCode 'code' command is installed -if ! command -v code &>/dev/null; then - echo "VSCode 'code' command not found; see https://code.visualstudio.com/docs/editor/command-line#_launching-from-command-line" - exit 1 +# Skip VSCode cli check if a cli tool name is specified by the user +if [ -z "$2" ]; then + # Ensure VSCode 'code' command is installed + if ! command -v code &>/dev/null; then + echo "VSCode 'code' command not found; see https://code.visualstudio.com/docs/editor/command-line#_launching-from-command-line" + exit 1 + fi fi pr_number="$1" @@ -46,11 +49,27 @@ trap finish EXIT # 3. Download extension vsix gh run download "$check_number" --repo "$repo" --name vsix --dir "$tmpdir" -# 4. Uninstall production cursorless -code --uninstall-extension pokey.cursorless || echo "Cursorless not currently installed" +if [ -z "$2" ]; then + # 4. Uninstall production cursorless + code --uninstall-extension pokey.cursorless || echo "Cursorless not currently installed" + + # 5. Install downloaded extension + code --install-extension "$tmpdir/cursorless-development.vsix" --force +else + # We need to build the above two commands in an array due to having the cli tool passed as an argument to this script + # See https://unix.stackexchange.com/a/444949 for why using eval for this is a bad idea -# 5. Install downloaded extension -code --install-extension "$tmpdir/cursorless-development.vsix" --force + # 4. Uninstall production cursorless + cmd_uninstall=($2) + cmd_uninstall+=(--uninstall-extension pokey.cursorless \|\| echo "Cursorless not currently installed") + echo ${cmd_uninstall[@]} + "${cmd_uninstall[@]}" + + # 5. Install downloaded extension + cmd_from_pr=($2) + cmd_from_pr+=(--install-extension "$tmpdir/cursorless-development.vsix" --force) + "${cmd_from_pr[@]}" +fi echo -e "\e[1;32mPlease restart VSCode\e[0m" echo "To uninstall and revert to production Cursorless, run the adjacent uninstall-local.sh" diff --git a/packages/cursorless-vscode/scripts/install-local.sh b/packages/cursorless-vscode/scripts/install-local.sh index d8f2c8c9cf..6eb79f3fe2 100755 --- a/packages/cursorless-vscode/scripts/install-local.sh +++ b/packages/cursorless-vscode/scripts/install-local.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -euo pipefail +set -eo pipefail # Bundles and installs a local version of Cursorless, uninstalling production # Cursorless first and using a special extension id to break update chain @@ -13,11 +13,22 @@ pnpm populate-dist --local-install cd dist vsce package -o ../bundle.vsix -# 3. Uninstall production cursorless -code --uninstall-extension pokey.cursorless || echo "Cursorless not currently installed" +if [ -z "$1" ]; then + # 3. Uninstall production cursorless + code --uninstall-extension pokey.cursorless || echo "Cursorless not currently installed" -# 4. Install local Cursorless -code --install-extension ../bundle.vsix --force + # 4. Install local Cursorless + code --install-extension ../bundle.vsix --force +else + # Construct above commands in arrays to use specified cli tool name (see comments in ./install-from-pr.sh at line 59) + cmd_uninstall=($1) + cmd_uninstall+=(--uninstall-extension pokey.cursorless \|\| echo "Cursorless not currently installed") + "${cmd_uninstall[@]}" + + cmd_install_local=($1) + cmd_install_local+=(--install-extension ../bundle.vsix --force) + "${cmd_install_local[@]}" +fi echo -e "\e[1;32mPlease restart VSCode\e[0m" echo "To uninstall and revert to production Cursorless, run the adjacent uninstall-local.sh" diff --git a/packages/cursorless-vscode/scripts/uninstall-local.sh b/packages/cursorless-vscode/scripts/uninstall-local.sh index b3bcecef45..b0f5f02583 100755 --- a/packages/cursorless-vscode/scripts/uninstall-local.sh +++ b/packages/cursorless-vscode/scripts/uninstall-local.sh @@ -1,13 +1,24 @@ #!/usr/bin/env bash -set -euo pipefail +set -eo pipefail # Switch back to production Cursorless extension locally after having run -# ./install-local.sh +# ./install-local.sh or ./install-from-pr.sh -# 1. Uninstall local cursorless -code --uninstall-extension pokey.cursorless-development || echo "Cursorless development version not currently installed" +if [ -z "$1" ]; then + # 1. Uninstall local cursorless + code --uninstall-extension pokey.cursorless-development || echo "Cursorless development version not currently installed" -# 2. Install production Cursorless -code --install-extension pokey.cursorless + # 2. Install production Cursorless + code --install-extension pokey.cursorless +else + # Construct above commands in arrays to use specified cli tool name (see comments in ./install-from-pr.sh at line 59) + cmd_uninstall=($1) + cmd_uninstall+=(--uninstall-extension pokey.cursorless-development \|\| echo "Cursorless development version not currently installed") + "${cmd_uninstall[@]}" + + cmd_install_prod=($1) + cmd_install_prod+=(--install-extension pokey.cursorless) + "${cmd_install_prod[@]}" +fi echo -e "\e[1;32mPlease restart VSCode\e[0m"