forked from auth0/lock
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy deploy scripts from the current Lock
- Loading branch information
1 parent
71b0e88
commit df0d118
Showing
9 changed files
with
259 additions
and
36,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
node_modules/ | ||
build/ | ||
node_modules/ | ||
release/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters