Skip to content
Merged
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
16 changes: 5 additions & 11 deletions install/bash/examples.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NC="${NC:-\033[0m}"

# Examples configuration
EXAMPLES_FOLDER_NAME="plainlang-examples"
EXAMPLES_DOWNLOAD_URL="https://github.com/Codeplain-ai/plainlang-examples/archive/refs/tags/0.1.zip"
EXAMPLES_DOWNLOAD_URL="https://codeplain.ai/examples/unix"

# Show current directory and ask for extraction path
CURRENT_DIR=$(pwd)
Expand Down Expand Up @@ -55,18 +55,12 @@ if [ "$SKIP_DOWNLOAD" = false ]; then
if [ $? -eq 0 ] && [ -s "$TEMP_ZIP" ]; then
echo -e " ${GRAY}Extracting to ${EXTRACT_PATH}...${NC}"

# Extract the zip file
unzip -q -o "$TEMP_ZIP" -d "$EXTRACT_PATH" 2>/dev/null
# Extract the zip file (contents are at the zip root, so extract into the target folder)
EXTRACTED_DIR="${EXTRACT_PATH}/${EXAMPLES_FOLDER_NAME}"
rm -rf "$EXTRACTED_DIR" 2>/dev/null # Remove existing if present
unzip -q -o "$TEMP_ZIP" -d "$EXTRACTED_DIR" 2>/dev/null

if [ $? -eq 0 ]; then
# Find and rename extracted directory to remove version number
EXTRACTED_DIR="${EXTRACT_PATH}/${EXAMPLES_FOLDER_NAME}"
VERSIONED_DIR=$(find "$EXTRACT_PATH" -maxdepth 1 -type d -name "${EXAMPLES_FOLDER_NAME}-*" | head -1)
if [ -n "$VERSIONED_DIR" ]; then
rm -rf "$EXTRACTED_DIR" 2>/dev/null # Remove existing if present
mv "$VERSIONED_DIR" "$EXTRACTED_DIR"
fi

# Remove the .gitignore file from the root of the extracted directory
if [ -f "${EXTRACTED_DIR}/.gitignore" ]; then
rm -f "${EXTRACTED_DIR}/.gitignore"
Expand Down
16 changes: 5 additions & 11 deletions install/powershell/examples.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (-not $env:NC) { $NC = "$([char]27)[0m" } else

# Examples configuration
$EXAMPLES_FOLDER_NAME = "plainlang-examples"
$EXAMPLES_DOWNLOAD_URL = "https://github.com/Codeplain-ai/plainlang-examples/archive/refs/tags/0.1.zip"
$EXAMPLES_DOWNLOAD_URL = "https://codeplain.ai/examples/windows"

# Show current directory and ask for extraction path
$CURRENT_DIR = Get-Location
Expand Down Expand Up @@ -58,18 +58,12 @@ if (-not $SKIP_DOWNLOAD) {
Write-Host " ${GRAY}Extracting to ${EXTRACT_PATH}...${NC}"

try {
Expand-Archive -Path $TEMP_ZIP -DestinationPath $EXTRACT_PATH -Force

# Find and rename extracted directory to remove version number
# Extract the zip file (contents are at the zip root, so extract into the target folder)
$EXTRACTED_DIR = Join-Path $EXTRACT_PATH $EXAMPLES_FOLDER_NAME
$VERSIONED_DIR = Get-ChildItem -Path $EXTRACT_PATH -Directory -Filter "${EXAMPLES_FOLDER_NAME}-*" | Select-Object -First 1

if ($VERSIONED_DIR) {
if (Test-Path $EXTRACTED_DIR) {
Remove-Item -Path $EXTRACTED_DIR -Recurse -Force -ErrorAction SilentlyContinue
}
Rename-Item -Path $VERSIONED_DIR.FullName -NewName $EXAMPLES_FOLDER_NAME
if (Test-Path $EXTRACTED_DIR) {
Remove-Item -Path $EXTRACTED_DIR -Recurse -Force -ErrorAction SilentlyContinue
}
Expand-Archive -Path $TEMP_ZIP -DestinationPath $EXTRACTED_DIR -Force

# Remove the .gitignore file from the root of the extracted directory
$GITIGNORE_PATH = Join-Path $EXTRACTED_DIR ".gitignore"
Expand Down
Loading