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)
...@@ -41,7 +41,7 @@ class ArchiveHelper { ...@@ -41,7 +41,7 @@ class ArchiveHelper {
} }
public async getBase64(folderPath: string): Promise<string> { public async getBase64(folderPath: string): Promise<string> {
let data: any; let data: string;
const tarDataStream = new stream.Writable({ const tarDataStream = new stream.Writable({
write(this: Writable, chunk: Buffer, _encoding: BufferEncoding, next: (error?: Error | null) => void) { write(this: Writable, chunk: Buffer, _encoding: BufferEncoding, next: (error?: Error | null) => void) {
if ( data ) { if ( data ) {
...@@ -55,9 +55,9 @@ class ArchiveHelper { ...@@ -55,9 +55,9 @@ class ArchiveHelper {
await this.compress(folderPath, tarDataStream); await this.compress(folderPath, tarDataStream);
await (new Promise((resolve, reject) => { data = await (new Promise((resolve) => {
tarDataStream.on('close', () => { tarDataStream.on('close', () => {
resolve(0); resolve(data);
}); });
})); }));
......
...@@ -48,7 +48,7 @@ class SharedAssignmentHelper { ...@@ -48,7 +48,7 @@ class SharedAssignmentHelper {
const isValid = validator(results); const isValid = validator(results);
return { return {
results: isValid ? results : results as any, results: isValid ? results : results as AssignmentFile,
isValid: isValid, isValid: isValid,
errors : validator.errors errors : validator.errors
}; };
......
...@@ -5,7 +5,7 @@ import JSON5 from 'json5'; ...@@ -5,7 +5,7 @@ import JSON5 from 'json5';
class SharedExerciseHelper { class SharedExerciseHelper {
validateResultFile(resultsFilePathOrStr: string, isFile: boolean = true): { results: ExerciseResultsFile | undefined, isValid: boolean, errors: Array<ErrorObject<string, Record<string, any>, unknown> | string> | null | undefined } { validateResultFile(resultsFilePathOrStr: string, isFile: boolean = true): { results: ExerciseResultsFile | undefined, isValid: boolean, errors: Array<ErrorObject | string> | null | undefined } {
const ajv = new Ajv(); const ajv = new Ajv();
const schema: JTDSchemaType<ExerciseResultsFile> = { const schema: JTDSchemaType<ExerciseResultsFile> = {
...@@ -49,7 +49,7 @@ class SharedExerciseHelper { ...@@ -49,7 +49,7 @@ class SharedExerciseHelper {
} }
return { return {
results: isValid ? results : results as any, results: isValid ? results : results as ExerciseResultsFile,
isValid: isValid, isValid: isValid,
errors : validator.errors errors : validator.errors
}; };
......
...@@ -4,12 +4,15 @@ class LazyVal<T> { ...@@ -4,12 +4,15 @@ class LazyVal<T> {
constructor(private valLoader: () => Promise<T> | T) {} constructor(private valLoader: () => Promise<T> | T) {}
get value(): Promise<T> { get value(): Promise<T> {
return new Promise<T>(async (resolve) => { return new Promise<T>((resolve) => {
if ( this.val === undefined ) { if ( this.val === undefined ) {
this.val = await this.valLoader(); Promise.resolve(this.valLoader()).then((value: T) => {
this.val = value;
resolve(value);
});
} else {
resolve(this.val);
} }
resolve(this.val);
}); });
} }
......
...@@ -11,7 +11,7 @@ class Toolbox { ...@@ -11,7 +11,7 @@ class Toolbox {
Source of getAllFiles and getTotalSize (modified for this project): https://coderrocketfuel.com/article/get-the-total-size-of-all-files-in-a-directory-using-node-js Source of getAllFiles and getTotalSize (modified for this project): https://coderrocketfuel.com/article/get-the-total-size-of-all-files-in-a-directory-using-node-js
*/ */
private async getAllFiles(dirPath: string, arrayOfFiles: Array<string> = []): Promise<Array<string>> { private async getAllFiles(dirPath: string, arrayOfFiles: Array<string> = []): Promise<Array<string>> {
let files = await fs.readdir(dirPath); const files = await fs.readdir(dirPath);
await Promise.all(files.map(async file => { await Promise.all(files.map(async file => {
if ( (await fs.stat(dirPath + '/' + file)).isDirectory() ) { if ( (await fs.stat(dirPath + '/' + file)).isDirectory() ) {
...@@ -22,7 +22,7 @@ class Toolbox { ...@@ -22,7 +22,7 @@ class Toolbox {
})); }));
return arrayOfFiles; return arrayOfFiles;
}; }
private async getTotalSize(directoryPath: string): Promise<number> { private async getTotalSize(directoryPath: string): Promise<number> {
const arrayOfFiles = await this.getAllFiles(directoryPath); const arrayOfFiles = await this.getAllFiles(directoryPath);
...@@ -34,7 +34,7 @@ class Toolbox { ...@@ -34,7 +34,7 @@ class Toolbox {
} }
return totalSize; return totalSize;
}; }
get fs() { get fs() {
return { return {
......
declare global { declare global {
interface BigInt {
toJSON: () => string;
}
interface Array<T> { interface Array<T> {
removeObjectDuplicates: (getProperty: (item: T) => any) => Array<T>; removeObjectDuplicates: (getProperty: (item: T) => unknown) => Array<T>;
} }
...@@ -22,15 +27,15 @@ function registerAll() { ...@@ -22,15 +27,15 @@ function registerAll() {
} }
function registerBigIntJson() { function registerBigIntJson() {
(BigInt.prototype as any).toJSON = function () { BigInt.prototype.toJSON = function () {
return this.toString(); return this.toString();
}; };
} }
function registerArrayRemoveObjectDuplicates() { function registerArrayRemoveObjectDuplicates() {
Array.prototype.removeObjectDuplicates = function <T>(this: Array<T>, getProperty: (item: T) => any): Array<T> { Array.prototype.removeObjectDuplicates = function <T>(this: Array<T>, getProperty: (item: T) => unknown): Array<T> {
return this.reduce((accumulator: Array<T>, current: T) => { return this.reduce((accumulator: Array<T>, current: T) => {
if ( !accumulator.find((item: any) => getProperty(item) === getProperty(current)) ) { if ( !accumulator.find((item: T) => getProperty(item) === getProperty(current)) ) {
accumulator.push(current); accumulator.push(current);
} }
return accumulator; return accumulator;
......
...@@ -131,7 +131,7 @@ class RecursiveFilesStats { ...@@ -131,7 +131,7 @@ class RecursiveFilesStats {
} }
return stat; return stat;
}; }
/** /**
* Get ext * Get ext
......
...@@ -11,20 +11,16 @@ class GitlabManager { ...@@ -11,20 +11,16 @@ class GitlabManager {
} }
async getTokens(codeOrRefresh: string, isRefresh: boolean = false, clientSecret: string = ''): Promise<GitlabToken> { async getTokens(codeOrRefresh: string, isRefresh: boolean = false, clientSecret: string = ''): Promise<GitlabToken> {
try { const response = await axios.post<GitlabToken>(SharedConfig.login.gitlab.url.token, {
const response = await axios.post<GitlabToken>(SharedConfig.login.gitlab.url.token, { client_id : SharedConfig.login.gitlab.client.id,
client_id : SharedConfig.login.gitlab.client.id, client_secret: clientSecret,
client_secret: clientSecret, grant_type : isRefresh ? 'refresh_token' : 'authorization_code',
grant_type : isRefresh ? 'refresh_token' : 'authorization_code', refresh_token: codeOrRefresh,
refresh_token: codeOrRefresh, code : codeOrRefresh,
code : codeOrRefresh, redirect_uri : SharedConfig.login.gitlab.url.redirect
redirect_uri : SharedConfig.login.gitlab.url.redirect });
});
return response.data;
return response.data;
} catch ( error ) {
throw error;
}
} }
async getRepositoryPipelines(repoId: number, branch: string = 'main'): Promise<Array<GitlabPipeline>> { async getRepositoryPipelines(repoId: number, branch: string = 'main'): Promise<Array<GitlabPipeline>> {
......
...@@ -3,8 +3,8 @@ enum GitlabRoute { ...@@ -3,8 +3,8 @@ enum GitlabRoute {
PROFILE_GET = '/user', PROFILE_GET = '/user',
USERS_GET = '/users', USERS_GET = '/users',
REPOSITORY_GET = '/projects/{{id}}', REPOSITORY_GET = '/projects/{{id}}',
REPOSITORY_CREATE = '/projects', REPOSITORY_CREATE = '/projects', // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
REPOSITORY_DELETE = '/projects/{{id}}', REPOSITORY_DELETE = '/projects/{{id}}', // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
REPOSITORY_EDIT = '/projects/{{id}}', REPOSITORY_EDIT = '/projects/{{id}}',
REPOSITORY_FORK = '/projects/{{id}}/fork', REPOSITORY_FORK = '/projects/{{id}}/fork',
REPOSITORY_MEMBER_ADD = '/projects/{{id}}/members', REPOSITORY_MEMBER_ADD = '/projects/{{id}}/members',
......