-
Notifications
You must be signed in to change notification settings - Fork 14
/
mklib.sh
executable file
·83 lines (64 loc) · 1.07 KB
/
mklib.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: mklib.sh <libname>"
exit 1
fi
mkdir $1
cat > $1/package.json <<HERE
{
"name": "@winglibs/$1",
"description": "$1 library for Wing",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "https://github.com/winglang/winglibs.git",
"directory": "$1"
},
"wing": {
"platforms": [
"sim"
]
},
"license": "MIT"
}
HERE
cat > $1/lib.w <<HERE
pub class Adder {
pub inflight add(x: num, y: num): num {
return x + y;
}
}
HERE
cat > $1/lib.test.w <<HERE
bring expect;
bring "./lib.w" as l;
let adder = new l.Adder();
test "add() adds two numbers" {
expect.equal(adder.add(1, 2), 3);
}
HERE
cat > $1/.gitignore <<HERE
target/
node_modules/
HERE
cat > $1/README.md <<HERE
# $1
## Prerequisites
* [winglang](https://winglang.io).
## Installation
\`\`\`sh
npm i @winglibs/$1
\`\`\`
## Usage
\`\`\`js
bring $1;
let adder = new $1.Adder();
\`\`\`
## License
This library is licensed under the [MIT License](./LICENSE).
HERE
cp ./LICENSE $1/
./mkrepo.sh
rm -fr target/
cd $1
wing test *.test.w