@ihk-gfi/lux-components-update 11.13.0 → 13.0.1

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 (230) hide show
  1. package/README.md +2 -4
  2. package/package.json +14 -17
  3. package/src/add-lux-components/files/app/app.component.html +1 -1
  4. package/src/add-lux-components/files/app/app.component.ts +4 -1
  5. package/src/add-lux-components/files/locale/messages.en.xlf +489 -235
  6. package/src/add-lux-components/files/locale/messages.xlf +451 -218
  7. package/src/add-lux-components/files/scripts/.browserslistrc +10 -7
  8. package/src/add-lux-components/files/src/index.html +31 -0
  9. package/src/add-lux-components/index.js +151 -78
  10. package/src/add-lux-components/index.js.map +1 -1
  11. package/src/add-lux-components/index.ts +141 -66
  12. package/src/add-lux-components/index_spec.js +4 -4
  13. package/src/add-lux-components/index_spec.js.map +1 -1
  14. package/src/add-lux-components/index_spec.ts +1 -1
  15. package/src/add-lux-components/schema.json +1 -1
  16. package/src/collection.json +8 -88
  17. package/src/update-dependencies/index.d.ts +1 -1
  18. package/src/update-dependencies/index.js +82 -65
  19. package/src/update-dependencies/index.js.map +1 -1
  20. package/src/update-dependencies/index.ts +112 -95
  21. package/src/update-dependencies/schema.json +1 -1
  22. package/src/update-en-messages/index.d.ts +2 -0
  23. package/src/update-en-messages/index.js +75 -0
  24. package/src/update-en-messages/index.js.map +1 -0
  25. package/src/update-en-messages/index.ts +78 -0
  26. package/src/{update110100 → update-en-messages}/schema.json +3 -3
  27. package/src/updates/update130000/files/root/.browserslistrc +20 -0
  28. package/src/updates/update130000/index.d.ts +27 -0
  29. package/src/updates/update130000/index.js +296 -0
  30. package/src/updates/update130000/index.js.map +1 -0
  31. package/src/updates/update130000/index.ts +346 -0
  32. package/src/{migrate-to-eslint → updates/update130000}/index_spec.d.ts +0 -0
  33. package/src/updates/update130000/index_spec.js +574 -0
  34. package/src/updates/update130000/index_spec.js.map +1 -0
  35. package/src/updates/update130000/index_spec.ts +665 -0
  36. package/src/{update → updates/update130000}/schema.json +1 -1
  37. package/src/utility/dependencies.js +16 -14
  38. package/src/utility/dependencies.js.map +1 -1
  39. package/src/utility/dependencies.ts +6 -4
  40. package/src/utility/files.d.ts +5 -1
  41. package/src/utility/files.js +27 -16
  42. package/src/utility/files.js.map +1 -1
  43. package/src/utility/files.ts +16 -3
  44. package/src/utility/html.js +88 -25
  45. package/src/utility/html.js.map +1 -1
  46. package/src/utility/html.ts +105 -29
  47. package/src/{migrate-to-webcomponent/index_spec.d.ts → utility/html_spec.d.ts} +0 -0
  48. package/src/utility/html_spec.js +560 -0
  49. package/src/utility/html_spec.js.map +1 -0
  50. package/src/utility/html_spec.ts +575 -0
  51. package/src/utility/json.d.ts +46 -1
  52. package/src/utility/json.js +174 -4
  53. package/src/utility/json.js.map +1 -1
  54. package/src/utility/json.ts +198 -3
  55. package/src/{update/index_spec.d.ts → utility/json_spec.d.ts} +0 -0
  56. package/src/utility/json_spec.js +326 -0
  57. package/src/utility/json_spec.js.map +1 -0
  58. package/src/utility/json_spec.ts +376 -0
  59. package/src/utility/typescript.js +16 -16
  60. package/src/utility/typescript.js.map +1 -1
  61. package/src/utility/typescript_spec.js +36 -36
  62. package/src/utility/typescript_spec.js.map +1 -1
  63. package/src/utility/util.d.ts +2 -2
  64. package/src/utility/util.js +16 -14
  65. package/src/utility/util.js.map +1 -1
  66. package/src/utility/util.ts +7 -5
  67. package/src/utility/validation.js +11 -11
  68. package/src/utility/validation.js.map +1 -1
  69. package/src/migrate-to-eslint/files/.eslintrc.json +0 -68
  70. package/src/migrate-to-eslint/files/.prettierrc +0 -25
  71. package/src/migrate-to-eslint/index.d.ts +0 -6
  72. package/src/migrate-to-eslint/index.js +0 -149
  73. package/src/migrate-to-eslint/index.js.map +0 -1
  74. package/src/migrate-to-eslint/index.ts +0 -181
  75. package/src/migrate-to-eslint/index_spec.js +0 -129
  76. package/src/migrate-to-eslint/index_spec.js.map +0 -1
  77. package/src/migrate-to-eslint/index_spec.ts +0 -152
  78. package/src/migrate-to-eslint/schema.json +0 -23
  79. package/src/migrate-to-webcomponent/index.d.ts +0 -10
  80. package/src/migrate-to-webcomponent/index.js +0 -278
  81. package/src/migrate-to-webcomponent/index.js.map +0 -1
  82. package/src/migrate-to-webcomponent/index.ts +0 -331
  83. package/src/migrate-to-webcomponent/index_spec.js +0 -580
  84. package/src/migrate-to-webcomponent/index_spec.js.map +0 -1
  85. package/src/migrate-to-webcomponent/index_spec.ts +0 -703
  86. package/src/migrate-to-webcomponent/schema.json +0 -23
  87. package/src/update/files/locale/messages.en.xlf +0 -940
  88. package/src/update/files/locale/messages.xlf +0 -815
  89. package/src/update/files/scripts/move-de-files.js +0 -15
  90. package/src/update/index.d.ts +0 -23
  91. package/src/update/index.js +0 -635
  92. package/src/update/index.js.map +0 -1
  93. package/src/update/index.ts +0 -712
  94. package/src/update/index_spec.js +0 -984
  95. package/src/update/index_spec.js.map +0 -1
  96. package/src/update/index_spec.ts +0 -1139
  97. package/src/update110001/index.d.ts +0 -2
  98. package/src/update110001/index.js +0 -42
  99. package/src/update110001/index.js.map +0 -1
  100. package/src/update110001/index.ts +0 -40
  101. package/src/update110001/index_spec.d.ts +0 -1
  102. package/src/update110001/index_spec.js +0 -67
  103. package/src/update110001/index_spec.js.map +0 -1
  104. package/src/update110001/index_spec.ts +0 -72
  105. package/src/update110001/schema.json +0 -23
  106. package/src/update110100/index.d.ts +0 -2
  107. package/src/update110100/index.js +0 -27
  108. package/src/update110100/index.js.map +0 -1
  109. package/src/update110100/index.ts +0 -24
  110. package/src/update110100/index_spec.d.ts +0 -1
  111. package/src/update110100/index_spec.js +0 -69
  112. package/src/update110100/index_spec.js.map +0 -1
  113. package/src/update110100/index_spec.ts +0 -73
  114. package/src/update110101/index.d.ts +0 -2
  115. package/src/update110101/index.js +0 -24
  116. package/src/update110101/index.js.map +0 -1
  117. package/src/update110101/index.ts +0 -21
  118. package/src/update110101/index_spec.d.ts +0 -1
  119. package/src/update110101/index_spec.js +0 -65
  120. package/src/update110101/index_spec.js.map +0 -1
  121. package/src/update110101/index_spec.ts +0 -69
  122. package/src/update110101/schema.json +0 -23
  123. package/src/update110200/index.d.ts +0 -2
  124. package/src/update110200/index.js +0 -24
  125. package/src/update110200/index.js.map +0 -1
  126. package/src/update110200/index.ts +0 -21
  127. package/src/update110200/index_spec.d.ts +0 -1
  128. package/src/update110200/index_spec.js +0 -65
  129. package/src/update110200/index_spec.js.map +0 -1
  130. package/src/update110200/index_spec.ts +0 -69
  131. package/src/update110200/schema.json +0 -23
  132. package/src/update110300/index.d.ts +0 -2
  133. package/src/update110300/index.js +0 -133
  134. package/src/update110300/index.js.map +0 -1
  135. package/src/update110300/index.ts +0 -148
  136. package/src/update110300/index_spec.d.ts +0 -1
  137. package/src/update110300/index_spec.js +0 -121
  138. package/src/update110300/index_spec.js.map +0 -1
  139. package/src/update110300/index_spec.ts +0 -139
  140. package/src/update110300/schema.json +0 -23
  141. package/src/update110400/index.d.ts +0 -2
  142. package/src/update110400/index.js +0 -28
  143. package/src/update110400/index.js.map +0 -1
  144. package/src/update110400/index.ts +0 -28
  145. package/src/update110400/index_spec.d.ts +0 -1
  146. package/src/update110400/index_spec.js +0 -66
  147. package/src/update110400/index_spec.js.map +0 -1
  148. package/src/update110400/index_spec.ts +0 -70
  149. package/src/update110400/schema.json +0 -23
  150. package/src/update110500/index.d.ts +0 -2
  151. package/src/update110500/index.js +0 -28
  152. package/src/update110500/index.js.map +0 -1
  153. package/src/update110500/index.ts +0 -28
  154. package/src/update110500/index_spec.d.ts +0 -1
  155. package/src/update110500/index_spec.js +0 -66
  156. package/src/update110500/index_spec.js.map +0 -1
  157. package/src/update110500/index_spec.ts +0 -70
  158. package/src/update110500/schema.json +0 -23
  159. package/src/update110600/index.d.ts +0 -2
  160. package/src/update110600/index.js +0 -28
  161. package/src/update110600/index.js.map +0 -1
  162. package/src/update110600/index.ts +0 -28
  163. package/src/update110600/index_spec.d.ts +0 -1
  164. package/src/update110600/index_spec.js +0 -66
  165. package/src/update110600/index_spec.js.map +0 -1
  166. package/src/update110600/index_spec.ts +0 -70
  167. package/src/update110600/schema.json +0 -23
  168. package/src/update110700/index.d.ts +0 -2
  169. package/src/update110700/index.js +0 -45
  170. package/src/update110700/index.js.map +0 -1
  171. package/src/update110700/index.ts +0 -47
  172. package/src/update110700/index_spec.d.ts +0 -1
  173. package/src/update110700/index_spec.js +0 -108
  174. package/src/update110700/index_spec.js.map +0 -1
  175. package/src/update110700/index_spec.ts +0 -122
  176. package/src/update110700/schema.json +0 -23
  177. package/src/update110800/index.d.ts +0 -2
  178. package/src/update110800/index.js +0 -32
  179. package/src/update110800/index.js.map +0 -1
  180. package/src/update110800/index.ts +0 -33
  181. package/src/update110800/index_spec.d.ts +0 -1
  182. package/src/update110800/index_spec.js +0 -70
  183. package/src/update110800/index_spec.js.map +0 -1
  184. package/src/update110800/index_spec.ts +0 -75
  185. package/src/update110800/schema.json +0 -23
  186. package/src/update110900/index.d.ts +0 -4
  187. package/src/update110900/index.js +0 -111
  188. package/src/update110900/index.js.map +0 -1
  189. package/src/update110900/index.ts +0 -123
  190. package/src/update110900/index_spec.d.ts +0 -1
  191. package/src/update110900/index_spec.js +0 -311
  192. package/src/update110900/index_spec.js.map +0 -1
  193. package/src/update110900/index_spec.ts +0 -341
  194. package/src/update110900/schema.json +0 -23
  195. package/src/update111000/index.d.ts +0 -2
  196. package/src/update111000/index.js +0 -27
  197. package/src/update111000/index.js.map +0 -1
  198. package/src/update111000/index.ts +0 -27
  199. package/src/update111000/index_spec.d.ts +0 -1
  200. package/src/update111000/index_spec.js +0 -65
  201. package/src/update111000/index_spec.js.map +0 -1
  202. package/src/update111000/index_spec.ts +0 -70
  203. package/src/update111000/schema.json +0 -23
  204. package/src/update111100/index.d.ts +0 -2
  205. package/src/update111100/index.js +0 -389
  206. package/src/update111100/index.js.map +0 -1
  207. package/src/update111100/index.ts +0 -405
  208. package/src/update111100/index_spec.d.ts +0 -1
  209. package/src/update111100/index_spec.js +0 -66
  210. package/src/update111100/index_spec.js.map +0 -1
  211. package/src/update111100/index_spec.ts +0 -70
  212. package/src/update111100/schema.json +0 -23
  213. package/src/update111200/index.d.ts +0 -2
  214. package/src/update111200/index.js +0 -59
  215. package/src/update111200/index.js.map +0 -1
  216. package/src/update111200/index.ts +0 -75
  217. package/src/update111200/index_spec.d.ts +0 -1
  218. package/src/update111200/index_spec.js +0 -67
  219. package/src/update111200/index_spec.js.map +0 -1
  220. package/src/update111200/index_spec.ts +0 -71
  221. package/src/update111200/schema.json +0 -23
  222. package/src/update111300/index.d.ts +0 -2
  223. package/src/update111300/index.js +0 -27
  224. package/src/update111300/index.js.map +0 -1
  225. package/src/update111300/index.ts +0 -27
  226. package/src/update111300/index_spec.d.ts +0 -1
  227. package/src/update111300/index_spec.js +0 -65
  228. package/src/update111300/index_spec.js.map +0 -1
  229. package/src/update111300/index_spec.ts +0 -69
  230. package/src/update111300/schema.json +0 -23
