Skip to content

Commit

Permalink
refactor: apply standalone migration (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation authored May 4, 2023
1 parent 08ccf28 commit 0171563
Show file tree
Hide file tree
Showing 50 changed files with 734 additions and 384 deletions.
30 changes: 15 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": [
"*.ts"
],
"files": ["*.ts"],
"parserOptions": {
"project": [
"tsconfig.json"
],
"project": ["tsconfig.json"],
"createDefaultProgram": true
},
"extends": [
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
Expand All @@ -34,16 +30,20 @@
"prefix": "t9n",
"style": "kebab-case"
}
],
"import/no-unresolved": "off",
"import/order": [
"error",
{
"alphabetize": { "order": "asc", "caseInsensitive": true },
"newlines-between": "always"
}
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {}
}
]
Expand Down
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.angular/*
.github/*
browserslist
LICENSE
coverage
app/*
package-lock.json
.*
*.ico
*.xlf
*.svg
Expand All @@ -16,5 +15,6 @@ server/client/*
schematics/*/index.js
schematics/*/index.d.ts
yarn.lock
package-lock.json
test/xlf
test/xlf2
7 changes: 2 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
"type": "node",
"request": "launch",
"name": "t9n xlf cli",
"runtimeArgs": [
"${workspaceRoot}/bin/cli.js",
"t9n-xlf.json"
],
"runtimeArgs": ["${workspaceRoot}/bin/cli.js", "t9n-xlf.json"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"port": 9229
Expand All @@ -44,4 +41,4 @@
"port": 9229
}
]
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"build": "yarn -s build:ng && yarn -s build:node",
"build:ng": "ng build --configuration production",
"build:node": "rollup --config rollup.config.mjs",
"format": "prettier --ignore-unknown --write **/*",
"format": "prettier --ignore-unknown --write \"**/*\"",
"test": "yarn -s test:node",
"test:node": "jest",
"lint": "ng lint",
Expand Down Expand Up @@ -93,6 +93,7 @@
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"eslint": "^8.39.0",
"eslint-plugin-import": "^2.27.5",
"husky": "^8.0.3",
"jasmine-core": "~4.6.0",
"jest": "^29.5.0",
Expand Down
10 changes: 0 additions & 10 deletions src/app/app-routing.module.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [AppComponent],
imports: [RouterTestingModule, AppComponent],
}).compileComponents();
}));

Expand Down
22 changes: 21 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import { Component, HostBinding } from '@angular/core';
import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import {
MatSnackBar,
MatSnackBarModule,
MatSnackBarRef,
SimpleSnackBar,
} from '@angular/material/snack-bar';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { RouterLink, RouterOutlet } from '@angular/router';

import { WebsocketService } from './core/websocket.service';

@Component({
selector: 't9n-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [
MatToolbarModule,
MatButtonModule,
RouterLink,
MatIconModule,
MatSnackBarModule,
MatTooltipModule,
RouterOutlet,
],
})
export class AppComponent {
@HostBinding('class.service-down') serviceDown = false;
Expand Down
37 changes: 0 additions & 37 deletions src/app/app.module.ts

This file was deleted.

15 changes: 5 additions & 10 deletions src/app/core/websocket.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { delay, filter, retryWhen, skip, tap } from 'rxjs/operators';
import { distinctUntilChanged, filter, retry, tap } from 'rxjs/operators';
import { webSocket } from 'rxjs/webSocket';

import { environment } from '../../environments/environment';
Expand All @@ -12,19 +12,14 @@ import { ProjectInfo } from './project-info';
})
export class WebsocketService {
private readonly _projectSubject = new BehaviorSubject<ProjectInfo | null>(null);
readonly project = this._projectSubject.pipe(skip(1));
readonly project = this._projectSubject.pipe(
distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b))
);
readonly projectChange = this.project.pipe(filter((p): p is ProjectInfo => !!p));

constructor() {
webSocket(environment.translationSocket)
.pipe(
retryWhen((errors) =>
errors.pipe(
tap(() => this._projectSubject.next(null)),
delay(1000)
)
)
)
.pipe(tap({ error: () => this._projectSubject.next(null) }), retry({ delay: 1000 }))
.subscribe((r) => this._projectSubject.next(r as ProjectInfo));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { TitleCasePipe } from '@angular/common';
import { Component } from '@angular/core';

@Component({
selector: 't9n-i18n-examples-template',
templateUrl: './i18n-examples-template.component.html',
standalone: true,
imports: [TitleCasePipe],
})
export class I18nExamplesTemplateComponent {
title = 'angular-t9n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('AddLanguageModalComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [AddLanguageModalComponent],
imports: [AddLanguageModalComponent],
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import { NgIf, NgFor, AsyncPipe } from '@angular/common';
import { Component } from '@angular/core';
import { AbstractControl, UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog';
import {
AbstractControl,
UntypedFormBuilder,
UntypedFormGroup,
Validators,
ReactiveFormsModule,
} from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatButtonModule } from '@angular/material/button';
import { MatOptionModule } from '@angular/material/core';
import { MatDialogRef, MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { Observable } from 'rxjs';
import { map, startWith, switchMap, take } from 'rxjs/operators';

Expand All @@ -11,6 +23,19 @@ import { TranslationService } from '../../core/translation.service';
selector: 't9n-add-language-modal',
templateUrl: './add-language-modal.component.html',
styleUrls: ['./add-language-modal.component.scss'],
standalone: true,
imports: [
MatDialogModule,
ReactiveFormsModule,
MatFormFieldModule,
MatInputModule,
MatAutocompleteModule,
NgIf,
NgFor,
MatOptionModule,
MatButtonModule,
AsyncPipe,
],
})
export class AddLanguageModalComponent {
form: UntypedFormGroup;
Expand Down
17 changes: 0 additions & 17 deletions src/app/overview/overview-routing.module.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/app/overview/overview-routing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Routes } from '@angular/router';

export const routes: Routes = [
{
path: '',
loadComponent: () => import('./overview/overview.component').then((m) => m.OverviewComponent),
},
];
31 changes: 0 additions & 31 deletions src/app/overview/overview.module.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/overview/overview/overview.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('OverviewComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [OverviewComponent],
imports: [OverviewComponent],
}).compileComponents();
}));

Expand Down
18 changes: 17 additions & 1 deletion src/app/overview/overview/overview.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { NgFor, NgIf, AsyncPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatTooltipModule } from '@angular/material/tooltip';
import { RouterLink } from '@angular/router';
import { forkJoin, Observable, of } from 'rxjs';
import { map, switchMap, take } from 'rxjs/operators';

Expand All @@ -13,6 +18,17 @@ import { AddLanguageModalComponent } from '../add-language-modal/add-language-mo
templateUrl: './overview.component.html',
styleUrls: ['./overview.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
AsyncPipe,
MatButtonModule,
MatCardModule,
MatDialogModule,
MatTooltipModule,
RouterLink,
NgFor,
NgIf,
],
})
export class OverviewComponent implements OnInit {
project: Observable<string>;
Expand Down
Loading

0 comments on commit 0171563

Please sign in to comment.