Skip to content

Commit 1e9421f

Browse files
committed
First pass at angular elements
1 parent d75ec14 commit 1e9421f

36 files changed

+8664
-16
lines changed

angular.json

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
"styles": [
2626
"apps/dashboard/src/styles.css"
2727
],
28-
"scripts": []
28+
"scripts": [
29+
{
30+
"input": "node_modules/document-register-element/build/document-register-element.js"
31+
}
32+
]
2933
},
3034
"configurations": {
3135
"production": {
@@ -184,6 +188,120 @@
184188
}
185189
}
186190
}
191+
},
192+
"embed": {
193+
"root": "apps/embed/",
194+
"sourceRoot": "apps/embed/src",
195+
"projectType": "application",
196+
"prefix": "workspace",
197+
"schematics": {},
198+
"architect": {
199+
"build": {
200+
"builder": "@angular-devkit/build-angular:browser",
201+
"options": {
202+
"outputPath": "dist/apps/embed",
203+
"index": "apps/embed/src/index.html",
204+
"main": "apps/embed/src/main.ts",
205+
"polyfills": "apps/embed/src/polyfills.ts",
206+
"tsConfig": "apps/embed/tsconfig.app.json",
207+
"assets": [
208+
"apps/embed/src/favicon.ico",
209+
"apps/embed/src/assets"
210+
],
211+
"styles": [
212+
"apps/embed/src/styles.css"
213+
],
214+
"scripts": []
215+
},
216+
"configurations": {
217+
"production": {
218+
"fileReplacements": [
219+
{
220+
"replace": "apps/embed/src/environments/environment.ts",
221+
"with": "apps/embed/src/environments/environment.prod.ts"
222+
}
223+
],
224+
"optimization": true,
225+
"outputHashing": "all",
226+
"sourceMap": false,
227+
"extractCss": true,
228+
"namedChunks": false,
229+
"aot": true,
230+
"extractLicenses": true,
231+
"vendorChunk": false,
232+
"buildOptimizer": true
233+
}
234+
}
235+
},
236+
"serve": {
237+
"builder": "@angular-devkit/build-angular:dev-server",
238+
"options": {
239+
"browserTarget": "embed:build"
240+
},
241+
"configurations": {
242+
"production": {
243+
"browserTarget": "embed:build:production"
244+
}
245+
}
246+
},
247+
"extract-i18n": {
248+
"builder": "@angular-devkit/build-angular:extract-i18n",
249+
"options": {
250+
"browserTarget": "embed:build"
251+
}
252+
},
253+
"test": {
254+
"builder": "@angular-devkit/build-angular:karma",
255+
"options": {
256+
"main": "apps/embed/src/test.ts",
257+
"polyfills": "apps/embed/src/polyfills.ts",
258+
"tsConfig": "apps/embed/tsconfig.spec.json",
259+
"karmaConfig": "apps/embed/karma.conf.js",
260+
"styles": [
261+
"apps/embed/src/styles.css"
262+
],
263+
"scripts": [],
264+
"assets": [
265+
"apps/embed/src/favicon.ico",
266+
"apps/embed/src/assets"
267+
]
268+
}
269+
},
270+
"lint": {
271+
"builder": "@angular-devkit/build-angular:tslint",
272+
"options": {
273+
"tsConfig": [
274+
"apps/embed/tsconfig.app.json",
275+
"apps/embed/tsconfig.spec.json"
276+
],
277+
"exclude": [
278+
"**/node_modules/**"
279+
]
280+
}
281+
}
282+
}
283+
},
284+
"embed-e2e": {
285+
"root": "apps/embed-e2e/",
286+
"projectType": "application",
287+
"architect": {
288+
"e2e": {
289+
"builder": "@angular-devkit/build-angular:protractor",
290+
"options": {
291+
"protractorConfig": "apps/embed-e2e/protractor.conf.js",
292+
"devServerTarget": "embed:serve"
293+
}
294+
},
295+
"lint": {
296+
"builder": "@angular-devkit/build-angular:tslint",
297+
"options": {
298+
"tsConfig": "apps/embed-e2e/tsconfig.e2e.json",
299+
"exclude": [
300+
"**/node_modules/**"
301+
]
302+
}
303+
}
304+
}
187305
}
188306
},
189307
"cli": {

apps/embed-e2e/protractor.conf.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Protractor configuration file, see link for more information
2+
// https://github.com/angular/protractor/blob/master/lib/config.ts
3+
4+
const { SpecReporter } = require('jasmine-spec-reporter');
5+
6+
exports.config = {
7+
allScriptsTimeout: 11000,
8+
specs: [
9+
'./src/**/*.e2e-spec.ts'
10+
],
11+
capabilities: {
12+
'browserName': 'chrome'
13+
},
14+
directConnect: true,
15+
baseUrl: 'http://localhost:4200/',
16+
framework: 'jasmine',
17+
jasmineNodeOpts: {
18+
showColors: true,
19+
defaultTimeoutInterval: 30000,
20+
print: function() {}
21+
},
22+
onPrepare() {
23+
require('ts-node').register({
24+
project: require('path').join(__dirname, './tsconfig.e2e.json')
25+
});
26+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27+
}
28+
};

apps/embed-e2e/src/app.e2e-spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { AppPage } from './app.po';
2+
3+
describe('workspace-project App', () => {
4+
let page: AppPage;
5+
6+
beforeEach(() => {
7+
page = new AppPage();
8+
});
9+
10+
it('should display welcome message', () => {
11+
page.navigateTo();
12+
expect(page.getParagraphText()).toEqual('Welcome to workspace!');
13+
});
14+
});

apps/embed-e2e/src/app.po.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { browser, by, element } from 'protractor';
2+
3+
export class AppPage {
4+
navigateTo() {
5+
return browser.get('/');
6+
}
7+
8+
getParagraphText() {
9+
return element(by.css('workspace-root h1')).getText();
10+
}
11+
}

apps/embed-e2e/tsconfig.e2e.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc/apps/embed-e2e",
5+
"module": "commonjs",
6+
"target": "es5",
7+
"types": [
8+
"jasmine",
9+
"jasminewd2",
10+
"node"
11+
]
12+
}
13+
}

