datagrok-tools 4.13.79 → 4.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Datagrok-tools changelog
2
2
 
3
+ ## 4.14.0 (2025-05-12)
4
+
5
+ ### Features
6
+
7
+ * Added annotation creation by decorators
8
+
3
9
  ## 4.13.70 (2025-04-14)
4
10
 
5
11
  ### Features
@@ -20,11 +20,13 @@ let pseudoParams = exports.pseudoParams = /*#__PURE__*/function (pseudoParams) {
20
20
  pseudoParams["INPUT_TYPE"] = "inputType";
21
21
  return pseudoParams;
22
22
  }({});
23
+ const nonMetaData = ['sidebar', 'editor'];
24
+ const decoratorOptionToAnnotation = new Map([['initialValue', 'default']]);
23
25
  let FUNC_TYPES = exports.FUNC_TYPES = /*#__PURE__*/function (FUNC_TYPES) {
24
26
  FUNC_TYPES["APP"] = "app";
25
27
  FUNC_TYPES["CELL_RENDERER"] = "cellRenderer";
26
28
  FUNC_TYPES["FILE_EXPORTER"] = "fileExporter";
27
- FUNC_TYPES["FILE_IMPORTER"] = "file-handler";
29
+ FUNC_TYPES["FILE_HANDLER"] = "file-handler";
28
30
  FUNC_TYPES["FILE_VIEWER"] = "fileViewer";
29
31
  FUNC_TYPES["SETTINGS_EDITOR"] = "packageSettingsEditor";
30
32
  FUNC_TYPES["VIEWER"] = "viewer";
@@ -38,6 +40,7 @@ let FUNC_TYPES = exports.FUNC_TYPES = /*#__PURE__*/function (FUNC_TYPES) {
38
40
  FUNC_TYPES["DASHBOARD"] = "dashboard";
39
41
  FUNC_TYPES["FUNCTION_ANALYSIS"] = "functionAnalysis";
40
42
  FUNC_TYPES["CONVERTER"] = "converter";
43
+ FUNC_TYPES["MODEL"] = "model";
41
44
  return FUNC_TYPES;
42
45
  }({});
43
46
  const typesToAnnotation = exports.typesToAnnotation = {
@@ -63,17 +66,19 @@ const typesToAnnotation = exports.typesToAnnotation = {
63
66
  'FuncCall': 'funccall',
64
67
  'DG.SemanticValue': 'semantic_value',
65
68
  'SemanticValue': 'semantic_value',
66
- 'any': 'dynamic'
69
+ 'any': 'dynamic',
70
+ 'void': 'void',
71
+ 'string': 'string'
67
72
  };
68
73
 
69
74
  /** Generates an annotation header for a function based on provided metadata. */
70
75
  function getFuncAnnotation(data, comment = '//', sep = '\n') {
71
76
  const isFileViewer = data.tags?.includes(FUNC_TYPES.FILE_VIEWER) ?? false;
72
- const isFileImporter = data.tags?.includes(FUNC_TYPES.FILE_IMPORTER) ?? false;
77
+ const isFileImporter = data.tags?.includes(FUNC_TYPES.FILE_HANDLER) ?? false;
73
78
  let s = '';
74
79
  if (data.name) s += `${comment}name: ${data.name}${sep}`;
75
80
  if (pseudoParams.EXTENSION in data && data.tags != null && data.tags.includes(FUNC_TYPES.FILE_EXPORTER)) s += `${comment}description: Save as ${data[pseudoParams.EXTENSION]}${sep}`;else if (data.description) s += `${comment}description: ${data.description}${sep}`;
76
- if (data.tags) {
81
+ if (data.tags && data.tags?.length > 0) {
77
82
  s += `${comment}tags: ${isFileViewer && data[pseudoParams.EXTENSIONS] ? data.tags.concat(data[pseudoParams.EXTENSIONS].map(ext => 'fileViewer-' + ext)).join(', ') : data.tags.join(', ')}${sep}`;
78
83
  }
79
84
  for (let input of data.inputs ?? []) {
@@ -88,22 +93,30 @@ function getFuncAnnotation(data, comment = '//', sep = '\n') {
88
93
  if (input?.options?.type) type = input?.options?.type;else if (annotationType) {
89
94
  if (isArray) type = `list<${annotationType}>`;else type = annotationType;
90
95
  } else type = 'dynamic';
91
- console.log(input);
92
96
  const options = input?.options?.options ? buildStringOfOptions(input.options.options ?? {}) : '';
93
- const functionName = (input.options?.name ? input?.options?.name ?? ` ${input.name?.replaceAll('.', '')}` : '')?.trim();
97
+ const functionName = (input.options?.name ? input?.options?.name : ` ${input.name?.replaceAll('.', '')}`)?.trim();
94
98
  s += comment + 'input: ' + type + ' ' + functionName + (input.defaultValue !== undefined ? `= ${input.defaultValue}` : '') + ' ' + options.replaceAll('"', '\'') + sep;
95
99
  }
96
100
  if (data.outputs) {
97
- for (const output of data.outputs) s += comment + 'output: ' + output.type + (output.name ? ` ${output.name}` : '') + sep;
101
+ for (const output of data.outputs) if (output.type !== 'void') s += comment + 'output: ' + output.type + (output.name ? ` ${output.name}${output.options ? ` ${buildStringOfOptions(output.options)}` : ''}` : '') + sep;
98
102
  }
99
103
  if (data.meta) {
100
104
  for (let entry of Object.entries(data.meta)) s += `${comment}meta.${entry[0]}: ${entry[1]}${sep}`;
101
105
  }
102
106
  for (const parameter in data) {
103
- if (parameter === pseudoParams.EXTENSION || parameter === pseudoParams.INPUT_TYPE || parameter === 'meta') continue;else if (parameter === pseudoParams.EXTENSIONS) {
107
+ if (parameter === pseudoParams.EXTENSION || parameter === pseudoParams.INPUT_TYPE || parameter === 'meta' || parameter === 'isAsync' || parameter === 'test') continue;else if (parameter === pseudoParams.EXTENSIONS) {
104
108
  if (isFileViewer) continue;
105
109
  s += `${comment}meta.ext: ${data[parameter]}${sep}`;
106
- } else if (!headerParams.includes(parameter)) s += `${comment}meta.${parameter}: ${data[parameter]}${sep}`;
110
+ } else if (!headerParams.includes(parameter)) {
111
+ if (nonMetaData.includes(parameter)) s += `${comment}${parameter}: ${data[parameter]}${sep}`;else s += `${comment}meta.${parameter}: ${data[parameter]}${sep}`;
112
+ }
113
+ }
114
+ if (data.test) {
115
+ for (let entry of Object.entries(data.test)) {
116
+ if (entry[0] === 'test' || entry[0] === 'wait') s += `${comment}`;else s += `, `;
117
+ s += `${entry[0]}: ${entry[1]} `;
118
+ }
119
+ s += `${sep}`;
107
120
  }
108
121
  return s;
109
122
  }
@@ -111,8 +124,10 @@ function buildStringOfOptions(options) {
111
124
  let optionsInString = [];
112
125
  for (const [key, value] of Object.entries(options ?? {})) {
113
126
  let val = value;
127
+ let option = key;
128
+ option = decoratorOptionToAnnotation.get(option) ?? option;
114
129
  if (Array.isArray(value)) val = JSON.stringify(value);
115
- optionsInString.push(`${key}: ${val}`);
130
+ optionsInString.push(`${option}: ${val}`);
116
131
  }
117
132
  return `{ ${optionsInString.join('; ')} }`;
118
133
  }
@@ -158,9 +173,9 @@ const reservedDecorators = exports.reservedDecorators = {
158
173
  },
159
174
  genFunc: generateFunc
160
175
  },
161
- fileImporter: {
176
+ fileHandler: {
162
177
  metadata: {
163
- tags: [FUNC_TYPES.FILE_IMPORTER],
178
+ tags: [FUNC_TYPES.FILE_HANDLER],
164
179
  inputs: [{
165
180
  name: 'content',
166
181
  type: 'string'
@@ -323,6 +338,36 @@ const reservedDecorators = exports.reservedDecorators = {
323
338
  }]
324
339
  },
325
340
  genFunc: generateFunc
341
+ },
342
+ demo: {
343
+ metadata: {
344
+ tags: [],
345
+ inputs: [],
346
+ outputs: []
347
+ },
348
+ genFunc: generateFunc
349
+ },
350
+ treeBrowser: {
351
+ metadata: {
352
+ tags: [],
353
+ inputs: [{
354
+ name: 'treeNode',
355
+ type: 'dynamic'
356
+ }, {
357
+ name: 'browseView',
358
+ type: 'view'
359
+ }],
360
+ outputs: []
361
+ },
362
+ genFunc: generateFunc
363
+ },
364
+ model: {
365
+ metadata: {
366
+ tags: [FUNC_TYPES.MODEL],
367
+ inputs: [],
368
+ outputs: []
369
+ },
370
+ genFunc: generateFunc
326
371
  }
327
372
  };
328
373
 
@@ -330,12 +375,13 @@ const reservedDecorators = exports.reservedDecorators = {
330
375
  function generateClassFunc(annotation, className, sep = '\n') {
331
376
  return annotation + `export function _${className}() {${sep} return new ${className}();${sep}}${sep.repeat(2)}`;
332
377
  }
378
+ const primitives = new Set(['string', 'string[]', 'number', 'number[]', 'boolean', 'boolean[]']);
333
379
 
334
380
  /** Generates a DG function. */
335
- function generateFunc(annotation, funcName, sep = '\n', className = '', inputs = []) {
336
- let funcSigNature = inputs.map(e => `${e.name}: ${e.type}`).join(', ');
381
+ function generateFunc(annotation, funcName, sep = '\n', className = '', inputs = [], isAsync = false) {
382
+ let funcSigNature = inputs.map(e => `${e.name}: ${primitives.has(e.type ?? '') ? e.type : 'any'}`).join(', ');
337
383
  let funcArguments = inputs.map(e => e.name).join(', ');
338
- return annotation + `export function _${funcName}(${funcSigNature}) {${sep} return ${className.length > 0 ? `${className}.` : ''}${funcName}(${funcArguments});${sep}}${sep.repeat(2)}`;
384
+ return annotation + `export ${isAsync ? 'async ' : ''}function ${funcName}(${funcSigNature}) {${sep} return ${className.length > 0 ? `${className}.` : ''}${funcName}(${funcArguments});${sep}}${sep.repeat(2)}`;
339
385
  }
340
386
  function generateImport(className, path, sep = '\n') {
341
387
  return `import {${className}} from '${path}';${sep}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datagrok-tools",
3
- "version": "4.13.79",
3
+ "version": "4.14.1",
4
4
  "description": "Utility to upload and publish packages to Datagrok",
5
5
  "homepage": "https://github.com/datagrok-ai/public/tree/master/tools#readme",
6
6
  "dependencies": {
@@ -12,7 +12,7 @@ const {
12
12
  typesToAnnotation
13
13
  } = require("../bin/utils/func-generation");
14
14
 
15
- const baseImport = '\nimport * as DG from \'datagrok-api/dg\';\n\n';
15
+ const baseImport = '\n';
16
16
 
17
17
  class FuncGeneratorPlugin {
18
18
  constructor(options = { outputPath: "./src/package.g.ts" }) {
@@ -33,6 +33,9 @@ class FuncGeneratorPlugin {
33
33
 
34
34
  for (const file of tsFiles) {
35
35
  const content = fs.readFileSync(file, "utf-8");
36
+ if(!content.includes('@grok.decorators.'))
37
+ continue;
38
+
36
39
  if (!content) continue;
37
40
  const ast = tsParser.parse(content, {
38
41
  sourceType: "module",
@@ -44,11 +47,6 @@ class FuncGeneratorPlugin {
44
47
  });
45
48
  const functions = [];
46
49
  let imports = new Set();
47
-
48
- const fileName = path.basename(file);
49
- if(fileName === 'package-functions.ts')
50
- imports = new Set([... this._readImports(content)]);
51
-
52
50
  this._walk(ast, (node, parentClass) => {
53
51
  const decorators = node.decorators;
54
52
  if (!decorators || decorators.length === 0) return;
@@ -58,12 +56,14 @@ class FuncGeneratorPlugin {
58
56
 
59
57
  if (node?.type === "MethodDefinition")
60
58
  this._addNodeData(node, file, srcDirPath, functions, imports, genImports, genExports, parentClass);
61
- });
59
+ });
62
60
  this._insertImports([...imports]);
63
- fs.appendFileSync(this.options.outputPath, functions.join("\n"), "utf-8");
61
+ fs.appendFileSync(this.options.outputPath, functions.join(""), "utf-8");
64
62
  }
63
+ this._checkPackageFileForDecoratorsExport(packageFilePath);
64
+ // Uncommment to add obvious import/export
65
+ // this._writeToPackageFile(packageFilePath, genImports, genExports);
65
66
 
66
- this._writeToPackageFile(packageFilePath, genImports, genExports);
67
67
  });
68
68
  }
69
69
 
@@ -87,26 +87,33 @@ class FuncGeneratorPlugin {
87
87
  const decoratorOptions = this._readDecoratorOptions(exp.arguments[0].properties);
88
88
  decoratorOptions.set('tags', [...(reservedDecorators[name]['metadata']['tags'] ?? [] ), ...(decoratorOptions.get('tags') ?? [])])
89
89
  const functionParams = node?.type === 'MethodDefinition' ? this._readMethodParamas(node) : [];
90
-
91
90
  const annotationByReturnType = node?.type === 'MethodDefinition' ? this._readFunctionReturnTypeInfo(node) : '';
92
91
  const annotationByReturnTypeObj = { name: 'result', type: annotationByReturnType };
93
-
92
+ const isMethodAsync = this._isMethodAsync(node);
94
93
  let importString = generateImport(node?.type === 'MethodDefinition' ? className : identifierName, modifyImportPath(path.dirname(this.options.outputPath), file));
95
94
  imports.add(importString);
96
- const funcName = `_${identifierName}`;
95
+ const funcName = `${node?.type === 'MethodDefinition' ? '' : '_'}${identifierName}`;
97
96
  const funcAnnotaionOptions = {
98
97
  ...reservedDecorators[name]['metadata'],
99
98
  ...(annotationByReturnType ? {outputs: [annotationByReturnTypeObj ?? {}]} : {}),
100
99
  ...Object.fromEntries(decoratorOptions),
101
100
  ...{inputs: functionParams},
101
+ ...{isAsync: isMethodAsync}
102
102
  };
103
-
104
- functions.push(reservedDecorators[name]['genFunc'](getFuncAnnotation(funcAnnotaionOptions), identifierName,'\n', (className ?? ''), functionParams));
105
-
103
+ if (!funcAnnotaionOptions.name)
104
+ funcAnnotaionOptions.name = identifierName;
105
+ functions.push(reservedDecorators[name]['genFunc'](getFuncAnnotation(funcAnnotaionOptions), identifierName,'\n', (className ?? ''), functionParams, funcAnnotaionOptions.isAsync ?? false));
106
106
  genImports.push(generateImport(funcName, modifyImportPath(srcDirPath, this.options.outputPath)));
107
107
  genExports.push(generateExport(funcName));
108
108
  }
109
109
 
110
+ _isMethodAsync(node){
111
+ let result = false;
112
+ if (node.type === 'MethodDefinition')
113
+ result = node.value.async;
114
+ return result;
115
+ }
116
+
110
117
  _readImports (content) {
111
118
  const importRegex = /(import(?:[\s\w{},*]+from\s*)?['"]([^'"]+)['"];)/g;
112
119
  const results = [];
@@ -152,13 +159,14 @@ class FuncGeneratorPlugin {
152
159
  _readMethodParamas(node) {
153
160
  const params = node?.value?.params?.map(param => {
154
161
  let baseParam = param.type === 'TSNonNullExpression' ? param.expression : param;
155
- let defaultValue = undefined;
156
162
  const options = param.decorators?.length > 0? Object.fromEntries(this._readDecoratorOptions(param.decorators[0]?.expression?.arguments[0].properties)) : undefined;
157
163
 
164
+ // Commented code finds value by default of function's variable
165
+ // let defaultValue = undefined;
158
166
  if(baseParam.type === 'AssignmentPattern')
159
167
  {
160
- if (baseParam?.right?.type === 'Literal')
161
- defaultValue = baseParam?.right?.raw;
168
+ // if (baseParam?.right?.type === 'Literal')
169
+ // defaultValue = baseParam?.right?.raw;
162
170
  baseParam = baseParam?.left;
163
171
  }
164
172
 
@@ -167,50 +175,53 @@ class FuncGeneratorPlugin {
167
175
  baseParam.type === 'RestElement'
168
176
  ? `...${baseParam.argument.name}`
169
177
  : baseParam.name;
170
-
171
178
  if (baseParam?.argument?.typeAnnotation)
172
179
  name += ': ' + generate(baseParam.argument.typeAnnotation.typeAnnotation).code;
173
180
 
174
181
  let type = '';
175
- if (baseParam?.typeAnnotation)
182
+ if (baseParam?.typeAnnotation?.typeAnnotation)
176
183
  type = generate(baseParam.typeAnnotation.typeAnnotation).code;
177
- else
184
+ else
178
185
  type = 'any';
179
-
180
- return { name: name, type: type, defaultValue: defaultValue, options: options };
186
+
187
+ let params = baseParam.typeAnnotation.typeAnnotation.typeArguments?.params;
188
+ if(type !== 'any' && params && params.length > 0)
189
+ type += `<${params.map((e)=>e.typeName.name).join(',')}>`;
190
+ return { name: name, type: type, options: options };
181
191
  }
182
- else if (baseParam.type === 'ObjectPattern' || baseParam.type === 'ArrayPattern') {
183
- let name = '';
184
- if (baseParam.type === 'ObjectPattern') {
185
- const properties = baseParam.properties.map(prop => {
186
- if (prop.type === 'Property' && prop.key.type === 'Identifier')
187
- return prop.key.name;
188
- else if (prop.type === 'RestElement' && prop.argument.type === 'Identifier')
189
- return `...${prop.argument.name}`;
190
- else
191
- return generate(prop).code;
192
- });
193
- name = `{ ${properties.join(', ')} }`;
194
- } else {
195
- const elements = baseParam.elements.map(elem => {
196
- if (elem) {
197
- if (elem.type === 'Identifier')
198
- return elem.name;
199
- else
200
- return generate(elem).code;
201
- } else return '';
202
- });
203
- name = `[${elements.join(', ')}]`;
204
- }
192
+ // Commented code belove sets more strong types for ObjectPatterns and ArrayPatterns
193
+ // else if (baseParam.type === 'ObjectPattern' || baseParam.type === 'ArrayPattern') {
194
+ // let name = '';
195
+ // if (baseParam.type === 'ObjectPattern') {
196
+ // const properties = baseParam.properties.map(prop => {
197
+ // if (prop.type === 'Property' && prop.key.type === 'Identifier')
198
+ // return prop.key.name;
199
+ // else if (prop.type === 'RestElement' && prop.argument.type === 'Identifier')
200
+ // return `...${prop.argument.name}`;
201
+ // else
202
+ // return generate(prop).code;
203
+ // });
204
+ // name = `{ ${properties.join(', ')} }`;
205
+ // } else {
206
+ // const elements = baseParam.elements.map(elem => {
207
+ // if (elem) {
208
+ // if (elem.type === 'Identifier')
209
+ // return elem.name;
210
+ // else
211
+ // return generate(elem).code;
212
+ // } else return '';
213
+ // });
214
+ // name = `[${elements.join(', ')}]`;
215
+ // }
205
216
 
206
- let type = '';
207
- if (baseParam.typeAnnotation)
208
- type = generate(baseParam.typeAnnotation.typeAnnotation).code;
209
- else
210
- type = 'any';
211
-
212
- return { name: name, type: type, defaultValue: defaultValue, options: options };
213
- }
217
+ // let type = '';
218
+ // if (baseParam.typeAnnotation)
219
+ // type = generate(baseParam.typeAnnotation.typeAnnotation).code;
220
+ // else
221
+ // type = 'any';
222
+
223
+ // return { name: name, type: type, options: options };
224
+ // }
214
225
  return { name: 'value', type: 'any', options: undefined };
215
226
  });
216
227
  return params;
@@ -219,7 +230,7 @@ class FuncGeneratorPlugin {
219
230
  _getTsFiles(root) {
220
231
  const tsFiles = [];
221
232
  const extPattern = /\.tsx?$/;
222
- const excludedFiles = ["package.ts", "package-test.ts", "package.g.ts"];
233
+ const excludedFiles = ["package-test.ts", "package.g.ts"];
223
234
 
224
235
  function findFiles(dir) {
225
236
  const files = fs.readdirSync(dir);
@@ -257,41 +268,42 @@ class FuncGeneratorPlugin {
257
268
  _readFunctionReturnTypeInfo(node) {
258
269
  let resultType = 'any';
259
270
  let isArray = false;
260
- const annotation = node.value.returnType.typeAnnotation;
261
- if (annotation?.typeName?.name === 'Promise')
262
- {
263
- const argumnets = annotation.typeArguments?.params;
264
- if (argumnets && argumnets.length===1)
271
+ const annotation = node.value?.returnType?.typeAnnotation;
272
+ if (annotation) {
273
+ if (annotation?.typeName?.name === 'Promise')
265
274
  {
266
- if (argumnets[0].typeName)
267
- resultType = argumnets[0].typeName?.right?.name ?? argumnets[0].typeName?.name;
268
- else if (argumnets[0].type !== 'TSArrayType')
269
- resultType = this._getTypeNameFromNode(argumnets[0]);
270
- else if (argumnets[0].elementType.type !== 'TSTypeReference'){
275
+ const argumnets = annotation.typeArguments?.params;
276
+ if (argumnets && argumnets.length===1)
277
+ {
278
+ if (argumnets[0].typeName)
279
+ resultType = argumnets[0].typeName?.right?.name ?? argumnets[0].typeName?.name;
280
+ else if (argumnets[0].type !== 'TSArrayType')
281
+ resultType = this._getTypeNameFromNode(argumnets[0]);
282
+ else if (argumnets[0].elementType.type !== 'TSTypeReference'){
283
+ isArray = true;
284
+ resultType = this._getTypeNameFromNode(argumnets[0]?.elementType);
285
+ }
286
+ else{
287
+ isArray = true;
288
+ resultType = argumnets[0].elementType?.typeName?.name || argumnets[0].elementType?.typeName?.right?.name;
289
+ }
290
+ }
291
+ }
292
+ else{
293
+ if (annotation.type === 'TSTypeReference')
294
+ resultType = annotation.typeName?.right?.name ?? annotation.typeName?.name;
295
+ else if (annotation.type !== 'TSArrayType')
296
+ resultType = this._getTypeNameFromNode(annotation);
297
+ else if (annotation.elementType.type !== 'TSTypeReference'){
271
298
  isArray = true;
272
- resultType = this._getTypeNameFromNode(argumnets[0]?.elementType);
299
+ resultType = this._getTypeNameFromNode(annotation?.elementType);
273
300
  }
274
301
  else{
275
302
  isArray = true;
276
- resultType = argumnets[0].elementType?.typeName?.name || argumnets[0].elementType?.typeName?.right?.name;
303
+ resultType = (annotation?.elementType?.typeName?.name || annotation?.elementType?.typeName?.right?.name);
277
304
  }
278
305
  }
279
306
  }
280
- else{
281
- if (annotation.type === 'TSTypeReference')
282
- resultType = annotation.typeName?.right?.name ?? annotation.typeName?.name;
283
- else if (annotation.type !== 'TSArrayType')
284
- resultType = this._getTypeNameFromNode(annotation);
285
- else if (annotation.elementType.type !== 'TSTypeReference'){
286
- isArray = true;
287
- resultType = this._getTypeNameFromNode(annotation?.elementType);
288
- }
289
- else{
290
- isArray = true;
291
- resultType = (annotation?.elementType?.typeName?.name || annotation?.elementType?.typeName?.right?.name);
292
- }
293
- }
294
-
295
307
  resultType = typesToAnnotation[resultType];
296
308
  if (isArray && resultType)
297
309
  resultType = `list<${resultType}>`
@@ -318,12 +330,19 @@ class FuncGeneratorPlugin {
318
330
  fs.writeFileSync(this.options.outputPath, baseImport);
319
331
  }
320
332
 
321
- _writeToPackageFile(filePath, imports, exports) {
322
- if (imports.length !== exports.length) return;
333
+ _checkPackageFileForDecoratorsExport(packagePath){
334
+ const content = fs.readFileSync(packagePath, "utf-8");
335
+ const decoratorsExportRegex = /export\s*\*\s*from\s*'\.\/package\.g';/;
336
+ if (!decoratorsExportRegex.test(content))
337
+ console.warn(`\nWARNING: Your package doesn't export package.g.ts file to package.ts \n please add "export * from './package.g';" to the package.ts file.\n`);
338
+ }
339
+
340
+ _writeToPackageFile(filePath, imports, exp) {
341
+ if (imports.length !== exp.length) return;
323
342
  let content = fs.readFileSync(filePath, "utf-8");
324
343
  for (let i = 0; i < imports.length; i++) {
325
344
  const importStatement = imports[i];
326
- const exportStatement = exports[i];
345
+ const exportStatement = exp[i];
327
346
  if (!content.includes(importStatement.trim()))
328
347
  content = importStatement + content + exportStatement;
329
348
  }