Skip to content

Commit

Permalink
setup Scully to add platform-server renderer. Update to RX7 (scullyio…
Browse files Browse the repository at this point in the history
…#1446)

* chore(monorepo): update to rx7 and fix merge conflicts
  • Loading branch information
SanderElias authored Oct 14, 2021
1 parent 47bbe32 commit 84e886f
Show file tree
Hide file tree
Showing 128 changed files with 5,958 additions and 1,108 deletions.
7 changes: 2 additions & 5 deletions apps/sample-blog/src/app/about/about.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ScullyRoutesService } from '@scullyio/ng-lib';
import { take } from 'rxjs/operators';
import { firstValueFrom } from 'rxjs';

@Component({
selector: 'app-about',
Expand All @@ -11,10 +11,7 @@ export class AboutComponent implements OnInit {
constructor(private srs: ScullyRoutesService) {}

async ngOnInit() {
const cur = await this.srs
.getCurrent()
.pipe(take(1))
.toPromise();
const cur = await firstValueFrom(this.srs.getCurrent())
console.log(cur);
}
}
6 changes: 4 additions & 2 deletions apps/sample-blog/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { AppComponent } from './app.component';
BrowserModule,
HttpClientModule,
AppRoutingModule,
ScullyLibModule.forRoot({ useTransferState: true, alwaysMonitor: true })
ScullyLibModule
.forRoot({ useTransferState: true, alwaysMonitor: true })
],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule { }

14 changes: 14 additions & 0 deletions apps/sample-blog/src/app/app.universal.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppComponent } from './app.component';
import { AppModule } from './app.module';


@NgModule({
imports: [
AppModule,
ServerModule,
],
bootstrap: [AppComponent],
})
export class AppUniversalModule {}
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/blog/blog-holder.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { ScullyRoute, ScullyRoutesService, TransferStateService } from '@scullyio/ng-lib';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';

@Component({
selector: 'app-blog-holder',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ScullyRoute, ScullyRoutesService } from '@scullyio/ng-lib';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';

@Component({
selector: 'app-blog-list',
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/demo/demo.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router';
import { pluck, tap } from 'rxjs/operators';
import { pluck, tap } from 'rxjs';

@Component({
selector: 'app-demo',
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/noscript/noscript.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Component, NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ScullyLibModule, TransferStateService } from '@scullyio/ng-lib';
import { map } from 'rxjs/operators';
import { map } from 'rxjs';
import { User } from '../user/user.component';

@Component({
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/slow/slow.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Component } from '@angular/core';
import { isScullyGenerated } from '@scullyio/ng-lib';
import { first } from 'rxjs/operators';
import { first } from 'rxjs';

@Component({
selector: 'app-slow',
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/static/static.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { ScullyRoutesService } from '@scullyio/ng-lib';
import { map, tap } from 'rxjs/operators';
import { map, tap } from 'rxjs';

@Component({
selector: 'app-static',
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/user/post/post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
tap,
filter,
map,
} from 'rxjs/operators';
} from 'rxjs';
import { Post } from '../posts/posts.component';
import { isScullyGenerated, TransferStateService } from '@scullyio/ng-lib';
import { ActivatedRoute } from '@angular/router';
Expand Down
8 changes: 4 additions & 4 deletions apps/sample-blog/src/app/user/posts/posts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
shareReplay,
switchMap,
tap,
} from 'rxjs/operators';
} from 'rxjs';

export interface Post {
userId: number;
Expand All @@ -37,18 +37,18 @@ export class PostsComponent implements OnInit {
switchMap((id) =>
this.http.get<Post[]>(`/api/posts?userId=${id}`).pipe(
catchError(() =>
of({
of([{
id,
title: 'not found',
} as Post)
}] as Post[])
)
)
),
shareReplay(1)
);

// This is an example of using TransferState
posts$ = isScullyGenerated()
posts$:Observable<Post[]> = isScullyGenerated()
? this.transferState.getState('posts')
: this.apiPosts$.pipe(
tap((posts) => this.transferState.setState('posts', posts))
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
map,
shareReplay,
tap,
} from 'rxjs/operators';
} from 'rxjs';

@Component({
selector: 'app-user',
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/user/users/users.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1>Users</h1>
<tr *ngFor="let user of users">
<td>{{ user.id }}</td>
<td>
<a [routerLink]="user.id" [queryParams]="{ id: user.id }">
<a [routerLink]="''+user.id" [queryParams]="{ id: user.id }">
{{ user.name }}</a
>
</td>
Expand Down
2 changes: 1 addition & 1 deletion apps/sample-blog/src/app/user/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { isScullyGenerated, TransferStateService } from '@scullyio/ng-lib';
import { of } from 'rxjs';
import { catchError, map, shareReplay, tap } from 'rxjs/operators';
import { catchError, map, shareReplay, tap } from 'rxjs';
import { User } from '../user.component';

@Component({
Expand Down
10 changes: 10 additions & 0 deletions apps/sample-blog/src/main.universal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';


if (environment.production) {
enableProdMode();
}
export { renderModule, renderModuleFactory } from '@angular/platform-server';
export { AppUniversalModule } from './app/app.universal.module';

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { NavListService } from '../../../nav-list/nav-list.service';
import { ScullyRoutesService } from '@scullyio/ng-lib';
import { pluck, take } from 'rxjs/operators';
import { pluck, take } from 'rxjs';

const langs = {
es: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DoCheck, Injectable } from '@angular/core';
import { ScullyRoute, ScullyRoutesService } from '@scullyio/ng-lib';
import { combineLatest, EMPTY, forkJoin, Observable, throwError } from 'rxjs';
import { catchError, map, take, tap } from 'rxjs/operators';
import { catchError, map, take, tap } from 'rxjs';

export interface DocTree {
_route: ScullyRoute;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, ViewEncapsulation } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { EMPTY } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { catchError, map, tap } from 'rxjs';
import { NavListService } from '../../../components/nav-list/nav-list.service';

@Component({
Expand Down
20 changes: 20 additions & 0 deletions apps/universal-sample-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": "apps/universal-sample-e2e/tsconfig.*?.json"
},
"rules": {}
},
{
"files": ["src/plugins/index.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
}
}
]
}
12 changes: 12 additions & 0 deletions apps/universal-sample-e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts",
"video": true,
"videosFolder": "../../dist/cypress/apps/universal-sample-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/universal-sample-e2e/screenshots",
"chromeWebSecurity": false
}
4 changes: 4 additions & 0 deletions apps/universal-sample-e2e/src/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]"
}
13 changes: 13 additions & 0 deletions apps/universal-sample-e2e/src/integration/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getGreeting } from '../support/app.po';

describe('universal-sample', () => {
beforeEach(() => cy.visit('/'));

it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('[email protected]', 'myPassword');

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome to universal-sample!');
});
});
22 changes: 22 additions & 0 deletions apps/universal-sample-e2e/src/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

// Preprocess Typescript file using Nx helper
on('file:preprocessor', preprocessTypescript(config));
};
1 change: 1 addition & 0 deletions apps/universal-sample-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
33 changes: 33 additions & 0 deletions apps/universal-sample-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
17 changes: 17 additions & 0 deletions apps/universal-sample-e2e/src/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';
18 changes: 18 additions & 0 deletions apps/universal-sample-e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"],
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.js"],
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictTemplates": true
}
}
10 changes: 10 additions & 0 deletions apps/universal-sample-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.e2e.json"
}
]
}
17 changes: 17 additions & 0 deletions apps/universal-sample/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
# npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
Loading

0 comments on commit 84e886f

Please sign in to comment.