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
273 changes: 273 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
source <(direnv stdlib)

export WORKSPACE_EXT_ROOT_PATH="$HOME/@Dev/MakecodeArcade/@Extensions/@Daddy/"
export REPOS_ROOT_PATH="$HOME/@Dev/MakecodeArcade/@Extensions/@Daddy/@Repos/"
export WORKSPACE_PATH="$HOME/@Dev/MakecodeArcade/@Extensions/@Daddy/switchcase/"
export REPO_PATH="$HOME/@Dev/MakecodeArcade/@Extensions/@Daddy/@Repos/makecode-ext-switchcase/"

export EDITOR="code"

export REPO_REMOTE_URL="https://github.com/seriussoft/makecode-ext-switchcase.git"
export REPO_BRANCH_DEV="dev"
export REPO_BRANCH_DEV_LOCAL="dev-local-rpi400"

#
# Functions
#

# TODO: Create a localized shortcut for copyWSToRepo() and copyRepoToWS() that doesn't need any arguments

# Copy over code FROM workspace-directory [--ws] TO local-repo-directory [--repo]
copyWSToRepo() {

use_default_dirs_if_empty=0
use_default_dirs_only=0
same_directories_provided=0
run_simulation_without_sideeffects=0

while [[ $# -gt 0 ]]; do
case "$1" in
--help|-help|-h)
#echo "copyWSToRepo [--ws|-ws|w] {workspace_directory} [--repo|-repo|-r] {local_repo_directory} [--default|-default|-d] (will use the default values found int $WORKSPACE_DIR and $LOCAL_REPO_DIR) [--help|-help|-h] # Help flag forces an exit without running any of the script"
# FULL MANPAGES/Documentation on how to use this function and its flags properly printed to screen with the following function call...
showHelp_copyWSandRepo "copyWSToRepo"
return
;;
--ws|-ws|-w)
workspace_dir="$2"
shift 2
;;
--repo|-repo|-r)
repo_dir="$2"
shift 2
;;
--default|-default|-d)
use_default_dirs_if_empty=1
shift
;;
--ignoreargs|-ignoreargs|-i)
use_default_dirs_only=1
shift
;;
--same|-same|-s)
echo "Because you provided the --same flag (or derivative variant), no destructive or side-effect-producing code will be run. Instead, you will see what WOULD have run had you provided both directories and appropriate flags --ws && --repo..."
same_directories_provided=1
run_simulation_without_sideeffects=1
;;
*)
# invalid flag or argument; let's just shift the args[] and move on
shift
;;
esac
done

# indicates how many (0, 1, or 2) of the two directories are empty BEFORE all other flags are checked
empty_count_prework=0
# indicates how many (0, 1, or 2) of the two directories are empty AFTER all flags are checked
empty_count_postwork=0
# indicates no value was provided for ws if value > 0
ws_empty=0
# indicates no value was provided for repo if value > 0
repo_empty=0
# indicates EITHER --default OR --ignoreargs if value > 0
using_defaults=0

# indicate that any or non of the default flags (--default or --ignoreargs) were provided
if [ $use_default_dirs_if_empty -gt 0 ] || [ $use_default_dirs_only -gt 0 ]; then
using_defaults=1
fi

# if BOTH directories are empty, run through logic checks so we can determine whether to simulate, run, or error out...
if [ -z "$workspace_dir" ] && [ -z "$repo_dir" ]; then
empty_count_prework=2
ws_empty=1
repo_empty=1
# if NOT using_defaults, then empty_count_postwork is 2, just like $empty_count_prework, else 0
if [ $using_defaults -lt 1 ]; then
empty_count_postwork=2
fi
# if ONLY $workspace_dir is empty, run through logic checks so we can determine whether to simulate, run, or error out...
elif [ -z "$workspace_dir" ]; then
empty_count_prework=1
ws_empty=1
# if NOT using_defaults, then empty_count_postwork is 1, just like $empty_count_prework, else 0
if [ $using_defaults -lt 1 ]; then
empty_count_postwork=1
fi
# if ONLY $repo_dir is empty, run through logic checks so we can determine whether to simulate, run, or error out...
elif [ -z "$repo_dir" ]; then
# just the $repo_dir is empty, but we need to check if either of the default flag are checked
empty_count_prework=1
repo_empty=1
# if NOT using_defaults, then empty_count_postwork is 1, just like $empty_count_prework, else 0
if [ $using_defaults -lt 1 ]; then
empty_count_postwork=1
fi
else
# all values are provided, no more logic needs to be run so far...
echo ""
fi

# assign the default value if no value is provided and you supplied the default flag: [-d|--default|-default]
if [ $use_default_dirs_if_empty -gt 0 ]; then
workspace_dir=${workspace_dir:-$WORKSPACE_PATH}
repo_dir=${repo_dir:-$REPO_PATH}
fi

