Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • jw_sonar
  • jw_sonar_backup
  • main
  • move-to-esm-only
  • open_tool_for_self_hosting
  • v5.0
  • v4.1
  • v4.2
8 results

Target

Select target project
  • dojo_project/projects/shared/nodesharedcode
1 result
Select Git revision
  • jw_sonar
  • jw_sonar_backup
  • main
  • move-to-esm-only
  • open_tool_for_self_hosting
  • v5.0
  • v4.1
  • v4.2
8 results
Show changes
Commits on Source (1)
......@@ -11,14 +11,14 @@ class SharedConfig {
enabled: boolean
url: string
token: string
}
};
constructor() {
this.production = process.env.NODE_ENV === 'production';
this.sonar = {
enabled: ['yes', 'true', '1', 'on'].includes(process.env.SONAR_ENABLED?.trim()?.toLowerCase() ?? ''),
url: process.env.SONAR_URL || '',
token: process.env.SONAR_TOKEN || ''
enabled: [ 'yes', 'true', '1', 'on' ].includes(process.env.SONAR_ENABLED?.trim()?.toLowerCase() ?? ''),
url : process.env.SONAR_URL ?? '',
token : process.env.SONAR_TOKEN ?? ''
};
this.logsFolder = process.env.LOGS_FOLDER ?? '';
......
......@@ -4,7 +4,7 @@ import path from 'path';
class Toolbox {
public urlToPath(url: string): string {
return url.replace(/^([a-z]{3,5}:\/{2})?[a-z.@]+(:[0-9]{1,5})?.(.*)/, '$3').replace('.git', '');
return url.replace(/^([a-z]{3,5}:\/{2})?[a-z.@]+(:\d{1,5})?.(.*)/, '$3').replace('.git', '');
}
/*
......
......@@ -64,7 +64,7 @@ function registerStringCapitalizeName() {
function registerStringConvertWithEnvVars() {
String.prototype.convertWithEnvVars = function (this: string): string {
return this.replace(/\${?([a-zA-Z0-9_]+)}?/g, (_match: string, p1: string) => process.env[p1] || '');
return this.replace(/\${?(\w+)}?/g, (_match: string, p1: string) => process.env[p1] ?? '');
};
}
......
......@@ -57,10 +57,10 @@ class RecursiveFilesStats {
name: file,
path: path.join(rootPath, file)
})).filter(item => {
if ( options.include && options.include.test(item.path) ) {
if ( options.include?.test(item.path) ) {
return true;
}
if ( options.exclude && options.exclude.test(item.path) ) {
if ( options.exclude?.test(item.path) ) {
return false;
}
if ( options.ignored ) {
......
......@@ -10,9 +10,7 @@ class SharedGitlabManager {
private readonly refreshTokenFunction?: () => Promise<string>;
setToken(token: string) {
this.api = new Gitlab(Object.assign({
host: this.gitlabUrl ?? ''
}, this.refreshTokenFunction ? { oauthToken: token } : { token: token }));
this.api = new Gitlab({ host: this.gitlabUrl ?? '', ...(this.refreshTokenFunction ? { oauthToken: token } : { token: token }) });
}
constructor(public gitlabUrl: string, token: string, public clientId?: string, public urlRedirect?: string, public urlToken?: string, refreshTokenFunction?: () => Promise<string>) {
......
......@@ -4,19 +4,19 @@ import SharedConfig from '../config/SharedConfig';
class SharedSonarManager {
// Use custom instance to allow self-signed certificates
private instance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
});
private readonly axiosInstance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
});
async isSonarSupported(): Promise<boolean> {
if (!SharedConfig.sonar.enabled) {
if ( !SharedConfig.sonar.enabled ) {
return false;
}
try {
const sonar = await this.instance.get(SharedConfig.sonar.url);
const sonar = await this.axiosInstance.get(SharedConfig.sonar.url);
return sonar.status == 200;
} catch ( error ) {
return false;
......@@ -29,15 +29,16 @@ class SharedSonarManager {
* @param language
*/
mapLanguage(language: string): string {
switch (language) {
case "csharp":
return "cs";
case "python":
return "py";
switch ( language ) {
case 'csharp':
return 'cs';
case 'python':
return 'py';
default:
return language;
}
}
}
export default new SharedSonarManager();
\ No newline at end of file