Skip to content

Commit

Permalink
Improve scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
grubersjoe committed Oct 21, 2024
1 parent 985f781 commit d051906
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 35 deletions.
13 changes: 13 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env fish

cd (dirname (status --current-filename))
source common.sh

echo "Building react-activity-calendar...."
cd ../react-activity-calendar;
and git checkout main &> /dev/null;
and git pull &> /dev/null;
and pnpm i --ignore-scripts > /dev/null;
and pnpm build &> /dev/null; or abort "Failed to build react-activity-calendar";
and cd -;
or abort "failed building"
5 changes: 5 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function abort
set_color red;
echo "Error: $argv"
exit 1
end
1 change: 1 addition & 0 deletions test_kill.sh → scripts/kill.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env fish
echo "Killing processes on port 3001-3004"
kill (lsof -ti:3001,3002,3003,3004) &> /dev/null
41 changes: 41 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env fish

cd (dirname (status --current-filename))
source common.sh

./kill.sh

set -l pids
cd ../frameworks
for p in */package.json
set -l framework (dirname $p);
and cd $framework; or abort "cd";
and pnpm i --ignore-scripts > /dev/null; or abort "failed installing packages";
and cp -r ../../react-activity-calendar/build node_modules/react-activity-calendar/; or abort "copying build artifacts failed";
and pnpm run "$argv[1]-test" > /dev/null &

set -l pid $last_pid
set -a pids $pid;
and echo "Starting $framework (pid $pid)...";
and cd -;
or abort "unknown"
end

set sleep 10
if test "$argv[1]" = "dev"
set sleep 3
end

echo "Waiting $sleep s for servers to start..."
sleep $sleep

for pid in $pids;
if not ps -p $pid > /dev/null
abort "$pid not running"
end
end

open http://localhost:3001
open http://localhost:3002
open http://localhost:3003
open http://localhost:3004
13 changes: 13 additions & 0 deletions scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env fish

cd (dirname (status --current-filename))
source common.sh

echo "Fetching react-activity-calendar..."
git submodule update --init > /dev/null;
and cd ../react-activity-calendar &> /dev/null;
and git checkout main &> /dev/null;
and git pull > /dev/null;
and cd -;
or abort "failed fetching"

12 changes: 12 additions & 0 deletions test-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env fish

if test "$argv[1]" != "dev" -a "$argv[1]" != "ssr"
set p (basename (status -f))
echo "Usage: $p [dev|ssr]"
exit 1
end

cd (dirname (status --current-filename))
./scripts/upgrade.sh
./scripts/build.sh
./scripts/run.sh $argv
10 changes: 10 additions & 0 deletions test-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env fish

if test "$argv[1]" != "dev" -a "$argv[1]" != "ssr"
set p (basename (status -f))
echo "Usage: $p [dev|ssr]"
exit 1
end

cd (dirname (status --current-filename))
./scripts/run.sh $argv
35 changes: 0 additions & 35 deletions test.sh

This file was deleted.

0 comments on commit d051906

Please sign in to comment.