Skip to content

Commit

Permalink
feat(sandbox): create the sandox-angular-lib project (ARCH-285) (#2848
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tschaffter authored Sep 23, 2024
1 parent ca25d15 commit 5632759
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/sandbox/angular-app/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<app-nx-welcome></app-nx-welcome> <router-outlet></router-outlet>
<app-nx-welcome></app-nx-welcome>
<sandbox-angular-lib></sandbox-angular-lib>
<router-outlet></router-outlet>
3 changes: 2 additions & 1 deletion apps/sandbox/angular-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component } from '@angular/core';
import { RouterModule } from '@angular/router';
import { NxWelcomeComponent } from './nx-welcome.component';
import { SandboxAngularLibComponent } from '@sagebionetworks/sandbox-angular-lib';

@Component({
standalone: true,
imports: [NxWelcomeComponent, RouterModule],
imports: [NxWelcomeComponent, RouterModule, SandboxAngularLibComponent],
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
Expand Down
33 changes: 33 additions & 0 deletions libs/sandbox/angular-lib/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "sandbox",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "sandbox",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nx/angular-template"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/sandbox/angular-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# sandbox-angular-lib

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test sandbox-angular-lib` to execute the unit tests.
21 changes: 21 additions & 0 deletions libs/sandbox/angular-lib/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
displayName: 'sandbox-angular-lib',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
coverageDirectory: '../../../coverage/libs/sandbox/angular-lib',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
20 changes: 20 additions & 0 deletions libs/sandbox/angular-lib/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "sandbox-angular-lib",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/sandbox/angular-lib/src",
"prefix": "lib",
"projectType": "library",
"tags": [],
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/sandbox/angular-lib/jest.config.ts"
}
},
"lint": {
"executor": "@nx/eslint:lint"
}
}
}
1 change: 1 addition & 0 deletions libs/sandbox/angular-lib/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/sandbox-angular-lib/sandbox-angular-lib.component';
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>sandbox-angular-lib works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SandboxAngularLibComponent } from './sandbox-angular-lib.component';

describe('SandboxAngularLibComponent', () => {
let component: SandboxAngularLibComponent;
let fixture: ComponentFixture<SandboxAngularLibComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SandboxAngularLibComponent],
}).compileComponents();

fixture = TestBed.createComponent(SandboxAngularLibComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';

@Component({
selector: 'sandbox-angular-lib',
standalone: true,
imports: [CommonModule],
templateUrl: './sandbox-angular-lib.component.html',
styleUrl: './sandbox-angular-lib.component.css',
})
export class SandboxAngularLibComponent {}
8 changes: 8 additions & 0 deletions libs/sandbox/angular-lib/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
globalThis.ngJest = {
testEnvironmentOptions: {
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
},
};
import 'jest-preset-angular/setup-jest';
28 changes: 28 additions & 0 deletions libs/sandbox/angular-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "es2022",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
12 changes: 12 additions & 0 deletions libs/sandbox/angular-lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": ["src/**/*.spec.ts", "src/test-setup.ts", "jest.config.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}
11 changes: 11 additions & 0 deletions libs/sandbox/angular-lib/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"target": "es2016",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
}
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"@sagebionetworks/shared/util": ["libs/shared/typescript/util/src/index.ts"],
"@sagebionetworks/shared/web-components": [
"libs/shared/typescript/web-components/src/index.ts"
]
],
"@sagebionetworks/sandbox-angular-lib": ["libs/sandbox/angular-lib/src/index.ts"]
}
},
"exclude": ["node_modules", "tmp"]
Expand Down

0 comments on commit 5632759

Please sign in to comment.