Skip to content

Latest commit

 

History

History
136 lines (90 loc) · 2.56 KB

File metadata and controls

136 lines (90 loc) · 2.56 KB

Build Instructions for sitemap-cli-gen

This document outlines the process for setting up, building, testing, and publishing the sitemap-cli-gen package.

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/sitemap-cli-gen.git
    cd sitemap-cli-gen
  2. Install dependencies:

    npm install

Development Workflow

  1. Make your code changes in the JavaScript files.

  2. Test your changes locally:

    npm test

CLI Usage

The package includes a CLI tool. After installation, you can use it as follows:

npx sitemap-cli-gen baseUrl=https://example.com outDir=./public maxDepth=3

Or if installed globally:

sitemap-cli-gen baseUrl=https://example.com outDir=./public maxDepth=3

Testing

We use Jest for testing. To run the test suite:

npm test

To run tests in watch mode during development:

npm run test:watch

Publishing

We use a bash script to automate the publication process. Here's how to use it:

  1. Ensure you have the necessary permissions:

    chmod +x publish.sh
  2. Run the publication script:

    ./publish.sh <version_type>

    Replace <version_type> with either patch, minor, or major.

    For example:

    ./publish.sh patch
  3. If you encounter permission issues with the script, you can run the commands manually:

    # Ensure you're on the main branch
    git checkout main
    
    # Pull latest changes
    git pull origin main
    
    # Run tests
    npm test
    
    # Bump version (replace 'patch' with 'minor' or 'major' as needed)
    npm version patch -m "Bump version to %s"
    
    # Push changes and tags
    git push && git push --tags
    
    # Publish to npm
    npm publish

Troubleshooting

If you encounter a "permission denied" error when running the publish script:

  1. Check file permissions:

    ls -l publish.sh
  2. If needed, change file ownership:

    sudo chown yourusername:yourgroupname publish.sh
  3. Ensure you're in the correct directory:

    pwd
  4. Try running with bash explicitly:

    bash publish.sh patch

Notes

  • Always ensure all tests pass before publishing.
  • Update the CHANGELOG.md file with any significant changes before publishing.
  • Make sure you're logged into npm (npm login) before attempting to publish.
  • The main CLI file is cli.js. Ensure this file has the correct permissions to be executed.

For any questions or issues, please open an issue on the GitHub repository.