From 907dae117618a5af6fb2afe1ea7bb9dd74bebcb9 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Mon, 12 Jan 2015 22:05:59 -0500 Subject: [PATCH 01/13] chore(nom): Make modules Browserify compatible --- scripts/bower/publish.sh | 22 ++++++++++++++++++++++ scripts/utils.inc | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 0170f6183174..e942ea3d6d96 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -75,6 +75,28 @@ function prepare { replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION" replaceJsonProp "package.json" "version" ".*" "$NEW_VERSION" replaceJsonProp "package.json" "angular.*" ".*" "$NEW_VERSION" + deleteJsonProp "package.json" "main" + + echo "-- Adding CommonJS index file" + if [ -f "index.js" ] + then + rm index.js + fi + + touch index.js + echo "require('./$repo');" >> index.js + echo "" >> index.js + echo "module.exports = $repo;" >> index.js + if [ $repo == "angular" ] + then + echo "module.exports = angular;" + else + suffix=`echo $repo | cut -c9-` + first=`echo $suffix | cut -c1 | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + tail=`echo $suffix | cut -c2-` + + echo "module.exports = angular.module('ng$first$tail');" + fi git add -A diff --git a/scripts/utils.inc b/scripts/utils.inc index 919f7df9799e..9feea7a5959d 100644 --- a/scripts/utils.inc +++ b/scripts/utils.inc @@ -207,6 +207,12 @@ function replaceJsonProp { replaceInFile $1 '"('$2')"[ ]*:[ ]*"'$3'"' '"\1": "'$4'"' } +# deleteJsonProp(jsonFile, property) +# - restriction: property needs to be on a single line! +function deleteJsonProp { + sed -i '' -e /\"$2\"\:/d $1 +} + # replaceInFile(file, findPattern, replacePattern) function replaceInFile { sed -i .tmp -E "s/$2/$3/" $1 From 736f6c4f1502d212f4a8ee517ab8eef2e87011a1 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Mon, 12 Jan 2015 22:45:52 -0500 Subject: [PATCH 02/13] Export module name only --- scripts/bower/publish.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index e942ea3d6d96..57c23db2eefe 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -91,11 +91,12 @@ function prepare { then echo "module.exports = angular;" else + # convert to module names (angular-animate >> ngAnimate) suffix=`echo $repo | cut -c9-` first=`echo $suffix | cut -c1 | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` tail=`echo $suffix | cut -c2-` - echo "module.exports = angular.module('ng$first$tail');" + echo "module.exports = 'ng$first$tail';" fi git add -A From 62b538c35dbc429993da769a1afc173c49d88256 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Mon, 12 Jan 2015 22:50:02 -0500 Subject: [PATCH 03/13] chore(npm): Pipe to index.js, duh. --- scripts/bower/publish.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 57c23db2eefe..f47fa7f95cc2 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -89,14 +89,14 @@ function prepare { echo "module.exports = $repo;" >> index.js if [ $repo == "angular" ] then - echo "module.exports = angular;" + echo "module.exports = angular;" >> index.js else # convert to module names (angular-animate >> ngAnimate) suffix=`echo $repo | cut -c9-` first=`echo $suffix | cut -c1 | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` tail=`echo $suffix | cut -c2-` - echo "module.exports = 'ng$first$tail';" + echo "module.exports = 'ng$first$tail';" >> index.js fi git add -A From 706b0ced00b18206dc814e39527083bfffb600a3 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Mon, 12 Jan 2015 22:54:55 -0500 Subject: [PATCH 04/13] chore(npm): Better way to initialize index.js --- scripts/bower/publish.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index f47fa7f95cc2..039524b30782 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -78,13 +78,7 @@ function prepare { deleteJsonProp "package.json" "main" echo "-- Adding CommonJS index file" - if [ -f "index.js" ] - then - rm index.js - fi - - touch index.js - echo "require('./$repo');" >> index.js + echo "require('./$repo');" > index.js echo "" >> index.js echo "module.exports = $repo;" >> index.js if [ $repo == "angular" ] From 156ca4c26063c3c488c073a5047dc8ef2037f168 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Mon, 12 Jan 2015 23:28:20 -0500 Subject: [PATCH 05/13] chore(npm): Add angular peer dependency where appropriate --- scripts/bower/publish.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 039524b30782..d215e5f61249 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -91,6 +91,14 @@ function prepare { tail=`echo $suffix | cut -c2-` echo "module.exports = 'ng$first$tail';" >> index.js + + # add angular as a peer dependency + deleteJsonProp "package.json" "peerDependencies" + replaceInFile "package.json" "homepage\"\: \"http\:\/\/angularjs\.org\"$" "homepage\"\: \"http\:\/\/angularjs\.org\"," + sed -i '' -e /^}/d "package.json" + # have to use single line form so deleteJsonProp will work + echo "\t\"peerDependencies\": { \"angular\": \"$NEW_VERSION\" }" >> package.json + echo '}' >> package.json fi git add -A From b4a052d5e1198e17cf171c56b6ae162cb7997a89 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Mon, 12 Jan 2015 23:36:48 -0500 Subject: [PATCH 06/13] chore(npm): Handle special case of angular-mocks module(s) --- scripts/bower/publish.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index d215e5f61249..e99ac8ec1eb0 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -90,7 +90,14 @@ function prepare { first=`echo $suffix | cut -c1 | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` tail=`echo $suffix | cut -c2-` - echo "module.exports = 'ng$first$tail';" >> index.js + if [ $repo != "angular-mocks" ] + then + echo "module.exports = 'ng$first$tail';" >> index.js + else + echo "exports.ngMock = 'ngMock';" >> index.js + echo "exports.ngMockE2E = 'ngMockE2E';" >> index.js + echo "exports.ngAnimateMock = 'ngAnimateMock';" >> index.js + fi # add angular as a peer dependency deleteJsonProp "package.json" "peerDependencies" From 5b5d50cb752a0e75d8fdd4dc79cac8771b3c329d Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Tue, 13 Jan 2015 09:40:09 -0500 Subject: [PATCH 07/13] chore(npm): Remove errant code gen line --- scripts/bower/publish.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index e99ac8ec1eb0..b579773266b8 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -80,7 +80,6 @@ function prepare { echo "-- Adding CommonJS index file" echo "require('./$repo');" > index.js echo "" >> index.js - echo "module.exports = $repo;" >> index.js if [ $repo == "angular" ] then echo "module.exports = angular;" >> index.js From 24dfc82f2fdb81684d07968eaf7e90a87fd60121 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Tue, 13 Jan 2015 09:52:08 -0500 Subject: [PATCH 08/13] chore(npm): Use 2 spaces in package.json, not a tab --- scripts/bower/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index b579773266b8..bb27e0917186 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -103,7 +103,7 @@ function prepare { replaceInFile "package.json" "homepage\"\: \"http\:\/\/angularjs\.org\"$" "homepage\"\: \"http\:\/\/angularjs\.org\"," sed -i '' -e /^}/d "package.json" # have to use single line form so deleteJsonProp will work - echo "\t\"peerDependencies\": { \"angular\": \"$NEW_VERSION\" }" >> package.json + echo " \"peerDependencies\": { \"angular\": \"$NEW_VERSION\" }" >> package.json echo '}' >> package.json fi From 8f5bb249c5c389d3bf4596c6b53f7b194654ab0e Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Tue, 13 Jan 2015 21:58:41 -0500 Subject: [PATCH 09/13] chore(npm): List new utility function --- scripts/utils.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/utils.inc b/scripts/utils.inc index 9feea7a5959d..4aedca9cead0 100644 --- a/scripts/utils.inc +++ b/scripts/utils.inc @@ -46,6 +46,7 @@ # Utility functions: # - readJsonProp # - replaceJsonProp +# - deleteJsonProp # - resolveDir # - getVar # - serVar From e8b9b7a37a8336cdc3be36220352fedd738363e6 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Tue, 13 Jan 2015 21:59:02 -0500 Subject: [PATCH 10/13] chore(npm): Remove peerDependencies generation --- scripts/bower/publish.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index bb27e0917186..188178ef572e 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -97,14 +97,6 @@ function prepare { echo "exports.ngMockE2E = 'ngMockE2E';" >> index.js echo "exports.ngAnimateMock = 'ngAnimateMock';" >> index.js fi - - # add angular as a peer dependency - deleteJsonProp "package.json" "peerDependencies" - replaceInFile "package.json" "homepage\"\: \"http\:\/\/angularjs\.org\"$" "homepage\"\: \"http\:\/\/angularjs\.org\"," - sed -i '' -e /^}/d "package.json" - # have to use single line form so deleteJsonProp will work - echo " \"peerDependencies\": { \"angular\": \"$NEW_VERSION\" }" >> package.json - echo '}' >> package.json fi git add -A From 1916264460dab08775cfd548b1c1ee6d64edab82 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Thu, 15 Jan 2015 12:20:53 -0500 Subject: [PATCH 11/13] Updating to return the module for everything but angular and angular-mocks --- scripts/bower/publish.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 188178ef572e..1d68b50fad89 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -91,7 +91,7 @@ function prepare { if [ $repo != "angular-mocks" ] then - echo "module.exports = 'ng$first$tail';" >> index.js + echo "module.exports = angular.module('ng$first$tail');" >> index.js else echo "exports.ngMock = 'ngMock';" >> index.js echo "exports.ngMockE2E = 'ngMockE2E';" >> index.js From b40fe181d0912d3167636f479b675956e2fb3d61 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Fri, 23 Jan 2015 11:22:57 -0500 Subject: [PATCH 12/13] Clean up and allowing use of require('angular-mocks/ngMock').name --- scripts/bower/publish.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 1d68b50fad89..7bfe3b8eff1f 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -29,6 +29,11 @@ function init { angular-touch angular-messages ) + MOCK_MODULES=( + ngMock + ngMockE2E + ngAnimateMock + ) } @@ -77,9 +82,13 @@ function prepare { replaceJsonProp "package.json" "angular.*" ".*" "$NEW_VERSION" deleteJsonProp "package.json" "main" - echo "-- Adding CommonJS index file" - echo "require('./$repo');" > index.js - echo "" >> index.js + if [ $repo != "angular-mocks" ] + then + echo "-- Adding $repo CommonJS index file" + echo "require('./$repo');" > index.js + echo "" >> index.js + fi + if [ $repo == "angular" ] then echo "module.exports = angular;" >> index.js @@ -93,9 +102,13 @@ function prepare { then echo "module.exports = angular.module('ng$first$tail');" >> index.js else - echo "exports.ngMock = 'ngMock';" >> index.js - echo "exports.ngMockE2E = 'ngMockE2E';" >> index.js - echo "exports.ngAnimateMock = 'ngAnimateMock';" >> index.js + for mock in "${MOCK_MODULES[@]}" + do + echo "-- Adding $repo/$mock CommonJS file" + echo "require('./$repo');" > $mock.js + echo "" >> $mock.js + echo "module.exports = angular.module('$mock');" >> $mock.js + done fi fi From ed8489a055e81ff74fa4a985292afd2f8a1d8087 Mon Sep 17 00:00:00 2001 From: Ben Clinkinbeard Date: Wed, 18 Feb 2015 15:38:10 -0500 Subject: [PATCH 13/13] chore(npm): Return module name for all but angular and angular-mocks angular returns angular object, angular-mocks provides ngAnimateMock.js, ngMock.js and ngMockE2E.js which all return their respective module names --- scripts/bower/publish.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 7bfe3b8eff1f..f1ad9d5d47fd 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -100,14 +100,14 @@ function prepare { if [ $repo != "angular-mocks" ] then - echo "module.exports = angular.module('ng$first$tail');" >> index.js + echo "module.exports = 'ng$first$tail';" >> index.js else for mock in "${MOCK_MODULES[@]}" do echo "-- Adding $repo/$mock CommonJS file" echo "require('./$repo');" > $mock.js echo "" >> $mock.js - echo "module.exports = angular.module('$mock');" >> $mock.js + echo "module.exports = '$mock';" >> $mock.js done fi fi