1
1
#! /usr/bin/env bash
2
- set -exu
2
+ set -xu
3
3
4
4
# Stages a release by putting everything that should be packaged and released
5
5
# into the ./deploy folder. This script should be run from the root of the
@@ -12,19 +12,55 @@ set -exu
12
12
rm -rf ./dist
13
13
rm -rf ./deploy
14
14
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
16
44
ng build
17
45
18
46
# Inline the css and html into the component ts files.
19
47
npm run inline-resources
20
48
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/*
23
54
24
55
# Copy all components/ to deploy/
25
56
cp -R ./dist/components/* ./deploy/
26
57
27
58
# Copy the core/ directory directly into ./deploy
28
59
cp -R ./dist/core/ ./deploy/core/
29
60
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
+
30
66
# To test the packages, simply `npm install` the package directories.
0 commit comments