Skip to content
Closed
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
7 changes: 0 additions & 7 deletions .env.example

This file was deleted.

31 changes: 2 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ on designers and developers alike throughout the development process.

## Development environment

Create .env file from .env.example

```bash
if [ ! -f .env ]; then cp ./.env.example ./.env; fi
```

### Playground setup

Run the `pg-setup` file.
Run the `pg-setup` script.

```bash
npm run pg:setup
Expand All @@ -28,31 +20,12 @@ You can then test the playground apps at `localhost:4200` by running:
# build the web components
npm run dev:watch

# add one of the following
# and one of the following
npm run serve:angular
npm run serve:react
npm run serve:web
```

### Multiple playgrounds

Since the playground is not included in the CVS it is common to have playground
comment/uncomment code the `npm run pg:switch` script can automate this by switching
code that is out of sync with library code. To prevent having to continually
between playgrounds that are specific to the branch.

To switch to a branch that doesn't yet exist, run the following

```bash
npm run pg:switch new [branch-name]
```

To switch to an existing branch run the following

```bash
npm run pg:switch [branch-name]
```

---

## Contribution Guidelines
Expand Down
31 changes: 25 additions & 6 deletions scripts/pg-setup
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#!/usr/bin/bash
#!/bin/bash

if [ -d playground ]; then
echo "Playground folder already exists!"
exit 1
if [ ! -f .env ]; then
echo "VITE_DEV="true"" >.env
fi

mkdir ./playground
cp -r ./_templates/* ./playground
if [ ! -d playground ]; then
mkdir ./playground
cp -r ./.templates/* ./playground
fi

while true; do
read -p "Do you want to automate playground swapping? (yes/no) " yn
case $yn in
[Yy]*) break ;;
[Nn]*)
echo "Done!"
exit
;;
*) echo "Invalid input. Please answer yes or no." ;;
esac
done

if [ ! -e ".git/hooks/post-checkout" ]; then
cp "./scripts/post-checkout" ".git/hooks"
chmod +x ".git/hooks/post-checkout"
echo "[post-checkout] file has been added to .git/hooks"
fi
61 changes: 0 additions & 61 deletions scripts/pg-switch

This file was deleted.

34 changes: 34 additions & 0 deletions scripts/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

prev_branch=$(git rev-parse --symbolic-full-name --abbrev-ref=loose @{-1})
current_branch=$(git branch --show-current)

if [ ! -n "$prev_branch" ]; then
echo "No previous branch exists to swap"
exit 0
fi

# Move the existing playground to the .playgrounds dir
if [ -d "./playground" ]; then
rm -rf .playgrounds/"$prev_branch"
mv playground .playgrounds/"$prev_branch"
fi

src_dir=".playgrounds/$current_branch"

# Init a playground if it is a new branch
if [ ! -d "$src_dir" ]; then
mkdir -p "$src_dir"
cp -r .templates/* "$src_dir"
fi

# ensure the playground dir exists
if [ ! -d "./playground" ]; then
mkdir "./playground"
fi

# move by copying the new test playground
# mv is used as it is less destructive in the event something happens
cp -r "$src_dir"/* playground

echo "Switched playgrounds => ["$current_branch"]"