1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.updatePackage = void 0;
|
4 | var schematics_1 = require("@angular-devkit/schematics");
|
5 | function updatePackage(name) {
|
6 | return function (tree, context) {
|
7 | var pkgPath = '/package.json';
|
8 | var buffer = tree.read(pkgPath);
|
9 | if (buffer === null) {
|
10 | throw new schematics_1.SchematicsException('Could not read package.json');
|
11 | }
|
12 | var content = buffer.toString();
|
13 | var pkg = JSON.parse(content);
|
14 | if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
|
15 | throw new schematics_1.SchematicsException('Error reading package.json');
|
16 | }
|
17 | var dependencyCategories = ['dependencies', 'devDependencies'];
|
18 | dependencyCategories.forEach(function (category) {
|
19 | var packageName = "@ngrx/".concat(name);
|
20 | if (pkg[category] && pkg[category][packageName]) {
|
21 | var firstChar = pkg[category][packageName][0];
|
22 | var suffix = match(firstChar, '^') || match(firstChar, '~');
|
23 | pkg[category][packageName] = "".concat(suffix, "6.0.0");
|
24 | }
|
25 | });
|
26 | tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
|
27 | return tree;
|
28 | };
|
29 | }
|
30 | exports.updatePackage = updatePackage;
|
31 | function match(value, test) {
|
32 | return value === test ? test : '';
|
33 | }
|
34 |
|
\ | No newline at end of file |