Skip to content

Commit

Permalink
feat(): change to Covalent Angular package format build w/ ng-packagr (
Browse files Browse the repository at this point in the history
…Teradata#1065)

* feat(): cherry-pick over inital ssr research/solution to new clean branch last 2 branches were outdated and getting too dirty

* feat(): mod paging, virtual scroll, notifications to follow ng-packagr consumption style to produce respective angular package format v5

* feat(): push yarn.lock update

* feat(): ng-packagr mod for @covalent/common and resove new file paths breaking npm run serve

* feat(): common folder setup for Angular Package Format and cleaned up scripts used for building @covalent/core and testing ssr

* fix(): forgot to save merge conflict resolution

* refactor(): remove outdated custom build config

* refactor(): remove package-lock.json

* feat(): enable imports from secondary entry points

For paging, virtual-scroll, notifications, and common.
Example for paging:
import { CovalentPagingModule } from '@covalent/core';
import { CovalentPagingModule } from '@covalent/core/paging';
...

* fix(): linting issue

* fix(): breaking test because of import location

* feat(): Angular package format build for /messages with /common ng-packangr hack work around

* feat(): mod build path to be deploy/platform instead of dist/

* feat(): fix linting issue

* fix(): remove message export from message.module and update common public_api

* feat(): ng-packagr setup for chips

* feat(): ng-packagr setup for data-table

* fix(): forgot to export chips in platform/index

* feat(): ng-packagr setup for dialogs

* fix(): export dialogs from core public-api

* feat(): ng-packagr setup for expansion-panel

* feat(): ng-packagr setup for file

* feat(): ng-packagr setup for json-formatter

* fix(): breaking test because of filepath

* feat(): ng-packagr setup for layout

* feat(): ng-packagr setup for loading

* feat(): ng-packagr setup for media

* feat(): ng-packagr setup for menu

* feat(): ng-packagr setup for search

* ng-packagr setup for steps

* feat(): clean up post ng-packagr conversion for /core

* feat(): move and build required files that ng-packagr doesn't handle

* fix(): breaking testing because of file path

* feat(): ng-packagr setup for primary entrypoint: dynamic-forms

* feat(): ng-packagr setup for primary entrypoint: highlight

* feat(): ng-packagr setup for primary entrypoint: http

* feat(): ng-packagr setup for primary entrypoint: markdown

* feat(): updated ng-packangr to 2.0.0-rc.0

* fix(): double exporting

* feat(): upgrade ng-packagr to 2.0.0-rc-6

* feat(): upgrade ng-packagr to 2.0.0-rc-7 and consolidated ng-package settings

* fix(): change ng-packagr.json to ng-packagr.js for last ng-packagr update

* feat(): upgrade ng-packagr to 2.0.0-rc-8

* feat(): upgrade ng-packagr to 2.0.0-rc-10

* refactor(): clean up + consolidate code/scripts

* refactor(): additional clean up

* fix(): linting issues

* chore(): delete unneeded tsconfig-aot.json

* chore(): set -e in build scripts to stop script if it fails

* chore(): ignore failure if .tgz pack is not there

* fix(): test run different sed command based on platform

* refactor(): remove platform echo test
  • Loading branch information
stevenov7 authored and emoralesb05 committed Jan 15, 2018
1 parent 8e18beb commit 24b29d3
Show file tree
Hide file tree
Showing 147 changed files with 2,188 additions and 1,733 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

# compiled output
/**/dist
/**/.ng_pkg_build
/**/.td_build_common
/**/.td_test_universal
/deploy
/tmp

# dependencies
/node_modules
/**/node_modules
/bower_components

# IDEs and editors
Expand Down
60 changes: 24 additions & 36 deletions build.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,30 @@ module.exports = {
'src/**/**/package.json'
],
deployed: 'deploy/platform/',
styles: [
'!src/theme.scss',
'!src/styles.scss',
'src/**/**.scss',
'!src/app/**/**.scss',
'src/**/**.css',
'!src/app/**/**.css'
PostNgPackngrBuildRequiredFiles: [
'!src/platform/core/**/*.component.scss',
'src/platform/core/**/*.scss',

'src/platform/core/**/codepoints',
'src/platform/core/**/MaterialIcons-Regular.eot',
'src/platform/core/**/MaterialIcons-Regular.ijmap',
'src/platform/core/**/MaterialIcons-Regular.ttf',
'src/platform/core/**/MaterialIcons-Regular.woff',
'src/platform/core/**/MaterialIcons-Regular.woff2',
'src/platform/core/**/*.md',
],
PostNgPackngrCompileStyles: [
'deploy/platform/core/**/material-icons.scss',
'deploy/platform/core/**/platform.scss',
'deploy/platform/core/**/theming/prebuilt/**/*.scss'
],
PostNgPackngrAdditionalFiles: [
'!src/platform/core/**/*.component.scss',
'!src/platform/core/**/*.scss',
'!src/platform/**/*.component.scss',
'src/platform/**/*.scss',
'!src/platform/core/**/*.md',
'src/platform/**/*.md',
],
requiredfiles: [
'src/**/codepoints',
'src/**/MaterialIcons-Regular.eot',
'src/**/MaterialIcons-Regular.ijmap',
'src/**/MaterialIcons-Regular.ttf',
'src/**/MaterialIcons-Regular.woff',
'src/**/MaterialIcons-Regular.woff2',
'!src/theme.scss',
'!src/styles.scss',
'src/**/**.scss',
'!src/app/**/**.scss',
'src/**/**.html',
'src/**/**.md',
'src/**/**.js',
'src/**/**.ts',
'!src/**/**.spec.ts',
'src/**/**/package.json',
'src/**/tsconfig-aot.json',
'!src/tests/**/**.ts',
'!src/app/**/**.html',
'!src/app/**/**.js',
'!src/app/**/**.ts',
'!src/environments/**/**.ts',
'!src/polyfills.ts',
'!src/main.ts',
'!src/test.ts',
'src/typings.d.ts',
'!src/index.html'
]
}
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
"bump-patch": "gulp bump-version --ver patch",
"bump-minor": "gulp bump-version --ver minor",
"bump-major": "gulp bump-version --ver major",
"aot": "./node_modules/.bin/ngc -p deploy/platform/tsconfig-aot.json && tsc -p src/platform/tsconfig-aot.json",
"serve": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng serve",
"serve:prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng serve --aot --prod --sourcemap=false --build-optimizer",
"build:docs": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --aot --prod --sourcemap=false --build-optimizer",
"build:release": "bash scripts/build-release",
"build:universal": "bash scripts/build-universal",
"publish:npm": "npm run build:release && bash scripts/npm-publish",
"publish:nightly": "npm run build:release && bash scripts/nightly-publish",
"ghpages:deploy": "npm run build:docs -- --base-href /covalent/ && bash scripts/ghpages-deploy",
"release:start": "bash scripts/start-release",
"release:finish": "bash scripts/finish-release",
"combat-training": "bash scripts/combat-training",
"bundle-report": "npm run build:docs -- --stats-json && webpack-bundle-analyzer dist/stats.json",
"generate:changelog": "./node_modules/.bin/conventional-changelog -i docs/CHANGELOG.md -s -p angular"
},
Expand Down Expand Up @@ -127,6 +126,7 @@
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "1.0.1",
"merge2": "1.0.2",
"ng-packagr": "2.0.0-rc.10",
"node-sass": "3.8.0",
"phantomjs-prebuilt": "2.1.14",
"protractor": "~5.1.0",
Expand Down
113 changes: 89 additions & 24 deletions scripts/build-release
Original file line number Diff line number Diff line change
@@ -1,33 +1,98 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

