Skip to content

Commit ec6bf2a

Browse files
committed
fix(load-component): improve error logging and debugging in utility functions
- Add detailed console logs for JSON parsing errors in readJsonFile function - Log component path and directory files to help identify entry file issues - Enhance debugging information with fsStat, packageInfo, and tsconfigPath outputs - Update package version to 0.0.10-beta.6 for load-component - Update package version to 0.1.6-beta.18 for engine package Signed-off-by: zxypro1 <1018995004@qq.com>
1 parent a86e154 commit ec6bf2a

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/engine/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless-devs/engine",
3-
"version": "0.1.6-beta.17",
3+
"version": "0.1.6-beta.18",
44
"description": "a engine lib for serverless-devs",
55
"main": "lib/index.js",
66
"scripts": {

packages/load-component/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@serverless-devs/load-component",
3-
"version": "0.0.10-beta.5",
3+
"version": "0.0.10-beta.6",
44
"description": "request for serverless-devs",
55
"main": "lib/index.js",
66
"scripts": {

packages/load-component/src/utils/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export function readJsonFile(filePath: string) {
1414
const data = fs.readFileSync(filePath, 'utf8');
1515
try {
1616
return JSON.parse(data);
17-
} catch (error) { }
17+
} catch (error) {
18+
console.log(`[readJsonFile] Failed to parse JSON file: ${filePath}`);
19+
console.log(`[readJsonFile] Error message: ${error instanceof Error ? error.message : String(error)}`);
20+
console.log(`[readJsonFile] Error stack: ${error instanceof Error ? error.stack : 'No stack trace'}`);
21+
}
1822
}
1923
}
2024

@@ -37,6 +41,10 @@ const getEntryFile = async (componentPath: string, logger: any) => {
3741
const indexPath = path.resolve(componentPath, './index.js');
3842
if (fs.existsSync(indexPath)) return indexPath;
3943
// No valid entry file found
44+
console.log('componentPath: ', componentPath);
45+
if (fsStat.isDirectory()) {
46+
console.log('component path files: ', fs.readdirSync(componentPath));
47+
}
4048
console.log(`fsStat: ${JSON.stringify(fsStat)}`);
4149
console.log(`packageInfo: ${JSON.stringify(packageInfo)}`);
4250
console.log(`tsconfigPath: ${tsconfigPath}`);

0 commit comments

Comments
 (0)