@ihk-gfi/lux-components-update 13.3.0 → 14.0.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/README.md +2 -2
- package/package.json +10 -8
- package/src/add-lux-components/files/app/app-routing.module.ts +2 -0
- package/src/add-lux-components/files/app/app.component.html +7 -2
- package/src/add-lux-components/files/app/app.component.ts +9 -1
- package/src/add-lux-components/files/app/app.module.ts +6 -1
- package/src/add-lux-components/files/app/base/license-hint/license-hint.component.html +7 -0
- package/src/add-lux-components/files/app/base/license-hint/license-hint.component.ts +18 -0
- package/src/add-lux-components/files/app/home/home.component.scss +3 -0
- package/src/add-lux-components/files/assets/svg/Example.svg +6 -0
- package/src/add-lux-components/files/assets/svg/android.svg +2 -0
- package/src/add-lux-components/files/assets/svg/box.svg +690 -0
- package/src/add-lux-components/files/assets/svg/demoAppLogo.svg +1 -0
- package/src/add-lux-components/files/assets/svg/red_power_button.svg +67 -0
- package/src/add-lux-components/files/assets/svg/svg2009.svg +57457 -0
- package/src/add-lux-components/files/environments/environment.ts +2 -2
- package/src/add-lux-components/files/locale/messages.en.xlf +544 -373
- package/src/add-lux-components/files/locale/messages.xlf +517 -352
- package/src/add-lux-components/files/src/polyfills.ts +29 -39
- package/src/add-lux-components/index.d.ts +1 -1
- package/src/add-lux-components/index.js +47 -26
- package/src/add-lux-components/index.js.map +1 -1
- package/src/add-lux-components/index.ts +50 -31
- package/src/add-lux-components/index_spec.js +3 -3
- package/src/add-lux-components/index_spec.ts +1 -1
- package/src/collection.json +13 -19
- package/src/theme/change-theme-to-authentic/index.d.ts +4 -0
- package/src/theme/change-theme-to-authentic/index.js +129 -0
- package/src/theme/change-theme-to-authentic/index.js.map +1 -0
- package/src/theme/change-theme-to-authentic/index.ts +131 -0
- package/src/{updates/update130000 → theme/change-theme-to-authentic}/index_spec.d.ts +0 -0
- package/src/theme/change-theme-to-authentic/index_spec.js +300 -0
- package/src/theme/change-theme-to-authentic/index_spec.js.map +1 -0
- package/src/theme/change-theme-to-authentic/index_spec.ts +321 -0
- package/src/{updates/update130300 → theme/change-theme-to-authentic}/schema.json +3 -3
- package/src/theme/change-to-lux-icons/index.d.ts +7 -0
- package/src/theme/change-to-lux-icons/index.js +395 -0
- package/src/theme/change-to-lux-icons/index.js.map +1 -0
- package/src/theme/change-to-lux-icons/index.ts +406 -0
- package/src/{updates/update130100 → theme/change-to-lux-icons}/index_spec.d.ts +0 -0
- package/src/theme/change-to-lux-icons/index_spec.js +214 -0
- package/src/theme/change-to-lux-icons/index_spec.js.map +1 -0
- package/src/theme/change-to-lux-icons/index_spec.ts +220 -0
- package/src/{updates/update130200 → theme/change-to-lux-icons}/schema.json +3 -3
- package/src/update-dependencies/index.d.ts +0 -3
- package/src/update-dependencies/index.js +68 -116
- package/src/update-dependencies/index.js.map +1 -1
- package/src/update-dependencies/index.ts +73 -122
- package/src/update-en-messages/index.js +18 -15
- package/src/update-en-messages/index.js.map +1 -1
- package/src/update-en-messages/index.ts +22 -16
- package/src/updates/update140000/files/src/polyfills.ts +70 -0
- package/src/updates/update140000/index.d.ts +8 -0
- package/src/updates/update140000/index.js +83 -0
- package/src/updates/update140000/index.js.map +1 -0
- package/src/updates/update140000/index.ts +97 -0
- package/src/updates/{update130200 → update140000}/index_spec.d.ts +0 -0
- package/src/updates/update140000/index_spec.js +77 -0
- package/src/updates/update140000/index_spec.js.map +1 -0
- package/src/updates/update140000/index_spec.ts +79 -0
- package/src/updates/{update130000 → update140000}/schema.json +0 -0
- package/src/utility/files.d.ts +2 -2
- package/src/utility/files.js +5 -5
- package/src/utility/files.js.map +1 -1
- package/src/utility/files.ts +5 -5
- package/src/utility/html/hit.d.ts +21 -0
- package/src/utility/html/hit.js +27 -0
- package/src/utility/html/hit.js.map +1 -0
- package/src/utility/html/hit.ts +28 -0
- package/src/utility/html/html-manipulator.d.ts +71 -0
- package/src/utility/html/html-manipulator.js +136 -0
- package/src/utility/html/html-manipulator.js.map +1 -0
- package/src/utility/html/html-manipulator.ts +156 -0
- package/src/utility/{html_spec.d.ts → html/html_spec.d.ts} +0 -0
- package/src/utility/{html_spec.js → html/html_spec.js} +232 -100
- package/src/utility/html/html_spec.js.map +1 -0
- package/src/utility/{html_spec.ts → html/html_spec.ts} +282 -106
- package/src/utility/html/manipulator-functions.d.ts +99 -0
- package/src/utility/html/manipulator-functions.js +147 -0
- package/src/utility/html/manipulator-functions.js.map +1 -0
- package/src/utility/html/manipulator-functions.ts +149 -0
- package/src/utility/json.d.ts +2 -2
- package/src/utility/json.js +11 -7
- package/src/utility/json.js.map +1 -1
- package/src/utility/json.ts +42 -26
- package/src/utility/json_spec.js +18 -18
- package/src/utility/json_spec.js.map +1 -1
- package/src/utility/json_spec.ts +136 -66
- package/src/utility/typescript.d.ts +3 -3
- package/src/utility/typescript.js +2 -2
- package/src/utility/typescript.js.map +1 -1
- package/src/utility/typescript.ts +3 -3
- package/src/utility/typescript_spec.js +0 -1
- package/src/utility/typescript_spec.js.map +1 -1
- package/src/utility/typescript_spec.ts +0 -2
- package/src/utility/util.d.ts +7 -6
- package/src/utility/util.js +12 -8
- package/src/utility/util.js.map +1 -1
- package/src/utility/util.ts +13 -10
- package/src/utility/validation.d.ts +2 -3
- package/src/utility/validation.js +2 -3
- package/src/utility/validation.js.map +1 -1
- package/src/utility/validation.ts +2 -3
- package/tsconfig.json +5 -7
- package/src/add-lux-components/files/scripts/.browserslistrc +0 -20
- package/src/updates/update130000/files/root/.browserslistrc +0 -20
- package/src/updates/update130000/index.d.ts +0 -27
- package/src/updates/update130000/index.js +0 -310
- package/src/updates/update130000/index.js.map +0 -1
- package/src/updates/update130000/index.ts +0 -362
- package/src/updates/update130000/index_spec.js +0 -584
- package/src/updates/update130000/index_spec.js.map +0 -1
- package/src/updates/update130000/index_spec.ts +0 -675
- package/src/updates/update130100/index.d.ts +0 -2
- package/src/updates/update130100/index.js +0 -27
- package/src/updates/update130100/index.js.map +0 -1
- package/src/updates/update130100/index.ts +0 -27
- package/src/updates/update130100/index_spec.js +0 -65
- package/src/updates/update130100/index_spec.js.map +0 -1
- package/src/updates/update130100/index_spec.ts +0 -69
- package/src/updates/update130100/schema.json +0 -23
- package/src/updates/update130200/index.d.ts +0 -2
- package/src/updates/update130200/index.js +0 -43
- package/src/updates/update130200/index.js.map +0 -1
- package/src/updates/update130200/index.ts +0 -41
- package/src/updates/update130200/index_spec.js +0 -106
- package/src/updates/update130200/index_spec.js.map +0 -1
- package/src/updates/update130200/index_spec.ts +0 -110
- package/src/updates/update130300/index.d.ts +0 -2
- package/src/updates/update130300/index.js +0 -35
- package/src/updates/update130300/index.js.map +0 -1
- package/src/updates/update130300/index.ts +0 -32
- package/src/updates/update130300/index_spec.d.ts +0 -1
- package/src/updates/update130300/index_spec.js +0 -85
- package/src/updates/update130300/index_spec.js.map +0 -1
- package/src/updates/update130300/index_spec.ts +0 -89
- package/src/utility/html.d.ts +0 -49
- package/src/utility/html.js +0 -246
- package/src/utility/html.js.map +0 -1
- package/src/utility/html.ts +0 -288
- package/src/utility/html_spec.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeAttrFn = exports.appendAttrFn = exports.updateAttrFn = exports.updateAttrIfFn = exports.renameAttrFn = exports.renameElementFn = exports.removeElementFn = exports.addAttrFn = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
/**
|
|
6
|
+
* Diese Funktion fügt dem Element ein neues Attribut hinzu. Das neue Attribut wird direkt hinter dem Tag als erstes Attribut hinzugefügt.
|
|
7
|
+
*
|
|
8
|
+
* @example Neues Attribut "luxHint"
|
|
9
|
+
* Input: <lux-input luxLabel="Lorem ipsum"></lux-input>
|
|
10
|
+
* Output: <lux-input luxHint="Hint" luxLabel="Lorem ipsum"></lux-input>
|
|
11
|
+
*
|
|
12
|
+
* @param name Ein Attributname.
|
|
13
|
+
* @param value Ein Attributwert.
|
|
14
|
+
*/
|
|
15
|
+
const addAttrFn = (name, value) => {
|
|
16
|
+
return (hit) => {
|
|
17
|
+
hit.elementContent = (0, util_1.replaceFirst)(hit.elementContent, `<${hit.selector}`, `<${hit.selector} ${name}="${value}"`);
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.addAttrFn = addAttrFn;
|
|
21
|
+
/**
|
|
22
|
+
* Diese Funktion löscht das gesamte Element.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* Input: <lux-input luxLabel="Lorem ipsum"></lux-input>
|
|
26
|
+
* Output:
|
|
27
|
+
*
|
|
28
|
+
* @param hit Ein {@link Hit}.
|
|
29
|
+
*/
|
|
30
|
+
const removeElementFn = (hit) => {
|
|
31
|
+
hit.elementContent = '';
|
|
32
|
+
};
|
|
33
|
+
exports.removeElementFn = removeElementFn;
|
|
34
|
+
/**
|
|
35
|
+
* Diese Funktion benennt das Element um.
|
|
36
|
+
*
|
|
37
|
+
* @example Neuer Name "lux-input-ac"
|
|
38
|
+
* Input: <lux-input luxLabel="Lorem ipsum"></lux-input>
|
|
39
|
+
* Output: <lux-input-ac luxLabel="Lorem ipsum"></lux-input-ac>
|
|
40
|
+
*
|
|
41
|
+
* @param newName Der neue Name.
|
|
42
|
+
*/
|
|
43
|
+
const renameElementFn = (newName) => {
|
|
44
|
+
return (hit) => {
|
|
45
|
+
hit.elementContent = (0, util_1.replaceAll)(hit.elementContent, `<${hit.selector}>`, `<${newName}>`);
|
|
46
|
+
hit.elementContent = (0, util_1.replaceAll)(hit.elementContent, `<${hit.selector} `, `<${newName} `);
|
|
47
|
+
hit.elementContent = (0, util_1.replaceAll)(hit.elementContent, `<${hit.selector}\n`, `<${newName}\n`);
|
|
48
|
+
hit.elementContent = (0, util_1.replaceAll)(hit.elementContent, `</${hit.selector}>`, `</${newName}>`);
|
|
49
|
+
hit.elementContent = (0, util_1.replaceAll)(hit.elementContent, `</${hit.selector} `, `</${newName} `);
|
|
50
|
+
hit.elementContent = (0, util_1.replaceAll)(hit.elementContent, `<${hit.selector}\n`, `<${newName}\n`);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.renameElementFn = renameElementFn;
|
|
54
|
+
/**
|
|
55
|
+
* Diese Funktion benennt ein Attribut um.
|
|
56
|
+
*
|
|
57
|
+
* @example Alter Name "luxSelectedFiles", neuer Name "luxSelected"
|
|
58
|
+
* Input: <lux-file-list (luxSelectedFiles)="..."></lux-file-list>
|
|
59
|
+
* Output: <lux-file-list (luxSelected)="..."></lux-file-list>
|
|
60
|
+
*
|
|
61
|
+
* @param oldName Ein alter Name.
|
|
62
|
+
* @param newName Ein neuer Name.
|
|
63
|
+
*/
|
|
64
|
+
const renameAttrFn = (oldName, newName) => {
|
|
65
|
+
return (hit) => {
|
|
66
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?)' + oldName + '((\\)|\\]|\\)\\])?)\\s*=\\s*"(.*?)"', 'm');
|
|
67
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1' + newName + '$3="$5"');
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.renameAttrFn = renameAttrFn;
|
|
71
|
+
/**
|
|
72
|
+
* Diese Funktion aktualisiert den Attributwert nur, wenn dieser mit dem alten Wert übereinstimmt.
|
|
73
|
+
*
|
|
74
|
+
* @example Name "luxLabel", alter Wert "Vorname" und neuer Wert "Name" (alter Wert stimmt überein und der neue Wert wird gesetzt)
|
|
75
|
+
* Input: <lux-input luxLabel="Vorname"></lux-input>
|
|
76
|
+
* Output: <lux-input luxLabel="Name"></lux-input>
|
|
77
|
+
*
|
|
78
|
+
* @example Name "luxLabel", alter Wert "Name" und neuer Wert "Nachname" (alter Wert stimmt nicht überein und der HTML-Inhalt bleibt unverändert)
|
|
79
|
+
* Input: <lux-input luxLabel="Vorname"></lux-input>
|
|
80
|
+
* Output: <lux-input luxLabel="Vorname"></lux-input>
|
|
81
|
+
*
|
|
82
|
+
* @param name Ein Attributname.
|
|
83
|
+
* @param oldValue Ein alter Attributwert.
|
|
84
|
+
* @param newValue Ein neuer Attributwert.
|
|
85
|
+
*/
|
|
86
|
+
const updateAttrIfFn = (name, oldValue, newValue) => {
|
|
87
|
+
return (hit) => {
|
|
88
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?)\\s*=\\s*"(' + oldValue + ')"', 'm');
|
|
89
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1="' + newValue + '"');
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.updateAttrIfFn = updateAttrIfFn;
|
|
93
|
+
/**
|
|
94
|
+
* Diese Funktion aktualisiert den Attributwert, wenn es das Attribut gibt. D.h. wenn es das Attribut nicht gibt, wird es auch nicht angelegt.
|
|
95
|
+
*
|
|
96
|
+
* @example Name "luxLabel", Wert "Vorname" (Attribut vorhanden und der Wert wird gesetzt)
|
|
97
|
+
* Input: <lux-input luxLabel="Name"></lux-input>
|
|
98
|
+
* Output: <lux-input luxLabel="Vorname"></lux-input>
|
|
99
|
+
*
|
|
100
|
+
* @example Name "luxLabel", Wert "Vorname" (Attribut nicht vorhanden und der HTML-Inhalt bleibt unverändert)
|
|
101
|
+
* Input: <lux-input></lux-input>
|
|
102
|
+
* Output: <lux-input></lux-input>
|
|
103
|
+
*
|
|
104
|
+
* @param name Ein Attributname.
|
|
105
|
+
* @param value Ein Attributwert.
|
|
106
|
+
*/
|
|
107
|
+
const updateAttrFn = (name, value) => {
|
|
108
|
+
return (hit) => {
|
|
109
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?)\\s*=\\s*"(.*?)"', 'm');
|
|
110
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1="' + value + '"');
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
exports.updateAttrFn = updateAttrFn;
|
|
114
|
+
/**
|
|
115
|
+
* Diese Funktion hängt den Wert hinten an, wenn es das Attribut gibt.
|
|
116
|
+
*
|
|
117
|
+
* @example Name "luxLabel", Wert " (*)"
|
|
118
|
+
* Input: <lux-input luxLabel="Nachname"></lux-input>
|
|
119
|
+
* Output: <lux-input luxLabel="Nachname (*)"></lux-input>
|
|
120
|
+
*
|
|
121
|
+
* @param name Ein Attributname.
|
|
122
|
+
* @param appendValue Ein anzuhängender Wert.
|
|
123
|
+
*/
|
|
124
|
+
const appendAttrFn = (name, appendValue) => {
|
|
125
|
+
return (hit) => {
|
|
126
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?)\\s*=\\s*"(.*?)"', 'm');
|
|
127
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1="$4' + appendValue + '"');
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
exports.appendAttrFn = appendAttrFn;
|
|
131
|
+
/**
|
|
132
|
+
* Diese Funktion löscht ein Attribut.
|
|
133
|
+
*
|
|
134
|
+
* @example Attribut "luxHint"
|
|
135
|
+
* Input: <lux-input luxLabel="Name" luxHint="Lorem ipsum"></lux-input>
|
|
136
|
+
* Output: <lux-input luxLabel="Name"></lux-input>
|
|
137
|
+
*
|
|
138
|
+
* @param name Ein Attributname.
|
|
139
|
+
*/
|
|
140
|
+
const removeAttrFn = (name) => {
|
|
141
|
+
return (hit) => {
|
|
142
|
+
const pattern = new RegExp('(\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?\\s*=\\s*"(.*?)"', 'm');
|
|
143
|
+
hit.elementContent = hit.elementContent.replace(pattern, '');
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
exports.removeAttrFn = removeAttrFn;
|
|
147
|
+
//# sourceMappingURL=manipulator-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manipulator-functions.js","sourceRoot":"","sources":["manipulator-functions.ts"],"names":[],"mappings":";;;AAAA,kCAAmD;AAQnD;;;;;;;;;GASG;AACI,MAAM,SAAS,GAA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B,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,oBAAoB,GAAG,IAAI,GAAG,oCAAoC,EAAE,GAAG,CAAC,CAAC;QACpG,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;IACjF,CAAC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB;AAEF;;;;;;;;;GASG;AACI,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,WAAmB,EAAE,EAAE;IAChE,OAAO,CAAC,GAAQ,EAAE,EAAE;QAClB,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,oBAAoB,GAAG,IAAI,GAAG,oCAAoC,EAAE,GAAG,CAAC,CAAC;QACpG,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,GAAG,GAAG,CAAC,CAAC;IACzF,CAAC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB;AAEF;;;;;;;;GAQG;AACI,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IAC3C,OAAO,CAAC,GAAQ,EAAE,EAAE;QAClB,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,mBAAmB,GAAG,IAAI,GAAG,mCAAmC,EAAE,GAAG,CAAC,CAAC;QAClG,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { replaceAll, replaceFirst } from '../util';
|
|
2
|
+
import { Hit } from './hit';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef ManipulatorFn Eine Manipulator-Funktion transformiert den HTML-Inhalt eines {@link Element}s.
|
|
6
|
+
*/
|
|
7
|
+
export declare type ManipulatorFn = (hit: Hit) => void;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Diese Funktion fügt dem Element ein neues Attribut hinzu. Das neue Attribut wird direkt hinter dem Tag als erstes Attribut hinzugefügt.
|
|
11
|
+
*
|
|
12
|
+
* @example Neues Attribut "luxHint"
|
|
13
|
+
* Input: <lux-input luxLabel="Lorem ipsum"></lux-input>
|
|
14
|
+
* Output: <lux-input luxHint="Hint" luxLabel="Lorem ipsum"></lux-input>
|
|
15
|
+
*
|
|
16
|
+
* @param name Ein Attributname.
|
|
17
|
+
* @param value Ein Attributwert.
|
|
18
|
+
*/
|
|
19
|
+
export const addAttrFn = (name: string, value: string) => {
|
|
20
|
+
return (hit: Hit) => {
|
|
21
|
+
hit.elementContent = replaceFirst(hit.elementContent, `<${hit.selector}`, `<${hit.selector} ${name}="${value}"`);
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Diese Funktion löscht das gesamte Element.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* Input: <lux-input luxLabel="Lorem ipsum"></lux-input>
|
|
30
|
+
* Output:
|
|
31
|
+
*
|
|
32
|
+
* @param hit Ein {@link Hit}.
|
|
33
|
+
*/
|
|
34
|
+
export const removeElementFn = (hit: Hit) => {
|
|
35
|
+
hit.elementContent = '';
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Diese Funktion benennt das Element um.
|
|
40
|
+
*
|
|
41
|
+
* @example Neuer Name "lux-input-ac"
|
|
42
|
+
* Input: <lux-input luxLabel="Lorem ipsum"></lux-input>
|
|
43
|
+
* Output: <lux-input-ac luxLabel="Lorem ipsum"></lux-input-ac>
|
|
44
|
+
*
|
|
45
|
+
* @param newName Der neue Name.
|
|
46
|
+
*/
|
|
47
|
+
export const renameElementFn = (newName: string) => {
|
|
48
|
+
return (hit: Hit) => {
|
|
49
|
+
hit.elementContent = replaceAll(hit.elementContent, `<${hit.selector}>`, `<${newName}>`);
|
|
50
|
+
hit.elementContent = replaceAll(hit.elementContent, `<${hit.selector} `, `<${newName} `);
|
|
51
|
+
hit.elementContent = replaceAll(hit.elementContent, `<${hit.selector}\n`, `<${newName}\n`);
|
|
52
|
+
hit.elementContent = replaceAll(hit.elementContent, `</${hit.selector}>`, `</${newName}>`);
|
|
53
|
+
hit.elementContent = replaceAll(hit.elementContent, `</${hit.selector} `, `</${newName} `);
|
|
54
|
+
hit.elementContent = replaceAll(hit.elementContent, `<${hit.selector}\n`, `<${newName}\n`);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Diese Funktion benennt ein Attribut um.
|
|
60
|
+
*
|
|
61
|
+
* @example Alter Name "luxSelectedFiles", neuer Name "luxSelected"
|
|
62
|
+
* Input: <lux-file-list (luxSelectedFiles)="..."></lux-file-list>
|
|
63
|
+
* Output: <lux-file-list (luxSelected)="..."></lux-file-list>
|
|
64
|
+
*
|
|
65
|
+
* @param oldName Ein alter Name.
|
|
66
|
+
* @param newName Ein neuer Name.
|
|
67
|
+
*/
|
|
68
|
+
export const renameAttrFn = (oldName: string, newName: string) => {
|
|
69
|
+
return (hit: Hit) => {
|
|
70
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?)' + oldName + '((\\)|\\]|\\)\\])?)\\s*=\\s*"(.*?)"', 'm');
|
|
71
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1' + newName + '$3="$5"');
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Diese Funktion aktualisiert den Attributwert nur, wenn dieser mit dem alten Wert übereinstimmt.
|
|
77
|
+
*
|
|
78
|
+
* @example Name "luxLabel", alter Wert "Vorname" und neuer Wert "Name" (alter Wert stimmt überein und der neue Wert wird gesetzt)
|
|
79
|
+
* Input: <lux-input luxLabel="Vorname"></lux-input>
|
|
80
|
+
* Output: <lux-input luxLabel="Name"></lux-input>
|
|
81
|
+
*
|
|
82
|
+
* @example Name "luxLabel", alter Wert "Name" und neuer Wert "Nachname" (alter Wert stimmt nicht überein und der HTML-Inhalt bleibt unverändert)
|
|
83
|
+
* Input: <lux-input luxLabel="Vorname"></lux-input>
|
|
84
|
+
* Output: <lux-input luxLabel="Vorname"></lux-input>
|
|
85
|
+
*
|
|
86
|
+
* @param name Ein Attributname.
|
|
87
|
+
* @param oldValue Ein alter Attributwert.
|
|
88
|
+
* @param newValue Ein neuer Attributwert.
|
|
89
|
+
*/
|
|
90
|
+
export const updateAttrIfFn = (name: string, oldValue: string, newValue: string) => {
|
|
91
|
+
return (hit: Hit) => {
|
|
92
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?)\\s*=\\s*"(' + oldValue + ')"', 'm');
|
|
93
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1="' + newValue + '"');
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Diese Funktion aktualisiert den Attributwert, wenn es das Attribut gibt. D.h. wenn es das Attribut nicht gibt, wird es auch nicht angelegt.
|
|
99
|
+
*
|
|
100
|
+
* @example Name "luxLabel", Wert "Vorname" (Attribut vorhanden und der Wert wird gesetzt)
|
|
101
|
+
* Input: <lux-input luxLabel="Name"></lux-input>
|
|
102
|
+
* Output: <lux-input luxLabel="Vorname"></lux-input>
|
|
103
|
+
*
|
|
104
|
+
* @example Name "luxLabel", Wert "Vorname" (Attribut nicht vorhanden und der HTML-Inhalt bleibt unverändert)
|
|
105
|
+
* Input: <lux-input></lux-input>
|
|
106
|
+
* Output: <lux-input></lux-input>
|
|
107
|
+
*
|
|
108
|
+
* @param name Ein Attributname.
|
|
109
|
+
* @param value Ein Attributwert.
|
|
110
|
+
*/
|
|
111
|
+
export const updateAttrFn = (name: string, value: string) => {
|
|
112
|
+
return (hit: Hit) => {
|
|
113
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?)\\s*=\\s*"(.*?)"', 'm');
|
|
114
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1="' + value + '"');
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Diese Funktion hängt den Wert hinten an, wenn es das Attribut gibt.
|
|
120
|
+
*
|
|
121
|
+
* @example Name "luxLabel", Wert " (*)"
|
|
122
|
+
* Input: <lux-input luxLabel="Nachname"></lux-input>
|
|
123
|
+
* Output: <lux-input luxLabel="Nachname (*)"></lux-input>
|
|
124
|
+
*
|
|
125
|
+
* @param name Ein Attributname.
|
|
126
|
+
* @param appendValue Ein anzuhängender Wert.
|
|
127
|
+
*/
|
|
128
|
+
export const appendAttrFn = (name: string, appendValue: string) => {
|
|
129
|
+
return (hit: Hit) => {
|
|
130
|
+
const pattern = new RegExp('((\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?)\\s*=\\s*"(.*?)"', 'm');
|
|
131
|
+
hit.elementContent = hit.elementContent.replace(pattern, '$1="$4' + appendValue + '"');
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Diese Funktion löscht ein Attribut.
|
|
137
|
+
*
|
|
138
|
+
* @example Attribut "luxHint"
|
|
139
|
+
* Input: <lux-input luxLabel="Name" luxHint="Lorem ipsum"></lux-input>
|
|
140
|
+
* Output: <lux-input luxLabel="Name"></lux-input>
|
|
141
|
+
*
|
|
142
|
+
* @param name Ein Attributname.
|
|
143
|
+
*/
|
|
144
|
+
export const removeAttrFn = (name: string) => {
|
|
145
|
+
return (hit: Hit) => {
|
|
146
|
+
const pattern = new RegExp('(\\(|\\[|\\[\\()?' + name + '(\\)|\\]|\\)\\])?\\s*=\\s*"(.*?)"', 'm');
|
|
147
|
+
hit.elementContent = hit.elementContent.replace(pattern, '');
|
|
148
|
+
};
|
|
149
|
+
};
|
package/src/utility/json.d.ts
CHANGED
|
@@ -32,8 +32,8 @@ export declare function readJsonAsString(tree: Tree, filePath: string): string;
|
|
|
32
32
|
* @param index Ein Index (z.B. 0).
|
|
33
33
|
*/
|
|
34
34
|
export declare function appendScript(script: string, part: string, index?: number): string;
|
|
35
|
-
export declare function updateJsonValue(
|
|
36
|
-
export declare function updateJsonArray(
|
|
35
|
+
export declare function updateJsonValue(filePath: string, jsonPath: string[], value: any, onlyUpdate?: boolean): Rule;
|
|
36
|
+
export declare function updateJsonArray(filePath: string, jsonPath: string[], value: any, onlyUpdate?: boolean, findFn?: (value: Node) => boolean): Rule;
|
|
37
37
|
/**
|
|
38
38
|
* Diese Methode liefert den Index im Array des Objekts mit der übergebenen Property zurück.
|
|
39
39
|
*
|
package/src/utility/json.js
CHANGED
|
@@ -67,22 +67,25 @@ function appendScript(script, part, index) {
|
|
|
67
67
|
return newSkript;
|
|
68
68
|
}
|
|
69
69
|
exports.appendScript = appendScript;
|
|
70
|
-
function updateJsonValue(
|
|
71
|
-
return (tree,
|
|
70
|
+
function updateJsonValue(filePath, jsonPath, value, onlyUpdate = false) {
|
|
71
|
+
return (tree, _context) => {
|
|
72
72
|
const found = (0, jsonc_parser_1.findNodeAtLocation)(readJson(tree, filePath), jsonPath);
|
|
73
73
|
if (!onlyUpdate || (onlyUpdate && found)) {
|
|
74
74
|
const jsonFile = readJsonAsString(tree, filePath);
|
|
75
|
-
const edits = (0, jsonc_parser_1.modify)(jsonFile, jsonPath, value, {
|
|
75
|
+
const edits = (0, jsonc_parser_1.modify)(jsonFile, jsonPath, value, {
|
|
76
|
+
formattingOptions: exports.jsonFormattingOptions,
|
|
77
|
+
isArrayInsertion: false
|
|
78
|
+
});
|
|
76
79
|
if (edits) {
|
|
77
80
|
tree.overwrite(filePath, (0, jsonc_parser_1.applyEdits)(jsonFile, edits));
|
|
78
|
-
(0, logging_1.logInfo)(
|
|
81
|
+
(0, logging_1.logInfo)(`Wert ${getLogValue(value)} an der Stelle "${jsonPath.join('.')}" eingetragen.`);
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
exports.updateJsonValue = updateJsonValue;
|
|
84
|
-
function updateJsonArray(
|
|
85
|
-
return (tree,
|
|
87
|
+
function updateJsonArray(filePath, jsonPath, value, onlyUpdate = false, findFn) {
|
|
88
|
+
return (tree, _context) => {
|
|
86
89
|
// Gibt es bereits eine passende Stelle?
|
|
87
90
|
let foundIndex = -1;
|
|
88
91
|
let childrenCount = -1;
|
|
@@ -238,6 +241,7 @@ function removeJsonNode(tree, filePath, jsonPath, message = `Den Abschnitt "${JS
|
|
|
238
241
|
}
|
|
239
242
|
exports.removeJsonNode = removeJsonNode;
|
|
240
243
|
function getLogValue(value) {
|
|
241
|
-
|
|
244
|
+
let logValue = JSON.stringify(value);
|
|
245
|
+
return logValue && logValue.startsWith('"') && logValue.endsWith('"') ? logValue : `"${logValue}"`;
|
|
242
246
|
}
|
|
243
247
|
//# sourceMappingURL=json.js.map
|
package/src/utility/json.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["json.ts"],"names":[],"mappings":";;;AACA,+CAA0G;AAC1G,uCAAkE;AAErD,QAAA,qBAAqB,GAAsB;IACtD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,IAAI;CACV,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAU,EAAE,QAAgB;IACnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,MAAM,IAAA,sCAA4B,EAAC,oBAAoB,QAAQ,eAAe,CAAC,CAAC;KACjF;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAElC,IAAI,MAAM,GAAG,IAAA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,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC;AACrG,CAAC"}
|
package/src/utility/json.ts
CHANGED
|
@@ -69,30 +69,39 @@ export function appendScript(script: string, part: string, index?: number) {
|
|
|
69
69
|
return newSkript;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
export function updateJsonValue(
|
|
73
|
-
|
|
72
|
+
export function updateJsonValue(
|
|
73
|
+
filePath: string,
|
|
74
|
+
jsonPath: string[],
|
|
75
|
+
value: any,
|
|
76
|
+
onlyUpdate = false
|
|
77
|
+
): Rule {
|
|
78
|
+
return (tree: Tree, _context: SchematicContext) => {
|
|
74
79
|
const found = findNodeAtLocation(readJson(tree, filePath), jsonPath);
|
|
75
80
|
|
|
76
81
|
if (!onlyUpdate || (onlyUpdate && found)) {
|
|
77
82
|
const jsonFile = readJsonAsString(tree, filePath);
|
|
78
|
-
const edits = modify(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{ formattingOptions: jsonFormattingOptions, isArrayInsertion: false}
|
|
83
|
-
);
|
|
83
|
+
const edits = modify(jsonFile, jsonPath, value, {
|
|
84
|
+
formattingOptions: jsonFormattingOptions,
|
|
85
|
+
isArrayInsertion: false
|
|
86
|
+
});
|
|
84
87
|
|
|
85
88
|
if (edits) {
|
|
86
89
|
tree.overwrite(filePath, applyEdits(jsonFile, edits));
|
|
87
|
-
|
|
90
|
+
|
|
91
|
+
logInfo(`Wert ${getLogValue(value)} an der Stelle "${jsonPath.join('.')}" eingetragen.`);
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
|
|
93
|
-
export function updateJsonArray(
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
export function updateJsonArray(
|
|
98
|
+
filePath: string,
|
|
99
|
+
jsonPath: string[],
|
|
100
|
+
value: any,
|
|
101
|
+
onlyUpdate = false,
|
|
102
|
+
findFn?: (value: Node) => boolean
|
|
103
|
+
): Rule {
|
|
104
|
+
return (tree: Tree, _context: SchematicContext) => {
|
|
96
105
|
// Gibt es bereits eine passende Stelle?
|
|
97
106
|
let foundIndex = -1;
|
|
98
107
|
let childrenCount = -1;
|
|
@@ -113,7 +122,7 @@ export function updateJsonArray(options: any, filePath: string, jsonPath: string
|
|
|
113
122
|
|
|
114
123
|
if (findFn) {
|
|
115
124
|
for (let i = 0; i < node.children.length; i++) {
|
|
116
|
-
if (findFn(node.children[
|
|
125
|
+
if (findFn(node.children[i])) {
|
|
117
126
|
foundIndex = i;
|
|
118
127
|
break;
|
|
119
128
|
}
|
|
@@ -124,10 +133,10 @@ export function updateJsonArray(options: any, filePath: string, jsonPath: string
|
|
|
124
133
|
if (!onlyUpdate || (onlyUpdate && foundIndex >= 0)) {
|
|
125
134
|
const jsonFile = readJsonAsString(tree, filePath);
|
|
126
135
|
const edits = modify(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
jsonFile,
|
|
137
|
+
[...jsonPath, foundIndex >= 0 ? foundIndex : childrenCount !== -1 ? childrenCount : 0],
|
|
138
|
+
value,
|
|
139
|
+
{ formattingOptions: jsonFormattingOptions, isArrayInsertion: foundIndex === -1 }
|
|
131
140
|
);
|
|
132
141
|
|
|
133
142
|
if (edits) {
|
|
@@ -201,11 +210,11 @@ export function findObjectPropertyInArray(node: Node, propertyName: string, prop
|
|
|
201
210
|
if (assetObjectChildren[j].type === 'property') {
|
|
202
211
|
const propertyChildren = assetObjectChildren[j].children ?? [];
|
|
203
212
|
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
propertyChildren.length > 1 &&
|
|
214
|
+
propertyChildren[0].value === propertyName &&
|
|
215
|
+
propertyChildren[1].value === propertyValue
|
|
207
216
|
) {
|
|
208
|
-
|
|
217
|
+
found = true;
|
|
209
218
|
break;
|
|
210
219
|
}
|
|
211
220
|
}
|
|
@@ -250,12 +259,17 @@ export function findStringIndexInArray(arrayNode: Node, value: string): number {
|
|
|
250
259
|
return arrayIndex;
|
|
251
260
|
}
|
|
252
261
|
|
|
253
|
-
export function removeJsonNode(
|
|
254
|
-
|
|
262
|
+
export function removeJsonNode(
|
|
263
|
+
tree: Tree,
|
|
264
|
+
filePath: string,
|
|
265
|
+
jsonPath: (string | any)[],
|
|
266
|
+
message = `Den Abschnitt "${JSON.stringify(jsonPath)}" gelöscht.`
|
|
267
|
+
) {
|
|
268
|
+
const contentAsNode = readJson(tree, filePath);
|
|
255
269
|
const testAssetsNode = findNodeAtLocation(contentAsNode, jsonPath);
|
|
256
270
|
if (testAssetsNode) {
|
|
257
271
|
const angularJson = readJsonAsString(tree, filePath);
|
|
258
|
-
const edits
|
|
272
|
+
const edits = modify(angularJson, jsonPath, void 0, { formattingOptions: jsonFormattingOptions });
|
|
259
273
|
if (edits) {
|
|
260
274
|
tree.overwrite(filePath, applyEdits(angularJson, edits));
|
|
261
275
|
logInfo(message);
|
|
@@ -263,6 +277,8 @@ export function removeJsonNode(tree: Tree, filePath: string, jsonPath: (string |
|
|
|
263
277
|
}
|
|
264
278
|
}
|
|
265
279
|
|
|
266
|
-
function getLogValue(value: any) {
|
|
267
|
-
|
|
280
|
+
function getLogValue(value: any): string {
|
|
281
|
+
let logValue = JSON.stringify(value);
|
|
282
|
+
|
|
283
|
+
return logValue && logValue.startsWith('"') && logValue.endsWith('"') ? logValue : `"${logValue}"`;
|
|
268
284
|
}
|
package/src/utility/json_spec.js
CHANGED
|
@@ -37,18 +37,18 @@ describe('json', () => {
|
|
|
37
37
|
it('Sollte den neuen Wert hinzufügen', () => {
|
|
38
38
|
const filePath = testOptions.path + '/updateJsonValue/updateJsonValueAdd.json';
|
|
39
39
|
appTree.create(filePath, updateJsonValueAdd);
|
|
40
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonValue)(
|
|
40
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonValue)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'aaa'], 'bbb'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
41
41
|
var _a;
|
|
42
|
-
const content = (_a =
|
|
42
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
43
43
|
expect(content).toContain('"aaa": "bbb');
|
|
44
44
|
}, (reason) => expect(reason).toBeUndefined());
|
|
45
45
|
});
|
|
46
46
|
it('Sollte den neuen Wert ersetzen', () => {
|
|
47
47
|
const filePath = testOptions.path + '/updateJsonValue/updateJsonValueReplace.json';
|
|
48
48
|
appTree.create(filePath, updateJsonValueReplace);
|
|
49
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonValue)(
|
|
49
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonValue)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'aaa'], false), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
50
50
|
var _a;
|
|
51
|
-
const content = (_a =
|
|
51
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
52
52
|
expect(content).toContain('"aaa": false');
|
|
53
53
|
}, (reason) => expect(reason).toBeUndefined());
|
|
54
54
|
});
|
|
@@ -57,27 +57,27 @@ describe('json', () => {
|
|
|
57
57
|
it('Sollte das Array inklusive dem neuen Wert hinzufügen', () => {
|
|
58
58
|
const filePath = testOptions.path + '/updateJsonArray/updateJsonArrNoArray.json';
|
|
59
59
|
appTree.create(filePath, updateJsonArrNoArray);
|
|
60
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
60
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'assets'], 'aaa'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
61
61
|
var _a;
|
|
62
|
-
const content = (_a =
|
|
62
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
63
63
|
expect(content).toContain('"assets": [\n "aaa"\n ]\n');
|
|
64
64
|
}, (reason) => expect(reason).toBeUndefined());
|
|
65
65
|
});
|
|
66
66
|
it('Sollte den neuen Wert im vorhandenen leeren Array hinzufügen', () => {
|
|
67
67
|
const filePath = testOptions.path + '/updateJsonArray/updateJsonArrEmptyArray.json';
|
|
68
68
|
appTree.create(filePath, updateJsonArrEmptyArray);
|
|
69
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
69
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'assets'], 'aaa'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
70
70
|
var _a;
|
|
71
|
-
const content = (_a =
|
|
71
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
72
72
|
expect(content).toContain('"assets": [\n "aaa"\n ],\n');
|
|
73
73
|
}, (reason) => expect(reason).toBeUndefined());
|
|
74
74
|
});
|
|
75
75
|
it('Sollte den Wert im vorhandenen leeren Array nicht doppelt hinzufügen', () => {
|
|
76
76
|
const filePath = testOptions.path + '/updateJsonArray/updateJsonArrDoubleEntry.json';
|
|
77
77
|
appTree.create(filePath, updateJsonArrDoubleEntry);
|
|
78
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
78
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'assets'], 'aaa'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
79
79
|
var _a;
|
|
80
|
-
const content = (_a =
|
|
80
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
81
81
|
expect(content).toContain('"assets": [\n' +
|
|
82
82
|
' "aaa",\n' +
|
|
83
83
|
' "bbb",\n' +
|
|
@@ -88,9 +88,9 @@ describe('json', () => {
|
|
|
88
88
|
it('Sollte den neuen Wert am Ende des vorhanden Arrays hinzufügen', () => {
|
|
89
89
|
const filePath = testOptions.path + '/updateJsonArray/updateJsonArrAppendArray.json';
|
|
90
90
|
appTree.create(filePath, updateJsonArrAppendArray);
|
|
91
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
91
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'assets'], 'bbb'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
92
92
|
var _a;
|
|
93
|
-
const content = (_a =
|
|
93
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
94
94
|
expect(content).toContain('"assets": [\n' +
|
|
95
95
|
' "aaa",\n' +
|
|
96
96
|
' "bbb",\n' +
|
|
@@ -101,9 +101,9 @@ describe('json', () => {
|
|
|
101
101
|
it('Sollte den Wert im Array ersetzen', () => {
|
|
102
102
|
const filePath = testOptions.path + '/updateJsonArray/updateJsonArrReplaceValue.json';
|
|
103
103
|
appTree.create(filePath, updateJsonArrReplaceValue);
|
|
104
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
104
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'assets'], 'new', true, (node) => node.value === 'bbb'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
105
105
|
var _a;
|
|
106
|
-
const content = (_a =
|
|
106
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
107
107
|
expect(content).toContain('"assets": [\n' +
|
|
108
108
|
' "aaa",\n' +
|
|
109
109
|
' "new",\n' +
|
|
@@ -119,9 +119,9 @@ describe('json', () => {
|
|
|
119
119
|
"maximumWarning": "1mb",
|
|
120
120
|
"maximumError": "2mb"
|
|
121
121
|
};
|
|
122
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
122
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'budgets'], newValue, true, (node) => (0, json_1.findObjectPropertyInArray)(node, 'type', 'initial')), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
123
123
|
var _a;
|
|
124
|
-
const content = (_a =
|
|
124
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
125
125
|
expect(content).toContain('"maximumWarning": "1mb"');
|
|
126
126
|
expect(content).toContain('"maximumError": "2mb"');
|
|
127
127
|
}, (reason) => expect(reason).toBeUndefined());
|
|
@@ -129,9 +129,9 @@ describe('json', () => {
|
|
|
129
129
|
it('Sollte den neuen Wert im Array nur ersetzen, wenn der alte Wert vorhanden war', () => {
|
|
130
130
|
const filePath = testOptions.path + '/updateJsonArray/updateJsonArrReplaceValue.json';
|
|
131
131
|
appTree.create(filePath, updateJsonArrReplaceValue);
|
|
132
|
-
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(
|
|
132
|
+
(0, schematics_1.callRule)((0, json_1.updateJsonArray)(filePath, ['projects', 'lux-components', 'architect', 'build', 'options', 'assets'], 'new', true, (node) => node.value === 'notThere'), (0, rxjs_1.of)(appTree), context).subscribe((success) => {
|
|
133
133
|
var _a;
|
|
134
|
-
const content = (_a =
|
|
134
|
+
const content = (_a = success.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
135
135
|
expect(content).toContain('"assets": [\n' +
|
|
136
136
|
' "aaa",\n' +
|
|
137
137
|
' "bbb",\n' +
|