aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ovsx_package_last_published_version8
-rwxr-xr-xbin/ovsx_publish_all_packages19
-rwxr-xr-xbin/ovsx_publish_package_when_outdated20
-rwxr-xr-xbin/vsce_package_last_published_version9
-rwxr-xr-xbin/vsce_publish_all_packages14
-rwxr-xr-xbin/vsce_publish_package_when_outdated22
6 files changed, 92 insertions, 0 deletions
diff --git a/bin/ovsx_package_last_published_version b/bin/ovsx_package_last_published_version
new file mode 100755
index 0000000..80c25c2
--- /dev/null
+++ b/bin/ovsx_package_last_published_version
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+set -e
+
+PUBLISHER=$1
+PACKAGE_NAME=$2
+
+(npx ovsx get --metadata "${PUBLISHER}.${PACKAGE_NAME}" || echo '{"version":"not yet published"}') |
+ jq -r .version
diff --git a/bin/ovsx_publish_all_packages b/bin/ovsx_publish_all_packages
new file mode 100755
index 0000000..42701f9
--- /dev/null
+++ b/bin/ovsx_publish_all_packages
@@ -0,0 +1,19 @@
+#!/usr/bin/env sh
+
+# 2021-08-28:
+# publishing an extension package with at least one unpublished extension fails
+# most of the packaged extensions are not published in the Open VSX registry
+# let's fail silently =(
+# set -e
+
+PATH_TO_THIS_SCRIPT=$(realpath "$0")
+BIN_DIR=$(dirname "${PATH_TO_THIS_SCRIPT}")
+ROOT_DIR=$(dirname "${BIN_DIR}")
+
+for PACKAGE in "${ROOT_DIR}/extensions/"*; do
+ cd "${PACKAGE}"
+
+ ovsx_publish_package_when_outdated
+
+ cd "${ROOT_DIR}"
+done
diff --git a/bin/ovsx_publish_package_when_outdated b/bin/ovsx_publish_package_when_outdated
new file mode 100755
index 0000000..68280ba
--- /dev/null
+++ b/bin/ovsx_publish_package_when_outdated
@@ -0,0 +1,20 @@
+#!/usr/bin/env sh
+set -e
+
+PACKAGE_LOCAL_VERSION=$(node --print "require('./package.json').version")
+PUBLISHER=$(node --print "require('./package.json').publisher")
+PACKAGE_NAME=$(node --print "require('./package.json').name")
+
+PACKAGE_LAST_PUBLISHED_VERSION=$(ovsx_package_last_published_version "${PUBLISHER}" "${PACKAGE_NAME}")
+
+echo "${PUBLISHER}.${PACKAGE_NAME}"
+echo "Package local version: ${PACKAGE_LOCAL_VERSION}"
+echo "Package last published version: ${PACKAGE_LAST_PUBLISHED_VERSION}"
+
+if [ "${PACKAGE_LAST_PUBLISHED_VERSION}" != "${PACKAGE_LOCAL_VERSION}" ]; then
+ echo "Package is outdated"
+ echo "Publishing..."
+ npx ovsx publish
+else
+ echo "Package is up-to-date"
+fi
diff --git a/bin/vsce_package_last_published_version b/bin/vsce_package_last_published_version
new file mode 100755
index 0000000..c371b7d
--- /dev/null
+++ b/bin/vsce_package_last_published_version
@@ -0,0 +1,9 @@
+#!/usr/bin/env sh
+set -e
+
+PUBLISHER=$1
+PACKAGE_NAME=$2
+
+npx vsce show "${PUBLISHER}.${PACKAGE_NAME}" |
+ grep -E -o "Version:\s+(\S+)" |
+ sed -r "s/Version:\s+(\S+)/\1/"
diff --git a/bin/vsce_publish_all_packages b/bin/vsce_publish_all_packages
new file mode 100755
index 0000000..44ef557
--- /dev/null
+++ b/bin/vsce_publish_all_packages
@@ -0,0 +1,14 @@
+#!/usr/bin/env sh
+set -e
+
+PATH_TO_THIS_SCRIPT=$(realpath "$0")
+BIN_DIR=$(dirname "${PATH_TO_THIS_SCRIPT}")
+ROOT_DIR=$(dirname "${BIN_DIR}")
+
+for PACKAGE in "${ROOT_DIR}/extensions/"*; do
+ cd "${PACKAGE}"
+
+ vsce_publish_package_when_outdated
+
+ cd "${ROOT_DIR}"
+done
diff --git a/bin/vsce_publish_package_when_outdated b/bin/vsce_publish_package_when_outdated
new file mode 100755
index 0000000..4d428c9
--- /dev/null
+++ b/bin/vsce_publish_package_when_outdated
@@ -0,0 +1,22 @@
+#!/usr/bin/env sh
+set -e
+
+PACKAGE_LOCAL_VERSION=$(node --print "require('./package.json').version")
+PUBLISHER=$(node --print "require('./package.json').publisher")
+PACKAGE_NAME=$(node --print "require('./package.json').name")
+
+PACKAGE_LAST_PUBLISHED_VERSION=$(vsce_package_last_published_version "${PUBLISHER}" "${PACKAGE_NAME}")
+
+echo "${PUBLISHER}.${PACKAGE_NAME}"
+echo "Package local version: ${PACKAGE_LOCAL_VERSION}"
+echo "Package last published version: ${PACKAGE_LAST_PUBLISHED_VERSION}"
+
+if [ "${PACKAGE_LAST_PUBLISHED_VERSION}" != "${PACKAGE_LOCAL_VERSION}" ]; then
+ echo "Package is outdated"
+ echo "Package contains"
+ npx vsce ls
+ echo "Publishing..."
+ npx vsce publish
+else
+ echo "Package is up-to-date"
+fi