Skip to content

Commit 6140ed9

Browse files
Update make scripts (#48)
# Description This pull request refactors the `deploy` and `cleanup` scripts for managing snap-in packages and versions. The main change is the removal of sourcing `shared.sh` file, which is no longer in use, and the `$DR_OPTS` variable, which was previously used to pass additional options to the `devrev` CLI commands. # DevRev issue https://app.devrev.ai/devrev/works/ISS-203111 # Documentation PR devrev/fern-api-docs#293 Preview: https://devrev-preview-b36b1ce8-1f2b-4b9e-b71b-00e4a027cfc0.docs.buildwithfern.com/airdrop/deploy-to-organization
1 parent 70c693b commit 6140ed9

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
@patricijabrecko @radovan-jorgic @devrev/airdrop
1+
@patricijabrecko @radovanjorgic @gasperzgonec @devrev/airdrop
2+
3+
# Test folder ownership
4+
code/test/ @navneel99

code/scripts/cleanup.sh

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
#!/usr/bin/env bash
22

3-
source "$(dirname "$0")"/shared.sh
4-
5-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
6-
PACKAGES="$(devrev snap_in_package list $DR_OPTS)"
3+
# Get all snap-in packages
4+
PACKAGES="$(devrev snap_in_package list)"
75
if [ -z "$PACKAGES" ]; then
86
echo "No snap-in packages found"
97
exit 0
108
fi
119

10+
# Get the first snap-in package ID
1211
PACKAGE_ID="$(jq -csr '.[0].id' <<< "$PACKAGES")"
1312
if [ -z "$PACKAGE_ID" ]; then
1413
echo "Failed to get snap-in package ID"
1514
exit 1
1615
fi
1716

18-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
19-
VERSIONS="$(devrev snap_in_version list $DR_OPTS --package "$PACKAGE_ID")"
17+
# Get all snap-in versions for the first package
18+
VERSIONS="$(devrev snap_in_version list --package "$PACKAGE_ID")"
2019
if [ -z "$VERSIONS" ]; then
2120
echo "No snap-in versions found"
2221
else
23-
VERSION_ID="$(jq -csr '.[0].id' <<< "$VERSIONS")"
24-
if [ -n "${VERSION_ID}" ]; then
25-
echo "Deleting snap-in version ${VERSION_ID}"
22+
# Get the first snap-in version ID
23+
VERSION_ID="$(jq -csr '.[0].id' <<< "$VERSIONS")"
24+
if [ -n "${VERSION_ID}" ]; then
25+
echo "Deleting snap-in version ${VERSION_ID}"
2626

27-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
28-
devrev snap_in_version delete-one $DR_OPTS "${VERSION_ID}" || exit 1
29-
fi
27+
devrev snap_in_version delete-one "${VERSION_ID}" || exit 1
28+
fi
3029
fi
3130

3231
echo "Deleting snap-in package ${PACKAGE_ID}"
3332

34-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
35-
devrev snap_in_package delete-one $DR_OPTS "${PACKAGE_ID}"
33+
devrev snap_in_package delete-one "${PACKAGE_ID}"

code/scripts/deploy.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@
22

33
echo "Creating Snap-in version..."
44

5-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
6-
VER_OUTPUT=$(devrev snap_in_version create-one $DR_OPTS \
5+
# Create a new snap-in version
6+
VER_OUTPUT=$(devrev snap_in_version create-one \
77
--path "." \
88
--create-package | tee /dev/tty)
99

10+
# Filter the output to get the snap-in version ID
1011
FILTERED_OUTPUT=$(grep "snap_in_version" <<<"$VER_OUTPUT" | grep -o '{.*}')
1112

1213
# Check if DevRev CLI returned an error (error messages contain the field 'message')
1314
if ! jq '.message' <<<"$FILTERED_OUTPUT" | grep null >/dev/null; then
1415
exit 1
1516
fi
1617

18+
# Get the snap-in version ID
1719
VERSION_ID=$(jq -r '.snap_in_version.id' <<<"$FILTERED_OUTPUT")
1820

1921
echo "Waiting 10 seconds for Snap-in version to be ready..."
2022
sleep 10
2123

24+
# Wait for the snap-in version to be ready
2225
while :; do
23-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
24-
VER_OUTPUT2=$(devrev snap_in_version show $DR_OPTS "$VERSION_ID")
26+
VER_OUTPUT2=$(devrev snap_in_version show "$VERSION_ID")
2527
STATE=$(jq -r '.snap_in_version.state' <<<"$VER_OUTPUT2")
2628
if [[ "$STATE" == "build_failed" ]] || [[ "$STATE" == "deployment_failed" ]]; then
2729
echo "Snap-in version build/deployment failed: $(jq -r '.snap_in_version.failure_reason' <<<"$VER_OUTPUT2")"
2830
exit 1
2931
elif [[ "$STATE" == "ready" ]]; then
30-
3132
break
3233
else
3334
echo "Snap-in version's state is $STATE, waiting 10 seconds..."
@@ -37,8 +38,8 @@ done
3738

3839
echo "Creating Snap-in draft..."
3940

40-
# shellcheck disable=SC2086 # $DR_OPTS is intentionally split here
41-
DRAFT_OUTPUT=$(devrev snap_in draft $DR_OPTS --snap_in_version "$VERSION_ID")
41+
# Create a new snap-in draft
42+
DRAFT_OUTPUT=$(devrev snap_in draft --snap_in_version "$VERSION_ID")
4243
jq <<<"$DRAFT_OUTPUT"
4344
echo "Snap-in draft created. Please go to the Snap-ins page in the DevRev UI to complete the installation process."
4445

0 commit comments

Comments
 (0)