@winner-fed/winner-deploy 3.4.1 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/see.js +35 -11
package/package.json
CHANGED
package/src/see.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.genDeployXml = function genDeployXml ({
|
|
|
80
80
|
variables = [],
|
|
81
81
|
description
|
|
82
82
|
}) {
|
|
83
|
-
const template = fs.readFileSync(resolveFile(`python/deploy.xml`))
|
|
83
|
+
const template = fs.readFileSync(resolveFile(`python/deploy.xml`)).toString()
|
|
84
84
|
|
|
85
85
|
return tpl(template, {
|
|
86
86
|
interpolate: /{{([\s\S]+?)}}/g
|
|
@@ -101,7 +101,7 @@ exports.genDeployXml = function genDeployXml ({
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
exports.genScripts = function genScripts (name, options) {
|
|
104
|
-
const template = fs.readFileSync(resolveFile(`python/scripts/${name}.py`))
|
|
104
|
+
const template = fs.readFileSync(resolveFile(`python/scripts/${name}.py`)).toString()
|
|
105
105
|
return tpl(template, {
|
|
106
106
|
interpolate: /{{([\s\S]+?)}}/g
|
|
107
107
|
})(options)
|
|
@@ -144,23 +144,47 @@ exports.genTemplate = function genTemplate (file, variables = []) {
|
|
|
144
144
|
visitor: {
|
|
145
145
|
Literal (path) {
|
|
146
146
|
if (path.parentPath.isProperty()) {
|
|
147
|
-
const
|
|
147
|
+
const currentNode = path.parentPath.get('key').node
|
|
148
|
+
let currentNodeName = currentNode.name
|
|
149
|
+
// 当 key 为字符串的时候,会转换失败
|
|
150
|
+
// 解决方法,重置为标识符字面量节点
|
|
151
|
+
// 如
|
|
152
|
+
// window.LOCAL_CONFIG_whaleTest = {
|
|
153
|
+
// "API_HOME": 'https://api.github.com/',
|
|
154
|
+
// 'API_USER': "https://www.baidu.com",
|
|
155
|
+
// API_UPLOAD: 'https://api.github.com/upload',
|
|
156
|
+
// IS_OPEN_VCONSOLE: false
|
|
157
|
+
// }
|
|
158
|
+
// 转换之后的效果是有问题的,API_HOME 没有转换
|
|
159
|
+
// window.LOCAL_CONFIG_whaleTest = {
|
|
160
|
+
// "API_HOME": 'https://api.github.com/',
|
|
161
|
+
// 'API_USER': "https://www.baidu.com",
|
|
162
|
+
// API_UPLOAD: 'https://api.github.com/upload',
|
|
163
|
+
// IS_OPEN_VCONSOLE: ${IS_OPEN_VCONSOLE}
|
|
164
|
+
// }
|
|
165
|
+
if (currentNode.type === 'StringLiteral') {
|
|
166
|
+
currentNode.type = 'Identifier'
|
|
167
|
+
currentNode.name = currentNode.value
|
|
168
|
+
currentNodeName = currentNode.value
|
|
169
|
+
}
|
|
148
170
|
|
|
171
|
+
const _match = findTemplateVariableItem(variables, (variable) => currentNodeName === variable.name)
|
|
149
172
|
if (_match) {
|
|
150
173
|
if (_match.fullPath.includes('complexSelect')) {
|
|
151
174
|
_match.name = _match.fullName
|
|
152
175
|
}
|
|
153
176
|
|
|
177
|
+
// 是否为字符串字面量节点
|
|
154
178
|
if (path.isStringLiteral()) {
|
|
155
179
|
path.node.value = `$!\{${_match.name}\}`
|
|
156
180
|
return
|
|
157
181
|
}
|
|
158
|
-
|
|
182
|
+
// 是否为数字字面量节点
|
|
159
183
|
if (path.isNumericLiteral()) {
|
|
160
|
-
path.node.value = `$!\{${
|
|
184
|
+
path.node.value = `$!\{${_match.name}\}`
|
|
161
185
|
return
|
|
162
186
|
}
|
|
163
|
-
|
|
187
|
+
// 是否为数布尔字面量节点
|
|
164
188
|
if (path.isBooleanLiteral()) {
|
|
165
189
|
path.node.type = 'StringLiteral'
|
|
166
190
|
|
|
@@ -235,7 +259,7 @@ exports.genDockerDeployXml = function genDockerDeployXml ({
|
|
|
235
259
|
web_app_web_service_name,
|
|
236
260
|
dockerImage
|
|
237
261
|
}) {
|
|
238
|
-
const template = fs.readFileSync(resolveFile(`docker/deploy.xml`))
|
|
262
|
+
const template = fs.readFileSync(resolveFile(`docker/deploy.xml`)).toString()
|
|
239
263
|
|
|
240
264
|
return tpl(template, {
|
|
241
265
|
interpolate: /{{([\s\S]+?)}}/g
|
|
@@ -258,7 +282,7 @@ exports.genDockerDeployXml = function genDockerDeployXml ({
|
|
|
258
282
|
}
|
|
259
283
|
|
|
260
284
|
exports.genK8sDeployRes = function genK8sDeployResYaml (options) {
|
|
261
|
-
const template = fs.readFileSync(resolveFile(`docker/k8s-deploy-res.yaml`))
|
|
285
|
+
const template = fs.readFileSync(resolveFile(`docker/k8s-deploy-res.yaml`)).toString()
|
|
262
286
|
|
|
263
287
|
return tpl(template, {
|
|
264
288
|
interpolate: /{{([\s\S]+?)}}/g
|
|
@@ -266,7 +290,7 @@ exports.genK8sDeployRes = function genK8sDeployResYaml (options) {
|
|
|
266
290
|
}
|
|
267
291
|
|
|
268
292
|
exports.genDockerfile = function genDockerfile (options) {
|
|
269
|
-
const template = fs.readFileSync(resolveFile(`docker/Dockerfile`))
|
|
293
|
+
const template = fs.readFileSync(resolveFile(`docker/Dockerfile`)).toString()
|
|
270
294
|
|
|
271
295
|
return tpl(template)(options)
|
|
272
296
|
}
|
|
@@ -282,7 +306,7 @@ exports.genDeployXmlBySh = function genDeployXmlBySh ({
|
|
|
282
306
|
variables = [],
|
|
283
307
|
description
|
|
284
308
|
}) {
|
|
285
|
-
const template = fs.readFileSync(resolveFile(`bash/deploy.xml`))
|
|
309
|
+
const template = fs.readFileSync(resolveFile(`bash/deploy.xml`)).toString()
|
|
286
310
|
|
|
287
311
|
return tpl(template, {
|
|
288
312
|
interpolate: /{{([\s\S]+?)}}/g
|
|
@@ -303,7 +327,7 @@ exports.genDeployXmlBySh = function genDeployXmlBySh ({
|
|
|
303
327
|
}
|
|
304
328
|
|
|
305
329
|
exports.genScriptsBySh = function genScriptsBySh (name, options) {
|
|
306
|
-
const template = fs.readFileSync(resolveFile(`bash/scripts/${name}.sh`))
|
|
330
|
+
const template = fs.readFileSync(resolveFile(`bash/scripts/${name}.sh`)).toString()
|
|
307
331
|
return tpl(template, {
|
|
308
332
|
interpolate: /{{([\s\S]+?)}}/g
|
|
309
333
|
})(options)
|