-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ls
137 lines (118 loc) · 3.86 KB
/
build.ls
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
process.chdir __dirname
require! {
"fs-extra": fs
"livescript2": livescript
terser
\js-yaml
\@vscode/vsce
}
const dist = \./dist
fs.emptyDirSync dist
# code = fs.readFileSync \./src/extension.ls \utf8
# code = livescript.compile code,
# bare: yes
# code = await terser.minify code
# code .= code
# fs.outputFileSync "#dist/dist/extension.js" code
# fs.copySync \./src/libs/livescript.min.js "#dist/dist/libs/livescript.min.js"
autocompletes = fs.readJsonSync \./syntaxes/autocompletes.json
snippets = fs.readJsonSync \./snippets/livescript.code-snippets
syntaxes = fs.readFileSync \./syntaxes/livescript.tmLanguage.yaml \utf8
windowMethods = []
staticMethods = {}
protoMethods = new Set
for item in autocompletes
if item.instance
methods = []
staticMethods[item.instance] = methods
for name in item.props ++ item.methods
isMethod = item.methods.includes name and name.0 == name.0.toLowerCase!
if item.proto == \window
key = name
snippet =
scope: \livescript
prefix: name
body: name
if isMethod
windowMethods.push name
else if item.instance
key = "#{item.instance}.#name"
snippet =
scope: \livescript
prefix: key
body: key
if isMethod
methods.push name
else
key = "#{item.proto}#name"
snippet =
scope: \livescript
prefix: name
body: name
if isMethod
protoMethods.add name
snippets[key] ?= snippet
windowMethods .= join \|
protoMethods = Array.from protoMethods .join \|
yamls = []
for instance, methods of staticMethods
if methods.length
instance .= split \.
methods .= join \|
switch instance.length
case 1
yaml = """
- match: (?<![."')\\]}?!])(#{instance.0})(\\.~?)(#methods)(?![\\w$])
captures:
1:
name: storage.type.livescript
2:
name: punctuation.accessor.livescript
3:
name: entity.name.function.livescript
"""
case 2
yaml = """
- match: (?<![."')\\]}?!])(#{instance.0})(\\.~?)(#{instance.1})(\\.~?)(#methods)(?![\\w$])
captures:
1:
name: storage.type.livescript
2:
name: punctuation.accessor.livescript
3:
patterns:
- include: '\#variable'
4:
name: punctuation.accessor.livescript
5:
name: entity.name.function.livescript
"""
yaml .= replace /^/gm " " .trimLeft!
yamls.push yaml
staticMethods = yamls.join "\n "
syntaxes .= replace /{{(\w+)}}/g (, name) ~>
eval name
json = jsYaml.load syntaxes
while /<<(\w+)>>/.test syntaxes
syntaxes .= replace /<<(\w+)>>/g (, name) ~>
json.variables[name].replace /'/g \''
json = jsYaml.load syntaxes
delete json.variables
fs.outputJsonSync "#dist/syntaxes/livescript.tmLanguage.json" json
fs.outputJsonSync "#dist/snippets/livescript.code-snippets" snippets
json = fs.readJsonSync \./package.json
fs.outputJsonSync "#dist/package.json" json
json = fs.readJsonSync \./language-configuration.json
fs.outputJsonSync "#dist/language-configuration.json" json
fs.copySync \./icon.png "#dist/icon.png"
fs.copySync \./sample.png "#dist/sample.png"
fs.copySync \./LICENSE "#dist/LICENSE"
fs.copySync \./README.md "#dist/README.md"
fs.copySync \./CHANGELOG.md "#dist/CHANGELOG.md"
pack = require \./package.json
extsDir = "C:/Users/QUANGTIEN/.vscode/extensions"
extDir = "#extsDir/tientq64.livescript-vscode-#{pack.version}"
fs.emptyDirSync extDir
fs.copySync dist, extDir
process.chdir dist
await vsce.createVSIX!