@@ -1,331 +0,0 @@
1
- import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2
- import { applyEdits, Edit, findNodeAtLocation, modify } from 'jsonc-parser';
3
- import * as ts from 'typescript';
4
- import { iterateFilesAndModifyContent } from '../utility/files';
5
- import { addAttribute, appendAttribute } from '../utility/html';
6
- import { appendScript, jsonFormattingOptions, readJson, readJsonAsString } from '../utility/json';
7
- import { logInfo } from '../utility/logging';
8
- import {
9
- addClassProperty,
10
- addConstructorContent,
11
- addConstructorParameter,
12
- addImport,
13
- addInterface,
14
- addMethod,
15
- getSourceNodes,
16
- getSyntaxListOfClass
17
- } from '../utility/typescript';
18
- import { finish, messageInfoRule, messageSuccessRule } from '../utility/util';
19
-
20
- export function migrateToWebcomponent(options: any): Rule {
21
- return chain([
22
- messageInfoRule(`LUX-Componentsprojekt wird zur Web Component umgebaut...`),
23
- updateAppComponent(options),
24
- updatePackageJson(options),
25
- updateAngularJson(options),
26
- updateAppRoutingModule(options),
27
- updateAppComponentHtml(options),
28
- createWebpackConfigJs(options),
29
- updateIndexHtml(options),
30
- updateAppModule(options),
31
- messageSuccessRule(`LUX-Componentsprojekt wurde zur Web Component umgebaut.`),
32
- finish()
33
- ]);
34
- }
35
-
36
- export function updateAppComponent(options: any): Rule {
37
- return chain([
38
- messageInfoRule(`AppComponent wird aktualisiert...`),
39
- (tree: Tree, context: SchematicContext) => {
40
- // Init
41
- const filePath = (options.path ? options.path : '') + '/src/app/app.component.ts';
42
-
43
- addImport(tree, filePath, '@ihk-gfi/lux-components', 'LuxAppService');
44
- addImport(tree, filePath, '@angular/core', 'ElementRef');
45
- addImport(tree, filePath, '@angular/core', 'Input');
46
-
47
- addConstructorParameter(tree, filePath, `private elementRef: ElementRef`);
48
- addConstructorParameter(tree, filePath, `private appService: LuxAppService`);
49
- addConstructorContent(tree, filePath,'this.appService.appEl = elementRef.nativeElement;', false);
50
- addConstructorContent(tree, filePath,'router.initialNavigation();', true);
51
-
52
- addClassProperty(tree, filePath, '@Input() luxAppHeader: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
53
- addClassProperty(tree, filePath, '@Input() luxAppFooter: \'normal\' | \'minimal\' | \'none\' = \'normal\';');
54
- addClassProperty(tree, filePath, '@Input() luxMode: \'stand-alone\' | \'portal\' = \'stand-alone\';');
55
- },
56
- messageSuccessRule(`AppComponent wurde aktualisiert.`)
57
- ]);
58
- }
59
-
60
- export function updatePackageJson(options: any): Rule {
61
- return chain([
62
- messageInfoRule(`Die Datei "package.json" wird angepasst...`),
63
- (tree: Tree, _context: SchematicContext) => {
64
- const filePath = `/package.json`;
65
-
66
- const newValuesArr = [
67
- { path: ['scripts', 'build-aot'], value: "ng lint --fix", message: `Skript "build-aot" aktualisiert.`},
68
- { path: ['scripts', 'buildzentral'], value: "ng lint --fix", message: `Skript "buildzentral" aktualisiert.`},
69
- { path: ['dependencies', '@webcomponents/webcomponentsjs'], value: "2.5.0", message: `Unter "dependencies" "@webcomponents/webcomponentsjs" hinzugefügt.`},
70
- { path: ['dependencies', 'ngx-build-plus'], value: "^11.0.0", message: `Unter "dependencies" "ngx-build-plus" hinzugefügt.`},
71
- { path: ['devDependencies', '@angular/elements'], value: "11.2.14", message: `Unter "devDependencies" "@angular/elements" hinzugefügt.`},
72
- { path: ['devDependencies', 'replace-in-file'], value: "6.2.0", message: `Unter "devDependencies" "replace-in-file" hinzugefügt.`}
73
- ];
74
-
75
- const packageJsonAsNode = readJson(tree, filePath);
76
- const buildAotScriptNode = findNodeAtLocation(packageJsonAsNode, ['scripts', 'build-aot']);
77
- if (buildAotScriptNode) {
78
- newValuesArr.push({
79
- path: ['scripts', 'build-aot'],
80
- value: appendScript(buildAotScriptNode.value, ' --single-bundle --output-hashing none'),
81
- message: `Das Skript "build-aot" angepasst.`
82
- });
83
- } else {
84
- newValuesArr.push({
85
- path: ['scripts', 'build-aot'],
86
- value: 'node --max_old_space_size=4024 ./node_modules/@angular/cli/bin/ng build --aot --single-bundle --output-hashing none && npm run move-de-files',
87
- message: `Das neue Skript "build-aot" hinzugefügt.`
88
- });
89
- }
90
-
91
- const buildZentralScriptNode = findNodeAtLocation(packageJsonAsNode, ['scripts', 'buildzentral']);
92
- if (buildZentralScriptNode) {
93
- newValuesArr.push({
94
- path: ['scripts', 'buildzentral'],
95
- value: appendScript(buildZentralScriptNode.value, ' --single-bundle --output-hashing none --plugin @ihk-gfi/lux-components/ie11-lazy-modules-plugin.js'),
96
- message: `Das Skript "buildzentral" angepasst.`
97
- });
98
- } else {
99
- newValuesArr.push({
100
- path: ['scripts', 'buildzentral'],
101
- value: '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',
102
- message: `Das neue Skript "buildzentral" hinzugefügt.`
103
- });
104
- }
105
-
106
- newValuesArr.forEach(change => {
107
- const tsConfigJson = readJsonAsString(tree, filePath);
108
- const edits: Edit[] = modify(tsConfigJson, change.path, change.value, { formattingOptions: jsonFormattingOptions })
109
-
110
- tree.overwrite(
111
- filePath,
112
- applyEdits(tsConfigJson, edits)
113
- );
114
-
115
- logInfo(change.message);
116
- });
117
-
118
- return tree;
119
- },
120
- messageSuccessRule(`Die Datei "package.json" wurde angepasst.`)
121
- ]);
122
- }
123
-
124
- export function updateAppRoutingModule(options: any): Rule {
125
- return chain([
126
- messageInfoRule(`Die Datei "app-routing.module.ts" wird angepasst...`),
127
- (tree: Tree, context: SchematicContext) => {
128
- iterateFilesAndModifyContent(
129
- tree,
130
- options.path,
131
- (filePath: string, content: string) => {
132
- let modifiedContent = content;
133
- modifiedContent = modifiedContent.replace(/import\('app\//g, 'import(\'./');
134
- modifiedContent = modifiedContent.replace(/import\("app\//g, 'import("./');
135
-
136
- if (content !== modifiedContent) {
137
- tree.overwrite(filePath, modifiedContent);
138
- logInfo(`Lazy-Importe angepasst.`);
139
- }
140
- },
141
- 'app-routing.module.ts'
142
- );
143
- },
144
- messageSuccessRule(`Die Datei "app-routing.module.ts" wurde angepasst.`)
145
- ]);
146
- }
147
-
148
- export function updateAngularJson(options: any): Rule {
149
- return chain([
150
- messageInfoRule(`Die Datei "angular.json" wird angepasst...`),
151
- (tree: Tree, _context: SchematicContext) => {
152
- const filePath = `/angular.json`;
153
-
154
- const newValuesArr = [
155
- {
156
- path: ['projects', options.project, 'architect', 'build', 'options', 'extraWebpackConfig'],
157
- value: 'webpack.config.js',
158
- message: `Der Abschnitt "extraWebpackConfig" wurde hinzugefügt.`,
159
- options: { formattingOptions: jsonFormattingOptions }
160
- },
161
- {
162
- path: ['projects', options.project, 'architect', 'build', 'options', 'scripts', 0],
163
- value: {
164
- bundleName: 'polyfill-webcomp-es5',
165
- input: 'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js'
166
- },
167
- message: `Skript "polyfill-webcomp-es5" wurde hinzugefügt.`,
168
- options: { formattingOptions: jsonFormattingOptions, isArrayInsertion: true }
169
- },
170
- {
171
- path: ['projects', options.project, 'architect', 'build', 'options', 'scripts', 0],
172
- value: {
173
- "bundleName": "polyfill-webcomp",
174
- "input": "node_modules/@webcomponents/webcomponentsjs/bundles/webcomponents-sd-ce-pf.js"
175
- },
176
- message: `Skript "polyfill-webcomp" wurde hinzugefügt.`,
177
- options: { formattingOptions: jsonFormattingOptions, isArrayInsertion: true }
178
- }
179
- ];
180
-
181
- newValuesArr.forEach(change => {
182
- const tsConfigJson = readJsonAsString(tree, filePath);
183
- const edits: Edit[] = modify(tsConfigJson, change.path, change.value, change.options)
184
-
185
- tree.overwrite(
186
- filePath,
187
- applyEdits(tsConfigJson, edits)
188
- );
189
-
190
- logInfo(change.message);
191
- });
192
-
193
- const content = (tree.read(filePath) as Buffer).toString();
194
-
195
- let modifiedContent = content;
196
- modifiedContent = modifiedContent.replace(new RegExp('@angular-devkit/build-angular:browser', 'g'), 'ngx-build-plus:browser');
197
- modifiedContent = modifiedContent.replace(new RegExp('@angular-devkit/build-angular:dev-server', 'g'), 'ngx-build-plus:dev-server');
198
- modifiedContent = modifiedContent.replace(new RegExp('@angular-devkit/build-angular:karma', 'g'), 'ngx-build-plus:karma');
199
-
200
- if (content !== modifiedContent) {
201
- tree.overwrite(filePath, modifiedContent);
202
- logInfo(`Einträge für den ngx-build-plus hinzugefügt.`);
203
- }
204
-
205
- return tree;
206
- },
207
- messageSuccessRule(`Die Datei "angular.json" wurde angepasst.`)
208
- ]);
209
- }
210
-
211
- export function updateAppModule(options: any): Rule {
212
- return chain([
213
- messageInfoRule(`Die Datei "app.module.ts" wird angepasst...`),
214
- (tree: Tree, context: SchematicContext) => {
215
- const filePath = (options.path ? options.path : '') + `/src/app/app.module.ts`;
216
-
217
- addImport(tree, filePath, '@angular/core', 'CUSTOM_ELEMENTS_SCHEMA');
218
- addImport(tree, filePath, '@angular/core', 'DoBootstrap');
219
- addImport(tree, filePath, '@angular/core', 'Injector');
220
- addImport(tree, filePath, '@angular/elements', 'createCustomElement');
221
-
222
- addInterface(tree, filePath, 'DoBootstrap');
223
-
224
- const service = `private injector: Injector`;
225
- addConstructorParameter(tree, filePath, service);
226
-
227
- addMethod(tree, filePath, getSyntaxListOfClass(tree, filePath), `
228
- ngDoBootstrap() {
229
- const ce = createCustomElement(AppComponent, { injector: this.injector });
230
- customElements.define('${getWebComponentTagName(options.project as string)}', ce);
231
- }`);
232
- logInfo(`ngDoBootstrap() {...} hinzugefügt.`);
233
-
234
- const content = (tree.read(filePath) as Buffer).toString();
235
- const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.length);
236
- const sourceFile = ts.createSourceFile(`${fileName}`, content, ts.ScriptTarget.Latest, true);
237
- const nodes = getSourceNodes(sourceFile);
238
-
239
- const bootstrap = nodes.find((n) => n.kind === ts.SyntaxKind.Identifier && n.getText() === 'bootstrap');
240
-
241
- if (bootstrap) {
242
- const updateRecorder = tree.beginUpdate(filePath);
243
- updateRecorder.remove(bootstrap.parent.pos, bootstrap.parent.end - bootstrap.parent.pos);
244
- updateRecorder.insertLeft(bootstrap.parent.pos, `\n schemas: [CUSTOM_ELEMENTS_SCHEMA]`);
245
- tree.commitUpdate(updateRecorder);
246
- logInfo(`bootstrap: [...] entfernt.`);
247
- logInfo(`schemas: [CUSTOM_ELEMENTS_SCHEMA] hinzugefügt.`);
248
- }
249
-
250
- },
251
- messageSuccessRule(`Die Datei "app.module.ts" wurde angepasst.`)
252
- ]);
253
- }
254
-
255
- export function updateIndexHtml(options: any): Rule {
256
- return chain([
257
- messageInfoRule(`Die Datei "index.html" wird angepasst...`),
258
- (tree: Tree, context: SchematicContext) => {
259
-
260
- let tagName = getWebComponentTagName(options.project as string);
261
-
262
- const filePath = 'src/index.html';
263
- const content = (tree.read(filePath) as Buffer).toString();
264
- const modifiedContent = content.replace(/app-root/g, tagName);
265
-
266
- tree.overwrite(filePath, modifiedContent);
267
- logInfo(`Das Tag "app-root" wurde umbenannt in "${tagName}".`);
268
- },
269
- messageSuccessRule(`Die Datei "index.html" wurde angepasst.`)
270
- ]);
271
- }
272
-
273
- export function createWebpackConfigJs(options: any): Rule {
274
- return chain([
275
- messageInfoRule(`Die Datei "webpack.config.js" wird angelegt...`),
276
- (tree: Tree, context: SchematicContext) => {
277
-
278
- let functionName = options.project as string;
279
- functionName = functionName.replace('-', '');
280
- functionName = functionName.replace('_', '');
281
- functionName = functionName.substring(0, 1).toUpperCase() + functionName.substring(1);
282
-
283
- tree.create('webpack.config.js', `
284
- module.exports = {
285
- output: {
286
- jsonpFunction: 'jsonpFunction${functionName}'
287
- }
288
- };
289
-
290
- `);
291
- },
292
- messageSuccessRule(`Die Datei "webpack.config.js" wurde angelegt.`)
293
- ]);
294
- }
295
-
296
- export function updateAppComponentHtml(options: any): Rule {
297
- return chain([
298
- messageInfoRule(`Die Datei "app.component.html" wird angepasst...`),
299
- (tree: Tree, context: SchematicContext) => {
300
- iterateFilesAndModifyContent(
301
- tree,
302
- options.path,
303
- (filePath: string, content: string) => {
304
- let result = addAttribute(content, 'lux-app-header', "*ngIf", 'this.luxAppHeader !== \'none\'');
305
- result = appendAttribute(result.content, 'lux-app-header-right-nav', "*ngIf", ' && luxMode === \'stand-alone\'');
306
- result = addAttribute(result.content, 'lux-app-footer', "*ngIf", 'this.luxAppFooter !== \'none\'');
307
-
308
- tree.overwrite(filePath, result.content);
309
-
310
- logInfo('Im "lux-app-header" das folgende Attribut *ngIf="this.luxAppHeader !== \'none\'" ergänzt.');
311
- logInfo('Im "lux-app-header-right-nav" den Wert " && luxMode === \'stand-alone\'" an das Attribut "*ngIf" angehangen.');
312
- logInfo('Im "lux-app-footer" das folgende Attribut *ngIf="this.luxAppFooter !== \'none\'" ergänzt.');
313
- },
314
- 'app.component.html'
315
- );
316
- },
317
- messageSuccessRule(`Die Datei "app.component.html" wurde angepasst.`)
318
- ]);
319
- }
320
-
321
- function getWebComponentTagName(projectName: string) {
322
- let tagName = projectName;
323
- tagName = tagName.replace(/[^a-z]/gi, '');
324
- tagName = tagName.toLowerCase();
325
- if (tagName.startsWith('lux')) {
326
- tagName = tagName.replace(/lux/i, 'lux-');
327
- } else {
328
- tagName = 'lux-' + tagName;
329
- }
330
- return tagName;
331
- }