@ngrx/store-devtools 21.0.0-beta.0 → 21.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/migrations/17_0_0-beta/index.js +66 -68
- package/migrations/17_0_0-beta/index.js.map +1 -1
- package/migrations/6_0_0/index.js +6 -3
- package/migrations/6_0_0/index.js.map +1 -1
- package/package.json +2 -2
- package/schematics/ng-add/index.js +86 -99
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +2 -0
- package/schematics-core/index.js +75 -24
- package/schematics-core/index.js.map +1 -1
- package/schematics-core/utility/ast-utils.js +234 -260
- package/schematics-core/utility/ast-utils.js.map +1 -1
- package/schematics-core/utility/change.js +82 -92
- package/schematics-core/utility/change.js.map +1 -1
- package/schematics-core/utility/config.js +13 -9
- package/schematics-core/utility/config.js.map +1 -1
- package/schematics-core/utility/find-component.js +35 -30
- package/schematics-core/utility/find-component.js.map +1 -1
- package/schematics-core/utility/find-module.js +38 -33
- package/schematics-core/utility/find-module.js.map +1 -1
- package/schematics-core/utility/json-utilts.js +8 -27
- package/schematics-core/utility/json-utilts.js.map +1 -1
- package/schematics-core/utility/libs-version.js +4 -1
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js +129 -152
- package/schematics-core/utility/ngrx-utils.js.map +1 -1
- package/schematics-core/utility/package.js +6 -4
- package/schematics-core/utility/package.js.map +1 -1
- package/schematics-core/utility/parse-name.js +8 -5
- package/schematics-core/utility/parse-name.js.map +1 -1
- package/schematics-core/utility/project.js +23 -17
- package/schematics-core/utility/project.js.map +1 -1
- package/schematics-core/utility/standalone.js +141 -214
- package/schematics-core/utility/standalone.js.map +1 -1
- package/schematics-core/utility/strings.js +32 -21
- package/schematics-core/utility/strings.js.map +1 -1
- package/schematics-core/utility/update.js +18 -15
- package/schematics-core/utility/update.js.map +1 -1
- package/schematics-core/utility/visitors.js +104 -192
- package/schematics-core/utility/visitors.js.map +1 -1
|
@@ -1,51 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
ar
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.default = default_1;
|
|
37
|
+
const ts = __importStar(require("typescript"));
|
|
38
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
39
|
+
const schematics_core_1 = require("../..//schematics-core");
|
|
29
40
|
function migrate() {
|
|
30
|
-
return
|
|
31
|
-
visitTSSourceFiles(tree,
|
|
32
|
-
|
|
41
|
+
return (tree) => {
|
|
42
|
+
(0, schematics_core_1.visitTSSourceFiles)(tree, (sourceFile) => {
|
|
43
|
+
const devtoolsImports = sourceFile.statements
|
|
33
44
|
.filter(ts.isImportDeclaration)
|
|
34
|
-
.filter(
|
|
35
|
-
var moduleSpecifier = _a.moduleSpecifier;
|
|
36
|
-
return moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools');
|
|
37
|
-
});
|
|
45
|
+
.filter(({ moduleSpecifier }) => moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools'));
|
|
38
46
|
if (devtoolsImports.length === 0) {
|
|
39
47
|
return;
|
|
40
48
|
}
|
|
41
|
-
|
|
42
|
-
commitChanges(tree, sourceFile.fileName, changes);
|
|
49
|
+
const changes = [...findAndUpdateConfigs(sourceFile)];
|
|
50
|
+
(0, schematics_core_1.commitChanges)(tree, sourceFile.fileName, changes);
|
|
43
51
|
});
|
|
44
52
|
};
|
|
45
53
|
}
|
|
46
54
|
function findAndUpdateConfigs(sourceFile) {
|
|
47
|
-
|
|
48
|
-
ts.forEachChild(sourceFile,
|
|
55
|
+
const changes = [];
|
|
56
|
+
ts.forEachChild(sourceFile, (node) => find(node, changes));
|
|
49
57
|
return changes;
|
|
50
58
|
function find(node, changes) {
|
|
51
59
|
if (ts.isPropertyAccessExpression(node) &&
|
|
@@ -54,45 +62,35 @@ function findAndUpdateConfigs(sourceFile) {
|
|
|
54
62
|
node.expression.text === 'StoreDevtoolsModule' &&
|
|
55
63
|
ts.isCallExpression(node.parent)) {
|
|
56
64
|
if (node.parent.arguments.length) {
|
|
57
|
-
|
|
65
|
+
const [devtoolsConfig] = node.parent.arguments;
|
|
58
66
|
if (ts.isObjectLiteralExpression(devtoolsConfig)) {
|
|
59
|
-
updateConfig(sourceFile, devtoolsConfig,
|
|
60
|
-
return changes.push(change);
|
|
61
|
-
});
|
|
67
|
+
updateConfig(sourceFile, devtoolsConfig, (change) => changes.push(change));
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
else {
|
|
65
|
-
createDevtoolsConfig(sourceFile, node.parent,
|
|
66
|
-
return changes.push(change);
|
|
67
|
-
});
|
|
71
|
+
createDevtoolsConfig(sourceFile, node.parent, (change) => changes.push(change));
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
if (ts.isCallExpression(node) &&
|
|
71
75
|
ts.isIdentifier(node.expression) &&
|
|
72
76
|
node.expression.text === 'provideStoreDevtools') {
|
|
73
77
|
if (node.arguments.length) {
|
|
74
|
-
|
|
78
|
+
const [devtoolsConfig] = node.arguments;
|
|
75
79
|
if (ts.isObjectLiteralExpression(devtoolsConfig)) {
|
|
76
|
-
updateConfig(sourceFile, devtoolsConfig,
|
|
77
|
-
return changes.push(change);
|
|
78
|
-
});
|
|
80
|
+
updateConfig(sourceFile, devtoolsConfig, (change) => changes.push(change));
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
else {
|
|
82
|
-
createDevtoolsConfig(sourceFile, node,
|
|
83
|
-
return changes.push(change);
|
|
84
|
-
});
|
|
84
|
+
createDevtoolsConfig(sourceFile, node, (change) => changes.push(change));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
ts.forEachChild(node,
|
|
87
|
+
ts.forEachChild(node, (childNode) => find(childNode, changes));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
function updateConfig(sourceFile, devtoolsConfig, addChange) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
p.name.text === 'connectOutsideZone';
|
|
95
|
-
});
|
|
91
|
+
const connectOutsideZoneProperty = devtoolsConfig.properties.find((p) => ts.isPropertyAssignment(p) &&
|
|
92
|
+
ts.isIdentifier(p.name) &&
|
|
93
|
+
p.name.text === 'connectOutsideZone');
|
|
96
94
|
if (!connectOutsideZoneProperty) {
|
|
97
95
|
addConnectInZoneProperty();
|
|
98
96
|
}
|
|
@@ -100,32 +98,32 @@ function updateConfig(sourceFile, devtoolsConfig, addChange) {
|
|
|
100
98
|
replaceConnectOutsideZoneConfig(connectOutsideZoneProperty);
|
|
101
99
|
}
|
|
102
100
|
function addConnectInZoneProperty() {
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
const configText = devtoolsConfig.getText(sourceFile);
|
|
102
|
+
const comma = !devtoolsConfig.properties.length ||
|
|
105
103
|
configText
|
|
106
104
|
.substring(0, configText.length - 1)
|
|
107
105
|
.trim()
|
|
108
106
|
.endsWith(',')
|
|
109
107
|
? ''
|
|
110
108
|
: ',';
|
|
111
|
-
addChange(new InsertChange(sourceFile.fileName, devtoolsConfig.getEnd() - 1,
|
|
109
|
+
addChange(new schematics_core_1.InsertChange(sourceFile.fileName, devtoolsConfig.getEnd() - 1, `${comma} connectInZone: true`.trim()));
|
|
112
110
|
}
|
|
113
111
|
function replaceConnectOutsideZoneConfig(connectOutsideZone) {
|
|
114
|
-
|
|
112
|
+
const currentValue = connectOutsideZone.initializer
|
|
115
113
|
.getText(sourceFile)
|
|
116
114
|
.trim();
|
|
117
|
-
addChange(createReplaceChange(sourceFile, connectOutsideZone.name, 'connectOutsideZone', 'connectInZone'));
|
|
118
|
-
addChange(createReplaceChange(sourceFile, connectOutsideZone.initializer, currentValue, currentValue === 'true'
|
|
115
|
+
addChange((0, schematics_core_1.createReplaceChange)(sourceFile, connectOutsideZone.name, 'connectOutsideZone', 'connectInZone'));
|
|
116
|
+
addChange((0, schematics_core_1.createReplaceChange)(sourceFile, connectOutsideZone.initializer, currentValue, currentValue === 'true'
|
|
119
117
|
? 'false'
|
|
120
118
|
: currentValue === 'false'
|
|
121
119
|
? 'true'
|
|
122
|
-
:
|
|
120
|
+
: `!${currentValue}`));
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
123
|
function createDevtoolsConfig(sourceFile, callExpression, addChange) {
|
|
126
|
-
addChange(new InsertChange(sourceFile.fileName, callExpression.getEnd() - 1,
|
|
124
|
+
addChange(new schematics_core_1.InsertChange(sourceFile.fileName, callExpression.getEnd() - 1, `{connectInZone: true}`));
|
|
127
125
|
}
|
|
128
|
-
|
|
129
|
-
return chain([migrate()]);
|
|
126
|
+
function default_1() {
|
|
127
|
+
return (0, schematics_1.chain)([migrate()]);
|
|
130
128
|
}
|
|
131
129
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/17_0_0-beta/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/17_0_0-beta/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmKA,4BAEC;AArKD,+CAAiC;AACjC,2DAA+D;AAC/D,4DAMgC;AAEhC,SAAS,OAAO;IACd,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAA,oCAAkB,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,EAAE;YACtC,MAAM,eAAe,GAAG,UAAU,CAAC,UAAU;iBAC1C,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC;iBAC9B,MAAM,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAC9B,eAAe,CA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;IACJ,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAAyB,EACzB,cAAiC,EACjC,SAAyC;IAEzC,SAAS,CACP,IAAI,8BAAY,CACd,UAAU,CAAC,QAAQ,EACnB,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,uBAAuB,CACxB,CACF,CAAC;AACJ,CAAC;AAED;IACE,OAAO,IAAA,kBAAK,EAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport { Rule, chain, Tree } from '@angular-devkit/schematics';\nimport {\n visitTSSourceFiles,\n commitChanges,\n InsertChange,\n Change,\n createReplaceChange,\n} from '../..//schematics-core';\n\nfunction migrate() {\n return (tree: Tree) => {\n visitTSSourceFiles(tree, (sourceFile) => {\n const devtoolsImports = sourceFile.statements\n .filter(ts.isImportDeclaration)\n .filter(({ moduleSpecifier }) =>\n moduleSpecifier.getText(sourceFile).includes('@ngrx/store-devtools')\n );\n\n if (devtoolsImports.length === 0) {\n return;\n }\n\n const changes = [...findAndUpdateConfigs(sourceFile)];\n\n commitChanges(tree, sourceFile.fileName, changes);\n });\n };\n}\n\nfunction findAndUpdateConfigs(sourceFile: ts.SourceFile) {\n const changes: Change[] = [];\n ts.forEachChild(sourceFile, (node) => find(node, changes));\n return changes;\n\n function find(node: ts.Node, changes: Change[]) {\n if (\n ts.isPropertyAccessExpression(node) &&\n node.name.text === 'instrument' &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'StoreDevtoolsModule' &&\n ts.isCallExpression(node.parent)\n ) {\n if (node.parent.arguments.length) {\n const [devtoolsConfig] = node.parent.arguments;\n\n if (ts.isObjectLiteralExpression(devtoolsConfig)) {\n updateConfig(sourceFile, devtoolsConfig, (change) =>\n changes.push(change)\n );\n }\n } else {\n createDevtoolsConfig(sourceFile, node.parent, (change) =>\n changes.push(change)\n );\n }\n }\n\n if (\n ts.isCallExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === 'provideStoreDevtools'\n ) {\n if (node.arguments.length) {\n const [devtoolsConfig] = node.arguments;\n\n if (ts.isObjectLiteralExpression(devtoolsConfig)) {\n updateConfig(sourceFile, devtoolsConfig, (change) =>\n changes.push(change)\n );\n }\n } else {\n createDevtoolsConfig(sourceFile, node, (change) =>\n changes.push(change)\n );\n }\n }\n\n ts.forEachChild(node, (childNode) => find(childNode, changes));\n }\n}\n\nfunction updateConfig(\n sourceFile: ts.SourceFile,\n devtoolsConfig: ts.ObjectLiteralExpression,\n addChange: (changes: Change) => number\n) {\n const connectOutsideZoneProperty = devtoolsConfig.properties.find(\n (p) =>\n ts.isPropertyAssignment(p) &&\n ts.isIdentifier(p.name) &&\n p.name.text === 'connectOutsideZone'\n );\n\n if (!connectOutsideZoneProperty) {\n addConnectInZoneProperty();\n } else if (ts.isPropertyAssignment(connectOutsideZoneProperty)) {\n replaceConnectOutsideZoneConfig(connectOutsideZoneProperty);\n }\n\n function addConnectInZoneProperty() {\n const configText = devtoolsConfig.getText(sourceFile);\n const comma =\n !devtoolsConfig.properties.length ||\n configText\n .substring(0, configText.length - 1)\n .trim()\n .endsWith(',')\n ? ''\n : ',';\n\n addChange(\n new InsertChange(\n sourceFile.fileName,\n devtoolsConfig.getEnd() - 1,\n `${comma} connectInZone: true`.trim()\n )\n );\n }\n\n function replaceConnectOutsideZoneConfig(\n connectOutsideZone: ts.PropertyAssignment\n ) {\n const currentValue = connectOutsideZone.initializer\n .getText(sourceFile)\n .trim();\n addChange(\n createReplaceChange(\n sourceFile,\n connectOutsideZone.name,\n 'connectOutsideZone',\n 'connectInZone'\n )\n );\n addChange(\n createReplaceChange(\n sourceFile,\n connectOutsideZone.initializer,\n currentValue,\n currentValue === 'true'\n ? 'false'\n : currentValue === 'false'\n ? 'true'\n : `!${currentValue}`\n )\n );\n }\n}\n\nfunction createDevtoolsConfig(\n sourceFile: ts.SourceFile,\n callExpression: ts.CallExpression,\n addChange: (...items: Change[]) => number\n) {\n addChange(\n new InsertChange(\n sourceFile.fileName,\n callExpression.getEnd() - 1,\n `{connectInZone: true}`\n )\n );\n}\n\nexport default function (): Rule {\n return chain([migrate()]);\n}\n"]}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const schematics_core_1 = require("../../schematics-core");
|
|
5
|
+
function default_1() {
|
|
6
|
+
return (0, schematics_core_1.updatePackage)('store-devtools');
|
|
4
7
|
}
|
|
5
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/6_0_0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/migrations/6_0_0/index.ts"],"names":[],"mappings":";;AAGA,4BAEC;AAJD,2DAAsD;AAEtD;IACE,OAAO,IAAA,+BAAa,EAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC","sourcesContent":["import { Rule } from '@angular-devkit/schematics';\nimport { updatePackage } from '../../schematics-core';\n\nexport default function (): Rule {\n return updatePackage('store-devtools');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/store-devtools",
|
|
3
|
-
"version": "21.0.0
|
|
3
|
+
"version": "21.0.0",
|
|
4
4
|
"description": "Developer tools for @ngrx/store",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"homepage": "https://github.com/ngrx/platform#readme",
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@angular/core": "^21.0.0",
|
|
24
|
-
"@ngrx/store": "21.0.0
|
|
24
|
+
"@ngrx/store": "21.0.0",
|
|
25
25
|
"rxjs": "^6.5.3 || ^7.5.0"
|
|
26
26
|
},
|
|
27
27
|
"schematics": "./schematics/collection.json",
|
|
@@ -1,152 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.default = default_1;
|
|
37
|
+
const ts = __importStar(require("typescript"));
|
|
38
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
39
|
+
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
40
|
+
const schematics_core_1 = require("../../schematics-core");
|
|
41
|
+
const standalone_1 = require("../../schematics-core/utility/standalone");
|
|
42
|
+
const project_1 = require("../../schematics-core/utility/project");
|
|
43
|
+
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
|
|
35
44
|
function addImportToNgModule(options) {
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
var modulePath = options.module;
|
|
45
|
+
return (host) => {
|
|
46
|
+
const modulePath = options.module;
|
|
39
47
|
if (!modulePath) {
|
|
40
48
|
return host;
|
|
41
49
|
}
|
|
42
50
|
if (!host.exists(modulePath)) {
|
|
43
51
|
throw new Error('Specified module does not exist');
|
|
44
52
|
}
|
|
45
|
-
|
|
53
|
+
const text = host.read(modulePath);
|
|
46
54
|
if (text === null) {
|
|
47
|
-
throw new SchematicsException(
|
|
55
|
+
throw new schematics_1.SchematicsException(`File ${modulePath} does not exist.`);
|
|
48
56
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
insertImport(source, modulePath, 'StoreDevtoolsModule', '@ngrx/store-devtools'),
|
|
54
|
-
insertImport(source, modulePath, 'isDevMode', '@angular/core'),
|
|
57
|
+
const sourceText = text.toString('utf-8');
|
|
58
|
+
const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
59
|
+
const [instrumentNgModuleImport] = (0, schematics_core_1.addImportToModule)(source, modulePath, `StoreDevtoolsModule.instrument({ maxAge: ${options.maxAge}, logOnly: !isDevMode() })`, modulePath);
|
|
60
|
+
const changes = [
|
|
61
|
+
(0, schematics_core_1.insertImport)(source, modulePath, 'StoreDevtoolsModule', '@ngrx/store-devtools'),
|
|
62
|
+
(0, schematics_core_1.insertImport)(source, modulePath, 'isDevMode', '@angular/core'),
|
|
55
63
|
instrumentNgModuleImport,
|
|
56
64
|
];
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (change instanceof InsertChange) {
|
|
62
|
-
recorder.insertLeft(change.pos, change.toAdd);
|
|
63
|
-
}
|
|
65
|
+
const recorder = host.beginUpdate(modulePath);
|
|
66
|
+
for (const change of changes) {
|
|
67
|
+
if (change instanceof schematics_core_1.InsertChange) {
|
|
68
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
67
|
-
finally {
|
|
68
|
-
try {
|
|
69
|
-
if (changes_1_1 && !changes_1_1.done && (_a = changes_1.return)) _a.call(changes_1);
|
|
70
|
-
}
|
|
71
|
-
finally { if (e_1) throw e_1.error; }
|
|
72
|
-
}
|
|
73
71
|
host.commitUpdate(recorder);
|
|
74
72
|
return host;
|
|
75
73
|
};
|
|
76
74
|
}
|
|
77
75
|
function addNgRxStoreDevToolsToPackageJson() {
|
|
78
|
-
return
|
|
79
|
-
addPackageToPackageJson(host, 'dependencies', '@ngrx/store-devtools', platformVersion);
|
|
80
|
-
context.addTask(new NodePackageInstallTask());
|
|
76
|
+
return (host, context) => {
|
|
77
|
+
(0, schematics_core_1.addPackageToPackageJson)(host, 'dependencies', '@ngrx/store-devtools', schematics_core_1.platformVersion);
|
|
78
|
+
context.addTask(new tasks_1.NodePackageInstallTask());
|
|
81
79
|
return host;
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
82
|
function addStandaloneConfig(options) {
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
var mainFile = getProjectMainFile(host, options);
|
|
83
|
+
return (host) => {
|
|
84
|
+
const mainFile = (0, project_1.getProjectMainFile)(host, options);
|
|
88
85
|
if (host.exists(mainFile)) {
|
|
89
|
-
|
|
90
|
-
if (callsProvidersFunction(host, mainFile, providerFn)) {
|
|
86
|
+
const providerFn = 'provideStoreDevtools';
|
|
87
|
+
if ((0, standalone_1.callsProvidersFunction)(host, mainFile, providerFn)) {
|
|
91
88
|
// exit because the store config is already provided
|
|
92
89
|
return host;
|
|
93
90
|
}
|
|
94
|
-
|
|
95
|
-
ts.factory.createIdentifier(
|
|
91
|
+
const providerOptions = [
|
|
92
|
+
ts.factory.createIdentifier(`{ maxAge: ${options.maxAge}, logOnly: !isDevMode() }`),
|
|
96
93
|
];
|
|
97
|
-
|
|
94
|
+
const patchedConfigFile = (0, standalone_1.addFunctionalProvidersToStandaloneBootstrap)(host, mainFile, providerFn, '@ngrx/store-devtools', providerOptions);
|
|
98
95
|
// insert reducers import into the patched file
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
insertImport(source, patchedConfigFile, 'isDevMode', '@angular/core'),
|
|
96
|
+
const configFileContent = host.read(patchedConfigFile);
|
|
97
|
+
const source = ts.createSourceFile(patchedConfigFile, configFileContent?.toString('utf-8') || '', ts.ScriptTarget.Latest, true);
|
|
98
|
+
const recorder = host.beginUpdate(patchedConfigFile);
|
|
99
|
+
const changes = [
|
|
100
|
+
(0, schematics_core_1.insertImport)(source, patchedConfigFile, 'isDevMode', '@angular/core'),
|
|
104
101
|
];
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (change instanceof InsertChange) {
|
|
109
|
-
recorder.insertLeft(change.pos, change.toAdd);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
114
|
-
finally {
|
|
115
|
-
try {
|
|
116
|
-
if (changes_2_1 && !changes_2_1.done && (_a = changes_2.return)) _a.call(changes_2);
|
|
102
|
+
for (const change of changes) {
|
|
103
|
+
if (change instanceof schematics_core_1.InsertChange) {
|
|
104
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
117
105
|
}
|
|
118
|
-
finally { if (e_2) throw e_2.error; }
|
|
119
106
|
}
|
|
120
107
|
host.commitUpdate(recorder);
|
|
121
108
|
return host;
|
|
122
109
|
}
|
|
123
|
-
throw new SchematicsException(
|
|
110
|
+
throw new schematics_1.SchematicsException(`Main file not found for a project ${options.project}`);
|
|
124
111
|
};
|
|
125
112
|
}
|
|
126
|
-
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
options.path = getProjectPath(host, options);
|
|
113
|
+
function default_1(options) {
|
|
114
|
+
return (host, context) => {
|
|
115
|
+
const mainFile = (0, project_1.getProjectMainFile)(host, options);
|
|
116
|
+
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainFile);
|
|
117
|
+
options.path = (0, schematics_core_1.getProjectPath)(host, options);
|
|
131
118
|
if (options.module && !isStandalone) {
|
|
132
|
-
options.module = findModuleFromOptions(host, {
|
|
119
|
+
options.module = (0, schematics_core_1.findModuleFromOptions)(host, {
|
|
133
120
|
name: '',
|
|
134
121
|
module: options.module,
|
|
135
122
|
path: options.path,
|
|
136
123
|
});
|
|
137
124
|
}
|
|
138
|
-
|
|
125
|
+
const parsedPath = (0, schematics_core_1.parseName)(options.path, '');
|
|
139
126
|
options.path = parsedPath.path;
|
|
140
127
|
if (options.maxAge && (options.maxAge < 0 || options.maxAge === 1)) {
|
|
141
|
-
throw new SchematicsException(
|
|
128
|
+
throw new schematics_1.SchematicsException(`maxAge should be an integer greater than 1.`);
|
|
142
129
|
}
|
|
143
|
-
|
|
130
|
+
const configOrModuleUpdate = isStandalone
|
|
144
131
|
? addStandaloneConfig(options)
|
|
145
132
|
: addImportToNgModule(options);
|
|
146
|
-
return chain([
|
|
147
|
-
branchAndMerge(chain([configOrModuleUpdate])),
|
|
133
|
+
return (0, schematics_1.chain)([
|
|
134
|
+
(0, schematics_1.branchAndMerge)((0, schematics_1.chain)([configOrModuleUpdate])),
|
|
148
135
|
options && options.skipPackageJson
|
|
149
|
-
? noop()
|
|
136
|
+
? (0, schematics_1.noop)()
|
|
150
137
|
: addNgRxStoreDevToolsToPackageJson(),
|
|
151
138
|
])(host, context);
|
|
152
139
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics/ng-add/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,4BAmCC;AA9LD,+CAAiC;AACjC,2DAQoC;AACpC,4DAA0E;AAC1E,2DAS+B;AAE/B,yEAGkD;AAClD,mEAA2E;AAC3E,2EAA2E;AAE3E,SAAS,mBAAmB,CAAC,OAA6B;IACxD,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAElC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CA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C,OAAO,CAAC;YAC9B,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO,IAAA,kBAAK,EAAC;YACX,IAAA,2BAAc,EAAC,IAAA,kBAAK,EAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC7C,OAAO,IAAI,OAAO,CAAC,eAAe;gBAChC,CAAC,CAAC,IAAA,iBAAI,GAAE;gBACR,CAAC,CAAC,iCAAiC,EAAE;SACxC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport {\n Rule,\n SchematicContext,\n SchematicsException,\n Tree,\n branchAndMerge,\n chain,\n noop,\n} from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport {\n InsertChange,\n addImportToModule,\n findModuleFromOptions,\n getProjectPath,\n insertImport,\n addPackageToPackageJson,\n platformVersion,\n parseName,\n} from '../../schematics-core';\nimport { Schema as StoreDevtoolsOptions } from './schema';\nimport {\n addFunctionalProvidersToStandaloneBootstrap,\n callsProvidersFunction,\n} from '../../schematics-core/utility/standalone';\nimport { getProjectMainFile } from '../../schematics-core/utility/project';\nimport { isStandaloneApp } from '@schematics/angular/utility/ng-ast-utils';\n\nfunction addImportToNgModule(options: StoreDevtoolsOptions): Rule {\n return (host: Tree) => {\n const modulePath = options.module;\n\n if (!modulePath) {\n return host;\n }\n\n if (!host.exists(modulePath)) {\n throw new Error('Specified module does not exist');\n }\n\n const text = host.read(modulePath);\n if (text === null) {\n throw new SchematicsException(`File ${modulePath} does not exist.`);\n }\n const sourceText = text.toString('utf-8');\n\n const source = ts.createSourceFile(\n modulePath,\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n\n const [instrumentNgModuleImport] = addImportToModule(\n source,\n modulePath,\n `StoreDevtoolsModule.instrument({ maxAge: ${options.maxAge}, logOnly: !isDevMode() })`,\n modulePath\n );\n\n const changes = [\n insertImport(\n source,\n modulePath,\n 'StoreDevtoolsModule',\n '@ngrx/store-devtools'\n ),\n insertImport(source, modulePath, 'isDevMode', '@angular/core'),\n instrumentNgModuleImport,\n ];\n const recorder = host.beginUpdate(modulePath);\n\n for (const change of changes) {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n }\n host.commitUpdate(recorder);\n\n return host;\n };\n}\n\nfunction addNgRxStoreDevToolsToPackageJson() {\n return (host: Tree, context: SchematicContext) => {\n addPackageToPackageJson(\n host,\n 'dependencies',\n '@ngrx/store-devtools',\n platformVersion\n );\n context.addTask(new NodePackageInstallTask());\n return host;\n };\n}\n\nfunction addStandaloneConfig(options: StoreDevtoolsOptions): Rule {\n return (host: Tree) => {\n const mainFile = getProjectMainFile(host, options);\n\n if (host.exists(mainFile)) {\n const providerFn = 'provideStoreDevtools';\n\n if (callsProvidersFunction(host, mainFile, providerFn)) {\n // exit because the store config is already provided\n return host;\n }\n\n const providerOptions = [\n ts.factory.createIdentifier(\n `{ maxAge: ${options.maxAge}, logOnly: !isDevMode() }`\n ),\n ];\n\n const patchedConfigFile = addFunctionalProvidersToStandaloneBootstrap(\n host,\n mainFile,\n providerFn,\n '@ngrx/store-devtools',\n providerOptions\n );\n\n // insert reducers import into the patched file\n const configFileContent = host.read(patchedConfigFile);\n const source = ts.createSourceFile(\n patchedConfigFile,\n configFileContent?.toString('utf-8') || '',\n ts.ScriptTarget.Latest,\n true\n );\n\n const recorder = host.beginUpdate(patchedConfigFile);\n\n const changes = [\n insertImport(source, patchedConfigFile, 'isDevMode', '@angular/core'),\n ];\n\n for (const change of changes) {\n if (change instanceof InsertChange) {\n recorder.insertLeft(change.pos, change.toAdd);\n }\n }\n\n host.commitUpdate(recorder);\n\n return host;\n }\n\n throw new SchematicsException(\n `Main file not found for a project ${options.project}`\n );\n };\n}\n\nexport default function (options: StoreDevtoolsOptions): Rule {\n return (host: Tree, context: SchematicContext) => {\n const mainFile = getProjectMainFile(host, options);\n const isStandalone = isStandaloneApp(host, mainFile);\n\n options.path = getProjectPath(host, options);\n\n if (options.module && !isStandalone) {\n options.module = findModuleFromOptions(host, {\n name: '',\n module: options.module,\n path: options.path,\n });\n }\n\n const parsedPath = parseName(options.path, '');\n options.path = parsedPath.path;\n\n if (options.maxAge && (options.maxAge < 0 || options.maxAge === 1)) {\n throw new SchematicsException(\n `maxAge should be an integer greater than 1.`\n );\n }\n\n const configOrModuleUpdate = isStandalone\n ? addStandaloneConfig(options)\n : addImportToNgModule(options);\n\n return chain([\n branchAndMerge(chain([configOrModuleUpdate])),\n options && options.skipPackageJson\n ? noop()\n : addNgRxStoreDevToolsToPackageJson(),\n ])(host, context);\n };\n}\n"]}
|