|
4 | 4 | set -e
|
5 | 5 |
|
6 | 6 | # Variables
|
7 |
| -ASSET_URL="https://cdn.zudoku.dev/release/docs.zip" |
| 7 | +ASSET_URL="https://github.com/zuplo/zudoku/archive/refs/heads/main.tar.gz" |
8 | 8 | DOWNLOAD_DIR="/tmp/zudoku_download"
|
9 | 9 | DEST_DIR="docs/dev-portal/zudoku"
|
10 | 10 |
|
| 11 | +# Function to log messages |
| 12 | +log() { |
| 13 | + echo "[INFO] $1" |
| 14 | +} |
| 15 | + |
11 | 16 | # Remove existing directories
|
12 |
| -rm -rf "$DOWNLOAD_DIR" |
13 |
| -rm -rf "$DEST_DIR" |
| 17 | +log "Removing existing directories..." |
| 18 | +rm -rf "$DOWNLOAD_DIR" "$DEST_DIR" |
14 | 19 |
|
15 | 20 | # Create download directory
|
| 21 | +log "Creating download directory..." |
16 | 22 | mkdir -p "$DOWNLOAD_DIR"
|
17 | 23 |
|
18 |
| -# Download the latest zip release |
19 |
| -ZIP_FILE="$DOWNLOAD_DIR/zudoku_docs.zip" |
20 |
| -echo "Downloading the latest release..." |
21 |
| -curl -L -o "$ZIP_FILE" "$ASSET_URL" |
| 24 | +# Download the latest tar.gz release |
| 25 | +TAR_FILE="$DOWNLOAD_DIR/zudoku_docs.tar.gz" |
| 26 | +log "Downloading the latest release..." |
| 27 | +curl -L -o "$TAR_FILE" "$ASSET_URL" |
22 | 28 |
|
23 |
| -# Extract the zip file |
24 |
| -echo "Extracting the contents..." |
25 |
| -unzip -q "$ZIP_FILE" -d "$DOWNLOAD_DIR/extracted" |
| 29 | +# Extract the tar.gz file |
| 30 | +log "Extracting the contents..." |
| 31 | +mkdir -p "$DOWNLOAD_DIR/extracted" |
| 32 | +tar -xzf "$TAR_FILE" -C "$DOWNLOAD_DIR/extracted" |
26 | 33 |
|
27 | 34 | # Find the docs folder in the extracted contents
|
28 | 35 | EXTRACTED_DIR=$(find "$DOWNLOAD_DIR/extracted" -mindepth 1 -maxdepth 1 -type d | head -n 1)
|
29 | 36 |
|
30 |
| -echo $EXTRACTED_DIR |
| 37 | +if [ -z "$EXTRACTED_DIR" ]; then |
| 38 | + log "Error: Unable to find extracted directory." |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | + |
| 42 | +log "Extracted directory: $EXTRACTED_DIR" |
31 | 43 |
|
32 |
| -if [ -d "$EXTRACTED_DIR/pages" ]; then |
33 |
| - echo "Copying 'pages' folder to $DEST_DIR..." |
| 44 | +if [ -d "$EXTRACTED_DIR/docs/pages" ]; then |
| 45 | + log "Copying 'pages' folder to $DEST_DIR..." |
34 | 46 | mkdir -p "$DEST_DIR"
|
35 |
| - cp -r "$EXTRACTED_DIR/pages"/* "$DEST_DIR" |
| 47 | + cp -r "$EXTRACTED_DIR/docs/pages/"* "$DEST_DIR" |
36 | 48 | else
|
37 |
| - echo "'pages' folder not found in the extracted contents." |
| 49 | + log "Error: 'pages' folder not found in the extracted contents." |
38 | 50 | exit 1
|
39 | 51 | fi
|
40 | 52 |
|
41 | 53 | # Clean up
|
42 |
| -echo "Cleaning up..." |
| 54 | +log "Cleaning up temporary files..." |
43 | 55 | rm -rf "$DOWNLOAD_DIR"
|
44 | 56 |
|
45 |
| -# Delete Docs we dont want |
| 57 | +# Delete unwanted docs |
| 58 | +log "Deleting unwanted docs..." |
46 | 59 | rm -rf "$DEST_DIR/deploy"
|
47 |
| -rm -rf "$DEST_DIR/deployment.md" |
48 |
| -rm -rf "$DEST_DIR/introduction.md" |
49 |
| -rm -rf "$DEST_DIR/app-quickstart.md" |
50 |
| -rm -rf "$DEST_DIR/html-quickstart.md" |
| 60 | +rm -f "$DEST_DIR/deployment.md" |
| 61 | +rm -f "$DEST_DIR/introduction.md" |
| 62 | +rm -f "$DEST_DIR/app-quickstart.md" |
| 63 | +rm -f "$DEST_DIR/html-quickstart.md" |
51 | 64 |
|
| 65 | +# Run the update script |
| 66 | +log "Running the update script..." |
52 | 67 | npx tsx ./scripts/update-zudoku-docs.mts
|
53 | 68 |
|
54 |
| -echo "Update complete! The 'docs' folder has been updated." |
| 69 | +log "Update complete! The 'docs' folder has been updated." |
0 commit comments