@codebolt/codeboltjs 1.1.65 → 1.1.67
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 +10 -1
- package/modules/fs.d.ts +31 -1
- package/modules/fs.js +76 -2
- package/package.json +1 -1
- package/src/modules/fs.ts +77 -2
package/index.d.ts
CHANGED
|
@@ -21,11 +21,20 @@ declare class Codebolt {
|
|
|
21
21
|
fs: {
|
|
22
22
|
createFile: (fileName: string, source: string, filePath: string) => Promise<import("@codebolt/types").CreateFileResponse>;
|
|
23
23
|
createFolder: (folderName: string, folderPath: string) => Promise<import("@codebolt/types").CreateFolderResponse>;
|
|
24
|
-
readFile: (
|
|
24
|
+
readFile: (filePath: string) => Promise<import("@codebolt/types").ReadFileResponse>;
|
|
25
25
|
updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("@codebolt/types").UpdateFileResponse>;
|
|
26
26
|
deleteFile: (filename: string, filePath: string) => Promise<import("@codebolt/types").DeleteFileResponse>;
|
|
27
27
|
deleteFolder: (foldername: string, folderpath: string) => Promise<import("@codebolt/types").DeleteFolderResponse>;
|
|
28
28
|
listFile: (folderPath: string, isRecursive?: boolean) => Promise<unknown>;
|
|
29
|
+
listCodeDefinitionNames: (path: string) => Promise<{
|
|
30
|
+
success: boolean;
|
|
31
|
+
result: any;
|
|
32
|
+
}>;
|
|
33
|
+
searchFiles: (path: string, regex: string, filePattern: string) => Promise<{
|
|
34
|
+
success: boolean;
|
|
35
|
+
result: any;
|
|
36
|
+
}>;
|
|
37
|
+
writeToFile: (relPath: string, newContent: string) => Promise<unknown>;
|
|
29
38
|
};
|
|
30
39
|
git: {
|
|
31
40
|
init: (path: string) => Promise<any>;
|
package/modules/fs.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare const cbfs: {
|
|
|
28
28
|
* @param {string} filePath - The path of the file to read.
|
|
29
29
|
* @returns {Promise<ReadFileResponse>} A promise that resolves with the server response.
|
|
30
30
|
*/
|
|
31
|
-
readFile: (
|
|
31
|
+
readFile: (filePath: string) => Promise<ReadFileResponse>;
|
|
32
32
|
/**
|
|
33
33
|
* @function updateFile
|
|
34
34
|
* @description Updates the content of a file.
|
|
@@ -60,5 +60,35 @@ declare const cbfs: {
|
|
|
60
60
|
* @returns {Promise<FileListResponse>} A promise that resolves with the list of files.
|
|
61
61
|
*/
|
|
62
62
|
listFile: (folderPath: string, isRecursive?: boolean) => Promise<unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* @function listCodeDefinitionNames
|
|
65
|
+
* @description Lists all code definition names in a given path.
|
|
66
|
+
* @param {string} path - The path to search for code definitions.
|
|
67
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
|
|
68
|
+
*/
|
|
69
|
+
listCodeDefinitionNames: (path: string) => Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
result: any;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* @function searchFiles
|
|
75
|
+
* @description Searches files in a given path using a regex pattern.
|
|
76
|
+
* @param {string} path - The path to search within.
|
|
77
|
+
* @param {string} regex - The regex pattern to search for.
|
|
78
|
+
* @param {string} filePattern - The file pattern to match files.
|
|
79
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
|
|
80
|
+
*/
|
|
81
|
+
searchFiles: (path: string, regex: string, filePattern: string) => Promise<{
|
|
82
|
+
success: boolean;
|
|
83
|
+
result: any;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* @function writeToFile
|
|
87
|
+
* @description Writes content to a file.
|
|
88
|
+
* @param {string} relPath - The relative path of the file to write to.
|
|
89
|
+
* @param {string} newContent - The new content to write into the file.
|
|
90
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
91
|
+
*/
|
|
92
|
+
writeToFile: (relPath: string, newContent: string) => Promise<unknown>;
|
|
63
93
|
};
|
|
64
94
|
export default cbfs;
|
package/modules/fs.js
CHANGED
|
@@ -68,13 +68,12 @@ const cbfs = {
|
|
|
68
68
|
* @param {string} filePath - The path of the file to read.
|
|
69
69
|
* @returns {Promise<ReadFileResponse>} A promise that resolves with the server response.
|
|
70
70
|
*/
|
|
71
|
-
readFile: (
|
|
71
|
+
readFile: (filePath) => {
|
|
72
72
|
return new Promise((resolve, reject) => {
|
|
73
73
|
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
74
74
|
"type": "fsEvent",
|
|
75
75
|
"action": "readFile",
|
|
76
76
|
"message": {
|
|
77
|
-
filename,
|
|
78
77
|
filePath
|
|
79
78
|
},
|
|
80
79
|
}));
|
|
@@ -186,5 +185,80 @@ const cbfs = {
|
|
|
186
185
|
});
|
|
187
186
|
});
|
|
188
187
|
},
|
|
188
|
+
/**
|
|
189
|
+
* @function listCodeDefinitionNames
|
|
190
|
+
* @description Lists all code definition names in a given path.
|
|
191
|
+
* @param {string} path - The path to search for code definitions.
|
|
192
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
|
|
193
|
+
*/
|
|
194
|
+
listCodeDefinitionNames: (path) => {
|
|
195
|
+
return new Promise((resolve, reject) => {
|
|
196
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
197
|
+
"type": "fsEvent",
|
|
198
|
+
"action": "listCodeDefinitionNames",
|
|
199
|
+
"message": {
|
|
200
|
+
path
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
204
|
+
const response = JSON.parse(data);
|
|
205
|
+
if (response.type === "listCodeDefinitionNamesResponse") {
|
|
206
|
+
resolve(response);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* @function searchFiles
|
|
213
|
+
* @description Searches files in a given path using a regex pattern.
|
|
214
|
+
* @param {string} path - The path to search within.
|
|
215
|
+
* @param {string} regex - The regex pattern to search for.
|
|
216
|
+
* @param {string} filePattern - The file pattern to match files.
|
|
217
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
|
|
218
|
+
*/
|
|
219
|
+
searchFiles: (path, regex, filePattern) => {
|
|
220
|
+
return new Promise((resolve, reject) => {
|
|
221
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
222
|
+
"type": "fsEvent",
|
|
223
|
+
"action": "searchFiles",
|
|
224
|
+
"message": {
|
|
225
|
+
path,
|
|
226
|
+
regex,
|
|
227
|
+
filePattern
|
|
228
|
+
}
|
|
229
|
+
}));
|
|
230
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
231
|
+
const response = JSON.parse(data);
|
|
232
|
+
if (response.type === "searchFilesResponse") {
|
|
233
|
+
resolve(response);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
/**
|
|
239
|
+
* @function writeToFile
|
|
240
|
+
* @description Writes content to a file.
|
|
241
|
+
* @param {string} relPath - The relative path of the file to write to.
|
|
242
|
+
* @param {string} newContent - The new content to write into the file.
|
|
243
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
244
|
+
*/
|
|
245
|
+
writeToFile: (relPath, newContent) => {
|
|
246
|
+
return new Promise((resolve, reject) => {
|
|
247
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
248
|
+
"type": "fsEvent",
|
|
249
|
+
"action": "writeToFile",
|
|
250
|
+
"message": {
|
|
251
|
+
relPath,
|
|
252
|
+
newContent
|
|
253
|
+
}
|
|
254
|
+
}));
|
|
255
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
256
|
+
const response = JSON.parse(data);
|
|
257
|
+
if (response.type === "writeToFileResponse") {
|
|
258
|
+
resolve(response);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
},
|
|
189
263
|
};
|
|
190
264
|
exports.default = cbfs;
|
package/package.json
CHANGED
package/src/modules/fs.ts
CHANGED
|
@@ -64,13 +64,12 @@ const cbfs = {
|
|
|
64
64
|
* @param {string} filePath - The path of the file to read.
|
|
65
65
|
* @returns {Promise<ReadFileResponse>} A promise that resolves with the server response.
|
|
66
66
|
*/
|
|
67
|
-
readFile: (
|
|
67
|
+
readFile: (filePath: string): Promise<ReadFileResponse> => {
|
|
68
68
|
return new Promise((resolve, reject) => {
|
|
69
69
|
cbws.getWebsocket.send(JSON.stringify({
|
|
70
70
|
"type":"fsEvent",
|
|
71
71
|
"action": "readFile",
|
|
72
72
|
"message": {
|
|
73
|
-
filename,
|
|
74
73
|
filePath
|
|
75
74
|
},
|
|
76
75
|
}));
|
|
@@ -182,6 +181,82 @@ const cbfs = {
|
|
|
182
181
|
});
|
|
183
182
|
});
|
|
184
183
|
},
|
|
184
|
+
/**
|
|
185
|
+
* @function listCodeDefinitionNames
|
|
186
|
+
* @description Lists all code definition names in a given path.
|
|
187
|
+
* @param {string} path - The path to search for code definitions.
|
|
188
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
|
|
189
|
+
*/
|
|
190
|
+
listCodeDefinitionNames: (path: string): Promise<{success: boolean, result: any}> => {
|
|
191
|
+
return new Promise((resolve, reject) => {
|
|
192
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
193
|
+
"type": "fsEvent",
|
|
194
|
+
"action": "listCodeDefinitionNames",
|
|
195
|
+
"message": {
|
|
196
|
+
path
|
|
197
|
+
}
|
|
198
|
+
}));
|
|
199
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
200
|
+
const response = JSON.parse(data);
|
|
201
|
+
if (response.type === "listCodeDefinitionNamesResponse") {
|
|
202
|
+
resolve(response);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @function searchFiles
|
|
210
|
+
* @description Searches files in a given path using a regex pattern.
|
|
211
|
+
* @param {string} path - The path to search within.
|
|
212
|
+
* @param {string} regex - The regex pattern to search for.
|
|
213
|
+
* @param {string} filePattern - The file pattern to match files.
|
|
214
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
|
|
215
|
+
*/
|
|
216
|
+
searchFiles: (path: string, regex: string, filePattern: string): Promise<{success: boolean, result: any}> => {
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
219
|
+
"type": "fsEvent",
|
|
220
|
+
"action": "searchFiles",
|
|
221
|
+
"message": {
|
|
222
|
+
path,
|
|
223
|
+
regex,
|
|
224
|
+
filePattern
|
|
225
|
+
}
|
|
226
|
+
}));
|
|
227
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
228
|
+
const response = JSON.parse(data);
|
|
229
|
+
if (response.type === "searchFilesResponse") {
|
|
230
|
+
resolve(response);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
/**
|
|
236
|
+
* @function writeToFile
|
|
237
|
+
* @description Writes content to a file.
|
|
238
|
+
* @param {string} relPath - The relative path of the file to write to.
|
|
239
|
+
* @param {string} newContent - The new content to write into the file.
|
|
240
|
+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the write operation result.
|
|
241
|
+
*/
|
|
242
|
+
writeToFile: (relPath:string, newContent:string) => {
|
|
243
|
+
return new Promise((resolve, reject) => {
|
|
244
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
245
|
+
"type": "fsEvent",
|
|
246
|
+
"action": "writeToFile",
|
|
247
|
+
"message": {
|
|
248
|
+
relPath,
|
|
249
|
+
newContent
|
|
250
|
+
}
|
|
251
|
+
}));
|
|
252
|
+
cbws.getWebsocket.on('message', (data:string) => {
|
|
253
|
+
const response = JSON.parse(data);
|
|
254
|
+
if (response.type === "writeToFileResponse") {
|
|
255
|
+
resolve(response);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
},
|
|
185
260
|
|
|
186
261
|
};
|
|
187
262
|
|