Skip to content

Commit

Permalink
Copy deploy scripts from the current Lock
Browse files Browse the repository at this point in the history
  • Loading branch information
gnandretta committed Sep 2, 2015
1 parent 71b0e88 commit df0d118
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 36,635 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
build/
node_modules/
release/
File renamed without changes.
127 changes: 127 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
"use strict";

var fs = require("fs");
var pkg = require("./package");

var minor_version = pkg.version.replace(/\.(\d)*$/, "");
var major_version = pkg.version.replace(/\.(\d)*\.(\d)*$/, "");
var path = require("path");

function rename_release (v) {
return function (d, f) {
var dest = path.join(d, f.replace(/(\.min)?\.js$/, "-"+ v + "$1.js"));
return dest;
};
}

module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
aws_s3: {
options: {
accessKeyId: process.env.S3_KEY,
secretAccessKey: process.env.S3_SECRET,
bucket: process.env.S3_BUCKET,
region: process.env.S3_REGION,
uploadConcurrency: 5,
params: {
CacheControl: "public, max-age=300"
},
// debug: true <<< use this option to test changes
},
clean: {
files: [
{action: "delete", dest: "js/lock-passwordless-" + pkg.version + ".js"},
{action: "delete", dest: "js/lock-passwordless-" + pkg.version + ".min.js"},
{action: "delete", dest: "js/lock-passwordless-" + major_version + ".js"},
{action: "delete", dest: "js/lock-passwordless-" + major_version + ".min.js"},
{action: "delete", dest: "js/lock-passwordless-" + minor_version + ".js"},
{action: "delete", dest: "js/lock-passwordless-" + minor_version + ".min.js"}
]
},
publish: {
files: [
{
expand: true,
cwd: "release/",
src: ["**"],
dest: "js/"
}
]
}
},
browserify: {
options: {
browserifyOptions: {
extensions: ".jsx"
}
},
build: {
src: "src/browser.js",
dest: "build/auth0-lock-passwordless.js"
}
},
copy: {
release: {
files: [
{expand: true, flatten: true, src: "build/*", dest: "release/", rename: rename_release(pkg.version)},
{expand: true, flatten: true, src: "build/*", dest: "release/", rename: rename_release(minor_version)},
{expand: true, flatten: true, src: "build/*", dest: "release/", rename: rename_release(major_version)}
]
}
},
env: {
build: {
NODE_ENV: "production"
}
},
fastly: {
options: {
key: process.env.FASTLY_KEY,
host: process.env.FASTLY_HOST
},
purge: {
options: {
urls: [
"js/lock-passwordless" + pkg.version + ".js",
"js/lock-passwordless" + pkg.version + ".min.js",
"js/lock-passwordless" + major_version + ".js",
"js/lock-passwordless" + major_version + ".min.js",
"js/lock-passwordless" + minor_version + ".js",
"js/lock-passwordless" + minor_version + ".min.js",
]
},
},
},
http: {
purge_js: {options: {url: process.env.CDN_ROOT + "/js/lock-passwordless" + pkg.version + ".js", method: "DELETE"}},
purge_js_min: {options: {url: process.env.CDN_ROOT + "/js/lock-passwordless" + pkg.version + ".min.js", method: "DELETE"}},
purge_major_js: {options: {url: process.env.CDN_ROOT + "/js/lock-passwordless" + major_version + ".js", method: "DELETE"}},
purge_major_js_min: {options: {url: process.env.CDN_ROOT + "/js/lock-passwordless" + major_version + ".min.js", method: "DELETE"}},
purge_minor_js: {options: {url: process.env.CDN_ROOT + "/js/lock-passwordless" + minor_version + ".js", method: "DELETE"}},
purge_minor_js_min: {options: {url: process.env.CDN_ROOT + "/js/lock-passwordless" + minor_version + ".min.js", method: "DELETE"} }
},
uglify: {
build: {
src: "build/auth0-lock-passwordless.js",
dest: "build/auth0-lock-passwordless.min.js"
}
}
});

grunt.loadNpmTasks("grunt-aws-s3");
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-env");
grunt.loadNpmTasks("grunt-fastly");
grunt.loadNpmTasks("grunt-http");