# overrides all situations, except [--same|-same|-s], so it needs to be after $use_default_dirs_if_empty - this depends on [-i|--ignoreargs|-ignoreargs]
if [ $use_default_dirs_only -gt 0 ]; then
workspace_dir=$WORKSPACE_PATH
repo_dir=$REPO_PATH
fi

# lets run a simulation of what WOULD have been executed had we NOT provided the --same|-same|-s flag
if [ $run_simulation_without_sideeffects -gt 0 ]; then
# need to finish out the logic for the following variables:
# TODO: Handle logic for $empty_count_prework - this may have originally been intended for custom logic within $use_default_dirs_if_empty or $use_default_dirs_only
# TODO: Handle logic for $empty_count_postwork - this may have originally been intended for custom logic with the error handler, and the $using_defaults variable
# TODO: Handle logic for $ws_empty - this was intended for governing which of the directories took priority and which one to NOT default a value to from the directories...
# TODO: Handle logic for $repo_empty - see the entry for $ws_empty; this is a pair with $ws_empty so far as HOW the logic works...
# TODO: Handle logic for $using_defaults - related to the $empty_count_prework and $empty_count_postwork entries above and the logic related to the $use_default_dirs_if_empty and $use_default_dirs_only variables...

# print out the call that would have run if the [--same|-same|-s] flag was NOT enabled. This is as far as the simulation can go today...
echo "cp -a \"${workspace_dir}/.\" \"$repo_dir/\""
# not an error, so return like normal to prevent confusion surrounding
return
fi

# backup to keep from odd behavior or wonky/confusing error messages
if [ -z "$workspace_dir" ] || [ -z "$repo_dir" ]; then
echo -e "Error: workspace_directory and local_repo_directory MUST be specified. \nIf you want to use the default directories for this project, then you need to use the [-d|--default|-default] flag or the [-i|--ignoreargs|-ignoreargs] flag AND to assign them to the proper local shared variables at the top of our '.envrc' file and activate it with 'direnv allow'. \nFor more information, use the '-h' flag when running this function."
return 1
fi

cp -a "${workspace_dir}/." "$repo_dir/"
}

# TODO: Once copyWSToRepo is completed, copy code over to this method and update the simulation, error, and cp execution code and save.
# Copy over code FROM local-repo-directory [--repo] TO workspace-directory --ws
copyRepoToWS() {

while [[ $# -gt 0 ]]; do
case "$1" in
--help|-help|-h)
echo "copyRepoToWS [--ws|-ws|w] {workspace_directory} [--repo|-repo|-r] {local_repo_directory} [--help|-help|-h] # Help flag forces an exit without running any of the script"
return
;;
--ws|-ws|-w)
workspace_dir="$2"
shift 2
;;
--repo|-repo|-r)
repo_dir="$2"
shift 2
;;
esac
done


cp -a "${repo_dir}/." "${workspace_dir}/"
}


# Perform the traditional git-add-*, git-commit-with-msg and git-push. $1 will auto pull the text you provide in `gitpush "This is my commit message"`
gitpush() {
git add .
git commit -m "$1"
git push
}

# > git clone https://github.com/seriussoft/makecode-ext-switchcase.git
# > cd makecode-ext-switchcase
#
# > git checkout dev
# > git add .
# > git commit -m "Merge and promote current code from rpi400"
# > git push origin dev-local-rpi400

# Perform the traditional git-checkout
gitcheck() {

repo=""
repo_given=false
branch_remote=""
branch_remote_given=false
branch_local=""
branch_local_given=false

while [[ $# -gt 0 ]]; do
case $1 in
-help|--help|-h)
echo "gitcheck [--repo|-repo|-r] {repo_url} [--branch|-branch|-b] {remote_branch to check out and default local_branch if no local_branch is supplied} [--localbranch|-localbranch|-l] {local_branch to use with checked out repository} [--help|-help|-h] # Help flag forces an exit without running any of the script"
return
;;
-repo|--repo|-r)
repo="$2"
shift 2
;;
-branch|--branch|-b)
branch_remote="$2"
shift 2
;;
-local|--localbranch|-l)
branch_local="$2"
shift 2
;;
esac
done

if [ -z "$branch_remote" ]; then
echo "ERROR: Missing Remote Branch"
fi

if [ -z "$branch_local" ]; then
echo "ERROR: Missing Local Branch"
fi

if [ -z "$repo" ]; then
echo "ERROR: Missing Repo"
fi

git checkout -b "${repo}"

}



