diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..b7e9068 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,82 @@ +name: Bug Report +description: Report a bug in the npm package template +title: "[Bug]: " +labels: ["bug", "triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! 🐛 + + - type: textarea + id: description + attributes: + label: Bug Description + description: A clear and concise description of what the bug is. + placeholder: Describe the bug... + validations: + required: true + + - type: textarea + id: reproduction + attributes: + label: Steps to Reproduce + description: Steps to reproduce the behavior + placeholder: | + 1. Go to '...' + 2. Click on '...' + 3. Scroll down to '...' + 4. See error + validations: + required: true + + - type: textarea + id: expected + attributes: + label: Expected Behavior + description: What you expected to happen + placeholder: Describe what you expected to happen... + validations: + required: true + + - type: textarea + id: actual + attributes: + label: Actual Behavior + description: What actually happened + placeholder: Describe what actually happened... + validations: + required: true + + - type: textarea + id: environment + attributes: + label: Environment + description: Please provide your environment details + placeholder: | + - OS: [e.g. Windows 11, macOS 12.3, Ubuntu 20.04] + - Node.js version: [e.g. 18.15.0] + - npm version: [e.g. 9.5.0] + - Package version: [e.g. 1.0.0] + validations: + required: true + + - type: textarea + id: additional + attributes: + label: Additional Context + description: Add any other context about the problem here + placeholder: Add any screenshots, logs, or additional information... + + - type: checkboxes + id: terms + attributes: + label: Checklist + description: Please confirm the following + options: + - label: I have searched existing issues to avoid duplicates + required: true + - label: I have provided all required information + required: true + - label: I have tested this with the latest version + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000..2e9e143 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,73 @@ +name: Documentation Issue +description: Report an issue with documentation +title: "[Docs]: " +labels: ["documentation", "triage"] +body: + - type: markdown + attributes: + value: | + Thanks for helping improve our documentation! 📚 + + - type: dropdown + id: doc-type + attributes: + label: Documentation Type + description: What type of documentation issue is this? + options: + - README.md + - Setup Guide (TEMPLATE_SETUP.md) + - API Documentation + - Examples + - Contributing Guide + - Code Comments + - Other + validations: + required: true + + - type: textarea + id: issue + attributes: + label: Documentation Issue + description: What's wrong with the current documentation? + placeholder: Describe the documentation issue... + validations: + required: true + + - type: textarea + id: location + attributes: + label: Location + description: Where is this documentation located? + placeholder: | + - File: README.md + - Section: Installation + - Line: 45 + validations: + required: true + + - type: textarea + id: suggestion + attributes: + label: Suggested Improvement + description: How would you improve this documentation? + placeholder: Describe your suggested improvement... + validations: + required: true + + - type: textarea + id: additional + attributes: + label: Additional Context + description: Any additional context or examples + placeholder: Add any additional context... + + - type: checkboxes + id: terms + attributes: + label: Checklist + description: Please confirm the following + options: + - label: I have searched existing issues to avoid duplicates + required: true + - label: I have provided specific details about the issue + required: true diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..c13bca9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,89 @@ +name: Feature Request +description: Suggest a new feature for the npm package template +title: "[Feature]: " +labels: ["enhancement", "triage"] +body: + - type: markdown + attributes: + value: | + Thanks for suggesting a new feature! 🚀 + + - type: textarea + id: summary + attributes: + label: Feature Summary + description: A brief summary of the feature you'd like to see + placeholder: Briefly describe the feature... + validations: + required: true + + - type: textarea + id: motivation + attributes: + label: Motivation + description: Why would this feature be useful? What problem does it solve? + placeholder: Explain the motivation and use case... + validations: + required: true + + - type: textarea + id: solution + attributes: + label: Proposed Solution + description: How would you like this feature to work? + placeholder: Describe your proposed solution... + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternative Solutions + description: Are there any alternative solutions or workarounds? + placeholder: Describe any alternative solutions you've considered... + + - type: textarea + id: examples + attributes: + label: Examples + description: Provide examples of how this feature would be used + placeholder: | + ```typescript + // Example usage + ``` + + - type: dropdown + id: priority + attributes: + label: Priority + description: How important is this feature to you? + options: + - Low - Nice to have + - Medium - Would be helpful + - High - Important for my use case + - Critical - Blocking my usage + validations: + required: true + + - type: checkboxes + id: contribution + attributes: + label: Contribution + description: Are you willing to contribute to this feature? + options: + - label: I'm willing to submit a pull request for this feature + - label: I can help with testing + - label: I can help with documentation + + - type: checkboxes + id: terms + attributes: + label: Checklist + description: Please confirm the following + options: + - label: I have searched existing issues to avoid duplicates + required: true + - label: This feature would benefit the broader community + required: true + - label: I have provided sufficient detail for evaluation + required: true diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..59dbdd9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,35 @@ +version: 2 +updates: + # Enable version updates for npm + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + reviewers: + - "xarlizard" + assignees: + - "xarlizard" + commit-message: + prefix: "chore" + include: "scope" + # Allow both direct and indirect dependencies + allow: + - dependency-type: "direct" + - dependency-type: "indirect" + # Ignore major version updates for stability + ignore: + - dependency-name: "*" + update-types: ["version-update:semver-major"] + + # Enable version updates for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + reviewers: + - "xarlizard" + assignees: + - "xarlizard" + commit-message: + prefix: "ci" + include: "scope" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..4a68257 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,72 @@ +## Description + + + +## Type of Change + + + +- [ ] 🐛 Bug fix (non-breaking change which fixes an issue) +- [ ] 🚀 New feature (non-breaking change which adds functionality) +- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] 📚 Documentation update +- [ ] 🔧 Maintenance (refactoring, dependencies, etc.) + +## Changes Made + + + +- +- +- + +## Testing + + + +- [ ] All existing tests pass +- [ ] New tests have been added for new functionality +- [ ] Manual testing has been performed +- [ ] Example code has been tested + +## Checklist + + + +- [ ] My code follows the project's style guidelines +- [ ] I have performed a self-review of my own code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes +- [ ] Any dependent changes have been merged and published + +## Related Issues + + + +Closes # + +## Screenshots (if applicable) + + + +## Additional Notes + + + +## Deployment Notes + + + +--- + +**For Template Users:** +If you're using this template, please update this section with your specific PR template requirements. + +**For Maintainers:** +- [ ] Code review completed +- [ ] All CI checks pass +- [ ] Documentation updated +- [ ] Ready to merge diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..57ccfe5 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,19 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: production + url: https://www.npmjs.com/package/react-api-forge + + steps: + - uses: actions/checkout@v3 + + - name: Build and Deploy + run: echo "This is a template. Add your deployment command here, e.g., npm run deploy, scp, rsync, or a cloud CLI." diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b452089..cdbeb8f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -62,10 +62,57 @@ jobs: - name: Build package run: npm run build - - name: Publish to NPM - run: npm publish + - name: Publish to NPM (with fallback to scoped name) + run: | + # Backup original package.json + cp package.json package.json.backup + + # Try publishing with original name first + ORIGINAL_NAME=$(node -p "require('./package.json').name") + echo "📦 Attempting to publish with original name: $ORIGINAL_NAME" + + if npm publish; then + echo "✅ Successfully published with original name: $ORIGINAL_NAME" + else + echo "❌ Failed to publish with original name, trying with scoped name..." + # Restore backup + mv package.json.backup package.json + + # Create scoped version using GitHub username + node -e " + const pkg = require('./package.json'); + const owner = process.env.GITHUB_REPOSITORY.split('/')[0]; + const originalName = pkg.name.replace(/^@[^/]+\//, ''); // Remove existing scope if any + pkg.name = \`@\${owner}/\${originalName}\`; + pkg.publishConfig = { + access: 'public', + registry: 'https://registry.npmjs.org' + }; + console.log(\`📦 Retrying with scoped name: \${pkg.name}\`); + require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)); + " + + SCOPED_NAME=$(node -p "require('./package.json').name") + echo "🚀 Publishing scoped package: $SCOPED_NAME" + + if npm publish; then + echo "✅ Successfully published with scoped name: $SCOPED_NAME" + echo "💡 Users can install with: npm install $SCOPED_NAME" + else + echo "❌ Failed to publish even with scoped name: $SCOPED_NAME" + echo "🔍 Please check NPM_TOKEN permissions and package configuration" + exit 1 + fi + fi + + # Always restore original package.json if backup exists + if [ -f package.json.backup ]; then + mv package.json.backup package.json + echo "🔄 Restored original package.json" + fi env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + publish-github: needs: test runs-on: ubuntu-latest @@ -95,11 +142,18 @@ jobs: cp package.json package.json.backup node -e " const pkg = require('./package.json'); - pkg.name = '@Xarlizard/react-api-forge'; + const owner = process.env.GITHUB_REPOSITORY.split('/')[0]; + const repoName = process.env.GITHUB_REPOSITORY.split('/')[1]; + + // Use the repository name for GitHub Packages to avoid URL encoding issues + pkg.name = \`@\${owner}/\${repoName}\`; pkg.publishConfig = { - '@Xarlizard:registry': 'https://npm.pkg.github.com', - 'access': 'public' + registry: 'https://npm.pkg.github.com', + access: 'public' }; + + console.log(\`📦 Publishing to GitHub Packages as: \${pkg.name}\`); + console.log(\`🎯 Repository: \${process.env.GITHUB_REPOSITORY}\`); require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2)); " diff --git a/CHANGELOG.md b/CHANGELOG.md index f00a556..777ab95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.2] - 2025-08-05 + +### Added +- Workflow for Deploy, and updated the Publish workflow +- Dependabot yml +- Templates for pull requests and issues +- Updated some dependencies + ## [1.0.1] - 2025-07-11 ### Changed diff --git a/README.md b/README.md index 92b9c60..ca35039 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ [![npm version](https://badge.fury.io/js/react-api-forge.svg)](https://badge.fury.io/js/react-api-forge) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/) +[![Production Deployment](https://github.com/xarlizard/react-api-forge/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/xarlizard/react-api-forge/actions/workflows/deploy.yml) +[![Coverage](https://codecov.io/gh/xarlizard/react-api-forge/branch/main/graph/badge.svg)](https://codecov.io/gh/xarlizard/react-api-forge) A flexible and robust React hook factory for creating API hooks with consistent patterns. Build type-safe, reusable API hooks with built-in loading states, error handling, and request cancellation. diff --git a/package-lock.json b/package-lock.json index c0669b1..d9a32be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-api-forge", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "react-api-forge", - "version": "1.0.1", + "version": "1.0.2", "license": "MIT", "dependencies": { "axios": "^1.10.0" diff --git a/package.json b/package.json index 3dd85d5..d69418b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-api-forge", - "version": "1.0.1", + "version": "1.0.2", "description": "A flexible and robust React hook factory for creating API hooks with consistent patterns", "type": "module", "main": "dist/index.js", @@ -22,7 +22,12 @@ "scripts": { "build": "rollup -c", "test": "jest", + "test:watch": "jest --watch", + "test:coverage": "jest --coverage", "lint": "eslint \"src/**/*.{ts,tsx}\"", + "lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix", + "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"", + "format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md}\"", "typecheck": "tsc --noEmit", "dev": "pwsh -ExecutionPolicy Bypass -File scripts/dev.ps1", "dev:test": "pwsh -ExecutionPolicy Bypass -File scripts/dev.ps1 -Task test", @@ -30,6 +35,8 @@ "dev:lint": "pwsh -ExecutionPolicy Bypass -File scripts/dev.ps1 -Task lint", "dev:typecheck": "pwsh -ExecutionPolicy Bypass -File scripts/dev.ps1 -Task typecheck", "prepublishOnly": "npm run build && npm run test && npm run lint && npm run typecheck", + "setup": "node scripts/setup.js", + "setup:ps": "pwsh -ExecutionPolicy Bypass -File scripts/setup.ps1", "release": "node scripts/release.js patch", "release:minor": "node scripts/release.js minor", "release:major": "node scripts/release.js major",