-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add local plugin repo utility (#292)
* add local plugin repo utility * add plugin id arg
- Loading branch information
Showing
2 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Running a local plugin repository | ||
For more info read: https://plugins.jetbrains.com/docs/intellij/update-plugins-format.html | ||
|
||
### Why? | ||
To test a flow which updates the plugin to a new version without actually deploying versions to the marketplace. | ||
|
||
### How? | ||
The `run-local-repo.sh` takes a locally built version and creates a web server that serves this version in a format that JetBrains acknowledges. | ||
|
||
#### Prerequisites | ||
1. Install `ngrok` and `http-server`: | ||
```bash | ||
npm i -g ngrok http-server | ||
``` | ||
|
||
#### Instructions | ||
1. Run ngrok, in order to have an https url (IJ requires it): | ||
```bash | ||
ngrok http 8080 | ||
``` | ||
2. Edit `build.gradle`: Set the version to something higher than what you intend to run, in order for IJ to consider this plugin an "update" - Edit this line: | ||
```groovy | ||
version project.hasProperty('externalVersion') ? project.externalVersion : '<your-version>' | ||
``` | ||
3. **In this directory**, run the script like so: | ||
```bash | ||
./run-local-repo.sh -b -u <ngrok https url> | ||
``` | ||
(You can drop `-b` if you already have a plugin built in `../build/distributions`). | ||
|
||
4. In the output of this command you'll find a line that goes like so: | ||
``` | ||
>>> This is the url you need to add as a repository: <url> | ||
``` | ||
Copy this `url`. | ||
5. Revert the changes to `build.gradle`. | ||
6. Run the `runIde` gradle task. | ||
7. In the debugger sandbox, got to `Settings -> Plugins -> <Settings icon> -> Manage Plugin Repositories...`. Click the `+` sign - Copy the `url` there. | ||
And that's it! Now You'll see that there's an available update from the local repository with the version you built. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#! /bin/bash | ||
|
||
set -e | ||
|
||
xml_file_name=updatePlugins.xml | ||
build_plugin=false | ||
|
||
while getopts :u:i:b flag; do | ||
case "${flag}" in | ||
u) url=${OPTARG} ;; | ||
b) build_plugin=true ;; | ||
i) plugin_id=${OPTARG} ;; | ||
*) ;; | ||
esac | ||
done | ||
|
||
if [ "$build_plugin" == "true" ]; then | ||
echo ">>> Building the plugin..." | ||
cd .. | ||
./gradlew buildPlugin | ||
cd - | ||
fi | ||
if [ -z "$plugin_id" ]; then | ||
plugin_id="com.tabnine.TabNine" | ||
fi | ||
if [ -z "$url" ]; then | ||
echo "'-u' is required" | ||
exit | ||
fi | ||
|
||
cp ../build/distributions/*TabNine*.zip . | ||
plugin_file="$(basename -- "$(ls -al ./*TabNine*.zip)")" | ||
plugin_version="$(echo "$plugin_file" | grep -o -P '(?<=-).*(?=.zip)')" | ||
|
||
xml_data="<plugins><plugin id=\"$plugin_id\" url=\"$url/$plugin_file\" version=\"$plugin_version\"/></plugins>" | ||
|
||
printf ">>> generating %s with the following data: \"%s\"\n" "$xml_file_name" "$xml_data" | ||
printf "\n$(tput setaf 2)>>> This is the url you need to add as a repository: %s$(tput sgr0)\n\n" "$url/$xml_file_name" | ||
|
||
echo "$xml_data" >$xml_file_name | ||
|
||
echo ">>> Running http-server..." | ||
http-server |