This document outlines the process for setting up, building, testing, and publishing the sitemap-cli-gen package.
-
Clone the repository:
git clone https://github.com/yourusername/sitemap-cli-gen.git cd sitemap-cli-gen -
Install dependencies:
npm install
-
Make your code changes in the JavaScript files.
-
Test your changes locally:
npm test
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=3Or if installed globally:
sitemap-cli-gen baseUrl=https://example.com outDir=./public maxDepth=3We use Jest for testing. To run the test suite:
npm testTo run tests in watch mode during development:
npm run test:watchWe use a bash script to automate the publication process. Here's how to use it:
-
Ensure you have the necessary permissions:
chmod +x publish.sh
-
Run the publication script:
./publish.sh <version_type>
Replace
<version_type>with eitherpatch,minor, ormajor.For example:
./publish.sh patch
-
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
If you encounter a "permission denied" error when running the publish script:
-
Check file permissions:
ls -l publish.sh
-
If needed, change file ownership:
sudo chown yourusername:yourgroupname publish.sh
-
Ensure you're in the correct directory:
pwd -
Try running with bash explicitly:
bash publish.sh patch
- 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.