diff --git a/apps/module-to-standalone/.eslintrc.json b/apps/module-to-standalone/.eslintrc.json new file mode 100644 index 0000000..b428c22 --- /dev/null +++ b/apps/module-to-standalone/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/apps/module-to-standalone/README.md b/apps/module-to-standalone/README.md new file mode 100644 index 0000000..f7def58 --- /dev/null +++ b/apps/module-to-standalone/README.md @@ -0,0 +1,32 @@ +

refactor module to standalone

+ +> Author: Thomas Laforge + + + +### Information + +### Statement + +### Step 1 + +### Step 2 + +### Constraints: + +### Submitting your work + +1. Fork the project +2. clone it +3. npm install +4. `npx nx serve module-to-standalone` +5. _...work on it_ +6. Commit your work +7. Submit a PR with a title beginning with **Answer:26** that I will review and other dev can review. + +module-to-standalone +module-to-standalone solution author + + + +_You can ask any question on_ twitter diff --git a/apps/module-to-standalone/project.json b/apps/module-to-standalone/project.json new file mode 100644 index 0000000..5827132 --- /dev/null +++ b/apps/module-to-standalone/project.json @@ -0,0 +1,81 @@ +{ + "name": "module-to-standalone", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "prefix": "app", + "sourceRoot": "apps/module-to-standalone/src", + "tags": [], + "targets": { + "build": { + "executor": "@angular-devkit/build-angular:browser", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/apps/module-to-standalone", + "index": "apps/module-to-standalone/src/index.html", + "main": "apps/module-to-standalone/src/main.ts", + "polyfills": ["zone.js"], + "tsConfig": "apps/module-to-standalone/tsconfig.app.json", + "assets": [ + "apps/module-to-standalone/src/favicon.ico", + "apps/module-to-standalone/src/assets" + ], + "styles": ["apps/module-to-standalone/src/styles.scss"], + "scripts": [] + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "initial", + "maximumWarning": "500kb", + "maximumError": "1mb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "2kb", + "maximumError": "4kb" + } + ], + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "executor": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "browserTarget": "module-to-standalone:build:production" + }, + "development": { + "browserTarget": "module-to-standalone:build:development" + } + }, + "defaultConfiguration": "development" + }, + "extract-i18n": { + "executor": "@angular-devkit/build-angular:extract-i18n", + "options": { + "browserTarget": "module-to-standalone:build" + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "apps/module-to-standalone/**/*.ts", + "apps/module-to-standalone/**/*.html" + ] + } + } + } +} diff --git a/apps/module-to-standalone/src/app/app.component.ts b/apps/module-to-standalone/src/app/app.component.ts new file mode 100644 index 0000000..91a72fa --- /dev/null +++ b/apps/module-to-standalone/src/app/app.component.ts @@ -0,0 +1,27 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + template: `
+ + + +
+ `, + host: { + class: 'flex flex-col p-4 gap-3', + }, +}) +export class AppComponent {} diff --git a/apps/module-to-standalone/src/app/app.module.ts b/apps/module-to-standalone/src/app/app.module.ts new file mode 100644 index 0000000..c795a11 --- /dev/null +++ b/apps/module-to-standalone/src/app/app.module.ts @@ -0,0 +1,11 @@ +import { MainShellModule } from '@angular-challenges/module-to-standalone/shell'; +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; +import { AppComponent } from './app.component'; + +@NgModule({ + declarations: [AppComponent], + imports: [BrowserModule, MainShellModule], + bootstrap: [AppComponent], +}) +export class AppModule {} diff --git a/apps/module-to-standalone/src/assets/.gitkeep b/apps/module-to-standalone/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/apps/module-to-standalone/src/favicon.ico b/apps/module-to-standalone/src/favicon.ico new file mode 100644 index 0000000..317ebcb Binary files /dev/null and b/apps/module-to-standalone/src/favicon.ico differ diff --git a/apps/module-to-standalone/src/index.html b/apps/module-to-standalone/src/index.html new file mode 100644 index 0000000..153133d --- /dev/null +++ b/apps/module-to-standalone/src/index.html @@ -0,0 +1,13 @@ + + + + + module-to-standalone + + + + + + + + diff --git a/apps/module-to-standalone/src/main.ts b/apps/module-to-standalone/src/main.ts new file mode 100644 index 0000000..16de236 --- /dev/null +++ b/apps/module-to-standalone/src/main.ts @@ -0,0 +1,6 @@ +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { AppModule } from './app/app.module'; + +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch((err) => console.error(err)); diff --git a/apps/module-to-standalone/src/styles.scss b/apps/module-to-standalone/src/styles.scss new file mode 100644 index 0000000..77e408a --- /dev/null +++ b/apps/module-to-standalone/src/styles.scss @@ -0,0 +1,5 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +/* You can add global styles to this file, and also import other style files */ diff --git a/apps/module-to-standalone/tailwind.config.js b/apps/module-to-standalone/tailwind.config.js new file mode 100644 index 0000000..99d683d --- /dev/null +++ b/apps/module-to-standalone/tailwind.config.js @@ -0,0 +1,14 @@ +const { createGlobPatternsForDependencies } = require('@nx/angular/tailwind'); +const { join } = require('path'); + +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [ + 'apps/module-to-standalone/**/*.{ts,html}', + 'libs/module-to-standalone/**/*.{ts,html}', + ], + theme: { + extend: {}, + }, + plugins: [], +}; diff --git a/apps/module-to-standalone/tsconfig.app.json b/apps/module-to-standalone/tsconfig.app.json new file mode 100644 index 0000000..fff4a41 --- /dev/null +++ b/apps/module-to-standalone/tsconfig.app.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [] + }, + "files": ["src/main.ts"], + "include": ["src/**/*.d.ts"], + "exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"] +} diff --git a/apps/module-to-standalone/tsconfig.editor.json b/apps/module-to-standalone/tsconfig.editor.json new file mode 100644 index 0000000..5c283ab --- /dev/null +++ b/apps/module-to-standalone/tsconfig.editor.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "src/**/*.ts", + "../../libs/module-to-standalone/shell/src/lib/main-shell.routes.ts", + "../../libs/module-to-standalone/shell/src/lib/main-shell.component.ts" + ], + "compilerOptions": { + "types": [] + } +} diff --git a/apps/module-to-standalone/tsconfig.json b/apps/module-to-standalone/tsconfig.json new file mode 100644 index 0000000..0731542 --- /dev/null +++ b/apps/module-to-standalone/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.editor.json" + } + ], + "extends": "../../tsconfig.base.json", + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/apps/projection/project.json b/apps/projection/project.json index 181f0d2..646f8ab 100644 --- a/apps/projection/project.json +++ b/apps/projection/project.json @@ -3,7 +3,7 @@ "$schema": "../../node_modules/nx/schemas/project-schema.json", "projectType": "application", "sourceRoot": "apps/projection/src", - "prefix": "angular-challenges", + "prefix": "app", "targets": { "build": { "executor": "@angular-devkit/build-angular:browser", diff --git a/libs/cli/src/generators/app/files/app/src/app/app.component.ts__tmpl__ b/libs/cli/src/generators/app/files/app/src/app/app.component.ts__tmpl__ index d977f09..937cefb 100644 --- a/libs/cli/src/generators/app/files/app/src/app/app.component.ts__tmpl__ +++ b/libs/cli/src/generators/app/files/app/src/app/app.component.ts__tmpl__ @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; @Component({ standalone: true, imports: [], - selector: 'app-root', + selector: 'lib-root', template: ``, styles: [''], }) diff --git a/libs/cli/src/generators/app/files/readme/README.md__tmpl__ b/libs/cli/src/generators/app/files/readme/README.md__tmpl__ index e0dfb5c..0797278 100644 --- a/libs/cli/src/generators/app/files/readme/README.md__tmpl__ +++ b/libs/cli/src/generators/app/files/readme/README.md__tmpl__ @@ -25,7 +25,6 @@ 7. Submit a PR with a title beginning with **Answer:<%= challengeNumber %>** that I will review and other dev can review. <%= projectName %> - <%= projectName %> solution author diff --git a/libs/module-to-standalone/admin/feature/.eslintrc.json b/libs/module-to-standalone/admin/feature/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/admin/feature/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/admin/feature/README.md b/libs/module-to-standalone/admin/feature/README.md new file mode 100644 index 0000000..77de8a8 --- /dev/null +++ b/libs/module-to-standalone/admin/feature/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-admin-feature + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-admin-feature` to execute the unit tests. diff --git a/libs/module-to-standalone/admin/feature/jest.config.ts b/libs/module-to-standalone/admin/feature/jest.config.ts new file mode 100644 index 0000000..547252e --- /dev/null +++ b/libs/module-to-standalone/admin/feature/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-admin-feature', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/admin/feature', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/admin/feature/project.json b/libs/module-to-standalone/admin/feature/project.json new file mode 100644 index 0000000..b63f6ca --- /dev/null +++ b/libs/module-to-standalone/admin/feature/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-admin-feature", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/admin/feature/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/admin/feature/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/admin/feature/**/*.ts", + "libs/module-to-standalone/admin/feature/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/admin/feature/src/index.ts b/libs/module-to-standalone/admin/feature/src/index.ts new file mode 100644 index 0000000..76c8330 --- /dev/null +++ b/libs/module-to-standalone/admin/feature/src/index.ts @@ -0,0 +1 @@ +export * from './lib/admin-feature.module'; diff --git a/libs/module-to-standalone/admin/feature/src/lib/admin-feature.module.ts b/libs/module-to-standalone/admin/feature/src/lib/admin-feature.module.ts new file mode 100644 index 0000000..6bdda1d --- /dev/null +++ b/libs/module-to-standalone/admin/feature/src/lib/admin-feature.module.ts @@ -0,0 +1,34 @@ +import { IsAuthorizedGuard } from '@angular-challenges/module-to-standalone/admin/shared'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@NgModule({ + declarations: [], + imports: [ + CommonModule, + RouterModule.forChild([ + { + path: '', + canActivate: [IsAuthorizedGuard], + children: [ + { + path: '', + loadChildren: () => + import('./dashboard/dashboard.component').then( + (m) => m.DashboardModule + ), + }, + { + path: 'create-user', + loadChildren: () => + import('./create-user/create-user.component').then( + (m) => m.CreateUserModule + ), + }, + ], + }, + ]), + ], +}) +export class AdminFeatureModule {} diff --git a/libs/module-to-standalone/admin/feature/src/lib/create-user/create-user.component.ts b/libs/module-to-standalone/admin/feature/src/lib/create-user/create-user.component.ts new file mode 100644 index 0000000..3f8076e --- /dev/null +++ b/libs/module-to-standalone/admin/feature/src/lib/create-user/create-user.component.ts @@ -0,0 +1,22 @@ +import { Component, NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@Component({ + selector: 'lib-create-user', + template: `Create User Form + + `, +}) +export class CreateUserComponent {} + +@NgModule({ + imports: [ + RouterModule.forChild([{ path: '', component: CreateUserComponent }]), + ], + declarations: [CreateUserComponent], +}) +export class CreateUserModule {} diff --git a/libs/module-to-standalone/admin/feature/src/lib/dashboard/dashboard.component.ts b/libs/module-to-standalone/admin/feature/src/lib/dashboard/dashboard.component.ts new file mode 100644 index 0000000..dbb2412 --- /dev/null +++ b/libs/module-to-standalone/admin/feature/src/lib/dashboard/dashboard.component.ts @@ -0,0 +1,22 @@ +import { Component, NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@Component({ + selector: 'lib-dashboard', + template: `Dashboard + + `, +}) +export class DashboardComponent {} + +@NgModule({ + imports: [ + RouterModule.forChild([{ path: '', component: DashboardComponent }]), + ], + declarations: [DashboardComponent], +}) +export class DashboardModule {} diff --git a/libs/module-to-standalone/admin/feature/src/test-setup.ts b/libs/module-to-standalone/admin/feature/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/admin/feature/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/admin/feature/tsconfig.json b/libs/module-to-standalone/admin/feature/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/admin/feature/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/admin/feature/tsconfig.lib.json b/libs/module-to-standalone/admin/feature/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/admin/feature/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/admin/feature/tsconfig.spec.json b/libs/module-to-standalone/admin/feature/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/admin/feature/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/admin/shared/.eslintrc.json b/libs/module-to-standalone/admin/shared/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/admin/shared/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/admin/shared/README.md b/libs/module-to-standalone/admin/shared/README.md new file mode 100644 index 0000000..7de0927 --- /dev/null +++ b/libs/module-to-standalone/admin/shared/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-admin-shared + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-admin-shared` to execute the unit tests. diff --git a/libs/module-to-standalone/admin/shared/jest.config.ts b/libs/module-to-standalone/admin/shared/jest.config.ts new file mode 100644 index 0000000..41e6691 --- /dev/null +++ b/libs/module-to-standalone/admin/shared/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-admin-shared', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/admin/shared', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/admin/shared/project.json b/libs/module-to-standalone/admin/shared/project.json new file mode 100644 index 0000000..fa81f8e --- /dev/null +++ b/libs/module-to-standalone/admin/shared/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-admin-shared", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/admin/shared/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/admin/shared/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/admin/shared/**/*.ts", + "libs/module-to-standalone/admin/shared/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/admin/shared/src/index.ts b/libs/module-to-standalone/admin/shared/src/index.ts new file mode 100644 index 0000000..21a285c --- /dev/null +++ b/libs/module-to-standalone/admin/shared/src/index.ts @@ -0,0 +1 @@ +export * from './lib/authorized.guard'; diff --git a/libs/module-to-standalone/admin/shared/src/lib/authorized.guard.ts b/libs/module-to-standalone/admin/shared/src/lib/authorized.guard.ts new file mode 100644 index 0000000..42b59ee --- /dev/null +++ b/libs/module-to-standalone/admin/shared/src/lib/authorized.guard.ts @@ -0,0 +1,23 @@ +import { CanActivate, Router, UrlTree } from '@angular/router'; + +import { AuthorizationService } from '@angular-challenges/module-to-standalone/core/service'; +import { Injectable } from '@angular/core'; +import { Observable, map } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class IsAuthorizedGuard implements CanActivate { + constructor( + private authorizationService: AuthorizationService, + private router: Router + ) {} + + canActivate(): Observable { + return this.authorizationService.isAuthorized$.pipe( + map((isAuthorized) => + isAuthorized ? true : this.router.createUrlTree(['forbidden']) + ) + ); + } +} diff --git a/libs/module-to-standalone/admin/shared/src/test-setup.ts b/libs/module-to-standalone/admin/shared/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/admin/shared/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/admin/shared/tsconfig.json b/libs/module-to-standalone/admin/shared/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/admin/shared/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/admin/shared/tsconfig.lib.json b/libs/module-to-standalone/admin/shared/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/admin/shared/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/admin/shared/tsconfig.spec.json b/libs/module-to-standalone/admin/shared/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/admin/shared/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/core/providers/.eslintrc.json b/libs/module-to-standalone/core/providers/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/core/providers/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/core/providers/README.md b/libs/module-to-standalone/core/providers/README.md new file mode 100644 index 0000000..e418186 --- /dev/null +++ b/libs/module-to-standalone/core/providers/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-core-providers + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-core-providers` to execute the unit tests. diff --git a/libs/module-to-standalone/core/providers/jest.config.ts b/libs/module-to-standalone/core/providers/jest.config.ts new file mode 100644 index 0000000..d7c3486 --- /dev/null +++ b/libs/module-to-standalone/core/providers/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-core-providers', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/core/providers', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/core/providers/ng-package.json b/libs/module-to-standalone/core/providers/ng-package.json new file mode 100644 index 0000000..d19cc55 --- /dev/null +++ b/libs/module-to-standalone/core/providers/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../../../dist/libs/module-to-standalone/core/providers", + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/libs/module-to-standalone/core/providers/package.json b/libs/module-to-standalone/core/providers/package.json new file mode 100644 index 0000000..82aac03 --- /dev/null +++ b/libs/module-to-standalone/core/providers/package.json @@ -0,0 +1,12 @@ +{ + "name": "@angular-challenges/module-to-standalone/core/providers", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^16.0.0", + "@angular/core": "^16.0.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "sideEffects": false +} diff --git a/libs/module-to-standalone/core/providers/project.json b/libs/module-to-standalone/core/providers/project.json new file mode 100644 index 0000000..75f41e8 --- /dev/null +++ b/libs/module-to-standalone/core/providers/project.json @@ -0,0 +1,50 @@ +{ + "name": "module-to-standalone-core-providers", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/core/providers/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/angular:ng-packagr-lite", + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], + "options": { + "project": "libs/module-to-standalone/core/providers/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "libs/module-to-standalone/core/providers/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "libs/module-to-standalone/core/providers/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/core/providers/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/core/providers/**/*.ts", + "libs/module-to-standalone/core/providers/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/core/providers/src/index.ts b/libs/module-to-standalone/core/providers/src/index.ts new file mode 100644 index 0000000..cf9fbaf --- /dev/null +++ b/libs/module-to-standalone/core/providers/src/index.ts @@ -0,0 +1 @@ +export * from './lib/token.provider'; diff --git a/libs/module-to-standalone/core/providers/src/lib/token.provider.ts b/libs/module-to-standalone/core/providers/src/lib/token.provider.ts new file mode 100644 index 0000000..3f498ee --- /dev/null +++ b/libs/module-to-standalone/core/providers/src/lib/token.provider.ts @@ -0,0 +1,16 @@ +import { + EnvironmentProviders, + InjectionToken, + makeEnvironmentProviders, +} from '@angular/core'; + +export const TOKEN = new InjectionToken('token'); + +export const provideToken = (token: string): EnvironmentProviders => { + return makeEnvironmentProviders([ + { + provide: TOKEN, + useValue: token, + }, + ]); +}; diff --git a/libs/module-to-standalone/core/providers/src/test-setup.ts b/libs/module-to-standalone/core/providers/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/core/providers/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/core/providers/tsconfig.json b/libs/module-to-standalone/core/providers/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/core/providers/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/core/providers/tsconfig.lib.json b/libs/module-to-standalone/core/providers/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/core/providers/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/core/providers/tsconfig.lib.prod.json b/libs/module-to-standalone/core/providers/tsconfig.lib.prod.json new file mode 100644 index 0000000..61b5237 --- /dev/null +++ b/libs/module-to-standalone/core/providers/tsconfig.lib.prod.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": {} +} diff --git a/libs/module-to-standalone/core/providers/tsconfig.spec.json b/libs/module-to-standalone/core/providers/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/core/providers/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/core/service/.eslintrc.json b/libs/module-to-standalone/core/service/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/core/service/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/core/service/README.md b/libs/module-to-standalone/core/service/README.md new file mode 100644 index 0000000..9f33e41 --- /dev/null +++ b/libs/module-to-standalone/core/service/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-core-service + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-core-service` to execute the unit tests. diff --git a/libs/module-to-standalone/core/service/jest.config.ts b/libs/module-to-standalone/core/service/jest.config.ts new file mode 100644 index 0000000..82808fc --- /dev/null +++ b/libs/module-to-standalone/core/service/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-core-service', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/core/service', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/core/service/project.json b/libs/module-to-standalone/core/service/project.json new file mode 100644 index 0000000..b12404e --- /dev/null +++ b/libs/module-to-standalone/core/service/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-core-service", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/core/service/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/core/service/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/core/service/**/*.ts", + "libs/module-to-standalone/core/service/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/core/service/src/index.ts b/libs/module-to-standalone/core/service/src/index.ts new file mode 100644 index 0000000..c964214 --- /dev/null +++ b/libs/module-to-standalone/core/service/src/index.ts @@ -0,0 +1 @@ +export * from './lib/authorization.service'; diff --git a/libs/module-to-standalone/core/service/src/lib/authorization.service.ts b/libs/module-to-standalone/core/service/src/lib/authorization.service.ts new file mode 100644 index 0000000..d991109 --- /dev/null +++ b/libs/module-to-standalone/core/service/src/lib/authorization.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject } from 'rxjs'; + +@Injectable({ providedIn: 'root' }) +export class AuthorizationService { + private isAuthorized = new BehaviorSubject(true); + isAuthorized$ = this.isAuthorized.asObservable(); + + authorize() { + this.isAuthorized.next(true); + } + + forbid() { + this.isAuthorized.next(false); + } +} diff --git a/libs/module-to-standalone/core/service/src/test-setup.ts b/libs/module-to-standalone/core/service/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/core/service/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/core/service/tsconfig.json b/libs/module-to-standalone/core/service/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/core/service/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/core/service/tsconfig.lib.json b/libs/module-to-standalone/core/service/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/core/service/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/core/service/tsconfig.spec.json b/libs/module-to-standalone/core/service/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/core/service/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/forbidden/.eslintrc.json b/libs/module-to-standalone/forbidden/.eslintrc.json new file mode 100644 index 0000000..56c12ac --- /dev/null +++ b/libs/module-to-standalone/forbidden/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/forbidden/README.md b/libs/module-to-standalone/forbidden/README.md new file mode 100644 index 0000000..0e06177 --- /dev/null +++ b/libs/module-to-standalone/forbidden/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-forbidden + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-forbidden` to execute the unit tests. diff --git a/libs/module-to-standalone/forbidden/jest.config.ts b/libs/module-to-standalone/forbidden/jest.config.ts new file mode 100644 index 0000000..7470436 --- /dev/null +++ b/libs/module-to-standalone/forbidden/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-forbidden', + preset: '../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: '../../../coverage/libs/module-to-standalone/forbidden', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/forbidden/project.json b/libs/module-to-standalone/forbidden/project.json new file mode 100644 index 0000000..3ac94e9 --- /dev/null +++ b/libs/module-to-standalone/forbidden/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-forbidden", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/forbidden/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/forbidden/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/forbidden/**/*.ts", + "libs/module-to-standalone/forbidden/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/forbidden/src/index.ts b/libs/module-to-standalone/forbidden/src/index.ts new file mode 100644 index 0000000..672622f --- /dev/null +++ b/libs/module-to-standalone/forbidden/src/index.ts @@ -0,0 +1 @@ +export * from './lib/forbidden.module'; diff --git a/libs/module-to-standalone/forbidden/src/lib/forbidden.component.ts b/libs/module-to-standalone/forbidden/src/lib/forbidden.component.ts new file mode 100644 index 0000000..18d6c2d --- /dev/null +++ b/libs/module-to-standalone/forbidden/src/lib/forbidden.component.ts @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'lib-home', + template: `Forbidden component`, +}) +export class ForbiddenComponent {} diff --git a/libs/module-to-standalone/forbidden/src/lib/forbidden.module.ts b/libs/module-to-standalone/forbidden/src/lib/forbidden.module.ts new file mode 100644 index 0000000..0b363bf --- /dev/null +++ b/libs/module-to-standalone/forbidden/src/lib/forbidden.module.ts @@ -0,0 +1,13 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { ForbiddenComponent } from './forbidden.component'; + +@NgModule({ + declarations: [ForbiddenComponent], + imports: [ + CommonModule, + RouterModule.forChild([{ path: '', component: ForbiddenComponent }]), + ], +}) +export class ForbiddenModule {} diff --git a/libs/module-to-standalone/forbidden/src/test-setup.ts b/libs/module-to-standalone/forbidden/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/forbidden/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/forbidden/tsconfig.json b/libs/module-to-standalone/forbidden/tsconfig.json new file mode 100644 index 0000000..5cf0a16 --- /dev/null +++ b/libs/module-to-standalone/forbidden/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/forbidden/tsconfig.lib.json b/libs/module-to-standalone/forbidden/tsconfig.lib.json new file mode 100644 index 0000000..9b49be7 --- /dev/null +++ b/libs/module-to-standalone/forbidden/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/forbidden/tsconfig.spec.json b/libs/module-to-standalone/forbidden/tsconfig.spec.json new file mode 100644 index 0000000..f858ef7 --- /dev/null +++ b/libs/module-to-standalone/forbidden/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/home/.eslintrc.json b/libs/module-to-standalone/home/.eslintrc.json new file mode 100644 index 0000000..56c12ac --- /dev/null +++ b/libs/module-to-standalone/home/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/home/README.md b/libs/module-to-standalone/home/README.md new file mode 100644 index 0000000..de075cc --- /dev/null +++ b/libs/module-to-standalone/home/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-home + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-home` to execute the unit tests. diff --git a/libs/module-to-standalone/home/jest.config.ts b/libs/module-to-standalone/home/jest.config.ts new file mode 100644 index 0000000..b4d6a04 --- /dev/null +++ b/libs/module-to-standalone/home/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-home', + preset: '../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: '../../../coverage/libs/module-to-standalone/home', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/home/project.json b/libs/module-to-standalone/home/project.json new file mode 100644 index 0000000..cec9d5b --- /dev/null +++ b/libs/module-to-standalone/home/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-home", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/home/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/home/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/home/**/*.ts", + "libs/module-to-standalone/home/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/home/src/index.ts b/libs/module-to-standalone/home/src/index.ts new file mode 100644 index 0000000..fe97ad5 --- /dev/null +++ b/libs/module-to-standalone/home/src/index.ts @@ -0,0 +1 @@ +export * from './lib/home.module'; diff --git a/libs/module-to-standalone/home/src/lib/home.component.ts b/libs/module-to-standalone/home/src/lib/home.component.ts new file mode 100644 index 0000000..7e5c6f3 --- /dev/null +++ b/libs/module-to-standalone/home/src/lib/home.component.ts @@ -0,0 +1,27 @@ +import { TOKEN } from '@angular-challenges/module-to-standalone/core/providers'; +import { AuthorizationService } from '@angular-challenges/module-to-standalone/core/service'; +import { Component, Inject } from '@angular/core'; + +@Component({ + selector: 'lib-home', + template: `Home component + +
+ Authorization : + + + (isAuthorized: {{ authorizeService.isAuthorized$ | async }}) +
+ +
LoadedToken {{ token }}
`, +}) +export class HomeComponent { + constructor( + public authorizeService: AuthorizationService, + @Inject(TOKEN) public token: string + ) {} +} diff --git a/libs/module-to-standalone/home/src/lib/home.module.ts b/libs/module-to-standalone/home/src/lib/home.module.ts new file mode 100644 index 0000000..30ae1ea --- /dev/null +++ b/libs/module-to-standalone/home/src/lib/home.module.ts @@ -0,0 +1,13 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { HomeComponent } from './home.component'; + +@NgModule({ + declarations: [HomeComponent], + imports: [ + RouterModule.forChild([{ path: '', component: HomeComponent }]), + CommonModule, + ], +}) +export class ModuleToStandaloneHomeModule {} diff --git a/libs/module-to-standalone/home/src/test-setup.ts b/libs/module-to-standalone/home/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/home/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/home/tsconfig.json b/libs/module-to-standalone/home/tsconfig.json new file mode 100644 index 0000000..5cf0a16 --- /dev/null +++ b/libs/module-to-standalone/home/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/home/tsconfig.lib.json b/libs/module-to-standalone/home/tsconfig.lib.json new file mode 100644 index 0000000..9b49be7 --- /dev/null +++ b/libs/module-to-standalone/home/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/home/tsconfig.spec.json b/libs/module-to-standalone/home/tsconfig.spec.json new file mode 100644 index 0000000..f858ef7 --- /dev/null +++ b/libs/module-to-standalone/home/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/shell/.eslintrc.json b/libs/module-to-standalone/shell/.eslintrc.json new file mode 100644 index 0000000..56c12ac --- /dev/null +++ b/libs/module-to-standalone/shell/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/shell/README.md b/libs/module-to-standalone/shell/README.md new file mode 100644 index 0000000..0fbe7e1 --- /dev/null +++ b/libs/module-to-standalone/shell/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-shell + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-shell` to execute the unit tests. diff --git a/libs/module-to-standalone/shell/jest.config.ts b/libs/module-to-standalone/shell/jest.config.ts new file mode 100644 index 0000000..ff53f23 --- /dev/null +++ b/libs/module-to-standalone/shell/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-shell', + preset: '../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: '../../../coverage/libs/module-to-standalone/shell', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/shell/project.json b/libs/module-to-standalone/shell/project.json new file mode 100644 index 0000000..75f9e5b --- /dev/null +++ b/libs/module-to-standalone/shell/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-shell", + "$schema": "../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/shell/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/shell/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/shell/**/*.ts", + "libs/module-to-standalone/shell/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/shell/src/index.ts b/libs/module-to-standalone/shell/src/index.ts new file mode 100644 index 0000000..494d409 --- /dev/null +++ b/libs/module-to-standalone/shell/src/index.ts @@ -0,0 +1 @@ +export * from './lib/main-shell.module'; diff --git a/libs/module-to-standalone/shell/src/lib/main-shell.module.ts b/libs/module-to-standalone/shell/src/lib/main-shell.module.ts new file mode 100644 index 0000000..e886da9 --- /dev/null +++ b/libs/module-to-standalone/shell/src/lib/main-shell.module.ts @@ -0,0 +1,11 @@ +import { provideToken } from '@angular-challenges/module-to-standalone/core/providers'; +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { appRoutes } from './main-shell.routes'; + +@NgModule({ + imports: [RouterModule.forRoot(appRoutes)], + exports: [RouterModule], + providers: [provideToken('main-shell-token')], +}) +export class MainShellModule {} diff --git a/libs/module-to-standalone/shell/src/lib/main-shell.routes.ts b/libs/module-to-standalone/shell/src/lib/main-shell.routes.ts new file mode 100644 index 0000000..8578fe8 --- /dev/null +++ b/libs/module-to-standalone/shell/src/lib/main-shell.routes.ts @@ -0,0 +1,34 @@ +import { Route } from '@angular/router'; + +export const appRoutes: Route[] = [ + { path: '', redirectTo: 'home', pathMatch: 'full' }, + { + path: 'home', + loadChildren: () => + import('@angular-challenges/module-to-standalone/home').then( + (m) => m.ModuleToStandaloneHomeModule + ), + }, + { + path: 'admin', + loadChildren: () => + import('@angular-challenges/module-to-standalone/admin/feature').then( + (m) => m.AdminFeatureModule + ), + }, + { + path: 'user', + loadChildren: () => + import('@angular-challenges/module-to-standalone/user/shell').then( + (m) => m.UserShellModule + ), + }, + + { + path: 'forbidden', + loadChildren: () => + import('@angular-challenges/module-to-standalone/forbidden').then( + (m) => m.ForbiddenModule + ), + }, +]; diff --git a/libs/module-to-standalone/shell/src/test-setup.ts b/libs/module-to-standalone/shell/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/shell/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/shell/tsconfig.json b/libs/module-to-standalone/shell/tsconfig.json new file mode 100644 index 0000000..5cf0a16 --- /dev/null +++ b/libs/module-to-standalone/shell/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/shell/tsconfig.lib.json b/libs/module-to-standalone/shell/tsconfig.lib.json new file mode 100644 index 0000000..9b49be7 --- /dev/null +++ b/libs/module-to-standalone/shell/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/shell/tsconfig.spec.json b/libs/module-to-standalone/shell/tsconfig.spec.json new file mode 100644 index 0000000..f858ef7 --- /dev/null +++ b/libs/module-to-standalone/shell/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/user/contact/.eslintrc.json b/libs/module-to-standalone/user/contact/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/user/contact/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/user/contact/README.md b/libs/module-to-standalone/user/contact/README.md new file mode 100644 index 0000000..bf29f85 --- /dev/null +++ b/libs/module-to-standalone/user/contact/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-user-contact + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-user-contact` to execute the unit tests. diff --git a/libs/module-to-standalone/user/contact/jest.config.ts b/libs/module-to-standalone/user/contact/jest.config.ts new file mode 100644 index 0000000..c6402b9 --- /dev/null +++ b/libs/module-to-standalone/user/contact/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-user-contact', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/user/contact', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/user/contact/ng-package.json b/libs/module-to-standalone/user/contact/ng-package.json new file mode 100644 index 0000000..e24aaa0 --- /dev/null +++ b/libs/module-to-standalone/user/contact/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../../../dist/libs/module-to-standalone/user/contact", + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/libs/module-to-standalone/user/contact/package.json b/libs/module-to-standalone/user/contact/package.json new file mode 100644 index 0000000..c69df7c --- /dev/null +++ b/libs/module-to-standalone/user/contact/package.json @@ -0,0 +1,12 @@ +{ + "name": "@angular-challenges/module-to-standalone/user/contact", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^16.0.0", + "@angular/core": "^16.0.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "sideEffects": false +} diff --git a/libs/module-to-standalone/user/contact/project.json b/libs/module-to-standalone/user/contact/project.json new file mode 100644 index 0000000..eb6e5e7 --- /dev/null +++ b/libs/module-to-standalone/user/contact/project.json @@ -0,0 +1,50 @@ +{ + "name": "module-to-standalone-user-contact", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/user/contact/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/angular:ng-packagr-lite", + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], + "options": { + "project": "libs/module-to-standalone/user/contact/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "libs/module-to-standalone/user/contact/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "libs/module-to-standalone/user/contact/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/user/contact/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/user/contact/**/*.ts", + "libs/module-to-standalone/user/contact/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/user/contact/src/index.ts b/libs/module-to-standalone/user/contact/src/index.ts new file mode 100644 index 0000000..8561ea5 --- /dev/null +++ b/libs/module-to-standalone/user/contact/src/index.ts @@ -0,0 +1 @@ +export * from './lib/contact-feature.module'; diff --git a/libs/module-to-standalone/user/contact/src/lib/contact-feature.module.ts b/libs/module-to-standalone/user/contact/src/lib/contact-feature.module.ts new file mode 100644 index 0000000..70a4726 --- /dev/null +++ b/libs/module-to-standalone/user/contact/src/lib/contact-feature.module.ts @@ -0,0 +1,27 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@NgModule({ + declarations: [], + imports: [ + CommonModule, + RouterModule.forChild([ + { + path: '', + loadChildren: () => + import('./dashboard/dashboard.component').then( + (m) => m.ContactDashboardModule + ), + }, + { + path: 'create-contact', + loadChildren: () => + import('./create-contact/create-contact.component').then( + (m) => m.CreateContactModule + ), + }, + ]), + ], +}) +export class ContactFeatureModule {} diff --git a/libs/module-to-standalone/user/contact/src/lib/create-contact/create-contact.component.ts b/libs/module-to-standalone/user/contact/src/lib/create-contact/create-contact.component.ts new file mode 100644 index 0000000..ffd2389 --- /dev/null +++ b/libs/module-to-standalone/user/contact/src/lib/create-contact/create-contact.component.ts @@ -0,0 +1,22 @@ +import { Component, NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@Component({ + selector: 'lib-create-contact', + template: `Create Contact Form + + `, +}) +export class CreateContactComponent {} + +@NgModule({ + imports: [ + RouterModule.forChild([{ path: '', component: CreateContactComponent }]), + ], + declarations: [CreateContactComponent], +}) +export class CreateContactModule {} diff --git a/libs/module-to-standalone/user/contact/src/lib/dashboard/dashboard.component.ts b/libs/module-to-standalone/user/contact/src/lib/dashboard/dashboard.component.ts new file mode 100644 index 0000000..3d6a81b --- /dev/null +++ b/libs/module-to-standalone/user/contact/src/lib/dashboard/dashboard.component.ts @@ -0,0 +1,22 @@ +import { Component, NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +@Component({ + selector: 'lib-contact-dashboard', + template: `Contact Dashboard + + `, +}) +export class ContactDashboardComponent {} + +@NgModule({ + imports: [ + RouterModule.forChild([{ path: '', component: ContactDashboardComponent }]), + ], + declarations: [ContactDashboardComponent], +}) +export class ContactDashboardModule {} diff --git a/libs/module-to-standalone/user/contact/src/test-setup.ts b/libs/module-to-standalone/user/contact/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/user/contact/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/user/contact/tsconfig.json b/libs/module-to-standalone/user/contact/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/user/contact/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/user/contact/tsconfig.lib.json b/libs/module-to-standalone/user/contact/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/user/contact/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/user/contact/tsconfig.lib.prod.json b/libs/module-to-standalone/user/contact/tsconfig.lib.prod.json new file mode 100644 index 0000000..61b5237 --- /dev/null +++ b/libs/module-to-standalone/user/contact/tsconfig.lib.prod.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": {} +} diff --git a/libs/module-to-standalone/user/contact/tsconfig.spec.json b/libs/module-to-standalone/user/contact/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/user/contact/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/user/feature/.eslintrc.json b/libs/module-to-standalone/user/feature/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/user/feature/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/user/feature/README.md b/libs/module-to-standalone/user/feature/README.md new file mode 100644 index 0000000..c4cb490 --- /dev/null +++ b/libs/module-to-standalone/user/feature/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-user-feature + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-user-feature` to execute the unit tests. diff --git a/libs/module-to-standalone/user/feature/jest.config.ts b/libs/module-to-standalone/user/feature/jest.config.ts new file mode 100644 index 0000000..1103896 --- /dev/null +++ b/libs/module-to-standalone/user/feature/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-user-feature', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/user/feature', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/user/feature/ng-package.json b/libs/module-to-standalone/user/feature/ng-package.json new file mode 100644 index 0000000..6d7af66 --- /dev/null +++ b/libs/module-to-standalone/user/feature/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../../../dist/libs/module-to-standalone/user/feature", + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/libs/module-to-standalone/user/feature/package.json b/libs/module-to-standalone/user/feature/package.json new file mode 100644 index 0000000..342ede2 --- /dev/null +++ b/libs/module-to-standalone/user/feature/package.json @@ -0,0 +1,12 @@ +{ + "name": "@angular-challenges/module-to-standalone/user/feature", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^16.0.0", + "@angular/core": "^16.0.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "sideEffects": false +} diff --git a/libs/module-to-standalone/user/feature/project.json b/libs/module-to-standalone/user/feature/project.json new file mode 100644 index 0000000..2f1f3f7 --- /dev/null +++ b/libs/module-to-standalone/user/feature/project.json @@ -0,0 +1,50 @@ +{ + "name": "module-to-standalone-user-feature", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/user/feature/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/angular:ng-packagr-lite", + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], + "options": { + "project": "libs/module-to-standalone/user/feature/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "libs/module-to-standalone/user/feature/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "libs/module-to-standalone/user/feature/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/user/feature/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/user/feature/**/*.ts", + "libs/module-to-standalone/user/feature/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/user/feature/src/index.ts b/libs/module-to-standalone/user/feature/src/index.ts new file mode 100644 index 0000000..9efe9ca --- /dev/null +++ b/libs/module-to-standalone/user/feature/src/index.ts @@ -0,0 +1,4 @@ +export * from './lib/module-to-standalone-user-feature.module'; +export * from './lib/lib.routes'; + +export * from './lib/lib.routes'; diff --git a/libs/module-to-standalone/user/feature/src/lib/lib.routes.ts b/libs/module-to-standalone/user/feature/src/lib/lib.routes.ts new file mode 100644 index 0000000..5652435 --- /dev/null +++ b/libs/module-to-standalone/user/feature/src/lib/lib.routes.ts @@ -0,0 +1,3 @@ +import { Route } from '@angular/router'; + +export const moduleToStandaloneUserFeatureRoutes: Route[] = []; diff --git a/libs/module-to-standalone/user/feature/src/lib/module-to-standalone-user-feature.module.ts b/libs/module-to-standalone/user/feature/src/lib/module-to-standalone-user-feature.module.ts new file mode 100644 index 0000000..9dc3f4c --- /dev/null +++ b/libs/module-to-standalone/user/feature/src/lib/module-to-standalone-user-feature.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { RouterModule, RouterModule, Route } from '@angular/router'; +import { moduleToStandaloneUserFeatureRoutes } from './lib.routes'; + +@NgModule({ + imports: [ + CommonModule, + RouterModule.forChild(moduleToStandaloneUserFeatureRoutes), + RouterModule, + ], +}) +export class ModuleToStandaloneUserFeatureModule {} diff --git a/libs/module-to-standalone/user/feature/src/test-setup.ts b/libs/module-to-standalone/user/feature/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/user/feature/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/user/feature/tsconfig.json b/libs/module-to-standalone/user/feature/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/user/feature/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/user/feature/tsconfig.lib.json b/libs/module-to-standalone/user/feature/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/user/feature/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/user/feature/tsconfig.lib.prod.json b/libs/module-to-standalone/user/feature/tsconfig.lib.prod.json new file mode 100644 index 0000000..61b5237 --- /dev/null +++ b/libs/module-to-standalone/user/feature/tsconfig.lib.prod.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": {} +} diff --git a/libs/module-to-standalone/user/feature/tsconfig.spec.json b/libs/module-to-standalone/user/feature/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/user/feature/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/user/home/.eslintrc.json b/libs/module-to-standalone/user/home/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/user/home/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/user/home/README.md b/libs/module-to-standalone/user/home/README.md new file mode 100644 index 0000000..8c06694 --- /dev/null +++ b/libs/module-to-standalone/user/home/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-user-home + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-user-home` to execute the unit tests. diff --git a/libs/module-to-standalone/user/home/jest.config.ts b/libs/module-to-standalone/user/home/jest.config.ts new file mode 100644 index 0000000..90ae704 --- /dev/null +++ b/libs/module-to-standalone/user/home/jest.config.ts @@ -0,0 +1,22 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-user-home', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: '../../../../coverage/libs/module-to-standalone/user/home', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/user/home/project.json b/libs/module-to-standalone/user/home/project.json new file mode 100644 index 0000000..503e50a --- /dev/null +++ b/libs/module-to-standalone/user/home/project.json @@ -0,0 +1,34 @@ +{ + "name": "module-to-standalone-user-home", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/user/home/src", + "prefix": "angular-challenges", + "tags": [], + "projectType": "library", + "targets": { + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/user/home/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/user/home/**/*.ts", + "libs/module-to-standalone/user/home/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/user/home/src/index.ts b/libs/module-to-standalone/user/home/src/index.ts new file mode 100644 index 0000000..fe97ad5 --- /dev/null +++ b/libs/module-to-standalone/user/home/src/index.ts @@ -0,0 +1 @@ +export * from './lib/home.module'; diff --git a/libs/module-to-standalone/user/home/src/lib/home.component.ts b/libs/module-to-standalone/user/home/src/lib/home.component.ts new file mode 100644 index 0000000..8e2bf7b --- /dev/null +++ b/libs/module-to-standalone/user/home/src/lib/home.component.ts @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'lib-user-home', + template: `User Home component`, +}) +export class UserHomeComponent {} diff --git a/libs/module-to-standalone/user/home/src/lib/home.module.ts b/libs/module-to-standalone/user/home/src/lib/home.module.ts new file mode 100644 index 0000000..ceeb495 --- /dev/null +++ b/libs/module-to-standalone/user/home/src/lib/home.module.ts @@ -0,0 +1,11 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { UserHomeComponent } from './home.component'; + +@NgModule({ + declarations: [UserHomeComponent], + imports: [ + RouterModule.forChild([{ path: '', component: UserHomeComponent }]), + ], +}) +export class UserHomeModule {} diff --git a/libs/module-to-standalone/user/home/src/test-setup.ts b/libs/module-to-standalone/user/home/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/user/home/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/user/home/tsconfig.json b/libs/module-to-standalone/user/home/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/user/home/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/user/home/tsconfig.lib.json b/libs/module-to-standalone/user/home/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/user/home/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/user/home/tsconfig.spec.json b/libs/module-to-standalone/user/home/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/user/home/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/module-to-standalone/user/shell/.eslintrc.json b/libs/module-to-standalone/user/shell/.eslintrc.json new file mode 100644 index 0000000..b597630 --- /dev/null +++ b/libs/module-to-standalone/user/shell/.eslintrc.json @@ -0,0 +1,36 @@ +{ + "extends": ["../../../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "lib", + "style": "camelCase" + } + ], + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "lib", + "style": "kebab-case" + } + ] + }, + "extends": [ + "plugin:@nx/angular", + "plugin:@angular-eslint/template/process-inline-templates" + ] + }, + { + "files": ["*.html"], + "extends": ["plugin:@nx/angular-template"], + "rules": {} + } + ] +} diff --git a/libs/module-to-standalone/user/shell/README.md b/libs/module-to-standalone/user/shell/README.md new file mode 100644 index 0000000..21158e3 --- /dev/null +++ b/libs/module-to-standalone/user/shell/README.md @@ -0,0 +1,7 @@ +# module-to-standalone-user-shell + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test module-to-standalone-user-shell` to execute the unit tests. diff --git a/libs/module-to-standalone/user/shell/jest.config.ts b/libs/module-to-standalone/user/shell/jest.config.ts new file mode 100644 index 0000000..74a019b --- /dev/null +++ b/libs/module-to-standalone/user/shell/jest.config.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +export default { + displayName: 'module-to-standalone-user-shell', + preset: '../../../../jest.preset.js', + setupFilesAfterEnv: ['/src/test-setup.ts'], + coverageDirectory: + '../../../../coverage/libs/module-to-standalone/user/shell', + transform: { + '^.+\\.(ts|mjs|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/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', + ], +}; diff --git a/libs/module-to-standalone/user/shell/ng-package.json b/libs/module-to-standalone/user/shell/ng-package.json new file mode 100644 index 0000000..04ce729 --- /dev/null +++ b/libs/module-to-standalone/user/shell/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../../../dist/libs/module-to-standalone/user/shell", + "lib": { + "entryFile": "src/index.ts" + } +} diff --git a/libs/module-to-standalone/user/shell/package.json b/libs/module-to-standalone/user/shell/package.json new file mode 100644 index 0000000..a6e33c6 --- /dev/null +++ b/libs/module-to-standalone/user/shell/package.json @@ -0,0 +1,12 @@ +{ + "name": "@angular-challenges/module-to-standalone/user/shell", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^16.0.0", + "@angular/core": "^16.0.0" + }, + "dependencies": { + "tslib": "^2.3.0" + }, + "sideEffects": false +} diff --git a/libs/module-to-standalone/user/shell/project.json b/libs/module-to-standalone/user/shell/project.json new file mode 100644 index 0000000..a1a5bd2 --- /dev/null +++ b/libs/module-to-standalone/user/shell/project.json @@ -0,0 +1,50 @@ +{ + "name": "module-to-standalone-user-shell", + "$schema": "../../../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/module-to-standalone/user/shell/src", + "prefix": "lib", + "tags": [], + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/angular:ng-packagr-lite", + "outputs": ["{workspaceRoot}/dist/{projectRoot}"], + "options": { + "project": "libs/module-to-standalone/user/shell/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "libs/module-to-standalone/user/shell/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "libs/module-to-standalone/user/shell/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "libs/module-to-standalone/user/shell/jest.config.ts", + "passWithNoTests": true + }, + "configurations": { + "ci": { + "ci": true, + "codeCoverage": true + } + } + }, + "lint": { + "executor": "@nx/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": [ + "libs/module-to-standalone/user/shell/**/*.ts", + "libs/module-to-standalone/user/shell/**/*.html" + ] + } + } + } +} diff --git a/libs/module-to-standalone/user/shell/src/index.ts b/libs/module-to-standalone/user/shell/src/index.ts new file mode 100644 index 0000000..641fd68 --- /dev/null +++ b/libs/module-to-standalone/user/shell/src/index.ts @@ -0,0 +1 @@ +export * from './lib/user-shell.module'; diff --git a/libs/module-to-standalone/user/shell/src/lib/user-shell.component.ts b/libs/module-to-standalone/user/shell/src/lib/user-shell.component.ts new file mode 100644 index 0000000..2c106ba --- /dev/null +++ b/libs/module-to-standalone/user/shell/src/lib/user-shell.component.ts @@ -0,0 +1,33 @@ +import { TOKEN } from '@angular-challenges/module-to-standalone/core/providers'; +import { Component, Inject } from '@angular/core'; + +@Component({ + selector: 'lib-user-shell', + template: ` + -- User Panel -- +
+ + + More buttons ... +
+ +
+ LoadedToken + {{ token }} +
+ `, + host: { + class: 'flex flex-col p-4 gap-3 border border-blue', + }, +}) +export class UserShellComponent { + constructor(@Inject(TOKEN) public token: string) {} +} diff --git a/libs/module-to-standalone/user/shell/src/lib/user-shell.module.ts b/libs/module-to-standalone/user/shell/src/lib/user-shell.module.ts new file mode 100644 index 0000000..433d6f7 --- /dev/null +++ b/libs/module-to-standalone/user/shell/src/lib/user-shell.module.ts @@ -0,0 +1,13 @@ +import { provideToken } from '@angular-challenges/module-to-standalone/core/providers'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { UserShellComponent } from './user-shell.component'; +import { userShellRoutes } from './user-shell.routes'; + +@NgModule({ + imports: [CommonModule, RouterModule.forChild(userShellRoutes), RouterModule], + declarations: [UserShellComponent], + providers: [provideToken('user-token')], +}) +export class UserShellModule {} diff --git a/libs/module-to-standalone/user/shell/src/lib/user-shell.routes.ts b/libs/module-to-standalone/user/shell/src/lib/user-shell.routes.ts new file mode 100644 index 0000000..4363686 --- /dev/null +++ b/libs/module-to-standalone/user/shell/src/lib/user-shell.routes.ts @@ -0,0 +1,26 @@ +import { Route } from '@angular/router'; +import { UserShellComponent } from './user-shell.component'; + +export const userShellRoutes: Route[] = [ + { + path: '', + component: UserShellComponent, + children: [ + { path: '', redirectTo: 'home', pathMatch: 'full' }, + { + path: 'home', + loadChildren: () => + import('@angular-challenges/module-to-standalone/user/home').then( + (m) => m.UserHomeModule + ), + }, + { + path: 'contact', + loadChildren: () => + import('@angular-challenges/module-to-standalone/user/contact').then( + (m) => m.ContactFeatureModule + ), + }, + ], + }, +]; diff --git a/libs/module-to-standalone/user/shell/src/test-setup.ts b/libs/module-to-standalone/user/shell/src/test-setup.ts new file mode 100644 index 0000000..ab1eeeb --- /dev/null +++ b/libs/module-to-standalone/user/shell/src/test-setup.ts @@ -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'; diff --git a/libs/module-to-standalone/user/shell/tsconfig.json b/libs/module-to-standalone/user/shell/tsconfig.json new file mode 100644 index 0000000..b9e5be0 --- /dev/null +++ b/libs/module-to-standalone/user/shell/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "es2022", + "useDefineForClassFields": false, + "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 + } +} diff --git a/libs/module-to-standalone/user/shell/tsconfig.lib.json b/libs/module-to-standalone/user/shell/tsconfig.lib.json new file mode 100644 index 0000000..9127387 --- /dev/null +++ b/libs/module-to-standalone/user/shell/tsconfig.lib.json @@ -0,0 +1,17 @@ +{ + "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"] +} diff --git a/libs/module-to-standalone/user/shell/tsconfig.lib.prod.json b/libs/module-to-standalone/user/shell/tsconfig.lib.prod.json new file mode 100644 index 0000000..61b5237 --- /dev/null +++ b/libs/module-to-standalone/user/shell/tsconfig.lib.prod.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.lib.json", + "compilerOptions": { + "declarationMap": false + }, + "angularCompilerOptions": {} +} diff --git a/libs/module-to-standalone/user/shell/tsconfig.spec.json b/libs/module-to-standalone/user/shell/tsconfig.spec.json new file mode 100644 index 0000000..6e5925e --- /dev/null +++ b/libs/module-to-standalone/user/shell/tsconfig.spec.json @@ -0,0 +1,16 @@ +{ + "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" + ] +} diff --git a/libs/ngrx-notification/backend/.eslintrc.json b/libs/ngrx-notification/backend/.eslintrc.json index 81d0f0e..9247a6e 100644 --- a/libs/ngrx-notification/backend/.eslintrc.json +++ b/libs/ngrx-notification/backend/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "angularChallenges", + "prefix": "lib", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "angular-challenges", + "prefix": "lib", "style": "kebab-case" } ] diff --git a/libs/ngrx-notification/backend/project.json b/libs/ngrx-notification/backend/project.json index cc0546f..f2da523 100644 --- a/libs/ngrx-notification/backend/project.json +++ b/libs/ngrx-notification/backend/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "library", "sourceRoot": "libs/ngrx-notification/backend/src", - "prefix": "angular-challenges", + "prefix": "lib", "targets": { "test": { "executor": "@nx/jest:jest", diff --git a/libs/ngrx-notification/model/.eslintrc.json b/libs/ngrx-notification/model/.eslintrc.json index 81d0f0e..9247a6e 100644 --- a/libs/ngrx-notification/model/.eslintrc.json +++ b/libs/ngrx-notification/model/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "angularChallenges", + "prefix": "lib", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "angular-challenges", + "prefix": "lib", "style": "kebab-case" } ] diff --git a/libs/ngrx-notification/model/project.json b/libs/ngrx-notification/model/project.json index 9fa6ae2..21ac400 100644 --- a/libs/ngrx-notification/model/project.json +++ b/libs/ngrx-notification/model/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "library", "sourceRoot": "libs/ngrx-notification/model/src", - "prefix": "angular-challenges", + "prefix": "lib", "targets": { "test": { "executor": "@nx/jest:jest", diff --git a/libs/shared/ngrx-callstate-store/.eslintrc.json b/libs/shared/ngrx-callstate-store/.eslintrc.json index 81d0f0e..9247a6e 100644 --- a/libs/shared/ngrx-callstate-store/.eslintrc.json +++ b/libs/shared/ngrx-callstate-store/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "angularChallenges", + "prefix": "lib", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "angular-challenges", + "prefix": "lib", "style": "kebab-case" } ] diff --git a/libs/shared/ngrx-callstate-store/project.json b/libs/shared/ngrx-callstate-store/project.json index a5e31f0..b9fc884 100644 --- a/libs/shared/ngrx-callstate-store/project.json +++ b/libs/shared/ngrx-callstate-store/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "library", "sourceRoot": "libs/shared/ngrx-callstate-store/src", - "prefix": "angular-challenges", + "prefix": "lib", "targets": { "build": { "executor": "@nx/angular:package", diff --git a/libs/shared/utils/.eslintrc.json b/libs/shared/utils/.eslintrc.json index 817727b..56c12ac 100644 --- a/libs/shared/utils/.eslintrc.json +++ b/libs/shared/utils/.eslintrc.json @@ -9,7 +9,7 @@ "error", { "type": "attribute", - "prefix": "angularChallenges", + "prefix": "lib", "style": "camelCase" } ], @@ -17,7 +17,7 @@ "error", { "type": "element", - "prefix": "angular-challenges", + "prefix": "lib", "style": "kebab-case" } ] diff --git a/libs/shared/utils/project.json b/libs/shared/utils/project.json index dc069e1..760636f 100644 --- a/libs/shared/utils/project.json +++ b/libs/shared/utils/project.json @@ -3,7 +3,7 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "projectType": "library", "sourceRoot": "libs/shared/utils/src", - "prefix": "angular-challenges", + "prefix": "lib", "targets": { "test": { "executor": "@nx/jest:jest", diff --git a/libs/testing-table/backend/.eslintrc.json b/libs/testing-table/backend/.eslintrc.json index 817727b..56c12ac 100644 --- a/libs/testing-table/backend/.eslintrc.json +++ b/libs/testing-table/backend/.eslintrc.json @@ -9,7 +9,7 @@ "error", { "type": "attribute", - "prefix": "angularChallenges", + "prefix": "lib", "style": "camelCase" } ], @@ -17,7 +17,7 @@ "error", { "type": "element", - "prefix": "angular-challenges", + "prefix": "lib", "style": "kebab-case" } ] diff --git a/libs/testing-table/backend/project.json b/libs/testing-table/backend/project.json index d35d0dc..3bc8250 100644 --- a/libs/testing-table/backend/project.json +++ b/libs/testing-table/backend/project.json @@ -2,7 +2,7 @@ "name": "testing-table-backend", "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "libs/testing-table/backend/src", - "prefix": "angular-challenges", + "prefix": "lib", "tags": [], "projectType": "library", "targets": { diff --git a/libs/testing-table/model/project.json b/libs/testing-table/model/project.json index 621922c..3097ca0 100644 --- a/libs/testing-table/model/project.json +++ b/libs/testing-table/model/project.json @@ -2,7 +2,7 @@ "name": "testing-table-model", "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "libs/testing-table/model/src", - "prefix": "angular-challenges", + "prefix": "lib", "tags": [], "projectType": "library", "targets": {} diff --git a/nx.json b/nx.json index 50d7377..3a2294b 100644 --- a/nx.json +++ b/nx.json @@ -64,7 +64,9 @@ }, "@nx/angular:library": { "linter": "eslint", - "unitTestRunner": "jest" + "unitTestRunner": "jest", + "prefix": "lib", + "buildable": "true" }, "@nx/angular:component": { "style": "scss", diff --git a/package-lock.json b/package-lock.json index eb9d13f..ffb2232 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,7 +85,7 @@ "jest-preset-angular": "13.1.1", "jsonc-eslint-parser": "^2.1.0", "lint-staged": "^13.0.3", - "ng-packagr": "16.0.1", + "ng-packagr": "~16.0.0", "nx": "16.2.1", "postcss": "^8.4.5", "postcss-import": "~14.1.0", diff --git a/package.json b/package.json index 3b00e06..78852f5 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "jest-preset-angular": "13.1.1", "jsonc-eslint-parser": "^2.1.0", "lint-staged": "^13.0.3", - "ng-packagr": "16.0.1", + "ng-packagr": "~16.0.0", "nx": "16.2.1", "postcss": "^8.4.5", "postcss-import": "~14.1.0", diff --git a/tsconfig.base.json b/tsconfig.base.json index 17b5ccd..5bbf124 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -16,6 +16,39 @@ "baseUrl": ".", "paths": { "@angular-challenges/cli": ["libs/cli/src/index.ts"], + "@angular-challenges/module-to-standalone/admin/feature": [ + "libs/module-to-standalone/admin/feature/src/index.ts" + ], + "@angular-challenges/module-to-standalone/admin/shared": [ + "libs/module-to-standalone/admin/shared/src/index.ts" + ], + "@angular-challenges/module-to-standalone/core/providers": [ + "libs/module-to-standalone/core/providers/src/index.ts" + ], + "@angular-challenges/module-to-standalone/core/service": [ + "libs/module-to-standalone/core/service/src/index.ts" + ], + "@angular-challenges/module-to-standalone/forbidden": [ + "libs/module-to-standalone/forbidden/src/index.ts" + ], + "@angular-challenges/module-to-standalone/home": [ + "libs/module-to-standalone/home/src/index.ts" + ], + "@angular-challenges/module-to-standalone/shell": [ + "libs/module-to-standalone/shell/src/index.ts" + ], + "@angular-challenges/module-to-standalone/user/contact": [ + "libs/module-to-standalone/user/contact/src/index.ts" + ], + "@angular-challenges/module-to-standalone/user/feature": [ + "libs/module-to-standalone/user/feature/src/index.ts" + ], + "@angular-challenges/module-to-standalone/user/home": [ + "libs/module-to-standalone/user/home/src/index.ts" + ], + "@angular-challenges/module-to-standalone/user/shell": [ + "libs/module-to-standalone/user/shell/src/index.ts" + ], "@angular-challenges/ngrx-notification/backend": [ "libs/ngrx-notification/backend/src/index.ts" ],