|
| 1 | +#!env node |
| 2 | +"use strict"; |
| 3 | + |
| 4 | +const COMMIT_ARTIFACTS = ['lib', 'lib-esm', '_bundles', 'package.json']; |
| 5 | + |
| 6 | +let shx = require('shelljs'); |
| 7 | +let readlineSync = require('readline-sync'); |
| 8 | +let fs = require('fs'); |
| 9 | +let path = require('path'); |
| 10 | +let util = require('./util'); |
| 11 | +let _exec = util._exec; |
| 12 | + |
| 13 | +let pkg = require('../package.json'); |
| 14 | +let version = pkg.version; |
| 15 | + |
| 16 | +shx.cd(path.join(__dirname, '..')); |
| 17 | + |
| 18 | +var widen = false; |
| 19 | +var coreDep = pkg.dependencies['@uirouter/core']; |
| 20 | +var isNarrow = /^[[=~]?(\d.*)/.exec(coreDep); |
| 21 | +var widenedDep = isNarrow && '^' + isNarrow[1]; |
| 22 | + |
| 23 | +if (isNarrow && readlineSync.keyInYN('Widen @uirouter/core dependency from ' + coreDep + ' to ' + widenedDep + '?')) { |
| 24 | + widen = false; |
| 25 | +} |
| 26 | + |
| 27 | +const YYYYMMDD = (function() { |
| 28 | + var date = new Date(); |
| 29 | + var year = date.getFullYear(); |
| 30 | + |
| 31 | + var month = date.getMonth() + 1; |
| 32 | + month = (month < 10 ? "0" : "") + month; |
| 33 | + |
| 34 | + var day = date.getDate(); |
| 35 | + day = (day < 10 ? "0" : "") + day; |
| 36 | + |
| 37 | + return year + month + day; |
| 38 | +})(); |
| 39 | + |
| 40 | +let tagname = `SNAPSHOT-${YYYYMMDD}`; |
| 41 | +tagname += readlineSync.question(`Suffix for tag ${tagname} (optional)?`); |
| 42 | + |
| 43 | +if (!readlineSync.keyInYN(`Ready to publish ${tagname} tag?`)) { |
| 44 | + process.exit(1); |
| 45 | +} |
| 46 | + |
| 47 | +util.ensureCleanMaster('master'); |
| 48 | + |
| 49 | +// then tag and push tag |
| 50 | +_exec(`git checkout -b ${tagname}-prep`); |
| 51 | + |
| 52 | +pkg.dependencies['@uirouter/core'] = widenedDep; |
| 53 | +// pkg.version = tagname; |
| 54 | + |
| 55 | +fs.writeFileSync("package.json", JSON.stringify(pkg, undefined, 2)); |
| 56 | +_exec('git commit -m "Widening @uirouter/core dependency range to ' + widenedDep + '" package.json'); |
| 57 | + |
| 58 | +_exec('npm run package'); |
| 59 | + |
| 60 | +_exec(`git add --force ${COMMIT_ARTIFACTS.join(' ')}`); |
| 61 | +_exec(`git rm yarn.lock`); |
| 62 | + |
| 63 | +_exec(`git commit -m 'chore(*): commiting build files'`); |
| 64 | +_exec(`git tag ${tagname}`); |
| 65 | +_exec(`git push -u origin ${tagname}`); |
| 66 | +_exec(`git checkout master`); |
| 67 | +_exec(`git branch -D ${tagname}-prep`); |
0 commit comments