@ihk-gfi/lux-components-update 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/LICENSE +198 -0
  2. package/README.md +55 -0
  3. package/package.json +54 -0
  4. package/src/add-lux-components/files/app/app-routing.module.ts +19 -0
  5. package/src/add-lux-components/files/app/app.component.html +27 -0
  6. package/src/add-lux-components/files/app/app.component.spec.ts +19 -0
  7. package/src/add-lux-components/files/app/app.component.ts +13 -0
  8. package/src/add-lux-components/files/app/app.module.ts +56 -0
  9. package/src/add-lux-components/files/app/error/error.component.html +10 -0
  10. package/src/add-lux-components/files/app/error/error.component.scss +3 -0
  11. package/src/add-lux-components/files/app/error/error.component.spec.ts +49 -0
  12. package/src/add-lux-components/files/app/error/error.component.ts +17 -0
  13. package/src/add-lux-components/files/app/home/home.component.html +7 -0
  14. package/src/add-lux-components/files/app/home/home.component.scss +0 -0
  15. package/src/add-lux-components/files/app/home/home.component.ts +13 -0
  16. package/src/add-lux-components/files/app/profil/profil.component.html +1 -0
  17. package/src/add-lux-components/files/app/profil/profil.component.scss +0 -0
  18. package/src/add-lux-components/files/app/profil/profil.component.spec.ts +24 -0
  19. package/src/add-lux-components/files/app/profil/profil.component.ts +11 -0
  20. package/src/add-lux-components/files/environments/environment.prod.ts +4 -0
  21. package/src/add-lux-components/files/environments/environment.ts +17 -0
  22. package/src/add-lux-components/files/locale/messages.en.xlf +948 -0
  23. package/src/add-lux-components/files/locale/messages.xlf +822 -0
  24. package/src/add-lux-components/files/scripts/.browserslistrc +17 -0
  25. package/src/add-lux-components/files/src/polyfills.ts +68 -0
  26. package/src/add-lux-components/index.d.ts +10 -0
  27. package/src/add-lux-components/index.js +143 -0
  28. package/src/add-lux-components/index.js.map +1 -0
  29. package/src/add-lux-components/index.ts +183 -0
  30. package/src/add-lux-components/index_spec.d.ts +1 -0
  31. package/src/add-lux-components/index_spec.js +51 -0
  32. package/src/add-lux-components/index_spec.js.map +1 -0
  33. package/src/add-lux-components/index_spec.ts +55 -0
  34. package/src/add-lux-components/schema.json +23 -0
  35. package/src/collection.json +55 -0
  36. package/src/migrate-to-eslint/files/.eslintrc.json +68 -0
  37. package/src/migrate-to-eslint/files/.prettierrc +25 -0
  38. package/src/migrate-to-eslint/index.d.ts +6 -0
  39. package/src/migrate-to-eslint/index.js +149 -0
  40. package/src/migrate-to-eslint/index.js.map +1 -0
  41. package/src/migrate-to-eslint/index.ts +181 -0
  42. package/src/migrate-to-eslint/index_spec.d.ts +1 -0
  43. package/src/migrate-to-eslint/index_spec.js +129 -0
  44. package/src/migrate-to-eslint/index_spec.js.map +1 -0
  45. package/src/migrate-to-eslint/index_spec.ts +152 -0
  46. package/src/migrate-to-eslint/schema.json +23 -0
  47. package/src/migrate-to-webcomponent/index.d.ts +10 -0
  48. package/src/migrate-to-webcomponent/index.js +278 -0
  49. package/src/migrate-to-webcomponent/index.js.map +1 -0
  50. package/src/migrate-to-webcomponent/index.ts +331 -0
  51. package/src/migrate-to-webcomponent/index_spec.d.ts +1 -0
  52. package/src/migrate-to-webcomponent/index_spec.js +580 -0
  53. package/src/migrate-to-webcomponent/index_spec.js.map +1 -0
  54. package/src/migrate-to-webcomponent/index_spec.ts +703 -0
  55. package/src/migrate-to-webcomponent/schema.json +23 -0
  56. package/src/update/files/locale/messages.en.xlf +940 -0
  57. package/src/update/files/locale/messages.xlf +815 -0
  58. package/src/update/files/scripts/move-de-files.js +15 -0
  59. package/src/update/index.d.ts +23 -0
  60. package/src/update/index.js +635 -0
  61. package/src/update/index.js.map +1 -0
  62. package/src/update/index.ts +712 -0
  63. package/src/update/index_spec.d.ts +1 -0
  64. package/src/update/index_spec.js +990 -0
  65. package/src/update/index_spec.js.map +1 -0
  66. package/src/update/index_spec.ts +1145 -0
  67. package/src/update/schema.json +23 -0
  68. package/src/update-dependencies/index.d.ts +5 -0
  69. package/src/update-dependencies/index.js +113 -0
  70. package/src/update-dependencies/index.js.map +1 -0
  71. package/src/update-dependencies/index.ts +114 -0
  72. package/src/update-dependencies/schema.json +23 -0
  73. package/src/update110001/index.d.ts +2 -0
  74. package/src/update110001/index.js +42 -0
  75. package/src/update110001/index.js.map +1 -0
  76. package/src/update110001/index.ts +40 -0
  77. package/src/update110001/index_spec.d.ts +1 -0
  78. package/src/update110001/index_spec.js +67 -0
  79. package/src/update110001/index_spec.js.map +1 -0
  80. package/src/update110001/index_spec.ts +72 -0
  81. package/src/update110001/schema.json +23 -0
  82. package/src/update110100/index.d.ts +2 -0
  83. package/src/update110100/index.js +27 -0
  84. package/src/update110100/index.js.map +1 -0
  85. package/src/update110100/index.ts +24 -0
  86. package/src/update110100/index_spec.d.ts +1 -0
  87. package/src/update110100/index_spec.js +69 -0
  88. package/src/update110100/index_spec.js.map +1 -0
  89. package/src/update110100/index_spec.ts +73 -0
  90. package/src/update110100/schema.json +23 -0
  91. package/src/update110101/index.d.ts +2 -0
  92. package/src/update110101/index.js +24 -0
  93. package/src/update110101/index.js.map +1 -0
  94. package/src/update110101/index.ts +21 -0
  95. package/src/update110101/index_spec.d.ts +1 -0
  96. package/src/update110101/index_spec.js +65 -0
  97. package/src/update110101/index_spec.js.map +1 -0
  98. package/src/update110101/index_spec.ts +69 -0
  99. package/src/update110101/schema.json +23 -0
  100. package/src/update110200/index.d.ts +2 -0
  101. package/src/update110200/index.js +24 -0
  102. package/src/update110200/index.js.map +1 -0
  103. package/src/update110200/index.ts +21 -0
  104. package/src/update110200/index_spec.d.ts +1 -0
  105. package/src/update110200/index_spec.js +65 -0
  106. package/src/update110200/index_spec.js.map +1 -0
  107. package/src/update110200/index_spec.ts +69 -0
  108. package/src/update110200/schema.json +23 -0
  109. package/src/update110300/index.d.ts +2 -0
  110. package/src/update110300/index.js +133 -0
  111. package/src/update110300/index.js.map +1 -0
  112. package/src/update110300/index.ts +148 -0
  113. package/src/update110300/index_spec.d.ts +1 -0
  114. package/src/update110300/index_spec.js +121 -0
  115. package/src/update110300/index_spec.js.map +1 -0
  116. package/src/update110300/index_spec.ts +139 -0
  117. package/src/update110300/schema.json +23 -0
  118. package/src/utility/dependencies.d.ts +39 -0
  119. package/src/utility/dependencies.js +96 -0
  120. package/src/utility/dependencies.js.map +1 -0
  121. package/src/utility/dependencies.ts +116 -0
  122. package/src/utility/files.d.ts +60 -0
  123. package/src/utility/files.js +299 -0
  124. package/src/utility/files.js.map +1 -0
  125. package/src/utility/files.ts +355 -0
  126. package/src/utility/html.d.ts +49 -0
  127. package/src/utility/html.js +183 -0
  128. package/src/utility/html.js.map +1 -0
  129. package/src/utility/html.ts +212 -0
  130. package/src/utility/json.d.ts +34 -0
  131. package/src/utility/json.js +70 -0
  132. package/src/utility/json.js.map +1 -0
  133. package/src/utility/json.ts +70 -0
  134. package/src/utility/logging.d.ts +32 -0
  135. package/src/utility/logging.js +82 -0
  136. package/src/utility/logging.js.map +1 -0
  137. package/src/utility/logging.ts +80 -0
  138. package/src/utility/test.d.ts +10 -0
  139. package/src/utility/test.js +24 -0
  140. package/src/utility/test.js.map +1 -0
  141. package/src/utility/test.ts +24 -0
  142. package/src/utility/typescript.d.ts +22 -0
  143. package/src/utility/typescript.js +521 -0
  144. package/src/utility/typescript.js.map +1 -0
  145. package/src/utility/typescript.ts +598 -0
  146. package/src/utility/typescript_spec.d.ts +1 -0
  147. package/src/utility/typescript_spec.js +1006 -0
  148. package/src/utility/typescript_spec.js.map +1 -0
  149. package/src/utility/typescript_spec.ts +1267 -0
  150. package/src/utility/util.d.ts +33 -0
  151. package/src/utility/util.js +139 -0
  152. package/src/utility/util.js.map +1 -0
  153. package/src/utility/util.ts +140 -0
  154. package/src/utility/validation.d.ts +11 -0
  155. package/src/utility/validation.js +44 -0
  156. package/src/utility/validation.js.map +1 -0
  157. package/src/utility/validation.ts +49 -0
  158. package/tsconfig.json +37 -0
