Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
<Tabs groupId="vsx">
<TabItem value="vscode" label="VSCode">

```bash
pnpm -F cursorless-vscode install-local
```

</TabItem>
<TabItem value="vscodium" label="VSCodium">

```bash
pnpm -F cursorless-vscode install-local codium
```

</TabItem>
</Tabs>

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.

Expand All @@ -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
```
<Tabs groupId="vsx">
<TabItem value="vscode" label="VSCode">

```bash
pnpm -F cursorless-vscode install-from-pr 1281
```

</TabItem>
<TabItem value="vscodium" label="VSCodium">

```bash
pnpm -F cursorless-vscode install-from-pr 1281 codium
```

</TabItem>
</Tabs>

To uninstall the local build and revert to production cursorless, run the following command:

```bash
pnpm -F cursorless-vscode uninstall-local
```
<Tabs groupId="vsx">
<TabItem value="vscode" label="VSCode">

```bash
pnpm -F cursorless-vscode uninstall-local
```

</TabItem>
<TabItem value="vscodium" label="VSCodium">

```bash
pnpm -F cursorless-vscode uninstall-local codium
```

</TabItem>
</Tabs>

## Regular manual maintenance tasks

Expand Down
43 changes: 31 additions & 12 deletions packages/cursorless-vscode/scripts/install-from-pr.sh
Original file line number Diff line number Diff line change
@@ -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 <pr-number>"
# Ensure we have a variable at $1 (the pr number)
if [ -z "$1" ]; then
echo "Usage: install-from-pr $1 <pr-number> $2 <optional-cli-name>" # I'm sure there's a better way to specifiy this argument is optional than this but idk what it is
exit 1
fi

Expand All @@ -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"
Expand All @@ -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"
21 changes: 16 additions & 5 deletions packages/cursorless-vscode/scripts/install-local.sh
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"
23 changes: 17 additions & 6 deletions packages/cursorless-vscode/scripts/uninstall-local.sh
Original file line number Diff line number Diff line change
@@ -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"
Loading