@darabonba/python-generator 2.0.0 → 2.0.1
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/lib/generator.js +10 -6
- package/package.json +1 -1
- package/tests/expected/complex/tea_python_tests/client.py +5 -4
- package/tests/expected/multi/tea_python_tests/model/user.py +3 -0
- package/tests/fixtures/complex/main.dara +1 -0
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/Teafile +7 -1
- package/tests/fixtures/multi/libraries/darabonba_Util_0.2.11/util.tea +2 -0
- package/tests/fixtures/multi/model/user.dara +2 -0
- package/tests/output/complex/tea_python_tests/client.py +5 -4
- package/tests/output/multi/tea_python_tests/model/user.py +3 -0
- package/src/generator.js +0 -231
- package/src/langs/common/combinator.js +0 -193
- package/src/langs/common/config.js +0 -60
- package/src/langs/common/enum.js +0 -179
- package/src/langs/common/items.js +0 -551
- package/src/langs/common/package_info.js +0 -53
- package/src/langs/python/combinator.js +0 -1898
- package/src/langs/python/config.js +0 -169
- package/src/langs/python/files/.gitignore.tmpl +0 -5
- package/src/langs/python/files/__init__.py.tmpl +0 -1
- package/src/langs/python/files/setup.py.tmpl +0 -74
- package/src/langs/python/package_info.js +0 -78
- package/src/langs/python2/combinator.js +0 -1770
- package/src/langs/python2/config.js +0 -162
- package/src/langs/python2/files/.gitignore.tmpl +0 -5
- package/src/langs/python2/files/__init__.py.tmpl +0 -1
- package/src/langs/python2/files/setup.py.tmpl +0 -82
- package/src/langs/python2/package_info.js +0 -78
- package/src/lib/debug.js +0 -55
- package/src/lib/emitter.js +0 -95
- package/src/lib/helper.js +0 -207
- package/src/resolver/base.js +0 -282
- package/src/resolver/client.js +0 -1013
- package/src/resolver/model.js +0 -159
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const assert = require('assert');
|
|
4
|
-
const debug = require('../../lib/debug');
|
|
5
|
-
|
|
6
|
-
class Counter {
|
|
7
|
-
constructor(start = -1) {
|
|
8
|
-
this.index = start;
|
|
9
|
-
}
|
|
10
|
-
once() {
|
|
11
|
-
this.index++;
|
|
12
|
-
return this.index;
|
|
13
|
-
}
|
|
14
|
-
step(step = 1, length = 1) {
|
|
15
|
-
this.index = this.index + step * length;
|
|
16
|
-
return this.index;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const count = new Counter();
|
|
20
|
-
const ItemSet = {};
|
|
21
|
-
|
|
22
|
-
class Item {
|
|
23
|
-
constructor() {
|
|
24
|
-
this.index = count.once();
|
|
25
|
-
ItemSet[this.index] = this;
|
|
26
|
-
this.belong = 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getItemByIndex(index) {
|
|
30
|
-
if (ItemSet[index]) {
|
|
31
|
-
return ItemSet[index];
|
|
32
|
-
}
|
|
33
|
-
debug.stack(`Index [${index}] not exist in ItemSet`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
setBelongTo(gram, belong) {
|
|
37
|
-
if (gram instanceof Item) {
|
|
38
|
-
gram.belong = belong;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getParent() {
|
|
43
|
-
return this.getItemByIndex(this.belong);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
class AnnotationItem extends Item {
|
|
48
|
-
constructor(belong, mode = 'single', content = null) {
|
|
49
|
-
super();
|
|
50
|
-
this.belong = belong;
|
|
51
|
-
this.mode = mode; // single | multi
|
|
52
|
-
this.content = content;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
class Grammer extends Item {
|
|
57
|
-
constructor(eol = null, newLine = null) {
|
|
58
|
-
super();
|
|
59
|
-
this.eol = eol;
|
|
60
|
-
this.newLine = newLine;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
class GrammerValue extends Grammer {
|
|
65
|
-
constructor(type, value, key = '', needCast = false) {
|
|
66
|
-
super();
|
|
67
|
-
this.type = type; // map | array | string | number | call | null | behavior | param | expr | merge | var | class
|
|
68
|
-
this.key = key;
|
|
69
|
-
this.value = value;
|
|
70
|
-
this.needCast = needCast;
|
|
71
|
-
this.keyType = '';
|
|
72
|
-
this.itemType = '';
|
|
73
|
-
this.isExpand = false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
class GrammerNewObject extends Grammer {
|
|
78
|
-
constructor(objectName, params = [], type = 'var') {
|
|
79
|
-
super();
|
|
80
|
-
this.name = objectName;
|
|
81
|
-
this.params = params;
|
|
82
|
-
this.type = type; // var | map
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
addParam(param) {
|
|
86
|
-
this.params.push(param);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
class GrammerVar extends Grammer {
|
|
91
|
-
constructor(name = '', dataType = '', varType = 'var', itemType = '') {
|
|
92
|
-
super();
|
|
93
|
-
this.name = name;
|
|
94
|
-
this.type = dataType; // Types Enum
|
|
95
|
-
this.varType = varType; // static_class 静态类名 || var 可变 || const 不可变
|
|
96
|
-
this.itemType = itemType;
|
|
97
|
-
this.eol = false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
class GrammerExpr extends Grammer {
|
|
102
|
-
constructor(left = null, opt = '', right = '') {
|
|
103
|
-
super();
|
|
104
|
-
this.left = left; // GrammerVar
|
|
105
|
-
this.opt = opt;
|
|
106
|
-
this.right = right;
|
|
107
|
-
this.setBelongTo(left, this.index);
|
|
108
|
-
this.setBelongTo(right, this.index);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
class GrammerCall extends Grammer {
|
|
113
|
-
constructor(type = 'method', path = [], params = [], returnType = null, hasThrow = false) {
|
|
114
|
-
super();
|
|
115
|
-
this.type = type; // method | key | index | prop | sys_func | super
|
|
116
|
-
this.path = [];
|
|
117
|
-
path.forEach(p => {
|
|
118
|
-
this.addPath(p);
|
|
119
|
-
});
|
|
120
|
-
this.params = params;
|
|
121
|
-
this.returnType = returnType;
|
|
122
|
-
this.hasThrow = hasThrow;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
addPath(path) {
|
|
126
|
-
// {type: '', name: ''}
|
|
127
|
-
const pathType = [
|
|
128
|
-
'parent', 'object', 'object_static',
|
|
129
|
-
'call', 'call_static', 'call_async',
|
|
130
|
-
'call_static_async', 'prop',
|
|
131
|
-
'prop_static', 'map', 'list',
|
|
132
|
-
'map_set', 'map_get', 'object_static_async',
|
|
133
|
-
'object_async', 'parent_async'
|
|
134
|
-
];
|
|
135
|
-
if (pathType.indexOf(path.type) < 0) {
|
|
136
|
-
throw new Error(
|
|
137
|
-
`${path.type} path.type should be parent|object|object_static|call|call_static|prop|prop_static|map|list`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
this.path.push(path);
|
|
141
|
-
return this;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
addParams(param) {
|
|
145
|
-
this.params.push(param);
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
class GrammerCondition extends Grammer {
|
|
151
|
-
constructor(type = '', conditionBody = [], body = []) {
|
|
152
|
-
super();
|
|
153
|
-
this.type = type; // like 'if' | elseif | else | 'while' | 'doWhile'
|
|
154
|
-
this.body = body; // Grammer
|
|
155
|
-
this.conditionBody = conditionBody; // GrammerExpr | GrammerValue | GrammerCall
|
|
156
|
-
this.elseItem = [];
|
|
157
|
-
this.eol = false;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
addElse(elseItem) {
|
|
161
|
-
assert.equal(true, elseItem instanceof GrammerCondition);
|
|
162
|
-
this.elseItem.push(elseItem);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
addBodyNode(node) {
|
|
166
|
-
assert.equal(true, node instanceof Grammer || node instanceof AnnotationItem);
|
|
167
|
-
this.body.push(node);
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
addCondition(condition) {
|
|
172
|
-
assert.equal(true,
|
|
173
|
-
condition instanceof GrammerExpr ||
|
|
174
|
-
condition instanceof GrammerValue ||
|
|
175
|
-
condition instanceof GrammerCall
|
|
176
|
-
);
|
|
177
|
-
this.conditionBody.push(condition);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
class GrammerException extends Grammer {
|
|
182
|
-
constructor(type = '', exceptionVar = null) {
|
|
183
|
-
super();
|
|
184
|
-
this.type = type;
|
|
185
|
-
this.exceptionVar = exceptionVar; // GrammerVar
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
class GrammerCatch extends Grammer {
|
|
190
|
-
constructor(body = [], exceptions = null) {
|
|
191
|
-
super();
|
|
192
|
-
this.exceptions = exceptions; // GrammerException
|
|
193
|
-
this.body = body; // Grammer
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
addBodyNode(node) {
|
|
197
|
-
this.body.push(node);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
class GrammerFinally extends Grammer {
|
|
202
|
-
constructor(body = []) {
|
|
203
|
-
super();
|
|
204
|
-
this.body = body; // Grammer
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
addBodyNode(node) {
|
|
208
|
-
this.body.push(node);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
class GrammerTryCatch extends Grammer {
|
|
213
|
-
constructor(body = [], catchGramList = [], finallyGram = null) {
|
|
214
|
-
super();
|
|
215
|
-
this.body = body; // Grammer
|
|
216
|
-
this.catchBody = catchGramList; // GrammerCatch
|
|
217
|
-
this.finallyBody = finallyGram; // GrammerFinally
|
|
218
|
-
this.eol = false;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
addBodyNode(node) {
|
|
222
|
-
assert.equal(true, node instanceof Grammer || node instanceof AnnotationItem);
|
|
223
|
-
this.body.push(node);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
addCatch(node) {
|
|
227
|
-
assert.equal(true, node instanceof GrammerCatch);
|
|
228
|
-
this.catchBody.push(node);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
setFinally(node) {
|
|
232
|
-
assert.equal(true, node instanceof GrammerFinally);
|
|
233
|
-
this.finallyBody = node;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
class GrammerThrows extends Grammer {
|
|
238
|
-
constructor(exception = null, params = [], msg = '') {
|
|
239
|
-
super();
|
|
240
|
-
this.exception = exception; // ExceptionEnum
|
|
241
|
-
this.params = params; // GrammerValue
|
|
242
|
-
this.message = msg;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
addParam(param) {
|
|
246
|
-
assert.equal(true, param instanceof GrammerValue);
|
|
247
|
-
this.params.push(param);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
class GrammerReturnType extends Grammer {
|
|
252
|
-
constructor(type = '', isOptional = false, keyType = null, itemType = null) {
|
|
253
|
-
super();
|
|
254
|
-
this.type = type;
|
|
255
|
-
this.optional = isOptional;
|
|
256
|
-
this.keyType = keyType;
|
|
257
|
-
this.itemType = itemType;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
class GrammerReturn extends Grammer {
|
|
262
|
-
constructor(expr = '', type = '') {
|
|
263
|
-
super();
|
|
264
|
-
this.type = type; // null | grammer
|
|
265
|
-
this.expr = expr;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
class GrammerLoop extends Grammer {
|
|
270
|
-
constructor(type = '') {
|
|
271
|
-
super();
|
|
272
|
-
this.type = type; // foreach | forCondition
|
|
273
|
-
this.item = null; // GrammerVar
|
|
274
|
-
this.source = null; // GrammerCall | GrammerValue
|
|
275
|
-
this.start = null; // GrammerExpr
|
|
276
|
-
this.contions = [];
|
|
277
|
-
this.step = null; // GrammerExpr
|
|
278
|
-
this.body = [];
|
|
279
|
-
this.eol = false;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
addBodyNode(node) {
|
|
283
|
-
assert.equal(true, node instanceof Grammer);
|
|
284
|
-
this.body.push(node);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
class GrammerContinue extends Grammer {
|
|
289
|
-
constructor(belong) {
|
|
290
|
-
super();
|
|
291
|
-
this.belong = belong; // counter index
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
class GrammerBreak extends Grammer {
|
|
296
|
-
constructor(belong) {
|
|
297
|
-
super();
|
|
298
|
-
this.belong = belong; // counter index
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
class GrammerNewLine extends Grammer {
|
|
303
|
-
constructor(number = 1) {
|
|
304
|
-
super();
|
|
305
|
-
this.number = number;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
class GrammerSymbol extends Grammer {
|
|
310
|
-
constructor(symbol) {
|
|
311
|
-
super();
|
|
312
|
-
this.symbol = symbol;
|
|
313
|
-
this.eol = false;
|
|
314
|
-
this.newLine = false;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
class PropItem extends Item {
|
|
319
|
-
constructor() {
|
|
320
|
-
super();
|
|
321
|
-
this.modify = []; // Modify
|
|
322
|
-
this.name = '';
|
|
323
|
-
this.type = '';
|
|
324
|
-
this.itemType = '';
|
|
325
|
-
this.value = null;
|
|
326
|
-
this.notes = []; // [{key:'name', value:'test', type:'string'}, {key:'length', value:10, type:'number'}]
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
addModify(modify) {
|
|
330
|
-
this.modify.push(modify);
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
addNote(note) {
|
|
335
|
-
this.notes.push(note);
|
|
336
|
-
return this;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
class NoteItem extends Item {
|
|
341
|
-
constructor(key, value) {
|
|
342
|
-
super();
|
|
343
|
-
const typeMap = ['number', 'string', 'boolean'];
|
|
344
|
-
let type = typeof value;
|
|
345
|
-
if (value === null || value === 'null') {
|
|
346
|
-
type = 'null';
|
|
347
|
-
} else if (typeMap.indexOf(type) === -1) {
|
|
348
|
-
throw new Error(`Not suppoted type : ${type} [${typeMap.toString()}]`);
|
|
349
|
-
}
|
|
350
|
-
this.key = key;
|
|
351
|
-
this.value = value;
|
|
352
|
-
this.type = type;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
class FuncItem extends Item {
|
|
357
|
-
constructor() {
|
|
358
|
-
super();
|
|
359
|
-
this.name = '';
|
|
360
|
-
this.modify = []; // Modify
|
|
361
|
-
this.params = []; // param
|
|
362
|
-
this.throws = []; // Exception name
|
|
363
|
-
this.return = []; // GrammerReturn
|
|
364
|
-
this.annotations = []; // AnnotationItem
|
|
365
|
-
this.body = []; // grammer
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
addBodyNode(node) {
|
|
369
|
-
assert.equal(true, node instanceof Grammer);
|
|
370
|
-
this.body.push(node);
|
|
371
|
-
return this;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
addAnnotation(node) {
|
|
375
|
-
assert.equal(true, node instanceof AnnotationItem);
|
|
376
|
-
this.annotations.push(node);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
class ConstructItem extends Item {
|
|
381
|
-
constructor(params = [], body = [], annotations = []) {
|
|
382
|
-
super();
|
|
383
|
-
this.params = params;
|
|
384
|
-
this.body = body;
|
|
385
|
-
this.annotations = annotations;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
addParamNode(node) {
|
|
389
|
-
assert.equal(true, node instanceof Grammer);
|
|
390
|
-
this.params.push(node);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
addBodyNode(node) {
|
|
394
|
-
assert.equal(true, node instanceof Grammer);
|
|
395
|
-
this.body.push(node);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
addAnnotation(node) {
|
|
399
|
-
assert.equal(true, node instanceof AnnotationItem);
|
|
400
|
-
this.annotations.push(node);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
class ObjectItem extends Item {
|
|
405
|
-
constructor(type) {
|
|
406
|
-
super();
|
|
407
|
-
assert.equal(true, type === 'client' || type === 'model');
|
|
408
|
-
this.type = type; // client | model
|
|
409
|
-
this.modify = []; // Modify
|
|
410
|
-
this.name = ''; // object name
|
|
411
|
-
this.extends = []; // object extends
|
|
412
|
-
this.body = []; // PropItem | FuncItem | ConstructItem ...
|
|
413
|
-
this.annotations = []; // AnnotationItem
|
|
414
|
-
this.topAnnotation = []; // AnnotationItem
|
|
415
|
-
this.subObject = []; // ObjectItem
|
|
416
|
-
this.includeList = [];
|
|
417
|
-
this.includeModelList = [];
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
addBodyNode(node) {
|
|
421
|
-
if (!(node instanceof PropItem || node instanceof FuncItem || node instanceof ObjectItem || node instanceof AnnotationItem || node instanceof ConstructItem)) {
|
|
422
|
-
throw new Error('Only suppoted PropItem | FuncItem | ObjectItem | AnnotationItem | ConstructItem');
|
|
423
|
-
}
|
|
424
|
-
this.body.push(node);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
addModify(modify) {
|
|
428
|
-
this.modify.push(modify);
|
|
429
|
-
return this;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
addExtends(extend) {
|
|
433
|
-
this.extends.push(extend);
|
|
434
|
-
return this;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
class Behavior extends Grammer {
|
|
439
|
-
constructor() {
|
|
440
|
-
super();
|
|
441
|
-
this.name = '';
|
|
442
|
-
this.eol = false;
|
|
443
|
-
this.newLine = false;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
class BehaviorTimeNow extends Behavior {
|
|
448
|
-
constructor() {
|
|
449
|
-
super();
|
|
450
|
-
this.name = 'behaviorTimeNow';
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
class BehaviorSetMapItem extends Behavior {
|
|
455
|
-
constructor(call = null, key = '', value = null, isVar = false) {
|
|
456
|
-
super();
|
|
457
|
-
this.name = 'behaviorSetMapItem';
|
|
458
|
-
assert.equal(true, call instanceof GrammerCall);
|
|
459
|
-
this.call = call;
|
|
460
|
-
this.key = key;
|
|
461
|
-
this.isVar = isVar;
|
|
462
|
-
this.value = value;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
class BehaviorDoAction extends Behavior {
|
|
467
|
-
constructor(responseVar = null, params = [], callbackBody = []) {
|
|
468
|
-
super();
|
|
469
|
-
this.name = 'behaviorDoAction';
|
|
470
|
-
this.var = responseVar;
|
|
471
|
-
this.params = params;
|
|
472
|
-
this.body = callbackBody;
|
|
473
|
-
}
|
|
474
|
-
addBodyNode(node) {
|
|
475
|
-
this.body.push(node);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
class BehaviorRetry extends Behavior {
|
|
480
|
-
constructor() {
|
|
481
|
-
super();
|
|
482
|
-
this.name = 'behaviorRetry';
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
class BehaviorToModel extends Behavior {
|
|
487
|
-
constructor(grammer, expected) {
|
|
488
|
-
super();
|
|
489
|
-
this.name = 'behaviorToModel';
|
|
490
|
-
this.grammer = grammer;
|
|
491
|
-
this.expected = expected;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
class BehaviorToMap extends Behavior {
|
|
496
|
-
constructor(grammer, inferred) {
|
|
497
|
-
super();
|
|
498
|
-
this.name = 'behaviorToMap';
|
|
499
|
-
this.grammer = grammer;
|
|
500
|
-
this.inferred = inferred;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
class BehaviorStrFormat extends Behavior {
|
|
505
|
-
constructor(tmp, item) {
|
|
506
|
-
super();
|
|
507
|
-
this.name = 'behaviorStrFormat';
|
|
508
|
-
this.tmp = tmp;
|
|
509
|
-
this.item = item;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
module.exports = {
|
|
514
|
-
Counter,
|
|
515
|
-
|
|
516
|
-
AnnotationItem,
|
|
517
|
-
ConstructItem,
|
|
518
|
-
ObjectItem,
|
|
519
|
-
FuncItem,
|
|
520
|
-
PropItem,
|
|
521
|
-
NoteItem,
|
|
522
|
-
|
|
523
|
-
Grammer,
|
|
524
|
-
GrammerVar,
|
|
525
|
-
GrammerCall,
|
|
526
|
-
GrammerExpr,
|
|
527
|
-
GrammerLoop,
|
|
528
|
-
GrammerBreak,
|
|
529
|
-
GrammerCatch,
|
|
530
|
-
GrammerValue,
|
|
531
|
-
GrammerSymbol,
|
|
532
|
-
GrammerReturn,
|
|
533
|
-
GrammerThrows,
|
|
534
|
-
GrammerNewLine,
|
|
535
|
-
GrammerFinally,
|
|
536
|
-
GrammerContinue,
|
|
537
|
-
GrammerTryCatch,
|
|
538
|
-
GrammerNewObject,
|
|
539
|
-
GrammerCondition,
|
|
540
|
-
GrammerException,
|
|
541
|
-
GrammerReturnType,
|
|
542
|
-
|
|
543
|
-
Behavior,
|
|
544
|
-
BehaviorToMap,
|
|
545
|
-
BehaviorRetry,
|
|
546
|
-
BehaviorTimeNow,
|
|
547
|
-
BehaviorToModel,
|
|
548
|
-
BehaviorDoAction,
|
|
549
|
-
BehaviorSetMapItem,
|
|
550
|
-
BehaviorStrFormat
|
|
551
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const debug = require('../../lib/debug');
|
|
6
|
-
|
|
7
|
-
class BasePackageInfo {
|
|
8
|
-
constructor(config) {
|
|
9
|
-
this.config = config;
|
|
10
|
-
this.outputDir = '';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
render(tamplate, params = {}) {
|
|
14
|
-
Object.keys(params).forEach((key) => {
|
|
15
|
-
tamplate = tamplate.split('${' + key + '}').join(params[key]);
|
|
16
|
-
});
|
|
17
|
-
return tamplate;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
renderAuto(templatePath, targetPath, params) {
|
|
21
|
-
let content = fs.readFileSync(templatePath).toString();
|
|
22
|
-
content = this.render(content, params);
|
|
23
|
-
if (!fs.existsSync(path.dirname(targetPath))) {
|
|
24
|
-
fs.mkdirSync(path.dirname(targetPath), {
|
|
25
|
-
recursive: true
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
fs.writeFileSync(targetPath, content);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
resolveOutputDir(packageInfo, append = '../') {
|
|
32
|
-
let outputDir = path.join(this.config.dir, append);
|
|
33
|
-
if (packageInfo.outputDir) {
|
|
34
|
-
outputDir = path.join(outputDir, packageInfo.outputDir);
|
|
35
|
-
}
|
|
36
|
-
if (!fs.existsSync(outputDir)) {
|
|
37
|
-
fs.mkdirSync(outputDir, {
|
|
38
|
-
recursive: true
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return outputDir;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
checkParams(packageInfo, validateParam = []) {
|
|
45
|
-
validateParam.forEach(key => {
|
|
46
|
-
if (typeof packageInfo[key] === 'undefined') {
|
|
47
|
-
debug.stack('need config packageInfo.' + key, packageInfo);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = BasePackageInfo;
|