set -o errexit
###################
# START: BUILD @covalent/core primary and secondary entrypoints
###################

# Clear deploy/ so that we guarantee there are no stale artifacts.
echo "Cleaning deploy/"
# HACK START - common
# (Remove in future): used to resolve ng-packagr current lack of support for Intra-package dependencies between entry points && ability to override tsconfig:
# this hack builds common using ng-packagr to generate @covalent/core/common and puts it into the projects root 'node_modules'
# https://github.com/dherges/ng-packagr/issues/379 && https://github.com/dherges/ng-packagr/issues/256
# Reason for hack: we need these missing features because we use '/common' between multiple entry points both primary and secondary
# and ng-packagr currently doesn't support it. So for now we are going to create/build the package that contains
# @covalent/core/common just by itself, we will then copy the generated './deploy/platform' that was generated into
# our projects root './node_modules' and then in the respective modules/components under /core we will replaces '../common/*'
# with '@covalent/core/common'. Now when we run ng-packagr on the whole /core suit when it see's '@covalent/core/common' it will
# take it from our root's './node_modules' instead of trying to find its intra-package dependency '../common' like before (which is
# not there because of ng-packagr build alogrithm changing the filepath). So this hack resolve
# the issue for ng-packagr but it bring up an issue when trying to serve the app with 'npm run serve'
# we also had to add inside the roots tsconfig.json a new path for the core's secondary entrypoints '"@covalent/core/*": ["./platform/core/*"],'
# because we are not using a relative path anymore '../common'.

# clean up first if building again
rm -rf ./node_modules/@covalent/core
rm -rf ./src/platform/node_modules
rm -rf ./deploy
rm -rf ./src/platform/.td_build_common

