-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
prepare_vscode_tree.sh
executable file
·222 lines (192 loc) · 7.58 KB
/
prepare_vscode_tree.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/bash
#
# Replace 'Markdown' by 'Textile' in VSCode Markdown Language Features tree.
# vscode and vscode-loc are fetched from their GitHub repo, into ./tools/tmp/
# Then, all needed files are processed and copied to ./tools/tmp/out/
#
# After running this tool, you can compare ./ and ./tools/tmp/out/ to gather
# new features.
VSCODE_VERSION_GIT="tags/1.69.2"
VSCODE_LOC_VERSION_GIT="32be2376681ab2490ef1dc8c9e51168fd4701ccd"
. $(dirname $0)/log.sh
function process_dir_src() {
dir=$1
out_dir=$2
elements=$3
OLD_DIR=`pwd`
DEST_DIR=$OLD_DIR/$out_dir
# unsafe
rm -rf "$out_dir"
mkdir -p "$out_dir"
if [ $? -ne 0 ]; then
fatal_error "cannot mkdir $out_dir"
fi
echo "Processing tree of $dir to $out_dir"
if [ ! -d "$dir" ]; then
fatal_error "$dir doesn't exist"
fi
# After this line, don't forget to `cd $OLD_DIR` before leaving function, and use $DEST_DIR instead of $out_dir
cd "$dir"
processed=0
for file in $elements; do
echo " - Processing $file"
# files will be copied to $DEST_DIR with their directory
# but, file from ../ will be copied at the root $DEST_DIR
dirname=$(dirname "$file")
if [ "$dirname" != ".." ]; then
mkdir -p "$DEST_DIR/$dirname"
destfile=$DEST_DIR/$file
else
destfile=$DEST_DIR/$(basename "$file")
fi
extension="${file##*.}"
if [ "$extension" = "js" ] || [ "$extension" = "json" ] || [ "$extension" = "ts" ] || [ "$extension" = "css" ]; then
# replace markdown by textile
sed -e "s/markdown/textile/g" "$file" > "$destfile"
sed -i -e "s/dotMdResource/dotTextileResource/g" "$destfile"
sed -i -e "s/IMdParser/ITextileParser/g" "$destfile"
sed -i -e "s/IMdWorkspace/ITextileWorkspace/g" "$destfile"
sed -i -e "s/InMemoryMdWorkspace/InMemoryTextileWorkspace/g" "$destfile"
sed -i -e "s/MarkdownIt/TextileJS/g" "$destfile"
sed -i -e "s/Markdown/Textile/g" "$destfile"
sed -i -e "s/MdDocumentLinks/TextileDocumentLinks/g" "$destfile"
sed -i -e "s/MDDocument/TextileDocument/g" "$destfile"
sed -i -e "s/MdDocumentRenderer/TextileDocumentRenderer/g" "$destfile"
sed -i -e "s/MdReferencesProvider/TextileReferencesProvider/g" "$destfile"
sed -i -e "s/MdDocumentInfoCache/TextileDocumentInfoCache/g" "$destfile"
sed -i -e "s/MdDocumentSymbolProvider/TextileDocumentSymbolProvider/g" "$destfile"
sed -i -e "s/MdLinkSource/TextileLinkSource/g" "$destfile"
sed -i -e "s/MdInlineLink/TextileInlineLink/g" "$destfile"
sed -i -e "s/MdLinkDefinition/TextileLinkDefinition/g" "$destfile"
sed -i -e "s/MdLinkProvider/TextileLinkProvider/g" "$destfile"
sed -i -e "s/MdLink/TextileLink/g" "$destfile"
sed -i -e "s/MdParsingProvider/TextileParsingProvider/g" "$destfile"
sed -i -e "s/MdTableOfContentsProvider/TextileTableOfContentsProvider/g" "$destfile"
sed -i -e "s/MdWorkspaceInfoCache/TextileWorkspaceInfoCache/g" "$destfile"
sed -i -e "s/MdWorkspaceContents/TextileWorkspaceContents/g" "$destfile"
sed -i -e "s/MdWorkspaceSymbolProvider/TextileWorkspaceSymbolProvider/g" "$destfile"
sed -i -e "s/MdPathCompletionProvider/TextilePathCompletionProvider/g" "$destfile"
sed -i -e "s/MdFoldingProvider/TextileFoldingProvider/g" "$destfile"
sed -i -e "s/MdWorkspaceCache/TextileWorkspaceCache/g" "$destfile"
sed -i -e "s/MdHeaderReference/TextileHeaderReference/g" "$destfile"
sed -i -e "s/MdReference/TextileReference/g" "$destfile"
sed -i -e "s/MdFileRenameEdit/TextileFileRenameEdit/g" "$destfile"
sed -i -e "s/MdWorkspaceEdit/TextileWorkspaceEdit/g" "$destfile"
sed -i -e "s/MdRenameProvider/TextileRenameProvider/g" "$destfile"
sed -i -e "s/MdSmartSelect/TextileSmartSelect/g" "$destfile"
sed -i -e "s/MdTableOfContentsWatcher/TextileTableOfContentsWatcher/g" "$destfile"
sed -i -e "s/MdVsCodeDefinitionProvider/TextileVsCodeDefinitionProvider/g" "$destfile"
sed -i -e "s/MdVsCodeLinkProvider/TextileVsCodeLinkProvider/g" "$destfile"
sed -i -e "s/MdVsCodePathCompletionProvider/TextileVsCodePathCompletionProvider/g" "$destfile"
sed -i -e "s/MdVsCodeReferencesProvider/TextileVsCodeReferencesProvider/g" "$destfile"
sed -i -e "s/MdVsCodeRenameProvider/TextileVsCodeRenameProvider/g" "$destfile"
sed -i -e "s/tryOpenMdFile/tryOpenTextileFile/g" "$destfile"
sed -i -e "s/tryFindMdDocumentForLink/tryFindTextileDocumentForLink/g" "$destfile"
sed -i -e "s/VsCodeMdWorkspace/VsCodeTextileWorkspace/g" "$destfile"
sed -i -e "s/'.md'/'.textile'/g" "$destfile"
sed -i -e "s/ .md / .textile /g" "$destfile"
sed -i -e "s/\*.md'/\*.textile'/g" "$destfile"
sed -i -e 's/`.md`/`.textile`/g' "$destfile"
sed -i -e "s/'doc.md'/'doc.textile'/g" "$destfile"
sed -i -e "s/'other.md'/'other.textile'/g" "$destfile"
else
# just copy other kind of files
cp "$file" "$destfile"
fi
# rename files named "markdown..." to "textile..."
# don't bother with files from "../", there is no such case now
if [ "$dirname" != ".." ]; then
if echo "$file" | grep -iE "markdown[a-z]*.[a-z]+$" ; then
target="${file/markdown/textile}"
if [ "$target" = "./media/textile.css" ]; then
# main CSS file should be splitted in 2
target_end="./media/textile-theming.css"
{ sed -n '/body.wordWrap pre {/q;p'; cat > "$DEST_DIR/$target_end"; } <"$destfile" >"$DEST_DIR/$target"
sed -i '1ibody.wordWrap pre {' "$DEST_DIR/$target_end"
rm "$destfile"
else
mv "$destfile" "$DEST_DIR/$target"
fi
fi
fi
let processed++
done
cd $OLD_DIR
if [ $processed -eq 0 ]; then
fatal_error "Nothing done"
else
echo " -> $processed files processed"
fi
}
function process_dir_i18n() {
# Process : https://github.com/Microsoft/vscode-loc/blob/master/i18n/vscode-language-pack-fr/translations/extensions/markdown-language-features.i18n.json
dir=$1
out_dir=$2
echo "Processing tree of $dir to $out_dir"
if [ ! -d "$dir" ]; then
fatal_error "$dir doesn't exist"
fi
# unsafe
rm -rf "$out_dir"
mkdir -p "$out_dir"
if [ $? -ne 0 ]; then
fatal_error "cannot mkdir $out_dir"
fi
processed=0
for file in $dir/vscode-language-pack-*/translations/extensions/markdown-language-features.i18n.json; do
echo " - Processing $file"
lang=${file%/translations/extensions/markdown-language-features.i18n.json}
lang=${lang#$dir/vscode-language-pack-}
./tools/split_i18n_bundle.js "$lang" "$file" "$out_dir"
if [ $? -eq 0 ]; then
let processed++
else
fatal_error "Error"
fi
done
if [ $processed -eq 0 ]; then
fatal_error "Nothing done"
else
echo " -> $processed files processed"
fi
}
function github_DL() {
package=$1
OLD_PWD=`pwd`
cd ./tools/tmp/
if [ -d "$package" ]; then
cd "$package"
git fetch
if [ $? -ne 0 ]; then
fatal_error "cannot fetch $package"
fi
else
git clone "https://github.com/Microsoft/$package.git"
if [ $? -ne 0 ]; then
fatal_error "cannot clone $package"
fi
cd "$package"
fi
# Checkout to specific tag
if [ ! -z "$2" ]; then
git checkout "$2"
else
git pull
fi
if [ $? -ne 0 ]; then
fatal_error "cannot update $package"
fi
cd $OLD_PWD
}
# -----------
echo "Processing src"
# Download from github : https://github.com/Microsoft/vscode
github_DL "vscode" $VSCODE_VERSION_GIT
process_dir_src ./tools/tmp/vscode/extensions/markdown-language-features ./tools/tmp/out/ '../shared.webpack.config.js ../tsconfig.base.json ./src/*.* ./src/*/*.* ./media/*.* ./notebook/*.* ./.vscodeignore ./*.json ./*.js ./preview-src/*.* ./schemas/package.schema.json ./test-workspace/*.* ./test-workspace/*/*.*'
# -----------
echo "Processing locales"
# Download from github : https://github.com/Microsoft/vscode-loc.git
github_DL "vscode-loc" $VSCODE_LOC_VERSION_GIT
process_dir_i18n ./tools/tmp/vscode-loc/i18n/ ./tools/tmp/out/i18n/
# -----------
end_ok