@codebolt/codeboltjs 1.1.35 → 1.1.37

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/index.d.ts CHANGED
@@ -131,7 +131,7 @@ declare class Codebolt {
131
131
  executeCommandWithStream(command: string): EventEmitter<[never]>;
132
132
  };
133
133
  codeutils: {
134
- getJsTree: (filePath?: string | undefined) => Promise<import("@codebolt/types").GetJsTreeResponse>;
134
+ getJsTree: (filePath?: string | undefined) => Promise<any>;
135
135
  getAllFilesAsMarkDown: () => Promise<string>;
136
136
  performMatch: (matcherDefinition: object, problemPatterns: any[], problems: any[]) => Promise<import("@codebolt/types").MatchProblemResponse>;
137
137
  getMatcherList: () => Promise<import("@codebolt/types").GetMatcherListTreeResponse>;
@@ -1,4 +1,4 @@
1
- import { GetJsTreeResponse, MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
1
+ import { MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
2
2
  /**
3
3
  * A utility module for working with code.
4
4
  */
@@ -8,7 +8,7 @@ declare const cbcodeutils: {
8
8
  * @param {string} filePath - The path of the file to retrieve the JS tree for.
9
9
  * @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
10
10
  */
11
- getJsTree: (filePath?: string) => Promise<GetJsTreeResponse>;
11
+ getJsTree: (filePath?: string) => Promise<any>;
12
12
  /**
13
13
  * Retrieves all files as Markdown.
14
14
  * @returns {Promise<string>} A promise that resolves with the Markdown content of all files.
@@ -70,7 +70,8 @@ const cbcodeutils = {
70
70
  else if (path_1.default.extname(file.name) === '.js') {
71
71
  const code = fs.readFileSync(path_1.default.join(directory, file.name), 'utf-8');
72
72
  console.log(code);
73
- const tree = parser.parse(code);
73
+ let tree = parser.parse(code);
74
+ tree.rootNode.path = path_1.default.join(directory, file.name); // Set file path for t
74
75
  trees.push(tree);
75
76
  }
76
77
  });
@@ -82,13 +83,14 @@ const cbcodeutils = {
82
83
  // Read a single JavaScript file
83
84
  const code = fs.readFileSync(pathInput, 'utf-8');
84
85
  let tree = parser.parse(code);
86
+ tree.rootNode.path = pathInput; // Set file path for t
85
87
  trees.push(tree);
86
88
  }
87
- return trees; // Return an array of abstract syntax trees (ASTs)
89
+ resolve({ event: 'GetJsTreeResponse', payload: trees }); // Return an array of abstract syntax trees (ASTs)
88
90
  }
89
91
  catch (error) {
90
92
  console.error('An error occurred:', error);
91
- return null; // Return null in case of error
93
+ return { event: 'GetJsTreeResponse', payload: null }; // Return null in case of error
92
94
  }
93
95
  }
94
96
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -16,7 +16,7 @@ const cbcodeutils = {
16
16
  * @param {string} filePath - The path of the file to retrieve the JS tree for.
17
17
  * @returns {Promise<GetJsTreeResponse>} A promise that resolves with the JS tree response.
18
18
  */
19
- getJsTree: (filePath?: string): Promise<GetJsTreeResponse> => {
19
+ getJsTree: (filePath?: string): Promise<any> => {
20
20
  return new Promise( async (resolve, reject) => {
21
21
  cbws.getWebsocket.send(JSON.stringify({
22
22
  "type": "settingEvent",
@@ -33,6 +33,7 @@ const cbcodeutils = {
33
33
  parser.setLanguage(JavaScript);
34
34
  const trees = [];
35
35
  const functionNodes = [];
36
+
36
37
  const processDirectory = (directory:any) => {
37
38
  console.log("isdir")
38
39
  // Read all files in the directory
@@ -46,7 +47,8 @@ const cbcodeutils = {
46
47
  } else if (path.extname(file.name) === '.js') {
47
48
  const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
48
49
  console.log(code);
49
- const tree = parser.parse(code);
50
+ let tree:any = parser.parse(code);
51
+ tree.rootNode.path = path.join(directory, file.name); // Set file path for t
50
52
  trees.push(tree);
51
53
  }
52
54
  });
@@ -57,15 +59,16 @@ const cbcodeutils = {
57
59
  } else if (path.extname(pathInput) === '.js') {
58
60
  // Read a single JavaScript file
59
61
  const code = fs.readFileSync(pathInput, 'utf-8');
60
- let tree = parser.parse(code);
62
+ let tree:any = parser.parse(code);
63
+ tree.rootNode.path = pathInput; // Set file path for t
61
64
 
62
65
  trees.push(tree);
63
66
  }
64
67
 
65
- return trees; // Return an array of abstract syntax trees (ASTs)
68
+ resolve({ event: 'GetJsTreeResponse',payload:trees}); // Return an array of abstract syntax trees (ASTs)
66
69
  } catch (error) {
67
70
  console.error('An error occurred:', error);
68
- return null; // Return null in case of error
71
+ return { event: 'GetJsTreeResponse',payload:null}; // Return null in case of error
69
72
  }
70
73
  }
71
74
  });