1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler-cli/ngcc/src/writing/package_json_updater", ["require", "exports", "tslib", "@angular/compiler-cli/src/ngtsc/file_system"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.applyChange = exports.DirectPackageJsonUpdater = exports.PackageJsonUpdate = void 0;
|
---|
20 | var tslib_1 = require("tslib");
|
---|
21 | var file_system_1 = require("@angular/compiler-cli/src/ngtsc/file_system");
|
---|
22 | /**
|
---|
23 | * A utility class providing a fluent API for recording multiple changes to a `package.json` file
|
---|
24 | * (and optionally its in-memory parsed representation).
|
---|
25 | *
|
---|
26 | * NOTE: This class should generally not be instantiated directly; instances are implicitly created
|
---|
27 | * via `PackageJsonUpdater#createUpdate()`.
|
---|
28 | */
|
---|
29 | var PackageJsonUpdate = /** @class */ (function () {
|
---|
30 | function PackageJsonUpdate(writeChangesImpl) {
|
---|
31 | this.writeChangesImpl = writeChangesImpl;
|
---|
32 | this.changes = [];
|
---|
33 | this.applied = false;
|
---|
34 | }
|
---|
35 | /**
|
---|
36 | * Record a change to a `package.json` property.
|
---|
37 | *
|
---|
38 | * If the ancestor objects do not yet exist in the `package.json` file, they will be created. The
|
---|
39 | * positioning of the property can also be specified. (If the property already exists, it will be
|
---|
40 | * moved accordingly.)
|
---|
41 | *
|
---|
42 | * NOTE: Property positioning is only guaranteed to be respected in the serialized `package.json`
|
---|
43 | * file. Positioning will not be taken into account when updating in-memory representations.
|
---|
44 | *
|
---|
45 | * NOTE 2: Property positioning only affects the last property in `propertyPath`. Ancestor
|
---|
46 | * objects' positioning will not be affected.
|
---|
47 | *
|
---|
48 | * @param propertyPath The path of a (possibly nested) property to add/update.
|
---|
49 | * @param value The new value to set the property to.
|
---|
50 | * @param position The desired position for the added/updated property.
|
---|
51 | */
|
---|
52 | PackageJsonUpdate.prototype.addChange = function (propertyPath, value, positioning) {
|
---|
53 | if (positioning === void 0) { positioning = 'unimportant'; }
|
---|
54 | this.ensureNotApplied();
|
---|
55 | this.changes.push([propertyPath, value, positioning]);
|
---|
56 | return this;
|
---|
57 | };
|
---|
58 | /**
|
---|
59 | * Write the recorded changes to the associated `package.json` file (and optionally a
|
---|
60 | * pre-existing, in-memory representation of it).
|
---|
61 | *
|
---|
62 | * @param packageJsonPath The path to the `package.json` file that needs to be updated.
|
---|
63 | * @param parsedJson A pre-existing, in-memory representation of the `package.json` file that
|
---|
64 | * needs to be updated as well.
|
---|
65 | */
|
---|
66 | PackageJsonUpdate.prototype.writeChanges = function (packageJsonPath, parsedJson) {
|
---|
67 | this.ensureNotApplied();
|
---|
68 | this.writeChangesImpl(this.changes, packageJsonPath, parsedJson);
|
---|
69 | this.applied = true;
|
---|
70 | };
|
---|
71 | PackageJsonUpdate.prototype.ensureNotApplied = function () {
|
---|
72 | if (this.applied) {
|
---|
73 | throw new Error('Trying to apply a `PackageJsonUpdate` that has already been applied.');
|
---|
74 | }
|
---|
75 | };
|
---|
76 | return PackageJsonUpdate;
|
---|
77 | }());
|
---|
78 | exports.PackageJsonUpdate = PackageJsonUpdate;
|
---|
79 | /** A `PackageJsonUpdater` that writes directly to the file-system. */
|
---|
80 | var DirectPackageJsonUpdater = /** @class */ (function () {
|
---|
81 | function DirectPackageJsonUpdater(fs) {
|
---|
82 | this.fs = fs;
|
---|
83 | }
|
---|
84 | DirectPackageJsonUpdater.prototype.createUpdate = function () {
|
---|
85 | var _this = this;
|
---|
86 | return new PackageJsonUpdate(function () {
|
---|
87 | var args = [];
|
---|
88 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
89 | args[_i] = arguments[_i];
|
---|
90 | }
|
---|
91 | return _this.writeChanges.apply(_this, tslib_1.__spreadArray([], tslib_1.__read(args)));
|
---|
92 | });
|
---|
93 | };
|
---|
94 | DirectPackageJsonUpdater.prototype.writeChanges = function (changes, packageJsonPath, preExistingParsedJson) {
|
---|
95 | var e_1, _a;
|
---|
96 | if (changes.length === 0) {
|
---|
97 | throw new Error("No changes to write to '" + packageJsonPath + "'.");
|
---|
98 | }
|
---|
99 | // Read and parse the `package.json` content.
|
---|
100 | // NOTE: We are not using `preExistingParsedJson` (even if specified) to avoid corrupting the
|
---|
101 | // content on disk in case `preExistingParsedJson` is outdated.
|
---|
102 | var parsedJson = this.fs.exists(packageJsonPath) ?
|
---|
103 | JSON.parse(this.fs.readFile(packageJsonPath)) :
|
---|
104 | {};
|
---|
105 | try {
|
---|
106 | // Apply all changes to both the canonical representation (read from disk) and any pre-existing,
|
---|
107 | // in-memory representation.
|
---|
108 | for (var changes_1 = tslib_1.__values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
---|
109 | var _b = tslib_1.__read(changes_1_1.value, 3), propPath = _b[0], value = _b[1], positioning = _b[2];
|
---|
110 | if (propPath.length === 0) {
|
---|
111 | throw new Error("Missing property path for writing value to '" + packageJsonPath + "'.");
|
---|
112 | }
|
---|
113 | applyChange(parsedJson, propPath, value, positioning);
|
---|
114 | if (preExistingParsedJson) {
|
---|
115 | // No need to take property positioning into account for in-memory representations.
|
---|
116 | applyChange(preExistingParsedJson, propPath, value, 'unimportant');
|
---|
117 | }
|
---|
118 | }
|
---|
119 | }
|
---|
120 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
121 | finally {
|
---|
122 | try {
|
---|
123 | if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
|
---|
124 | }
|
---|
125 | finally { if (e_1) throw e_1.error; }
|
---|
126 | }
|
---|
127 | // Ensure the containing directory exists (in case this is a synthesized `package.json` due to a
|
---|
128 | // custom configuration) and write the updated content to disk.
|
---|
129 | this.fs.ensureDir(file_system_1.dirname(packageJsonPath));
|
---|
130 | this.fs.writeFile(packageJsonPath, JSON.stringify(parsedJson, null, 2) + "\n");
|
---|
131 | };
|
---|
132 | return DirectPackageJsonUpdater;
|
---|
133 | }());
|
---|
134 | exports.DirectPackageJsonUpdater = DirectPackageJsonUpdater;
|
---|
135 | // Helpers
|
---|
136 | function applyChange(ctx, propPath, value, positioning) {
|
---|
137 | var lastPropIdx = propPath.length - 1;
|
---|
138 | var lastProp = propPath[lastPropIdx];
|
---|
139 | for (var i = 0; i < lastPropIdx; i++) {
|
---|
140 | var key = propPath[i];
|
---|
141 | var newCtx = ctx.hasOwnProperty(key) ? ctx[key] : (ctx[key] = {});
|
---|
142 | if ((typeof newCtx !== 'object') || (newCtx === null) || Array.isArray(newCtx)) {
|
---|
143 | throw new Error("Property path '" + propPath.join('.') + "' does not point to an object.");
|
---|
144 | }
|
---|
145 | ctx = newCtx;
|
---|
146 | }
|
---|
147 | ctx[lastProp] = value;
|
---|
148 | positionProperty(ctx, lastProp, positioning);
|
---|
149 | }
|
---|
150 | exports.applyChange = applyChange;
|
---|
151 | function movePropBefore(ctx, prop, isNextProp) {
|
---|
152 | var allProps = Object.keys(ctx);
|
---|
153 | var otherProps = allProps.filter(function (p) { return p !== prop; });
|
---|
154 | var nextPropIdx = otherProps.findIndex(isNextProp);
|
---|
155 | var propsToShift = (nextPropIdx === -1) ? [] : otherProps.slice(nextPropIdx);
|
---|
156 | movePropToEnd(ctx, prop);
|
---|
157 | propsToShift.forEach(function (p) { return movePropToEnd(ctx, p); });
|
---|
158 | }
|
---|
159 | function movePropToEnd(ctx, prop) {
|
---|
160 | var value = ctx[prop];
|
---|
161 | delete ctx[prop];
|
---|
162 | ctx[prop] = value;
|
---|
163 | }
|
---|
164 | function positionProperty(ctx, prop, positioning) {
|
---|
165 | switch (positioning) {
|
---|
166 | case 'alphabetic':
|
---|
167 | movePropBefore(ctx, prop, function (p) { return p > prop; });
|
---|
168 | break;
|
---|
169 | case 'unimportant':
|
---|
170 | // Leave the property order unchanged; i.e. newly added properties will be last and existing
|
---|
171 | // ones will remain in their old position.
|
---|
172 | break;
|
---|
173 | default:
|
---|
174 | if ((typeof positioning !== 'object') || (positioning.before === undefined)) {
|
---|
175 | throw new Error("Unknown positioning (" + JSON.stringify(positioning) + ") for property '" + prop + "'.");
|
---|
176 | }
|
---|
177 | movePropBefore(ctx, prop, function (p) { return p === positioning.before; });
|
---|
178 | break;
|
---|
179 | }
|
---|
180 | }
|
---|
181 | });
|
---|
182 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFja2FnZV9qc29uX3VwZGF0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci1jbGkvbmdjYy9zcmMvd3JpdGluZy9wYWNrYWdlX2pzb25fdXBkYXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7Ozs7O0lBRUgsMkVBQW1GO0lBK0NuRjs7Ozs7O09BTUc7SUFDSDtRQUlFLDJCQUFvQixnQkFBMkM7WUFBM0MscUJBQWdCLEdBQWhCLGdCQUFnQixDQUEyQjtZQUh2RCxZQUFPLEdBQXdCLEVBQUUsQ0FBQztZQUNsQyxZQUFPLEdBQUcsS0FBSyxDQUFDO1FBRTBDLENBQUM7UUFFbkU7Ozs7Ozs7Ozs7Ozs7Ozs7V0FnQkc7UUFDSCxxQ0FBUyxHQUFULFVBQ0ksWUFBc0IsRUFBRSxLQUFnQixFQUN4QyxXQUEyRDtZQUEzRCw0QkFBQSxFQUFBLDJCQUEyRDtZQUM3RCxJQUFJLEN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