Skip to content

Commit 696de15

Browse files
committed
chore: maintenance
1 parent bc1d34f commit 696de15

35 files changed

+3543
-4229
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
challenges
3+
templates
4+
temp
5+
tmp
6+
build

.eslintrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": ["conventions"],
3+
"plugins": ["import", "unicorn"],
4+
"parserOptions": {
5+
"project": "./tsconfig.json"
6+
},
7+
"env": {
8+
"node": true,
9+
"jest": true
10+
},
11+
"rules": {
12+
"import/extensions": ["error", "always"],
13+
"unicorn/prevent-abbreviations": "error"
14+
}
15+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/challenges.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: 'Use Node.js'
2323
uses: 'actions/[email protected]'
2424
with:
25-
node-version: '16.x'
25+
node-version: 'lts/*'
2626
cache: 'npm'
2727

2828
- name: 'Install'

.github/workflows/cli.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: 'Use Node.js'
1616
uses: 'actions/[email protected]'
1717
with:
18-
node-version: '16.x'
18+
node-version: 'lts/*'
1919
cache: 'npm'
2020

2121
- name: 'Install'
@@ -34,7 +34,7 @@ jobs:
3434
- name: 'Use Node.js'
3535
uses: 'actions/[email protected]'
3636
with:
37-
node-version: '16.x'
37+
node-version: 'lts/*'
3838
cache: 'npm'
3939

4040
- name: 'Install'
@@ -56,7 +56,7 @@ jobs:
5656
- name: 'Use Node.js'
5757
uses: 'actions/[email protected]'
5858
with:
59-
node-version: '16.x'
59+
node-version: 'lts/*'
6060
cache: 'npm'
6161

6262
- name: 'Install'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ npm-debug.log*
77

88
# production
99
build
10+
.swc
1011
__pycache__
1112
obj
1213
bin

.swcrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"jsc": {
3+
"parser": {
4+
"syntax": "typescript",
5+
"decorators": true,
6+
"dynamicImport": true
7+
},
8+
"transform": {
9+
"legacyDecorator": true,
10+
"decoratorMetadata": true
11+
},
12+
"target": "es2022",
13+
"loose": true
14+
},
15+
"module": {
16+
"type": "commonjs",
17+
"strict": false,
18+
"strictMode": true,
19+
"lazy": false,
20+
"noInterop": false
21+
}
22+
}

cli/__test__/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { Docker } from '../services/Docker'
1+
import { Docker } from '../services/Docker.js'
22

33
jest.setTimeout(Docker.MAXIMUM_TIMEOUT_MILLISECONDS)

cli/cli.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Builtins, Cli } from 'clipanion'
22

3-
import { GenerateChallengeCommand } from './commands/generate/challenge'
4-
import { GenerateSolutionCommand } from './commands/generate/solution'
5-
import { RunTestCommand } from './commands/run/test'
3+
import { GenerateChallengeCommand } from './commands/generate/challenge.js'
4+
import { GenerateSolutionCommand } from './commands/generate/solution.js'
5+
import { RunTestCommand } from './commands/run/test.js'
66