@@ -0,0 +1,703 @@
1
+ import { callRule, SchematicContext } from '@angular-devkit/schematics';
2
+ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
3
+ import * as path from 'path';
4
+ import { of as observableOf } from 'rxjs';
5
+ import { appOptions, workspaceOptions } from '../utility/test';
6
+ import { UtilConfig } from '../utility/util';
7
+ import {
8
+ createWebpackConfigJs,
9
+ updateAngularJson,
10
+ updateAppComponent,
11
+ updateAppComponentHtml,
12
+ updateAppModule,
13
+ updateAppRoutingModule,
14
+ updateIndexHtml,
15
+ updatePackageJson
16
+ } from './index';
17
+
18
+ const collectionPath = path.join(__dirname, '../collection.json');
19
+
20
+ describe('migrate-to-eslint', () => {
21
+ let appTree: UnitTestTree;
22
+ let runner: SchematicTestRunner;
23
+ let context: SchematicContext;
24
+
25
+ const testOptions: any = {};
26
+
27
+ beforeEach(async () => {
28
+ runner = new SchematicTestRunner('schematics', collectionPath);
29
+
30
+ appTree = await runner.runExternalSchematicAsync('@schematics/angular', 'workspace', workspaceOptions).toPromise();
31
+ appTree = await runner
32
+ .runExternalSchematicAsync('@schematics/angular', 'application', appOptions, appTree)
33
+ .toPromise();
34
+
35
+ UtilConfig.defaultWaitMS = 0;
36
+
37
+ const collection = runner.engine.createCollection(collectionPath);
38
+ const schematic = runner.engine.createSchematic('migrate-to-webcomponent', collection);
39
+ context = runner.engine.createContext(schematic);
40
+
41
+ testOptions.project = appOptions.name;
42
+ testOptions.path = workspaceOptions.newProjectRoot + '/' + appOptions.name;
43
+ testOptions.verbose = true;
44
+ });
45
+
46
+ describe('[Rule] updateAppComponent', () => {
47
+ it('Sollte die Datei "app.component.ts" angepasst haben', (done) => {
48
+ appTree.overwrite(
49
+ (testOptions.path ? testOptions.path : '') + `/src/app/app.component.ts`,
50
+ `
51
+ import { Version } from './../../src-gen/bsclient/model/version';
52
+ import { AccountFacadeService } from './../../src-gen/bsclient/api/accountFacade.service';
53
+ import { Component, OnInit } from '@angular/core';
54
+ import { Router } from '@angular/router';
55
+ import { LuxAppFooterLinkService, LuxAppFooterLinkInfo, LuxThemeService } from '@ihk-gfi/lux-components';
56
+ import { FeedbackService } from './components/feedback/feedback.service';
57
+ import { SharedService } from './services/shared.service';
58
+
59
+ @Component({
60
+ selector : 'app-root',
61
+ templateUrl: './app.component.html',
62
+ styleUrls : [ './app.component.scss' ]
63
+ })
64
+ export class AppComponent implements OnInit {
65
+
66
+ luxVersion = '';
67
+ isMaintenanceOrUnauthorized = false;
68
+
69
+ constructor(private readonly fachService: AccountFacadeService,
70
+ public router: Router, public window: Window,
71
+ public sharedService: SharedService,
72
+ private linkService: LuxAppFooterLinkService,
73
+ public feedbackService: FeedbackService, private themeService: LuxThemeService) {
74
+ themeService.loadTheme();
75
+ this.isMaintenanceOrUnauthorized = window.location.href.endsWith('/maintenance') || window.location.href.endsWith('/unauthorized');
76
+ }
77
+
78
+ }
79
+
80
+ `
81
+ );
82
+
83
+ callRule(updateAppComponent(testOptions), observableOf(appTree), context).subscribe(
84
+ (success) => {
85
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app.component.ts`)?.toString();
86
+
87
+ expect(content).toContain('private themeService: LuxThemeService, private elementRef: ElementRef, private appService: LuxAppService)');
88
+ expect(content).toContain('import { LuxAppFooterLinkService, LuxAppFooterLinkInfo, LuxThemeService, LuxAppService } from \'@ihk-gfi/lux-components\';');
89
+ expect(content).toContain('import { Component, OnInit, ElementRef, Input } from \'@angular/core\';');
90
+ expect(content).toContain('private elementRef: ElementRef, private appService: LuxAppService) {\n' +
91
+ ' this.appService.appEl = elementRef.nativeElement;\n' +
92
+ ' themeService.loadTheme();\n' +
93
+ ' this.isMaintenanceOrUnauthorized = window.location.href.endsWith(\'/maintenance\') || window.location.href.endsWith(\'/unauthorized\');\n' +
94
+ ' router.initialNavigation();\n' +
95
+ ' }');
96
+
97
+ expect(content).toContain('@Input() luxAppHeader: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
98
+ expect(content).toContain('@Input() luxAppFooter: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
99
+ expect(content).toContain('@Input() luxMode: \'stand-alone\' | \'portal\' = \'stand-alone\';');
100
+
101
+ done();
102
+ },
103
+ (reason) => expect(reason).toBeUndefined()
104
+ );
105
+ });
106
+ });
107
+
108
+ describe('[Rule] updatePackageJson', () => {
109
+ it('Sollte die Datei "package.json" (ohne skripte) angepasst haben', (done) => {
110
+ appTree.overwrite(
111
+ `package.json`,
112
+ `
113
+
114
+ `
115
+ );
116
+
117
+ callRule(updatePackageJson(testOptions), observableOf(appTree), context).subscribe(
118
+ (success) => {
119
+ const content = success.read(`package.json`)?.toString();
120
+
121
+ expect(content).toContain('"build-aot": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --aot --single-bundle --output-hashing none && npm run move-de-files"');
122
+ expect(content).toContain('"buildzentral": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --prod --single-bundle --output-hashing none --plugin @ihk-gfi/lux-components/ie11-lazy-modules-plugin.js && npm run move-de-files"');
123
+
124
+ expect(content).toContain('"@webcomponents/webcomponentsjs"');
125
+ expect(content).toContain('"ngx-build-plus"');
126
+ expect(content).toContain('"@angular/elements"');
127
+ expect(content).toContain('"replace-in-file"');
128
+ done();
129
+ },
130
+ (reason) => expect(reason).toBeUndefined()
131
+ );
132
+ });
133
+
134
+ it('Sollte die Datei "package.json" (mit skripte) angepasst haben', (done) => {
135
+ appTree.overwrite(
136
+ `package.json`,
137
+ `
138
+ {
139
+ "name": "bar",
140
+ "version": "0.0.1",
141
+ "license": "MIT",
142
+ "scripts": {
143
+ "ng": "ng",
144
+ "start": "ng serve --public-host=http://localhost:4200",
145
+ "build": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --source-map",
146
+ "build-aot": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --aot && npm run move-de-files",
147
+ "buildzentral": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --prod && npm run move-de-files",
148
+ },
149
+ "private": true,
150
+ "dependencies": {
151
+ },
152
+ "devDependencies": {
153
+ }
154
+ }
155
+
156
+ `
157
+ );
158
+
159
+ callRule(updatePackageJson(testOptions), observableOf(appTree), context).subscribe(
160
+ (success) => {
161
+ const content = success.read(`package.json`)?.toString();
162
+
163
+ expect(content).toContain('"build-aot": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --aot --single-bundle --output-hashing none && npm run move-de-files"');
164
+ expect(content).toContain('"buildzentral": "node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --prod --single-bundle --output-hashing none --plugin @ihk-gfi/lux-components/ie11-lazy-modules-plugin.js && npm run move-de-files"');
165
+
166
+ expect(content).toContain('"@webcomponents/webcomponentsjs"');
167
+ expect(content).toContain('"ngx-build-plus"');
168
+ expect(content).toContain('"@angular/elements"');
169
+ expect(content).toContain('"replace-in-file"');
170
+ done();
171
+ },
172
+ (reason) => expect(reason).toBeUndefined()
173
+ );
174
+ });
175
+ });
176
+
177
+ describe('[Rule] updateAppRoutingModule', () => {
178
+ it('Sollte die Datei "app-routing.module.ts" angepasst haben', (done) => {
179
+ appTree.create(
180
+ (testOptions.path ? testOptions.path : '') + `/src/app/app-routing.module.ts`,
181
+ `
182
+ const routes: Routes = [
183
+ {path: '', component: HomeComponent},
184
+ {path: 'impressum', component: ImpressumComponent},
185
+ {path: 'anbindung', loadChildren: () => import('app/components/anbindung/anbindung.module').then(m => m.AnbindungModule)},
186
+ {path: 'information', loadChildren: () => import('app/components/info/info.module').then(m => m.InfoModule)},
187
+ {path: '**', component: ErrorComponent} // Immer als letzte Route !! -> 404!
188
+ ];
189
+
190
+ `
191
+ );
192
+
193
+ callRule(updateAppRoutingModule(testOptions), observableOf(appTree), context).subscribe(
194
+ (success) => {
195
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app-routing.module.ts`)?.toString();
196
+
197
+ expect(content).not.toContain('import(\'app/');
198
+ expect(content).toContain('import(\'./');
199
+
200
+ done();
201
+ },
202
+ (reason) => expect(reason).toBeUndefined()
203
+ );
204
+ });
205
+
206
+ it('Sollte die Datei "app-routing.module.ts" (Doppelte Anführungszeichen) angepasst haben', (done) => {
207
+ appTree.create(
208
+ (testOptions.path ? testOptions.path : '') + `/src/app/app-routing.module.ts`,
209
+ `
210
+ const routes: Routes = [
211
+ {path: '', component: HomeComponent},
212
+ {path: 'impressum', component: ImpressumComponent},
213
+ {path: 'anbindung', loadChildren: () => import("app/components/anbindung/anbindung.module").then(m => m.AnbindungModule)},
214
+ {path: 'information', loadChildren: () => import("app/components/info/info.module").then(m => m.InfoModule)},
215
+ {path: '**', component: ErrorComponent} // Immer als letzte Route !! -> 404!
216
+ ];
217
+
218
+ `
219
+ );
220
+
221
+ callRule(updateAppRoutingModule(testOptions), observableOf(appTree), context).subscribe(
222
+ (success) => {
223
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app-routing.module.ts`)?.toString();
224
+
225
+ expect(content).not.toContain('import("app/');
226
+ expect(content).toContain('import("./');
227
+
228
+ done();
229
+ },
230
+ (reason) => expect(reason).toBeUndefined()
231
+ );
232
+ });
233
+ });
234
+
235
+ describe('[Rule] updateAngularJson', () => {
236
+ it('Sollte die Datei "angular.json" angepasst haben', (done) => {
237
+ appTree.overwrite(
238
+ `angular.json`,
239
+ `
240
+ {
241
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
242
+ "version": 1,
243
+ "newProjectRoot": "projects",
244
+ "projects": {
245
+ "bar": {
246
+ "root": "",
247
+ "sourceRoot": "src",
248
+ "projectType": "application",
249
+ "architect": {
250
+ "build": {
251
+ "builder": "@angular-devkit/build-angular:browser",
252
+ "options": {
253
+ "outputPath": "dist",
254
+ "index": "src/index.html",
255
+ "main": "src/main.ts",
256
+ "tsConfig": "src/tsconfig.app.json",
257
+ "polyfills": "src/polyfills.ts",
258
+ "assets": [
259
+ {
260
+ "glob": "*.css",
261
+ "input": "./node_modules/@ihk-gfi/lux-components-theme/prebuilt-themes",
262
+ "output": "./assets/themes"
263
+ },
264
+ "src/assets",
265
+ {
266
+ "glob": "**/*",
267
+ "input": "./node_modules/pdfjs-dist/cmaps/",
268
+ "output": "./assets/cmaps"
269
+ }
270
+ ],
271
+ "styles": [
272
+ "src/styles.scss"
273
+ ],
274
+ "scripts": [],
275
+ "allowedCommonJsDependencies": [
276
+ "hammerjs",
277
+ "ng2-pdf-viewer"
278
+ ],
279
+ "localize": [
280
+ "de"
281
+ ],
282
+ "i18nMissingTranslation": "error"
283
+ },
284
+ "configurations": {
285
+ "production": {
286
+ "budgets": [
287
+ {
288
+ "type": "anyComponentStyle",
289
+ "maximumWarning": "6kb"
290
+ }
291
+ ],
292
+ "optimization": true,
293
+ "outputHashing": "all",
294
+ "sourceMap": false,
295
+ "namedChunks": false,
296
+ "aot": true,
297
+ "extractLicenses": true,
298
+ "vendorChunk": false,
299
+ "buildOptimizer": true,
300
+ "fileReplacements": [
301
+ {
302
+ "replace": "src/environments/environment.ts",
303
+ "with": "src/environments/environment.prod.ts"
304
+ }
305
+ ]
306
+ },
307
+ "es5": {
308
+ "budgets": [
309
+ {
310
+ "type": "anyComponentStyle",
311
+ "maximumWarning": "6kb"
312
+ }
313
+ ],
314
+ "tsConfig": "src/tsconfig.app.ie.json"
315
+ },
316
+ "en": {
317
+ "localize": [
318
+ "en"
319
+ ],
320
+ "aot": true,
321
+ "outputPath": "dist/en",
322
+ "i18nMissingTranslation": "error"
323
+ }
324
+ }
325
+ },
326
+ "serve": {
327
+ "builder": "@angular-devkit/build-angular:dev-server",
328
+ "options": {
329
+ "browserTarget": "lux-bp:build"
330
+ },
331
+ "configurations": {
332
+ "production": {
333
+ "browserTarget": "lux-bp:build:production"
334
+ },
335
+ "es5": {
336
+ "browserTarget": "lux-bp:build:es5"
337
+ },
338
+ "en": {
339
+ "browserTarget": "lux-bp:build:en"
340
+ }
341
+ }
342
+ },
343
+ "extract-i18n": {
344
+ "builder": "@angular-devkit/build-angular:extract-i18n",
345
+ "options": {
346
+ "browserTarget": "lux-bp:build"
347
+ }
348
+ },
349
+ "test": {
350
+ "builder": "@angular-devkit/build-angular:karma",
351
+ "options": {
352
+ "main": "src/test.ts",
353
+ "karmaConfig": "./karma.conf.js",
354
+ "polyfills": "src/polyfills.ts",
355
+ "tsConfig": "src/tsconfig.spec.json",
356
+ "scripts": [],
357
+ "styles": [
358
+ "src/styles.scss"
359
+ ],
360
+ "assets": [
361
+ {
362
+ "glob": "*.css",
363
+ "input": "./node_modules/@ihk-gfi/lux-components-theme/prebuilt-themes",
364
+ "output": "./assets/themes"
365
+ },
366
+ "src/assets",
367
+ {
368
+ "glob": "**/*",
369
+ "input": "./node_modules/pdfjs-dist/cmaps/",
370
+ "output": "./assets/cmaps"
371
+ }
372
+ ]
373
+ }
374
+ },
375
+ "lint": {
376
+ "builder": "@angular-eslint/builder:lint",
377
+ "options": {
378
+ "lintFilePatterns": [
379
+ "src/**/*.ts",
380
+ "src/**/*.html"
381
+ ]
382
+ }
383
+ }
384
+ },
385
+ "i18n": {
386
+ "sourceLocale": {
387
+ "code": "de",
388
+ "baseHref": "/"
389
+ },
390
+ "locales": {
391
+ "en": "src/locale/messages.en.xlf"
392
+ }
393
+ }
394
+ },
395
+ "lux-bp-e2e": {
396
+ "root": "e2e",
397
+ "sourceRoot": "e2e",
398
+ "projectType": "application",
399
+ "architect": {
400
+ "e2e": {
401
+ "builder": "@angular-devkit/build-angular:protractor",
402
+ "options": {
403
+ "protractorConfig": "./protractor.conf.js",
404
+ "devServerTarget": "lux-bp:serve"
405
+ }
406
+ }
407
+ }
408
+ }
409
+ },
410
+ "defaultProject": "lux-bp",
411
+ "schematics": {
412
+ "@schematics/angular:component": {
413
+ "prefix": "bp",
414
+ "style": "scss"
415
+ },
416
+ "@schematics/angular:directive": {
417
+ "prefix": "bp"
418
+ }
419
+ },
420
+ "cli": {
421
+ "defaultCollection": "@angular-eslint/schematics"
422
+ }
423
+ }
424
+
425
+ `
426
+ );
427
+
428
+ callRule(updateAngularJson(testOptions), observableOf(appTree), context).subscribe(
429
+ (success) => {
430
+ const content = success.read(`angular.json`)?.toString();
431
+
432
+ expect(content).toContain('"scripts": [\n' +
433
+ ' {\n' +
434
+ ' "bundleName": "polyfill-webcomp",\n' +
435
+ ' "input": "node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js"\n' +
436
+ ' },\n' +
437
+ ' {\n' +
438
+ ' "bundleName": "polyfill-webcomp-es5",\n' +
439
+ ' "input": "node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"\n' +
440
+ ' }\n' +
441
+ ' ]');
442
+
443
+ expect(content).not.toContain('@angular-devkit/build-angular:browser');
444
+ expect(content).toContain('ngx-build-plus:browser');
445
+ expect(content).not.toContain('@angular-devkit/build-angular:dev-server');
446
+ expect(content).toContain('ngx-build-plus:dev-server');
447
+ expect(content).not.toContain('@angular-devkit/build-angular:karma');
448
+ expect(content).toContain('ngx-build-plus:karma');
449
+
450
+ done();
451
+ },
452
+ (reason) => expect(reason).toBeUndefined()
453
+ );
454
+ });
455
+ });
456
+
457
+ describe('[Rule] updateAppModule', () => {
458
+ it('Sollte die Datei "app.module.ts" (ohne Konstruktor) angepasst haben', (done) => {
459
+ appTree.overwrite(
460
+ (testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`,
461
+ `
462
+ import { AppRoutingModule } from './app-routing.module';
463
+ import { NgModule, ErrorHandler } from '@angular/core';
464
+ import { AppComponent } from './app.component';
465
+
466
+ export class AppModule {
467
+
468
+ }
469
+ `
470
+ );
471
+
472
+ callRule(updateAppModule(testOptions), observableOf(appTree), context).subscribe(
473
+ (success) => {
474
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`)?.toString();
475
+
476
+ expect(content).toContain('import { createCustomElement } from \'@angular/elements\';');
477
+ expect(content).toContain('export class AppModule implements DoBootstrap');
478
+ expect(content).toContain('constructor(private injector: Injector) {}');
479
+
480
+ done();
481
+ },
482
+ (reason) => expect(reason).toBeUndefined()
483
+ );
484
+ });
485
+
486
+ it('Sollte die Datei "app.module.ts" (mit Konstruktor - ohne Parameter) angepasst haben', (done) => {
487
+ appTree.overwrite(
488
+ (testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`,
489
+ `
490
+ import { AppRoutingModule } from './app-routing.module';
491
+ import { NgModule, ErrorHandler } from '@angular/core';
492
+ import { AppComponent } from './app.component';
493
+
494
+ export class AppModule {
495
+
496
+ constructor() {}
497
+
498
+ }
499
+ `
500
+ );
501
+
502
+ callRule(updateAppModule(testOptions), observableOf(appTree), context).subscribe(
503
+ (success) => {
504
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`)?.toString();
505
+
506
+ expect(content).toContain('import { createCustomElement } from \'@angular/elements\';');
507
+ expect(content).toContain('export class AppModule implements DoBootstrap');
508
+ expect(content).toContain('constructor(private injector: Injector) {}');
509
+
510
+ done();
511
+ },
512
+ (reason) => expect(reason).toBeUndefined()
513
+ );
514
+ });
515
+
516
+ it('Sollte die Datei "app.module.ts" (mit Konstruktor - mit Parameter) angepasst haben', (done) => {
517
+ appTree.overwrite(
518
+ (testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`,
519
+ `
520
+ import { AppRoutingModule } from './app-routing.module';
521
+ import { NgModule, ErrorHandler } from '@angular/core';
522
+ import { AppComponent } from './app.component';
523
+
524
+ export class AppModule {
525
+
526
+ constructor(private aaa: Aaa) {}
527
+
528
+ ngOnInit() {
529
+ }
530
+ }
531
+ `
532
+ );
533
+
534
+ callRule(updateAppModule(testOptions), observableOf(appTree), context).subscribe(
535
+ (success) => {
536
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`)?.toString();
537
+
538
+ expect(content).toContain('import { createCustomElement } from \'@angular/elements\';');
539
+ expect(content).toContain('export class AppModule implements DoBootstrap');
540
+ expect(content).toContain('constructor(private aaa: Aaa, private injector: Injector) {}');
541
+
542
+ done();
543
+ },
544
+ (reason) => expect(reason).toBeUndefined()
545
+ );
546
+ });
547
+
548
+ it('Sollte die Datei "app.module.ts" (bootstrap entfernen - schema hinzufügen) angepasst haben', (done) => {
549
+ appTree.overwrite(
550
+ (testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`,
551
+ `
552
+ import { AppRoutingModule } from './app-routing.module';
553
+ import { NgModule, ErrorHandler } from '@angular/core';
554
+ import { AppComponent } from './app.component';
555
+
556
+ @NgModule({
557
+ declarations : [
558
+ AppComponent
559
+ ],
560
+ imports : [
561
+ HttpClientModule
562
+ ],
563
+ entryComponents: [
564
+ LuxSnackbarComponent,
565
+ LuxFilePreviewComponent
566
+ ],
567
+ providers : [
568
+ LuxDialogService,
569
+ DatePipe,
570
+ { provide: Window, useValue: window }
571
+ ],
572
+ bootstrap : [
573
+ AppComponent
574
+ ]
575
+ })
576
+ export class AppModule {
577
+
578
+ constructor(private aaa: Aaa) {}
579
+
580
+ ngOnInit() {
581
+ }
582
+ }
583
+ `
584
+ );
585
+
586
+ callRule(updateAppModule(testOptions), observableOf(appTree), context).subscribe(
587
+ (success) => {
588
+ const content = success.read((testOptions.path ? testOptions.path : '') + `/src/app/app.module.ts`)?.toString();
589
+
590
+ expect(content).toContain('schemas: [CUSTOM_ELEMENTS_SCHEMA]');
591
+ expect(content).not.toContain('bootstrap :');
592
+
593
+ done();
594
+ },
595
+ (reason) => expect(reason).toBeUndefined()
596
+ );
597
+ });
598
+ });
599
+
600
+ describe('[Rule] updateIndexHtml', () => {
601
+ it('Sollte die Datei "index.html" angepasst haben', (done) => {
602
+ appTree.create(
603
+ 'src/index.html',
604
+ `
605
+ <!doctype html>
606
+ <html lang="de">
607
+ <head>
608
+ <meta charset="utf-8">
609
+ <title>LUX Blueprint</title>
610
+ <base href="/">
611
+ <meta name="viewport" content="width=device-width, initial-scale=1">
612
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
613
+ </head>
614
+ <body style="margin: 0">
615
+ <noscript>
616
+ <div id="no-js" class="lux-no-js">
617
+ <p><b>Achtung, Javascript ist deaktiviert.</b></p>
618
+ <p>Bitte aktivieren Sie Javascript in Ihrem Browser, damit die Applikation funktionsf&auml;hig ist.</p>
619
+ </div>
620
+ </noscript>
621
+ <app-root></app-root>
622
+ </body>
623
+ </html>
624
+ `
625
+ );
626
+
627
+ const newTestOptions = JSON.parse(JSON.stringify(testOptions));
628
+ newTestOptions.project = 'Ka-74öäü';
629
+
630
+ callRule(updateIndexHtml(newTestOptions), observableOf(appTree), context).subscribe(
631
+ (success) => {
632
+ const content = success.read('src/index.html')?.toString();
633
+
634
+ expect(content).not.toContain('<app-root></app-root>');
635
+ expect(content).toContain('<lux-ka></lux-ka>');
636
+
637
+ done();
638
+ },
639
+ (reason) => expect(reason).toBeUndefined()
640
+ );
641
+ });
642
+ });
643
+
644
+ describe('[Rule] updateAppComponentHtml', () => {
645
+ it('Sollte die Datei "app.component.html" angepasst haben', (done) => {
646
+ appTree.overwrite(
647
+ testOptions.path + '/src/app/app.component.html',
648
+ `
649
+ <lux-app-header luxAppTitle="LUX Blueprint" luxAppTitleShort="LUX"
650
+ luxUserName="{{sharedService.getBenutzernameAsObservable() | async}}">
651
+ </lux-app-header>
652
+
653
+ <lux-app-header-right-nav *ngIf="(sharedService.isLoggedInAsObservable() | async)">
654
+ <lux-menu-item luxIconName="fa-power-off" luxLabel="Abmelden"
655
+ (luxClicked)="sharedService.logout(true)"></lux-menu-item>
656
+ </lux-app-header-right-nav>
657
+
658
+ <lux-app-content></lux-app-content>
659
+
660
+ <lux-app-footer *ngIf="this.luxAppFooter !== 'none'" luxVersion="{{luxVersion}}">
661
+ </lux-app-footer>
662
+ `
663
+ );
664
+
665
+ callRule(updateAppComponentHtml(testOptions), observableOf(appTree), context).subscribe(
666
+ (success) => {
667
+ const content = success.read(testOptions.path + '/src/app/app.component.html')?.toString();
668
+
669
+ expect(content).toContain('*ngIf="this.luxAppHeader !== \'none\'"');
670
+ expect(content).toContain('*ngIf="(sharedService.isLoggedInAsObservable() | async) && luxMode === \'stand-alone\'"');
671
+ expect(content).toContain('*ngIf="this.luxAppFooter !== \'none\'"');
672
+ expect(content).toContain('<lux-app-content></lux-app-content>');
673
+ expect(content).not.toContain('<lux-app-content/>');
674
+
675
+ done();
676
+ },
677
+ (reason) => expect(reason).toBeUndefined()
678
+ );
679
+ });
680
+ });
681
+
682
+ describe('[Rule] createWebpackConfigJs', () => {
683
+ it('Sollte die Datei "webpack.config.js" angelegt haben', (done) => {
684
+
685
+ callRule(createWebpackConfigJs(testOptions), observableOf(appTree), context).subscribe(
686
+ (success) => {
687
+ const content = success.read('webpack.config.js')?.toString();
688
+
689
+ expect(content).toContain(`
690
+ module.exports = {
691
+ output: {
692
+ jsonpFunction: 'jsonpFunctionBar'
693
+ }
694
+ };`);
695
+
696
+ done();
697
+ },
698
+ (reason) => expect(reason).toBeUndefined()
699
+ );
700
+ });
701
+ });
702
+
703
+ });