@ngrx/data 21.0.0 → 21.0.1
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/package.json +4 -4
- package/schematics/ng-add/index.js +130 -131
- 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,3 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decamelize = decamelize;
|
|
4
|
+
exports.dasherize = dasherize;
|
|
5
|
+
exports.camelize = camelize;
|
|
6
|
+
exports.classify = classify;
|
|
7
|
+
exports.underscore = underscore;
|
|
8
|
+
exports.capitalize = capitalize;
|
|
9
|
+
exports.pluralize = pluralize;
|
|
10
|
+
exports.group = group;
|
|
11
|
+
exports.featurePath = featurePath;
|
|
1
12
|
/**
|
|
2
13
|
* @license
|
|
3
14
|
* Copyright Google Inc. All Rights Reserved.
|
|
@@ -5,11 +16,11 @@
|
|
|
5
16
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
17
|
* found in the LICENSE file at https://angular.io/license
|
|
7
18
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
const STRING_DASHERIZE_REGEXP = /[ _]/g;
|
|
20
|
+
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
21
|
+
const STRING_CAMELIZE_REGEXP = /(-|_|\.|\s)+(.)?/g;
|
|
22
|
+
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
|
|
23
|
+
const STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
|
|
13
24
|
/**
|
|
14
25
|
* Converts a camelized string into all lower case separated by underscores.
|
|
15
26
|
*
|
|
@@ -20,7 +31,7 @@ var STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
|
|
|
20
31
|
decamelize('my favorite items'); // 'my favorite items'
|
|
21
32
|
```
|
|
22
33
|
*/
|
|
23
|
-
|
|
34
|
+
function decamelize(str) {
|
|
24
35
|
return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
@@ -33,7 +44,7 @@ export function decamelize(str) {
|
|
|
33
44
|
dasherize('my favorite items'); // 'my-favorite-items'
|
|
34
45
|
```
|
|
35
46
|
*/
|
|
36
|
-
|
|
47
|
+
function dasherize(str) {
|
|
37
48
|
return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');
|
|
38
49
|
}
|
|
39
50
|
/**
|
|
@@ -47,12 +58,12 @@ export function dasherize(str) {
|
|
|
47
58
|
camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
48
59
|
```
|
|
49
60
|
*/
|
|
50
|
-
|
|
61
|
+
function camelize(str) {
|
|
51
62
|
return str
|
|
52
|
-
.replace(STRING_CAMELIZE_REGEXP,
|
|
63
|
+
.replace(STRING_CAMELIZE_REGEXP, (_match, _separator, chr) => {
|
|
53
64
|
return chr ? chr.toUpperCase() : '';
|
|
54
65
|
})
|
|
55
|
-
.replace(/^([A-Z])/,
|
|
66
|
+
.replace(/^([A-Z])/, (match) => match.toLowerCase());
|
|
56
67
|
}
|
|
57
68
|
/**
|
|
58
69
|
Returns the UpperCamelCase form of a string.
|
|
@@ -64,10 +75,10 @@ export function camelize(str) {
|
|
|
64
75
|
'my favorite items'.classify(); // 'MyFavoriteItems'
|
|
65
76
|
```
|
|
66
77
|
*/
|
|
67
|
-
|
|
78
|
+
function classify(str) {
|
|
68
79
|
return str
|
|
69
80
|
.split('.')
|
|
70
|
-
.map(
|
|
81
|
+
.map((part) => capitalize(camelize(part)))
|
|
71
82
|
.join('.');
|
|
72
83
|
}
|
|
73
84
|
/**
|
|
@@ -81,7 +92,7 @@ export function classify(str) {
|
|
|
81
92
|
'my favorite items'.underscore(); // 'my_favorite_items'
|
|
82
93
|
```
|
|
83
94
|
*/
|
|
84
|
-
|
|
95
|
+
function underscore(str) {
|
|
85
96
|
return str
|
|
86
97
|
.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')
|
|
87
98
|
.replace(STRING_UNDERSCORE_REGEXP_2, '_')
|
|
@@ -97,7 +108,7 @@ export function underscore(str) {
|
|
|
97
108
|
'my favorite items'.capitalize() // 'My favorite items'
|
|
98
109
|
```
|
|
99
110
|
*/
|
|
100
|
-
|
|
111
|
+
function capitalize(str) {
|
|
101
112
|
return str.charAt(0).toUpperCase() + str.substring(1);
|
|
102
113
|
}
|
|
103
114
|
/**
|
|
@@ -111,16 +122,16 @@ export function capitalize(str) {
|
|
|
111
122
|
'user'.pluralize() // 'users'
|
|
112
123
|
```
|
|
113
124
|
*/
|
|
114
|
-
|
|
115
|
-
return camelize([/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map(
|
|
125
|
+
function pluralize(str) {
|
|
126
|
+
return camelize([/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map((c, i) => (str = str.replace(c, `$1${'iv'[i] || ''}e`))) && str + 's');
|
|
116
127
|
}
|
|
117
|
-
|
|
118
|
-
return group ?
|
|
128
|
+
function group(name, group) {
|
|
129
|
+
return group ? `${group}/${name}` : name;
|
|
119
130
|
}
|
|
120
|
-
|
|
131
|
+
function featurePath(group, flat, path, name) {
|
|
121
132
|
if (group && !flat) {
|
|
122
|
-
return
|
|
133
|
+
return `../../${path}/${name}/`;
|
|
123
134
|
}
|
|
124
|
-
return group ?
|
|
135
|
+
return group ? `../${path}/` : './';
|
|
125
136
|
}
|
|
126
137
|
//# sourceMappingURL=strings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../../../modules/data/schematics-core/utility/strings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../../../modules/data/schematics-core/utility/strings.ts"],"names":[],"mappings":";;AAuBA,gCAEC;AAYD,8BAEC;AAaD,4BASC;AAYD,4BAKC;AAaD,gCAKC;AAYD,gCAEC;AAaD,8BAMC;AAED,sBAEC;AAED,kCAWC;AAlJD;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACxC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AACrD,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AACxD,MAAM,0BAA0B,GA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AAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,OAAO,QAAQ,CACb,CAAC,cAAc,EAAE,QAAQ,EAAE,0BAA0B,CAAC,CAAC,GAAG,CACxD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CACxD,IAAI,GAAG,GAAG,GAAG,CACf,CAAC;AACJ,CAAC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,KAAyB;IAC3D,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,SAAgB,WAAW,CACzB,KAA0B,EAC1B,IAAyB,EACzB,IAAY,EACZ,IAAY;IAEZ,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,OAAO,SAAS,IAAI,IAAI,IAAI,GAAG,CAAC;IAClC,CAAC;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\nconst STRING_CAMELIZE_REGEXP = /(-|_|\\.|\\s)+(.)?/g;\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\nconst STRING_UNDERSCORE_REGEXP_2 = /-|\\s+/g;\n\n/**\n * Converts a camelized string into all lower case separated by underscores.\n *\n ```javascript\n decamelize('innerHTML'); // 'inner_html'\n decamelize('action_name'); // 'action_name'\n decamelize('css-class-name'); // 'css-class-name'\n decamelize('my favorite items'); // 'my favorite items'\n ```\n */\nexport function decamelize(str: string): string {\n return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();\n}\n\n/**\n Replaces underscores, spaces, or camelCase with dashes.\n\n ```javascript\n dasherize('innerHTML'); // 'inner-html'\n dasherize('action_name'); // 'action-name'\n dasherize('css-class-name'); // 'css-class-name'\n dasherize('my favorite items'); // 'my-favorite-items'\n ```\n */\nexport function dasherize(str?: string): string {\n return decamelize(str || '').replace(STRING_DASHERIZE_REGEXP, '-');\n}\n\n/**\n Returns the lowerCamelCase form of a string.\n\n ```javascript\n camelize('innerHTML'); // 'innerHTML'\n camelize('action_name'); // 'actionName'\n camelize('css-class-name'); // 'cssClassName'\n camelize('my favorite items'); // 'myFavoriteItems'\n camelize('My Favorite Items'); // 'myFavoriteItems'\n ```\n */\nexport function camelize(str: string): string {\n return str\n .replace(\n STRING_CAMELIZE_REGEXP,\n (_match: string, _separator: string, chr: string) => {\n return chr ? chr.toUpperCase() : '';\n }\n )\n .replace(/^([A-Z])/, (match: string) => match.toLowerCase());\n}\n\n/**\n Returns the UpperCamelCase form of a string.\n\n ```javascript\n 'innerHTML'.classify(); // 'InnerHTML'\n 'action_name'.classify(); // 'ActionName'\n 'css-class-name'.classify(); // 'CssClassName'\n 'my favorite items'.classify(); // 'MyFavoriteItems'\n ```\n */\nexport function classify(str: string): string {\n return str\n .split('.')\n .map((part) => capitalize(camelize(part)))\n .join('.');\n}\n\n/**\n More general than decamelize. Returns the lower\\_case\\_and\\_underscored\n form of a string.\n\n ```javascript\n 'innerHTML'.underscore(); // 'inner_html'\n 'action_name'.underscore(); // 'action_name'\n 'css-class-name'.underscore(); // 'css_class_name'\n 'my favorite items'.underscore(); // 'my_favorite_items'\n ```\n */\nexport function underscore(str: string): string {\n return str\n .replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')\n .replace(STRING_UNDERSCORE_REGEXP_2, '_')\n .toLowerCase();\n}\n\n/**\n Returns the Capitalized form of a string\n\n ```javascript\n 'innerHTML'.capitalize() // 'InnerHTML'\n 'action_name'.capitalize() // 'Action_name'\n 'css-class-name'.capitalize() // 'Css-class-name'\n 'my favorite items'.capitalize() // 'My favorite items'\n ```\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.substring(1);\n}\n\n/**\n Returns the plural form of a string\n\n ```javascript\n 'innerHTML'.pluralize() // 'innerHTMLs'\n 'action_name'.pluralize() // 'actionNames'\n 'css-class-name'.pluralize() // 'cssClassNames'\n 'regex'.pluralize() // 'regexes'\n 'user'.pluralize() // 'users'\n ```\n */\nexport function pluralize(str: string): string {\n return camelize(\n [/([^aeiou])y$/, /()fe?$/, /([^aeiou]o|[sxz]|[cs]h)$/].map(\n (c, i) => (str = str.replace(c, `$1${'iv'[i] || ''}e`))\n ) && str + 's'\n );\n}\n\nexport function group(name: string, group: string | undefined) {\n return group ? `${group}/${name}` : name;\n}\n\nexport function featurePath(\n group: boolean | undefined,\n flat: boolean | undefined,\n path: string,\n name: string\n) {\n if (group && !flat) {\n return `../../${path}/${name}/`;\n }\n\n return group ? `../${path}/` : './';\n}\n"]}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePackage = updatePackage;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
function updatePackage(name) {
|
|
6
|
+
return (tree, context) => {
|
|
7
|
+
const pkgPath = '/package.json';
|
|
8
|
+
const buffer = tree.read(pkgPath);
|
|
6
9
|
if (buffer === null) {
|
|
7
|
-
throw new SchematicsException('Could not read package.json');
|
|
10
|
+
throw new schematics_1.SchematicsException('Could not read package.json');
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
const content = buffer.toString();
|
|
13
|
+
const pkg = JSON.parse(content);
|
|
11
14
|
if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
|
|
12
|
-
throw new SchematicsException('Error reading package.json');
|
|
15
|
+
throw new schematics_1.SchematicsException('Error reading package.json');
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
dependencyCategories.forEach(
|
|
16
|
-
|
|
17
|
+
const dependencyCategories = ['dependencies', 'devDependencies'];
|
|
18
|
+
dependencyCategories.forEach((category) => {
|
|
19
|
+
const packageName = `@ngrx/${name}`;
|
|
17
20
|
if (pkg[category] && pkg[category][packageName]) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
pkg[category][packageName] =
|
|
21
|
+
const firstChar = pkg[category][packageName][0];
|
|
22
|
+
const suffix = match(firstChar, '^') || match(firstChar, '~');
|
|
23
|
+
pkg[category][packageName] = `${suffix}6.0.0`;
|
|
21
24
|
}
|
|
22
25
|
});
|
|
23
26
|
tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../modules/data/schematics-core/utility/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../modules/data/schematics-core/utility/update.ts"],"names":[],"mappings":";;AAOA,sCA+BC;AAtCD,2DAKoC;AAEpC,SAAgB,aAAa,CAAC,IAAY;IACxC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,OAAO,GAAG,eAAe,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,gCAAmB,CAAC,6BAA6B,CAAC,CAAC;QAC/D,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,CA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ematics';\n\nexport function updatePackage(name: string): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const pkgPath = '/package.json';\n const buffer = tree.read(pkgPath);\n if (buffer === null) {\n throw new SchematicsException('Could not read package.json');\n }\n const content = buffer.toString();\n const pkg = JSON.parse(content);\n\n if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {\n throw new SchematicsException('Error reading package.json');\n }\n\n const dependencyCategories = ['dependencies', 'devDependencies'];\n\n dependencyCategories.forEach((category) => {\n const packageName = `@ngrx/${name}`;\n\n if (pkg[category] && pkg[category][packageName]) {\n const firstChar = pkg[category][packageName][0];\n const suffix = match(firstChar, '^') || match(firstChar, '~');\n\n pkg[category][packageName] = `${suffix}6.0.0`;\n }\n });\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));\n\n return tree;\n };\n}\n\nfunction match(value: string, test: string) {\n return value === test ? test : '';\n}\n"]}
|
|
@@ -1,87 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
8
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
9
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
10
|
-
switch (op[0]) {
|
|
11
|
-
case 0: case 1: t = op; break;
|
|
12
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
13
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
14
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
15
|
-
default:
|
|
16
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
17
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
18
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
19
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
20
|
-
if (t[2]) _.ops.pop();
|
|
21
|
-
_.trys.pop(); continue;
|
|
22
|
-
}
|
|
23
|
-
op = body.call(thisArg, _);
|
|
24
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
25
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
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]; } };
|
|
26
7
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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);
|
|
36
26
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
67
|
-
finally {
|
|
68
|
-
try {
|
|
69
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
70
|
-
}
|
|
71
|
-
finally { if (e_1) throw e_1.error; }
|
|
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.visitTSSourceFiles = visitTSSourceFiles;
|
|
37
|
+
exports.visitTemplates = visitTemplates;
|
|
38
|
+
exports.visitNgModuleImports = visitNgModuleImports;
|
|
39
|
+
exports.visitNgModuleExports = visitNgModuleExports;
|
|
40
|
+
exports.visitComponents = visitComponents;
|
|
41
|
+
exports.visitNgModules = visitNgModules;
|
|
42
|
+
exports.visitDecorator = visitDecorator;
|
|
43
|
+
exports.visitImportDeclaration = visitImportDeclaration;
|
|
44
|
+
exports.visitImportSpecifier = visitImportSpecifier;
|
|
45
|
+
exports.visitTypeReference = visitTypeReference;
|
|
46
|
+
exports.visitTypeLiteral = visitTypeLiteral;
|
|
47
|
+
exports.visitCallExpression = visitCallExpression;
|
|
48
|
+
const ts = __importStar(require("typescript"));
|
|
49
|
+
const core_1 = require("@angular-devkit/core");
|
|
50
|
+
function visitTSSourceFiles(tree, visitor) {
|
|
51
|
+
let result = undefined;
|
|
52
|
+
for (const sourceFile of visit(tree.root)) {
|
|
53
|
+
result = visitor(sourceFile, tree, result);
|
|
72
54
|
}
|
|
73
55
|
return result;
|
|
74
56
|
}
|
|
75
|
-
|
|
76
|
-
visitTSSourceFiles(tree,
|
|
77
|
-
visitComponents(source,
|
|
57
|
+
function visitTemplates(tree, visitor) {
|
|
58
|
+
visitTSSourceFiles(tree, (source) => {
|
|
59
|
+
visitComponents(source, (_, decoratorExpressionNode) => {
|
|
78
60
|
ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {
|
|
79
61
|
if (ts.isPropertyAssignment(n) && ts.isIdentifier(n.name)) {
|
|
80
62
|
if (n.name.text === 'template' &&
|
|
81
63
|
ts.isStringLiteralLike(n.initializer)) {
|
|
82
64
|
// Need to add an offset of one to the start because the template quotes are
|
|
83
65
|
// not part of the template content.
|
|
84
|
-
|
|
66
|
+
const templateStartIdx = n.initializer.getStart() + 1;
|
|
85
67
|
visitor({
|
|
86
68
|
fileName: source.fileName,
|
|
87
69
|
content: n.initializer.text,
|
|
@@ -92,12 +74,12 @@ export function visitTemplates(tree, visitor) {
|
|
|
92
74
|
}
|
|
93
75
|
else if (n.name.text === 'templateUrl' &&
|
|
94
76
|
ts.isStringLiteralLike(n.initializer)) {
|
|
95
|
-
|
|
96
|
-
|
|
77
|
+
const parts = (0, core_1.normalize)(source.fileName).split('/').slice(0, -1);
|
|
78
|
+
const templatePath = (0, core_1.resolve)((0, core_1.normalize)(parts.join('/')), (0, core_1.normalize)(n.initializer.text));
|
|
97
79
|
if (!tree.exists(templatePath)) {
|
|
98
80
|
return;
|
|
99
81
|
}
|
|
100
|
-
|
|
82
|
+
const fileContent = tree.read(templatePath);
|
|
101
83
|
if (!fileContent) {
|
|
102
84
|
return;
|
|
103
85
|
}
|
|
@@ -115,14 +97,14 @@ export function visitTemplates(tree, visitor) {
|
|
|
115
97
|
});
|
|
116
98
|
});
|
|
117
99
|
}
|
|
118
|
-
|
|
100
|
+
function visitNgModuleImports(sourceFile, callback) {
|
|
119
101
|
visitNgModuleProperty(sourceFile, callback, 'imports');
|
|
120
102
|
}
|
|
121
|
-
|
|
103
|
+
function visitNgModuleExports(sourceFile, callback) {
|
|
122
104
|
visitNgModuleProperty(sourceFile, callback, 'exports');
|
|
123
105
|
}
|
|
124
106
|
function visitNgModuleProperty(sourceFile, callback, property) {
|
|
125
|
-
visitNgModules(sourceFile,
|
|
107
|
+
visitNgModules(sourceFile, (_, decoratorExpressionNode) => {
|
|
126
108
|
ts.forEachChild(decoratorExpressionNode, function findTemplates(n) {
|
|
127
109
|
if (ts.isPropertyAssignment(n) &&
|
|
128
110
|
ts.isIdentifier(n.name) &&
|
|
@@ -135,23 +117,23 @@ function visitNgModuleProperty(sourceFile, callback, property) {
|
|
|
135
117
|
});
|
|
136
118
|
});
|
|
137
119
|
}
|
|
138
|
-
|
|
120
|
+
function visitComponents(sourceFile, callback) {
|
|
139
121
|
visitDecorator(sourceFile, 'Component', callback);
|
|
140
122
|
}
|
|
141
|
-
|
|
123
|
+
function visitNgModules(sourceFile, callback) {
|
|
142
124
|
visitDecorator(sourceFile, 'NgModule', callback);
|
|
143
125
|
}
|
|
144
|
-
|
|
126
|
+
function visitDecorator(sourceFile, decoratorName, callback) {
|
|
145
127
|
ts.forEachChild(sourceFile, function findClassDeclaration(node) {
|
|
146
128
|
if (!ts.isClassDeclaration(node)) {
|
|
147
129
|
ts.forEachChild(node, findClassDeclaration);
|
|
148
130
|
}
|
|
149
|
-
|
|
150
|
-
|
|
131
|
+
const classDeclarationNode = node;
|
|
132
|
+
const decorators = ts.getDecorators(classDeclarationNode);
|
|
151
133
|
if (!decorators || !decorators.length) {
|
|
152
134
|
return;
|
|
153
135
|
}
|
|
154
|
-
|
|
136
|
+
const componentDecorator = decorators.find((d) => {
|
|
155
137
|
return (ts.isCallExpression(d.expression) &&
|
|
156
138
|
ts.isIdentifier(d.expression.expression) &&
|
|
157
139
|
d.expression.expression.text === decoratorName);
|
|
@@ -159,154 +141,84 @@ export function visitDecorator(sourceFile, decoratorName, callback) {
|
|
|
159
141
|
if (!componentDecorator) {
|
|
160
142
|
return;
|
|
161
143
|
}
|
|
162
|
-
|
|
144
|
+
const { expression } = componentDecorator;
|
|
163
145
|
if (!ts.isCallExpression(expression)) {
|
|
164
146
|
return;
|
|
165
147
|
}
|
|
166
|
-
|
|
148
|
+
const [arg] = expression.arguments;
|
|
167
149
|
if (!arg || !ts.isObjectLiteralExpression(arg)) {
|
|
168
150
|
return;
|
|
169
151
|
}
|
|
170
152
|
callback(classDeclarationNode, arg);
|
|
171
153
|
});
|
|
172
154
|
}
|
|
173
|
-
|
|
155
|
+
function visitImportDeclaration(node, callback) {
|
|
174
156
|
if (ts.isImportDeclaration(node)) {
|
|
175
|
-
|
|
176
|
-
|
|
157
|
+
const moduleSpecifier = node.moduleSpecifier.getText();
|
|
158
|
+
const moduleName = moduleSpecifier.replaceAll('"', '').replaceAll("'", '');
|
|
177
159
|
callback(node, moduleName);
|
|
178
160
|
}
|
|
179
|
-
ts.forEachChild(node,
|
|
161
|
+
ts.forEachChild(node, (child) => {
|
|
180
162
|
visitImportDeclaration(child, callback);
|
|
181
163
|
});
|
|
182
164
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var importClause = node.importClause;
|
|
165
|
+
function visitImportSpecifier(node, callback) {
|
|
166
|
+
const { importClause } = node;
|
|
186
167
|
if (!importClause) {
|
|
187
168
|
return;
|
|
188
169
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
for (var namedImportChildren_1 = (e_3 = void 0, __values(namedImportChildren)), namedImportChildren_1_1 = namedImportChildren_1.next(); !namedImportChildren_1_1.done; namedImportChildren_1_1 = namedImportChildren_1.next()) {
|
|
197
|
-
var importSpecifier = namedImportChildren_1_1.value;
|
|
198
|
-
if (ts.isImportSpecifier(importSpecifier)) {
|
|
199
|
-
callback(importSpecifier);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
204
|
-
finally {
|
|
205
|
-
try {
|
|
206
|
-
if (namedImportChildren_1_1 && !namedImportChildren_1_1.done && (_b = namedImportChildren_1.return)) _b.call(namedImportChildren_1);
|
|
207
|
-
}
|
|
208
|
-
finally { if (e_3) throw e_3.error; }
|
|
170
|
+
const importClauseChildren = importClause.getChildren();
|
|
171
|
+
for (const namedImport of importClauseChildren) {
|
|
172
|
+
if (ts.isNamedImports(namedImport)) {
|
|
173
|
+
const namedImportChildren = namedImport.elements;
|
|
174
|
+
for (const importSpecifier of namedImportChildren) {
|
|
175
|
+
if (ts.isImportSpecifier(importSpecifier)) {
|
|
176
|
+
callback(importSpecifier);
|
|
209
177
|
}
|
|
210
178
|
}
|
|
211
179
|
}
|
|
212
180
|
}
|
|
213
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
214
|
-
finally {
|
|
215
|
-
try {
|
|
216
|
-
if (importClauseChildren_1_1 && !importClauseChildren_1_1.done && (_a = importClauseChildren_1.return)) _a.call(importClauseChildren_1);
|
|
217
|
-
}
|
|
218
|
-
finally { if (e_2) throw e_2.error; }
|
|
219
|
-
}
|
|
220
181
|
}
|
|
221
|
-
|
|
182
|
+
function visitTypeReference(node, callback) {
|
|
222
183
|
if (ts.isTypeReferenceNode(node)) {
|
|
223
184
|
callback(node);
|
|
224
185
|
}
|
|
225
|
-
ts.forEachChild(node,
|
|
186
|
+
ts.forEachChild(node, (child) => {
|
|
226
187
|
visitTypeReference(child, callback);
|
|
227
188
|
});
|
|
228
189
|
}
|
|
229
|
-
|
|
190
|
+
function visitTypeLiteral(node, callback) {
|
|
230
191
|
if (ts.isTypeLiteralNode(node)) {
|
|
231
192
|
callback(node);
|
|
232
193
|
}
|
|
233
|
-
ts.forEachChild(node,
|
|
194
|
+
ts.forEachChild(node, (child) => {
|
|
234
195
|
visitTypeLiteral(child, callback);
|
|
235
196
|
});
|
|
236
197
|
}
|
|
237
|
-
|
|
198
|
+
function visitCallExpression(node, callback) {
|
|
238
199
|
if (ts.isCallExpression(node)) {
|
|
239
200
|
callback(node);
|
|
240
201
|
}
|
|
241
|
-
ts.forEachChild(node,
|
|
202
|
+
ts.forEachChild(node, (child) => {
|
|
242
203
|
visitCallExpression(child, callback);
|
|
243
204
|
});
|
|
244
205
|
}
|
|
245
|
-
function visit(directory) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
case 1:
|
|
255
|
-
if (!!_b.done) return [3 /*break*/, 4];
|
|
256
|
-
path = _b.value;
|
|
257
|
-
if (!(path.endsWith('.ts') && !path.endsWith('.d.ts'))) return [3 /*break*/, 3];
|
|
258
|
-
entry = directory.file(path);
|
|
259
|
-
if (!entry) return [3 /*break*/, 3];
|
|
260
|
-
content = entry.content;
|
|
261
|
-
source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
|
|
262
|
-
return [4 /*yield*/, source];
|
|
263
|
-
case 2:
|
|
264
|
-
_g.sent();
|
|
265
|
-
_g.label = 3;
|
|
266
|
-
case 3:
|
|
267
|
-
_b = _a.next();
|
|
268
|
-
return [3 /*break*/, 1];
|
|
269
|
-
case 4: return [3 /*break*/, 7];
|
|
270
|
-
case 5:
|
|
271
|
-
e_4_1 = _g.sent();
|
|
272
|
-
e_4 = { error: e_4_1 };
|
|
273
|
-
return [3 /*break*/, 7];
|
|
274
|
-
case 6:
|
|
275
|
-
try {
|
|
276
|
-
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
277
|
-
}
|
|
278
|
-
finally { if (e_4) throw e_4.error; }
|
|
279
|
-
return [7 /*endfinally*/];
|
|
280
|
-
case 7:
|
|
281
|
-
_g.trys.push([7, 12, 13, 14]);
|
|
282
|
-
_c = __values(directory.subdirs), _d = _c.next();
|
|
283
|
-
_g.label = 8;
|
|
284
|
-
case 8:
|
|
285
|
-
if (!!_d.done) return [3 /*break*/, 11];
|
|
286
|
-
path = _d.value;
|
|
287
|
-
if (path === 'node_modules') {
|
|
288
|
-
return [3 /*break*/, 10];
|
|
289
|
-
}
|
|
290
|
-
return [5 /*yield**/, __values(visit(directory.dir(path)))];
|
|
291
|
-
case 9:
|
|
292
|
-
_g.sent();
|
|
293
|
-
_g.label = 10;
|
|
294
|
-
case 10:
|
|
295
|
-
_d = _c.next();
|
|
296
|
-
return [3 /*break*/, 8];
|
|
297
|
-
case 11: return [3 /*break*/, 14];
|
|
298
|
-
case 12:
|
|
299
|
-
e_5_1 = _g.sent();
|
|
300
|
-
e_5 = { error: e_5_1 };
|
|
301
|
-
return [3 /*break*/, 14];
|
|
302
|
-
case 13:
|
|
303
|
-
try {
|
|
304
|
-
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
305
|
-
}
|
|
306
|
-
finally { if (e_5) throw e_5.error; }
|
|
307
|
-
return [7 /*endfinally*/];
|
|
308
|
-
case 14: return [2 /*return*/];
|
|
206
|
+
function* visit(directory) {
|
|
207
|
+
for (const path of directory.subfiles) {
|
|
208
|
+
if (path.endsWith('.ts') && !path.endsWith('.d.ts')) {
|
|
209
|
+
const entry = directory.file(path);
|
|
210
|
+
if (entry) {
|
|
211
|
+
const content = entry.content;
|
|
212
|
+
const source = ts.createSourceFile(entry.path, content.toString().replace(/^\uFEFF/, ''), ts.ScriptTarget.Latest, true);
|
|
213
|
+
yield source;
|
|
214
|
+
}
|
|
309
215
|
}
|
|
310
|
-
}
|
|
216
|
+
}
|
|
217
|
+
for (const path of directory.subdirs) {
|
|
218
|
+
if (path === 'node_modules') {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
yield* visit(directory.dir(path));
|
|
222
|
+
}
|
|
311
223
|
}
|
|
312
224
|
//# sourceMappingURL=visitors.js.map
|