apps/embed/browserslist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
5+
> 0.5%
6+
last 2 versions
7+
Firefox ESR
8+
not dead
9+
# IE 9-11

apps/embed/karma.conf.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
18+
coverageIstanbulReporter: {
19+
dir: require('path').join(__dirname, '../../coverage'),
20+
reports: ['html', 'lcovonly'],
21+
fixWebpackSourcePaths: true
22+
},
23+
reporters: ['progress', 'kjhtml'],
24+
port: 9876,
25+
colors: true,
26+
logLevel: config.LOG_INFO,
27+
autoWatch: true,
28+
browsers: ['Chrome'],
29+
singleRun: false
30+
});
31+
};

apps/embed/src/app/app.component.css

Whitespace-only changes.

apps/embed/src/app/app.component.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
<div style="text-align:center">
3+
<h1>Welcome to workspace!</h1>
4+
<img width="300" src="https://raw.githubusercontent.com/nrwl/nx/master/nx-logo.png">
5+
</div>
6+
7+
<h2>This is an Angular CLI app built with Nrwl Nx!</h2>
8+
9+
An open source toolkit for enterprise Angular applications.
10+
11+
Nx is designed to help you create and build enterprise grade Angular applications. It provides an opinionated approach to application project structure and patterns.
12+
13+
<h2>Quick Start & Documentation</h2>
14+
15+
<a href="https://nrwl.io/nx">Watch a 5-minute video on how to get started with Nx.</a>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { TestBed, async } from '@angular/core/testing';
2+
import { AppComponent } from './app.component';
3+
describe('AppComponent', () => {
4+
beforeEach(
5+
async(() => {
6+
TestBed.configureTestingModule({
7+
declarations: [AppComponent]
8+
}).compileComponents();
9+
})
10+
);
11+
it(
12+
'should create the app',
13+
async(() => {
14+
const fixture = TestBed.createComponent(AppComponent);
15+
const app = fixture.debugElement.componentInstance;
16+
expect(app).toBeTruthy();
17+
})
18+
);
19+
it(
20+
`should have as title 'workspace'`,
21+
async(() => {
22+
const fixture = TestBed.createComponent(AppComponent);
23+
const app = fixture.debugElement.componentInstance;
24+
expect(app.title).toEqual('workspace');
25+
})
26+
);
27+
it(
28+
'should render title in a h1 tag',
29+
async(() => {
30+
const fixture = TestBed.createComponent(AppComponent);
31+
fixture.detectChanges();
32+
const compiled = fixture.debugElement.nativeElement;
33+
expect(compiled.querySelector('h1').textContent).toContain(
34+
'Welcome to workspace!'
35+
);
36+
})
37+
);
38+
});

apps/embed/src/app/app.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'workspace-root',
5+
templateUrl: './app.component.html',
6+
styleUrls: ['./app.component.css']
7+
})
8+
export class AppComponent {
9+
title = 'workspace';
10+
}

apps/embed/src/app/app.module.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { BrowserModule } from '@angular/platform-browser';
2+
import { Injector, NgModule } from '@angular/core';
3+
4+
import { AppComponent } from './app.component';
5+
import { NxModule } from '@nrwl/nx';
6+
import { DashComponent } from './dash/dash.component';
7+
import { createCustomElement } from '@angular/elements';
8+
9+
@NgModule({
10+
declarations: [AppComponent, DashComponent],
11+
imports: [BrowserModule, NxModule.forRoot()],
12+
providers: [],
13+
entryComponents: [DashComponent]
14+
})
15+
export class AppModule {
16+
constructor(private injector: Injector) {}
17+
18+
ngDoBootstrap() {
19+
const el = createCustomElement(DashComponent, {injector: this.injector});
20+
customElements.define('embedded-dashboard', el);
21+
}
22+
23+
}

apps/embed/src/app/dash/dash.component.css

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>IT WORKETH!</h1>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { DashComponent } from './dash.component';
4+
5+
describe('DashComponent', () => {
6+
let component: DashComponent;
7+
let fixture: ComponentFixture<DashComponent>;
8+
9+
beforeEach(async(() => {
10+
TestBed.configureTestingModule({
11+
declarations: [ DashComponent ]
12+
})
13+
.compileComponents();
14+
}));
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(DashComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2+
3+
@Component({
4+
selector: 'workspace-dash',
5+
templateUrl: './dash.component.html',
6+
styleUrls: ['./dash.component.css'],
7+
encapsulation: ViewEncapsulation.Native
8+
})
9+
export class DashComponent implements OnInit {
10+
11+
constructor() { }
12+
13+
ngOnInit() {
14+
}
15+
16+
}

apps/embed/src/assets/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
production: true
3+
};

0 commit comments

Comments
 (0)