echo 'Creating @covalent/core/common secondary entrypoint hack'
cd ./src/platform
mkdir .td_build_common
# move files to build only '@covalent/core/common' into its own build station to not cause other secondary entry points to build
cp -r ./core/common .td_build_common/
cp ./core/ng-package.js .td_build_common/
cp ./core/index.ts .td_build_common/
cd .td_build_common

# create necessary files for building @covalent/core/common
echo '{ "name": "@covalent/core" }' > package.json
echo "export * from './common';" > public-api.ts
echo "export * from './public-api';" > index.ts

# regex replace as needed for specific build of @covalent/core/common
if [ "$(uname)" == "Darwin" ]; then
# Do under Mac OS X platform
sed -i '' 's/..\/..\/..\/deploy\/platform/.\/deploy\/platform/' ng-package.js
else
sed -i 's/..\/..\/..\/deploy\/platform/.\/deploy\/platform/' ng-package.js
fi

../../../node_modules/.bin/ng-packagr -p ng-package.js

# move completed build over to root node_modules as @covalent/core/*
cp -r ./deploy/platform/core ../../../node_modules/@covalent/

# kill build station don't need it anymore
rm -rf ../.td_build_common
cd ../../..
echo 'Completed @covalent/core/common secondary entrypoint hack'
# HACK END - common

# Steps to package '@covalent/core' and it's children '@covalent/core/*'
echo 'Creating @covalent/core @covalent/core/* build'
./node_modules/.bin/ng-packagr -p src/platform/core/ng-package.js
# move over additional required files manually that ng-packagr doesn't do automatically
echo 'Compiling and moving moving some requried files not handled by ng-packagr files'
gulp move-required-core-files
gulp compile-core-sass
echo 'Completed compiling and moving moving some requried files not handled by ng-packagr files'

# Perform a build.
gulp build
echo "SASS compiled..."
# HACK (Remove in future): remove remnants of @covalent/core/common see script/ng-packagr-common for details
rm -rf ./node_modules/@covalent/core
echo 'Completed @covalent/core @covalent/core/* build'

# Prepare for aot
gulp prepare-aot
echo "Preparing files for AoT build"
###################
# END: BUILD @covalent/core primary and secondary entrypoints
###################

# AoT compilation
npm run aot
echo "Compiled TS and generated *.metadata.json files..."

# Clean source .ts files
cd deploy/
find . -name "*.ts" ! -name "*.d.ts" -type f -delete
cd ..
echo "Remove source .ts files so they arent published"
# HACK (Remove in future): used to resolve ng-packagr current lack of support for Intra-package dependencies between entry points && ability to override tsconfig:
# HACK START
mkdir -p src/platform/node_modules/@covalent
cp -r deploy/platform/core src/platform/node_modules/@covalent
# HACK END

# Inline the css and html into the component files.
gulp inline-resource-files
echo "Resources inlined..."
# BUILD: @covalent/dynamic-forms primary entrypoint
./node_modules/.bin/ng-packagr -p src/platform/dynamic-forms/ng-package.js
# BUILD: @covalent/highlight primary entrypoint
./node_modules/.bin/ng-packagr -p src/platform/highlight/ng-package.js
# BUILD: @covalent/http primary entrypoint
./node_modules/.bin/ng-packagr -p src/platform/http/ng-package.js
# BUILD: @covalent/markdown primary entrypoint
./node_modules/.bin/ng-packagr -p src/platform/markdown/ng-package.js

# Bundle
gulp rollup-code
echo "Bundled..."
# HACK (Remove in future): remove remnants of platform/node_modules was used for building purposes
rm -rf src/platform/node_modules
# Need to move required file after ng-packagr runs because ng-packagr overrides primary entrypoint folders
gulp move-additional-platform-files
24 changes: 24 additions & 0 deletions scripts/build-universal
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e

# build and test ssr in universal app
npm run build:release
rm -rf .td_test_universal
rm -f deploy/platform/core/covalent-core-*.tgz

cd deploy/platform/core
npm pack
cd ../../..

cp -r src/universal-app .td_test_universal
cd .td_test_universal
npm install
npm install ../deploy/platform/core/covalent-core-*.tgz
../node_modules/.bin/ngc -p tsconfig-battle-zone.json
../node_modules/.bin/tsc -p tsconfig-battle-royale.json

node battle-royale.js

cd ..
rm -rf .td_test_universal
rm deploy/platform/core/covalent-core-*.tgz
8 changes: 0 additions & 8 deletions scripts/build.js

This file was deleted.

10 changes: 0 additions & 10 deletions scripts/clean.js

This file was deleted.

31 changes: 0 additions & 31 deletions scripts/combat-training

This file was deleted.

27 changes: 0 additions & 27 deletions scripts/compile-sass.js

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/inline-resource-files.js

This file was deleted.

Loading

0 comments on commit 24b29d3

Please sign in to comment.