-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnewProject.sh
executable file
·65 lines (50 loc) · 1.41 KB
/
newProject.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# create a new TS Nodejs project with AVA test support
set -e # halt the script if an error occurs
# (a) create directories and add packages
NAME=$1
mkdir $NAME
cd $NAME
npm init -y
npm init ava
npm i -D typescript ts-node
mkdir src
mkdir test
mkdir test/int
mkdir test/unit
# (b) update JSON
jq '.ava = {
"files": [
"test/**/*.test.ts"
],
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
}' package.json | sponge package.json
jq '.scripts = {
"build": "tsc",
"commit": "git-cz",
"coverage": "nyc npm test",
"int-test": "ava --config int-tests.config.cjs",
"lint": "eslint \"src/**/*.ts\"",
"lintfix": "eslint \"src/**/*.ts\" --fix",
"prepack": "rm -rf lib && tsc -b",
"report": "nyc report --reporter=json",
"test": "ava",
"view-coverage": "nyc --extension .ts ava --forbid-only"
}' package.json | sponge package.json
# (c) download files
TS_CONFIG=https://raw.githubusercontent.com/YizYah/testingWebinar/main/tsconfig.json
wget $TS_CONFIG -O tsconfig.json
INT_CONFIG=https://raw.githubusercontent.com/YizYah/testingWebinar/main/int-tests.config.cjs
wget $INT_CONFIG -O int-tests.config.cjs
GIT_IGNORE=https://raw.githubusercontent.com/YizYah/testingWebinar/main/.gitignore
wget $GIT_IGNORE -O .gitignore
# make sure git is initialized
git init
git add . && git commit -m “init”
mkdir .github
mkdir .github/workflows