Skip to content

Commit

Permalink
wip! ng-packagr architect
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 committed Feb 13, 2020
1 parent 1569f4b commit 5d70941
Show file tree
Hide file tree
Showing 25 changed files with 1,105 additions and 35 deletions.
20 changes: 16 additions & 4 deletions examples/angular_bazel_architect/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
load("@npm//@angular-devkit/architect-cli:index.bzl", "architect", "architect_test")

exports_files([
"tsconfig.json",
"angular.json",
])

architect(
name = "build",
args = [
Expand All @@ -9,8 +14,7 @@ architect(
configuration_env_vars = ["NG_BUILD_CACHE"],
data = glob(
[
"src/*",
"src/**",
"src/**/*"
],
exclude = [
"src/**/*.spec.ts",
Expand All @@ -22,12 +26,16 @@ architect(
"tsconfig.app.json",
"tsconfig.json",
"@npm//mime",
"@npm//zone.js",
"@npm//tslib",
"@npm//typescript",
"@npm//@angular/cli",
"@npm//@angular/core",
"@npm//@angular/router",
"@npm//@angular/platform-browser-dynamic",
"@npm//@angular-devkit/architect-cli",
"@npm//@angular-devkit/build-angular",
"//projects/frontend-lib:build"
],
output_dir = True,
)
Expand All @@ -37,8 +45,7 @@ architect_test(
args = ["frontend:test"],
configuration_env_vars = ["NG_BUILD_CACHE"],
data = glob([
"src/*",
"src/**",
"src/**/*"
]) + [
"angular.json",
"karma.conf.js",
Expand All @@ -51,11 +58,13 @@ architect_test(
"@npm//@angular/router",
"@npm//@angular/platform-browser-dynamic",
"@npm//@angular-devkit/build-angular",
"@npm//zone.js",
"@npm//karma",
"@npm//karma-chrome-launcher",
"@npm//karma-coverage-istanbul-reporter",
"@npm//karma-jasmine",
"@npm//karma-jasmine-html-reporter",
"//projects/frontend-lib:build"
],
tags = [
"browser:chromium-local",
Expand Down Expand Up @@ -96,9 +105,12 @@ architect_test(
"@npm//protractor",
"@npm//jasmine-spec-reporter",
"@npm//ts-node",
"@npm//tslib",
"@npm//typescript",
"@npm//@types/jasmine",
"@npm//@types/jasminewd2",
"@npm//@types/node",
"//projects/frontend-lib:build"
],
tags = [
"browser:chromium-local",
Expand Down
44 changes: 43 additions & 1 deletion examples/angular_bazel_architect/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,48 @@
}
}
}
}},
},
"frontend-lib": {
"projectType": "library",
"root": "projects/frontend-lib",
"sourceRoot": "projects/frontend-lib/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/frontend-lib/tsconfig.lib.json",
"project": "projects/frontend-lib/ng-package.js"
},
"configurations": {
"production": {
"tsConfig": "projects/frontend-lib/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"preserveSymlinks": true,
"main": "projects/frontend-lib/src/test.ts",
"tsConfig": "projects/frontend-lib/tsconfig.spec.json",
"karmaConfig": "projects/frontend-lib/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/frontend-lib/tsconfig.lib.json",
"projects/frontend-lib/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend"
}
6 changes: 4 additions & 2 deletions examples/angular_bazel_architect/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module.exports = function(config) {
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'), require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
Expand Down
6 changes: 4 additions & 2 deletions examples/angular_bazel_architect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "bazel build :build",
"test": "bazel test :test",
"build": "bazelisk build :build",
"test": "bazelisk test :test",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "patch-package && ngcc --properties es2015 browser module main --first-only"
Expand All @@ -29,6 +29,7 @@
},
"devDependencies": {
"@angular-devkit/build-angular": "0.900.1",
"@angular-devkit/build-ng-packagr": "0.900.1",
"@angular/cli": "9.0.1",
"@angular/compiler-cli": "9.0.0",
"@angular/language-service": "9.0.0",
Expand All @@ -47,6 +48,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"ng-packagr": "^9.0.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
Expand Down
77 changes: 77 additions & 0 deletions examples/angular_bazel_architect/projects/frontend-lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
load("@npm//@angular-devkit/architect-cli:index.bzl", "architect", "architect_test")

package(default_visibility = ["//visibility:public"])

architect(
name = "build",
args = [
"frontend-lib:build",
"--",
"$(@D)"
],
data = glob(
[
"src/**/*"
],
exclude = [
"src/**/*.spec.ts",
"src/test.ts",
],
) + [
"ng-package.js",
"package.json",
"tsconfig.lib.json",
"tsconfig.lib.prod.json",
"@angular_bazel_architect//:angular.json",
"@angular_bazel_architect//:tsconfig.json",
"@npm//@angular/cli",
"@npm//@angular/core",
"@npm//zone.js",
"@npm//tslib",
"@npm//typescript",
"@npm//@angular-devkit/architect-cli",
"@npm//@angular-devkit/build-ng-packagr",
],
output_dir = True,
)

architect_test(
name = "test",
args = ["frontend-lib:test"],
data = glob([
"src/**/*"
]) + [
"karma.conf.js",
"tsconfig.spec.json",
"@angular_bazel_architect//:angular.json",
"@angular_bazel_architect//:tsconfig.json",
"@npm//@types/jasmine",
"@npm//@types/node",
"@npm//@angular/cli",
"@npm//@angular/core",
"@npm//@angular/platform-browser-dynamic",
"@npm//@angular-devkit/build-angular",
"@npm//tslib",
"@npm//typescript",
"@npm//zone.js",
"@npm//karma",
"@npm//karma-chrome-launcher",
"@npm//karma-coverage-istanbul-reporter",
"@npm//karma-jasmine",
"@npm//karma-jasmine-html-reporter",
],
tags = [
"browser:chromium-local",
# This fails locally on macos buildkite trying to capture Chrome.
# Tested locally on OSX and it works so it is something to do with the
# buildkite osx machine chrome version/configuration.
# ==================== Test output for //:test:
# 29 01 2020 23:31:42.804:INFO [karma-server]: Karma v4.1.0 server started at http://0.0.0.0:9876/
# 29 01 2020 23:31:42.806:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
# 29 01 2020 23:31:42.808:INFO [launcher]: Starting browser ChromeHeadless
# 29 01 2020 23:32:42.815:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
# 29 01 2020 23:32:44.818:WARN [launcher]: ChromeHeadless was not killed in 2000 ms, sending SIGKILL.
# 29 01 2020 23:32:46.822:WARN [launcher]: ChromeHeadless was not killed by SIGKILL in 2000 ms, continuing.
"no-bazelci-mac",
],
)
24 changes: 24 additions & 0 deletions examples/angular_bazel_architect/projects/frontend-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# FrontendLib

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.0.

## Code scaffolding

Run `ng generate component component-name --project frontend-lib` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project frontend-lib`.
> Note: Don't forget to add `--project frontend-lib` or else it will be added to the default project in your `angular.json` file.
## Build

Run `ng build frontend-lib` to build the project. The build artifacts will be stored in the `dist/` directory.

## Publishing

After building your library with `ng build frontend-lib`, go to the dist folder `cd dist/frontend-lib` and run `npm publish`.

## Running unit tests

Run `ng test frontend-lib` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage/frontend-lib'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']
}
},
browsers: ['ChromeHeadlessNoSandbox'],
singleRun: false,
restartOnFileChange: true
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

const { resolve } = require('path');

module.exports = {
dest: resolve(process.argv.pop()),
lib: {
entryFile: 'src/public-api.ts'
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "frontend-lib",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^9.0.0",
"@angular/core": "^9.0.0",
"tslib": "^1.10.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { FrontendLibComponent } from './frontend-lib.component';

describe('FrontendLibComponent', () => {
let component: FrontendLibComponent;
let fixture: ComponentFixture<FrontendLibComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FrontendLibComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(FrontendLibComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'lib-frontend-lib',
template: `
<p>
frontend-lib works!
</p>
`,
styles: []
})
export class FrontendLibComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { FrontendLibComponent } from './frontend-lib.component';



@NgModule({
declarations: [FrontendLibComponent],
imports: [
],
exports: [FrontendLibComponent]
})
export class FrontendLibModule { }
Loading

0 comments on commit 5d70941

Please sign in to comment.