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
6 changes: 4 additions & 2 deletions ide/docopts.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OpenServerless Ide Development Utilities.
Usage:
ide login [<username>] [<apihost>]
ide devel [--fast] [--dry-run]
ide deploy [<action>] [--dry-run]
ide deploy [<action>|--packages|--web] [--dry-run]
ide undeploy [<action>] [--dry-run]
ide clean
ide setup
Expand Down Expand Up @@ -60,6 +60,8 @@ Usage:
## Options

```
--fast Skip the initial deployment step and go in incremental update mode
--dry-run Simulates the execution without making any actual changes
--packages Only deploy packages, skip web upload
--web Only deploy web folder, skip packages
--fast Skip the initial deployment step and go in incremental update mode
```
81 changes: 48 additions & 33 deletions ide/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vars:
API_HOST:
sh: |
echo "http://localhost:80"

DEPLOY_CURRENT_HASH:
sh: |
if test -e "$OPS_ROOT/ide/deploy/bun.lockb"
Expand All @@ -36,12 +36,12 @@ vars:
then cat "$OPS_ROOT/ide/deploy/hash.lock"
else echo "0"
fi

tasks:

prereq:
silent: true
vars:
vars:
MSG: |
This command must be run inside a devcontainer.
Please use 'ops ide devcontainer' to create a configuration and enter in a devcontainer.
Expand All @@ -59,31 +59,31 @@ tasks:
- test "$(ops -wsk property get --namespace | awk '{ print $3 }')" = "$OPSDEV_USERNAME" || die "Repeat the login"
- |
if ! test -d "$OPS_ROOT/ide/deploy/node_modules" || [ "{{.DEPLOY_CURRENT_HASH}}" != "{{.DEPLOY_PREVIOUS_HASH}}" ]
then
then
cd $OPS_ROOT/ide/deploy && bun install && rm -f $OPS_ROOT/ide/deploy/hash.lock && bun $OPS_ROOT/ide/deploy/bun.lockb --hash > $OPS_ROOT/ide/deploy/hash.lock
fi
- |
if test -e "$OPS_PWD/package.json"
then if ! test -d "$OPS_PWD/node_modules"
then cd $OPS_PWD ; bun install
fi
fi
fi
- task: kill

devcontainer:
silent: true
desc: add a devcontainer to your project
cmds:
- |
if test -e "$OPS_PWD/.devcontainer/devcontainer.json"
then echo "a .devcontainer already exists"
else
else
mkdir -p "$OPS_PWD/.devcontainer"
cp devcontainer.json "$OPS_PWD/.devcontainer/"
echo "devcontainer created in .devcontainer - please use VSCode and the command 'Reopen in Container'"
fi
- |
if echo "$OPS_PWD/" | rg ' '
if echo "$OPS_PWD/" | rg ' '
then die "please place your workspace in a folder WITHOUT SPACES IN THE FOLDER NAME!!!!"
fi
- bun x @devcontainers/cli up --workspace-folder "$OPS_PWD"
Expand All @@ -98,22 +98,22 @@ tasks:
PIDFILE=$(ops -opspath ~/.ops/tmp/deploy.pid)
echo $PIDFILE
if test -e $PIDFILE
then
then
PID=$(cat $PIDFILE)

if [ ! -z "$PID" ]; then
if ps -p "$PID" > /dev/null;
then
echo "Found previous deploy pid: $PID"
kill "$PID"
# PGRP=$(ps -o 'pgid=' -p $PID | xargs)
# PGRP=$(ps -o 'pgid=' -p $PID | xargs)
# if [ ! -z "$PGRP" ];
# then
# then
# echo "Terminating deploy process group $PGRP"
# kill "$PGRP"
# else
# echo "Terminating deploy process $PID"
# kill "$PID"
# kill "$PID"
# fi
fi
fi
Expand Down Expand Up @@ -153,7 +153,7 @@ tasks:
fi
echo "*** Configuring Access to OpenServerless ***"
if test -z "{{._apihost_}}"
then
then
if test -z "$OPS_APIHOST"
then
echo -n "Enter Apihost: "
Expand Down Expand Up @@ -188,11 +188,11 @@ tasks:
config OPSDEV_USERNAME="$OPSDEV_USERNAME"
config OPSDEV_HOST="$OPSDEV_HOST_PROT://$OPSDEV_USERNAME.$OPSDEV_HOST_URL"
source ~/.wskprops
else
else
false
fi



