Compare commits

..

No commits in common. "d8e4c7689f3fafc62ba868323dbbedef7bddf5eb" and "39db41badfa82f35f6d3e6a0b915b2f2d81ec338" have entirely different histories.

52 changed files with 11666 additions and 11953 deletions

View file

@ -1,10 +1,6 @@
kind: pipeline pipeline:
type: docker build:
name: default image: fritteli/headless-nodejs:1.1.0
steps:
- name: install
image: node:20-alpine
commands: commands:
- npm install - npm install
- npm run test:ci - npm run test:ci

View file

@ -1,4 +1,4 @@
# Editor configuration, see https://editorconfig.org # Editor configuration, see http://editorconfig.org
root = true root = true
[*] [*]
@ -8,9 +8,6 @@ indent_size = 2
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md] [*.md]
max_line_length = off max_line_length = off
trim_trailing_whitespace = false trim_trailing_whitespace = false

28
.gitignore vendored
View file

@ -1,42 +1,44 @@
# See http://help.github.com/ignore-files/ for more about ignoring files. # See http://help.github.com/ignore-files/ for more about ignoring files.
# Compiled output # compiled output
/dist /dist
/tmp /tmp
/out-tsc /out-tsc
/bazel-out
# Node # dependencies
/node_modules /node_modules
npm-debug.log
yarn-error.log
# IDEs and editors # IDEs and editors
.idea/ /.idea
.project .project
.classpath .classpath
.c9/ .c9/
*.launch *.launch
.settings/ .settings/
*.sublime-workspace *.sublime-workspace
*.iml
# Visual Studio Code # IDE - VSCode
.vscode/tasks.json .vscode/*
!.vscode/settings.json !.vscode/settings.json
!.vscode/tasks.json !.vscode/tasks.json
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
.history/*
# Miscellaneous # misc
/.angular/cache /.sass-cache
.sass-cache/
/connect.lock /connect.lock
/coverage /coverage
/libpeerconnection.log /libpeerconnection.log
npm-debug.log
testem.log testem.log
/typings /typings
# System files # e2e
# /e2e/*.js
/e2e/*.map
# System Files
.DS_Store .DS_Store
Thumbs.db Thumbs.db
*~

View file

@ -1,4 +1,4 @@
# Convertorizr - Convert whatever you want! # convertorizr - Convert whatever you want!
This is a short introduction to the awesome Convertorizr hosted at https://conv.friedli.info/. This is a short introduction to the awesome Convertorizr hosted at https://conv.friedli.info/.
@ -11,11 +11,11 @@ Cheers!
# Technical stuff # Technical stuff
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.1.0. This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.1.5.
## Development server ## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding ## Code scaffolding
@ -23,7 +23,7 @@ Run `ng generate component component-name` to generate a new component. You can
## Build ## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests ## Running unit tests
@ -31,8 +31,8 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
## Running end-to-end tests ## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help ## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 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).

View file

@ -3,28 +3,25 @@
"version": 1, "version": 1,
"newProjectRoot": "projects", "newProjectRoot": "projects",
"projects": { "projects": {
"convertorizr": { "converter": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "", "root": "",
"sourceRoot": "src", "sourceRoot": "src",
"projectType": "application",
"prefix": "app", "prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": { "architect": {
"build": { "build": {
"builder": "@angular-devkit/build-angular:application", "builder": "@angular-devkit/build-angular:browser",
"options": { "options": {
"outputPath": "dist/convertorizr", "outputPath": "dist/converter",
"index": "src/index.html", "index": "src/index.html",
"browser": "src/main.ts", "main": "src/main.ts",
"polyfills": [ "polyfills": "src/polyfills.ts",
"zone.js" "tsConfig": "src/tsconfig.app.json",
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [ "assets": [
"src/favicon.ico", "src/favicon.ico",
"src/assets" "src/assets"
@ -36,66 +33,99 @@
}, },
"configurations": { "configurations": {
"production": { "production": {
"budgets": [ "fileReplacements": [
{ {
"type": "initial", "replace": "src/environments/environment.ts",
"maximumWarning": "500kb", "with": "src/environments/environment.prod.ts"
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
} }
], ],
"outputHashing": "all" "optimization": true,
}, "outputHashing": "all",
"development": { "sourceMap": false,
"optimization": false, "extractCss": true,
"extractLicenses": false, "namedChunks": false,
"sourceMap": true "aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
} }
}, }
"defaultConfiguration": "production"
}, },
"serve": { "serve": {
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "converter:build"
},
"configurations": { "configurations": {
"production": { "production": {
"buildTarget": "convertorizr:build:production" "browserTarget": "converter:build:production"
},
"development": {
"buildTarget": "convertorizr:build:development"
} }
}, }
"defaultConfiguration": "development"
}, },
"extract-i18n": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n", "builder": "@angular-devkit/build-angular:extract-i18n",
"options": { "options": {
"buildTarget": "convertorizr:build" "browserTarget": "converter:build"
} }
}, },
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-devkit/build-angular:karma",
"options": { "options": {
"polyfills": [ "main": "src/test.ts",
"zone.js", "polyfills": "src/polyfills.ts",
"zone.js/testing" "tsConfig": "src/tsconfig.spec.json",
], "karmaConfig": "src/karma.conf.js",
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [ "styles": [
"src/styles.scss" "src/styles.scss"
], ],
"scripts": [] "scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"converter-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "converter:serve"
},
"configurations": {
"production": {
"devServerTarget": "converter:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
} }
} }
} }
} }
} },
"defaultProject": "converter"
} }

31
e2e/protractor.conf.js Normal file
View file

@ -0,0 +1,31 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--no-sandbox" ]
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};

41
e2e/src/app.e2e-spec.ts Normal file
View file

@ -0,0 +1,41 @@
import {ConvertorizrPage} from './app.po';
describe('convertorizr App', () => {
let page: ConvertorizrPage;
beforeEach(() => {
page = new ConvertorizrPage();
});
it('should display a textarea that is initially empty', () => {
page.navigateTo()
.then(() => page.getInputFieldContent(0))
.then((value: string) => {
expect(value).toEqual('');
});
});
it('should convert a string to its base64 representation', () => {
page.navigateTo()
.then(() => page.setInputFieldContent(0, 'Hello, World!'))
.then(() => page.getSelectedConverterOption(0))
.then((option: string) => {
expect(option).toEqual('Select conversion ...');
})
.then(() => page.selectConverterOption(0, 'Encode Base 64'))
.then(() => page.getInputFieldContent(1))
.then((content: string) => {
expect(content).toEqual('SGVsbG8sIFdvcmxkIQ==');
});
});
it('should display an error message if the conversion fails', () => {
page.navigateTo()
.then(() => page.setInputFieldContent(0, 'Oh noes!'))
.then(() => page.selectConverterOption(0, 'Decode Base 64'))
.then(() => page.getErrorMessage(0))
.then((content: string) => {
expect(content).toEqual('Could not decode base64 string. Maybe corrupt input?');
});
});
});

53
e2e/src/app.po.ts Normal file
View file

@ -0,0 +1,53 @@
import {browser, by, element, ElementFinder} from 'protractor';
import {promise, WebElementPromise} from 'selenium-webdriver';
export class ConvertorizrPage {
navigateTo(): promise.Promise<any> {
return browser.get('/');
}
private getInputField(index: number): WebElementPromise {
return element
.all(by.css('app-root div.inputwrapper'))
.get(index)
.element(by.css('.textwrapper textarea'))
.getWebElement();
}
getInputFieldContent(index: number): promise.Promise<string> {
return this.getInputField(index).getText();
}
setInputFieldContent(index: number, content: string): promise.Promise<void> {
return this.getInputField(index).sendKeys(content);
}
private getConverterDropdown(index: number): ElementFinder {
return element
.all(by.css('app-root div.inputwrapper'))
.get(index)
.element(by.css('.selectwrapper select'));
}
getSelectedConverterOption(index: number): promise.Promise<string> {
return this.getConverterDropdown(index)
.$('option:checked')
.getWebElement()
.getText();
}
selectConverterOption(index: number, optionName: string): promise.Promise<void> {
return this.getConverterDropdown(index)
.element(by.cssContainingText('option', optionName))
.click();
}
getErrorMessage(index: number): promise.Promise<string> {
return element
.all(by.css('app-root div.inputwrapper'))
.get(index)
.element(by.css('app-error-message div.errormessage'))
.getWebElement()
.getText();
}
}

13
e2e/tsconfig.e2e.json Normal file
View file

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}

22541
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "convertorizr", "name": "convertorizr",
"version": "2.0.0-dev.1", "version": "1.3.1-1",
"description": "Decode or encode base64, punycode, HTML entities, URI components, ...", "description": "Decode or encode base64, punycode, HTML entities, URI components, ...",
"keywords": [ "keywords": [
"encode", "encode",
@ -14,7 +14,7 @@
"email": "manuel@fritteli.ch" "email": "manuel@fritteli.ch"
}, },
"license": "MIT", "license": "MIT",
"homepage": "https://conv.friedli.info/", "homepage": "https://manuel.pages.gittr.ch/dencode.org",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://gittr.ch/manuel/converter.git" "url": "https://gittr.ch/manuel/converter.git"
@ -22,43 +22,50 @@
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build --delete-output-path",
"watch": "ng build --watch --configuration development", "build-prod": "ng build --prod --optimization --aot --delete-output-path --build-optimizer",
"test": "ng test", "test": "ng test --code-coverage",
"test:ci": "ng test --no-watch --no-progress --browsers=ChromiumHeadless" "test:ci": "ng test --browsers ChromeHeadlessNoSandbox --watch=false --code-coverage",
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "npm rebuild node-sass"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^17.1.0", "@angular/common": "6.1.7",
"@angular/common": "^17.1.0", "@angular/compiler": "6.1.7",
"@angular/compiler": "^17.1.0", "@angular/core": "6.1.7",
"@angular/core": "^17.1.0", "@angular/forms": "6.1.7",
"@angular/forms": "^17.1.0", "@angular/platform-browser": "6.1.7",
"@angular/platform-browser": "^17.1.0", "@angular/platform-browser-dynamic": "6.1.7",
"@angular/platform-browser-dynamic": "^17.1.0", "@angular/router": "6.1.7",
"@angular/router": "^17.1.0", "core-js": "^2.5.1",
"punycode": "^2.3.1", "punycode": "^2.1.0",
"quoted-printable": "^1.0.1", "quoted-printable": "^1.0.0",
"rxjs": "~7.8.0", "rxjs": "^6.3.2",
"tslib": "^2.3.0", "utf8": "^2.1.0",
"utf8": "^3.0.0", "zone.js": "^0.8.26"
"zone.js": "~0.14.3"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^17.1.0", "@angular-devkit/build-angular": "~0.7.0",
"@angular/cli": "^17.1.0", "@angular/cli": "6.1.5",
"@angular/compiler-cli": "^17.1.0", "@angular/compiler-cli": "6.1.7",
"@types/jasmine": "~5.1.0", "@types/jasmine": "~2.8.6",
"@types/node": "^20.11.5", "@types/jasminewd2": "~2.0.3",
"@types/punycode": "^2.1.3", "@types/node": "~8.9.4",
"@types/quoted-printable": "^1.0.2", "codelyzer": "~4.2.1",
"@types/utf8": "^3.0.3", "jasmine-core": "~2.99.1",
"jasmine-core": "~5.1.0", "jasmine-spec-reporter": "~4.2.1",
"karma": "~6.4.0", "karma": "~1.7.1",
"karma-chrome-launcher": "~3.2.0", "karma-chrome-launcher": "~2.2.0",
"karma-coverage": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~5.1.0", "karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "~2.1.0", "karma-jasmine-html-reporter": "^0.2.2",
"typescript": "~5.3.2" "karma-nightmare": "~0.4.15",
"protractor": "~5.4.0",
"puppeteer": "~1.7.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "2.9.2"
} }
} }

View file

@ -1,9 +1,7 @@
@for (step of steps; track step.index) { <div *ngFor="let step of steps" class="inputwrapper">
<div class="inputwrapper"> <app-text-input-field [step]="step" #ti></app-text-input-field>
<app-text-input-field [step]="step" #ti></app-text-input-field> <app-converter-selector [step]="step" [textInput]="ti"></app-converter-selector>
<app-converter-selector [step]="step" [textInput]="ti"></app-converter-selector> <app-error-message [step]="step"></app-error-message>
<app-error-message [step]="step"></app-error-message> </div>
</div>
}
<app-version></app-version> <app-version></app-version>
<!--<router-outlet></router-outlet>--> <!--<router-outlet></router-outlet>-->

View file

@ -1,26 +1,39 @@
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {FormsModule} from '@angular/forms';
import {Step} from './step'; import {Step} from './step';
import {VersionComponent} from './version/version.component';
import {ConverterSelectorComponent} from './converter-selector/converter-selector.component';
import {TextInputFieldComponent} from './text-input-field/text-input-field.component';
import {ErrorMessageComponent} from './error-message/error-message.component';
describe('AppComponent', () => { describe('AppComponent', () => {
let sut: AppComponent; let sut: AppComponent;
let fixture: ComponentFixture<AppComponent>; let fixture: ComponentFixture<AppComponent>;
const firstStep: Step = new Step(0); const firstStep: Step = new Step(0);
beforeEach(async () => { beforeEach(async(() => {
await TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [AppComponent] declarations: [
AppComponent,
ConverterSelectorComponent,
ErrorMessageComponent,
TextInputFieldComponent,
VersionComponent
],
imports: [FormsModule]
}) })
.compileComponents(); .compileComponents();
}); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(AppComponent); fixture = TestBed.createComponent(AppComponent);
sut = fixture.componentInstance; sut = fixture.componentInstance;
}); });
it('should create the app', () => { it('should create the app', async(() => {
// const fixture = TestBed.createComponent(AppComponent); // const fixture = TestBed.createComponent(AppComponent);
expect(sut).toBeTruthy(); const app = fixture.debugElement.componentInstance;
}); expect(app).toBeTruthy();
}));
}); });

View file

@ -1,24 +1,11 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {InputComponentManagerService} from './input-component-manager.service'; import {InputComponentManagerService} from './input-component-manager.service';
import {Step} from './step'; import {Step} from './step';
import {RouterOutlet} from '@angular/router';
import {TextInputFieldComponent} from './text-input-field/text-input-field.component';
import {ConverterSelectorComponent} from './converter-selector/converter-selector.component';
import {ErrorMessageComponent} from './error-message/error-message.component';
import {VersionComponent} from './version/version.component';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
standalone: true,
imports: [
ConverterSelectorComponent,
ErrorMessageComponent,
RouterOutlet,
TextInputFieldComponent,
VersionComponent
],
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrl: './app.component.scss' styleUrls: ['./app.component.scss']
}) })
export class AppComponent implements OnInit { export class AppComponent implements OnInit {
public steps: Step[] = []; public steps: Step[] = [];

View file

@ -1,8 +0,0 @@
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [provideRouter(routes)]
};

View file

@ -12,11 +12,11 @@ import { ErrorMessageComponent } from './error-message/error-message.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
// AppComponent, AppComponent,
// VersionComponent, VersionComponent,
// TextInputFieldComponent, TextInputFieldComponent,
// ConverterSelectorComponent, ConverterSelectorComponent,
// ErrorMessageComponent ErrorMessageComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
@ -27,7 +27,7 @@ import { ErrorMessageComponent } from './error-message/error-message.component';
InputComponentManagerService, InputComponentManagerService,
NativeLibraryWrapperService NativeLibraryWrapperService
], ],
// bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { export class AppModule {
} }

View file

@ -1,3 +0,0 @@
import { Routes } from '@angular/router';
export const routes: Routes = [];

View file

@ -35,7 +35,7 @@ export class ConverterRegistryService {
return this.converters; return this.converters;
} }
public getConverter(id: string): Converter | undefined { public getConverter(id: string): Converter {
return this.converters.find((converter: Converter): boolean => converter.getId() === id); return this.converters.find((converter: Converter): boolean => converter.getId() === id);
} }

View file

@ -2,9 +2,8 @@
<div class="arrow_box"> <div class="arrow_box">
<select class="select" (change)="convert($event)"> <select class="select" (change)="convert($event)">
<option id="undefined">Select conversion ...</option> <option id="undefined">Select conversion ...</option>
@for (c of converters; track c.getId()) { <option class="option" *ngFor="let c of converters" id="{{c.getId()}}">{{c.getDisplayname()}}
<option class="option" id="{{c.getId()}}">{{ c.getDisplayname() }}</option> </option>
}
</select> </select>
</div> </div>
</div> </div>

View file

@ -1,4 +1,4 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {ConverterSelectorComponent} from './converter-selector.component'; import {ConverterSelectorComponent} from './converter-selector.component';
import {Component, ViewChild} from '@angular/core'; import {Component, ViewChild} from '@angular/core';
@ -17,7 +17,7 @@ class TestHostComponent {
public step: Step = new Step(42); public step: Step = new Step(42);
public textInputComponent: TextInputFieldComponent = new TextInputFieldComponent(inputComponentManagerServiceStub); public textInputComponent: TextInputFieldComponent = new TextInputFieldComponent(inputComponentManagerServiceStub);
@ViewChild(ConverterSelectorComponent) @ViewChild(ConverterSelectorComponent)
public sutComponent!: ConverterSelectorComponent; public sutComponent: ConverterSelectorComponent;
} }
const inputComponentManagerServiceStub = createSpyObj(['getNext']); const inputComponentManagerServiceStub = createSpyObj(['getNext']);
@ -39,10 +39,10 @@ describe('ConverterSelectorComponent', () => {
converterRegistryServiceStub.getAllConverters.and.returnValue([converter1, converter2, converter3]); converterRegistryServiceStub.getAllConverters.and.returnValue([converter1, converter2, converter3]);
converterRegistryServiceStub.getConverter.and.returnValue(undefined); converterRegistryServiceStub.getConverter.and.returnValue(undefined);
beforeEach(async () => { beforeEach(async(() => {
await TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ConverterSelectorComponent],
declarations: [ declarations: [
ConverterSelectorComponent,
TestHostComponent TestHostComponent
], ],
providers: [ providers: [
@ -51,7 +51,7 @@ describe('ConverterSelectorComponent', () => {
] ]
}) })
.compileComponents(); .compileComponents();
}); }));
beforeEach(() => { beforeEach(() => {
testHostFixture = TestBed.createComponent(TestHostComponent); testHostFixture = TestBed.createComponent(TestHostComponent);
@ -59,7 +59,7 @@ describe('ConverterSelectorComponent', () => {
testHostFixture.detectChanges(); testHostFixture.detectChanges();
}); });
it('should create the component', () => { it('should create', () => {
expect(testHostComponent.sutComponent).toBeTruthy(); expect(testHostComponent.sutComponent).toBeTruthy();
}); });

View file

@ -3,20 +3,17 @@ import {Step} from '../step';
import {Converter} from '../converter/converter'; import {Converter} from '../converter/converter';
import {ConverterRegistryService} from '../converter-registry.service'; import {ConverterRegistryService} from '../converter-registry.service';
import {TextInputFieldComponent} from '../text-input-field/text-input-field.component'; import {TextInputFieldComponent} from '../text-input-field/text-input-field.component';
import {CommonModule} from '@angular/common';
@Component({ @Component({
selector: 'app-converter-selector', selector: 'app-converter-selector',
templateUrl: './converter-selector.component.html', templateUrl: './converter-selector.component.html',
standalone: true, styleUrls: ['./converter-selector.component.scss']
styleUrls: ['./converter-selector.component.scss'],
imports: [CommonModule]
}) })
export class ConverterSelectorComponent implements OnInit { export class ConverterSelectorComponent implements OnInit {
@Input() @Input()
public step!: Step; public step: Step;
@Input() @Input()
textInput!: TextInputFieldComponent; private textInput: TextInputFieldComponent;
public converters: Converter[] = []; public converters: Converter[] = [];
constructor(private converterRegistryService: ConverterRegistryService) { constructor(private converterRegistryService: ConverterRegistryService) {

View file

@ -1,5 +1,5 @@
import {PunycodeDecoder} from './punycode-decoder'; import {PunycodeDecoder} from './punycode-decoder';
import {NativeLibraryWrapperService, Punycode} from '../native-library-wrapper.service'; import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import createSpyObj = jasmine.createSpyObj; import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy; import Spy = jasmine.Spy;
@ -9,8 +9,8 @@ describe('PunycodeDecoder', () => {
let decodeSpy: Spy; let decodeSpy: Spy;
beforeEach(() => { beforeEach(() => {
nativeWrapperSpy = {punycode: createSpyObj<Punycode>(['decode'])}; nativeWrapperSpy = {punycode: createSpyObj(['decode'])};
decodeSpy = nativeWrapperSpy.punycode!.decode as Spy; decodeSpy = nativeWrapperSpy.punycode.decode as Spy;
sut = new PunycodeDecoder((nativeWrapperSpy as NativeLibraryWrapperService)); sut = new PunycodeDecoder((nativeWrapperSpy as NativeLibraryWrapperService));
}); });

View file

@ -1,4 +1,4 @@
import {NativeLibraryWrapperService, Punycode} from '../native-library-wrapper.service'; import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import {PunycodeEncoder} from './punycode-encoder'; import {PunycodeEncoder} from './punycode-encoder';
import createSpyObj = jasmine.createSpyObj; import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy; import Spy = jasmine.Spy;
@ -9,8 +9,8 @@ describe('PunycodeEncoder', () => {
let encodeSpy: Spy; let encodeSpy: Spy;
beforeEach(() => { beforeEach(() => {
nativeWrapperSpy = {punycode: createSpyObj<Punycode>(['encode'])}; nativeWrapperSpy = {punycode: createSpyObj(['encode'])};
encodeSpy = nativeWrapperSpy.punycode!.encode as Spy; encodeSpy = nativeWrapperSpy.punycode.encode as Spy;
sut = new PunycodeEncoder(nativeWrapperSpy as NativeLibraryWrapperService); sut = new PunycodeEncoder(nativeWrapperSpy as NativeLibraryWrapperService);
}); });

View file

@ -1,4 +1,4 @@
import {NativeLibraryWrapperService, QuotedPrintable} from '../native-library-wrapper.service'; import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import {QuotedPrintableDecoder} from './quoted-printable-decoder'; import {QuotedPrintableDecoder} from './quoted-printable-decoder';
import createSpyObj = jasmine.createSpyObj; import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy; import Spy = jasmine.Spy;
@ -9,8 +9,8 @@ describe('QuotedPrintableDecoder', () => {
let decodeSpy: Spy; let decodeSpy: Spy;
beforeEach(() => { beforeEach(() => {
nativeWrapperSpy = {quotedPrintable: createSpyObj<QuotedPrintable>(['decode'])}; nativeWrapperSpy = {quotedPrintable: createSpyObj(['decode'])};
decodeSpy = nativeWrapperSpy.quotedPrintable!.decode as Spy; decodeSpy = nativeWrapperSpy.quotedPrintable.decode as Spy;
sut = new QuotedPrintableDecoder((nativeWrapperSpy as NativeLibraryWrapperService)); sut = new QuotedPrintableDecoder((nativeWrapperSpy as NativeLibraryWrapperService));
}); });

View file

@ -1,4 +1,4 @@
import {NativeLibraryWrapperService, QuotedPrintable} from '../native-library-wrapper.service'; import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import {QuotedPrintableEncoder} from './quoted-printable-encoder'; import {QuotedPrintableEncoder} from './quoted-printable-encoder';
import createSpyObj = jasmine.createSpyObj; import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy; import Spy = jasmine.Spy;
@ -9,8 +9,8 @@ describe('QuotedPrintableEncoder', () => {
let encodeSpy: Spy; let encodeSpy: Spy;
beforeEach(() => { beforeEach(() => {
nativeWrapperSpy = {quotedPrintable: createSpyObj<QuotedPrintable>(['encode'])}; nativeWrapperSpy = {quotedPrintable: createSpyObj(['encode'])};
encodeSpy = nativeWrapperSpy.quotedPrintable!.encode as Spy; encodeSpy = nativeWrapperSpy.quotedPrintable.encode as Spy;
sut = new QuotedPrintableEncoder(nativeWrapperSpy as NativeLibraryWrapperService); sut = new QuotedPrintableEncoder(nativeWrapperSpy as NativeLibraryWrapperService);
}); });

View file

@ -13,7 +13,7 @@ export class ROT13Converter implements Converter {
try { try {
const inChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; const inChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const outChars = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'; const outChars = 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm';
const translate = (c: string) => { const translate = c => {
const charIndex = inChars.indexOf(c); const charIndex = inChars.indexOf(c);
return charIndex > -1 ? outChars[charIndex] : c; return charIndex > -1 ? outChars[charIndex] : c;
}; };

View file

@ -1,4 +1,4 @@
import {NativeLibraryWrapperService, Utf8} from '../native-library-wrapper.service'; import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import {UTF8Decoder} from './utf8-decoder'; import {UTF8Decoder} from './utf8-decoder';
import createSpyObj = jasmine.createSpyObj; import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy; import Spy = jasmine.Spy;
@ -9,8 +9,8 @@ describe('UTF8Decoder', () => {
let decodeSpy: Spy; let decodeSpy: Spy;
beforeEach(() => { beforeEach(() => {
nativeWrapperSpy = {utf8: createSpyObj<Utf8>(['decode'])}; nativeWrapperSpy = {utf8: createSpyObj(['decode'])};
decodeSpy = nativeWrapperSpy.utf8!.decode as Spy; decodeSpy = nativeWrapperSpy.utf8.decode as Spy;
sut = new UTF8Decoder((nativeWrapperSpy as NativeLibraryWrapperService)); sut = new UTF8Decoder((nativeWrapperSpy as NativeLibraryWrapperService));
}); });

View file

@ -1,4 +1,4 @@
import {NativeLibraryWrapperService, Utf8} from '../native-library-wrapper.service'; import {NativeLibraryWrapperService} from '../native-library-wrapper.service';
import {UTF8Encoder} from './utf8-encoder'; import {UTF8Encoder} from './utf8-encoder';
import createSpyObj = jasmine.createSpyObj; import createSpyObj = jasmine.createSpyObj;
import Spy = jasmine.Spy; import Spy = jasmine.Spy;
@ -9,8 +9,8 @@ describe('UTF8Encoder', () => {
let encodeSpy: Spy; let encodeSpy: Spy;
beforeEach(() => { beforeEach(() => {
nativeWrapperSpy = {utf8: createSpyObj<Utf8>(['encode'])}; nativeWrapperSpy = {utf8: createSpyObj(['encode'])};
encodeSpy = nativeWrapperSpy.utf8!.encode as Spy; encodeSpy = nativeWrapperSpy.utf8.encode as Spy;
sut = new UTF8Encoder(nativeWrapperSpy as NativeLibraryWrapperService); sut = new UTF8Encoder(nativeWrapperSpy as NativeLibraryWrapperService);
}); });

View file

@ -1,3 +1 @@
@if (step.error) { <div class="errormessage" *ngIf="step.error" [innerHTML]="step.message"></div>
<div class="errormessage" [innerHTML]="step.message"></div>
}

View file

@ -1,4 +1,4 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {ErrorMessageComponent} from './error-message.component'; import {ErrorMessageComponent} from './error-message.component';
import {Component, ViewChild} from '@angular/core'; import {Component, ViewChild} from '@angular/core';
@ -10,20 +10,22 @@ import {Step} from '../step';
class TestHostComponent { class TestHostComponent {
public step: Step = new Step(42); public step: Step = new Step(42);
@ViewChild(ErrorMessageComponent) @ViewChild(ErrorMessageComponent)
public sutComponent!: ErrorMessageComponent; public sutComponent: ErrorMessageComponent;
} }
describe('ErrorMessageComponent', () => { describe('ErrorMessageComponent', () => {
let testHostComponent: TestHostComponent; let testHostComponent: TestHostComponent;
let testHostFixture: ComponentFixture<TestHostComponent>; let testHostFixture: ComponentFixture<TestHostComponent>;
beforeEach(async () => { beforeEach(async(() => {
await TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ErrorMessageComponent], declarations: [
declarations: [TestHostComponent] ErrorMessageComponent,
TestHostComponent
]
}) })
.compileComponents(); .compileComponents();
}); }));
beforeEach(() => { beforeEach(() => {
testHostFixture = TestBed.createComponent(TestHostComponent); testHostFixture = TestBed.createComponent(TestHostComponent);

View file

@ -2,14 +2,13 @@ import {Component, Input} from '@angular/core';
import {Step} from '../step'; import {Step} from '../step';
@Component({ @Component({
selector: 'app-error-message', selector: 'app-error-message',
templateUrl: './error-message.component.html', templateUrl: './error-message.component.html',
standalone: true, styleUrls: ['./error-message.component.scss']
styleUrls: ['./error-message.component.scss']
}) })
export class ErrorMessageComponent { export class ErrorMessageComponent {
@Input() @Input()
public step!: Step; public step: Step;
constructor() { constructor() {
} }

View file

@ -24,12 +24,12 @@ describe('InputComponentManagerService', () => {
); );
it('must not add a null Step', inject([InputComponentManagerService], (service: InputComponentManagerService) => { it('must not add a null Step', inject([InputComponentManagerService], (service: InputComponentManagerService) => {
expect(() => service.register(null!)).toThrowError(); expect(() => service.register(null)).toThrowError();
expect(service.getAllComponents().length).toEqual(0); expect(service.getAllComponents().length).toEqual(0);
})); }));
it('must not add an undefined Step', inject([InputComponentManagerService], (service: InputComponentManagerService) => { it('must not add an undefined Step', inject([InputComponentManagerService], (service: InputComponentManagerService) => {
expect(() => service.register(undefined!)).toThrowError(); expect(() => service.register(undefined)).toThrowError();
expect(service.getAllComponents().length).toEqual(0); expect(service.getAllComponents().length).toEqual(0);
})); }));

View file

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import * as NativePunycode from 'punycode/'; import * as NativePunycode from 'punycode';
import * as NativeQuotedPrintable from 'quoted-printable'; import * as NativeQuotedPrintable from 'quoted-printable';
import * as NativeUtf8 from 'utf8'; import * as NativeUtf8 from 'utf8';
@ -18,19 +18,19 @@ export class NativeLibraryWrapperService {
} }
} }
export interface Punycode { interface Punycode {
encode(input: string): string; encode(input: string): string;
decode(input: string): string; decode(input: string): string;
} }
export interface QuotedPrintable { interface QuotedPrintable {
encode(input: string): string; encode(input: string): string;
decode(input: string): string; decode(input: string): string;
} }
export interface Utf8 { interface Utf8 {
encode(input: any): string; encode(input: any): string;
decode(input: string): any; decode(input: string): any;

View file

@ -2,7 +2,7 @@ import {Converter} from './converter/converter';
export class Step { export class Step {
public content = ''; public content = '';
public selectedConverter: Converter | undefined; public selectedConverter: Converter = undefined;
public index: number; public index: number;
public error = false; public error = false;
public message = ''; public message = '';

View file

@ -1,4 +1,4 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {TextInputFieldComponent} from './text-input-field.component'; import {TextInputFieldComponent} from './text-input-field.component';
import {Step} from '../step'; import {Step} from '../step';
@ -13,7 +13,7 @@ import createSpyObj = jasmine.createSpyObj;
class TestHostComponent { class TestHostComponent {
public step: Step = new Step(42); public step: Step = new Step(42);
@ViewChild(TextInputFieldComponent) @ViewChild(TextInputFieldComponent)
public sutComponent!: TextInputFieldComponent; public sutComponent: TextInputFieldComponent;
} }
describe('TextInputFieldComponent', () => { describe('TextInputFieldComponent', () => {
@ -23,16 +23,17 @@ describe('TextInputFieldComponent', () => {
const inputComponentManagerServiceStub = createSpyObj(['getNext']); const inputComponentManagerServiceStub = createSpyObj(['getNext']);
inputComponentManagerServiceStub.getNext.and.returnValue(undefined); inputComponentManagerServiceStub.getNext.and.returnValue(undefined);
beforeEach(async () => { beforeEach(async(() => {
await TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
TestHostComponent TestHostComponent,
TextInputFieldComponent
], ],
imports: [TextInputFieldComponent, FormsModule], imports: [FormsModule],
providers: [{provide: InputComponentManagerService, useValue: inputComponentManagerServiceStub}] providers: [{provide: InputComponentManagerService, useValue: inputComponentManagerServiceStub}]
}) })
.compileComponents(); .compileComponents();
}); }));
beforeEach(() => { beforeEach(() => {
testHostFixture = TestBed.createComponent(TestHostComponent); testHostFixture = TestBed.createComponent(TestHostComponent);
@ -40,7 +41,7 @@ describe('TextInputFieldComponent', () => {
testHostFixture.detectChanges(); testHostFixture.detectChanges();
}); });
it('should create the component', () => { it('should create', () => {
expect(testHostComponent.sutComponent).toBeTruthy(); expect(testHostComponent.sutComponent).toBeTruthy();
}); });

View file

@ -2,35 +2,32 @@ import {Component, Input} from '@angular/core';
import {Step} from '../step'; import {Step} from '../step';
import {Converter} from '../converter/converter'; import {Converter} from '../converter/converter';
import {InputComponentManagerService} from '../input-component-manager.service'; import {InputComponentManagerService} from '../input-component-manager.service';
import {FormsModule} from '@angular/forms';
@Component({ @Component({
selector: 'app-text-input-field', selector: 'app-text-input-field',
templateUrl: './text-input-field.component.html', templateUrl: './text-input-field.component.html',
standalone: true, styleUrls: ['./text-input-field.component.scss']
styleUrls: ['./text-input-field.component.scss'],
imports: [FormsModule]
}) })
export class TextInputFieldComponent { export class TextInputFieldComponent {
@Input() @Input()
public step!: Step; public step: Step;
constructor(private inputComponentManagerService: InputComponentManagerService) { constructor(private inputComponentManagerService: InputComponentManagerService) {
} }
update(step: Step): void { update(step: Step): void {
const converter: Converter | undefined = step.selectedConverter; const converter: Converter = step.selectedConverter;
if (converter !== undefined) { if (converter !== undefined) {
const content: string = step.content; const content: string = step.content;
let result: string | null; let result: string;
try { try {
result = converter.convert(content); result = converter.convert(content);
} catch (error) { } catch (error) {
if (typeof console === 'object' && typeof console.log === 'function') { if (typeof console === 'object' && typeof console.log === 'function') {
console.log(error); console.log(error);
} }
step.message = (error as Error).message; step.message = error.message;
step.error = true; step.error = true;
result = null; result = null;
} }

View file

@ -1,18 +1,18 @@
import {ComponentFixture, TestBed} from '@angular/core/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {VersionComponent} from './version.component'; import {VersionComponent} from './version.component';
import packageInfo from '../../../package.json'; import {environment} from '../../environments/environment';
describe('VersionComponent', () => { describe('VersionComponent', () => {
let component: VersionComponent; let component: VersionComponent;
let fixture: ComponentFixture<VersionComponent>; let fixture: ComponentFixture<VersionComponent>;
beforeEach(async () => { beforeEach(async(() => {
await TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [VersionComponent] declarations: [VersionComponent]
}) })
.compileComponents(); .compileComponents();
}); }));
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(VersionComponent); fixture = TestBed.createComponent(VersionComponent);
@ -20,13 +20,13 @@ describe('VersionComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create the component', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
it('should contain the correct version', () => { it('should contain the correct version', () => {
// when executing the test, we're always running with the dev environment // when executing the test, we're always running with the dev environment
expect(component.VERSION).toEqual(`${packageInfo.version} (development build)`); expect(component.VERSION).toEqual(`${environment.appVersion} (development build)`);
}); });
it('should have the correct value for the "production" property', () => { it('should have the correct value for the "production" property', () => {

View file

@ -1,17 +1,14 @@
import {Component, isDevMode} from '@angular/core'; import {Component} from '@angular/core';
import {CommonModule} from '@angular/common'; import {environment} from '../../environments/environment';
import packageInfo from '../../../package.json';
@Component({ @Component({
selector: 'app-version', selector: 'app-version',
templateUrl: './version.component.html', templateUrl: './version.component.html',
standalone: true, styleUrls: ['./version.component.scss']
styleUrls: ['./version.component.scss'],
imports: [CommonModule]
}) })
export class VersionComponent { export class VersionComponent {
public readonly PROD: boolean = !isDevMode(); public readonly PROD: boolean = environment.production;
public readonly VERSION: string = packageInfo.version + (this.PROD ? '' : ' (development build)'); public readonly VERSION: string = environment.appVersion + (this.PROD ? '' : ' (development build)');
constructor() { constructor() {
} }

11
src/browserslist Normal file
View file

@ -0,0 +1,11 @@
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11

View file

@ -0,0 +1,4 @@
export const environment = {
production: true,
appVersion: require('../../package.json').version
};

View file

@ -0,0 +1,16 @@
// 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,
appVersion: require('../../package.json').version
};
/*
* In development mode, for easier debugging, you can ignore zone related error
* stack frames such as `zone.run`/`zoneDelegate.invokeTask` by importing the
* below file. Don't forget to comment it out in production mode
* because it will have a performance impact when errors are thrown
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.

40
src/karma.conf.js Normal file
View file

@ -0,0 +1,40 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-chrome-launcher'),
require('karma-jasmine'),
require('karma-nightmare'),
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'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
singleRun: false
});
};

View file

@ -1,6 +1,12 @@
import { bootstrapApplication } from '@angular/platform-browser'; import { enableProdMode } from '@angular/core';
import { appConfig } from './app/app.config'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig) import { AppModule } from './app/app.module';
.catch((err) => console.error(err)); import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));

76
src/polyfills.ts Normal file
View file

@ -0,0 +1,76 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';
/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import 'core-js/es7/reflect';
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
*/
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*/
// (window as any).__Zone_enable_cross_context_check = true;
/***************************************************************************************************
* APPLICATION IMPORTS
*/

