https://github.com/codaline-io/node-versionless-cache-key
github action to retrieve a cache key for npm without the version of the package
https://github.com/codaline-io/node-versionless-cache-key
Last synced: 9 months ago
JSON representation
github action to retrieve a cache key for npm without the version of the package
- Host: GitHub
- URL: https://github.com/codaline-io/node-versionless-cache-key
- Owner: codaline-io
- License: mit
- Created: 2022-09-21T11:07:03.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T08:56:14.000Z (about 2 years ago)
- Last Synced: 2025-02-18T05:03:02.616Z (over 1 year ago)
- Language: JavaScript
- Size: 297 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-versionless-cache-key
This action generates a cache key out of the package.json and package-lock.json.
The Problem: The package-lock.json contains the package version. If that versions changes the hash of the file changes. To avoid getting a new cache key, when your package version changes this actions strips the version.
It accepts a package.json and package-lock.json file path.
Nothing special is happening. Just replacing the version in package-lock and getting a hash back.
## What is happening
1. reads json files
2. grab package name from package.json
3. search for that package name and its following version key in package-lock.json
4. replaces all whitespaces, tabs and newlines and the version number with empty string
5. hashes the file content and output it as cache key
## Inputs
- **packageJSON**: path to package.json file. Default `./package.json`.
- **packageLockJSON**: path to package-lock.json file. Default `./package-lock.json`.
## Outputs
- **cacheKey**: The generated hash over package-lock.json without version number.
## Example usage
```
uses: codaline-io/node-versionless-cache-key@0.0.1
with:
packageJSON: custom-sub-folder/package-test.json
packageLockJSON: custom-sub-folder/my-lock-file.json
```