Skip to content

Commit

Permalink
feat: add Prettier (#72)
Browse files Browse the repository at this point in the history
* feat(project): add initial package.json file

* chore(package): update package.json config

- Remove unnecessary fields (version, main, keywords, author, license)
- Add `sideEffects` field set to false to enable better bundling optimizations.
- Specify package as an ES module by setting the `type` field to "module".
- Mark the package as private to prevent accidental publication.

* feat(npm-config): enforce installation of exact version dependencies

Add `.npmrc` file with `save-exact` set to `true` to enforce that the exact versions of dependencies are saved in package.json

* chore(dependencies): add `prettier` and `prettier-plugin-packagejson` as dev. dependencies

* feat(project): add Prettier config file

* chore: add .gitignore and .prettierignore files

Add .gitignore and .prettierignore files to prevent 'node_modules' and 'package-lock.json' from being tracked by git and formatted by Prettier.

* feat(package-scripts): add linting and formatting npm scripts

Added new `lint` and `fix` scripts in the package.json, allowing for code linting and auto-fixing issues using Prettier.

It also includes `concurrently` as a dev. dependency enabling running multiple npm scripts in parallel.

* style: add formatting changes made by Prettier

* chore(dependencies): add husky and lint-staged for pre-commit hooks

This commit adds two new development dependencies to the project: `husky` and `lint-staged`. Husky is used to configure Git hooks, and lint-staged allows running linters on staged files in Git

* chore(husky): add 'prepare' script for husky install

This commit ensures that Husky's git hooks are installed after running `npm install`.

* feat(husky): add pre-commit hook

* feat(lint-staged): add code formatting on commit

Added `.lintstagedrc.js` with a default export setting up Prettier to run against all matched files. The `--ignore-unknown` flag allows Prettier to skip files it does not recognize.

* ci(github-actions): add `node` setup in prettify workflow

This commit updates the code formatting's workflow. The 'Checkout' action is upgraded from v3 to v4. Additionally, this update introduces the setup-node action, specifying the `lts` version of Node.js, followed by `npm ci` to install dependencies based on the lock file.

* feat(environment): specify lts version of node in package.json

This commit introduces a `.nvmrc` file with the version `20.10.0`, and updates the `package.json` to include both `engines` and `volta` fields that enforce the use of the long-term support (LTS) of Node.js.

* ci(workflow): add names to new CI steps

* chore(dependencies): update `prettier-plugin-packagejson` to 2.4.9
  • Loading branch information
b-mendoza authored Jan 8, 2024
1 parent bad1041 commit def07bf
Show file tree
Hide file tree
Showing 24 changed files with 2,637 additions and 832 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.MD
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
<!--- Provide a general summary of your changes in the Title above -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

Fixes #

## Description

<!--- Describe your changes in detail -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of Changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
18 changes: 13 additions & 5 deletions .github/workflows/prettify.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: Prettier Action

on:
push
on: push

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
Expand All @@ -19,8 +18,17 @@ jobs:
- name: Commit URL
run: git remote set-url origin https://github-actions:${{github.token}}@github.com/rbjks/rbjks.github.io.git

- name: Prettify code
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Install Dependencies
run: npm ci

- name: Prettify Code
uses: creyD/[email protected]
with:
dry: False
dry: false
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
'*': 'prettier --ignore-unknown --write',
};
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.10.0
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @ts-check

/** @type {import("prettier").Config} */
export default {
singleQuote: true,
plugins: ['prettier-plugin-packagejson'],
};
22 changes: 12 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Contributing Guidelines

First of all thanks for spending your time to contribute or showing interest to contribute to this project :smiley:
First of all thanks for spending your time to contribute or showing interest to contribute to this project :smiley:

This documentation contains a set of `Guidelines` and `Steps` to help you during the contribution process.



# 🔑 Guidelines for contributing :

Here are some set of guidelines to follow while contributing to `rbjks.github.io` :
Expand All @@ -20,32 +18,29 @@ Here are some set of guidelines to follow while contributing to `rbjks.github.io
8. Pull requests will be merged after appropriate reviews.
9. We all are here to learn. You are allowed to make mistakes. That's how you learn, right!.




# ▶️ Steps for contributing :

## Fork this repository

<img align="right" width="300" alt="image" src="https://user-images.githubusercontent.com/110724849/230174676-887cfddf-0c2d-4811-9aa1-0758af091c6b.png">

<br>
Fork this repository by clicking on the fork button on the top of this page.
This will create a copy of this repository in your account.


## Clone This Repository

<img align="right" width="200" src="https://user-images.githubusercontent.com/110724849/230175272-c713e91d-f5bf-4cc3-8e37-b36f5d6881fb.png">

Now clone the forked repository to your machine.
Now clone the forked repository to your machine.
Go to your GitHub account, open the forked repository, click on the code button and then click the copy to clipboard icon.


Open a terminal and run the following git command:

```
git clone https://github.com/<Your-Github-username>/rbjks.github.io.git
```


## Create a branch

Change to the repository directory on your computer (if you are not already there):
Expand All @@ -67,23 +62,29 @@ git checkout -b add-new-feature
```

## Make necessary changes and commit those changes

If you go to the project directory and execute the command `git status`, you'll see there are changes.

Add those changes to the branch you just created using the git add command:

```
git add .
```

Now commit those changes using the git commit command:

```
git commit -m "Your commit message"
```

## Push changes to GitHub

Push the changes to the forked repository using:

```
git push origin <Your-branch-name>
```

Navigate to the original fork of this repository on your profile and click on the branch you had committed to.
Then click on Contribute to create a Pull Request i.e create a PR on Github. (Don't just hit the create a pull request button, you must write a PR message to clarify why and what are you contributing)

Expand All @@ -92,6 +93,7 @@ Then click on Contribute to create a Pull Request i.e create a PR on Github. (Do
## Are you a beginner in using Github?

You can refer to the following articles on the basics of Git and Github and also contact me, in case you are stuck:

- [Forking a Repo](https://help.github.com/en/github/getting-started-with-github/fork-a-repo)
- [Cloning a Repo](https://help.github.com/en/desktop/contributing-to-projects/creating-an-issue-or-pull-request)
- [How to create a Pull Request](https://opensource.com/article/19/7/create-pull-request-github)
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ Access this website at https://rbjks.github.io/index.html
The aim for the website is as a static webpage for an NGO 'Ranjeet Bakhshi Jan Kalyan Sabha'. The NGO conducts many activites and crowd-funding campaigns to help people in lower-economic and social backgrounds to empower themselves.
This website has to be duolingual with both English and Hindi as the required languages.


Preferred colors for the website
Preferred colors for the website

<span style="color:#22B9A8">Emerald - #22B9A8</span>

![Emerald](https://user-images.githubusercontent.com/115361239/220578047-1ed3c681-0282-4b1e-85bd-66e86b1344bd.png)


<span style="color:#ff9933">Deep Saffron - #ff9933</span>

![Deep Saffron](https://user-images.githubusercontent.com/115361239/220579735-fb87b37d-67f4-406c-8188-2d42f29f9847.png)
Expand Down
Loading

0 comments on commit def07bf

Please sign in to comment.