Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flp-config): tidy up and improve logging configuration #2761

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/grumpy-shirts-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/flp-config-sub-generator': patch
---

tidy up
4 changes: 1 addition & 3 deletions packages/adp-tooling/src/preview/routes-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ export default class RoutesHandler {
const project = this.util.getProject();
const getPath = (projectPath: string, relativePath: string): string =>
path.join(projectPath, DirName.Changes, relativePath).split(path.sep).join(path.posix.sep);
const annotations = dataSources[dataSourceId].settings?.annotations
? [...dataSources[dataSourceId].settings.annotations].reverse()
: [];
const annotations = [...(dataSources[dataSourceId].settings?.annotations ?? [])].reverse();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Causing issues in the PR build, no need for changeset as it's a ts error

for (const annotation of annotations) {
const annotationSetting = dataSources[annotation];
if (annotationSetting.type === 'ODataAnnotation') {
Expand Down
5 changes: 3 additions & 2 deletions packages/flp-config-sub-generator/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ export default class extends Generator {
this.options = opts;

FlpGenLogger.configureLogging(
this.options.logger,
this.rootGeneratorName(),
this.log,
this.options.logWrapper,
this.options.logLevel
this.options.logLevel,
this.options.logger,
this.vscode
);

// If launched standalone, set the header, title and description
Expand Down
6 changes: 3 additions & 3 deletions packages/flp-config-sub-generator/src/utils/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import type { TOptions } from 'i18next';
import i18next from 'i18next';
import translations from '../translations/flp-config-sub-generator.i18n.json';

const ui5LibGeneratorNs = 'ui5-lib-generator';
const flpConfigGeneratorNs = 'flp-config-generator';

/**
* Initialize i18next with the translations for this module.
*/
export async function initI18n(): Promise<void> {
await i18next.init({ lng: 'en', fallbackLng: 'en' }, () =>
i18next.addResourceBundle('en', ui5LibGeneratorNs, translations)
i18next.addResourceBundle('en', flpConfigGeneratorNs, translations)
);
}

Expand All @@ -22,7 +22,7 @@ export async function initI18n(): Promise<void> {
*/
export function t(key: string, options?: TOptions): string {
if (!options?.ns) {
options = Object.assign(options ?? {}, { ns: ui5LibGeneratorNs });
options = Object.assign(options ?? {}, { ns: flpConfigGeneratorNs });
}
return i18next.t(key, options);
}
Expand Down
18 changes: 10 additions & 8 deletions packages/flp-config-sub-generator/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ export default class FlpGenLogger {
}

/**
* Configures the vscode logger.
* Configures the logger.
*
* @param vscLogger - the vscode logger
* @param loggerName - the logger name
* @param yoLogger - the yeoman logger
* @param vscode - the vscode instance
* @param logWrapper - log wrapper instance
* @param logLevel - the log level
* @param vscLogger - the vscode logger
* @param vscode - the vscode instance
*/
static configureLogging(
vscLogger: IVSCodeExtLogger,
loggerName: string,
yoLogger: Logger,
vscode?: unknown,
logLevel?: LogLevel
logWrapper?: LogWrapper,
logLevel?: LogLevel,
vscLogger?: IVSCodeExtLogger,
vscode?: unknown
): void {
const logWrapper = new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
FlpGenLogger.logger = logWrapper;
const logger = logWrapper ?? new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
FlpGenLogger.logger = logger;
}
}
Loading