Skip to content

Commit

Permalink
chore: add generate rollback script (midwayjs#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
czy88840616 authored Feb 25, 2021
1 parent 1be9b41 commit d2939f0
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 70 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"build": "sh scripts/build.sh",
"authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS",
"postinstall": "opencollective-postinstall",
"postversion": "node ./scripts/generate_rollback.js",
"lint": "lerna exec mwts check",
"lint:fix": "lerna exec mwts fix"
},
Expand Down
9 changes: 5 additions & 4 deletions packages/grpc/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,15 @@ describe('/test/index.test.ts', function () {

// 双向流
const result3= await new Promise<number>((resolve, reject) => {
const clientStream = service.addMore();
const duplexCall = clientStream.getCall();
const duplexCall = service.addMore().getCall();
total = 0;
let idx = 0;

duplexCall.on('data', (data: math.Num) => {
total += data.num;
idx++;
if (idx === 2) {
clientStream.end();
duplexCall.end();
resolve(total);
}
});
Expand All @@ -211,7 +210,9 @@ describe('/test/index.test.ts', function () {


// 保证顺序的双向流
const t = service.addMore();
const t = service.addMore({
messageKey: 'id'
});

const result4 = await new Promise<number>((resolve, reject) => {
total = 0;
Expand Down
40 changes: 40 additions & 0 deletions scripts/generate_rollback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { execSync } = require('child_process');
const { writeFileSync } = require('fs');
const { join } = require('path');

const currentVersion = require('../lerna.json').version;
const originData = execSync('npx lerna ls --json').toString();
const data = JSON.parse(originData);

const arr = ['#!/bin/bash\n', `# timestamp: ${Date.now()}\n\n`];
const diff = ['\n# Changes:\n\n'];

for (const item of data) {

if (item.private === false) {
const remoteVersion = execSync(
`npm show ${item.name} version`
).toString().replace('\n', '');

const localVersion = item.version;
console.log(`----> ${item.name} local=${localVersion} remote=${remoteVersion}`);

if (remoteVersion !== localVersion) {
arr.push(
`npm dist-tag add ${item.name}@${remoteVersion} latest\n`
);
arr.push(
`npm dist-tag add ${item.name}@${localVersion} beta\n`
);
arr.push(
`tnpm dist-tag add ${item.name}@${remoteVersion} latest\n`
);
arr.push(
`tnpm dist-tag add ${item.name}@${localVersion} latest\n`
);
diff.push(`# - ${item.name}: ${remoteVersion} => ${currentVersion}\n`);
}
}
}

writeFileSync(join(__dirname, `./rollback/rollback-${currentVersion}.sh`), arr.join('') + diff.join(''));
27 changes: 0 additions & 27 deletions scripts/rollback.js

This file was deleted.

39 changes: 0 additions & 39 deletions scripts/rollback.sh

This file was deleted.

51 changes: 51 additions & 0 deletions scripts/rollback/rollback-2.8.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Changes:
# - @midwayjs/bootstrap: 2.7.7 => 2.8.0
# - @midwayjs/core: 2.7.7 => 2.8.0
# - @midwayjs/decorator: 2.7.7 => 2.8.0
# - @midwayjs/faas: 2.7.7 => 2.8.0
# - @midwayjs/grpc: 2.7.7 => 2.8.0
# - @midwayjs/logger: 2.7.7 => 2.8.0
# - midway-schedule: 2.7.7 => 2.8.0
# - midway: 2.7.7 => 2.8.0
# - @midwayjs/mock: 2.7.7 => 2.8.0
# - @midwayjs/rabbitmq: 2.7.7 => 2.8.0
# - @midwayjs/socketio: 2.7.7 => 2.8.0
# - @midwayjs/typegoose: 2.7.7 => 2.8.0
# - @midwayjs/express: 2.7.7 => 2.8.0
# - @midwayjs/koa: 2.7.7 => 2.8.0
# - @midwayjs/web: 2.7.7 => 2.8.0

npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add [email protected] beta
npm dist-tag add [email protected] latest
npm dist-tag add [email protected] beta
npm dist-tag add [email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest
npm dist-tag add @midwayjs/[email protected] beta
npm dist-tag add @midwayjs/[email protected] latest

0 comments on commit d2939f0

Please sign in to comment.