@ngrx/store-devtools 20.1.0 → 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/fesm2022/ngrx-store-devtools.mjs +13 -13
- package/migrations/17_0_0-beta/index.js +11 -14
- package/migrations/17_0_0-beta/index.js.map +1 -1
- 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 +30 -33
- 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/standalone.js +13 -18
- package/schematics-core/utility/standalone.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/types/ngrx-store-devtools.d.ts +252 -0
- package/index.d.ts +0 -6
- package/public_api.d.ts +0 -1
- package/src/actions.d.ts +0 -79
- package/src/config.d.ts +0 -126
- package/src/devtools-dispatcher.d.ts +0 -6
- package/src/devtools.d.ts +0 -35
- package/src/extension.d.ts +0 -52
- package/src/index.d.ts +0 -6
- package/src/instrument.d.ts +0 -9
- package/src/provide-store-devtools.d.ts +0 -26
- package/src/reducer.d.ts +0 -47
- package/src/utils.d.ts +0 -42
- package/src/zone-config.d.ts +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAQ,MAAM,4BAA4B,CAAC;AAkIvE,MAAM,UAAU,gBAAgB,CAAC,IAAU;IACzC,IAAM,aAAa,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAC7E,IAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAjB,CAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAElE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAU;IACrC,IAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,IAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,mBAAmB,CAAC,0BAAmB,IAAI,MAAG,CAAC,CAAC;IAC5D,CAAC;IACD,IAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;IAEvC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { SchematicsException, Tree } from '@angular-devkit/schematics';\n\n// The interfaces below are generated from the Angular CLI configuration schema\n// https://github.com/angular/angular-cli/blob/master/packages/@angular/cli/lib/config/schema.json\nexport interface AppConfig {\n /**\n * Name of the app.\n */\n name?: string;\n /**\n * Directory where app files are placed.\n */\n appRoot?: string;\n /**\n * The root directory of the app.\n */\n root?: string;\n /**\n * The output directory for build results.\n */\n outDir?: string;\n /**\n * List of application assets.\n */\n assets?: (\n | string\n | {\n /**\n * The pattern to match.\n */\n glob?: string;\n /**\n * The dir to search within.\n */\n input?: string;\n /**\n * The output path (relative to the outDir).\n */\n output?: string;\n }\n )[];\n /**\n * URL where files will be deployed.\n */\n deployUrl?: string;\n /**\n * Base url for the application being built.\n */\n baseHref?: string;\n /**\n * The runtime platform of the app.\n */\n platform?: 'browser' | 'server';\n /**\n * The name of the start HTML file.\n */\n index?: string;\n /**\n * The name of the main entry-point file.\n */\n main?: string;\n /**\n * The name of the polyfills file.\n */\n polyfills?: string;\n /**\n * The name of the test entry-point file.\n */\n test?: string;\n /**\n * The name of the TypeScript configuration file.\n */\n tsconfig?: string;\n /**\n * The name of the TypeScript configuration file for unit tests.\n */\n testTsconfig?: string;\n /**\n * The prefix to apply to generated selectors.\n */\n prefix?: string;\n /**\n * Experimental support for a service worker from @angular/service-worker.\n */\n serviceWorker?: boolean;\n /**\n * Global styles to be included in the build.\n */\n styles?: (\n | string\n | {\n input?: string;\n [name: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n )[];\n /**\n * Options to pass to style preprocessors\n */\n stylePreprocessorOptions?: {\n /**\n * Paths to include. Paths will be resolved to project root.\n */\n includePaths?: string[];\n };\n /**\n * Global scripts to be included in the build.\n */\n scripts?: (\n | string\n | {\n input: string;\n [name: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n }\n )[];\n /**\n * Source file for environment config.\n */\n environmentSource?: string;\n /**\n * Name and corresponding file for environment config.\n */\n environments?: {\n [name: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n };\n appShell?: {\n app: string;\n route: string;\n };\n}\n\nexport function getWorkspacePath(host: Tree): string {\n const possibleFiles = ['/angular.json', '/.angular.json', '/workspace.json'];\n const path = possibleFiles.filter((path) => host.exists(path))[0];\n\n return path;\n}\n\nexport function getWorkspace(host: Tree) {\n const path = getWorkspacePath(host);\n const configBuffer = host.read(path);\n if (configBuffer === null) {\n throw new SchematicsException(`Could not find (${path})`);\n }\n const config = configBuffer.toString();\n\n return JSON.parse(config);\n}\n"]}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findComponentFromOptions = findComponentFromOptions;
|
|
4
|
-
exports.findComponent = findComponent;
|
|
5
|
-
exports.buildRelativePath = buildRelativePath;
|
|
6
1
|
/**
|
|
7
2
|
* @license
|
|
8
3
|
* Copyright Google Inc. All Rights Reserved.
|
|
@@ -10,33 +5,33 @@ exports.buildRelativePath = buildRelativePath;
|
|
|
10
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
11
6
|
* found in the LICENSE file at https://angular.io/license
|
|
12
7
|
*/
|
|
13
|
-
|
|
8
|
+
import { join, normalize, relative, strings, basename, extname, dirname, } from '@angular-devkit/core';
|
|
14
9
|
/**
|
|
15
10
|
* Find the component referred by a set of options passed to the schematics.
|
|
16
11
|
*/
|
|
17
|
-
function findComponentFromOptions(host, options) {
|
|
12
|
+
export function findComponentFromOptions(host, options) {
|
|
18
13
|
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
19
14
|
return undefined;
|
|
20
15
|
}
|
|
21
16
|
if (!options.component) {
|
|
22
17
|
var pathToCheck = (options.path || '') +
|
|
23
|
-
(options.flat ? '' : '/' +
|
|
24
|
-
return
|
|
18
|
+
(options.flat ? '' : '/' + strings.dasherize(options.name));
|
|
19
|
+
return normalize(findComponent(host, pathToCheck));
|
|
25
20
|
}
|
|
26
21
|
else {
|
|
27
|
-
var componentPath =
|
|
28
|
-
var componentBaseName =
|
|
22
|
+
var componentPath = normalize('/' + options.path + '/' + options.component);
|
|
23
|
+
var componentBaseName = normalize(componentPath).split('/').pop();
|
|
29
24
|
if (host.exists(componentPath)) {
|
|
30
|
-
return
|
|
25
|
+
return normalize(componentPath);
|
|
31
26
|
}
|
|
32
27
|
else if (host.exists(componentPath + '.ts')) {
|
|
33
|
-
return
|
|
28
|
+
return normalize(componentPath + '.ts');
|
|
34
29
|
}
|
|
35
30
|
else if (host.exists(componentPath + '.component.ts')) {
|
|
36
|
-
return
|
|
31
|
+
return normalize(componentPath + '.component.ts');
|
|
37
32
|
}
|
|
38
33
|
else if (host.exists(componentPath + '/' + componentBaseName + '.component.ts')) {
|
|
39
|
-
return
|
|
34
|
+
return normalize(componentPath + '/' + componentBaseName + '.component.ts');
|
|
40
35
|
}
|
|
41
36
|
else {
|
|
42
37
|
throw new Error("Specified component path ".concat(componentPath, " does not exist"));
|
|
@@ -46,13 +41,13 @@ function findComponentFromOptions(host, options) {
|
|
|
46
41
|
/**
|
|
47
42
|
* Function to find the "closest" component to a generated file's path.
|
|
48
43
|
*/
|
|
49
|
-
function findComponent(host, generateDir) {
|
|
44
|
+
export function findComponent(host, generateDir) {
|
|
50
45
|
var dir = host.getDir('/' + generateDir);
|
|
51
46
|
var componentRe = /\.component\.ts$/;
|
|
52
47
|
while (dir) {
|
|
53
48
|
var matches = dir.subfiles.filter(function (p) { return componentRe.test(p); });
|
|
54
49
|
if (matches.length == 1) {
|
|
55
|
-
return
|
|
50
|
+
return join(dir.path, matches[0]);
|
|
56
51
|
}
|
|
57
52
|
else if (matches.length > 1) {
|
|
58
53
|
throw new Error('More than one component matches. Use skip-import option to skip importing ' +
|
|
@@ -66,10 +61,10 @@ function findComponent(host, generateDir) {
|
|
|
66
61
|
/**
|
|
67
62
|
* Build a relative path from one file path to another file path.
|
|
68
63
|
*/
|
|
69
|
-
function buildRelativePath(from, to) {
|
|
64
|
+
export function buildRelativePath(from, to) {
|
|
70
65
|
var _a = parsePath(from), fromPath = _a.path, fromFileName = _a.filename, fromDirectory = _a.directory;
|
|
71
66
|
var _b = parsePath(to), toPath = _b.path, toFileName = _b.filename, toDirectory = _b.directory;
|
|
72
|
-
var relativePath =
|
|
67
|
+
var relativePath = relative(fromDirectory, toDirectory);
|
|
73
68
|
var fixedRelativePath = relativePath.startsWith('.')
|
|
74
69
|
? relativePath
|
|
75
70
|
: "./".concat(relativePath);
|
|
@@ -80,9 +75,9 @@ function buildRelativePath(from, to) {
|
|
|
80
75
|
: fixedRelativePath + '/').concat(convertToTypeScriptFileName(toFileName));
|
|
81
76
|
}
|
|
82
77
|
function parsePath(path) {
|
|
83
|
-
var pathNormalized =
|
|
84
|
-
var filename =
|
|
85
|
-
var directory = filename ?
|
|
78
|
+
var pathNormalized = normalize(path);
|
|
79
|
+
var filename = extname(pathNormalized) ? basename(pathNormalized) : '';
|
|
80
|
+
var directory = filename ? dirname(pathNormalized) : pathNormalized;
|
|
86
81
|
return {
|
|
87
82
|
path: pathNormalized,
|
|
88
83
|
filename: filename,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-component.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/find-component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-component.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/find-component.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,GACR,MAAM,sBAAsB,CAAC;AAW9B;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAU,EACV,OAAyB;IAEzB,IAAI,OAAO,CAAC,c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AC1D,IAAM,iBAAiB,GAAG,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC;QACpD,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,YAAK,YAAY,CAAE,CAAC;IAExB,OAAO,CAAC,UAAU,IAAI,UAAU,KAAK,UAAU;QAC7C,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,UACE,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC7B,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,iBAAiB,GAAG,GAAG,SAC1B,2BAA2B,CAAC,UAAU,CAAC,CAAE,CAAC;AACnD,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAM,cAAc,GAAG,SAAS,CAAC,IAAI,CAAS,CAAC;IAC/C,IAAM,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,IAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IACtE,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,UAAA;QACR,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AACD;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,QAA4B;IAC/D,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,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 */\nimport {\n Path,\n join,\n normalize,\n relative,\n strings,\n basename,\n extname,\n dirname,\n} from '@angular-devkit/core';\nimport { DirEntry, Tree } from '@angular-devkit/schematics';\n\nexport interface ComponentOptions {\n component?: string;\n name: string;\n flat?: boolean;\n path?: string;\n skipImport?: boolean;\n}\n\n/**\n * Find the component referred by a set of options passed to the schematics.\n */\nexport function findComponentFromOptions(\n host: Tree,\n options: ComponentOptions\n): Path | undefined {\n if (options.hasOwnProperty('skipImport') && options.skipImport) {\n return undefined;\n }\n\n if (!options.component) {\n const pathToCheck =\n (options.path || '') +\n (options.flat ? '' : '/' + strings.dasherize(options.name));\n\n return normalize(findComponent(host, pathToCheck));\n } else {\n const componentPath = normalize(\n '/' + options.path + '/' + options.component\n );\n const componentBaseName = normalize(componentPath).split('/').pop();\n\n if (host.exists(componentPath)) {\n return normalize(componentPath);\n } else if (host.exists(componentPath + '.ts')) {\n return normalize(componentPath + '.ts');\n } else if (host.exists(componentPath + '.component.ts')) {\n return normalize(componentPath + '.component.ts');\n } else if (\n host.exists(componentPath + '/' + componentBaseName + '.component.ts')\n ) {\n return normalize(\n componentPath + '/' + componentBaseName + '.component.ts'\n );\n } else {\n throw new Error(\n `Specified component path ${componentPath} does not exist`\n );\n }\n }\n}\n\n/**\n * Function to find the \"closest\" component to a generated file's path.\n */\nexport function findComponent(host: Tree, generateDir: string): Path {\n let dir: DirEntry | null = host.getDir('/' + generateDir);\n\n const componentRe = /\\.component\\.ts$/;\n\n while (dir) {\n const matches = dir.subfiles.filter((p) => componentRe.test(p));\n\n if (matches.length == 1) {\n return join(dir.path, matches[0]);\n } else if (matches.length > 1) {\n throw new Error(\n 'More than one component matches. Use skip-import option to skip importing ' +\n 'the component store into the closest component.'\n );\n }\n\n dir = dir.parent;\n }\n\n throw new Error(\n 'Could not find an Component. Use the skip-import ' +\n 'option to skip importing in Component.'\n );\n}\n\n/**\n * Build a relative path from one file path to another file path.\n */\nexport function buildRelativePath(from: string, to: string): string {\n const {\n path: fromPath,\n filename: fromFileName,\n directory: fromDirectory,\n } = parsePath(from);\n const {\n path: toPath,\n filename: toFileName,\n directory: toDirectory,\n } = parsePath(to);\n const relativePath = relative(fromDirectory, toDirectory);\n const fixedRelativePath = relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n\n return !toFileName || toFileName === 'index.ts'\n ? fixedRelativePath\n : `${\n fixedRelativePath.endsWith('/')\n ? fixedRelativePath\n : fixedRelativePath + '/'\n }${convertToTypeScriptFileName(toFileName)}`;\n}\n\nfunction parsePath(path: string) {\n const pathNormalized = normalize(path) as Path;\n const filename = extname(pathNormalized) ? basename(pathNormalized) : '';\n const directory = filename ? dirname(pathNormalized) : pathNormalized;\n return {\n path: pathNormalized,\n filename,\n directory,\n };\n}\n/**\n * Strips the typescript extension and clears index filenames\n * foo.ts -> foo\n * index.ts -> empty\n */\nfunction convertToTypeScriptFileName(filename: string | undefined) {\n return filename ? filename.replace(/(\\.ts)|(index\\.ts)$/, '') : '';\n}\n"]}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findModuleFromOptions = findModuleFromOptions;
|
|
4
|
-
exports.findModule = findModule;
|
|
5
|
-
exports.buildRelativePath = buildRelativePath;
|
|
6
1
|
/**
|
|
7
2
|
* @license
|
|
8
3
|
* Copyright Google Inc. All Rights Reserved.
|
|
@@ -10,39 +5,39 @@ exports.buildRelativePath = buildRelativePath;
|
|
|
10
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
11
6
|
* found in the LICENSE file at https://angular.io/license
|
|
12
7
|
*/
|
|
13
|
-
|
|
8
|
+
import { join, normalize, relative, strings, basename, extname, dirname, } from '@angular-devkit/core';
|
|
14
9
|
/**
|
|
15
10
|
* Find the module referred by a set of options passed to the schematics.
|
|
16
11
|
*/
|
|
17
|
-
function findModuleFromOptions(host, options) {
|
|
12
|
+
export function findModuleFromOptions(host, options) {
|
|
18
13
|
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
19
14
|
return undefined;
|
|
20
15
|
}
|
|
21
16
|
if (!options.module) {
|
|
22
17
|
var pathToCheck = (options.path || '') +
|
|
23
|
-
(options.flat ? '' : '/' +
|
|
24
|
-
return
|
|
18
|
+
(options.flat ? '' : '/' + strings.dasherize(options.name));
|
|
19
|
+
return normalize(findModule(host, pathToCheck));
|
|
25
20
|
}
|
|
26
21
|
else {
|
|
27
|
-
var modulePath =
|
|
28
|
-
var moduleBaseName =
|
|
22
|
+
var modulePath = normalize('/' + options.path + '/' + options.module);
|
|
23
|
+
var moduleBaseName = normalize(modulePath).split('/').pop();
|
|
29
24
|
if (host.exists(modulePath)) {
|
|
30
|
-
return
|
|
25
|
+
return normalize(modulePath);
|
|
31
26
|
}
|
|
32
27
|
else if (host.exists(modulePath + '.ts')) {
|
|
33
|
-
return
|
|
28
|
+
return normalize(modulePath + '.ts');
|
|
34
29
|
}
|
|
35
30
|
else if (host.exists(modulePath + '.module.ts')) {
|
|
36
|
-
return
|
|
31
|
+
return normalize(modulePath + '.module.ts');
|
|
37
32
|
}
|
|
38
33
|
else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
|
|
39
|
-
return
|
|
34
|
+
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
|
|
40
35
|
}
|
|
41
36
|
else if (host.exists(modulePath + '-module.ts')) {
|
|
42
|
-
return
|
|
37
|
+
return normalize(modulePath + '-module.ts');
|
|
43
38
|
}
|
|
44
39
|
else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {
|
|
45
|
-
return
|
|
40
|
+
return normalize(modulePath + '/' + moduleBaseName + '-module.ts');
|
|
46
41
|
}
|
|
47
42
|
else {
|
|
48
43
|
throw new Error("Specified module path ".concat(modulePath, " does not exist"));
|
|
@@ -52,14 +47,14 @@ function findModuleFromOptions(host, options) {
|
|
|
52
47
|
/**
|
|
53
48
|
* Function to find the "closest" module to a generated file's path.
|
|
54
49
|
*/
|
|
55
|
-
function findModule(host, generateDir) {
|
|
50
|
+
export function findModule(host, generateDir) {
|
|
56
51
|
var dir = host.getDir('/' + generateDir);
|
|
57
52
|
var moduleRe = /(\.|-)module\.ts$/;
|
|
58
53
|
var routingModuleRe = /-routing(\.|-)module\.ts/;
|
|
59
54
|
while (dir) {
|
|
60
55
|
var matches = dir.subfiles.filter(function (p) { return moduleRe.test(p) && !routingModuleRe.test(p); });
|
|
61
56
|
if (matches.length == 1) {
|
|
62
|
-
return
|
|
57
|
+
return join(dir.path, matches[0]);
|
|
63
58
|
}
|
|
64
59
|
else if (matches.length > 1) {
|
|
65
60
|
throw new Error('More than one module matches. Use skip-import option to skip importing ' +
|
|
@@ -73,10 +68,10 @@ function findModule(host, generateDir) {
|
|
|
73
68
|
/**
|
|
74
69
|
* Build a relative path from one file path to another file path.
|
|
75
70
|
*/
|
|
76
|
-
function buildRelativePath(from, to) {
|
|
71
|
+
export function buildRelativePath(from, to) {
|
|
77
72
|
var _a = parsePath(from), fromPath = _a.path, fromFileName = _a.filename, fromDirectory = _a.directory;
|
|
78
73
|
var _b = parsePath(to), toPath = _b.path, toFileName = _b.filename, toDirectory = _b.directory;
|
|
79
|
-
var relativePath =
|
|
74
|
+
var relativePath = relative(fromDirectory, toDirectory);
|
|
80
75
|
var fixedRelativePath = relativePath.startsWith('.')
|
|
81
76
|
? relativePath
|
|
82
77
|
: "./".concat(relativePath);
|
|
@@ -87,9 +82,9 @@ function buildRelativePath(from, to) {
|
|
|
87
82
|
: fixedRelativePath + '/').concat(convertToTypeScriptFileName(toFileName));
|
|
88
83
|
}
|
|
89
84
|
function parsePath(path) {
|
|
90
|
-
var pathNormalized =
|
|
91
|
-
var filename =
|
|
92
|
-
var directory = filename ?
|
|
85
|
+
var pathNormalized = normalize(path);
|
|
86
|
+
var filename = extname(pathNormalized) ? basename(pathNormalized) : '';
|
|
87
|
+
var directory = filename ? dirname(pathNormalized) : pathNormalized;
|
|
93
88
|
return {
|
|
94
89
|
path: pathNormalized,
|
|
95
90
|
filename: filename,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-module.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/find-module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-module.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/find-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAEL,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,GACR,MAAM,sBAAsB,CAAC;AAW9B;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,IAAU,EACV,OAAsB;IAEtB,IAAI,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC/D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,IAAM,WAAW,GACf,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;YACpB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9D,OAAO,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,IAAM,UAAU,GAAG,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACxE,IAAM,cAAc,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAE9D,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC;YAC3C,OAAO,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,CAA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OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,IAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IACtE,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,UAAA;QACR,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AACD;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,QAA4B;IAC/D,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,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 */\nimport {\n Path,\n join,\n normalize,\n relative,\n strings,\n basename,\n extname,\n dirname,\n} from '@angular-devkit/core';\nimport { DirEntry, Tree } from '@angular-devkit/schematics';\n\nexport interface ModuleOptions {\n module?: string;\n name: string;\n flat?: boolean;\n path?: string;\n skipImport?: boolean;\n}\n\n/**\n * Find the module referred by a set of options passed to the schematics.\n */\nexport function findModuleFromOptions(\n host: Tree,\n options: ModuleOptions\n): Path | undefined {\n if (options.hasOwnProperty('skipImport') && options.skipImport) {\n return undefined;\n }\n\n if (!options.module) {\n const pathToCheck =\n (options.path || '') +\n (options.flat ? '' : '/' + strings.dasherize(options.name));\n\n return normalize(findModule(host, pathToCheck));\n } else {\n const modulePath = normalize('/' + options.path + '/' + options.module);\n const moduleBaseName = normalize(modulePath).split('/').pop();\n\n if (host.exists(modulePath)) {\n return normalize(modulePath);\n } else if (host.exists(modulePath + '.ts')) {\n return normalize(modulePath + '.ts');\n } else if (host.exists(modulePath + '.module.ts')) {\n return normalize(modulePath + '.module.ts');\n } else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {\n return normalize(modulePath + '/' + moduleBaseName + '.module.ts');\n } else if (host.exists(modulePath + '-module.ts')) {\n return normalize(modulePath + '-module.ts');\n } else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {\n return normalize(modulePath + '/' + moduleBaseName + '-module.ts');\n } else {\n throw new Error(`Specified module path ${modulePath} does not exist`);\n }\n }\n}\n\n/**\n * Function to find the \"closest\" module to a generated file's path.\n */\nexport function findModule(host: Tree, generateDir: string): Path {\n let dir: DirEntry | null = host.getDir('/' + generateDir);\n\n const moduleRe = /(\\.|-)module\\.ts$/;\n const routingModuleRe = /-routing(\\.|-)module\\.ts/;\n\n while (dir) {\n const matches = dir.subfiles.filter(\n (p) => moduleRe.test(p) && !routingModuleRe.test(p)\n );\n\n if (matches.length == 1) {\n return join(dir.path, matches[0]);\n } else if (matches.length > 1) {\n throw new Error(\n 'More than one module matches. Use skip-import option to skip importing ' +\n 'the component into the closest module.'\n );\n }\n\n dir = dir.parent;\n }\n\n throw new Error(\n 'Could not find an NgModule. Use the skip-import ' +\n 'option to skip importing in NgModule.'\n );\n}\n\n/**\n * Build a relative path from one file path to another file path.\n */\nexport function buildRelativePath(from: string, to: string): string {\n const {\n path: fromPath,\n filename: fromFileName,\n directory: fromDirectory,\n } = parsePath(from);\n const {\n path: toPath,\n filename: toFileName,\n directory: toDirectory,\n } = parsePath(to);\n const relativePath = relative(fromDirectory, toDirectory);\n const fixedRelativePath = relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n\n return !toFileName || toFileName === 'index.ts'\n ? fixedRelativePath\n : `${\n fixedRelativePath.endsWith('/')\n ? fixedRelativePath\n : fixedRelativePath + '/'\n }${convertToTypeScriptFileName(toFileName)}`;\n}\n\nfunction parsePath(path: string) {\n const pathNormalized = normalize(path) as Path;\n const filename = extname(pathNormalized) ? basename(pathNormalized) : '';\n const directory = filename ? dirname(pathNormalized) : pathNormalized;\n return {\n path: pathNormalized,\n filename,\n directory,\n };\n}\n/**\n * Strips the typescript extension and clears index filenames\n * foo.ts -> foo\n * index.ts -> empty\n */\nfunction convertToTypeScriptFileName(filename: string | undefined) {\n return filename ? filename.replace(/(\\.ts)|(index\\.ts)$/, '') : '';\n}\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);
|
|
@@ -10,10 +9,8 @@ var __values = (this && this.__values) || function(o) {
|
|
|
10
9
|
};
|
|
11
10
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
11
|
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.findPropertyInAstObject = findPropertyInAstObject;
|
|
15
12
|
// https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/json-utils.ts
|
|
16
|
-
function findPropertyInAstObject(node, propertyName) {
|
|
13
|
+
export function findPropertyInAstObject(node, propertyName) {
|
|
17
14
|
var e_1, _a;
|
|
18
15
|
var maybeNode = null;
|
|
19
16
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-utilts.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/json-utilts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-utilts.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/json-utilts.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uGAAuG;AACvG,MAAM,UAAU,uBAAuB,CACrC,IAAS,EACT,YAAoB;;IAEpB,IAAI,SAAS,GAAe,IAAI,CAAC;;QACjC,KAAuB,IAAA,KAAA,SAAA,IAAI,CAAC,UAAU,CAAA,gBAAA,4BAAE,CAAC;YAApC,IAAM,QAAQ,WAAA;YACjB,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,IAAI,YAAY,EAAE,CAAC;gBACvC,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC;YAC7B,CAAC;QACH,CAAC;;;;;;;;;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/utility/json-utils.ts\nexport function findPropertyInAstObject(\n node: any,\n propertyName: string\n): any | null {\n let maybeNode: any | null = null;\n for (const property of node.properties) {\n if (property.key.value == propertyName) {\n maybeNode = property.value;\n }\n }\n\n return maybeNode;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libs-version.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/libs-version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libs-version.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/libs-version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,eAAe,GAAG,gBAAgB,CAAC","sourcesContent":["export const platformVersion = '^21.0.0-beta.0';\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,33 +34,26 @@ 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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var stringUtils = require("./strings");
|
|
47
|
-
var change_1 = require("./change");
|
|
48
|
-
var schematics_1 = require("@angular-devkit/schematics");
|
|
49
|
-
var core_1 = require("@angular-devkit/core");
|
|
50
|
-
var find_module_1 = require("./find-module");
|
|
51
|
-
var ast_utils_1 = require("./ast-utils");
|
|
52
|
-
function addReducerToState(options) {
|
|
37
|
+
import * as ts from 'typescript';
|
|
38
|
+
import * as stringUtils from './strings';
|
|
39
|
+
import { InsertChange, NoopChange } from './change';
|
|
40
|
+
import { SchematicsException } from '@angular-devkit/schematics';
|
|
41
|
+
import { normalize } from '@angular-devkit/core';
|
|
42
|
+
import { buildRelativePath } from './find-module';
|
|
43
|
+
import { addImportToModule, insertImport } from './ast-utils';
|
|
44
|
+
export function addReducerToState(options) {
|
|
53
45
|
return function (host) {
|
|
54
46
|
var e_1, _a;
|
|
55
47
|
if (!options.reducers) {
|
|
56
48
|
return host;
|
|
57
49
|
}
|
|
58
|
-
var reducersPath =
|
|
50
|
+
var reducersPath = normalize("/".concat(options.path, "/").concat(options.reducers));
|
|
59
51
|
if (!host.exists(reducersPath)) {
|
|
60
52
|
throw new Error("Specified reducers path ".concat(reducersPath, " does not exist"));
|
|
61
53
|
}
|
|
62
54
|
var text = host.read(reducersPath);
|
|
63
55
|
if (text === null) {
|
|
64
|
-
throw new
|
|
56
|
+
throw new SchematicsException("File ".concat(reducersPath, " does not exist."));
|
|
65
57
|
}
|
|
66
58
|
var sourceText = text.toString('utf-8');
|
|
67
59
|
var source = ts.createSourceFile(reducersPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
@@ -70,8 +62,8 @@ function addReducerToState(options) {
|
|
|
70
62
|
(options.group ? 'reducers/' : '') +
|
|
71
63
|
stringUtils.dasherize(options.name) +
|
|
72
64
|
'.reducer';
|
|
73
|
-
var relativePath =
|
|
74
|
-
var reducerImport =
|
|
65
|
+
var relativePath = buildRelativePath(reducersPath, reducerPath);
|
|
66
|
+
var reducerImport = insertImport(source, reducersPath, "* as from".concat(stringUtils.classify(options.name)), relativePath, true);
|
|
75
67
|
var stateInterfaceInsert = addReducerToStateInterface(source, reducersPath, options);
|
|
76
68
|
var reducerMapInsert = addReducerToActionReducerMap(source, reducersPath, options);
|
|
77
69
|
var changes = [reducerImport, stateInterfaceInsert, reducerMapInsert];
|
|
@@ -79,7 +71,7 @@ function addReducerToState(options) {
|
|
|
79
71
|
try {
|
|
80
72
|
for (var changes_1 = __values(changes), changes_1_1 = changes_1.next(); !changes_1_1.done; changes_1_1 = changes_1.next()) {
|
|
81
73
|
var change = changes_1_1.value;
|
|
82
|
-
if (change instanceof
|
|
74
|
+
if (change instanceof InsertChange) {
|
|
83
75
|
recorder.insertLeft(change.pos, change.toAdd);
|
|
84
76
|
}
|
|
85
77
|
}
|
|
@@ -98,11 +90,11 @@ function addReducerToState(options) {
|
|
|
98
90
|
/**
|
|
99
91
|
* Insert the reducer into the first defined top level interface
|
|
100
92
|
*/
|
|
101
|
-
function addReducerToStateInterface(source, reducersPath, options) {
|
|
93
|
+
export function addReducerToStateInterface(source, reducersPath, options) {
|
|
102
94
|
var stateInterface = source.statements.find(function (stm) { return stm.kind === ts.SyntaxKind.InterfaceDeclaration; });
|
|
103
95
|
var node = stateInterface;
|
|
104
96
|
if (!node) {
|
|
105
|
-
return new
|
|
97
|
+
return new NoopChange();
|
|
106
98
|
}
|
|
107
99
|
var state = options.plural
|
|
108
100
|
? stringUtils.pluralize(options.name)
|
|
@@ -128,12 +120,12 @@ function addReducerToStateInterface(source, reducersPath, options) {
|
|
|
128
120
|
toInsert = "\n".concat(keyInsert);
|
|
129
121
|
}
|
|
130
122
|
}
|
|
131
|
-
return new
|
|
123
|
+
return new InsertChange(reducersPath, position, toInsert);
|
|
132
124
|
}
|
|
133
125
|
/**
|
|
134
126
|
* Insert the reducer into the ActionReducerMap
|
|
135
127
|
*/
|
|
136
|
-
function addReducerToActionReducerMap(source, reducersPath, options) {
|
|
128
|
+
export function addReducerToActionReducerMap(source, reducersPath, options) {
|
|
137
129
|
var initializer;
|
|
138
130
|
var actionReducerMap = source.statements
|
|
139
131
|
.filter(function (stm) { return stm.kind === ts.SyntaxKind.VariableStatement; })
|
|
@@ -150,7 +142,7 @@ function addReducerToActionReducerMap(source, reducersPath, options) {
|
|
|
150
142
|
return type.typeName.text === 'ActionReducerMap';
|
|
151
143
|
});
|
|
152
144
|
if (!actionReducerMap || !actionReducerMap.initializer) {
|
|
153
|
-
return new
|
|
145
|
+
return new NoopChange();
|
|
154
146
|
}
|
|
155
147
|
var node = actionReducerMap.initializer;
|
|
156
148
|
var state = options.plural
|
|
@@ -177,12 +169,12 @@ function addReducerToActionReducerMap(source, reducersPath, options) {
|
|
|
177
169
|
toInsert = "\n".concat(keyInsert);
|
|
178
170
|
}
|
|
179
171
|
}
|
|
180
|
-
return new
|
|
172
|
+
return new InsertChange(reducersPath, position, toInsert);
|
|
181
173
|
}
|
|
182
174
|
/**
|
|
183
175
|
* Add reducer feature to NgModule
|
|
184
176
|
*/
|
|
185
|
-
function addReducerImportToNgModule(options) {
|
|
177
|
+
export function addReducerImportToNgModule(options) {
|
|
186
178
|
return function (host) {
|
|
187
179
|
var e_2, _a;
|
|
188
180
|
if (!options.module) {
|
|
@@ -194,30 +186,30 @@ function addReducerImportToNgModule(options) {
|
|
|
194
186
|
}
|
|
195
187
|
var text = host.read(modulePath);
|
|
196
188
|
if (text === null) {
|
|
197
|
-
throw new
|
|
189
|
+
throw new SchematicsException("File ".concat(modulePath, " does not exist."));
|
|
198
190
|
}
|
|
199
191
|
var sourceText = text.toString('utf-8');
|
|
200
192
|
var source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
201
193
|
var commonImports = [
|
|
202
|
-
|
|
194
|
+
insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),
|
|
203
195
|
];
|
|
204
196
|
var reducerPath = "/".concat(options.path, "/") +
|
|
205
197
|
(options.flat ? '' : stringUtils.dasherize(options.name) + '/') +
|
|
206
198
|
(options.group ? 'reducers/' : '') +
|
|
207
199
|
stringUtils.dasherize(options.name) +
|
|
208
200
|
'.reducer';
|
|
209
|
-
var relativePath =
|
|
210
|
-
var reducerImport =
|
|
201
|
+
var relativePath = buildRelativePath(modulePath, reducerPath);
|
|
202
|
+
var reducerImport = insertImport(source, modulePath, "* as from".concat(stringUtils.classify(options.name)), relativePath, true);
|
|
211
203
|
var state = options.plural
|
|
212
204
|
? stringUtils.pluralize(options.name)
|
|
213
205
|
: stringUtils.camelize(options.name);
|
|
214
|
-
var _b = __read(
|
|
206
|
+
var _b = __read(addImportToModule(source, modulePath, "StoreModule.forFeature(from".concat(stringUtils.classify(options.name), ".").concat(state, "FeatureKey, from").concat(stringUtils.classify(options.name), ".reducer)"), relativePath), 1), storeNgModuleImport = _b[0];
|
|
215
207
|
var changes = __spreadArray(__spreadArray([], __read(commonImports), false), [reducerImport, storeNgModuleImport], false);
|
|
216
208
|
var recorder = host.beginUpdate(modulePath);
|
|
217
209
|
try {
|
|
218
210
|
for (var changes_2 = __values(changes), changes_2_1 = changes_2.next(); !changes_2_1.done; changes_2_1 = changes_2.next()) {
|
|
219
211
|
var change = changes_2_1.value;
|
|
220
|
-
if (change instanceof
|
|
212
|
+
if (change instanceof InsertChange) {
|
|
221
213
|
recorder.insertLeft(change.pos, change.toAdd);
|
|
222
214
|
}
|
|
223
215
|
}
|
|
@@ -233,7 +225,7 @@ function addReducerImportToNgModule(options) {
|
|
|
233
225
|
return host;
|
|
234
226
|
};
|
|
235
227
|
}
|
|
236
|
-
function omit(object, keyToRemove) {
|
|
228
|
+
export function omit(object, keyToRemove) {
|
|
237
229
|
return Object.keys(object)
|
|
238
230
|
.filter(function (key) { return key !== keyToRemove; })
|
|
239
231
|
.reduce(function (result, key) {
|
|
@@ -241,7 +233,7 @@ function omit(object, keyToRemove) {
|
|
|
241
233
|
return Object.assign(result, (_a = {}, _a[key] = object[key], _a));
|
|
242
234
|
}, {});
|
|
243
235
|
}
|
|
244
|
-
function getPrefix(options) {
|
|
236
|
+
export function getPrefix(options) {
|
|
245
237
|
return stringUtils.camelize(options.prefix || 'load');
|
|
246
238
|
}
|
|
247
239
|
//# sourceMappingURL=ngrx-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngrx-utils.js","sourceR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,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;;;;;;;;;QACD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,IAAI,CAClB,MAAS,EACT,WAAoB;IAEpB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACvB,MAAM,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,KAAK,WAAW,EAAnB,CAAmB,CAAC;SACpC,MAAM,CAAC,UAAC,MAAM,EAAE,GAAG;;QAAK,OAAA,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG;IAA7C,CAA6C,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,SAAgB,SAAS,CAAC,OAA4B;IACpD,OAAO,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport * as stringUtils from './strings';\nimport { InsertChange, Change, NoopChange } from './change';\nimport { Tree, SchematicsException, Rule } from '@angular-devkit/schematics';\nimport { normalize } from '@angular-devkit/core';\nimport { buildRelativePath } from './find-module';\nimport { addImportToModule, insertImport } from './ast-utils';\n\nexport function addReducerToState(options: any): Rule {\n return (host: Tree) => {\n if (!options.reducers) {\n return host;\n }\n\n const reducersPath = normalize(`/${options.path}/${options.reducers}`);\n\n if (!host.exists(reducersPath)) {\n throw new Error(`Specified reducers path ${reducersPath} does not exist`);\n }\n\n const text = host.read(reducersPath);\n if (text === null) {\n throw new SchematicsException(`File ${reducersPath} does not exist.`);\n }\n\n const sourceText = text.toString('utf-8');\n\n const source = ts.createSourceFile(\n reducersPath,\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n\n const reducerPath =\n `/${options.path}/` +\n (options.flat ? '' : stringUtils.dasherize(options.name) + '/') +\n (options.group ? 'reducers/' : '') +\n stringUtils.dasherize(options.name) +\n '.reducer';\n\n const relativePath = buildRelativePath(reducersPath, reducerPath);\n const reducerImport = insertImport(\n source,\n reducersPath,\n `* as from${stringUtils.classify(options.name)}`,\n relativePath,\n true\n );\n\n const stateInterfaceInsert = addReducerToStateInterface(\n source,\n reducersPath,\n options\n );\n const reducerMapInsert = addReducerToActionReducerMap(\n source,\n reducersPath,\n options\n );\n\n const changes = [reducerImport, stateInterfaceInsert, reducerMapInsert];\n const recorder = host.beginUpdate(reducersPath);\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\n/**\n * Insert the reducer into the first defined top level interface\n */\nexport function addReducerToStateInterface(\n source: ts.SourceFile,\n reducersPath: string,\n options: { name: string; plural: boolean }\n): Change {\n const stateInterface = source.statements.find(\n (stm) => stm.kind === ts.SyntaxKind.InterfaceDeclaration\n );\n let node = stateInterface as ts.Statement;\n\n if (!node) {\n return new NoopChange();\n }\n\n const state = options.plural\n ? stringUtils.pluralize(options.name)\n : stringUtils.camelize(options.name);\n\n const keyInsert = `[from${stringUtils.classify(\n options.name\n )}.${stringUtils.camelize(state)}FeatureKey]: from${stringUtils.classify(\n options.name\n )}.State;`;\n const expr = node as any;\n let position;\n let toInsert;\n\n if (expr.members.length === 0) {\n position = expr.getEnd() - 1;\n toInsert = ` ${keyInsert}\\n`;\n } else {\n node = expr.members[expr.members.length - 1];\n position = node.getEnd() + 1;\n // Get the indentation of the last element, if any.\n const text = node.getFullText(source);\n const matches = text.match(/^\\r?\\n+(\\s*)/);\n\n if (matches && matches.length > 0) {\n toInsert = `${matches[1]}${keyInsert}\\n`;\n } else {\n toInsert = `\\n${keyInsert}`;\n }\n }\n\n return new InsertChange(reducersPath, position, toInsert);\n}\n\n/**\n * Insert the reducer into the ActionReducerMap\n */\nexport function addReducerToActionReducerMap(\n source: ts.SourceFile,\n reducersPath: string,\n options: { name: string; plural: boolean }\n): Change {\n let initializer: any;\n const actionReducerMap: any = source.statements\n .filter((stm) => stm.kind === ts.SyntaxKind.VariableStatement)\n .filter((stm: any) => !!stm.declarationList)\n .map((stm: any) => {\n const {\n declarations,\n }: {\n declarations: ts.SyntaxKind.VariableDeclarationList[];\n } = stm.declarationList;\n const variable: any = declarations.find(\n (decl: any) => decl.kind === ts.SyntaxKind.VariableDeclaration\n );\n const type = variable ? variable.type : {};\n\n return { initializer: variable.initializer, type };\n })\n .filter((initWithType) => initWithType.type !== undefined)\n .find(({ type }) => type.typeName.text === 'ActionReducerMap');\n\n if (!actionReducerMap || !actionReducerMap.initializer) {\n return new NoopChange();\n }\n\n let node = actionReducerMap.initializer;\n\n const state = options.plural\n ? stringUtils.pluralize(options.name)\n : stringUtils.camelize(options.name);\n\n const keyInsert = `[from${stringUtils.classify(\n options.name\n )}.${stringUtils.camelize(state)}FeatureKey]: from${stringUtils.classify(\n options.name\n )}.reducer,`;\n const expr = node as any;\n let position;\n let toInsert;\n\n if (expr.properties.length === 0) {\n position = expr.getEnd() - 1;\n toInsert = ` ${keyInsert}\\n`;\n } else {\n node = expr.properties[expr.properties.length - 1];\n position = node.getEnd() + 1;\n // Get the indentation of the last element, if any.\n const text = node.getFullText(source);\n const matches = text.match(/^\\r?\\n+(\\s*)/);\n\n if (matches && matches.length > 0) {\n toInsert = `\\n${matches[1]}${keyInsert}`;\n } else {\n toInsert = `\\n${keyInsert}`;\n }\n }\n\n return new InsertChange(reducersPath, position, toInsert);\n}\n\n/**\n * Add reducer feature to NgModule\n */\nexport function addReducerImportToNgModule(options: any): Rule {\n return (host: Tree) => {\n if (!options.module) {\n return host;\n }\n\n const modulePath = options.module;\n if (!host.exists(options.module)) {\n throw new Error(`Specified module path ${modulePath} 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 commonImports = [\n insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),\n ];\n\n const reducerPath =\n `/${options.path}/` +\n (options.flat ? '' : stringUtils.dasherize(options.name) + '/') +\n (options.group ? 'reducers/' : '') +\n stringUtils.dasherize(options.name) +\n '.reducer';\n const relativePath = buildRelativePath(modulePath, reducerPath);\n const reducerImport = insertImport(\n source,\n modulePath,\n `* as from${stringUtils.classify(options.name)}`,\n relativePath,\n true\n );\n const state = options.plural\n ? stringUtils.pluralize(options.name)\n : stringUtils.camelize(options.name);\n const [storeNgModuleImport] = addImportToModule(\n source,\n modulePath,\n `StoreModule.forFeature(from${stringUtils.classify(\n options.name\n )}.${state}FeatureKey, from${stringUtils.classify(\n options.name\n )}.reducer)`,\n relativePath\n );\n const changes = [...commonImports, reducerImport, storeNgModuleImport];\n const recorder = host.beginUpdate(modulePath);\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\nexport function omit<T extends { [key: string]: any }>(\n object: T,\n keyToRemove: keyof T\n): Partial<T> {\n return Object.keys(object)\n .filter((key) => key !== keyToRemove)\n .reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});\n}\n\nexport function getPrefix(options: { prefix?: string }) {\n return stringUtils.camelize(options.prefix || 'load');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ngrx-utils.js","sourceRoot":"","sources":["../../../../../modules/store-devtools/schematics-core/utility/ngrx-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,WAAW,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAU,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAQ,mBAA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B,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,IAAI,CAClB,MAAS,EACT,WAAoB;IAEpB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SACvB,MAAM,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,KAAK,WAAW,EAAnB,CAAmB,CAAC;SACpC,MAAM,CAAC,UAAC,MAAM,EAAE,GAAG;;QAAK,OAAA,MAAM,CAAC,MAAM,CAAC,MAAM,YAAI,GAAC,GAAG,IAAG,MAAM,CAAC,GAAG,CAAC,MAAG;IAA7C,CAA6C,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAA4B;IACpD,OAAO,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import * as ts from 'typescript';\nimport * as stringUtils from './strings';\nimport { InsertChange, Change, NoopChange } from './change';\nimport { Tree, SchematicsException, Rule } from '@angular-devkit/schematics';\nimport { normalize } from '@angular-devkit/core';\nimport { buildRelativePath } from './find-module';\nimport { addImportToModule, insertImport } from './ast-utils';\n\nexport function addReducerToState(options: any): Rule {\n return (host: Tree) => {\n if (!options.reducers) {\n return host;\n }\n\n const reducersPath = normalize(`/${options.path}/${options.reducers}`);\n\n if (!host.exists(reducersPath)) {\n throw new Error(`Specified reducers path ${reducersPath} does not exist`);\n }\n\n const text = host.read(reducersPath);\n if (text === null) {\n throw new SchematicsException(`File ${reducersPath} does not exist.`);\n }\n\n const sourceText = text.toString('utf-8');\n\n const source = ts.createSourceFile(\n reducersPath,\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n\n const reducerPath =\n `/${options.path}/` +\n (options.flat ? '' : stringUtils.dasherize(options.name) + '/') +\n (options.group ? 'reducers/' : '') +\n stringUtils.dasherize(options.name) +\n '.reducer';\n\n const relativePath = buildRelativePath(reducersPath, reducerPath);\n const reducerImport = insertImport(\n source,\n reducersPath,\n `* as from${stringUtils.classify(options.name)}`,\n relativePath,\n true\n );\n\n const stateInterfaceInsert = addReducerToStateInterface(\n source,\n reducersPath,\n options\n );\n const reducerMapInsert = addReducerToActionReducerMap(\n source,\n reducersPath,\n options\n );\n\n const changes = [reducerImport, stateInterfaceInsert, reducerMapInsert];\n const recorder = host.beginUpdate(reducersPath);\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\n/**\n * Insert the reducer into the first defined top level interface\n */\nexport function addReducerToStateInterface(\n source: ts.SourceFile,\n reducersPath: string,\n options: { name: string; plural: boolean }\n): Change {\n const stateInterface = source.statements.find(\n (stm) => stm.kind === ts.SyntaxKind.InterfaceDeclaration\n );\n let node = stateInterface as ts.Statement;\n\n if (!node) {\n return new NoopChange();\n }\n\n const state = options.plural\n ? stringUtils.pluralize(options.name)\n : stringUtils.camelize(options.name);\n\n const keyInsert = `[from${stringUtils.classify(\n options.name\n )}.${stringUtils.camelize(state)}FeatureKey]: from${stringUtils.classify(\n options.name\n )}.State;`;\n const expr = node as any;\n let position;\n let toInsert;\n\n if (expr.members.length === 0) {\n position = expr.getEnd() - 1;\n toInsert = ` ${keyInsert}\\n`;\n } else {\n node = expr.members[expr.members.length - 1];\n position = node.getEnd() + 1;\n // Get the indentation of the last element, if any.\n const text = node.getFullText(source);\n const matches = text.match(/^\\r?\\n+(\\s*)/);\n\n if (matches && matches.length > 0) {\n toInsert = `${matches[1]}${keyInsert}\\n`;\n } else {\n toInsert = `\\n${keyInsert}`;\n }\n }\n\n return new InsertChange(reducersPath, position, toInsert);\n}\n\n/**\n * Insert the reducer into the ActionReducerMap\n */\nexport function addReducerToActionReducerMap(\n source: ts.SourceFile,\n reducersPath: string,\n options: { name: string; plural: boolean }\n): Change {\n let initializer: any;\n const actionReducerMap: any = source.statements\n .filter((stm) => stm.kind === ts.SyntaxKind.VariableStatement)\n .filter((stm: any) => !!stm.declarationList)\n .map((stm: any) => {\n const {\n declarations,\n }: {\n declarations: ts.SyntaxKind.VariableDeclarationList[];\n } = stm.declarationList;\n const variable: any = declarations.find(\n (decl: any) => decl.kind === ts.SyntaxKind.VariableDeclaration\n );\n const type = variable ? variable.type : {};\n\n return { initializer: variable.initializer, type };\n })\n .filter((initWithType) => initWithType.type !== undefined)\n .find(({ type }) => type.typeName.text === 'ActionReducerMap');\n\n if (!actionReducerMap || !actionReducerMap.initializer) {\n return new NoopChange();\n }\n\n let node = actionReducerMap.initializer;\n\n const state = options.plural\n ? stringUtils.pluralize(options.name)\n : stringUtils.camelize(options.name);\n\n const keyInsert = `[from${stringUtils.classify(\n options.name\n )}.${stringUtils.camelize(state)}FeatureKey]: from${stringUtils.classify(\n options.name\n )}.reducer,`;\n const expr = node as any;\n let position;\n let toInsert;\n\n if (expr.properties.length === 0) {\n position = expr.getEnd() - 1;\n toInsert = ` ${keyInsert}\\n`;\n } else {\n node = expr.properties[expr.properties.length - 1];\n position = node.getEnd() + 1;\n // Get the indentation of the last element, if any.\n const text = node.getFullText(source);\n const matches = text.match(/^\\r?\\n+(\\s*)/);\n\n if (matches && matches.length > 0) {\n toInsert = `\\n${matches[1]}${keyInsert}`;\n } else {\n toInsert = `\\n${keyInsert}`;\n }\n }\n\n return new InsertChange(reducersPath, position, toInsert);\n}\n\n/**\n * Add reducer feature to NgModule\n */\nexport function addReducerImportToNgModule(options: any): Rule {\n return (host: Tree) => {\n if (!options.module) {\n return host;\n }\n\n const modulePath = options.module;\n if (!host.exists(options.module)) {\n throw new Error(`Specified module path ${modulePath} 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 commonImports = [\n insertImport(source, modulePath, 'StoreModule', '@ngrx/store'),\n ];\n\n const reducerPath =\n `/${options.path}/` +\n (options.flat ? '' : stringUtils.dasherize(options.name) + '/') +\n (options.group ? 'reducers/' : '') +\n stringUtils.dasherize(options.name) +\n '.reducer';\n const relativePath = buildRelativePath(modulePath, reducerPath);\n const reducerImport = insertImport(\n source,\n modulePath,\n `* as from${stringUtils.classify(options.name)}`,\n relativePath,\n true\n );\n const state = options.plural\n ? stringUtils.pluralize(options.name)\n : stringUtils.camelize(options.name);\n const [storeNgModuleImport] = addImportToModule(\n source,\n modulePath,\n `StoreModule.forFeature(from${stringUtils.classify(\n options.name\n )}.${state}FeatureKey, from${stringUtils.classify(\n options.name\n )}.reducer)`,\n relativePath\n );\n const changes = [...commonImports, reducerImport, storeNgModuleImport];\n const recorder = host.beginUpdate(modulePath);\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\nexport function omit<T extends { [key: string]: any }>(\n object: T,\n keyToRemove: keyof T\n): Partial<T> {\n return Object.keys(object)\n .filter((key) => key !== keyToRemove)\n .reduce((result, key) => Object.assign(result, { [key]: object[key] }), {});\n}\n\nexport function getPrefix(options: { prefix?: string }) {\n return stringUtils.camelize(options.prefix || 'load');\n}\n"]}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addPackageToPackageJson = addPackageToPackageJson;
|
|
4
1
|
/**
|
|
5
2
|
* Adds a package to the package.json
|
|
6
3
|
*/
|
|
7
|
-
function addPackageToPackageJson(host, type, pkg, version) {
|
|
4
|
+
export function addPackageToPackageJson(host, type, pkg, version) {
|
|
8
5
|
var _a, _b;
|
|
9
6
|
if (host.exists('package.json')) {
|
|
10
7
|
var sourceText = (_b = (_a = host.read('package.json')) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) !== null && _b !== void 0 ? _b : '{}';
|