From 15bddab3b3ccd37f0c5e39ab68eb1be384325773 Mon Sep 17 00:00:00 2001 From: Ajesh Sen Thapa Date: Fri, 20 Dec 2024 10:05:55 +0545 Subject: [PATCH] docs: update contributing guidelines with example script --- CONTRIBUTING.md | 119 ++++++++++++++++++++++------ example.ts | 9 +++ jest.config.js | 2 +- package-lock.json | 197 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 4 +- tsconfig.json | 8 +- 6 files changed, 297 insertions(+), 42 deletions(-) create mode 100644 example.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85b8460..b145b86 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,36 +1,107 @@ -# How to contribute +# Contributing Guide -## Install dependencies +Thank you for your interest in contributing to the **node-nepali-datetime** project! +Your contributions will help improve and enhance this library. +Please take a moment to review the following guidelines before getting started. -```bash -npm install -``` +## Prerequisites -## Codestyle +Before contributing, ensure that you have the following: -A [.prettierrc](./.prettierrc) file is available to maintain the coding style. Besides, your code will automatically be formatted by the pre-commit hook. +- **Node.js v18 or higher** installed. Download it from the [official Node.js website](https://nodejs.org/) + or use `nvm` to manage multiple Node.js versions. +- **npm** installed (comes with Node.js). -## Unit tests +## Getting Started -Run the unittest using the below command: +To set up the project on your local machine, follow these steps: -```bash -npm test -``` +1. **Fork** the repository on GitHub. +2. **Clone** the forked repository to your local machine: -## Before submitting + ```bash + git clone https://github.com//node-nepali-datetime.git + cd node-nepali-datetime + ``` -Before submitting your Pull Request, please do the following steps: +3. **Install dependencies**: -1. Add any changes you want. -1. Add tests for the new changes. -1. Edit documentation (`README.md`) if you have changed something significant. -1. Commit your changes using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). - Examples: `feat: add JSON parser`, `feat(parser): add JSON parser`. + ```bash + npm install + ``` -## Other help +4. **Verify your setup**: -You can contribute by spreading a word about this library. -It would also be a huge contribution to write -a short article on how you are using this project. -You can also share your best practices with us. + - Run the example script to test the library: + + ```bash + npm run example + ``` + + Modify the [example.ts](./example.ts) file to experiment with your example code. + + - Run lint checks: + + ```bash + npm run lint + ``` + + - Run tests to ensure everything works: + + ```bash + npm run test + ``` + +5. **Start contributing** by making the necessary changes to the codebase. + +## Code Style + +- A **Prettier** configuration file ([`.prettierrc`](./.prettierrc)) is provided to maintain a consistent coding style. +- Pre-commit hooks will automatically format your code before committing. Ensure that your code passes lint checks. + +## Pull Requests + +We welcome and appreciate pull requests from the community. To contribute: + +1. **Fork** the repository and create a new branch based on the `main` branch: + + ```bash + git checkout -b + ``` + +2. **Write tests** for your changes if applicable. +3. **Follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)** for commit messages. + Examples: + + - `feat: add JSON parser` + - `fix(parser): resolve parsing issue` + +4. **Push** your branch to your forked repository: + + ```bash + git push origin + ``` + +5. **Create a Pull Request**: + + - Open a pull request from your branch to the `main` branch of the original repository. + - Provide a clear and concise description of the changes, along with relevant context. + +6. **Review & Feedback**: + + - Participate in the code review process and address any feedback promptly. + +## License + +By contributing to this project, you agree that your contributions will be licensed under the **GPL-3.0 License**. +Refer to the [LICENSE](./LICENSE) file for more details. + +## Other Ways to Contribute + +Even if you don’t contribute code, you can still help: + +- **Spread the word** about this library. +- Write a blog or article about how you use this project. +- Share your best practices, examples, or ideas with us. + +Thank you for contributing to **node-nepali-datetime**! 🎉 diff --git a/example.ts b/example.ts new file mode 100644 index 0000000..bff7cf2 --- /dev/null +++ b/example.ts @@ -0,0 +1,9 @@ +import NepaliDate from './src/NepaliDate' + +console.log('node-nepali-datetime') + +// Now +const now = new NepaliDate() +console.log('Now:', now.toString()) + +// Try your example codes here diff --git a/jest.config.js b/jest.config.js index 66c6fe0..bd9bcdc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,5 +5,5 @@ module.exports = { '^.+\\.ts?$': 'ts-jest', }, transformIgnorePatterns: ['/node_modules/'], - testPathIgnorePatterns: ['.eslintrc.js'], + testPathIgnorePatterns: [], } diff --git a/package-lock.json b/package-lock.json index 6dcbd02..50438e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "lint-staged": "^15.2.11", "prettier": "^3.4.2", "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", "tslib": "^2.8.1", "typescript": "^5.7.2", "unbuild": "^3.0.1" @@ -813,6 +814,30 @@ "node": ">=v18" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.24.0", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz", @@ -2328,6 +2353,34 @@ "node": ">=10.13.0" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -2492,6 +2545,19 @@ "node": ">=0.4.0" } }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/ajv": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", @@ -2562,6 +2628,13 @@ "node": ">= 8" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true, + "license": "MIT" + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -2915,9 +2988,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001689", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001689.tgz", - "integrity": "sha512-CmeR2VBycfa+5/jOfnp/NpWPGd06nf1XYiefUvhXFfZE4GkRc9jv+eGPS4nT558WS/8lYCzV8SlANCIPvbWP1g==", + "version": "1.0.30001690", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", + "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==", "dev": true, "funding": [ { @@ -2936,9 +3009,9 @@ "license": "CC-BY-4.0" }, "node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.0.tgz", + "integrity": "sha512-ZkD35Mx92acjB2yNJgziGqT9oKHEOxjTBTDRpOsRWtdecL/0jM3z5kM/CTzHWvHIen1GvkM85p6TuFfDGfc8/Q==", "dev": true, "license": "MIT", "engines": { @@ -3200,9 +3273,9 @@ "license": "MIT" }, "node_modules/consola": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/consola/-/consola-3.2.3.tgz", - "integrity": "sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.3.0.tgz", + "integrity": "sha512-kxltocVQCwQNFvw40dlVRYeAkAvtYjMFZYNlOcsF5wExPpGwPxMwgx4IfDJvBRPtBpnQwItd5WkTaR0ZwT/TmQ==", "dev": true, "license": "MIT", "engines": { @@ -3361,6 +3434,13 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true, + "license": "MIT" + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -3634,6 +3714,16 @@ "node": ">=8" } }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -3733,9 +3823,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.74", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.74.tgz", - "integrity": "sha512-ck3//9RC+6oss/1Bh9tiAVFy5vfSKbRHAFh7Z3/eTRkEqJeWgymloShB17Vg3Z4nmDNp35vAd1BZ6CMW4Wt6Iw==", + "version": "1.5.75", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz", + "integrity": "sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q==", "dev": true, "license": "ISC" }, @@ -5829,6 +5919,19 @@ "url": "https://opencollective.com/lint-staged" } }, + "node_modules/lint-staged/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/lint-staged/node_modules/execa": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", @@ -7427,9 +7530,9 @@ } }, "node_modules/resolve": { - "version": "1.22.9", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.9.tgz", - "integrity": "sha512-QxrmX1DzraFIi9PxdG5VkRfRwIgjwyud+z/iBwfRRrVmHc+P9Q7u2lSSpQ6bjr2gy5lrqIiU9vb6iAeGf2400A==", + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", "dev": true, "license": "MIT", "dependencies": { @@ -7440,6 +7543,9 @@ "bin": { "resolve": "bin/resolve" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -8099,6 +8205,50 @@ } } }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", @@ -8272,6 +8422,13 @@ "dev": true, "license": "MIT" }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true, + "license": "MIT" + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -8485,6 +8642,16 @@ "node": ">=8" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index a8a8b95..b17385a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "coverage": "jest --coverage", "prepare": "husky && npm run build", "lint": "prettier --check .", - "format": "prettier --write ." + "format": "prettier --write .", + "example": "ts-node example.ts" }, "lint-staged": { "*": "prettier --ignore-unknown --write" @@ -66,6 +67,7 @@ "lint-staged": "^15.2.11", "prettier": "^3.4.2", "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", "tslib": "^2.8.1", "typescript": "^5.7.2", "unbuild": "^3.0.1" diff --git a/tsconfig.json b/tsconfig.json index 5e65ad3..c4bea39 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,12 @@ "skipLibCheck": true, "moduleResolution": "node" }, + "ts-node": { + "transpileOnly": true, + "compilerOptions": { + "module": "commonjs" + } + }, "include": ["src"], - "exclude": ["node_modules", "dist", "__test__"] + "exclude": ["node_modules", "dist", "tests"] }