@angular-devkit/core 14.0.0-next.1 → 14.0.0-next.12
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/node/BUILD.bazel +0 -1
- package/node/experimental/index.js +5 -1
- package/node/experimental/jobs/index.js +5 -1
- package/node/host.js +10 -42
- package/node/index.js +5 -1
- package/node/testing/index.js +5 -1
- package/package.json +4 -5
- package/src/analytics/index.d.ts +1 -1
- package/src/analytics/index.js +7 -3
- package/src/{exception/exception.d.ts → exception.d.ts} +15 -0
- package/src/{exception/exception.js → exception.js} +15 -0
- package/src/experimental/jobs/create-job-handler.d.ts +1 -1
- package/src/experimental/jobs/create-job-handler.js +4 -4
- package/src/experimental/jobs/exception.d.ts +1 -1
- package/src/experimental/jobs/exception.js +3 -3
- package/src/experimental/jobs/index.js +5 -1
- package/src/experimental/jobs/strategy.d.ts +2 -2
- package/src/experimental/jobs/strategy.js +11 -4
- package/src/experimental.js +5 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +6 -2
- package/src/json/index.js +5 -1
- package/src/json/schema/index.js +5 -1
- package/src/json/schema/registry.d.ts +1 -1
- package/src/json/schema/registry.js +6 -2
- package/src/logger/index.js +5 -1
- package/src/utils/index.js +5 -1
- package/src/utils/strings.d.ts +1 -1
- package/src/utils/strings.js +2 -2
- package/src/virtual-fs/host/index.js +5 -1
- package/src/virtual-fs/index.js +5 -1
- package/src/virtual-fs/path.js +4 -4
- package/src/workspace/definitions.d.ts +1 -1
- package/src/workspace/definitions.js +8 -7
- package/src/workspace/index.js +5 -1
- package/src/workspace/json/metadata.d.ts +12 -13
- package/src/workspace/json/metadata.js +28 -19
- package/src/workspace/json/reader.js +71 -86
- package/src/workspace/json/utilities.d.ts +3 -7
- package/src/workspace/json/utilities.js +62 -180
- package/src/workspace/json/writer.js +26 -192
- package/src/exception/index.d.ts +0 -8
- package/src/exception/index.js +0 -20
- package/src/json/parser.d.ts +0 -104
- package/src/json/parser.js +0 -788
- package/src/json/parser_ast.d.ts +0 -67
- package/src/json/parser_ast.js +0 -9
|
@@ -7,201 +7,89 @@
|
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createVirtualAstObject =
|
|
11
|
-
const
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
10
|
+
exports.createVirtualAstObject = void 0;
|
|
11
|
+
const json_1 = require("../../json");
|
|
12
|
+
function createVirtualAstObject(root, options = {}) {
|
|
13
|
+
var _a;
|
|
14
|
+
const reporter = (path, target, oldValue, newValue) => {
|
|
15
|
+
if (!options.listener) {
|
|
16
|
+
return;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!isNaN(index)) {
|
|
22
|
-
return { node: parent.elements[index], parent };
|
|
18
|
+
if (oldValue === newValue || JSON.stringify(oldValue) === JSON.stringify(newValue)) {
|
|
19
|
+
// same value
|
|
20
|
+
return;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
writable: true,
|
|
32
|
-
value,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function escapeKey(key) {
|
|
36
|
-
if (typeof key === 'number') {
|
|
37
|
-
return key;
|
|
38
|
-
}
|
|
39
|
-
return key.replace('~', '~0').replace('/', '~1');
|
|
40
|
-
}
|
|
41
|
-
exports.escapeKey = escapeKey;
|
|
42
|
-
function unescapeKey(key) {
|
|
43
|
-
if (typeof key === 'number') {
|
|
44
|
-
return key;
|
|
45
|
-
}
|
|
46
|
-
return key.replace('~1', '/').replace('~0', '~');
|
|
47
|
-
}
|
|
48
|
-
exports.unescapeKey = unescapeKey;
|
|
49
|
-
function createVirtualAstObject(root, options = {}) {
|
|
50
|
-
const reporter = (path, parent, node, old, current) => {
|
|
51
|
-
if (options.listener) {
|
|
52
|
-
if (old === current || stableStringify(old) === stableStringify(current)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const op = old === undefined ? 'add' : current === undefined ? 'remove' : 'replace';
|
|
56
|
-
options.listener(op, path, parent, current);
|
|
22
|
+
if (Array.isArray(target)) {
|
|
23
|
+
// For arrays we remove the index and update the entire value as keeping
|
|
24
|
+
// track of changes by indices can be rather complex.
|
|
25
|
+
options.listener(path.slice(0, -1), target);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
options.listener(path, newValue);
|
|
57
29
|
}
|
|
58
30
|
};
|
|
59
|
-
return create(root,
|
|
31
|
+
return create(Array.isArray(root) ? [...root] : { ...root }, [], reporter, new Set(options.exclude), ((_a = options.include) === null || _a === void 0 ? void 0 : _a.length) ? new Set(options.include) : undefined);
|
|
60
32
|
}
|
|
61
33
|
exports.createVirtualAstObject = createVirtualAstObject;
|
|
62
|
-
function create(
|
|
63
|
-
|
|
64
|
-
const alteredNodes = new Set();
|
|
65
|
-
if (!base) {
|
|
66
|
-
if (ast.kind === 'object') {
|
|
67
|
-
base = Object.create(null);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
base = [];
|
|
71
|
-
base.length = ast.elements.length;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return new Proxy(base, {
|
|
34
|
+
function create(obj, path, reporter, excluded = new Set(), included) {
|
|
35
|
+
return new Proxy(obj, {
|
|
75
36
|
getOwnPropertyDescriptor(target, p) {
|
|
76
|
-
|
|
77
|
-
if (descriptor || typeof p === 'symbol') {
|
|
78
|
-
return descriptor;
|
|
79
|
-
}
|
|
80
|
-
else if (excluded.has(p) || (included && !included.has(p))) {
|
|
37
|
+
if (excluded.has(p) || (included && !included.has(p))) {
|
|
81
38
|
return undefined;
|
|
82
39
|
}
|
|
83
|
-
|
|
84
|
-
const cacheEntry = cache.get(propertyPath);
|
|
85
|
-
if (cacheEntry) {
|
|
86
|
-
if (cacheEntry.value !== undefined) {
|
|
87
|
-
return createPropertyDescriptor(cacheEntry.value);
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
const { node } = findNode(ast, p);
|
|
92
|
-
if (node) {
|
|
93
|
-
return createPropertyDescriptor(node.value);
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
40
|
+
return Reflect.getOwnPropertyDescriptor(target, p);
|
|
96
41
|
},
|
|
97
42
|
has(target, p) {
|
|
98
|
-
if (
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
else if (typeof p === 'symbol' || excluded.has(p)) {
|
|
43
|
+
if (typeof p === 'symbol' || excluded.has(p)) {
|
|
102
44
|
return false;
|
|
103
45
|
}
|
|
104
|
-
return
|
|
46
|
+
return Reflect.has(target, p);
|
|
105
47
|
},
|
|
106
48
|
get(target, p) {
|
|
107
|
-
if (
|
|
108
|
-
return Reflect.get(target, p);
|
|
109
|
-
}
|
|
110
|
-
else if (excluded.has(p) || (included && !included.has(p))) {
|
|
49
|
+
if (excluded.has(p) || (included && !included.has(p))) {
|
|
111
50
|
return undefined;
|
|
112
51
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return cacheEntry.value;
|
|
52
|
+
const value = Reflect.get(target, p);
|
|
53
|
+
if (typeof p === 'symbol') {
|
|
54
|
+
return value;
|
|
117
55
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!alteredNodes.has(node)) {
|
|
124
|
-
reporter(path, parent, vnode, old, current);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
value = node.value;
|
|
130
|
-
}
|
|
131
|
-
cache.set(propertyPath, { node, parent, value });
|
|
56
|
+
if (((0, json_1.isJsonObject)(value) && !(value instanceof Map)) || Array.isArray(value)) {
|
|
57
|
+
return create(value, [...path, p], reporter);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return value;
|
|
132
61
|
}
|
|
133
|
-
return value;
|
|
134
62
|
},
|
|
135
63
|
set(target, p, value) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
if (excluded.has(p) || (included && !included.has(p))) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
136
68
|
if (value === undefined) {
|
|
137
|
-
// setting to undefined is equivalent to a delete
|
|
138
|
-
|
|
139
|
-
return this.deleteProperty(target, p);
|
|
69
|
+
// setting to undefined is equivalent to a delete.
|
|
70
|
+
return (_b = (_a = this.deleteProperty) === null || _a === void 0 ? void 0 : _a.call(this, target, p)) !== null && _b !== void 0 ? _b : false;
|
|
140
71
|
}
|
|
141
|
-
if (typeof p === 'symbol'
|
|
72
|
+
if (typeof p === 'symbol') {
|
|
142
73
|
return Reflect.set(target, p, value);
|
|
143
74
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const jsonValue = value;
|
|
149
|
-
const propertyPath = path + '/' + escapeKey(p);
|
|
150
|
-
const cacheEntry = cache.get(propertyPath);
|
|
151
|
-
if (cacheEntry) {
|
|
152
|
-
const oldValue = cacheEntry.value;
|
|
153
|
-
cacheEntry.value = value;
|
|
154
|
-
if (cacheEntry.node && oldValue !== value) {
|
|
155
|
-
alteredNodes.add(cacheEntry.node);
|
|
156
|
-
}
|
|
157
|
-
reporter(propertyPath, cacheEntry.parent, cacheEntry.node, oldValue, jsonValue);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
const { node, parent } = findNode(ast, p);
|
|
161
|
-
cache.set(propertyPath, { node, parent, value: value });
|
|
162
|
-
if (node && node.value !== value) {
|
|
163
|
-
alteredNodes.add(node);
|
|
164
|
-
}
|
|
165
|
-
reporter(propertyPath, parent, node, node && node.value, value);
|
|
75
|
+
const existingValue = getCurrentValue(target, p);
|
|
76
|
+
if (Reflect.set(target, p, value)) {
|
|
77
|
+
reporter([...path, p], target, existingValue, value);
|
|
78
|
+
return true;
|
|
166
79
|
}
|
|
167
|
-
return
|
|
80
|
+
return false;
|
|
168
81
|
},
|
|
169
82
|
deleteProperty(target, p) {
|
|
170
|
-
if (
|
|
171
|
-
return Reflect.deleteProperty(target, p);
|
|
172
|
-
}
|
|
173
|
-
else if (excluded.has(p) || (included && !included.has(p))) {
|
|
83
|
+
if (excluded.has(p)) {
|
|
174
84
|
return false;
|
|
175
85
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (cacheEntry) {
|
|
179
|
-
const oldValue = cacheEntry.value;
|
|
180
|
-
cacheEntry.value = undefined;
|
|
181
|
-
if (cacheEntry.node) {
|
|
182
|
-
alteredNodes.add(cacheEntry.node);
|
|
183
|
-
}
|
|
184
|
-
if (cacheEntry.parent.kind === 'keyvalue') {
|
|
185
|
-
// Remove the entire key/value pair from this JSON object
|
|
186
|
-
reporter(propertyPath, ast, cacheEntry.node, oldValue, undefined);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
reporter(propertyPath, cacheEntry.parent, cacheEntry.node, oldValue, undefined);
|
|
190
|
-
}
|
|
86
|
+
if (typeof p === 'symbol') {
|
|
87
|
+
return Reflect.deleteProperty(target, p);
|
|
191
88
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
alteredNodes.add(node);
|
|
197
|
-
if (parent.kind === 'keyvalue') {
|
|
198
|
-
// Remove the entire key/value pair from this JSON object
|
|
199
|
-
reporter(propertyPath, ast, node, node && node.value, undefined);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
reporter(propertyPath, parent, node, node && node.value, undefined);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
89
|
+
const existingValue = getCurrentValue(target, p);
|
|
90
|
+
if (Reflect.deleteProperty(target, p)) {
|
|
91
|
+
reporter([...path, p], target, existingValue, undefined);
|
|
92
|
+
return true;
|
|
205
93
|
}
|
|
206
94
|
return true;
|
|
207
95
|
},
|
|
@@ -212,22 +100,16 @@ function create(ast, path, reporter, excluded = new Set(), included, base) {
|
|
|
212
100
|
return false;
|
|
213
101
|
},
|
|
214
102
|
ownKeys(target) {
|
|
215
|
-
|
|
216
|
-
if (ast.kind === 'object') {
|
|
217
|
-
keys = ast.properties
|
|
218
|
-
.map((entry) => entry.key.value)
|
|
219
|
-
.filter((p) => !excluded.has(p) && (!included || included.has(p)));
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
keys = [];
|
|
223
|
-
}
|
|
224
|
-
for (const key of cache.keys()) {
|
|
225
|
-
const relativeKey = key.substr(path.length + 1);
|
|
226
|
-
if (relativeKey.length > 0 && !relativeKey.includes('/')) {
|
|
227
|
-
keys.push(`${unescapeKey(relativeKey)}`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return [...new Set([...keys, ...Reflect.ownKeys(target)])];
|
|
103
|
+
return Reflect.ownKeys(target).filter((p) => !excluded.has(p) && (!included || included.has(p)));
|
|
231
104
|
},
|
|
232
105
|
});
|
|
233
106
|
}
|
|
107
|
+
function getCurrentValue(target, property) {
|
|
108
|
+
if (Array.isArray(target) && isFinite(+property)) {
|
|
109
|
+
return target[+property];
|
|
110
|
+
}
|
|
111
|
+
if (target && property in target) {
|
|
112
|
+
return target[property];
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
@@ -6,24 +6,19 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
8
8
|
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
10
|
exports.writeJsonWorkspace = void 0;
|
|
14
|
-
const
|
|
11
|
+
const jsonc_parser_1 = require("jsonc-parser");
|
|
15
12
|
const metadata_1 = require("./metadata");
|
|
16
|
-
const utilities_1 = require("./utilities");
|
|
17
13
|
async function writeJsonWorkspace(workspace, host, path, options = {}) {
|
|
18
14
|
const metadata = workspace[metadata_1.JsonWorkspaceSymbol];
|
|
19
15
|
if (metadata) {
|
|
20
16
|
if (!metadata.hasChanges) {
|
|
21
|
-
// nothing to do
|
|
22
17
|
return;
|
|
23
18
|
}
|
|
24
19
|
// update existing JSON workspace
|
|
25
20
|
const data = updateJsonWorkspace(metadata);
|
|
26
|
-
return host.writeFile(path
|
|
21
|
+
return host.writeFile(path !== null && path !== void 0 ? path : metadata.filePath, data);
|
|
27
22
|
}
|
|
28
23
|
else {
|
|
29
24
|
// serialize directly
|
|
@@ -91,206 +86,45 @@ function convertJsonTargetCollection(collection) {
|
|
|
91
86
|
}
|
|
92
87
|
return targets;
|
|
93
88
|
}
|
|
94
|
-
function
|
|
95
|
-
let i = node.start.offset;
|
|
96
|
-
while (i > 0 && /\s/.test(raw[i - 1])) {
|
|
97
|
-
--i;
|
|
98
|
-
}
|
|
99
|
-
return i;
|
|
100
|
-
}
|
|
101
|
-
function findFullEnd(node, raw) {
|
|
102
|
-
let i = node.end.offset;
|
|
103
|
-
if (i >= raw.length) {
|
|
104
|
-
return raw.length;
|
|
105
|
-
}
|
|
106
|
-
else if (raw[i] === ',') {
|
|
107
|
-
return i + 1;
|
|
108
|
-
}
|
|
109
|
-
while (i > node.start.offset && /\s/.test(raw[i - 1])) {
|
|
110
|
-
--i;
|
|
111
|
-
}
|
|
112
|
-
return i;
|
|
113
|
-
}
|
|
114
|
-
function findPrecedingComma(node, raw) {
|
|
115
|
-
let i = node.start.offset;
|
|
116
|
-
if (node.comments && node.comments.length > 0) {
|
|
117
|
-
i = node.comments[0].start.offset;
|
|
118
|
-
}
|
|
119
|
-
while (i > 0 && /\s/.test(raw[i - 1])) {
|
|
120
|
-
--i;
|
|
121
|
-
}
|
|
122
|
-
if (raw[i - 1] === ',') {
|
|
123
|
-
return i - 1;
|
|
124
|
-
}
|
|
125
|
-
return -1;
|
|
126
|
-
}
|
|
127
|
-
function stringify(value, multiline, depth, indent) {
|
|
89
|
+
function normalizeValue(value, type) {
|
|
128
90
|
if (value === undefined) {
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
if (multiline) {
|
|
132
|
-
const content = JSON.stringify(value, null, indent);
|
|
133
|
-
const spacing = '\n' + indent.repeat(depth);
|
|
134
|
-
return content.replace(/\n/g, spacing);
|
|
91
|
+
return undefined;
|
|
135
92
|
}
|
|
136
|
-
else {
|
|
137
|
-
return JSON.stringify(value);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function normalizeValue(value, type) {
|
|
141
93
|
switch (type) {
|
|
142
94
|
case 'project':
|
|
143
95
|
return convertJsonProject(value);
|
|
144
96
|
case 'projectcollection':
|
|
145
97
|
const projects = convertJsonProjectCollection(value);
|
|
146
|
-
return
|
|
98
|
+
return isEmpty(projects) ? undefined : projects;
|
|
147
99
|
case 'target':
|
|
148
100
|
return convertJsonTarget(value);
|
|
149
101
|
case 'targetcollection':
|
|
150
102
|
const targets = convertJsonTargetCollection(value);
|
|
151
|
-
return
|
|
103
|
+
return isEmpty(targets) ? undefined : targets;
|
|
152
104
|
default:
|
|
153
105
|
return value;
|
|
154
106
|
}
|
|
155
107
|
}
|
|
156
108
|
function updateJsonWorkspace(metadata) {
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const multiline = node.start.line !== node.end.line || type !== 'json';
|
|
164
|
-
const pathSegments = path.split('/');
|
|
165
|
-
const depth = pathSegments.length - 1; // TODO: more complete analysis
|
|
166
|
-
const propertyOrIndex = (0, utilities_1.unescapeKey)(pathSegments[depth]);
|
|
167
|
-
const jsonValue = normalizeValue(value, type);
|
|
168
|
-
if (op === 'add' && jsonValue === undefined) {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
// Track changes to the order/size of any modified objects/arrays
|
|
172
|
-
let elements = nodeChanges.get(node);
|
|
173
|
-
if (!elements) {
|
|
174
|
-
if (node.kind === 'array') {
|
|
175
|
-
elements = node.elements.slice();
|
|
176
|
-
nodeChanges.set(node, elements);
|
|
177
|
-
}
|
|
178
|
-
else if (node.kind === 'object') {
|
|
179
|
-
elements = node.properties.slice();
|
|
180
|
-
nodeChanges.set(node, elements);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
// keyvalue
|
|
184
|
-
elements = [];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
switch (op) {
|
|
188
|
-
case 'add':
|
|
189
|
-
let contentPrefix = '';
|
|
190
|
-
if (node.kind === 'object') {
|
|
191
|
-
contentPrefix = `"${propertyOrIndex}": `;
|
|
192
|
-
}
|
|
193
|
-
const spacing = multiline ? '\n' + indent.repeat(depth) : ' ';
|
|
194
|
-
const content = spacing + contentPrefix + stringify(jsonValue, multiline, depth, indent);
|
|
195
|
-
// Additions are handled after analyzing all operations
|
|
196
|
-
// This is mainly to support array operations which can occur at arbitrary indices
|
|
197
|
-
if (node.kind === 'object') {
|
|
198
|
-
// Object property additions are always added at the end for simplicity
|
|
199
|
-
elements.push(content);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
// Add place holders if adding an index past the length
|
|
203
|
-
// An empty string is an impossible real value
|
|
204
|
-
for (let i = elements.length; i < +propertyOrIndex; ++i) {
|
|
205
|
-
elements[i] = '';
|
|
206
|
-
}
|
|
207
|
-
if (elements[+propertyOrIndex] === '') {
|
|
208
|
-
elements[+propertyOrIndex] = content;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
elements.splice(+propertyOrIndex, 0, content);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
break;
|
|
215
|
-
case 'remove':
|
|
216
|
-
let removalIndex = -1;
|
|
217
|
-
if (node.kind === 'object') {
|
|
218
|
-
removalIndex = elements.findIndex((e) => {
|
|
219
|
-
return typeof e != 'string' && e.kind === 'keyvalue' && e.key.value === propertyOrIndex;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
else if (node.kind === 'array') {
|
|
223
|
-
removalIndex = +propertyOrIndex;
|
|
224
|
-
}
|
|
225
|
-
if (removalIndex === -1) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
const nodeToRemove = elements[removalIndex];
|
|
229
|
-
if (typeof nodeToRemove === 'string') {
|
|
230
|
-
// synthetic
|
|
231
|
-
elements.splice(removalIndex, 1);
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
if (elements.length - 1 === removalIndex) {
|
|
235
|
-
// If the element is a terminal element remove the otherwise trailing comma
|
|
236
|
-
const commaIndex = findPrecedingComma(nodeToRemove, data.original);
|
|
237
|
-
if (commaIndex !== -1) {
|
|
238
|
-
data.remove(commaIndex, commaIndex + 1);
|
|
239
|
-
removedCommas.add(commaIndex);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
data.remove(findFullStart(nodeToRemove, data.original), findFullEnd(nodeToRemove, data.original));
|
|
243
|
-
elements.splice(removalIndex, 1);
|
|
244
|
-
break;
|
|
245
|
-
case 'replace':
|
|
246
|
-
let nodeToReplace;
|
|
247
|
-
if (node.kind === 'keyvalue') {
|
|
248
|
-
nodeToReplace = node.value;
|
|
249
|
-
}
|
|
250
|
-
else if (node.kind === 'array') {
|
|
251
|
-
nodeToReplace = elements[+propertyOrIndex];
|
|
252
|
-
if (typeof nodeToReplace === 'string') {
|
|
253
|
-
// Was already modified. This is already handled.
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
nodeChanges.delete(nodeToReplace);
|
|
261
|
-
data.overwrite(nodeToReplace.start.offset, nodeToReplace.end.offset, stringify(jsonValue, multiline, depth, indent));
|
|
262
|
-
break;
|
|
109
|
+
let { raw: content } = metadata;
|
|
110
|
+
const { changes, hasLegacyTargetsName } = metadata;
|
|
111
|
+
for (const { jsonPath, value, type } of changes.values()) {
|
|
112
|
+
// Determine which key to use if (architect or targets)
|
|
113
|
+
if (hasLegacyTargetsName && jsonPath[2] === 'targets') {
|
|
114
|
+
jsonPath[2] = 'architect';
|
|
263
115
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
optimizedElements.push(element);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
let prefixComma = false;
|
|
284
|
-
for (const element of optimizedElements) {
|
|
285
|
-
if (typeof element === 'string') {
|
|
286
|
-
data.appendRight(parentPoint, (prefixComma ? ',' : '') + element);
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
parentPoint = findFullEnd(element, data.original);
|
|
290
|
-
prefixComma = data.original[parentPoint - 1] !== ',' || removedCommas.has(parentPoint - 1);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
const result = data.toString();
|
|
295
|
-
return result;
|
|
116
|
+
// modify
|
|
117
|
+
const newJsonPath = jsonPath.map((v) => (isFinite(+v) ? +v : v));
|
|
118
|
+
// TODO: `modify` re-parses the content every time.
|
|
119
|
+
// See: https://github.com/microsoft/node-jsonc-parser/blob/35d94cd71bd48f9784453b2439262c938e21d49b/src/impl/edit.ts#L18
|
|
120
|
+
// Ideally this should accept a string or an AST to avoid the potentially expensive repeat parsing operation.
|
|
121
|
+
const edits = (0, jsonc_parser_1.modify)(content, newJsonPath, normalizeValue(value, type), {
|
|
122
|
+
formattingOptions: {
|
|
123
|
+
insertSpaces: true,
|
|
124
|
+
tabSize: 2,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
content = (0, jsonc_parser_1.applyEdits)(content, edits);
|
|
128
|
+
}
|
|
129
|
+
return content;
|
|
296
130
|
}
|
package/src/exception/index.d.ts
DELETED
package/src/exception/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
__exportStar(require("./exception"), exports);
|