Skip to content

Commit 04d1c80

Browse files
jelbournhansl
authored andcommitted
chore: include .metadata.json files in packages for deployment (#848)
* update stage-release to include .metadata.json files * bump version from alpha.6 to alpha.6-2 * remove test files from packages * add skipTemplateCodegen option * add desc to enact-release script * improve script comments
1 parent 991364e commit 04d1c80

File tree

20 files changed

+86
-39
lines changed

20 files changed

+86
-39
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"deploy": "firebase deploy",
2323
"webdriver-manager": "webdriver-manager"
2424
},
25-
"version": "2.0.0-alpha.6",
25+
"version": "2.0.0-alpha.6-2",
2626
"license": "MIT",
2727
"engines": {
2828
"node": ">= 4.2.1 < 5"
@@ -43,6 +43,7 @@
4343
"zone.js": "0.6.12"
4444
},
4545
"devDependencies": {
46+
"@angular/compiler-cli": "^0.4.1",
4647
"add-stream": "^1.0.0",
4748
"angular-cli": "^1.0.0-beta.9",
4849
"broccoli-autoprefixer": "^4.1.0",

scripts/release/enact-release.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22

3+
# Run this script after running `stage-release.sh` to publish the packages staged to deploy/
4+
# Optionally uses the first argument as the tag for the release (such as "next").
5+
# This script should be run from the root of the material2 repo.
6+
7+
38
# `npm whoami` errors and dies if you're not logged in,
49
# so we redirect the stderr output to /dev/null since we don't care.
510
NPM_USER=$(npm whoami 2> /dev/null)
@@ -9,11 +14,15 @@ if [ "${NPM_USER}" != "angular2-material" ]; then
914
exit
1015
fi
1116

17+
NPM_TAG="latest"
18+
if [ "$1" ] ; then
19+
NPM_TAG=${1}
20+
fi
21+
1222
set -ex
1323

14-
for package in ./deploy/*
15-
do
16-
npm publish --access public ${package}
24+
for package in ./deploy/* ; do
25+
npm publish --access public ${package} --tag ${NPM_TAG}
1726
done
1827

1928
# Always log out of npm when publish is complete.

scripts/release/stage-release.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -exu
2+
set -xu
33

44
# Stages a release by putting everything that should be packaged and released
55
# into the ./deploy folder. This script should be run from the root of the
@@ -12,19 +12,55 @@ set -exu
1212
rm -rf ./dist
1313
rm -rf ./deploy
1414

15-
# Perform a build with the modified tsconfig.json.
15+
# deploy/ serves as a working directory to stage the release.
16+
mkdir deploy
17+
18+
# Start off by building normally.
19+
ng build
20+
21+
# We need to remove moduleId for the ngc build. We do this by simply commenting out with a
22+
# distinguishing marker and then undoing those lines after we've generated the .metadata.json files.
23+
grep -lr "moduleId:" ./src/ | xargs sed -i 's|moduleId:|//MODULE moduleId:|g'
24+
25+
# Run tsc directly first so that the output directories match what ngc is expecting. This is
26+
# different from what the CLI will output for *demo-app*, but we don't care about the output for
27+
# demo-app when we're staging a release (only components/ and core/).
28+
tsc -p ./src/demo-app
29+
30+
# Now run ngc to generate the .metadata.json files. Our tsconfig is configred with
31+
# skipTemplateCodegen, so only the metadata files are actually generated.
32+
./node_modules/.bin/ngc -p ./src/demo-app
33+
34+
# Restore the moduleIds.
35+
grep -lr "//MODULE " ./src/ | xargs sed -i 's|//MODULE ||g'
36+
37+
# At this point, we have all of our .metadata.json files, which is all we care about from ngc.
38+
# Temporarily copy them over to deploy/ so we can cut a clean build.
39+
# Use rsync since we want to preserve the directory structure and `cp --parents` won't work on OSX.
40+
find ./dist/{components,core} -iname "*.metadata.json" | xargs -i rsync -Rq {} ./deploy/
41+
42+
# Wipe away dist and perform a clean build.
43+
rm -rf ./dist
1644
ng build
1745

1846
# Inline the css and html into the component ts files.
1947
npm run inline-resources
2048

21-
# deploy/ serves as a working directory to stage the release.
22-
mkdir deploy
49+
# Move the .metadata.json files back to where we want them.
50+
(cd ./deploy ; find ./ -iname "*.metadata.json" | xargs -i rsync -Rq {} ../)
51+
52+
# Clear the deploy/ directory again now that we've pulled the metadata out of it.
53+
rm -rf ./deploy/*
2354

2455
# Copy all components/ to deploy/
2556
cp -R ./dist/components/* ./deploy/
2657

2758
# Copy the core/ directory directly into ./deploy
2859
cp -R ./dist/core/ ./deploy/core/
2960

61+
# Remove test files from deploy/
62+
find ./deploy -iname "*.spec.d.ts" | xargs rm
63+
find ./deploy -iname "*.spec.js" | xargs rm
64+
find ./deploy -iname "*.spec.js.map" | xargs rm
65+
3066
# To test the packages, simply `npm install` the package directories.

src/components/button/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/button",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material button",
55
"main": "./button.js",
66
"typings": "./button.d.ts",
@@ -23,6 +23,6 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6"
26+
"@angular2-material/core": "2.0.0-alpha.6-2"
2727
}
2828
}

src/components/card/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/card",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material card",
55
"main": "./card.js",
66
"typings": "./card.d.ts",
@@ -21,6 +21,6 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6"
24+
"@angular2-material/core": "2.0.0-alpha.6-2"
2525
}
2626
}

src/components/checkbox/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/checkbox",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material checkbox",
55
"main": "./checkbox.js",
66
"typings": "./checkbox.d.ts",
@@ -21,7 +21,7 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6",
24+
"@angular2-material/core": "2.0.0-alpha.6-2",
2525
"@angular/forms": "^0.1.0"
2626
}
2727
}

src/components/grid-list/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/grid-list",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material grid list",
55
"main": "./grid-list.js",
66
"typings": "./grid-list.d.ts",
@@ -23,6 +23,6 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6"
26+
"@angular2-material/core": "2.0.0-alpha.6-2"
2727
}
2828
}

src/components/icon/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/icon",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material icon",
55
"main": "./icon.js",
66
"typings": "./icon.d.ts",
@@ -22,6 +22,6 @@
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
2424
"@angular/http": "2.0.0-rc.4",
25-
"@angular2-material/core": "2.0.0-alpha.6"
25+
"@angular2-material/core": "2.0.0-alpha.6-2"
2626
}
2727
}

src/components/input/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/input",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material input",
55
"main": "./input.js",
66
"typings": "./input.d.ts",
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/angular/material2#readme",
2525
"peerDependencies": {
26-
"@angular2-material/core": "2.0.0-alpha.6",
26+
"@angular2-material/core": "2.0.0-alpha.6-2",
2727
"@angular/forms": "^0.1.0"
2828
}
2929
}

src/components/list/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular2-material/list",
3-
"version": "2.0.0-alpha.6",
3+
"version": "2.0.0-alpha.6-2",
44
"description": "Angular 2 Material list",
55
"main": "./list.js",
66
"typings": "./list.d.ts",
@@ -21,6 +21,6 @@
2121
},
2222
"homepage": "https://github.com/angular/material2#readme",
2323
"peerDependencies": {
24-
"@angular2-material/core": "2.0.0-alpha.6"
24+
"@angular2-material/core": "2.0.0-alpha.6-2"
2525
}
2626
}

0 commit comments

Comments
 (0)