Skip to content

Commit

Permalink
sqlite bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Mar 20, 2024
1 parent d1203e1 commit 93629ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions bundle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ while (( "$#" )); do
--tools | -t ) tools=1 ;; # bundle up repair and migration tools
--all | -a ) all=1 ;; # install all engines
--restart | -r ) restart=1 ;; # start cronicle upon completion
--engine ) shift; engine=$1 ;;
-*) echo "invalid parameter: $1"; usage ;;
* ) dist=$1; x=$(($x + 1))
esac
Expand Down Expand Up @@ -311,7 +312,7 @@ fi
sqlDrivers=()
sqlArgs=("--bundle" "--minify" "--platform=node" "--outdir=$dist/bin/engines")
# exclude unused drivers
sqlArgs+=("--external:better-sqlite3" "--external:mysql" "--external:sqlite3")
sqlArgs+=("--external:better-sqlite3" "--external:mysql")

if [ "$sql" = 1 ]; then
oracle=1
Expand Down Expand Up @@ -347,7 +348,13 @@ else
sqlArgs+=("--external:tedious")
fi

if [[ ${#sqlDrivers[@]} -gt 0 || "$sqlite" = 1 ]]; then
if [ "$sqlite" = 1 ]; then
sqlDrivers+=("sqlite3")
else
sqlArgs+=("--external:sqlite3")
fi

if [[ ${#sqlDrivers[@]} -gt 0 ]]; then
sqlInstall=("install" "--no-save" "--loglevel" "silent" "knex")
sqlInstall+=("${sqlDrivers[@]}")

Expand All @@ -356,6 +363,9 @@ if [[ ${#sqlDrivers[@]} -gt 0 || "$sqlite" = 1 ]]; then
echo " - bundling SQL Engine [${sqlDrivers[@]}]"
npm "${sqlInstall[@]}"
esbuild "${sqlArgs[@]}"
if [ "$sqlite" = 1 ]; then
cp -r node_modules/sqlite3/build $dist/bin/
fi
fi

if [ "$redis" = 1 ]; then
Expand All @@ -382,6 +392,12 @@ if [ ! -d $dist/conf ]; then
chmod 400 $dist/conf/secret_key
fi

# -- override storage engine if specified
if [ -f "sample_conf/examples/storage.$engine.json" ]; then
writehead "Overriding stoarge.json for $engine"
cp "sample_conf/examples/storage.$engine.json" $dist/conf/storage.json
fi


# ---- set up npm pac in dist if not yet, add some deps if needed
cd $dist
Expand Down Expand Up @@ -476,4 +492,5 @@ if [ "$test" = 1 ]; then
node node_modules/pixl-unit/unit.js $dist/bin/test.js
# remove test files
rm $dist/bin/test.js
fi
fi

2 changes: 1 addition & 1 deletion sample_conf/examples/storage.sqlite.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"table": "cronicle",
"useNullAsDefault": true,
"connection": {
"filename": "/tmp/cronicle.db"
"filename": "cronicle.db"
}
}
}

0 comments on commit 93629ef

Please sign in to comment.