Skip to content

Commit fcaa70c

Browse files
fix(adp-tooling): Improve logging for Cloud Foundry setup (#4599)
* fix: improve logging * chore: create changeset * fix: lint issue * Linting auto fix commit --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 499bff1 commit fcaa70c

7 files changed

Lines changed: 15 additions & 8 deletions

File tree

.changeset/young-birds-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sap-ux/adp-tooling": patch
3+
---
4+
5+
fix(adp-tooling): Improve logging for Cloud Foundry setup

packages/adp-tooling/src/cf/core/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export async function isLoggedInCf(cfConfig: CfConfig, logger: ToolsLogger): Pro
2929
}
3030

3131
try {
32-
const token = await cfGetAuthToken();
33-
logger?.log(`Retrieved CF auth token: ${token}`);
32+
await cfGetAuthToken();
3433
return true;
3534
} catch (e) {
3635
logger?.error(`Error occurred while trying to check if it is logged in: ${e?.message}`);

packages/adp-tooling/src/cf/services/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export async function getCfUi5AppInfo(
171171
appId
172172
)}&${appHostIdParams}`;
173173

174-
logger?.log(`Fetching ui5AppInfo.json from FDC: ${url}`);
174+
logger?.log(`Fetching ui5AppInfo.json`);
175175

176176
try {
177177
const response = await axios.get(url, requestArguments.options);

packages/adp-tooling/src/writer/cf.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,5 +159,8 @@ export async function setupCfPreview(
159159
}
160160

161161
await writeUi5AppInfo(basePath, ui5AppInfo, logger);
162+
163+
logger?.log('Starting build');
162164
await runBuild(basePath, { ADP_BUILDER_MODE: 'preview' });
165+
logger?.log('Build completed');
163166
}

packages/adp-tooling/test/unit/cf/core/auth.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ describe('CF Core Auth', () => {
7272

7373
expect(result).toBe(true);
7474
expect(mockCfGetAuthToken).toHaveBeenCalledTimes(1);
75-
expect(mockLogger.log).toHaveBeenCalledWith(`Retrieved CF auth token: ${mockToken}`);
7675
});
7776

7877
test('should return false when cfGetAuthToken throws an error', async () => {

packages/adp-tooling/test/unit/cf/services/api.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ describe('CF Services API', () => {
261261
} as Record<string, string>)
262262
} as Record<string, unknown>)
263263
);
264-
expect(mockLogger.log).toHaveBeenCalledWith(
265-
'Fetching ui5AppInfo.json from FDC: https://ui5-flexibility-design-and-configuration.sapui5flex.cfapps.test.cf.com/api/business-service/ui5appinfo?appId=test-app-id&appHostId=host-1&appHostId=host-2'
266-
);
264+
expect(mockLogger.log).toHaveBeenCalledWith('Fetching ui5AppInfo.json');
267265
expect(mockLogger.log).toHaveBeenCalledWith('Successfully retrieved ui5AppInfo.json from FDC');
268266
});
269267

packages/adp-tooling/test/unit/writer/cf.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ describe('CF Writer', () => {
232232
describe('setupCfPreview', () => {
233233
const mockLogger = {
234234
info: jest.fn(),
235-
error: jest.fn()
235+
error: jest.fn(),
236+
log: jest.fn()
236237
} as unknown as ToolsLogger;
237238

238239
const mockCfConfig: CfConfig = {
@@ -287,6 +288,8 @@ describe('CF Writer', () => {
287288
expect(mockGetBaseAppId).toHaveBeenCalledWith(projectDir);
288289
expect(mockGetCfUi5AppInfo).toHaveBeenCalledWith('test-app-id', ['host-123'], mockCfConfig, mockLogger);
289290
expect(mockRunBuild).toHaveBeenCalledWith(projectDir, { ADP_BUILDER_MODE: 'preview' });
291+
expect(mockLogger.log).toHaveBeenCalledWith('Starting build');
292+
expect(mockLogger.log).toHaveBeenCalledWith('Build completed');
290293
});
291294

292295
test('should throw error when serviceInstanceName not found', async () => {

0 commit comments

Comments
 (0)