Merge pull request #17 from HideyoshiNakazone/devel

Devel - Adds ServiceWorker Service
This commit is contained in:
2023-08-28 03:52:52 -03:00
committed by GitHub
11 changed files with 15944 additions and 24729 deletions

View File

@@ -1,16 +0,0 @@
# 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

View File

@@ -19,7 +19,10 @@
"plugin:@angular-eslint/template/process-inline-templates" "plugin:@angular-eslint/template/process-inline-templates"
], ],
"rules": { "rules": {
"indent": ["error", 4], "indent": [
"error",
4
],
"@angular-eslint/directive-selector": [ "@angular-eslint/directive-selector": [
"error", "error",
{ {

View File

@@ -4,8 +4,8 @@ WORKDIR /app
COPY . . COPY . .
RUN npm install RUN npm install
RUN npm install -g @angular/cli@14.0.6 RUN npm install -g @angular/cli@16
EXPOSE 5000-7000 EXPOSE 5000-7000
CMD ng build --configuration=production && npm start CMD ng build --configuration=production && npm start

View File

@@ -1,137 +1,145 @@
{ {
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1, "version": 1,
"newProjectRoot": "projects", "newProjectRoot": "projects",
"projects": { "projects": {
"frontend-hideyoshi.com": { "frontend-hideyoshi.com": {
"projectType": "application", "projectType": "application",
"schematics": {}, "schematics": {},
"root": "", "root": "",
"sourceRoot": "src", "sourceRoot": "src",
"prefix": "app", "prefix": "app",
"architect": { "architect": {
"build": { "build": {
"builder": "@angular-builders/custom-webpack:browser", "builder": "@angular-builders/custom-webpack:browser",
"options": { "options": {
"customWebpackConfig": { "customWebpackConfig": {
"path": "src/webpack.config.ts" "path": "src/webpack.config.ts"
}, },
"outputPath": "dist/frontend-hideyoshi.com", "outputPath": "dist/frontend-hideyoshi.com",
"index": "src/index.html", "index": "src/index.html",
"main": "src/main.ts", "main": "src/main.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json", "tsConfig": "tsconfig.app.json",
"allowedCommonJsDependencies": [ "allowedCommonJsDependencies": [
"ts-interface-checker" "ts-interface-checker"
], ],
"assets": [ "assets": [
"src/assets", "src/assets",
"src/manifest.webmanifest", "src/manifest.webmanifest",
"src/manifest.webmanifest" "src/manifest.webmanifest"
], ],
"styles": [ "styles": [
"src/styles.css", "src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css", "node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/normalize.css/normalize.css" "node_modules/normalize.css/normalize.css"
], ],
"scripts": [ "scripts": [
"node_modules/jquery/dist/jquery.min.js", "node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
], ],
"serviceWorker": true, "serviceWorker": true,
"ngswConfigPath": "ngsw-config.json" "ngswConfigPath": "ngsw-config.json"
}, },
"configurations": { "configurations": {
"production": { "production": {
"budgets": [ "budgets": [
{ {
"type": "initial", "type": "initial",
"maximumWarning": "500kb", "maximumWarning": "500kb",
"maximumError": "1mb" "maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all",
"serviceWorker": true
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
}, },
"serve": { {
"builder": "@angular-builders/custom-webpack:dev-server", "type": "anyComponentStyle",
"options": { "maximumWarning": "2kb",
"browserTarget": "frontend-hideyoshi.com:build:build" "maximumError": "4kb"
},
"configurations": {
"production": {
"browserTarget": "frontend-hideyoshi.com:build:production",
"proxyConfig": "src/proxy.conf.json"
},
"development": {
"browserTarget": "frontend-hideyoshi.com:build:development",
"proxyConfig": "src/proxy.conf.json"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend-hideyoshi.com:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/assets",
"src/manifest.webmanifest",
"src/manifest.webmanifest"
],
"styles": [
"src/styles.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
} }
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all",
"serviceWorker": true
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
} }
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "frontend-hideyoshi.com:build:build"
},
"configurations": {
"production": {
"browserTarget": "frontend-hideyoshi.com:build:production",
"proxyConfig": "src/proxy.conf.json"
},
"development": {
"browserTarget": "frontend-hideyoshi.com:build:development",
"proxyConfig": "src/proxy.conf.json"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend-hideyoshi.com:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/assets",
"src/manifest.webmanifest",
"src/manifest.webmanifest"
],
"styles": [
"src/styles.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"src/**/*.ts",
"src/**/*.html"
]
}
} }
}, }
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
],
"analytics": false
} }
} },
"cli": {
"schematicCollections": [
"@angular-eslint/schematics"
],
"analytics": false
},
"schematics": {
"@angular-eslint/schematics:application": {
"setParserOptionsProject": true
},
"@angular-eslint/schematics:library": {
"setParserOptionsProject": true
}
}
}

40185
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,65 +1,68 @@
{ {
"name": "frontend-hideyoshi.com", "name": "frontend-hideyoshi.com",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"start": "node ./server.js", "start": "node ./server.js",
"serve": "ng serve" "build": "ng build",
}, "serve": "ng serve",
"proxy": { "serve:prod": "ng serve --configuration=production",
"/callback": { "build:prod": "ng build --configuration=production"
"target": "http://localhost:8070" },
} "proxy": {
}, "/callback": {
"private": true, "target": "http://localhost:8070"
"dependencies": {
"@angular/animations": "^14.0.3",
"@angular/cdk": "^14.2.6",
"@angular/common": "^14.2.9",
"@angular/compiler": "^14.0.0",
"@angular/core": "^14.2.9",
"@angular/forms": "^14.0.0",
"@angular/material": "^14.2.6",
"@angular/platform-browser": "^14.0.0",
"@angular/platform-browser-dynamic": "^14.0.0",
"@angular/router": "^14.0.0",
"@angular/service-worker": "^14.0.0",
"@fortawesome/angular-fontawesome": "^0.11.1",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"bootstrap": "^4.6.2",
"cors": "^2.8.5",
"express": "^4.18.1",
"jquery": "^3.6.0",
"normalize.css": "^8.0.1",
"rxjs": "~7.5.0",
"ts-interface-checker": "^1.0.2",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^14.1.0",
"@angular-devkit/build-angular": "^14.0.3",
"@angular-eslint/builder": "^14.4.0",
"@angular-eslint/eslint-plugin": "14.0.0",
"@angular-eslint/eslint-plugin-template": "14.0.0",
"@angular-eslint/schematics": "14.0.0",
"@angular-eslint/template-parser": "14.0.0",
"@angular/cli": "^14.2.12",
"@angular/compiler-cli": "^14.0.0",
"@types/jasmine": "~4.0.0",
"@types/node": "^18.11.19",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"eslint": "^8.18.0",
"jasmine-core": "~4.1.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"ts-interface-builder": "^0.3.3",
"typescript": "~4.7.2"
} }
},
"private": true,
"dependencies": {
"@angular/animations": "^16.2.2",
"@angular/cdk": "^16.2.1",
"@angular/common": "^16.2.2",
"@angular/compiler": "^16.2.2",
"@angular/core": "^16.2.2",
"@angular/forms": "^16.2.2",
"@angular/material": "^16.2.1",
"@angular/platform-browser": "^16.2.2",
"@angular/platform-browser-dynamic": "^16.2.2",
"@angular/router": "^16.2.2",
"@angular/service-worker": "^16.2.2",
"@fortawesome/angular-fontawesome": "^0.13.0",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"bootstrap": "^4.6.2",
"cors": "^2.8.5",
"express": "^4.18.1",
"jquery": "^3.6.0",
"normalize.css": "^8.0.1",
"rxjs": "~7.5.0",
"ts-interface-checker": "^1.0.2",
"tslib": "^2.3.0",
"zone.js": "~0.13.1"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^16.0.1",
"@angular-devkit/build-angular": "^16.2.0",
"@angular-eslint/builder": "^16.1.1",
"@angular-eslint/eslint-plugin": "16.1.1",
"@angular-eslint/eslint-plugin-template": "16.1.1",
"@angular-eslint/schematics": "16.1.1",
"@angular-eslint/template-parser": "16.1.1",
"@angular/cli": "^16.2.0",
"@angular/compiler-cli": "^16.2.2",
"@types/jasmine": "~4.0.0",
"@types/node": "^18.11.19",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"eslint": "^8.39.0",
"jasmine-core": "~4.1.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"ts-interface-builder": "^0.3.3",
"typescript": "~4.9.5"
}
} }

View File

@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { AuthService } from './shared/auth/auth.service'; import { AuthService } from './shared/auth/auth.service';
import {UpdateService} from "./shared/service-worker/update.service";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@@ -7,10 +8,12 @@ import { AuthService } from './shared/auth/auth.service';
styleUrls: ['./app.component.css'] styleUrls: ['./app.component.css']
}) })
export class AppComponent implements OnInit { export class AppComponent implements OnInit {
title = 'frontend-hideyoshi.com'; title = 'frontend-hideyoshi.com';
constructor(private authService: AuthService) {} constructor(private authService: AuthService, private serviceWorker: UpdateService) {
this.serviceWorker.checkForUpdates();
}
ngOnInit(): void { ngOnInit(): void {
this.authService.autoLogin(); this.authService.autoLogin();

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { UpdateService } from './update.service';
describe('UpdateService', () => {
let service: UpdateService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(UpdateService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,26 @@
import { Injectable } from '@angular/core';
import {SwUpdate} from "@angular/service-worker";
import {interval} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class UpdateService {
constructor(private swUpdate: SwUpdate) {
if (swUpdate.isEnabled) {
interval(6 * 60 * 60).subscribe(() => swUpdate.checkForUpdate()
.then(() => console.log('checking for updates')));
}
}
public checkForUpdates(): void {
this.swUpdate.available.subscribe(event => this.promptUser());
}
private promptUser(): void {
console.log('updating to new version');
this.swUpdate.activateUpdate().then(() => document.location.reload());
}
}

View File

@@ -7,20 +7,8 @@ import {
platformBrowserDynamicTesting platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing'; } from '@angular/platform-browser-dynamic/testing';
declare const require: {
context(path: string, deep?: boolean, filter?: RegExp): {
<T>(id: string): T;
keys(): string[];
};
};
// First, initialize the Angular testing environment. // First, initialize the Angular testing environment.
getTestBed().initTestEnvironment( getTestBed().initTestEnvironment(
BrowserDynamicTestingModule, BrowserDynamicTestingModule,
platformBrowserDynamicTesting(), platformBrowserDynamicTesting(),
); );
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().forEach(context);

View File

@@ -16,12 +16,13 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"moduleResolution": "node", "moduleResolution": "node",
"importHelpers": true, "importHelpers": true,
"target": "es2020", "target": "ES2022",
"module": "es2020", "module": "es2020",
"lib": [ "lib": [
"es2020", "es2020",
"dom" "dom"
] ],
"useDefineForClassFields": false
}, },
"angularCompilerOptions": { "angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false, "enableI18nLegacyMessageIdFormat": false,