Skip to content

Commit 124e0b3

Browse files
chore(artifacts): Add artifact tagging script
1 parent 387c7f6 commit 124e0b3

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"clean": "shx rm -rf _bundles lib lib-esm build",
1414
"docs": "./scripts/docs.js",
1515
"package": "npm run build",
16-
"install": "node migrate/migratewarn.js"
16+
"install": "node migrate/migratewarn.js",
17+
"artifacts": "./scripts/artifact_tagging.js"
1718
},
1819
"homepage": "https://ui-router.github.io/react",
1920
"contributors": [
@@ -61,6 +62,7 @@
6162
"react-addons-test-utils": "^15.3.1",
6263
"react-dom": "^15.0.2",
6364
"react-test-renderer": "^15.3.1",
65+
"readline-sync": "^1.4.7",
6466
"replace-in-file": "^2.0.3",
6567
"shelljs": "^0.7.7",
6668
"shx": "^0.1.4",

scripts/artifact_tagging.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

Comments
 (0)