@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.
- package/LICENSE +198 -0
- package/README.md +55 -0
- package/package.json +54 -0
- package/src/add-lux-components/files/app/app-routing.module.ts +19 -0
- package/src/add-lux-components/files/app/app.component.html +27 -0
- package/src/add-lux-components/files/app/app.component.spec.ts +19 -0
- package/src/add-lux-components/files/app/app.component.ts +13 -0
- package/src/add-lux-components/files/app/app.module.ts +56 -0
- package/src/add-lux-components/files/app/error/error.component.html +10 -0
- package/src/add-lux-components/files/app/error/error.component.scss +3 -0
- package/src/add-lux-components/files/app/error/error.component.spec.ts +49 -0
- package/src/add-lux-components/files/app/error/error.component.ts +17 -0
- package/src/add-lux-components/files/app/home/home.component.html +7 -0
- package/src/add-lux-components/files/app/home/home.component.scss +0 -0
- package/src/add-lux-components/files/app/home/home.component.ts +13 -0
- package/src/add-lux-components/files/app/profil/profil.component.html +1 -0
- package/src/add-lux-components/files/app/profil/profil.component.scss +0 -0
- package/src/add-lux-components/files/app/profil/profil.component.spec.ts +24 -0
- package/src/add-lux-components/files/app/profil/profil.component.ts +11 -0
- package/src/add-lux-components/files/environments/environment.prod.ts +4 -0
- package/src/add-lux-components/files/environments/environment.ts +17 -0
- package/src/add-lux-components/files/locale/messages.en.xlf +948 -0
- package/src/add-lux-components/files/locale/messages.xlf +822 -0
- package/src/add-lux-components/files/scripts/.browserslistrc +17 -0
- package/src/add-lux-components/files/src/polyfills.ts +68 -0
- package/src/add-lux-components/index.d.ts +10 -0
- package/src/add-lux-components/index.js +143 -0
- package/src/add-lux-components/index.js.map +1 -0
- package/src/add-lux-components/index.ts +183 -0
- package/src/add-lux-components/index_spec.d.ts +1 -0
- package/src/add-lux-components/index_spec.js +51 -0
- package/src/add-lux-components/index_spec.js.map +1 -0
- package/src/add-lux-components/index_spec.ts +55 -0
- package/src/add-lux-components/schema.json +23 -0
- package/src/collection.json +55 -0
- package/src/migrate-to-eslint/files/.eslintrc.json +68 -0
- package/src/migrate-to-eslint/files/.prettierrc +25 -0
- package/src/migrate-to-eslint/index.d.ts +6 -0
- package/src/migrate-to-eslint/index.js +149 -0
- package/src/migrate-to-eslint/index.js.map +1 -0
- package/src/migrate-to-eslint/index.ts +181 -0
- package/src/migrate-to-eslint/index_spec.d.ts +1 -0
- package/src/migrate-to-eslint/index_spec.js +129 -0
- package/src/migrate-to-eslint/index_spec.js.map +1 -0
- package/src/migrate-to-eslint/index_spec.ts +152 -0
- package/src/migrate-to-eslint/schema.json +23 -0
- package/src/migrate-to-webcomponent/index.d.ts +10 -0
- package/src/migrate-to-webcomponent/index.js +278 -0
- package/src/migrate-to-webcomponent/index.js.map +1 -0
- package/src/migrate-to-webcomponent/index.ts +331 -0
- package/src/migrate-to-webcomponent/index_spec.d.ts +1 -0
- package/src/migrate-to-webcomponent/index_spec.js +580 -0
- package/src/migrate-to-webcomponent/index_spec.js.map +1 -0
- package/src/migrate-to-webcomponent/index_spec.ts +703 -0
- package/src/migrate-to-webcomponent/schema.json +23 -0
- package/src/update/files/locale/messages.en.xlf +940 -0
- package/src/update/files/locale/messages.xlf +815 -0
- package/src/update/files/scripts/move-de-files.js +15 -0
- package/src/update/index.d.ts +23 -0
- package/src/update/index.js +635 -0
- package/src/update/index.js.map +1 -0
- package/src/update/index.ts +712 -0
- package/src/update/index_spec.d.ts +1 -0
- package/src/update/index_spec.js +990 -0
- package/src/update/index_spec.js.map +1 -0
- package/src/update/index_spec.ts +1145 -0
- package/src/update/schema.json +23 -0
- package/src/update-dependencies/index.d.ts +5 -0
- package/src/update-dependencies/index.js +113 -0
- package/src/update-dependencies/index.js.map +1 -0
- package/src/update-dependencies/index.ts +114 -0
- package/src/update-dependencies/schema.json +23 -0
- package/src/update110001/index.d.ts +2 -0
- package/src/update110001/index.js +42 -0
- package/src/update110001/index.js.map +1 -0
- package/src/update110001/index.ts +40 -0
- package/src/update110001/index_spec.d.ts +1 -0
- package/src/update110001/index_spec.js +67 -0
- package/src/update110001/index_spec.js.map +1 -0
- package/src/update110001/index_spec.ts +72 -0
- package/src/update110001/schema.json +23 -0
- package/src/update110100/index.d.ts +2 -0
- package/src/update110100/index.js +27 -0
- package/src/update110100/index.js.map +1 -0
- package/src/update110100/index.ts +24 -0
- package/src/update110100/index_spec.d.ts +1 -0
- package/src/update110100/index_spec.js +69 -0
- package/src/update110100/index_spec.js.map +1 -0
- package/src/update110100/index_spec.ts +73 -0
- package/src/update110100/schema.json +23 -0
- package/src/update110101/index.d.ts +2 -0
- package/src/update110101/index.js +24 -0
- package/src/update110101/index.js.map +1 -0
- package/src/update110101/index.ts +21 -0
- package/src/update110101/index_spec.d.ts +1 -0
- package/src/update110101/index_spec.js +65 -0
- package/src/update110101/index_spec.js.map +1 -0
- package/src/update110101/index_spec.ts +69 -0
- package/src/update110101/schema.json +23 -0
- package/src/update110200/index.d.ts +2 -0
- package/src/update110200/index.js +24 -0
- package/src/update110200/index.js.map +1 -0
- package/src/update110200/index.ts +21 -0
- package/src/update110200/index_spec.d.ts +1 -0
- package/src/update110200/index_spec.js +65 -0
- package/src/update110200/index_spec.js.map +1 -0
- package/src/update110200/index_spec.ts +69 -0
- package/src/update110200/schema.json +23 -0
- package/src/update110300/index.d.ts +2 -0
- package/src/update110300/index.js +133 -0
- package/src/update110300/index.js.map +1 -0
- package/src/update110300/index.ts +148 -0
- package/src/update110300/index_spec.d.ts +1 -0
- package/src/update110300/index_spec.js +121 -0
- package/src/update110300/index_spec.js.map +1 -0
- package/src/update110300/index_spec.ts +139 -0
- package/src/update110300/schema.json +23 -0
- package/src/utility/dependencies.d.ts +39 -0
- package/src/utility/dependencies.js +96 -0
- package/src/utility/dependencies.js.map +1 -0
- package/src/utility/dependencies.ts +116 -0
- package/src/utility/files.d.ts +60 -0
- package/src/utility/files.js +299 -0
- package/src/utility/files.js.map +1 -0
- package/src/utility/files.ts +355 -0
- package/src/utility/html.d.ts +49 -0
- package/src/utility/html.js +183 -0
- package/src/utility/html.js.map +1 -0
- package/src/utility/html.ts +212 -0
- package/src/utility/json.d.ts +34 -0
- package/src/utility/json.js +70 -0
- package/src/utility/json.js.map +1 -0
- package/src/utility/json.ts +70 -0
- package/src/utility/logging.d.ts +32 -0
- package/src/utility/logging.js +82 -0
- package/src/utility/logging.js.map +1 -0
- package/src/utility/logging.ts +80 -0
- package/src/utility/test.d.ts +10 -0
- package/src/utility/test.js +24 -0
- package/src/utility/test.js.map +1 -0
- package/src/utility/test.ts +24 -0
- package/src/utility/typescript.d.ts +22 -0
- package/src/utility/typescript.js +521 -0
- package/src/utility/typescript.js.map +1 -0
- package/src/utility/typescript.ts +598 -0
- package/src/utility/typescript_spec.d.ts +1 -0
- package/src/utility/typescript_spec.js +1006 -0
- package/src/utility/typescript_spec.js.map +1 -0
- package/src/utility/typescript_spec.ts +1267 -0
- package/src/utility/util.d.ts +33 -0
- package/src/utility/util.js +139 -0
- package/src/utility/util.js.map +1 -0
- package/src/utility/util.ts +140 -0
- package/src/utility/validation.d.ts +11 -0
- package/src/utility/validation.js +44 -0
- package/src/utility/validation.js.map +1 -0
- package/src/utility/validation.ts +49 -0
- package/tsconfig.json +37 -0
|
@@ -0,0 +1,331 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|