poll:
silent: true
Expand Down Expand Up @@ -225,23 +225,41 @@ tasks:
then source $OPS_PWD/packages/.env
fi
if test -n "$AUTH_CHECK"
then if test "$AUTH_CHECK" != "$AUTH"
then echo "WARNING: wrong deploy! You are logged in a different user than your configured AUTH_CHECK" ; exit 1
then if test "$AUTH_CHECK" != "$AUTH"
then echo "WARNING: wrong deploy! You are logged in a different user than your pinned one and configured in .env as AUTH_CHECK" ; exit 1
fi
fi

if {{.__dry_run}}
then DRY="--dry-run" ; ECHO='echo'
else DRY="" ; ECHO=""
fi
if test -z "{{._action_}}"

if {{.__web}}
then deploy_packages=""
else deploy_packages="1"
fi

if {{.__packages}}
then deploy_web=""
else deploy_web="1"
fi

if test -n "{{._action_}}"
then
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -d $DRY
OPS_UPLOAD_FOLDER=`bun {{.TASKFILE_DIR}}/deploy/info.js upload web`
echo "UPLOAD ASSETS FROM ${OPS_UPLOAD_FOLDER}"
$ECHO $OPS util upload ${OPS_UPLOAD_FOLDER:-web}
echo "URL: $OPSDEV_HOST"
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -s "{{._action_}}" $DRY
else
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -s "{{._action_}}" $DRY
if [ -n "$deploy_packages" ]
then
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -d $DRY
fi
if [ -n "$deploy_web" ]
then
OPS_UPLOAD_FOLDER=`bun {{.TASKFILE_DIR}}/deploy/info.js upload web`
echo "UPLOAD ASSETS FROM ${OPS_UPLOAD_FOLDER}"
$ECHO $OPS util upload ${OPS_UPLOAD_FOLDER:-web}
echo "URL: $OPSDEV_HOST"
fi
fi

undeploy:
Expand All @@ -254,7 +272,6 @@ tasks:
then DRY="--dry-run"
else DRY=""
fi

# Check if an action argument is provided
if test -n "{{._action_}}"
then
Expand All @@ -270,25 +287,24 @@ tasks:
then echo '$' $OPS util clean
else $OPS util clean
fi


clean:
silent: true
cmds:
- task: kill
- |
if test -d "$OPS_PWD/packages"
then
if test -d "$OPS_PWD/packages"
then
echo "*** removing virtualenv"
/bin/rm -rvf "$OPS_PWD"/packages/*/*/virtualenv/
echo "*** removing node_modules"
/bin/rm -rvf "$OPS_PWD"/packages/*/*/node_modules/
echo "*** removing .zip"
/bin/rm -vf "$OPS_PWD"/packages/*/*.zip
/bin/rm -vf "$OPS_PWD"/packages/*/*.zip
else die "no packages in current directory"
fi


devel:
interactive: true
silent: true
Expand All @@ -304,7 +320,7 @@ tasks:
then source $OPS_PWD/packages/.env
fi
if test -n "$AUTH_CHECK"
then if test "$AUTH_CHECK" != "$AUTH"
then if test "$AUTH_CHECK" != "$AUTH"
then echo "WARNING: wrong deploy! You are logged in a different user than your configured AUTH_CHECK" ; exit 1
fi
fi
Expand Down Expand Up @@ -333,7 +349,6 @@ tasks:
bun {{.TASKFILE_DIR}}/deploy/index.js "$OPS_PWD" -w $FAST $DRY
true


shell:
desc: open a bash shell with the current environment
interactive: true
Expand Down
2 changes: 2 additions & 0 deletions util/docopts.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ OpenServerless Utilities

```text
Usage:
util apihost
util system
util update-cli
util check-operator-version <version>
Expand All @@ -48,6 +49,7 @@ Usage:
## Commands

```
- apihost current apihost
- system system info (<os>-<arch> in Go format)
- update-cli update the cli downloading the binary
- check-operator-version check if you need to update the operator
Expand Down
6 changes: 6 additions & 0 deletions util/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ tasks:
cmds:
- echo "{{OS}}-{{ARCH}}"

apihost:
desc: current apihost``
silent: true
cmds:
- ops -wsk property get | awk '/whisk API host/{print $4}'

update-cli:
desc: update CLI
silent: true
Expand Down