From b8d2d988017c198103c61977d3689006d1be0f33 Mon Sep 17 00:00:00 2001 From: Hoang Mirs Date: Thu, 29 Dec 2022 09:51:05 +0700 Subject: [PATCH 1/3] Add a contributing guideline --- .gitignore | 1 + CONTRIBUTING.md | 108 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 ++ 3 files changed, 113 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/.gitignore b/.gitignore index 68aeaf90..2320cbdd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ oclif.manifest.json yarn.lock /coverage +.DS_Store diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c332f359 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,108 @@ +# Contributing guidelines for the project + +First off, thank you for considering contributing to this project. It's people like you that make this project such a great tool. We appreciate your help! + +The following is a set of guidelines for contributing to this project. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. + +## Introduction + +This project is using TypeScript and [OCLIF](https://oclif.io/) to build the CLI. The project is using Jest for testing, ESLint for code formatting and linting. + +## Issues and feature requests + +If you have any issues or feature requests, please create an issue in the [GitHub issues](https://github.com/nimblehq/infrastructure-templates/issues) page. + +## Development + +### Prerequisites + +- Node.js 12.0.0 or higher +- NPM is preferred to use with this project, but you can use Yarn as well and don't commit the `yarn.lock` file to the repository + +### Install dependencies + +```bash +npm install +``` + +### Run the CLI locally + +Run the following command and follow the instructions: + +```bash +bin/dev generate {project-name} +``` + +### Project structure + +The project has the following main folders: + +- `bin` - contains the executable file for the CLI + - `dev` - the executable file for the CLI in development mode + - `run` - the executable file for the CLI in production mode + +- `src` - contains the source code of the CLI + - `index.ts` - the entry point of the CLI + - `commands` - contains the commands of the CLI + - `helpers` - contains the helper functions of the CLI + - `childProcess` - contains the helper functions for child process + - `file` - contains the helper functions for file interaction + - `terraform` - contains the helper functions for Terraform + - `templates` - contains the code to generate the templates + - `addons` - contains the code to generate the common addons e.g. version control, CI/CD, etc. + - `aws` - contains the code to generate the AWS modules e.g. VPC, RDS, etc. + - `core` - contains the code to generate the main Terraform files e.g. `main.tf`, `variables.tf`, etc. + - `skeleton` - contains the skeleton files for the project + - `addons` - contains the skeleton files for common addons e.g. version control, CI/CD, etc. + - `aws` - contains the skeleton files for AWS modules + - `core` - contains the skeleton files for common files e.g. `main.tf`, `variables.tf`, `.gitignore`, etc. + - `test` - contains the test helpers and configurations + +### Add a new command + +To add a new command, you need to create a new folder in the `src/commands` folder and add the `index.ts` file in it. +The command documentation can be found [here](https://oclif.io/docs/commands). + +### Add a new addon/module + +To add a new addon/module, you need to create a new folder in the `src/templates` folder depending on the type of the addon/module: + +- For common addons, create a new folder in the `src/templates/addons` folder +- For AWS modules, create a new folder in the `src/templates/aws` folder +- For common files, create a new folder in the `src/templates/core` folder + +Check the existing addons/modules for the reference. + +## Testing + +### Run tests + +```bash +npm run test +``` + +### Run and fix linting + +```bash +npm run lint // to check linting + +npm run lint:fix // to fix linting +``` + +## Publishing + +- This project will be published to NPM automatically when a new release is created in GitHub. Therefore, the package version in `package.json` should be updated before creating a new release. + +- The release should be created in the `master` branch. + +- The release should be created with the following format: `{version}` e.g. `1.0.0` + +### Manual publishing + +- To publish the project manually, run the following command: + +```bash +npm run publish +``` + +**Note:** You need to have the NPM account to publish the project and make sure that the version in `package.json` is updated. diff --git a/README.md b/README.md index 86696cae..0f16089c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,10 @@ or npx @nimblehq/infra-template generate {project-name} ``` +## Contributing + +Check out our [contributing guidelines](/CONTRIBUTING.md) to get started. + ## License This project is Copyright (c) 2014 and onwards Nimble. It is free software and may be redistributed under the terms specified in the [LICENSE] file. From 1b6304955c0ca8410a0a48d67a6894b2b425383e Mon Sep 17 00:00:00 2001 From: Hoang Mirs Date: Fri, 30 Dec 2022 13:45:02 +0700 Subject: [PATCH 2/3] Modify based on comments --- CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c332f359..3d3534cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ The following is a set of guidelines for contributing to this project. These are ## Introduction -This project is using TypeScript and [OCLIF](https://oclif.io/) to build the CLI. The project is using Jest for testing, ESLint for code formatting and linting. +This project uses TypeScript and [OCLIF](https://oclif.io/) to build the CLI, Jest for testing, and ESLint for code formatting and linting. ## Issues and feature requests @@ -17,7 +17,7 @@ If you have any issues or feature requests, please create an issue in the [GitHu ### Prerequisites - Node.js 12.0.0 or higher -- NPM is preferred to use with this project, but you can use Yarn as well and don't commit the `yarn.lock` file to the repository +- NPM is preferred to use with this project ### Install dependencies @@ -60,7 +60,7 @@ The project has the following main folders: ### Add a new command -To add a new command, you need to create a new folder in the `src/commands` folder and add the `index.ts` file in it. +To add a new command, create a new folder in the `src/commands` and add the `index.ts` file. The command documentation can be found [here](https://oclif.io/docs/commands). ### Add a new addon/module @@ -93,7 +93,7 @@ npm run lint:fix // to fix linting - This project will be published to NPM automatically when a new release is created in GitHub. Therefore, the package version in `package.json` should be updated before creating a new release. -- The release should be created in the `master` branch. +- The release should be created in the `main` branch. - The release should be created with the following format: `{version}` e.g. `1.0.0` @@ -105,4 +105,4 @@ npm run lint:fix // to fix linting npm run publish ``` -**Note:** You need to have the NPM account to publish the project and make sure that the version in `package.json` is updated. +**Note:** NPM credentials are required to publish the project. Ensure that the version in `package.json` is updated. From d10305a714146d8880c38292e9e7bac387aaf051 Mon Sep 17 00:00:00 2001 From: Hoang Mirs Date: Fri, 30 Dec 2022 14:30:47 +0700 Subject: [PATCH 3/3] Update Nodejs version --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d3534cb..981cceda 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ If you have any issues or feature requests, please create an issue in the [GitHu ### Prerequisites -- Node.js 12.0.0 or higher +- [Node.js](https://nodejs.org/en/download/) 12.x or higher - 18.x LTS is recommended - NPM is preferred to use with this project ### Install dependencies