From 8dcd1d71b96a6608f4d9be8f4a6a6a7ff114b477 Mon Sep 17 00:00:00 2001 From: Nato Boram Date: Mon, 2 Dec 2019 22:36:43 -0500 Subject: [PATCH 1/6] public artifacts --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8a89b85..27dc4dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ pages: - cp public/index.html public/404.html artifacts: paths: - - dist/public + - public only: - master - pages From cdb6d56c57f71a2fefa482c1a1f5212324cfd87c Mon Sep 17 00:00:00 2001 From: Nato Boram Date: Mon, 2 Dec 2019 22:59:54 -0500 Subject: [PATCH 2/6] moar chunks --- angular.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/angular.json b/angular.json index 4247459..9ebd3ad 100644 --- a/angular.json +++ b/angular.json @@ -47,12 +47,12 @@ ], "optimization": true, "outputHashing": "all", - "sourceMap": false, + "sourceMap": true, "extractCss": true, - "namedChunks": false, + "namedChunks": true, "aot": true, "extractLicenses": true, - "vendorChunk": false, + "vendorChunk": true, "buildOptimizer": true, "budgets": [ { From 55d2730a7ac0d844da70ca0a5546a13def65a42e Mon Sep 17 00:00:00 2001 From: Nato Boram Date: Mon, 2 Dec 2019 23:16:43 -0500 Subject: [PATCH 3/6] click on button --- src/app/pages/pages.component.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/pages/pages.component.html b/src/app/pages/pages.component.html index 7057c1a..4e7fb63 100644 --- a/src/app/pages/pages.component.html +++ b/src/app/pages/pages.component.html @@ -3,7 +3,7 @@

Public IPFS Cacher

-
+ @@ -12,12 +12,12 @@ - +
-
+ @@ -26,7 +26,7 @@ - +
From 890fc2aafa0c411cffec3567dafdcaef6def3731 Mon Sep 17 00:00:00 2001 From: Nato Boram Date: Tue, 3 Dec 2019 00:06:54 -0500 Subject: [PATCH 4/6] more environments --- angular.json | 58 ++++++++++++++++++++++++++ package.json | 7 ++-- src/app/app-routing.module.ts | 3 +- src/app/interfaces/environment.ts | 5 +++ src/environments/environment.gitlab.ts | 7 ++++ src/environments/environment.ipfs.ts | 6 +++ src/environments/environment.prod.ts | 8 +++- src/environments/environment.ts | 8 +++- 8 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 src/app/interfaces/environment.ts create mode 100644 src/environments/environment.gitlab.ts create mode 100644 src/environments/environment.ipfs.ts diff --git a/angular.json b/angular.json index 9ebd3ad..b535add 100644 --- a/angular.json +++ b/angular.json @@ -66,6 +66,64 @@ "maximumError": "10kb" } ] + }, + "gitlab": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.gitlab.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": true, + "extractCss": true, + "namedChunks": true, + "aot": true, + "extractLicenses": true, + "vendorChunk": true, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] + }, + "ipfs": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.ipfs.ts" + } + ], + "optimization": true, + "outputHashing": "all", + "sourceMap": true, + "extractCss": true, + "namedChunks": true, + "aot": true, + "extractLicenses": true, + "vendorChunk": true, + "buildOptimizer": true, + "budgets": [ + { + "type": "initial", + "maximumWarning": "2mb", + "maximumError": "5mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "6kb", + "maximumError": "10kb" + } + ] } } }, diff --git a/package.json b/package.json index 5b17ee3..2feea65 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "scripts": { "ng": "ng", "start": "ng serve --ssl", - "build": "ng build", - "build:prod": "ng build --prod", - "build:gitlab": "ng build --prod --base-href /public-gateway-cacher/", + "build": "ng build --base-href /", + "build:prod": "ng build --configuration=production --base-href /", + "build:gitlab": "ng build --configuration=gitlab --base-href /public-gateway-cacher/", + "build:ipfs": "ng build --configuration=ipfs", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 33ec000..aaf3979 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { environment } from '../environments/environment'; const routes: Routes = [{ path: '', @@ -7,7 +8,7 @@ const routes: Routes = [{ }]; @NgModule({ - imports: [RouterModule.forRoot(routes, { useHash: true })], + imports: [RouterModule.forRoot(routes, { useHash: environment.useHash })], exports: [RouterModule] }) export class AppRoutingModule { } diff --git a/src/app/interfaces/environment.ts b/src/app/interfaces/environment.ts new file mode 100644 index 0000000..f5b42a2 --- /dev/null +++ b/src/app/interfaces/environment.ts @@ -0,0 +1,5 @@ +export interface Environment { + production: boolean; + base_href?: string; + useHash: boolean; +} diff --git a/src/environments/environment.gitlab.ts b/src/environments/environment.gitlab.ts new file mode 100644 index 0000000..d43ab83 --- /dev/null +++ b/src/environments/environment.gitlab.ts @@ -0,0 +1,7 @@ +import { Environment } from '../app/interfaces/environment'; + +export const environment: Environment = { + production: true, + base_href: '/public-gateway-cacher', + useHash: false, +}; diff --git a/src/environments/environment.ipfs.ts b/src/environments/environment.ipfs.ts new file mode 100644 index 0000000..aa5bbea --- /dev/null +++ b/src/environments/environment.ipfs.ts @@ -0,0 +1,6 @@ +import { Environment } from '../app/interfaces/environment'; + +export const environment: Environment = { + production: true, + useHash: true, +}; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3612073..237438d 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,7 @@ -export const environment = { - production: true +import { Environment } from '../app/interfaces/environment'; + +export const environment: Environment = { + production: true, + base_href: '/', + useHash: false, }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7b4f817..f216fef 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,9 +1,13 @@ +import { Environment } from '../app/interfaces/environment'; + // This file can be replaced during build by using the `fileReplacements` array. // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. -export const environment = { - production: false +export const environment: Environment = { + production: false, + base_href: '/', + useHash: false, }; /* From adc24a72ba6973fab29b557f89191a89f7085d52 Mon Sep 17 00:00:00 2001 From: Nato Boram Date: Tue, 3 Dec 2019 00:12:57 -0500 Subject: [PATCH 5/6] cache:key:files --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27dc4dc..52a891b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,10 @@ before_script: - yarn cache: + key: + files: + - package.json + - yarn.lock paths: - node_modules From 093c3fffbfc7b70ba2114e2c06579a6d852e07fa Mon Sep 17 00:00:00 2001 From: Nato Boram Date: Tue, 3 Dec 2019 00:25:46 -0500 Subject: [PATCH 6/6] `${environment.base_href}/assets/json/gateways.json` --- src/app/services/gateway.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/services/gateway.service.ts b/src/app/services/gateway.service.ts index 0bff4fe..6437cb7 100644 --- a/src/app/services/gateway.service.ts +++ b/src/app/services/gateway.service.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; +import { environment } from '../../environments/environment'; @Injectable({ providedIn: 'root' @@ -12,7 +13,11 @@ export class GatewayService { ) { } list(): Observable { - return this.http.get('/assets/json/gateways.json'); + return this.http.get( + environment.base_href && environment.base_href !== '/' + ? `${environment.base_href}/assets/json/gateways.json` + : '/assets/json/gateways.json' + ); } get(gateway: string, type: string, hash: string): Observable {