Skip to content

Commit 70ff8e9

Browse files
Merge pull request #9 from hodfords-solutions/feat/refactor-source
feat: refactor eslint and upgrade dependencies
2 parents ac828c7 + 642018d commit 70ff8e9

38 files changed

+1109
-1195
lines changed

.eslintrc.js

-102
This file was deleted.

.github/workflows/publish.yml

+13-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ name: Publish Package to npmjs
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
jobs:
7+
lint:
8+
uses: hodfords-solutions/actions/.github/workflows/lint.yaml@main
79
build:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-node@v3
12-
with:
13-
node-version: '22.x'
14-
registry-url: 'https://registry.npmjs.org'
15-
- run: sh scripts/publish.sh
16-
env:
17-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10+
uses: hodfords-solutions/actions/.github/workflows/publish.yaml@main
11+
with:
12+
build_path: dist
13+
secrets:
14+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
15+
update-docs:
16+
uses: hodfords-solutions/actions/.github/workflows/update-doc.yaml@main
17+
needs: build
18+
secrets:
19+
DOC_SSH_PRIVATE_KEY: ${{ secrets.DOC_SSH_PRIVATE_KEY }}

.lintstagedrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"libs/**/*.ts": ["eslint --fix --max-warnings 0"]
2+
"lib/**/*.ts": ["eslint --fix --max-warnings 0"]
33
}

.prettierrc

-12
This file was deleted.

cspell.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"typeorm",
77
"postbuild",
88
"hodfords",
9-
"npmjs"
9+
"npmjs",
10+
"extname"
1011
],
1112
"flagWords": ["hte"],
1213
"ignorePaths": ["node_modules", "test", "*.spec.ts", "cspell.json"]

eslint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@hodfords/nestjs-eslint-config');
File renamed without changes.

libs/command.module.ts renamed to lib/command.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { MakeServiceCommand } from './commands/make-service.command';
1212

