From 354481223554204715d8a53971061909beb763be Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 6 Nov 2019 19:10:17 +0800 Subject: [PATCH] chore(cli): add check-version.js dist-tag-latest.js --- check-version.js | 21 +++++++++++++++++++++ dist-tag-latest.js | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 check-version.js create mode 100644 dist-tag-latest.js diff --git a/check-version.js b/check-version.js new file mode 100644 index 00000000000..2ed36d6a737 --- /dev/null +++ b/check-version.js @@ -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) + } + }) +}) diff --git a/dist-tag-latest.js b/dist-tag-latest.js new file mode 100644 index 00000000000..e3759ca9f44 --- /dev/null +++ b/dist-tag-latest.js @@ -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`) + } +})();