Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
feat: add rollback npm version command (#252)
Browse files Browse the repository at this point in the history
* feat: add rollback command

* chore: update CONTRIBUTING.md
  • Loading branch information
chenbin92 authored Apr 20, 2020
1 parent 8f4ba2c commit 7176025
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ $ npm run publish
* When you need to release a latest version, the tag will be created automatically, running `npm publish` will tag your package with the `latest` dist-tag.
* To publish a package with the `beta` dist-tag, you can choose to release rc、beta、alpha versions, the tag will not be created.

## Rollback Packages

When a serious bug occurs in the production environment, you can backtrack the package version:

```bash
# rollback packages
$ npm run rollback <version>

# sync packages
$ npm run sync
```


## Pull Request Guidelines

- Only code that's ready for release should be committed to the master branch. All development should be done in dedicated branches.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build": "ts-node ./scripts/build.ts",
"publish": "ts-node ./scripts/publish.ts",
"sync": "ts-node ./scripts/sync.ts",
"rollback": "ts-node ./scripts/rollback.ts",
"owner": "ts-node ./scripts/owner.ts",
"dependency:check": "ts-node ./scripts/dependency-check.ts",
"clean": "lerna clean --yes && rimraf packages/*/lib",
Expand Down
21 changes: 21 additions & 0 deletions scripts/rollback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as execa from 'execa';
import getPackages from './fn/getPackages';

// eslint-disable-next-line
const chalk = require('chalk');

(async () => {
const { packageNames } = await getPackages();
const args = process.argv;
const rollbackVersion = args[2];
packageNames.forEach((packageName) => {
console.log(`rollback: ${packageName}@${rollbackVersion}`);
execa.commandSync(`npm dist-tags add ${packageName}@${rollbackVersion} latest`, {
stdio: 'inherit'
});
console.log();
});
})().catch((e) => {
console.log(chalk.red(`\n ⚠️ ⚠️ ⚠️ rollback failed\n\n`), e);
process.exit(128);
});

0 comments on commit 7176025

Please sign in to comment.