1313
@Module({})
1414
export class CommandModule {
15-
static register(isEnableTypeorm: boolean = true): DynamicModule {
15+
static register(isEnableTypeorm = true): DynamicModule {
1616
const providers: Provider[] = [
1717
CommandService,
1818
MakeCommandCommand,

libs/command.service.ts renamed to lib/command.service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { COMMAND_KEY } from './decorators/command.decorator';
88
export class CommandService {
99
constructor(private modulesContainer: ModulesContainer) {}
1010

11-
async exec() {
11+
async exec(): Promise<void> {
1212
const program = new Command();
1313
const providerModules = [...this.modulesContainer.values()].map((module) => module.providers.values());
1414
for (const providerModule of providerModules) {
@@ -26,19 +26,19 @@ export class CommandService {
2626
await program.parseAsync();
2727
}
2828

29-
public addCommand(program, instance, meta) {
29+
public addCommand(program, instance, meta): void {
3030
const commandBuilder = new Command().command(meta.signature);
3131
if (meta.description) {
3232
commandBuilder.description(meta.description, meta.params);
3333
}
3434
if (meta.options) {
35-
for (let option of meta.options) {
35+
for (const option of meta.options) {
3636
commandBuilder.option(option.value, option.description);
3737
}
3838
}
3939

4040
if (meta.requiredOptions) {
41-
for (let option of meta.requiredOptions) {
41+
for (const option of meta.requiredOptions) {
4242
commandBuilder.requiredOption(option.value, option.description);
4343
}
4444
}

libs/commands/base-make.command.ts renamed to lib/commands/base-make.command.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,43 @@ export abstract class BaseMakeCommand extends BaseCommand {
1010

1111
abstract getStub();
1212

13-
public getContent() {
13+
public getContent(): void {
1414
this.content = readFileSync(this.getStub()).toString();
1515
}
1616

17-
public replaceContent(contents: { search: string; value: string }[]) {
18-
for (let content of contents) {
19-
let regex = new RegExp(escapeRegExp(content.search), 'g');
17+
public replaceContent(contents: { search: string; value: string }[]): void {
18+
for (const content of contents) {
19+
const regex = new RegExp(escapeRegExp(content.search), 'g');
2020
this.content = this.content.replace(regex, content.value);
2121
}
2222
}
2323

24-
public writeFile(pathName, fileName) {
24+
public writeFile(pathName: string, fileName: string): void {
2525
writeFileSync(path.join(process.cwd(), pathName, fileName), this.content);
2626
}
2727

28-
public writeFileToModule(pathName, fileName) {
29-
let fullPath = this.getModulePath(pathName);
28+
public writeFileToModule(pathName: string, fileName: string): void {
29+
const fullPath = this.getModulePath(pathName);
3030
mkdirSync(fullPath, { recursive: true });
3131
this.writeFile(fullPath, fileName);
3232
}
3333

34-
public getModulePath(pathName) {
34+
public getModulePath(pathName: string): string {
3535
if (this.opts.module) {
3636
return path.join('src', this.opts.module, pathName);
3737
}
3838
return path.join('src', pathName);
3939
}
4040

41-
public get args() {
41+
public get args(): string[] {
4242
return this.customArgs || this.program.args;
4343
}
4444

45-
public get opts() {
45+
public get opts(): object & { module?: string } {
4646
return this.customOptions || this.program.opts();
4747
}
4848

49-
public runWith(args: any[] = undefined, opts: any = undefined) {
49+
public runWith(args: object = undefined, opts: object = undefined): void {
5050
this.customArgs = args;
5151
this.customOptions = opts;
5252
return this.handle();

libs/commands/base.command.ts renamed to lib/commands/base.command.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import { Command } from 'commander';
44
export abstract class BaseCommand {
55
protected program: Command;
66

7-
abstract handle();
7+
abstract handle(): void;
88

9-
get params() {
9+
get params(): string[] {
1010
return this.program.args;
1111
}
1212

13-
public success(message) {
13+
public success(message): void {
1414
console.log(chalk.green(message));
1515
}
1616

17-
public error(message) {
17+
public error(message): void {
1818
console.log(chalk.red(message));
1919
}
2020

21-
public info(message) {
21+
public info(message): void {
2222
console.log(chalk.blue(message));
2323
}
2424

25-
public warn(message) {
25+
public warn(message): void {
2626
console.log(chalk.yellow(message));
2727
}
2828
}

libs/commands/make-command.command.ts renamed to lib/commands/make-command.command.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import { BaseMakeCommand } from './base-make.command';
1919
})
2020
@Injectable()
2121
export class MakeCommandCommand extends BaseMakeCommand {
22-
public getStub() {
22+
public getStub(): string {
2323
return resolve(__dirname, '../stubs/make-command.stub');
2424
}
2525

26-
public handle() {
26+
public handle(): void {
2727
const [command] = this.program.args;
2828
this.getContent();
2929
this.replaceContent([

libs/commands/make-controller.command.ts renamed to lib/commands/make-controller.command.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { BaseMakeCommand } from './base-make.command';
1515
})
1616
@Injectable()
1717
export class MakeControllerCommand extends BaseMakeCommand {
18-
public getStub() {
18+
public getStub(): string {
1919
return resolve(__dirname, '../stubs/modules/http/controllers/controller.stub');
2020
}
2121

22-
public handle() {
23-
let [name] = this.args;
22+
public handle(): void {
23+
const [name] = this.args;
2424
this.getContent();
2525
this.replaceContent([
2626
{

libs/commands/make-dto.command.ts renamed to lib/commands/make-dto.command.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { BaseMakeCommand } from './base-make.command';
1515
})
1616
@Injectable()
1717
export class MakeDtoCommand extends BaseMakeCommand {
18-
public getStub() {
18+
public getStub(): string {
1919
return resolve(__dirname, '../stubs/modules/http/dto/dto.stub');
2020
}
2121

22-
public handle() {
23-
let [name] = this.args;
22+
public handle(): void {
23+
const [name] = this.args;
2424
this.getContent();
2525
this.replaceContent([
2626
{

libs/commands/make-e2e-test.command.ts renamed to lib/commands/make-e2e-test.command.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { BaseMakeCommand } from './base-make.command';
1515
})
1616
@Injectable()
1717
export class MakeE2eTestCommand extends BaseMakeCommand {
18-
public getStub() {
18+
public getStub(): string {
1919
return resolve(__dirname, '../stubs/modules/tests/e2e-spec.stub');
2020
}
2121

22-
public handle() {
23-
let [name] = this.args;
22+
public handle(): void {
23+
const [name] = this.args;
2424
this.getContent();
2525
this.replaceContent([
2626
{

libs/commands/make-entity.command.ts renamed to lib/commands/make-entity.command.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { BaseMakeCommand } from './base-make.command';
1515
})
1616
@Injectable()
1717
export class MakeEntityCommand extends BaseMakeCommand {
18-
public getStub() {
18+
public getStub(): string {
1919
return resolve(__dirname, '../stubs/modules/entities/entity.stub');
2020
}
2121

22-
public handle() {
23-
let [name] = this.args;
22+
public handle(): void {
23+
const [name] = this.args;
2424
this.getContent();
2525
this.replaceContent([
2626
{

0 commit comments

Comments
 (0)