@ngrx/entity 20.0.1 → 21.0.0-beta.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/6_0_0/index.js +3 -6
- package/migrations/6_0_0/index.js.map +1 -1
- package/package.json +5 -5
- package/schematics/ng-add/index.js +8 -11
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +0 -2
- package/schematics-core/index.js +24 -75
- package/schematics-core/index.js.map +1 -1
- package/schematics-core/utility/ast-utils.js +28 -44
- package/schematics-core/utility/ast-utils.js.map +1 -1
- package/schematics-core/utility/change.js +8 -15
- package/schematics-core/utility/change.js.map +1 -1
- package/schematics-core/utility/config.js +4 -8
- package/schematics-core/utility/config.js.map +1 -1
- package/schematics-core/utility/find-component.js +17 -22
- package/schematics-core/utility/find-component.js.map +1 -1
- package/schematics-core/utility/find-module.js +19 -24
- package/schematics-core/utility/find-module.js.map +1 -1
- package/schematics-core/utility/json-utilts.js +1 -4
- package/schematics-core/utility/json-utilts.js.map +1 -1
- package/schematics-core/utility/libs-version.js +1 -4
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js +28 -36
- package/schematics-core/utility/ngrx-utils.js.map +1 -1
- package/schematics-core/utility/package.js +1 -4
- package/schematics-core/utility/package.js.map +1 -1
- package/schematics-core/utility/parse-name.js +5 -8
- package/schematics-core/utility/parse-name.js.map +1 -1
- package/schematics-core/utility/project.js +9 -15
- package/schematics-core/utility/project.js.map +1 -1
- package/schematics-core/utility/strings.js +9 -20
- package/schematics-core/utility/strings.js.map +1 -1
- package/schematics-core/utility/update.js +4 -7
- package/schematics-core/utility/update.js.map +1 -1
- package/schematics-core/utility/visitors.js +16 -30
- package/schematics-core/utility/visitors.js.map +1 -1
- package/{src/models.d.ts → types/ngrx-entity.d.ts} +28 -23
- package/index.d.ts +0 -6
- package/public_api.d.ts +0 -1
- package/src/create_adapter.d.ts +0 -5
- package/src/entity_state.d.ts +0 -8
- package/src/index.d.ts +0 -2
- package/src/sorted_state_adapter.d.ts +0 -2
- package/src/state_adapter.d.ts +0 -7
- package/src/state_selectors.d.ts +0 -7
- package/src/unsorted_state_adapter.d.ts +0 -2
- package/src/utils.d.ts +0 -2
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var schematics_core_1 = require("../../schematics-core");
|
|
5
|
-
function default_1() {
|
|
6
|
-
return (0, schematics_core_1.updatePackage)('entity');
|
|
1
|
+
import { updatePackage } from '../../schematics-core';
|
|
2
|
+
export default function () {
|
|
3
|
+
return updatePackage('entity');
|
|
7
4
|
}
|
|
8
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/entity/migrations/6_0_0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/entity/migrations/6_0_0/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,MAAM,CAAC,OAAO;IACZ,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import { Rule } from '@angular-devkit/schematics';\nimport { updatePackage } from '../../schematics-core';\n\nexport default function (): Rule {\n return updatePackage('entity');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrx/entity",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.0-beta.0",
|
|
4
4
|
"description": "Common utilities for entity reducers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/ngrx/platform#readme",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@angular/core": "^
|
|
24
|
-
"@ngrx/store": "
|
|
23
|
+
"@angular/core": "^21.0.0",
|
|
24
|
+
"@ngrx/store": "21.0.0-beta.0",
|
|
25
25
|
"rxjs": "^6.5.3 || ^7.5.0"
|
|
26
26
|
},
|
|
27
27
|
"schematics": "./schematics/collection.json",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
"tslib": "^2.0.0"
|
|
49
49
|
},
|
|
50
50
|
"module": "fesm2022/ngrx-entity.mjs",
|
|
51
|
-
"typings": "
|
|
51
|
+
"typings": "types/ngrx-entity.d.ts",
|
|
52
52
|
"exports": {
|
|
53
53
|
"./package.json": {
|
|
54
54
|
"default": "./package.json"
|
|
55
55
|
},
|
|
56
56
|
".": {
|
|
57
|
-
"types": "./
|
|
57
|
+
"types": "./types/ngrx-entity.d.ts",
|
|
58
58
|
"default": "./fesm2022/ngrx-entity.mjs"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
var tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
-
var schematics_core_1 = require("../../schematics-core");
|
|
1
|
+
import { chain, noop, } from '@angular-devkit/schematics';
|
|
2
|
+
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
3
|
+
import { addPackageToPackageJson, platformVersion, } from '../../schematics-core';
|
|
7
4
|
function addNgRxEntityToPackageJson() {
|
|
8
5
|
return function (host, context) {
|
|
9
|
-
|
|
10
|
-
context.addTask(new
|
|
6
|
+
addPackageToPackageJson(host, 'dependencies', '@ngrx/entity', platformVersion);
|
|
7
|
+
context.addTask(new NodePackageInstallTask());
|
|
11
8
|
return host;
|
|
12
9
|
};
|
|
13
10
|
}
|
|
14
|
-
function
|
|
11
|
+
export default function (options) {
|
|
15
12
|
return function (host, context) {
|
|
16
|
-
return
|
|
13
|
+
return chain([
|
|
17
14
|
options && options.skipPackageJson
|
|
18
|
-
?
|
|
15
|
+
? noop()
|
|
19
16
|
: addNgRxEntityToPackageJson(),
|
|
20
17
|
])(host, context);
|
|
21
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics/ng-add/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/entity/schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,EACL,IAAI,GACL,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAG/B,SAAS,0BAA0B;IACjC,OAAO,UAAC,IAAU,EAAE,OAAyB;QAC3C,uBAAuB,CACrB,IAAI,EACJ,cAAc,EACd,cAAc,EACd,eAAe,CAChB,CAAC;QACF,OAAO,CAAC,OAAO,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,WAAW,OAAsB;IAC7C,OAAO,UAAC,IAAU,EAAE,OAAyB;QAC3C,OAAO,KAAK,CAAC;YACX,OAAO,IAAI,OAAO,CAAC,eAAe;gBAChC,CAAC,CAAC,IAAI,EAAE;gBACR,CAAC,CAAC,0BAA0B,EAAE;SACjC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n Rule,\n SchematicContext,\n Tree,\n chain,\n noop,\n} from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport {\n addPackageToPackageJson,\n platformVersion,\n} from '../../schematics-core';\nimport { Schema as EntityOptions } from './schema';\n\nfunction addNgRxEntityToPackageJson() {\n return (host: Tree, context: SchematicContext) => {\n addPackageToPackageJson(\n host,\n 'dependencies',\n '@ngrx/entity',\n platformVersion\n );\n context.addTask(new NodePackageInstallTask());\n return host;\n };\n}\n\nexport default function (options: EntityOptions): Rule {\n return (host: Tree, context: SchematicContext) => {\n return chain([\n options && options.skipPackageJson\n ? noop()\n : addNgRxEntityToPackageJson(),\n ])(host, context);\n };\n}\n"]}
|
package/schematics-core/index.js
CHANGED
|
@@ -1,77 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var change_1 = require("./utility/change");
|
|
21
|
-
Object.defineProperty(exports, "NoopChange", { enumerable: true, get: function () { return change_1.NoopChange; } });
|
|
22
|
-
Object.defineProperty(exports, "InsertChange", { enumerable: true, get: function () { return change_1.InsertChange; } });
|
|
23
|
-
Object.defineProperty(exports, "RemoveChange", { enumerable: true, get: function () { return change_1.RemoveChange; } });
|
|
24
|
-
Object.defineProperty(exports, "ReplaceChange", { enumerable: true, get: function () { return change_1.ReplaceChange; } });
|
|
25
|
-
Object.defineProperty(exports, "createReplaceChange", { enumerable: true, get: function () { return change_1.createReplaceChange; } });
|
|
26
|
-
Object.defineProperty(exports, "createChangeRecorder", { enumerable: true, get: function () { return change_1.createChangeRecorder; } });
|
|
27
|
-
Object.defineProperty(exports, "commitChanges", { enumerable: true, get: function () { return change_1.commitChanges; } });
|
|
28
|
-
var config_1 = require("./utility/config");
|
|
29
|
-
Object.defineProperty(exports, "getWorkspace", { enumerable: true, get: function () { return config_1.getWorkspace; } });
|
|
30
|
-
Object.defineProperty(exports, "getWorkspacePath", { enumerable: true, get: function () { return config_1.getWorkspacePath; } });
|
|
31
|
-
var find_component_1 = require("./utility/find-component");
|
|
32
|
-
Object.defineProperty(exports, "findComponentFromOptions", { enumerable: true, get: function () { return find_component_1.findComponentFromOptions; } });
|
|
33
|
-
var find_module_1 = require("./utility/find-module");
|
|
34
|
-
Object.defineProperty(exports, "findModule", { enumerable: true, get: function () { return find_module_1.findModule; } });
|
|
35
|
-
Object.defineProperty(exports, "findModuleFromOptions", { enumerable: true, get: function () { return find_module_1.findModuleFromOptions; } });
|
|
36
|
-
Object.defineProperty(exports, "buildRelativePath", { enumerable: true, get: function () { return find_module_1.buildRelativePath; } });
|
|
37
|
-
var json_utilts_1 = require("./utility/json-utilts");
|
|
38
|
-
Object.defineProperty(exports, "findPropertyInAstObject", { enumerable: true, get: function () { return json_utilts_1.findPropertyInAstObject; } });
|
|
39
|
-
var ngrx_utils_1 = require("./utility/ngrx-utils");
|
|
40
|
-
Object.defineProperty(exports, "addReducerToState", { enumerable: true, get: function () { return ngrx_utils_1.addReducerToState; } });
|
|
41
|
-
Object.defineProperty(exports, "addReducerToStateInterface", { enumerable: true, get: function () { return ngrx_utils_1.addReducerToStateInterface; } });
|
|
42
|
-
Object.defineProperty(exports, "addReducerImportToNgModule", { enumerable: true, get: function () { return ngrx_utils_1.addReducerImportToNgModule; } });
|
|
43
|
-
Object.defineProperty(exports, "addReducerToActionReducerMap", { enumerable: true, get: function () { return ngrx_utils_1.addReducerToActionReducerMap; } });
|
|
44
|
-
Object.defineProperty(exports, "omit", { enumerable: true, get: function () { return ngrx_utils_1.omit; } });
|
|
45
|
-
Object.defineProperty(exports, "getPrefix", { enumerable: true, get: function () { return ngrx_utils_1.getPrefix; } });
|
|
46
|
-
var project_1 = require("./utility/project");
|
|
47
|
-
Object.defineProperty(exports, "getProjectPath", { enumerable: true, get: function () { return project_1.getProjectPath; } });
|
|
48
|
-
Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_1.getProject; } });
|
|
49
|
-
Object.defineProperty(exports, "isLib", { enumerable: true, get: function () { return project_1.isLib; } });
|
|
50
|
-
exports.stringUtils = {
|
|
51
|
-
dasherize: strings_1.dasherize,
|
|
52
|
-
decamelize: strings_1.decamelize,
|
|
53
|
-
camelize: strings_1.camelize,
|
|
54
|
-
classify: strings_1.classify,
|
|
55
|
-
underscore: strings_1.underscore,
|
|
56
|
-
group: strings_1.group,
|
|
57
|
-
capitalize: strings_1.capitalize,
|
|
58
|
-
featurePath: strings_1.featurePath,
|
|
59
|
-
pluralize: strings_1.pluralize,
|
|
1
|
+
import { dasherize, decamelize, camelize, classify, underscore, group, capitalize, featurePath, pluralize, } from './utility/strings';
|
|
2
|
+
export { findNodes, getSourceNodes, getDecoratorMetadata, getContentOfKeyLiteral, insertAfterLastOccurrence, insertImport, addBootstrapToModule, addDeclarationToModule, addExportToModule, addImportToModule, addProviderToComponent, addProviderToModule, replaceImport, containsProperty, } from './utility/ast-utils';
|
|
3
|
+
export { NoopChange, InsertChange, RemoveChange, ReplaceChange, createReplaceChange, createChangeRecorder, commitChanges, } from './utility/change';
|
|
4
|
+
export { getWorkspace, getWorkspacePath } from './utility/config';
|
|
5
|
+
export { findComponentFromOptions } from './utility/find-component';
|
|
6
|
+
export { findModule, findModuleFromOptions, buildRelativePath, } from './utility/find-module';
|
|
7
|
+
export { findPropertyInAstObject } from './utility/json-utilts';
|
|
8
|
+
export { addReducerToState, addReducerToStateInterface, addReducerImportToNgModule, addReducerToActionReducerMap, omit, getPrefix, } from './utility/ngrx-utils';
|
|
9
|
+
export { getProjectPath, getProject, isLib } from './utility/project';
|
|
10
|
+
export var stringUtils = {
|
|
11
|
+
dasherize: dasherize,
|
|
12
|
+
decamelize: decamelize,
|
|
13
|
+
camelize: camelize,
|
|
14
|
+
classify: classify,
|
|
15
|
+
underscore: underscore,
|
|
16
|
+
group: group,
|
|
17
|
+
capitalize: capitalize,
|
|
18
|
+
featurePath: featurePath,
|
|
19
|
+
pluralize: pluralize,
|
|
60
20
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(exports, "addPackageToPackageJson", { enumerable: true, get: function () { return package_1.addPackageToPackageJson; } });
|
|
67
|
-
var libs_version_1 = require("./utility/libs-version");
|
|
68
|
-
Object.defineProperty(exports, "platformVersion", { enumerable: true, get: function () { return libs_version_1.platformVersion; } });
|
|
69
|
-
var visitors_1 = require("./utility/visitors");
|
|
70
|
-
Object.defineProperty(exports, "visitTSSourceFiles", { enumerable: true, get: function () { return visitors_1.visitTSSourceFiles; } });
|
|
71
|
-
Object.defineProperty(exports, "visitNgModuleImports", { enumerable: true, get: function () { return visitors_1.visitNgModuleImports; } });
|
|
72
|
-
Object.defineProperty(exports, "visitNgModuleExports", { enumerable: true, get: function () { return visitors_1.visitNgModuleExports; } });
|
|
73
|
-
Object.defineProperty(exports, "visitComponents", { enumerable: true, get: function () { return visitors_1.visitComponents; } });
|
|
74
|
-
Object.defineProperty(exports, "visitDecorator", { enumerable: true, get: function () { return visitors_1.visitDecorator; } });
|
|
75
|
-
Object.defineProperty(exports, "visitNgModules", { enumerable: true, get: function () { return visitors_1.visitNgModules; } });
|
|
76
|
-
Object.defineProperty(exports, "visitTemplates", { enumerable: true, get: function () { return visitors_1.visitTemplates; } });
|
|
21
|
+
export { updatePackage } from './utility/update';
|
|
22
|
+
export { parseName } from './utility/parse-name';
|
|
23
|
+
export { addPackageToPackageJson } from './utility/package';
|
|
24
|
+
export { platformVersion } from './utility/libs-version';
|
|
25
|
+
export { visitTSSourceFiles, visitNgModuleImports, visitNgModuleExports, visitComponents, visitDecorator, visitNgModules, visitTemplates, } from './utility/visitors';
|
|
77
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/entity/schematics-core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/entity/schematics-core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,EACL,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAGL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAa,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,EAC1B,4BAA4B,EAC5B,IAAI,EACJ,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,CAAC,IAAM,WAAW,GAAG;IACzB,SAAS,WAAA;IACT,UAAU,YAAA;IACV,QAAQ,UAAA;IACR,QAAQ,UAAA;IACR,UAAU,YAAA;IACV,KAAK,OAAA;IACL,UAAU,YAAA;IACV,WAAW,aAAA;IACX,SAAS,WAAA;CACV,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAC","sourcesContent":["import {\n dasherize,\n decamelize,\n camelize,\n classify,\n underscore,\n group,\n capitalize,\n featurePath,\n pluralize,\n} from './utility/strings';\n\nexport {\n findNodes,\n getSourceNodes,\n getDecoratorMetadata,\n getContentOfKeyLiteral,\n insertAfterLastOccurrence,\n insertImport,\n addBootstrapToModule,\n addDeclarationToModule,\n addExportToModule,\n addImportToModule,\n addProviderToComponent,\n addProviderToModule,\n replaceImport,\n containsProperty,\n} from './utility/ast-utils';\n\nexport {\n Host,\n Change,\n NoopChange,\n InsertChange,\n RemoveChange,\n ReplaceChange,\n createReplaceChange,\n createChangeRecorder,\n commitChanges,\n} from './utility/change';\n\nexport { AppConfig, getWorkspace, getWorkspacePath } from './utility/config';\n\nexport { findComponentFromOptions } from './utility/find-component';\n\nexport {\n findModule,\n findModuleFromOptions,\n buildRelativePath,\n ModuleOptions,\n} from './utility/find-module';\n\nexport { findPropertyInAstObject } from './utility/json-utilts';\n\nexport {\n addReducerToState,\n addReducerToStateInterface,\n addReducerImportToNgModule,\n addReducerToActionReducerMap,\n omit,\n getPrefix,\n} from './utility/ngrx-utils';\n\nexport { getProjectPath, getProject, isLib } from './utility/project';\n\nexport const stringUtils = {\n dasherize,\n decamelize,\n camelize,\n classify,\n underscore,\n group,\n capitalize,\n featurePath,\n pluralize,\n};\n\nexport { updatePackage } from './utility/update';\n\nexport { parseName } from './utility/parse-name';\n\nexport { addPackageToPackageJson } from './utility/package';\n\nexport { platformVersion } from './utility/libs-version';\n\nexport {\n visitTSSourceFiles,\n visitNgModuleImports,\n visitNgModuleExports,\n visitComponents,\n visitDecorator,\n visitNgModules,\n visitTemplates,\n} from './utility/visitors';\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __values = (this && this.__values) || function(o) {
|
|
3
2
|
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
3
|
if (m) return m.call(o);
|
|
@@ -35,21 +34,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
35
34
|
}
|
|
36
35
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
36
|
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.findNodes = findNodes;
|
|
40
|
-
exports.getSourceNodes = getSourceNodes;
|
|
41
|
-
exports.insertAfterLastOccurrence = insertAfterLastOccurrence;
|
|
42
|
-
exports.getContentOfKeyLiteral = getContentOfKeyLiteral;
|
|
43
|
-
exports.getDecoratorMetadata = getDecoratorMetadata;
|
|
44
|
-
exports.addDeclarationToModule = addDeclarationToModule;
|
|
45
|
-
exports.addImportToModule = addImportToModule;
|
|
46
|
-
exports.addProviderToModule = addProviderToModule;
|
|
47
|
-
exports.addProviderToComponent = addProviderToComponent;
|
|
48
|
-
exports.addExportToModule = addExportToModule;
|
|
49
|
-
exports.addBootstrapToModule = addBootstrapToModule;
|
|
50
|
-
exports.insertImport = insertImport;
|
|
51
|
-
exports.replaceImport = replaceImport;
|
|
52
|
-
exports.containsProperty = containsProperty;
|
|
53
37
|
/* istanbul ignore file */
|
|
54
38
|
/**
|
|
55
39
|
* @license
|
|
@@ -58,8 +42,8 @@ exports.containsProperty = containsProperty;
|
|
|
58
42
|
* Use of this source code is governed by an MIT-style license that can be
|
|
59
43
|
* found in the LICENSE file at https://angular.io/license
|
|
60
44
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
import * as ts from 'typescript';
|
|
46
|
+
import { InsertChange, NoopChange, createReplaceChange, createRemoveChange, } from './change';
|
|
63
47
|
/**
|
|
64
48
|
* Find all nodes from the AST in the subtree of node of SyntaxKind kind.
|
|
65
49
|
* @param node
|
|
@@ -67,7 +51,7 @@ var change_1 = require("./change");
|
|
|
67
51
|
* @param max The maximum number of items to return.
|
|
68
52
|
* @return all nodes of kind, or [] if none is found
|
|
69
53
|
*/
|
|
70
|
-
function findNodes(node, kind, max) {
|
|
54
|
+
export function findNodes(node, kind, max) {
|
|
71
55
|
var e_1, _a;
|
|
72
56
|
if (max === void 0) { max = Infinity; }
|
|
73
57
|
if (!node || max == 0) {
|
|
@@ -108,7 +92,7 @@ function findNodes(node, kind, max) {
|
|
|
108
92
|
* @param sourceFile The source file object.
|
|
109
93
|
* @returns {Observable<ts.Node>} An observable of all the nodes in the source.
|
|
110
94
|
*/
|
|
111
|
-
function getSourceNodes(sourceFile) {
|
|
95
|
+
export function getSourceNodes(sourceFile) {
|
|
112
96
|
var nodes = [sourceFile];
|
|
113
97
|
var result = [];
|
|
114
98
|
while (nodes.length > 0) {
|
|
@@ -142,7 +126,7 @@ function nodesByPosition(first, second) {
|
|
|
142
126
|
* @return Change instance
|
|
143
127
|
* @throw Error if toInsert is first occurence but fall back is not set
|
|
144
128
|
*/
|
|
145
|
-
function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind) {
|
|
129
|
+
export function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind) {
|
|
146
130
|
var lastItem = nodes.sort(nodesByPosition).pop();
|
|
147
131
|
if (!lastItem) {
|
|
148
132
|
throw new Error();
|
|
@@ -154,9 +138,9 @@ function insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKin
|
|
|
154
138
|
throw new Error("tried to insert ".concat(toInsert, " as first occurence with no fallback position"));
|
|
155
139
|
}
|
|
156
140
|
var lastItemPosition = lastItem ? lastItem.end : fallbackPos;
|
|
157
|
-
return new
|
|
141
|
+
return new InsertChange(file, lastItemPosition, toInsert);
|
|
158
142
|
}
|
|
159
|
-
function getContentOfKeyLiteral(_source, node) {
|
|
143
|
+
export function getContentOfKeyLiteral(_source, node) {
|
|
160
144
|
if (node.kind == ts.SyntaxKind.Identifier) {
|
|
161
145
|
return node.text;
|
|
162
146
|
}
|
|
@@ -214,7 +198,7 @@ function _angularImportsFromNode(node, _sourceFile) {
|
|
|
214
198
|
return {};
|
|
215
199
|
}
|
|
216
200
|
}
|
|
217
|
-
function getDecoratorMetadata(source, identifier, module) {
|
|
201
|
+
export function getDecoratorMetadata(source, identifier, module) {
|
|
218
202
|
var angularImports = findNodes(source, ts.SyntaxKind.ImportDeclaration)
|
|
219
203
|
.map(function (node) {
|
|
220
204
|
return _angularImportsFromNode(node, source);
|
|
@@ -315,7 +299,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
315
299
|
toInsert_1 = ", ".concat(metadataField, ": [").concat(symbolName, "]");
|
|
316
300
|
}
|
|
317
301
|
}
|
|
318
|
-
var newMetadataProperty = new
|
|
302
|
+
var newMetadataProperty = new InsertChange(ngModulePath, position_1, toInsert_1);
|
|
319
303
|
var newMetadataImport = insertImport(source, ngModulePath, symbolName.replace(/\..*$/, ''), importPath);
|
|
320
304
|
return [newMetadataProperty, newMetadataImport];
|
|
321
305
|
}
|
|
@@ -359,7 +343,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
359
343
|
var epos = void 0;
|
|
360
344
|
if (effectsElements.length === 0) {
|
|
361
345
|
epos = effectsArgs.getStart() + 1;
|
|
362
|
-
return [new
|
|
346
|
+
return [new InsertChange(ngModulePath, epos, effectsSymbol)];
|
|
363
347
|
}
|
|
364
348
|
else {
|
|
365
349
|
var lastEffect = effectsElements[effectsElements.length - 1];
|
|
@@ -373,7 +357,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
373
357
|
else {
|
|
374
358
|
effectInsert = ", ".concat(effectsSymbol);
|
|
375
359
|
}
|
|
376
|
-
return [new
|
|
360
|
+
return [new InsertChange(ngModulePath, epos, effectInsert)];
|
|
377
361
|
}
|
|
378
362
|
}
|
|
379
363
|
else {
|
|
@@ -419,7 +403,7 @@ function _addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbo
|
|
|
419
403
|
toInsert = ", ".concat(symbolName);
|
|
420
404
|
}
|
|
421
405
|
}
|
|
422
|
-
var insert = new
|
|
406
|
+
var insert = new InsertChange(ngModulePath, position, toInsert);
|
|
423
407
|
var importInsert = insertImport(source, ngModulePath, symbolName.replace(/\..*$/, ''), importPath);
|
|
424
408
|
return [insert, importInsert];
|
|
425
409
|
}
|
|
@@ -471,7 +455,7 @@ function _addSymbolToComponentMetadata(source, componentPath, metadataField, sym
|
|
|
471
455
|
toInsert_2 = ", ".concat(metadataField, ": [").concat(symbolName, "]");
|
|
472
456
|
}
|
|
473
457
|
}
|
|
474
|
-
var newMetadataProperty = new
|
|
458
|
+
var newMetadataProperty = new InsertChange(componentPath, position_2, toInsert_2);
|
|
475
459
|
var newMetadataImport = insertImport(source, componentPath, symbolName.replace(/\..*$/, ''), importPath);
|
|
476
460
|
return [newMetadataProperty, newMetadataImport];
|
|
477
461
|
}
|
|
@@ -538,7 +522,7 @@ function _addSymbolToComponentMetadata(source, componentPath, metadataField, sym
|
|
|
538
522
|
toInsert = ", ".concat(symbolName);
|
|
539
523
|
}
|
|
540
524
|
}
|
|
541
|
-
var insert = new
|
|
525
|
+
var insert = new InsertChange(componentPath, position, toInsert);
|
|
542
526
|
var importInsert = insertImport(source, componentPath, symbolName.replace(/\..*$/, ''), importPath);
|
|
543
527
|
return [insert, importInsert];
|
|
544
528
|
}
|
|
@@ -546,38 +530,38 @@ function _addSymbolToComponentMetadata(source, componentPath, metadataField, sym
|
|
|
546
530
|
* Custom function to insert a declaration (component, pipe, directive)
|
|
547
531
|
* into NgModule declarations. It also imports the component.
|
|
548
532
|
*/
|
|
549
|
-
function addDeclarationToModule(source, modulePath, classifiedName, importPath) {
|
|
533
|
+
export function addDeclarationToModule(source, modulePath, classifiedName, importPath) {
|
|
550
534
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'declarations', classifiedName, importPath);
|
|
551
535
|
}
|
|
552
536
|
/**
|
|
553
537
|
* Custom function to insert a declaration (component, pipe, directive)
|
|
554
538
|
* into NgModule declarations. It also imports the component.
|
|
555
539
|
*/
|
|
556
|
-
function addImportToModule(source, modulePath, classifiedName, importPath) {
|
|
540
|
+
export function addImportToModule(source, modulePath, classifiedName, importPath) {
|
|
557
541
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'imports', classifiedName, importPath);
|
|
558
542
|
}
|
|
559
543
|
/**
|
|
560
544
|
* Custom function to insert a provider into NgModule. It also imports it.
|
|
561
545
|
*/
|
|
562
|
-
function addProviderToModule(source, modulePath, classifiedName, importPath) {
|
|
546
|
+
export function addProviderToModule(source, modulePath, classifiedName, importPath) {
|
|
563
547
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'providers', classifiedName, importPath);
|
|
564
548
|
}
|
|
565
549
|
/**
|
|
566
550
|
* Custom function to insert a provider into Component. It also imports it.
|
|
567
551
|
*/
|
|
568
|
-
function addProviderToComponent(source, componentPath, classifiedName, importPath) {
|
|
552
|
+
export function addProviderToComponent(source, componentPath, classifiedName, importPath) {
|
|
569
553
|
return _addSymbolToComponentMetadata(source, componentPath, 'providers', classifiedName, importPath);
|
|
570
554
|
}
|
|
571
555
|
/**
|
|
572
556
|
* Custom function to insert an export into NgModule. It also imports it.
|
|
573
557
|
*/
|
|
574
|
-
function addExportToModule(source, modulePath, classifiedName, importPath) {
|
|
558
|
+
export function addExportToModule(source, modulePath, classifiedName, importPath) {
|
|
575
559
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'exports', classifiedName, importPath);
|
|
576
560
|
}
|
|
577
561
|
/**
|
|
578
562
|
* Custom function to insert an export into NgModule. It also imports it.
|
|
579
563
|
*/
|
|
580
|
-
function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
564
|
+
export function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
581
565
|
return _addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath);
|
|
582
566
|
}
|
|
583
567
|
/**
|
|
@@ -589,7 +573,7 @@ function addBootstrapToModule(source, modulePath, classifiedName, importPath) {
|
|
|
589
573
|
* @param isDefault (if true, import follows style for importing default exports)
|
|
590
574
|
* @return Change
|
|
591
575
|
*/
|
|
592
|
-
function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
576
|
+
export function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
593
577
|
if (isDefault === void 0) { isDefault = false; }
|
|
594
578
|
var rootNode = source;
|
|
595
579
|
var allImports = findNodes(rootNode, ts.SyntaxKind.ImportDeclaration);
|
|
@@ -614,7 +598,7 @@ function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
|
614
598
|
});
|
|
615
599
|
// if imports * from fileName, don't add symbolName
|
|
616
600
|
if (importsAsterisk_1) {
|
|
617
|
-
return new
|
|
601
|
+
return new NoopChange();
|
|
618
602
|
}
|
|
619
603
|
var importTextNodes = imports_1.filter(function (n) { return n.text === symbolName; });
|
|
620
604
|
// insert import if it's not there
|
|
@@ -623,7 +607,7 @@ function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
|
623
607
|
findNodes(relevantImports[0], ts.SyntaxKind.FromKeyword)[0].getStart();
|
|
624
608
|
return insertAfterLastOccurrence(imports_1, ", ".concat(symbolName), fileToEdit, fallbackPos_1);
|
|
625
609
|
}
|
|
626
|
-
return new
|
|
610
|
+
return new NoopChange();
|
|
627
611
|
}
|
|
628
612
|
// no such import declaration exists
|
|
629
613
|
var useStrict = findNodes(rootNode, ts.SyntaxKind.StringLiteral).filter(function (n) { return n.getText() === 'use strict'; });
|
|
@@ -640,7 +624,7 @@ function insertImport(source, fileToEdit, symbolName, fileName, isDefault) {
|
|
|
640
624
|
" from '".concat(fileName, "'").concat(insertAtBeginning ? ';\n' : '');
|
|
641
625
|
return insertAfterLastOccurrence(allImports, toInsert, fileToEdit, fallbackPos, ts.SyntaxKind.StringLiteral);
|
|
642
626
|
}
|
|
643
|
-
function replaceImport(sourceFile, path, importFrom, importAsIs, importToBe) {
|
|
627
|
+
export function replaceImport(sourceFile, path, importFrom, importAsIs, importToBe) {
|
|
644
628
|
var imports = sourceFile.statements
|
|
645
629
|
.filter(ts.isImportDeclaration)
|
|
646
630
|
.filter(function (_a) {
|
|
@@ -679,21 +663,21 @@ function replaceImport(sourceFile, path, importFrom, importAsIs, importToBe) {
|
|
|
679
663
|
}
|
|
680
664
|
// identifier has not been imported, simply replace the old text with the new text
|
|
681
665
|
if (!isAlreadyImported) {
|
|
682
|
-
return
|
|
666
|
+
return createReplaceChange(sourceFile, specifier, importAsIs, importToBe);
|
|
683
667
|
}
|
|
684
668
|
var nextIdentifier = importSpecifiers[index + 1];
|
|
685
669
|
// identifer is not the last, also clean up the comma
|
|
686
670
|
if (nextIdentifier) {
|
|
687
|
-
return
|
|
671
|
+
return createRemoveChange(sourceFile, specifier, specifier.getStart(sourceFile), nextIdentifier.getStart(sourceFile));
|
|
688
672
|
}
|
|
689
673
|
// there are no imports following, just remove it
|
|
690
|
-
return
|
|
674
|
+
return createRemoveChange(sourceFile, specifier, specifier.getStart(sourceFile), specifier.getEnd());
|
|
691
675
|
});
|
|
692
676
|
return importChanges.filter(Boolean);
|
|
693
677
|
});
|
|
694
678
|
return changes.reduce(function (imports, curr) { return imports.concat(curr); }, []);
|
|
695
679
|
}
|
|
696
|
-
function containsProperty(objectLiteral, propertyName) {
|
|
680
|
+
export function containsProperty(objectLiteral, propertyName) {
|
|
697
681
|
return (objectLiteral &&
|
|
698
682
|
objectLiteral.properties.some(function (prop) {
|
|
699
683
|
return ts.isPropertyAssignment(prop) &&
|