77
export const cli = new Cli({
88
binaryLabel: 'programming-challenges',

cli/commands/generate/__test__/challenge.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import getStream from 'get-stream'
77
import fsMock from 'mock-fs'
88
import date from 'date-and-time'
99

10-
import { cli } from '../../../cli'
11-
import { isExistingPath } from '../../../utils/isExistingPath'
10+
import { cli } from '../../../cli.js'
11+
import { isExistingPath } from '../../../utils/isExistingPath.js'
1212

1313
const input = ['generate', 'challenge']
1414
const githubUser = 'Divlo'

cli/commands/generate/__test__/solution.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import getStream from 'get-stream'
77
import fsMock from 'mock-fs'
88
import date from 'date-and-time'
99

10-
import { cli } from '../../../cli'
11-
import { isExistingPath } from '../../../utils/isExistingPath'
10+
import { cli } from '../../../cli.js'
11+
import { isExistingPath } from '../../../utils/isExistingPath.js'
1212

1313
const input = ['generate', 'solution']
1414
const githubUser = 'Divlo'

cli/commands/generate/challenge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Command, Option } from 'clipanion'
22
import * as typanion from 'typanion'
33
import chalk from 'chalk'
44

5-
import { Challenge } from '../../services/Challenge'
5+
import { Challenge } from '../../services/Challenge.js'
66

77
export class GenerateChallengeCommand extends Command {
88
static paths = [['generate', 'challenge']]

cli/commands/generate/solution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Command, Option } from 'clipanion'
22
import * as typanion from 'typanion'
33
import chalk from 'chalk'
44

5-
import { Solution } from '../../services/Solution'
5+
import { Solution } from '../../services/Solution.js'
66

77
export class GenerateSolutionCommand extends Command {
88
static paths = [['generate', 'solution']]

cli/commands/run/__test__/test.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { PassThrough } from 'node:stream'
22

33
import chalk from 'chalk'
44

5-
import { cli } from '../../../cli'
6-
import { Test } from '../../../services/Test'
5+
import { cli } from '../../../cli.js'
6+
import { Test } from '../../../services/Test.js'
77

88
const input = ['run', 'test']
99
const challenge = 'hello-world'

cli/commands/run/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { Command, Option } from 'clipanion'
22
import * as typanion from 'typanion'
33
import chalk from 'chalk'
44

5-
import { Solution } from '../../services/Solution'
6-
import { GitAffected } from '../../services/GitAffected'
7-
import { template } from '../../services/Template'
8-
import { Test } from '../../services/Test'
5+
import { Solution } from '../../services/Solution.js'
6+
import { GitAffected } from '../../services/GitAffected.js'
7+
import { template } from '../../services/Template.js'
8+
import { Test } from '../../services/Test.js'
99

1010
export class RunTestCommand extends Command {
1111
static paths = [['run', 'test']]

cli/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env node
22
import { Cli } from 'clipanion'
33

4-
import { cli } from './cli'
4+
import { cli } from './cli.js'
55

6-
const [, , ...args] = process.argv
6+
const [, , ...arguments_] = process.argv
77

8-
cli.runExit(args, Cli.defaultContext).catch(() => {
8+
cli.runExit(arguments_, Cli.defaultContext).catch(() => {
99
console.error('Error occurred...')
1010
process.exit(1)
1111
})

cli/services/Challenge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import fs from 'node:fs'
33

44
import validateProjectName from 'validate-npm-package-name'
55

6-
import { isExistingPath } from '../utils/isExistingPath'
7-
import { template } from './Template'
6+
import { isExistingPath } from '../utils/isExistingPath.js'
7+
import { template } from './Template.js'
88

99
export interface ChallengeOptions {
1010
name: string

cli/services/GitAffected.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import execa from 'execa'
22

3-
import { Challenge } from './Challenge'
4-
import { Solution } from './Solution'
3+
import { Challenge } from './Challenge.js'
4+
import { Solution } from './Solution.js'
55

6-
const solutionsRegex = /challenges\/[\s\S]*\/solutions\/(c|cpp|cs|dart|java|javascript|python|rust|typescript)\/[\s\S]*\/(.*).(c|cpp|cs|dart|java|js|py|rs|ts)/
6+
const solutionsRegex = /challenges\/[\S\s]*\/solutions\/(c|cpp|cs|dart|java|javascript|python|rust|typescript)\/[\S\s]*\/(.*).(c|cpp|cs|dart|java|js|py|rs|ts)/
77

88
const dockerRegex = /templates\/docker\/(c|cpp|cs|dart|java|javascript|python|rust|typescript)\/(.*)/
99

10-
const inputOutputRegex = /challenges\/[\s\S]*\/test\/(.*)\/(input.txt|output.txt)/
10+
const inputOutputRegex = /challenges\/[\S\s]*\/test\/(.*)\/(input.txt|output.txt)/
1111

1212
export interface GitAffectedOptions {
1313
isContinuousIntegration: boolean

cli/services/Solution.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import fs from 'node:fs'
44
import {
55
createTemporaryEmptyFolder,
66
TEMPORARY_PATH
7-
} from '../utils/createTemporaryEmptyFolder'
8-
import { isExistingPath } from '../utils/isExistingPath'
9-
import { Challenge } from './Challenge'
10-
import { copyDirectory } from '../utils/copyDirectory'
11-
import { template } from './Template'
12-
import { docker } from './Docker'
13-
import { Test } from './Test'
7+
} from '../utils/createTemporaryEmptyFolder.js'
8+
import { isExistingPath } from '../utils/isExistingPath.js'
9+
import { Challenge } from './Challenge.js'
10+
import { copyDirectory } from '../utils/copyDirectory.js'
11+
import { template } from './Template.js'
12+
import { docker } from './Docker.js'
13+
import { Test } from './Test.js'
1414

1515
export interface GetSolutionOptions {
1616
programmingLanguageName: string

cli/services/Template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import fs from 'node:fs'
44
import { replaceInFile } from 'replace-in-file'
55
import date from 'date-and-time'
66

7-
import { copyDirectory } from '../utils/copyDirectory'
7+
import { copyDirectory } from '../utils/copyDirectory.js'
88

99
const TEMPLATE_PATH = path.join(__dirname, '..', '..', 'templates')
1010
const TEMPLATE_DOCKER_PATH = path.join(TEMPLATE_PATH, 'docker')
@@ -87,7 +87,7 @@ class Template {
8787
const { destination, githubUser, name } = options
8888
await copyDirectory(TEMPLATE_CHALLENGE_PATH, destination)
8989
await this.replaceInDestination({
90-
name: name,
90+
name,
9191
description: this.getDescription(githubUser),
9292
destination
9393
})

cli/services/Test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import ora from 'ora'
66
import chalk from 'chalk'
77
import { table } from 'table'
88

9-
import { Solution } from './Solution'
10-
import { docker } from './Docker'
9+
import { Solution } from './Solution.js'
10+
import { docker } from './Docker.js'
1111

1212
export interface InputOutput {
1313
input: string
@@ -49,7 +49,7 @@ export class Test implements TestOptions {
4949
this.elapsedTimeMilliseconds = options.elapsedTimeMilliseconds
5050
}
5151

52-
static async printResult (tests: Test[]): Promise<void> {
52+
static printResult (tests: Test[]): void {
5353
const tableResult = [
5454
[
5555
chalk.bold('N°'),
@@ -120,7 +120,7 @@ export class Test implements TestOptions {
120120
throw error
121121
}
122122
}
123-
await Test.printResult(tests)
123+
Test.printResult(tests)
124124
}
125125

126126
static async getInputOutput (testPath: string): Promise<InputOutput> {

cli/services/__test__/GitAffected.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Challenge } from '../Challenge'
2-
import { GitAffected } from '../GitAffected'
3-
import { Solution } from '../Solution'
1+
import { Challenge } from '../Challenge.js'
2+
import { GitAffected } from '../GitAffected.js'
3+
import { Solution } from '../Solution.js'
44

55
const gitAffected = new GitAffected({ isContinuousIntegration: false })
66

cli/utils/__test__/copyDirectory.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import fs from 'node:fs'
22

33
import fsMock from 'mock-fs'
44

5-
import { copyDirectory } from '../copyDirectory'
5+
import { copyDirectory } from '../copyDirectory.js'
66

77
describe('utils/copyDirectory', () => {
8-
afterEach(async () => {
8+
afterEach(() => {
99
fsMock.restore()
1010
})
1111

cli/utils/__test__/createTemporaryEmptyFolder.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import fsMock from 'mock-fs'
55
import {
66
TEMPORARY_PATH,
77
createTemporaryEmptyFolder
8-
} from '../createTemporaryEmptyFolder'
9-
import { isExistingPath } from '../isExistingPath'
8+
} from '../createTemporaryEmptyFolder.js'
9+
import { isExistingPath } from '../isExistingPath.js'
1010

1111
describe('utils/createTemporaryEmptyFolder', () => {
12-
afterEach(async () => {
12+
afterEach(() => {
1313
fsMock.restore()
1414
})
1515

cli/utils/__test__/isExistingPath.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import fsMock from 'mock-fs'
22

3-
import { isExistingPath } from '../isExistingPath'
3+
import { isExistingPath } from '../isExistingPath.js'
44

55
describe('utils/isExistingFile', () => {
6-
afterEach(async () => {
6+
afterEach(() => {
77
fsMock.restore()
88
})
99

cli/utils/createTemporaryEmptyFolder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
22
import fs from 'node:fs'
33

4-
import { isExistingPath } from '../utils/isExistingPath'
4+
import { isExistingPath } from '../utils/isExistingPath.js'
55

66
export const TEMPORARY_PATH = path.join(__dirname, '..', '..', 'temp')
77

jest.config.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
2-
"preset": "ts-jest",
32
"testEnvironment": "node",
3+
"resolver": "jest-ts-webcompat-resolver",
4+
"transform": {
5+
"^.+\\.(t|j)sx?$": ["@swc/jest"]
6+
},
47
"rootDir": "./cli",
58
"testPathIgnorePatterns": [
69
"<rootDir>/commands/run/test.ts",
710
"<rootDir>/services/Test.ts",
811
"<rootDir>/node_modules"
912
],
10-
"setupFiles": [
11-
"<rootDir>/__test__/setup.ts"
12-
]
13+
"setupFiles": ["<rootDir>/__test__/setup.ts"]
1314
}

0 commit comments

Comments
 (0)