Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 282c005

Browse files
committed
merge v0.20.0
2 parents 030a687 + bc99ecc commit 282c005

21 files changed

+578
-221
lines changed

.idea/runConfigurations/Debug_Server_Tests.xml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sakuraapi/core",
3-
"version": "0.19.5",
3+
"version": "0.20.0",
44
"description": "MongoDB and TypeScript MEAN Stack Framework for NodeJS",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -15,7 +15,6 @@
1515
"docs:generate": "./scripts/docs:generate.sh",
1616
"docs:publish": "./scripts/docs:publish.sh",
1717
"docs:serve": "./scripts/docs:serve.sh",
18-
"docker:compose-test": "./scripts/docker:compose-test.sh",
1918
"install": "chmod +x scripts/*.* || true",
2019
"lint": "./scripts/lint.sh",
2120
"prepublish": "npm test && npx nsp check",
@@ -70,7 +69,7 @@
7069
"supertest": "^3.1.0",
7170
"tslint": "^5.11.0",
7271
"typedoc": "^0.11.1",
73-
"typescript": "^2.9.2"
72+
"typescript": "^3.0.3"
7473
},
7574
"dependencies": {
7675
"bcrypt": "^3.0.0",

scripts/_functions.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4+
PROJECT_NAME="$(basename ${PROJECT_DIR})"
5+
6+
function compose {
7+
docker-compose --project-name ${PROJECT_NAME} --file ${COMPOSE_FILE} $@
8+
}
9+
10+
function down {
11+
compose down --remove-orphans
12+
docker volume prune -f || echo "skipped docker volume prune"
13+
}
14+
15+
function pull {
16+
local services
17+
local remoteServices
18+
services=$(compose config --services)
19+
remoteServices=""
20+
for service in ${services[@]}; do
21+
if [[ ${service} != local-* ]]; then
22+
remoteServices+=" $service"
23+
fi
24+
done
25+
26+
compose pull --parallel ${remoteServices}
27+
}
28+
29+
30+
function saveVersion {
31+
cat package.json \
32+
| grep version \
33+
| head -1 \
34+
| awk -F: '{ print $2 }' \
35+
| sed 's/[",]//g' \
36+
| tr -d '[[:space:]]' > ./lib/version
37+
}
38+
39+
function updateStart {
40+
echo
41+
echo "🚀 starting $0"
42+
}
43+
44+
function update {
45+
echo "$1"
46+
}
47+
48+
function updateDone {
49+
echo "$0 done"
50+
echo
51+
}

scripts/build.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
#!/usr/bin/env bash
22

3-
set -ex
3+
set -e
44

5+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
. ${DIR}/_functions.sh
7+
8+
updateStart
9+
10+
update "removing lib"
511
rm -rf lib/
12+
13+
update "compiling typescript"
614
npx tsc
15+
16+
update "syncing assets"
717
rsync -r --exclude=*.ts spec/ lib/spec
18+
19+
update "saving version"
20+
saveVersion

scripts/coverage.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
#!/usr/bin/env bash
22

3-
set -ex
4-
npm run docker:compose-test
5-
npm run build
3+
set -e
4+
5+
COMPOSE_FILE="./docker-compose.yml"
6+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
. ${DIR}/_functions.sh
8+
9+
updateStart
10+
11+
update "starting mongodb"
12+
trap down EXIT
13+
compose up -d
14+
15+
npm run build test
16+
17+
update "starting istanbul"
618
npx istanbul cover --include-all-sources node_modules/jasmine/bin/jasmine.js
7-
docker-compose down
19+
20+
update "opening report"
821
(open coverage/lcov-report/index.html || echo '')
22+
23+
updateDone

scripts/docker:compose-test.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/lint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
#!/usr/bin/env bash
22

3+
set -e
4+
5+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
. ${DIR}/_functions.sh
7+
8+
updateStart
9+
10+
update "starting tslint"
311
npx tslint -t stylish -c tslint.json -p tsconfig.json
12+
13+
updateDone

scripts/test.sh

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
#!/usr/bin/env bash
22

3-
set -ex
3+
set -e
44

5-
TEST_TYPE=${1:-clearDb}
5+
TEST_TYPE=${1:-"clearDb"}
66

7-
npm run docker:compose-test
8-
npm run build
9-
npx jasmine || ((say 'fail' || echo 'fail') ; exit 1)
7+
COMPOSE_FILE="./docker-compose.yml"
8+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
. ${DIR}/_functions.sh
10+
11+
updateStart
12+
13+
npm run build test
14+
15+
if [ "$1" == "webstorm-debug" ]; then
16+
17+
update "starting MongoDB"
18+
down
19+
compose up -d
20+
21+
else
22+
23+
update "starting MongoDB"
24+
if [ "$1" != "saveDb" ]; then
25+
trap down EXIT
26+
fi
27+
compose up -d
28+
29+
update "starting jasmine"
30+
npx jasmine
1031

11-
if [ $TEST_TYPE != "saveDb" ]; then
12-
docker-compose down
1332
fi
33+
34+
updateDone

src/core/@model/id.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ describe('@Id', () => {
4040
});
4141
});
4242

43+
it('allows default ID on instantiation', () => {
44+
45+
@Model()
46+
class DefaultValue extends SapiModelMixin() {
47+
@Id()
48+
id: ObjectID = new ObjectID();
49+
}
50+
51+
const result = new DefaultValue();
52+
expect(result.id).toBeDefined();
53+
54+
});
55+
4356
describe('@Db', () => {
4457
it('maps fromDb', () => {
4558
const id = new ObjectID();

0 commit comments

Comments
 (0)