Skip to content

Commit

Permalink
chore(cli): add check-version.js dist-tag-latest.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Nov 6, 2019
1 parent d6451be commit 3544812
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions check-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require('fs')
const path = require('path')

const request = require('request')

const registry = 'https://registry.npmjs.org/@dcloudio/'

const pkgs = fs.readdirSync(path.resolve(__dirname, 'packages'))

const tag = process.argv[2] || 'alpha'

pkgs.forEach(pkg => {
request(registry + pkg, function(error, response, body) {
if (error) {
console.log(pkg, error)
} else {
const version = JSON.parse(body)['dist-tags'][tag]
console.log(pkg + ':' + (' '.repeat(80 - (pkg + ':' + version).length)) + version)
}
})
})
17 changes: 17 additions & 0 deletions dist-tag-latest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs')
const path = require('path')
const shellExec = require('shell-exec')

const pkgs = fs.readdirSync(path.resolve(__dirname, 'packages'))

const version = process.argv[2]
if (!version) {
throw new Error('必须传入 version')
}

(async function() {
for (let i = 0; i < pkgs.length; i++) {
console.log(`npm dist-tag add @dcloudio/${pkgs[i]}@${version} latest`);
await shellExec(`npm dist-tag add @dcloudio/${pkgs[i]}@${version} latest`)
}
})();

0 comments on commit 3544812

Please sign in to comment.