# you need to provide the name of the function (either 'copyWSToRepo' or 'copyRepoToWS')
showHelp_copyWSandRepo() {
$funcName=$1
if [ -z $funcName ]; then
echo "ERROR: Cannot provide the correct output without a proper function name added as an argument after your function call to showFunc_copyWSandRepo"
fi

# echo -e "copyWSToRepo [--help|-help|-h] [--ws|-ws|-w] {workspace_dir} [--repo|-repo|-r] {local_repo_dir} [--default|-default|-d] [--ignoreargs|-ignoreargs|-i] [--same|-same|-s]\n"
echo -e "$funcName [--help|-help|-h] [--ws|-ws|-w] {workspace_dir} [--repo|-repo|-r] {local_repo_dir} [--default|-default|-d] [--ignoreargs|-ignoreargs|-i] [--same|-same|-s]\n"

printf "%-25s %s\n" "--help|-help|-h" "Show help and exit safely"
printf "%-25s %s\n" "--ws|-ws|-w {workspace-dir}" "Workspace directory \(required unless --default or --ignoreargs\)"
printf "%-25s %s\n" "--repo|-repo|-r {local-repo-dir}" "Local repo directory \(required unless --default or --ignoreargs\)"
printf "%-25s %s\n" "--default|-default|-d" "Use default values if missing/empty"
printf "%-25s %s\n" "--ignoreargs|-ignoreargs|-i" "Always use default values, ignore other args"
printf "%-25s %s\n" "--same|-same|-s" "Skip copy if workspace and repo are the same"

echo -e "\nSYNTAX & DETAILS:\n"

printf "%-25s %s\n\n" "--help|-help|-h" \
"Stops execution safely and returns help information specific to this function call and its flags."

printf "%-25s %s\n\n" "--ws|-ws|-w {workspace-dir}" \
"Specifies your workspace directory. Required unless --default or --ignoreargs is used. If not provided or empty, the function errors."

printf "%-25s %s\n\n" "--repo|-repo|-r {local-repo-dir}" \
"Specifies your local repo directory. Required unless --default or --ignoreargs is used. If not provided or empty, the function errors."

printf "%-25s %s\n\n" "--default|-default|-d" \
"Uses default values for missing or empty directory arguments. Does not override provided values unless they are empty."

printf "%-25s %s\n\n" "--ignoreargs|-ignoreargs|-i" \
"Forces use of default values, ignoring any other directory arguments. Overrides --default."

printf "%-25s %s\n\n" "--same|-same|-s" \
"Skips the copy operation if workspace and repo are the same. Overrides other directory flags."
}
13 changes: 13 additions & 0 deletions .github/workflows/makecode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: MakeCode Build
on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- run: npx makecode
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# MakeCode
built
node_modules
yotta_modules
yotta_targets
pxt_modules
.pxt
_site
*.db
*.tgz
.header.json
.simstate.json
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"arrowParens":"avoid","semi":false,"tabWidth":4}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-edu.pxt-vscode-web"
]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"editor.formatOnType": true,
"files.autoSave": "afterDelay",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/built/**": true,
"**/node_modules/**": true,
"**/yotta_modules/**": true,
"**/yotta_targets": true,
"**/pxt_modules/**": true,
"**/.pxt/**": true
},
"files.associations": {
"*.blocks": "html",
"*.jres": "json"
},
"search.exclude": {
"**/built": true,
"**/node_modules": true,
"**/yotta_modules": true,
"**/yotta_targets": true,
"**/pxt_modules": true,
"**/.pxt": true
},
"files.exclude": {
"**/pxt_modules": true,
"**/.pxt": true,
"**/mkc.json": true
}
}
Empty file added README.md
Empty file.
19 changes: 19 additions & 0 deletions case.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@



namespace switchCase {

/**
* Case Block Container
*/
//% block="case $match"
//% blockId=switchcase_case_block
//% group="Control"
//% weight=90
//% draggableParameters
//% draggableStatement=true
export function caseBlock(match: any): void {
//Placeholder for CodeGen
}

}
24 changes: 24 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This is the main file for your project.
*
* Create images, tilemaps, animations, and songs using the
* asset explorer in VS Code. You can reference those assets
* using the tagged templates on the assets namespace:
*
* assets.image`myImageName`
* assets.tilemap`myTilemapName`
* assets.tile`myTileName`
* assets.animation`myAnimationName`
* assets.song`mySongName`
*
* New to MakeCode Arcade? Try creating a new project using one
* of the templates to learn about Sprites, Tilemaps, Animations,
* and more! Or check out the reference docs here:
*
* https://arcade.makecode.com/reference
*/

game.onUpdate(() => {
// Code in this function will run once per frame. MakeCode
// Arcade games run at 30 FPS
});
4 changes: 4 additions & 0 deletions mkc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"targetWebsite": "https://arcade.makecode.com/",
"links": {}
}
Loading