Skip to content

Commit 481fdff

Browse files
committed
add pre-commit (code style), license
1 parent eaa5f1c commit 481fdff

6 files changed

Lines changed: 52 additions & 53 deletions

File tree

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "minter-cli",
3-
"version": "0.0.1",
4-
"description": "",
5-
"author": "",
3+
"version": "0.0.2",
4+
"description": "Minter CLI",
5+
"author": "webcounters (https://github.com/counters)",
66
"private": true,
7-
"license": "UNLICENSED",
7+
"license": "Apache-2.0",
88
"scripts": {
99
"build": "nest build",
1010
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
@@ -19,6 +19,11 @@
1919
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
2020
"test:e2e": "jest --config ./test/jest-e2e.json"
2121
},
22+
"husky": {
23+
"hooks": {
24+
"pre-commit": "npm run format"
25+
}
26+
},
2227
"dependencies": {
2328
"@nestjs/common": "^11.0.1",
2429
"@nestjs/core": "^11.0.1",

src/app.module.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { Module } from '@nestjs/common';
22
import { MinterApiService } from './services/minter-api/minter-api.service';
3-
import { ApiCommand } from "./commands/api/ApiCommand";
3+
import { ApiCommand } from './commands/api/ApiCommand';
44

55
@Module({
66
imports: [],
77
controllers: [],
8-
providers: [
9-
MinterApiService,
10-
...ApiCommand.registerWithSubCommands()
11-
],
8+
providers: [MinterApiService, ...ApiCommand.registerWithSubCommands()],
129
})
1310
export class AppModule {}

src/commands/api/ApiCommand.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Command, CommandRunner } from 'nest-commander';
2-
import {CandidateCommand} from "./CandidateCommand";
3-
2+
import { CandidateCommand } from './CandidateCommand';
43

54
@Command({
65
name: 'api',
@@ -10,7 +9,6 @@ import {CandidateCommand} from "./CandidateCommand";
109
})
1110
export class ApiCommand extends CommandRunner {
1211
run(passedParams: string[], options?: Record<string, any>): Promise<void> {
13-
this.command.help()
12+
this.command.help();
1413
}
15-
1614
}
Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
1-
import {Option, CommandRunner, SubCommand} from 'nest-commander';
2-
1+
import { Option, CommandRunner, SubCommand } from 'nest-commander';
32

43
@SubCommand({
5-
name: 'candidate',
6-
arguments: '<public_key>',
7-
argsDescription: {'public_key':'Public key'},
8-
description: 'Candidate returns candidate’s info by provided public key',
4+
name: 'candidate',
5+
arguments: '<public_key>',
6+
argsDescription: { public_key: 'Public key' },
7+
description: 'Candidate returns candidate’s info by provided public key',
98
})
109
export class CandidateCommand extends CommandRunner {
10+
async run(
11+
inputs: string[],
12+
options: { height?: number; not_show_stakes?: boolean },
13+
): Promise<void> {
14+
console.log('candidate');
15+
console.log(`inputs: ${inputs[0]}`);
16+
console.log(`height: ${options.height}`);
17+
console.log(`not_show_stakes: ${options.not_show_stakes}`);
18+
return Promise.resolve(undefined);
19+
}
1120

12-
async run(inputs: string[],
13-
options: { height?: number, not_show_stakes?: boolean},
14-
): Promise<void> {
15-
16-
console.log("candidate");
17-
console.log(`inputs: ${inputs[0]}`);
18-
console.log(`height: ${options.height}`);
19-
console.log(`not_show_stakes: ${options.not_show_stakes}`);
20-
return Promise.resolve(undefined);
21-
}
22-
23-
@Option({
24-
flags: '--height [number]',
25-
name: 'Height',
26-
description: 'Blockchain state height for the current request. Optional, the last default state of the node is used',
27-
})
28-
parseNumber(val: string): number {
29-
return Number(val);
30-
}
31-
32-
@Option({
33-
flags: '--not_show_stakes [boolean]',
34-
description: 'Do not display a list of steaks. Note: used_slots, uniq_users, min_stake will be filled',
35-
defaultValue: true,
36-
})
37-
parseBoolean(val: string): boolean {
38-
return JSON.parse(val);
39-
}
21+
@Option({
22+
flags: '--height [number]',
23+
name: 'Height',
24+
description:
25+
'Blockchain state height for the current request. Optional, the last default state of the node is used',
26+
})
27+
parseNumber(val: string): number {
28+
return Number(val);
29+
}
4030

31+
@Option({
32+
flags: '--not_show_stakes [boolean]',
33+
description:
34+
'Do not display a list of steaks. Note: used_slots, uniq_users, min_stake will be filled',
35+
defaultValue: true,
36+
})
37+
parseBoolean(val: string): boolean {
38+
return JSON.parse(val);
39+
}
4140
}

src/main.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {AppModule} from './app.module';
2-
import {CommandFactory} from "nest-commander";
1+
import { AppModule } from './app.module';
2+
import { CommandFactory } from 'nest-commander';
33

44
async function bootstrap() {
5-
// const app = await NestFactory.create(AppModule);
6-
// await app.listen(process.env.PORT ?? 3000);
7-
await CommandFactory.run(AppModule);
5+
// const app = await NestFactory.create(AppModule);
6+
// await app.listen(process.env.PORT ?? 3000);
7+
await CommandFactory.run(AppModule);
88
}
99

1010
bootstrap();

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"experimentalDecorators": true,
88
"allowSyntheticDefaultImports": true,
99
"target": "ES2023",
10-
"sourceMap": true,
10+
"sourceMap": false,
1111
"outDir": "./dist",
1212
"baseUrl": "./",
1313
"incremental": true,

0 commit comments

Comments
 (0)