20
src/test.ts Normal file
View file

@ -0,0 +1,20 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

13
src/tsconfig.app.json Normal file
View file

@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": [
"node"
]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}

18
src/tsconfig.spec.json Normal file
View file

@ -0,0 +1,18 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}

17
src/tslint.json Normal file
View file

@ -0,0 +1,17 @@
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}

View file

@ -1,16 +0,0 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [
"node"
]
},
"files": [
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
]
}

View file

@ -1,35 +1,21 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{ {
"compileOnSave": false, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc", "outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"esModuleInterop": true,
"sourceMap": true, "sourceMap": true,
"declaration": false, "declaration": false,
"experimentalDecorators": true, "module": "es2015",
"moduleResolution": "node", "moduleResolution": "node",
"importHelpers": true, "emitDecoratorMetadata": true,
"target": "ES2022", "experimentalDecorators": true,
"module": "ES2022", "target": "es5",
"useDefineForClassFields": false, "typeRoots": [
"lib": [ "node_modules/@types"
"ES2022",
"dom"
], ],
"resolveJsonModule": true, "lib": [
"allowSyntheticDefaultImports": true "es2017",
}, "dom"
"angularCompilerOptions": { ]
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
} }
} }

View file

@ -1,14 +0,0 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

130
tslint.json Normal file
View file

@ -0,0 +1,130 @@
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"import-spacing": true,
"indent": [
true,
"spaces"
],
"interface-over-type-literal": true,
"label-position": true,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-super": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-misused-new": true,
"no-non-null-assertion": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"prefer-const": true,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true
}
}