1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

build(deps): update latest

This commit is contained in:
2025-05-13 23:04:47 +02:00
parent 2b6669bf4a
commit 643989cc44
27 changed files with 3259 additions and 1393 deletions

View File

@ -19,7 +19,7 @@ export class Challenge implements ChallengeOptions {
public name: string
public path: string
constructor(options: ChallengeOptions) {
public constructor(options: ChallengeOptions) {
const { name } = options
this.name = name
this.path = fileURLToPath(new URL(`./${name}`, Challenge.BASE_URL))

View File

@ -20,7 +20,7 @@ export interface GitAffectedOptions {
export class GitAffected implements GitAffectedOptions {
public base?: string
constructor(options: GitAffectedOptions = {}) {
public constructor(options: GitAffectedOptions = {}) {
this.base = options.base
}

View File

@ -38,7 +38,7 @@ export class Solution implements SolutionOptions {
public path: string
public temporaryFolder: TemporaryFolder
constructor(options: SolutionOptions) {
public constructor(options: SolutionOptions) {
const { programmingLanguageName, challenge, name } = options
this.programmingLanguageName = programmingLanguageName
this.challenge = challenge
@ -92,7 +92,9 @@ export class Solution implements SolutionOptions {
}
}
static async generate(options: GenerateSolutionOptions): Promise<Solution> {
public static async generate(
options: GenerateSolutionOptions,
): Promise<Solution> {
const { name, challengeName, programmingLanguageName, githubUser } = options
const challenge = new Challenge({ name: challengeName })
if (!(await isExistingPath(challenge.path))) {
@ -116,7 +118,7 @@ export class Solution implements SolutionOptions {
return solution
}
static async get(options: GetSolutionOptions): Promise<Solution> {
public static async get(options: GetSolutionOptions): Promise<Solution> {
const { name, challengeName, programmingLanguageName } = options
const challenge = new Challenge({
name: challengeName,
@ -132,7 +134,9 @@ export class Solution implements SolutionOptions {
return solution
}
static async getManyByChallenge(challenge: Challenge): Promise<Solution[]> {
public static async getManyByChallenge(
challenge: Challenge,
): Promise<Solution[]> {
const solutionsPath = path.join(challenge.path, "solutions")
const languagesSolution = (await fs.promises.readdir(solutionsPath)).filter(
(name) => {
@ -151,7 +155,7 @@ export class Solution implements SolutionOptions {
return await Solution.getManyByPaths(paths)
}
static async getManyByProgrammingLanguages(
public static async getManyByProgrammingLanguages(
programmingLanguages?: string[],
): Promise<Solution[]> {
const languages =
@ -185,7 +189,7 @@ export class Solution implements SolutionOptions {
* @param paths relative to `challenges` (e.g: `challenges/hello-world/solutions/c/function`)
* @returns
*/
static async getManyByPaths(paths: string[]): Promise<Solution[]> {
public static async getManyByPaths(paths: string[]): Promise<Solution[]> {
const solutions: string[] = []
for (const path of paths) {
if (await isExistingPath(path)) {

View File

@ -25,7 +25,7 @@ export class SolutionTestsResult implements SolutionTestsResultOptions {
"Success:",
)} Tests passed! 🎉`
constructor(options: SolutionTestsResultOptions) {
public constructor(options: SolutionTestsResultOptions) {
this.tests = options.tests.sort((a, b) => {
return a.testNumber - b.testNumber
})

View File

@ -35,7 +35,7 @@ export class Test implements TestOptions {
public output: string
public stdout: string
constructor(options: TestOptions) {
public constructor(options: TestOptions) {
this.testNumber = options.testNumber
this.path = options.path
this.isSuccess = options.isSuccess
@ -44,7 +44,7 @@ export class Test implements TestOptions {
this.stdout = options.stdout
}
static async runAll(solution: Solution): Promise<SolutionTestsResult> {
public static async runAll(solution: Solution): Promise<SolutionTestsResult> {
const testsPath = path.join(solution.challenge.path, "test")
const testsFolders = await fs.promises.readdir(testsPath)
const testsNumbers = testsFolders.map((test) => {
@ -62,7 +62,7 @@ export class Test implements TestOptions {
return new SolutionTestsResult({ solution, tests, elapsedTimeMilliseconds })
}
static async getInputOutput(testPath: string): Promise<InputOutput> {
public static async getInputOutput(testPath: string): Promise<InputOutput> {
const inputPath = path.join(testPath, "input.txt")
const outputPath = path.join(testPath, "output.txt")
const input = await fs.promises.readFile(inputPath, { encoding: "utf-8" })
@ -72,7 +72,9 @@ export class Test implements TestOptions {
return { input, output }
}
static async runManyWithSolutions(solutions: Solution[]): Promise<number> {
public static async runManyWithSolutions(
solutions: Solution[],
): Promise<number> {
const solutionTestsResultsPromises: Array<Promise<SolutionTestsResult>> = []
let isSolutionSuccess = true
for (const solution of solutions) {
@ -98,7 +100,7 @@ export class Test implements TestOptions {
return 1
}
static async run(options: TestRunOptions): Promise<Test> {
public static async run(options: TestRunOptions): Promise<Test> {
const { input, output } = await Test.getInputOutput(options.path)
try {
const { stdout } = await docker.run(