-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json.sh
executable file
·175 lines (138 loc) · 4.42 KB
/
package.json.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/local/bin/lsc -cj
name: 'derby-select2'
description: 'Native DerbyJS replacement for jQuery Select2'
version: '0.3.0'
author:
name: 'Michael Brade'
email: '[email protected]'
keywords:
'derby'
'select2'
'jquery'
'racer'
repository:
type: 'git'
url: 'michael-brade/derby-select2'
main: 'core.js'
style: 'index.css'
files:
'css/'
'data/base.js'
'data/model.js'
'dropdown/search.js'
'dropdown/search.html'
'selection/base.js'
'selection/single.js'
'selection/single.html'
'selection/multiple.js'
'selection/multiple.html'
'selection/multiplereorder.js'
'selection/search.js'
'selection/search.html'
'selection/template.html'
'core.js'
'core.html'
'keys.js'
'results.js'
'results.html'
'index.css'
dependencies:
sortablejs: '1.10.x'
# utils
lodash: '4.17.x'
jquery: '3.4.x'
mixwith: '*'
devDependencies:
'bootstrap-sass': '3.4.x'
'sass': '1.23.x'
'uglify-js': '3.7.x'
'html-minifier': '4.x'
'@babel/core': '7.7.x'
'@babel/register': '7.7.x'
'@babel/preset-env': '7.7.x'
'@babel/plugin-proposal-class-properties': '7.7.x'
peerDependencies:
'derby': 'michael-brade/derby'
babel:
plugins:
* '@babel/plugin-proposal-class-properties'
...
presets:
* '@babel/preset-env'
targets:
node: 'current'
browsers: '> 0.5%, not dead'
...
eslintConfig:
env:
browser: true
node: true
jquery: true
parserOptions:
ecmaVersion: 2015
sourceType: 'module'
ecmaFeatures:
impliedStrict: true
scripts:
## building
# make sure a stash will be created and stash everything not committed
# beware: --all would be really correct, but it also removes node_modules, so use --include-untracked instead
prebuild: '
npm run clean;
touch .create_stash && git stash save --include-untracked "npm build stash";
npm test || { npm run postbuild; exit 1; };
'
# build the distribution under dist: create directory structure, transpile, uglify
build: "
export DEST=dist;
export SOURCES='*.js';
export VIEWS='*.html';
export ASSETS='.*\.scss|./README\.md|./package\.json';
export IGNORE=\"./$DEST|./test|./node_modules|./docs\";
echo \"\033[01;32mCompiling and minifying...\033[00m\";
find -regextype posix-egrep -regex $IGNORE -prune -o -name \"$SOURCES\" -print0
| xargs -n1 -P8 -0 sh -c '
echo $0...;
mkdir -p \"$DEST/`dirname $0`\";
babel \"$0\" | uglifyjs -cm -o \"$DEST/$0\"';
echo \"\033[01;32mMinifying views...\033[00m\";
find -regextype posix-egrep -regex $IGNORE -prune -o -name \"$VIEWS\" -print0
| xargs -n1 -P8 -0 sh -c '
echo \"$0 -> $DEST/$0\";
mkdir -p \"$DEST/`dirname $0`\";
html-minifier --config-file .html-minifierrc -o \"$DEST/$0\" \"$0\"'
| column -t -c 3;
sass -I node_modules/bootstrap-sass/assets/stylesheets -I css index.scss -s compressed --no-source-map $DEST/index.css;
echo \"\033[01;32mCopying assets...\033[00m\";
find -regextype posix-egrep -regex $IGNORE -prune -o -regex $ASSETS -print0
| xargs -n1 -0 sh -c '
echo \"$0 -> $DEST/$0\";
mkdir -p \"$DEST/`dirname \"$0\"`\";
cp -a \"$0\" \"$DEST/$0\"'
| column -t -c 3;
echo \"\033[01;32mDone!\033[00m\";
"
# restore the original situation
postbuild: 'git stash pop --index && rm .create_stash;'
clean: "rm -rf dist;" # the ; at the end is very important! otherwise "npm run clean ." would delete everything
## docs
docs: "
npm run build;
export DEST=docs;
cd dist; browserify -s Select2 core.js -o ../$DEST/select2.js; cd ..;
cp dist/index.css $DEST/css/index.css;
mkdir -p $DEST/selection $DEST/dropdown;
cp -a selection/*.html $DEST/selection;
cp -a dropdown/*.html $DEST/dropdown;
cp -a core.html results.html $DEST;
"
## testing
test: 'echo "TODO: no tests specified yet";'
## publishing
release: "npm run build; cd dist; npm publish;"
engines:
node: '12.x'
license: 'MIT'
bugs:
url: 'https://github.com/michael-brade/derby-select2/issues'
homepage: 'https://github.com/michael-brade/derby-select2#readme'