-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
> Remove ts-node dependency and do DB initialization via npm scripts hook and bash script. * Added prepare-database.sh * Remove swc & ts-node, since swc `useDefineForClassFields` will cause leoric create error [ref](https://github.com/TypeStrong/ts-node/blob/fd438213ad3b3e1bcabea48627255b8be74c1c24/src/transpilers/swc.ts#L229), which can't customize -------------- > 删除 ts-node 依赖,通过 npm scripts hook 和 bash 来进行 DB 初始化工作 * 新增 prepare-database.sh 处理 db 初始化工作 * 删除 ts-node 及 swc,swc 新版开启 `useDefineForClassFields` 会导致 leoric 创建对象失败,且无法自定义, [ref](https://github.com/TypeStrong/ts-node/blob/fd438213ad3b3e1bcabea48627255b8be74c1c24/src/transpilers/swc.ts#L229)一并去除
- Loading branch information
Showing
6 changed files
with
44 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# read variables from environment | ||
db_host=${MYSQL_HOST:-127.0.0.1} | ||
db_port=${MYSQL_PORT:-3306} | ||
db_username=${MYSQL_USER:-root} | ||
db_password=${MYSQL_PASSWORD:-} # default to empty password | ||
db_name=${MYSQL_DATABASE:-cnpmcore_unittest} | ||
|
||
# preapre mysql param | ||
param="-h $db_host -P $db_port -u $db_username" | ||
if [ -n "$db_password" ]; then | ||
param="$param -p$db_password" | ||
fi | ||
|
||
if [ "$CI" ]; then | ||
echo "⛷️ Skipping database creation in CI environment." | ||
else | ||
# reset database | ||
echo "️😈 Reset database in local" | ||
mysql $param -e "DROP DATABASE IF EXISTS $db_name" | ||
mysql $param -e "CREATE DATABASE $db_name CHARACTER SET utf8" | ||
fi | ||
|
||
|
||
# find all sql files and sort | ||
sql_files=$(ls sql/*.sql | sort) | ||
echo "🤖 Running the following SQL files:" | ||
|
||
# execute sql files | ||
for file in $sql_files; do | ||
echo "🔖 Running $file..." | ||
mysql $param $db_name < "$file" | ||
done | ||
|
||
echo "🎉 prepare database done" | ||
mysql $param -e "USE $db_name; SHOW TABLES;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,4 @@ | |
"exclude": [ | ||
"node_modules" | ||
], | ||
"ts-node": { | ||
"swc": true | ||
} | ||
} |