package
CLI builder to help users upgrade library versions
npm install lib-upgraderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Codemods, or jscodeshift transforms, are small programs that help automate changes in a codebase. Think of them as search and replace on steroids. This tool helps you to create a simple CLI to apply the codemods that you wrote, so that users can easily upgrade their code between various releases of your library.
$ npm install --save lib-upgrader jscodeshiftCreate a cli.js file at the root of your project that will serve as your upgrader executable, and add this sample code (sample available here):
#!/usr/bin/env node
'use strict';
var upgrader = require('lib-upgrader');
var pkg = require('./package.json');
var releases = require('./releases.json');
upgrader({
libraryName: 'Your library name',
releases: releases,
pkg: pkg,
dirname: __dirname
});and create a releases.json file next to cli.js, which looks like the following (sample available here):
[{
"version": "0.14.0",
"transforms": [
"path/to/transform/a.js",
"path/to/transform/b.js"
]
}, {
"version": "0.15.0",
"transforms": [
"path/to/transform/c.js",
"path/to/transform/d.js"
]
}, {
"version": "1.0.0",
"transforms": [
"path/to/transform/e.js",
"path/to/transform/f.js"
]
}, {
"version": "2.0.0",
"transforms": [
"path/to/transform/g.js",
"path/to/transform/h.js"
]
Give execution right to your script
chmod +x scriptand you should now be able to run the cli using
./cli.jsUnless you committed your changes and your directory is clean, when you run it, the program will exit and ask you to either commit or stash your changes. You can force through it by adding --force to the command line.
MIT © Jeroen Engels
Estimated unpacked size across 64 packages.
7.7 MB+
Includes dependencies.
11 direct · 5 outdated
^3.7.0
14.1.0
^4.0.0
16.2.4
^5.1.0
7.8.6
^3.3.4
3.7.2
^0.3.19
17.4.0
^0.6.3
7.3.1
^4.3.0
4.6.0
^1.0.7
1.0.7