grunt.registerTask("build", ["env:build", "browserify:build", "uglify:build"]);
grunt.registerTask("purge_cdn", ["http:purge_js", "http:purge_js_min", "http:purge_major_js", "http:purge_major_js_min", "http:purge_minor_js", "http:purge_minor_js_min"]);
grunt.registerTask("cdn", ["build", "copy:release", "aws_s3:clean", "aws_s3:publish", "purge_cdn"]);

};
45 changes: 45 additions & 0 deletions bin/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -e

BIN="./node_modules/.bin"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VERSION=$(node -e "console.log(require('$DIR/../package.json').version)")
PACKAGE=$(node -e "console.log(require('$DIR/../package.json').name)")

TAG_NAME="v$VERSION"
TAG_EXISTS=$(git tag -l "$TAG_NAME")

if [ ! -z "$TAG_EXISTS" ]; then
echo "There is already a tag $TAG_EXISTS in git. Skiping git deploy."
else
echo "Deploying $VERSION to git"

LAST_COMMIT=$(git log -1 --pretty=%B)
git checkout -b dist
grep -v '^build$' .gitignore > /tmp/.gitignore
mv /tmp/.gitignore .gitignore
git add --force build/*
git commit -am "$TAG_NAME"
git tag "$TAG_NAME" -m "$LAST_COMMIT"
git checkout master
git push origin $TAG_NAME
git branch -D dist
fi

NPM_EXISTS=$(npm info $PACKAGE@$VERSION)

if [ ! -z "$NPM_EXISTS" ]; then
echo "There is already a version $VERSION in npm. Skiping npm publish."
else
echo "Deploying $VERSION to npm"
npm publish
fi

CDN_EXISTS=$(curl -s -o /dev/null -w "%{http_code}" https://cdn.auth0.com/js/lock-passwordless$VERSION.min.js | grep 200 || true)

if [ ! -z "$CDN_EXISTS" ]; then
echo "There is already a version $VERSION in the CDN. Skiping cdn publish."
else
echo "Deploying $VERSION to cdn"
$BIN/grunt cdn
fi
45 changes: 45 additions & 0 deletions bin/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env node
var path = require('path');
var bump = require('bump');
var unreleased = require('unreleased');
var fs = require('fs');

function run(cmd, done) {
var exec = require('child_process').exec;
var proc = exec(cmd, done);
proc.stdout.pipe(process.stdout);
proc.stderr.pipe(process.stderr);
}

try {
var rootDir = path.resolve(__dirname, '..');
var res = bump(rootDir, process.argv.pop());

unreleased(res.version, rootDir, 'auth0/lock-passwordless', function (err, changelog) {
if (err) { return process.exit(1); }

changelog = new Buffer(changelog + '\n\n');
var file = path.join(rootDir, 'CHANGELOG.md');

var data = fs.readFileSync(file); //read existing contents into data
var fd = fs.openSync(file, 'w+');
fs.writeSync(fd, changelog, 0, changelog.length); //write new data
fs.writeSync(fd, data, 0, data.length); //append old data
fs.close(fd);

run('git commit -am "Release: ' + res.version + '"', function (err) {
if (!err) { return process.exit(0); }

// restore original status
console.error(err.message);
run('git checkout .', function (err) {
if (err) { console.error(err.message); }
process.exit(1);
});
});
});

} catch (err) {
console.error(err.message);
process.exit(1);
}
23 changes: 0 additions & 23 deletions build/browser.js

This file was deleted.

11 changes: 5 additions & 6 deletions build/build.js

Large diffs are not rendered by default.

36,628 changes: 23 additions & 36,605 deletions build/design-tools.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,24 @@
"babelify": "^6.1.2",
"browserify": "^10.2.4",
"browserify-css": "^0.6.1",
"bump": "git://github.com/ianstormtaylor/bump",
"expect.js": "^0.3.1",
"grunt": "^0.4.5",
"grunt-aws-s3": "^0.14.0",
"grunt-browserify": "^4.0.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-env": "^0.4.4",
"grunt-fastly": "^0.1.3",
"grunt-http": "^1.6.0",
"mocha": "^2.2.5",
"mochify": "^2.12.0",
"packageify": "^0.2.2",
"request": "^2.58.0",
"sinon": "^1.15.4",
"uglify-js": "^2.4.23",
"unreleased": "^0.1.0",
"watchify": "^3.2.2",
"zuul": "^3.2.0"
},
Expand Down

0 comments on commit df0d118

Please sign in to comment.