de-harvest
v1.0.19
Published
A command-line tool for collecting and aggregating file contents based on configurable patterns.
Downloads
458
Readme
de-harvest
A command-line tool for collecting and aggregating file contents based on configurable patterns.
Installation
You can use de-harvest without installation via npx:
npx de-harvest
Or install it globally:
npm install -g de-harvest
Usage
Basic Usage
Run de-harvest with a specified set name:
npx de-harvest --setname <your-set-name>
For example:
npx de-harvest --setname configs
Configuration
When you run de-harvest for the first time, it will create a de-harvest.config.js
file in your project root if one doesn't exist. By default, this file uses ES Modules syntax:
export default {
configs: {
include: ['**/*.js', '**/*.json'],
exclude: ['node_modules/**', 'dist/**']
},
docs: {
include: ['**/*.md'],
exclude: ['node_modules/**']
}
};
Troubleshooting: Module Format
If you encounter an error related to ES Modules, you may need to switch to CommonJS format. To do this, modify your de-harvest.config.js
as follows:
module.exports = {
configs: {
include: ['**/*.js', '**/*.json'],
exclude: ['node_modules/**', 'dist/**']
},
docs: {
include: ['**/*.md'],
exclude: ['node_modules/**']
}
};
The need to switch formats typically depends on your project's configuration:
- If your project's
package.json
contains"type": "module"
, use the ES Module format (default). - If it doesn't, or if you're working in an older Node.js environment, use the CommonJS format.
Include/Exclude Syntax
The include
and exclude
arrays use glob patterns to match files:
- Include: Patterns to match files that should be processed.
- Exclude: Patterns to match files that should be ignored, even if they match an include pattern.
Glob Pattern Syntax:
*
: Matches any number of characters, except path separators (/)**
: Matches any number of characters, including path separators?
: Matches a single character, except path separators[...]
: Matches a range of characters, similar to a RegExp range!(pattern|pattern|pattern)
: Matches anything that does not match any of the patterns provided
Examples:
**/*.js
: Matches all JavaScript files in all directoriessrc/**/*.{js,ts}
: Matches all .js and .ts files in the src directory and its subdirectories!node_modules/**
: Excludes all files in the node_modules directory and its subdirectories
Note: The order of patterns matters. More specific patterns should come after general ones.
Publishing Updates to npm
To publish updates to npm (making them available via npx), follow these steps:
Update the version number in
package.json
:{ "version": "1.0.1" }
Commit your changes:
git add . git commit -m "Update to version 1.0.1"
Create a git tag for the new version:
git tag v1.0.1
Push changes and tags to GitHub:
git push origin main --tags
Publish to npm:
npm publish
Note: Ensure you're logged in to npm (
npm login
) before publishing.
Development
To work on de-harvest locally:
- Clone the repository
- Install dependencies:
npm install
- Make your changes
- Test locally:
node index.cjs --setname <your-test-set>
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.