diff --git a/.github/workflows/contributor.yml b/.github/workflows/contributor.yml new file mode 100644 index 0000000..cfb986a --- /dev/null +++ b/.github/workflows/contributor.yml @@ -0,0 +1,19 @@ +name: Generate contributor list + +on: + push: + branches: + - main + +jobs: + contrib-readme-job: + runs-on: ubuntu-latest + name: A job to automate contrib in readme + permissions: + contents: write + pull-requests: write + steps: + - name: Contribute List + uses: akhilmhdh/contributors-readme-action@v2.3.10 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index ca7ec3e..62cad35 100644 --- a/README.md +++ b/README.md @@ -266,13 +266,14 @@ For reference, check out the `xsecurity` command implemented in [src/commands/xs ## Custom Module Creation Command -This project includes a custom script to generate a NestJS module along with additional folder structures for better organization. +This project includes a custom script to generate a new NestJS module with a well-organized folder structure. ### What this command does: - Creates a new module using the NestJS CLI. - Generates the associated controller and service. -- Adds additional folders (`dto`, `types`, `repositories`, `helpers`) inside the module folder for organizing your code. +- Adds additional folders (`dto`, `repositories`,) inside the module folder for organizing your code. +- Creates a `types.d.ts` file for type definitions. ### How to Use: @@ -293,6 +294,10 @@ This project includes a custom script to generate a NestJS module along with add - [@AHS12](https://www.github.com/AHS12) +## Contributors + + + ## License This project is brought to you by Innovix Matrix System and is released as open-source software under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/src/commands/create-module.command.ts b/src/commands/create-module.command.ts index 5b92c07..138294f 100644 --- a/src/commands/create-module.command.ts +++ b/src/commands/create-module.command.ts @@ -6,14 +6,11 @@ import * as path from 'path'; @Injectable() export class CreateModuleCommand { - @Command({ command: 'create:module ', describe: 'Create a new module with a predefined structure', }) - async run( - @Positional({ name: 'moduleName', describe: 'The name of the module', @@ -21,7 +18,6 @@ export class CreateModuleCommand { }) moduleName: string, ): Promise { - if (!moduleName) { console.error('Please provide a module name.'); process.exit(1); @@ -49,10 +45,8 @@ export class CreateModuleCommand { // Utility function to run shell commands runCommand(command: string): void { - try { execSync(command, { stdio: 'inherit' }); - } catch (error) { console.error(`Error executing command: ${command}`, error); } @@ -60,11 +54,9 @@ export class CreateModuleCommand { // Utility function to create a directory if it doesn't exist createDir(dirPath: string): void { - if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath, { recursive: true }); console.log(`Created directory: ${dirPath}`); - } else { console.log(`Directory already exists: ${dirPath}`); } @@ -72,12 +64,9 @@ export class CreateModuleCommand { // Utility function to create a file with content createFile(filePath: string, content: string): void { - if (!fs.existsSync(filePath)) { - fs.writeFileSync(filePath, content); console.log(`Created file: ${filePath}`); - } else { console.log(`File already exists: ${filePath}`); }