Skip to content

Instantly share code, notes, and snippets.

@crcdng
Last active October 6, 2024 22:46
Show Gist options
  • Select an option

  • Save crcdng/5d21f0ba770a8a68aecc86e319ef6aa3 to your computer and use it in GitHub Desktop.

Select an option

Save crcdng/5d21f0ba770a8a68aecc86e319ef6aa3 to your computer and use it in GitHub Desktop.

Revisions

  1. crcdng revised this gist Oct 6, 2024. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions prepare_itch.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    #!/bin/sh

    # shell script to build and prepare a Flutter/Flame web project for itch.io
    # builds and prepares a Flutter/Flame web build for itch.io
    # tested on Mac
    # added: create output dir if it does not exist
    # added: mitigate bug where keyboard keys are working fine locally but aren’t recognized on itch.io.
    # after uploading set the dimensions in the "Embed options" section on itch.io

    # set these parameters before running
    @@ -10,11 +12,17 @@ PROJECT_DIR='FULL PATH TO THE FLUTTER DIRECTORY OF YOUR PROJECT'
    TEMP_BUILD_DIR='FULL PATH TO A TEMPORARY DIRECTORY (WILL BE CREATED AND DELETED AT THE END)'
    OUTPUT_DIR='FULL PATH TO THE DIRECTORY WHERE THE ZIP FILE READY FOR UPLOAD TO ITCH.IO WILL BE PUT'

    if [ ! -d "$OUTPUT_DIR" ]; then
    echo "$OUTPUT_DIR does not exist. creating it"
    mkdir "$OUTPUT_DIR"
    fi

    cd $PROJECT_DIR &&
    flutter build web &&
    cp -R "${PROJECT_DIR}/build/web" $TEMP_BUILD_DIR &&
    sleep 1 && # recently breaks without waiting a bit after building
    sleep 1 &&
    cd $TEMP_BUILD_DIR &&
    sed -i '' 's/<base href="\/">//g' index.html &&
    zip -vr "${OUTPUT_DIR}/${PROJECT_NAME}_$(date +%Y%m%d-%H%M%S).zip" ./ -x "*.DS_Store" &&
    rm -r $TEMP_BUILD_DIR
    sed -i '' 's/<body>/<body>\n<script>window.onclick = function () { window.focus(); }<\/script>/g' index.html &&
    zip -vr "${OUTPUT_DIR}/${PROJECT_NAME}_$(date +%Y%m%d-%H%M%S).zip" ./ -x "*.DS_Store"
    rm -r $TEMP_BUILD_DIR
  2. crcdng revised this gist May 28, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions prepare_itch.sh
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ OUTPUT_DIR='FULL PATH TO THE DIRECTORY WHERE THE ZIP FILE READY FOR UPLOAD TO IT
    cd $PROJECT_DIR &&
    flutter build web &&
    cp -R "${PROJECT_DIR}/build/web" $TEMP_BUILD_DIR &&
    sleep 1 && # recently breaks without waiting a bit after building
    cd $TEMP_BUILD_DIR &&
    sed -i '' 's/<base href="\/">//g' index.html &&
    zip -vr "${OUTPUT_DIR}/${PROJECT_NAME}_$(date +%Y%m%d-%H%M%S).zip" ./ -x "*.DS_Store" &&
  3. crcdng revised this gist May 9, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions prepare_itch.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@

    # shell script to build and prepare a Flutter/Flame web project for itch.io
    # tested on Mac
    # after uploading set the dimensions in the "Embed options" section on itch.io

    # set these parameters before running
    PROJECT_NAME='NAME'
  4. crcdng revised this gist May 9, 2024. No changes.
  5. crcdng renamed this gist May 9, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt → prepare_itch.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/sh

    # builds and prepares a Flutter/Flame web build for itch.io
    # shell script to build and prepare a Flutter/Flame web project for itch.io
    # tested on Mac

    # set these parameters before running
  6. crcdng revised this gist May 8, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    #!/bin/sh

    # builds and prepares a Flutter/Flame web build for itch.io
    # tested on Mac

    # set these parameters before running
    PROJECT_NAME='NAME'
  7. crcdng revised this gist May 8, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # set these parameters before running
    PROJECT_NAME='NAME'
    PROJECT_DIR='FULL PATH TO THE FLUTTER DIRECTORY OF YOUR PROJECT'
    TEMP_BUILD_DIR='FULL PATH TO A TEMPORARY DIRECTORY (TEMPORARY, WILL BE CREATED AND DELETED AT THE END)'
    TEMP_BUILD_DIR='FULL PATH TO A TEMPORARY DIRECTORY (WILL BE CREATED AND DELETED AT THE END)'
    OUTPUT_DIR='FULL PATH TO THE DIRECTORY WHERE THE ZIP FILE READY FOR UPLOAD TO ITCH.IO WILL BE PUT'

    cd $PROJECT_DIR &&
  8. crcdng revised this gist May 8, 2024. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,11 @@

    # builds and prepares a Flutter/Flame web build for itch.io

    PROJECT_NAME='ttt'
    PROJECT_DIR='/Users/m/root/dev/flutter/games/ggj/ttt'
    TEMP_BUILD_DIR='/Users/m/Desktop/ttt'
    OUTPUT_DIR='/Users/m/Desktop'
    # set these parameters before running
    PROJECT_NAME='NAME'
    PROJECT_DIR='FULL PATH TO THE FLUTTER DIRECTORY OF YOUR PROJECT'
    TEMP_BUILD_DIR='FULL PATH TO A TEMPORARY DIRECTORY (TEMPORARY, WILL BE CREATED AND DELETED AT THE END)'
    OUTPUT_DIR='FULL PATH TO THE DIRECTORY WHERE THE ZIP FILE READY FOR UPLOAD TO ITCH.IO WILL BE PUT'

    cd $PROJECT_DIR &&
    flutter build web &&
  9. crcdng created this gist May 8, 2024.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/sh

    # builds and prepares a Flutter/Flame web build for itch.io

    PROJECT_NAME='ttt'
    PROJECT_DIR='/Users/m/root/dev/flutter/games/ggj/ttt'
    TEMP_BUILD_DIR='/Users/m/Desktop/ttt'
    OUTPUT_DIR='/Users/m/Desktop'

    cd $PROJECT_DIR &&
    flutter build web &&
    cp -R "${PROJECT_DIR}/build/web" $TEMP_BUILD_DIR &&
    cd $TEMP_BUILD_DIR &&
    sed -i '' 's/<base href="\/">//g' index.html &&
    zip -vr "${OUTPUT_DIR}/${PROJECT_NAME}_$(date +%Y%m%d-%H%M%S).zip" ./ -x "*.DS_Store" &&
    rm -r $TEMP_BUILD_DIR