Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
lockblocks
Advanced tools
Read the official documentation.
LockBlocks is a Node.js command line utility that allows you to easily update projects created from a starter.
Starters are an excellent way to hit the ground running with any new project without needing to write a bunch of boilerplate code. Simply clone the starter and build.
However, the moment you create a new project from a starter, you create a new maintenance fork. If you update the starter, any projects created from that starter will also need to be updated, and usually this must be done manually.
This can quickly snowball into a lot of work if you are maintaining several projects created from the same starter. Bugs can easily be introduced when manually updating projects, or you may simply forget to copy updates to each project.
Enter LockBlocks. With LockBlocks, you can configure an updater that specifies which files and directories should be updated from the starter.
You can specify fields to update in JSON and YAML files, such as your dependencies in package.json
, with granular control over how the updates are made for each field (merge, fill, replace, etc).
In addition, you can specify blocks of code that will be pulled from the starter when updating. This gives you a lot of control over what can be maintained in the starter, as you can lock parts of a file that are maintained in the starter, while leaving the rest of the file to be changed as the developer sees fit.
package.json
scripts and dependencies, or any other JSON or YAML files, as you see fit!If this project helped you, please consider buying me a coffee or sponsoring me. Your support is much appreciated!
npm i --save-dev lockblocks
Create a new file at the root of your starter project called lockblocks.yml
:
# lockblocks.yml
renameFiles: []
replaceFiles:
- lockblocks.yml
fillFiles: []
deleteFiles: []
excludePaths:
- .git
- .lockblocks
- node_modules
updateJson:
- path: package.json
root:
fill: true
updateFields:
- key: version
as: starterVersion
- key: scripts
merge: true
- key: dependencies
merge: true
- key: devDependencies
merge: true
updateYaml: []
This config will keep your
lockblocks.yml
and npm scripts and packages up to date, and will copy the starter'sversion
inpackage.json
asstarterVersion
.
Then create an npm script in package.json
to execute LockBlocks using a git project as the origin and the current project as the target. See below.
To update your project with LockBlocks using a git project as the origin, add this script to package.json
:
"scripts": {
"update": "git clone -q git@github.com:my-username/my-starter.git ./.lockblocks && lockblocks ./.lockblocks . --verbose && rm -rf .lockblocks"
},
...where git@github.com:my-username/my-starter.git
is the location to your starter git project.
This script will silently clone your project to the .lockblocks
directory, then run LockBlocks using that dir as the origin and the current directory as the target. The .lockblocks
directory will then be deleted when finished.
With this approach, be sure .lockblocks
is specified in excludePaths
.
See the Usage Documentation for full usage docs.
This utility uses a config file, lockblocks.yml
, to determine which files and directories to update in your project.
It also scans all files in the starter (origin directory) for special tags that specify additional updates to make, including blocks of code.
You can reference the order in which LockBlocks performs updates below.
LockBlocks operates in the following order:
renameFiles
and the lock-rename
tags found in origin.replaceFiles
and the lock-all
tags found in origin.fillFiles
.deleteFiles
.lock
block tags found in origin.updateJson
.updateYaml
.Type definitions have been included for TypeScript support.
Favicon by Twemoji.
Open source software is awesome and so are you. 😎
Feel free to submit a pull request for bugs or additions, and make sure to update tests as appropriate. If you find a mistake in the docs, send a PR! Even the smallest changes help.
For major changes, open an issue first to discuss what you'd like to change.
If you found this project helpful, let the community know by giving it a star: 👉⭐
See LICENSE.md.
FAQs
Node.js utility for updating projects created from starters.
The npm package lockblocks receives a total of 189 weekly downloads. As such, lockblocks popularity was classified as not popular.
We found that lockblocks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.