-
-
Notifications
You must be signed in to change notification settings - Fork 151
/
make-example
executable file
·118 lines (103 loc) · 2.49 KB
/
make-example
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
readonly MODULE="examples/$1"
readonly AUTHOR="Karsten Schmidt"
readonly EMAIL="k+npm@thi.ng"
echo "generating module: $MODULE"
mkdir -p $MODULE
echo "creating /src folder..."
mkdir -p $MODULE/src
cat << EOF > $MODULE/src/index.ts
import { } from "@thi.ng/hdom";
if (process.env.NODE_ENV !== "production") {
const hot = (<any>module).hot;
hot && hot.dispose(() => {});
}
EOF
echo "writing package.json..."
cat << EOF > $MODULE/package.json
{
"name": "$1",
"version": "0.0.1",
"repository": "https://github.com/thi-ng/umbrella",
"author": "$AUTHOR <$EMAIL>",
"license": "Apache-2.0",
"scripts": {
"clean": "rm -rf .cache build out",
"build": "yarn clean && parcel build index.html -d out --public-url ./ --no-source-maps --no-cache --detailed-report",
"start": "parcel index.html -p 8080 --open"
},
"devDependencies": {
"parcel-bundler": "^1.10.3",
"terser": "^3.10.1",
"typescript": "^3.1.3"
},
"dependencies": {
"@thi.ng/api": "latest",
"@thi.ng/atom": "latest",
"@thi.ng/rstream": "latest",
"@thi.ng/transducers-hdom": "latest"
},
"browserslist": [
"last 3 Chrome versions"
],
"browser": {
"process": false
}
}
EOF
echo "writing tsconfig.json..."
cat << EOF > $MODULE/tsconfig.json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": ".",
"target": "es6",
"sourceMap": true
},
"include": [
"./src/**/*.ts"
]
}
EOF
echo "writing .gitignore..."
cat << EOF > $MODULE/.gitignore
.cache
out
node_modules
yarn.lock
*.js
EOF
echo "writing index.html..."
cat << EOF > $MODULE/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>$1</title>
<link href="https://unpkg.com/tachyons@4.9.1/css/tachyons.min.css" rel="stylesheet">
<style>
</style>
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="./src/index.ts"></script>
</body>
</html>
EOF
echo "writing README.md..."
cat << EOF > $MODULE/README.md
# $1
[Live demo](http://demo.thi.ng/umbrella/$1/)
\`\`\`bash
git clone https://github.com/thi-ng/umbrella.git
cd umbrella/examples/$1
yarn install
yarn start
\`\`\`
## Authors
- $AUTHOR
## License
© 2018 $AUTHOR // Apache Software License 2.0
EOF