From 6006abe9e68de3be4fd91eb86c0371efc3195f09 Mon Sep 17 00:00:00 2001 From: Shreyash Date: Sat, 11 Jan 2025 10:42:08 +0000 Subject: [PATCH 1/5] feat(tests): add tests for adding 2 decimal numbers add a missing test case for validating addition of 2 decimal numbers --- tests/add.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/add.test.js b/tests/add.test.js index 9129e2e..7ec38bc 100644 --- a/tests/add.test.js +++ b/tests/add.test.js @@ -34,4 +34,14 @@ describe("Test add function", () => { expect(res).toBe(expected); }); + + it("should add two numbers with decimals", () => { + const firstNum = 3.5; + const secondNum = 2.5; + const expected = 6; + + const res = add(firstNum, secondNum); + + expect(res).toBe(expected); + }); }); From 037f5d6470361309f3a308e61cf3f020b64e6d7b Mon Sep 17 00:00:00 2001 From: Shreyash Date: Sun, 12 Jan 2025 10:39:02 +0000 Subject: [PATCH 2/5] docs(package): update README with the structure of this workshop describe how the workshop is structured in the project readme --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/README.md b/README.md index 11d464e..fd0e22f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,45 @@ Workshop for developing Open Source NPM packages. +## Getting Started + +- This workshop is designed to be a hands-on experience for developers who want to learn how to develop and publish Open Source NPM packages. + +- The workshop is divided into multiple sections, each section will cover a specific topic. + +--- + +## Sections + +### 1. **Code and Test**: + +Focuses on writing a simple add function and testing it using Vitest. Also, we will learn how to use the collaborative development tool, Git and GitHub. We talk about a Github Repository, Branches, and Merging. Along the way, we also discuss the importance of writing good commit messages. Issues and Pull Requests are also discussed. + +### 2. **Git Hooks**: + +This section is focussed on Git Hooks using Husky. We will learn how to use Husky to run tests before committing code. Husky makes it easy to use Git Hooks in your project. + +### 3. **CI**: + +This section is focussed on Continuous Integration using GitHub Actions. We will learn how to use GitHub Actions to run tests on every push to the repository and also on every Pull Request. + +### 4. **Linter and Formatter**: + +This section is focussed on using ESLint and Prettier. We will learn how to use ESLint to enforce code quality and Prettier to format the code. We also learn how to use Husky to run ESLint and Prettier on every commit. We also discuss about lint-staged and how it can be used to run ESLint and Prettier on staged files. + +### 5. **Commit Messages**: + +This section is focussed on writing good commit messages. We will learn how to use Conventional Commits to write commit messages. We will also learn how to use Commitlint to enforce Conventional Commits. Finally we run commitlint in CI. + +### 6. **Bundler**: + +This section is focussed on using Rollup as a bundler. We will learn how to use Rollup to bundle our code. We will also learn how to use Terser to minify the code. Finally we hook Rollup and Terser to our CI. + +### 7. **Documentation**: + +This section is focussed on writing documentation for our package. We already wrote some code documentation (using JSdoc) in the previous sections. In this section, we will learn how to write a README.md file for our package. We will also learn how to use GitHub Pages to host our documentation. We also discuss about templates for Pull Requests and Issues. Finally we end this section with a brief discussion on CHANGELOG.md and licensing our code. + +--- + ## Prerequisites - Node.js From 4ade4b57cbf1031232db99105274847aabba2efa Mon Sep 17 00:00:00 2001 From: Shreyash Date: Sun, 12 Jan 2025 10:54:03 +0000 Subject: [PATCH 3/5] docs(package): add PR template and contribution guidelines simply Pull Requests creation for new contributors by creating a template. also add a contributing.md file --- .github/CONTRIBUTING.md | 29 ++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..a6781ce --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing to Mathy + +Thank you for considering contributing to **Mathy**! We welcome all contributions to make this project better. Here's how you can help: + +--- + +## Getting Started + +1. **Fork the Repository**: + + - Click the "Fork" button on the top-right corner of the repository page. + +2. **Clone Your Fork**: + + ```bash + git clone https://github.com/WebDevCaptain-Lab/oss-npm-package-workshop.git + cd oss-npm-package-workshop + ``` + +3. **Install Dependencies**: + + ```bash + npm install + ``` + +4. **Run Tests**: + ```bash + npm test + ``` diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..c921d45 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,35 @@ + + +### Description + + + +### Related Issues + + + +Closes #123 + +### Type of change + +- [ ] Bug fix +- [ ] New feature +- [ ] Refactor +- [ ] Documentation update +- [ ] Other (please specify): + +### Checklist + +- [ ] My code follows the project's coding style. +- [ ] I have performed a self-review of my code. +- [ ] I have written or updated tests to cover my changes. +- [ ] I have updated documentation (if necessary). +- [ ] My changes generate no new warnings. + +### Screenshots (if applicable) + + + +### Additional context + + From bb11436007fbb214612122b318dac6ae0a51f71a Mon Sep 17 00:00:00 2001 From: Shreyash Date: Sun, 12 Jan 2025 11:24:12 +0000 Subject: [PATCH 4/5] docs(package): add roadmap, support, license and update contribution guidelines and readme add roadmap, support, license files and update contribution guidelines and readme.md --- .github/CONTRIBUTING.md | 72 +++++++++++++++++++++++++++++++++++++++++ .github/ROADMAP.md | 39 ++++++++++++++++++++++ .github/SUPPORT.md | 34 +++++++++++++++++++ LICENSE | 21 ++++++++++++ README.md | 8 +++++ 5 files changed, 174 insertions(+) create mode 100644 .github/ROADMAP.md create mode 100644 .github/SUPPORT.md create mode 100644 LICENSE diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a6781ce..2382d94 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -27,3 +27,75 @@ Thank you for considering contributing to **Mathy**! We welcome all contribution ```bash npm test ``` + +--- + +## How to Contribute + +### Reporting Issues + + Found a bug or have a suggestion? Open an issue and use the appropriate template. + +### Feature Requests + + Check the [Roadmap](./ROADMAP.md) to see if your feature aligns with future plans. If not, create an issue to discuss. + +### Submitting Pull Requests + +- Create a new branch for your work: + `git checkout -b my-feature` + +- Make your changes. Write clear and concise code, and add comments if necessary. + +- Ensure tests pass: + `npm test` + +- Push your branch and open a pull request: + `git push origin my-feature` + +- Follow the Pull Request Template to include all required details. + +- Code Style + Prettier and ESLint are used to enforce code style. Run: + + - `npm run lint` + - `npm run format` + +- Join the Discussion + Feel free to ask questions or seek guidance by opening a discussion or issue. Happy coding! + +--- + +### **2. CODE_OF_CONDUCT.md** + +Defines behavior expectations for contributors. + +```markdown +# Contributor Code of Conduct + +## Our Pledge + +We as contributors and maintainers pledge to make participation in this project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to a positive environment: + +- Being respectful of differing viewpoints. +- Providing constructive feedback. +- Showing empathy toward others. + +Examples of unacceptable behavior: + +- Use of sexualized language or unwelcome advances. +- Insulting or derogatory comments. +- Public or private harassment. + +## Enforcement + +Instances of unacceptable behavior can be reported by contacting the project team at **[hello@webdevcaptain.com](mailto:hello@webdevcaptain.com)**. All complaints will be reviewed and addressed confidentially. + +## Acknowledgments + +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org). +``` diff --git a/.github/ROADMAP.md b/.github/ROADMAP.md new file mode 100644 index 0000000..53d7822 --- /dev/null +++ b/.github/ROADMAP.md @@ -0,0 +1,39 @@ +# Mathy Roadmap + +Our goal is to make **Mathy** a comprehensive and lightweight library for performing basic mathematical operations. Here are our plans: + +--- + +## Current Features + +- **Addition**: Adds multiple numbers. + +--- + +## Future Features + +1. **Subtraction**: + + - Function to subtract one number from another. + - Example: `subtract(5, 3) // 2`. + +2. **Division**: + + - Function to divide one number by another. + - Example: `divide(6, 2) // 3`. + +3. **Advanced Operations**: + - Support for percentages. + - Modular arithmetic. + +--- + +## Long-Term Vision + +- Ensure compatibility with various JavaScript frameworks. +- Optimize performance for large datasets. +- Provide thorough documentation and examples. + +--- + +Want to contribute to this roadmap? See our [Contributing Guide](./CONTRIBUTING.md) for details! diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md new file mode 100644 index 0000000..9cb830b --- /dev/null +++ b/.github/SUPPORT.md @@ -0,0 +1,34 @@ +# Support Guide + +If you need help with **Mathy**, here’s how to get assistance: + +--- + +## Questions and Discussions + +- Open a [Discussion](https://github.com/WebDevCaptain-Lab/oss-npm-package-workshop.git/discussions) to ask a question or seek advice. + +## Reporting Bugs + +- Found a bug? [Open an Issue](https://github.com/WebDevCaptain-Lab/oss-npm-package-workshop.git/issues/new?template=bug_report.yml) using the Bug Report template. + +## Feature Requests + +- Have an idea for improving Math-Lib? Submit a [Feature Request](https://github.com/WebDevCaptain-Lab/oss-npm-package-workshop.git/issues/new?template=feature_request.yml). + +## Frequently Asked Questions (FAQ) + +1. **How do I install Mathy?** + + - Use npm: `npm install mathy`. + +2. **What versions of Node.js are supported?** + - We support Node.js versions >=20. + +--- + +## Contact Us + +If your query is not addressed above, email us at **[hello@webdevcaptain.com](mailto:hello@webdevcaptain.com)**. + +Please be patient as our team is small, but we’ll do our best to respond promptly. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e4a7955 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [2025] [Shreyash (WebDevcaptain)] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index fd0e22f..4e4405f 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,11 @@ This section is focussed on writing documentation for our package. We already wr - Node.js - NPM + +--- + +- [Contributing Guide](./CONTRIBUTING.md) +- [Code of Conduct](./CODE_OF_CONDUCT.md) +- [Roadmap](./ROADMAP.md) +- [Support Guide](./SUPPORT.md) +- [License](./LICENSE) From ebd5e364580c0194effb0627e4fd5413f404928c Mon Sep 17 00:00:00 2001 From: Shreyash Date: Sun, 12 Jan 2025 11:28:54 +0000 Subject: [PATCH 5/5] feat(contributions): add issue templates add issue templates for bug reporting, feature request and questions --- .github/ISSUE_TEMPLATE/bug_report.yml | 54 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 44 ++++++++++++++++++ .github/ISSUE_TEMPLATE/question.yml | 30 ++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/ISSUE_TEMPLATE/question.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..830cca2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,54 @@ +name: "Bug Report" +description: "Report a bug in Mathy Lib." +title: "[Bug]: " +labels: [bug] +body: + - type: markdown + attributes: + value: | + Thank you for reporting a bug! Please fill out the form below so we can resolve the issue promptly. + + - type: input + id: summary + attributes: + label: "Bug Summary" + description: "Provide a concise summary of the bug." + placeholder: "e.g., add function returns wrong result for negative numbers." + + - type: textarea + id: steps + attributes: + label: "Steps to Reproduce" + description: "Provide the steps to reproduce the bug." + placeholder: | + 1. Call `add(-1, -1)` + 2. Check the output + 3. Observe the issue + + - type: textarea + id: expected + attributes: + label: "Expected Behavior" + description: "What should happen instead?" + placeholder: "The `add` function should return -2." + + - type: textarea + id: actual + attributes: + label: "Actual Behavior" + description: "What actually happened?" + placeholder: "The `add` function returned 0." + + - type: input + id: environment + attributes: + label: "Environment Details" + description: "Provide relevant details about your setup." + placeholder: "OS: macOS 13, Node.js: 18.12.0, Mathy Lib version: 1.0.1" + + - type: textarea + id: additional + attributes: + label: "Additional Context" + description: "Add any other relevant information or screenshots." + placeholder: "Include error logs, screenshots, or related details." diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..5c45766 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,44 @@ +name: "Feature Request" +description: "Suggest a new feature or enhancement for Mathy Lib." +title: "[Feature]: " +labels: [enhancement] +body: + - type: markdown + attributes: + value: | + We'd love to hear your ideas for improving Mathy Lib! Please fill out the form below. + + - type: input + id: feature_summary + attributes: + label: "Feature Summary" + description: "Briefly describe the new feature or enhancement." + placeholder: "e.g., Add a function for subtracting numbers." + + - type: textarea + id: description + attributes: + label: "Description" + description: "Provide a detailed explanation of the feature." + placeholder: "The subtract function should return the difference of two numbers." + + - type: textarea + id: use_cases + attributes: + label: "Use Cases" + description: "Describe how this feature would be used." + placeholder: "This function will be used to perform simple subtraction operations." + + - type: textarea + id: alternatives + attributes: + label: "Alternatives" + description: "List any alternative solutions or features you've considered." + placeholder: "Using external libraries for subtraction, but it's not ideal for our lightweight library." + + - type: textarea + id: additional + attributes: + label: "Additional Context" + description: "Add any other relevant information or screenshots." + placeholder: "Provide examples, links, or other supporting details." diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 0000000..4ce2cd4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,30 @@ +name: "Question or Support" +description: "Ask a question or request support for Mathy Lib." +title: "[Question]: " +labels: [question] +body: + - type: markdown + attributes: + value: | + Have a question or need help? Let us know by filling out the form below. + + - type: input + id: question_summary + attributes: + label: "Question Summary" + description: "What is your question?" + placeholder: "e.g., How do I use the multiply function?" + + - type: textarea + id: details + attributes: + label: "Details" + description: "Provide additional details about your question or problem." + placeholder: "Include code examples, error logs, or other details." + + - type: textarea + id: additional + attributes: + label: "Additional Context" + description: "Add any other relevant information." + placeholder: "Screenshots, links to documentation, etc."