-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathmake.sh
More file actions
executable file
·168 lines (133 loc) · 3.75 KB
/
Copy pathmake.sh
File metadata and controls
executable file
·168 lines (133 loc) · 3.75 KB
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
#!/bin/bash
DT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../.."
if [ "$1" = "debug" ]; then
DEBUG="debug"
else
OUT_DIR=$1
DEBUG=$2
fi
# If not run from DataTables build script, redirect to there
if [ -z "$DT_BUILD" ]; then
cd $DT_DIR/build
./make.sh extension Plugins $DEBUG
cd -
exit
fi
function ts_plugin {
local SRC_FILE=$1
local DEST_DIR=$2
local REQUIRE=${3:-'datatables.net'}
local FILE_NAME=$(basename $SRC_FILE)
local VERSION=$(dt_version)
# Remove extension
FILE_NAME="${FILE_NAME%.*}"
if [ -z "$DEST_DIR" ]; then
DEST_DIR=$(dirname $(dirname $SRC_FILE))
fi
../../node_modules/.bin/tsc \
--target es6 \
--moduleResolution node \
--outDir $DEST_DIR \
--declaration \
--skipLibCheck \
--allowSyntheticDefaultImports \
$SRC_FILE
# Remove import statements - the wrap will add them
# sed -i '/^import /d' $DEST_DIR/$FILE_NAME.js
js_wrap $DEST_DIR/$FILE_NAME.js $VERSION "$REQUIRE"
}
function js_plugin {
local SRC_FILE=$1
local REQUIRE=${2:-'datatables.net'}
local DEST_DIR=$(dirname $(dirname $SRC_FILE))
local FILE_NAME=$(basename $SRC_FILE)
local VERSION=$(dt_version)
cp $SRC_FILE $DEST_DIR/$FILE_NAME
js_wrap $DEST_DIR/$FILE_NAME $VERSION "$REQUIRE"
}
function lang_plugin {
local SRC_FILE=$1
local DEST_DIR=$(dirname $SRC_FILE)
local FILE_NAME=$(basename $SRC_FILE)
FILE_NAME="${FILE_NAME%.*}"
echo_msg " Language $FILE_NAME"
JSON=$(<$SRC_FILE)
echo -n " " # ??? Without this the echo below outputs non-utf8 characters
echo "export default $JSON;" > $DEST_DIR/$FILE_NAME.mjs
cat << EOF > $DEST_DIR/$FILE_NAME.js
(function( factory ) {
if ( typeof define === 'function' && define.amd ) {
// AMD
define( [], factory);
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = factory();
}
// No browser loader - use JSON, ESM, CJS or AMD
}
(function() {
return $JSON;
}));
EOF
}
# Change into script's own dir
cd $(dirname $0)
DT_SRC=$(dirname $(dirname $(pwd)))
DT_BUILT="${DT_SRC}/built/DataTables"
. $DT_SRC/build/include.sh
PLUGINS="${DT_SRC}/extensions/Plugins"
if [ ! -e $DT_BUILT/extensions/Plugins ]; then
ln -s $PLUGINS $DT_BUILT/extensions/Plugins
fi
# for file in $PLUGINS/api/src/*.ts; do
# ts_plugin $file
# done
# for file in $PLUGINS/buttons/src/*.ts; do
# ts_plugin $file
# done
for file in $PLUGINS/editorFields/src/*.js; do
js_plugin $file
done
for FILE_IN in $PLUGINS/editorFields/src/*.scss; do
BASENAME=$(basename $FILE_IN .scss)
DIRNAME=$(dirname $FILE_IN)
FILE_OUT=${DIRNAME}/../${BASENAME}.scss
cp $FILE_IN $FILE_OUT
scss_compile $FILE_OUT
rm ${DIRNAME}/../${BASENAME}.css
done
# for file in $PLUGINS/dataRender/src/*.ts; do
# ts_plugin $file
# done
# for FEATURE_DIR in $PLUGINS/features/*; do
# NAME=$(basename $FEATURE_DIR)
# ## Build TS if there is a ts file
# ts_plugin $FEATURE_DIR/src/dataTables.$NAME.ts $FEATURE_DIR/dist
# if [ -e $FEATURE_DIR/src/types.d.ts ]; then
# cp $FEATURE_DIR/src/types.d.ts $FEATURE_DIR/dist
# fi
# ## Build SCSS
# if [ -e $FEATURE_DIR/src/dataTables.$NAME.scss ]; then
# cp $FEATURE_DIR/src/dataTables.$NAME.scss $FEATURE_DIR/dist
# scss_compile $FEATURE_DIR/dist/dataTables.$NAME.scss
# rm $FEATURE_DIR/dist/dataTables.$NAME.scss
# fi
# ## Build examples
# if [ -d $FEATURE_DIR/dist/examples ]; then
# rm -r $FEATURE_DIR/dist/examples
# fi
# # Build happens in the path that is http available, despite it just being a symlink
# cp -r $FEATURE_DIR/examples $FEATURE_DIR/dist/examples
# examples_process $DT_BUILT/extensions/Plugins/features/$NAME/dist
# done
# for file in $PLUGINS/sorting/src/*.ts; do
# ts_plugin $file
# done
# for file in $PLUGINS/type-detection/src/*.ts; do
# ts_plugin $file
# done
# echo_section " Languages"
# for file in $PLUGINS/i18n/*.json; do
# lang_plugin $file
# done