Skip to content

Commit

Permalink
Add artifact tagging script
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Mar 24, 2017
1 parent dc58311 commit abfbe9e
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"angular": "~1.6.1",
"angular-ui-router": "angular-ui/ui-router#1.0.0-rc.1-artifacts",
"awesome-typescript-loader": "^3.0.0",
"readline-sync": "^1.4.7",
"rxjs": "^5.0.0",
"shx": "^0.2.2",
"systemjs": "0.19.25",
"typescript": "^2.1.5",
"ui-router-core": "=5.0.0-pre.1",
Expand Down
30 changes: 30 additions & 0 deletions scripts/artifact_tagging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!env node
"use strict";

let version = require('../package.json').version;

require('shelljs/global');
let readlineSync = require('readline-sync');
let fs = require('fs');
let path = require('path');
let util = require('./util');
let _exec = util._exec;

cd(path.join(__dirname, '..'));

if (!readlineSync.keyInYN('Ready to publish to ' + version + '-artifacts tag?')) {
process.exit(1);
}

util.ensureCleanMaster('master');

_exec('npm run all');

// then tag and push tag
_exec(`git checkout -b ${version}-artifacts-prep`);
_exec(`git add --force lib _bundles`);
_exec(`git commit -m 'chore(*): commiting build files'`);
_exec(`git tag ${version}-artifacts`);
_exec(`git push -u origin ${version}-artifacts`);
_exec(`git checkout master`);
_exec(`git branch -D ${version}-artifacts-prep`);
74 changes: 74 additions & 0 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import progress from 'rollup-plugin-progress';
import sourcemaps from 'rollup-plugin-sourcemaps';
import visualizer from 'rollup-plugin-visualizer';

var MINIFY = process.env.MINIFY;
var ROUTER = process.env.ROUTER;
var EVENTS = process.env.EVENTS;
var RESOLVE = process.env.RESOLVE;

var pkg = require('./package.json');
var banner =
`/**
* ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license MIT License, http://www.opensource.org/licenses/MIT
*/`;

var uglifyOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) =>
comment.type === 'comment2' && /@license/i.test(comment.value);

var plugins = [
nodeResolve({jsnext: true}),
progress(),
sourcemaps(),
];

if (MINIFY) plugins.push(uglify(uglifyOpts));
if (ROUTER && MINIFY) plugins.push(visualizer({ sourcemap: true }));

var extension = MINIFY ? ".min.js" : ".js";

const BASE_CONFIG = {
sourceMap: true,
format: 'umd',
exports: 'named',
plugins: plugins,
banner: banner,
};

const ROUTER_CONFIG = Object.assign({
moduleName: 'angular-ui-router',
entry: 'lib-esm/index.js',
dest: 'release/angular-ui-router' + extension,
globals: { angular: 'angular' },
external: 'angular',
}, BASE_CONFIG);

const EVENTS_CONFIG = Object.assign({}, BASE_CONFIG, {
moduleName: 'angular-ui-router-state-events',
entry: 'lib-esm/legacy/stateEvents.js',
dest: 'release/stateEvents' + extension,
globals: { angular: 'angular', 'ui-router-core': 'ui-router-core' },
external: ['angular', 'ui-router-core'],
});

const RESOLVE_CONFIG = Object.assign({}, BASE_CONFIG, {
moduleName: 'angular-ui-router-resolve-service',
entry: 'lib-esm/legacy/resolveService.js',
dest: 'release/resolveService' + extension,
globals: { angular: 'angular', 'ui-router-core': 'ui-router-core' },
external: ['angular', 'ui-router-core'],
});

const CONFIG =
RESOLVE ? RESOLVE_CONFIG :
EVENTS ? EVENTS_CONFIG :
ROUTER ? ROUTER_CONFIG : ROUTER_CONFIG;

export default CONFIG;
39 changes: 39 additions & 0 deletions scripts/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use strict";

require('shelljs/global');
let fs = require('fs');

function ensureCleanMaster(branch) {
branch = branch || 'master';
if (exec('git symbolic-ref HEAD').stdout.trim() !== `refs/heads/${branch}`)
throw new Error(`Not on ${branch} branch, aborting`);
if (exec('git status --porcelain').stdout.trim() !== '')
throw new Error('Working copy is dirty, aborting');
}

function _exec(command) {
echo(command);
echo();
var result = exec(command);
if (result.code === 0) return result;
echo(`Aborting; non-zero return value (${result.code}) from: ${command}`);
exit(result.code)
}

function asJson (obj) { return JSON.stringify(obj, null, 2); }

let ensure = (type) => (path) => {
let is = false;
try { is = fs.lstatSync(path)['is' + type](); } catch (e) { console.log(e); }
if (!is) echo(`Not a ${type}: ${path}`) && exit(-3);
};
let assertDir = ensure('Directory');
let assertFile = ensure('File');

module.exports = {
ensureCleanMaster: ensureCleanMaster,
_exec: _exec,
asJson: asJson,
assertDir: assertDir,
assertFile: assertFile
};
46 changes: 45 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ errno@^0.1.3:
dependencies:
prr "~0.0.0"

es6-object-assign@^1.0.3:
version "1.1.0"
resolved "https://registry.yarnpkg.com/es6-object-assign/-/es6-object-assign-1.1.0.tgz#c2c3582656247c39ea107cb1e6652b6f9f24523c"

events@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
Expand Down Expand Up @@ -540,7 +544,7 @@ glob-parent@^2.0.0:
dependencies:
is-glob "^2.0.0"

glob@^7.0.5:
glob@^7.0.0, glob@^7.0.5:
version "7.1.1"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8"
dependencies:
Expand Down Expand Up @@ -630,6 +634,10 @@ interpret@^0.6.4:
version "0.6.6"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-0.6.6.tgz#fecd7a18e7ce5ca6abfb953e1f86213a49f1625b"

interpret@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c"

is-binary-path@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898"
Expand Down Expand Up @@ -986,6 +994,10 @@ path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"

pbkdf2-compat@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz#b6e0c8fa99494d94e0511575802a59a5c142f288"
Expand Down Expand Up @@ -1067,6 +1079,16 @@ readdirp@^2.0.0:
readable-stream "^2.0.2"
set-immediate-shim "^1.0.1"

readline-sync@^1.4.7:
version "1.4.7"
resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.7.tgz#001bfdd4c06110c3c084c63bf7c6a56022213f30"

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
dependencies:
resolve "^1.1.6"

regex-cache@^0.4.2:
version "0.4.3"
resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145"
Expand Down Expand Up @@ -1109,6 +1131,12 @@ request@^2.81.0:
tunnel-agent "^0.6.0"
uuid "^3.0.0"

resolve@^1.1.6:
version "1.3.2"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.2.tgz#1f0442c9e0cbb8136e87b9305f932f46c7f28235"
dependencies:
path-parse "^1.0.5"

right-align@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
Expand Down Expand Up @@ -1155,6 +1183,22 @@ sha.js@2.2.6:
version "2.2.6"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.2.6.tgz#17ddeddc5f722fb66501658895461977867315ba"

shelljs@^0.7.3:
version "0.7.7"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1"
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

shx@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/shx/-/shx-0.2.2.tgz#0a304d020b0edf1306ad81570e80f0346df58a39"
dependencies:
es6-object-assign "^1.0.3"
minimist "^1.2.0"
shelljs "^0.7.3"

signal-exit@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
Expand Down

0 comments on commit abfbe9e

Please sign in to comment.