|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -ex |
| 3 | + |
| 4 | +# Stages a release by putting everything that should be packaged and released |
| 5 | +# into the ./deploy folder. This script should be run from the root of the |
| 6 | +# material2 repo. |
| 7 | + |
| 8 | +# Make sure you are not running `ng serve` or `ng build --watch` when running this. |
| 9 | + |
| 10 | + |
| 11 | +# Clear dist/ and deploy/ so that we guarantee there are no stale artifacts. |
| 12 | +rm -rf ./dist |
| 13 | +rm -rf ./deploy |
| 14 | + |
| 15 | +# For packaging for npm only, replace the TypeScript module format to commonjs. |
| 16 | +# Creates a tscongig.json.backup with the original file that we'll use to restore after building. |
| 17 | +sed -i.backup 's|"module": ".+"|"module": "commonjs"|g' ./src/tsconfig.json |
| 18 | + |
| 19 | +# Perform a build with the modified tsconfig.json. |
| 20 | +ng build |
| 21 | + |
| 22 | +# Return tsconfig.json to its original state. |
| 23 | +mv -f ./src/tsconfig.json.backup ./src/tsconfig.json |
| 24 | + |
| 25 | +# Inline the css and html into the component ts files. |
| 26 | +./node_modules/gulp/bin/gulp.js inline-resources |
| 27 | + |
| 28 | +# deploy/ serves as a working directory to stage the release. |
| 29 | +mkdir deploy |
| 30 | + |
| 31 | +# Copy all components/ to deploy/ and replace "../core" with just "core" since each |
| 32 | +# component directory will now live as a sibling to core/. |
| 33 | +# Use a `.bak` extension for sed backup because `sed` on OSX will not work without a backup |
| 34 | +# extension. Delete the backups immediately after. |
| 35 | +cp -R ./dist/components/* ./deploy/ |
| 36 | +find ./deploy -type f \( -name "*.js" -o -name "*.ts" \) -exec sed -i.bak 's|\.\./core|core|g' {} \; |
| 37 | +find ./deploy -type f -name "*.bak" | xargs rm |
| 38 | + |
| 39 | +# Copy the core/ directory directly into ./deploy |
| 40 | +cp -R ./dist/core/ ./deploy/core/ |
| 41 | + |
| 42 | +# To test the packages, use `npm link` in the package directories. |
| 43 | +# See https://docs.npmjs.com/cli/link |
0 commit comments