@magic-xpa/cli 4.1201.0 → 4.1201.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/README.md +28 -28
- package/index.js.map +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/collection.json +75 -75
- package/src/public_api.js.map +1 -1
- package/src/public_api.ts +5 -5
- package/src/schematics/magic-utils/config.js.map +1 -1
- package/src/schematics/magic-utils/config.ts +68 -68
- package/src/schematics/magic-utils/env.js.map +1 -1
- package/src/schematics/magic-utils/env.ts +50 -50
- package/src/schematics/magic-utils/manifest.js.map +1 -1
- package/src/schematics/magic-utils/manifest.ts +46 -46
- package/src/schematics/magic-utils/metadata.class.js.map +1 -1
- package/src/schematics/magic-utils/metadata.class.ts +159 -159
- package/src/schematics/magic-utils/rules/generate.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/generate.rule.ts +61 -61
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-add-modules.rule.ts +360 -360
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.ts +19 -19
- package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
- package/src/schematics/magic-utils/rules/magic-option.scheme.ts +24 -24
- package/src/schematics/magic-utils/utils.js.map +1 -1
- package/src/schematics/magic-utils/utils.ts +134 -134
- package/src/schematics/mg-Install-prerequisites/index.js.map +1 -1
- package/src/schematics/mg-Install-prerequisites/index.ts +30 -30
- package/src/schematics/mg-Install-prerequisites/schema.json +14 -14
- package/src/schematics/mg-add/files/src/app/app.component.html +17 -17
- package/src/schematics/mg-add/files/src/app/app.routes.ts +14 -14
- package/src/schematics/mg-add/files/src/app/magic/component-list.g.ts +9 -9
- package/src/schematics/mg-add/files/src/magic-styles.css +131 -131
- package/src/schematics/mg-add/schema.json +29 -29
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.js.map +1 -1
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.ts +12 -12
- package/src/schematics/mg-add/webModule/app.routes.ts +14 -14
- package/src/schematics/mg-add-tasks/index.js.map +1 -1
- package/src/schematics/mg-add-tasks/index.ts +53 -53
- package/src/schematics/mg-add-tasks/schema.json +41 -41
- package/src/schematics/mg-delete-files/index.js.map +1 -1
- package/src/schematics/mg-delete-files/index.ts +12 -12
- package/src/schematics/mg-delete-files/schema.json +14 -14
- package/src/schematics/mg-gen-module/index.js.map +1 -1
- package/src/schematics/mg-gen-module/index.ts +14 -14
- package/src/schematics/mg-gen-module/schema.json +24 -24
- package/src/schematics/mg-generate/index.js.map +1 -1
- package/src/schematics/mg-generate/index.ts +12 -12
- package/src/schematics/mg-generate/schema.json +34 -34
- package/src/schematics/mg-install/index.js.map +1 -1
- package/src/schematics/mg-install/index.ts +37 -37
- package/src/schematics/mg-install/schema.json +24 -24
- package/src/schematics/mg-routes/schema.json +14 -14
- package/src/schematics/mg-single-control/schema.json +24 -24
- package/src/schematics/utils/ast.js.map +1 -1
- package/src/schematics/utils/ast.ts +103 -103
- package/src/schematics/utils/devkit-utils/README.md +1 -1
- package/src/schematics/utils/devkit-utils/ast-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ast-utils.ts +570 -570
- package/src/schematics/utils/devkit-utils/ast-utils_old.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ast-utils_old.ts +478 -478
- package/src/schematics/utils/devkit-utils/change.js.map +1 -1
- package/src/schematics/utils/devkit-utils/change.ts +127 -127
- package/src/schematics/utils/devkit-utils/component.js.map +1 -1
- package/src/schematics/utils/devkit-utils/component.ts +136 -136
- package/src/schematics/utils/devkit-utils/config.js.map +1 -1
- package/src/schematics/utils/devkit-utils/config.ts +120 -120
- package/src/schematics/utils/devkit-utils/find-module.js.map +1 -1
- package/src/schematics/utils/devkit-utils/find-module.ts +108 -108
- package/src/schematics/utils/devkit-utils/ng-ast-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/ng-ast-utils.ts +84 -84
- package/src/schematics/utils/devkit-utils/parse-name.js.map +1 -1
- package/src/schematics/utils/devkit-utils/parse-name.ts +24 -24
- package/src/schematics/utils/devkit-utils/route-utils.js.map +1 -1
- package/src/schematics/utils/devkit-utils/route-utils.ts +180 -180
- package/src/schematics/utils/devkit-utils/validation.js +1 -1
- package/src/schematics/utils/devkit-utils/validation.js.map +1 -1
- package/src/schematics/utils/devkit-utils/validation.ts +16 -16
- package/src/schematics/utils/html.js.map +1 -1
- package/src/schematics/utils/html.ts +63 -63
- package/src/schematics/utils/lib-versions.js.map +1 -1
- package/src/schematics/utils/lib-versions.ts +3 -3
- package/src/schematics/utils/package.js.map +1 -1
- package/src/schematics/utils/package.ts +22 -22
- package/src/schematics/utils/testing.js.map +1 -1
- package/src/schematics/utils/testing.ts +25 -25
- package/src/types/enums/Enums.js.map +1 -1
- package/src/types/enums/Enums.ts +2063 -2063
- package/src/types/enums/generated-file-types.enum.js.map +1 -1
- package/src/types/enums/generated-file-types.enum.ts +6 -6
- package/src/types/enums/horizontal-alignments.enum.js.map +1 -1
- package/src/types/enums/horizontal-alignments.enum.ts +6 -6
- package/src/types/enums/themes.enum.js.map +1 -1
- package/src/types/enums/themes.enum.ts +6 -6
- package/src/types/index.js.map +1 -1
- package/src/types/index.ts +8 -8
- package/src/types/interfaces/app.js.map +1 -1
- package/src/types/interfaces/app.ts +89 -89
- package/src/types/interfaces/control.js.map +1 -1
- package/src/types/interfaces/control.ts +106 -106
- package/src/types/interfaces/template.config.js.map +1 -1
- package/src/types/interfaces/template.config.ts +11 -11
- package/templates/angular/src/app/app.component.html.ejs +17 -17
- package/templates/angular/src/app/cmp-array.ejs +3 -3
- package/templates/angular/src/app/cmp-hash.ejs +3 -3
- package/templates/angular/src/app/component-list.g.ts +21 -21
- package/templates/angular/src/app.component.ts +16 -16
- package/templates/angular/src/app.module.ts +70 -70
- package/templates/angular/src/app.routes.ts +73 -73
- package/templates/angular/src/styles/app.css +5 -5
- package/templates/attributes/button_attributes.ejs +2 -2
- package/templates/attributes/common/base/class.ejs +6 -6
- package/templates/attributes/common/base/control_type.ejs +53 -53
- package/templates/attributes/common/base/enabled.ejs +9 -9
- package/templates/attributes/common/base/imageFileName.ejs +3 -3
- package/templates/attributes/common/base/no_control_class.ejs +3 -3
- package/templates/attributes/common/base/rtol.ejs +3 -3
- package/templates/attributes/common/base/tabindex.ejs +11 -11
- package/templates/attributes/common/base/testingId.ejs +8 -8
- package/templates/attributes/common/base/tooltip.ejs +7 -7
- package/templates/attributes/common/base/visible.ejs +6 -6
- package/templates/attributes/common/base/wallpaper.ejs +3 -3
- package/templates/attributes/common/base_attributes.ejs +10 -10
- package/templates/attributes/common/container_attributes.ejs +6 -6
- package/templates/attributes/common/control_attributes.ejs +3 -3
- package/templates/attributes/common/format.ejs +5 -5
- package/templates/attributes/common/input/hint.ejs +13 -13
- package/templates/attributes/common/input/multiline_edit.ejs +3 -3
- package/templates/attributes/common/input/must_input.ejs +8 -8
- package/templates/attributes/common/input/password_edit.ejs +7 -7
- package/templates/attributes/common/input/row_editing_input_attributes.ejs +6 -6
- package/templates/attributes/common/input/validation.ejs +5 -5
- package/templates/attributes/common/input_attributes.ejs +4 -4
- package/templates/attributes/common/no_control_base_attributes.ejs +4 -4
- package/templates/attributes/common/row_editing_button_attributes.ejs +10 -10
- package/templates/component/view.component.html +14 -14
- package/templates/component/view.component.ts +136 -136
- package/templates/themes/basicHTML/Code/theme.module.ts +10 -10
- package/templates/themes/basicHTML/combobox.ejs +37 -37
- package/templates/themes/basicHTML/edit.ejs +169 -169
- package/templates/themes/basicHTML/form.ejs +4 -4
- package/templates/themes/basicHTML/group.ejs +4 -4
- package/templates/themes/basicHTML/image.ejs +6 -6
- package/templates/themes/basicHTML/label.ejs +11 -11
- package/templates/themes/basicHTML/listbox.ejs +21 -21
- package/templates/themes/basicHTML/push-button.ejs +28 -28
- package/templates/themes/basicHTML/radio.ejs +20 -20
- package/templates/themes/basicHTML/subform.ejs +6 -6
- package/templates/themes/basicHTML/tab.ejs +31 -31
- package/templates/themes/basicHTML/tabpage.ejs +5 -5
- package/templates/themes/basicHiddenHTML/Code/theme.module.ts +10 -10
- package/templates/themes/basicHiddenHTML/combobox.ejs +5 -5
- package/templates/themes/basicHiddenHTML/form.ejs +3 -3
- package/templates/themes/basicHiddenHTML/group.ejs +2 -2
- package/templates/themes/basicHiddenHTML/image.ejs +4 -4
- package/templates/themes/basicHiddenHTML/label.ejs +1 -1
- package/templates/themes/basicHiddenHTML/listbox.ejs +8 -8
- package/templates/themes/basicHiddenHTML/push-button.ejs +26 -26
- package/templates/themes/basicHiddenHTML/radio.ejs +17 -17
- package/templates/themes/basicHiddenHTML/tab.ejs +13 -13
- package/templates/themes/basicHiddenHTML/table.ejs +18 -18
- package/templates/themes/basicHiddenHTML/tabpage.ejs +2 -2
- package/templates/themes/container.ejs +26 -26
- package/templates/themes/control.ejs +52 -52
- package/templates/themes/editTypeSelector.ejs +1 -1
- package/templates/themes/material/Code/theme.module.ts +68 -68
- package/templates/themes/material/base_attributes_date.ejs +8 -8
- package/templates/themes/material/combobox.ejs +58 -58
- package/templates/themes/material/edit.ejs +204 -204
- package/templates/themes/material/group.ejs +3 -3
- package/templates/themes/material/listbox.ejs +22 -22
- package/templates/themes/material/push-button.ejs +28 -28
- package/templates/themes/material/radio.ejs +22 -22
- package/templates/themes/material/subform.ejs +8 -8
- package/templates/themes/material/tab.ejs +19 -19
- package/templates/themes/router_outlet.ejs +5 -5
- package/templates/themes/table/HTMLTable/table.ejs +37 -37
- package/templates/themes/table/grid/additionalComponentCode.ejs +26 -26
- package/templates/themes/table/grid/additionalIncludes.ejs +1 -1
- package/templates/themes/table/grid/table.ejs +37 -37
- package/templates/themes/table/repeatable/column.ejs +11 -11
- package/templates/themes/table/repeatable/table.ejs +28 -28
- package/templates/themes/tableTypeSelector.ejs +21 -21
- package/tsconfig.json +36 -36
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import {SchematicsException, Tree} from '@angular-devkit/schematics';
|
|
9
|
-
|
|
10
|
-
export const ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** An Angular CLI Workspacer config (angular.json) */
|
|
14
|
-
export interface Workspace {
|
|
15
|
-
/** Link to schema. */
|
|
16
|
-
$schema?: string;
|
|
17
|
-
/** Workspace Schema version. */
|
|
18
|
-
version: number;
|
|
19
|
-
/** New project root. */
|
|
20
|
-
newProjectRoot?: string;
|
|
21
|
-
/** Tool options. */
|
|
22
|
-
cli?: {
|
|
23
|
-
/** Link to schema. */
|
|
24
|
-
$schema?: string;
|
|
25
|
-
[k: string]: any;
|
|
26
|
-
};
|
|
27
|
-
/** Tool options. */
|
|
28
|
-
schematics?: {
|
|
29
|
-
/** Link to schema. */
|
|
30
|
-
$schema?: string;
|
|
31
|
-
[k: string]: any;
|
|
32
|
-
};
|
|
33
|
-
/** Tool options. */
|
|
34
|
-
architect?: {
|
|
35
|
-
/** Link to schema. */
|
|
36
|
-
$schema?: string;
|
|
37
|
-
[k: string]: any;
|
|
38
|
-
};
|
|
39
|
-
/** A map of project names to project options. */
|
|
40
|
-
projects: {
|
|
41
|
-
[k: string]: Project;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* A project in an Angular CLI workspace (e.g. an app or a library). A single workspace
|
|
47
|
-
* can house multiple projects.
|
|
48
|
-
*/
|
|
49
|
-
export interface Project {
|
|
50
|
-
name: string;
|
|
51
|
-
|
|
52
|
-
/** Project type. */
|
|
53
|
-
projectType: 'application' | 'library';
|
|
54
|
-
/** Root of the project sourcefiles. */
|
|
55
|
-
root: string;
|
|
56
|
-
/** Tool options. */
|
|
57
|
-
cli?: {
|
|
58
|
-
/** Link to schema. */
|
|
59
|
-
$schema?: string;
|
|
60
|
-
[k: string]: any;
|
|
61
|
-
};
|
|
62
|
-
/** Tool options. */
|
|
63
|
-
schematics?: {
|
|
64
|
-
/** Link to schema. */
|
|
65
|
-
$schema?: string;
|
|
66
|
-
[k: string]: any;
|
|
67
|
-
};
|
|
68
|
-
/** Tool options. */
|
|
69
|
-
architect?: ProjectBuildOptions;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Architect options for an Angular CLI workspace. */
|
|
73
|
-
export interface ProjectBuildOptions {
|
|
74
|
-
/** Link to schema. */
|
|
75
|
-
$schema?: string;
|
|
76
|
-
[k: string]: any;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** Gets the Angular CLI workspace config (angular.json) */
|
|
80
|
-
export function getWorkspace(host: Tree): Workspace {
|
|
81
|
-
const configBuffer = host.read(ANGULAR_CLI_WORKSPACE_PATH);
|
|
82
|
-
if (configBuffer === null) {
|
|
83
|
-
throw new SchematicsException('Could not find angular.json');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return JSON.parse(configBuffer.toString());
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Gets a project from the Angular CLI workspace. If no project name is given, the first project
|
|
91
|
-
* will be retrieved.
|
|
92
|
-
*/
|
|
93
|
-
export function getProjectFromWorkspace(config: Workspace, projectName?: string): Project {
|
|
94
|
-
if (config.projects) {
|
|
95
|
-
if (projectName) {
|
|
96
|
-
const project = config.projects[projectName];
|
|
97
|
-
if (!project) {
|
|
98
|
-
throw new SchematicsException(`No project named "${projectName}" exists.`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
Object.defineProperty(project, 'name', {enumerable: false, value: projectName});
|
|
102
|
-
return project;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// If there is exactly one non-e2e project, use that. Otherwise, require that a specific
|
|
106
|
-
// project be specified.
|
|
107
|
-
const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));
|
|
108
|
-
if (allProjectNames.length === 1) {
|
|
109
|
-
const project = config.projects[allProjectNames[0]];
|
|
110
|
-
// Set a non-enumerable project name to the project. We need the name for schematics
|
|
111
|
-
// later on, but don't want to write it back out to the config file.
|
|
112
|
-
Object.defineProperty(project, 'name', {enumerable: false, value: projectName});
|
|
113
|
-
return project;
|
|
114
|
-
} else {
|
|
115
|
-
throw new SchematicsException('Multiple projects are defined; please specify a project name');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
throw new SchematicsException('No projects are defined');
|
|
120
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import {SchematicsException, Tree} from '@angular-devkit/schematics';
|
|
9
|
+
|
|
10
|
+
export const ANGULAR_CLI_WORKSPACE_PATH = '/angular.json';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** An Angular CLI Workspacer config (angular.json) */
|
|
14
|
+
export interface Workspace {
|
|
15
|
+
/** Link to schema. */
|
|
16
|
+
$schema?: string;
|
|
17
|
+
/** Workspace Schema version. */
|
|
18
|
+
version: number;
|
|
19
|
+
/** New project root. */
|
|
20
|
+
newProjectRoot?: string;
|
|
21
|
+
/** Tool options. */
|
|
22
|
+
cli?: {
|
|
23
|
+
/** Link to schema. */
|
|
24
|
+
$schema?: string;
|
|
25
|
+
[k: string]: any;
|
|
26
|
+
};
|
|
27
|
+
/** Tool options. */
|
|
28
|
+
schematics?: {
|
|
29
|
+
/** Link to schema. */
|
|
30
|
+
$schema?: string;
|
|
31
|
+
[k: string]: any;
|
|
32
|
+
};
|
|
33
|
+
/** Tool options. */
|
|
34
|
+
architect?: {
|
|
35
|
+
/** Link to schema. */
|
|
36
|
+
$schema?: string;
|
|
37
|
+
[k: string]: any;
|
|
38
|
+
};
|
|
39
|
+
/** A map of project names to project options. */
|
|
40
|
+
projects: {
|
|
41
|
+
[k: string]: Project;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A project in an Angular CLI workspace (e.g. an app or a library). A single workspace
|
|
47
|
+
* can house multiple projects.
|
|
48
|
+
*/
|
|
49
|
+
export interface Project {
|
|
50
|
+
name: string;
|
|
51
|
+
|
|
52
|
+
/** Project type. */
|
|
53
|
+
projectType: 'application' | 'library';
|
|
54
|
+
/** Root of the project sourcefiles. */
|
|
55
|
+
root: string;
|
|
56
|
+
/** Tool options. */
|
|
57
|
+
cli?: {
|
|
58
|
+
/** Link to schema. */
|
|
59
|
+
$schema?: string;
|
|
60
|
+
[k: string]: any;
|
|
61
|
+
};
|
|
62
|
+
/** Tool options. */
|
|
63
|
+
schematics?: {
|
|
64
|
+
/** Link to schema. */
|
|
65
|
+
$schema?: string;
|
|
66
|
+
[k: string]: any;
|
|
67
|
+
};
|
|
68
|
+
/** Tool options. */
|
|
69
|
+
architect?: ProjectBuildOptions;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Architect options for an Angular CLI workspace. */
|
|
73
|
+
export interface ProjectBuildOptions {
|
|
74
|
+
/** Link to schema. */
|
|
75
|
+
$schema?: string;
|
|
76
|
+
[k: string]: any;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Gets the Angular CLI workspace config (angular.json) */
|
|
80
|
+
export function getWorkspace(host: Tree): Workspace {
|
|
81
|
+
const configBuffer = host.read(ANGULAR_CLI_WORKSPACE_PATH);
|
|
82
|
+
if (configBuffer === null) {
|
|
83
|
+
throw new SchematicsException('Could not find angular.json');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return JSON.parse(configBuffer.toString());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Gets a project from the Angular CLI workspace. If no project name is given, the first project
|
|
91
|
+
* will be retrieved.
|
|
92
|
+
*/
|
|
93
|
+
export function getProjectFromWorkspace(config: Workspace, projectName?: string): Project {
|
|
94
|
+
if (config.projects) {
|
|
95
|
+
if (projectName) {
|
|
96
|
+
const project = config.projects[projectName];
|
|
97
|
+
if (!project) {
|
|
98
|
+
throw new SchematicsException(`No project named "${projectName}" exists.`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Object.defineProperty(project, 'name', {enumerable: false, value: projectName});
|
|
102
|
+
return project;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// If there is exactly one non-e2e project, use that. Otherwise, require that a specific
|
|
106
|
+
// project be specified.
|
|
107
|
+
const allProjectNames = Object.keys(config.projects).filter(p => !p.includes('e2e'));
|
|
108
|
+
if (allProjectNames.length === 1) {
|
|
109
|
+
const project = config.projects[allProjectNames[0]];
|
|
110
|
+
// Set a non-enumerable project name to the project. We need the name for schematics
|
|
111
|
+
// later on, but don't want to write it back out to the config file.
|
|
112
|
+
Object.defineProperty(project, 'name', {enumerable: false, value: projectName});
|
|
113
|
+
return project;
|
|
114
|
+
} else {
|
|
115
|
+
throw new SchematicsException('Multiple projects are defined; please specify a project name');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
throw new SchematicsException('No projects are defined');
|
|
120
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-module.js","sourceRoot":"","sources":["find-module.ts"],"names":[],"mappings":";;AAuBA,sDA2BC;AAKD,gCAqBC;AAKD,8CA0BC;AA3GD;;;;;;GAMG;AACH,+CAAgF;AAahF;;GAEG;AACH,SAAgB,qBAAqB,CAAC,IAAU,EAAE,OAAsB;IACtE,IAAI,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC/D,OAAO,SAAS,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AAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAEjC,MAAM,YAAY,GAAG,IAAA,eAAQ,EAAC,IAAA,gBAAS,EAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAA,gBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5F,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,6EAA6E;IAC7E,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,UAAU,GAAG,GAAG,CAAC;IACnB,CAAC;SAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC;IACD,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5C,UAAU,IAAI,GAAG,CAAC;IACpB,CAAC;IAED,OAAO,UAAU,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC;AAC5E,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 { Path, join, normalize, relative, strings } from '@angular-devkit/core';\nimport { DirEntry, Tree } from '@angular-devkit/schematics';\n\n\nexport interface ModuleOptions {\n module?: string;\n name: string;\n flat?: boolean;\n path?: string;\n skipImport?: boolean;\n}\n\n\n/**\n * Find the module referred by a set of options passed to the schematics.\n */\nexport function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined {\n if (options.hasOwnProperty('skipImport') && options.skipImport) {\n return undefined;\n }\n\n if (!options.module) {\n const pathToCheck = (options.path || '')\n + (options.flat ? '' : '/' + strings.dasherize(options.name));\n\n return normalize(findModule(host, pathToCheck));\n } else {\n const modulePath = normalize(\n '/' + (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 {\n throw new Error('Specified module 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(p => moduleRe.test(p) && !routingModuleRe.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('More than one module matches. Use skip-import option to skip importing '\n + 'the component into the closest module.');\n }\n\n dir = dir.parent;\n }\n\n throw new Error('Could not find an NgModule. Use the skip-import '\n + 'option to skip importing in NgModule.');\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 from = normalize(from);\n to = normalize(to);\n\n // Convert to arrays.\n const fromParts = from.split('/');\n const toParts = to.split('/');\n\n // Remove file names (preserving destination)\n fromParts.pop();\n const toFileName = toParts.pop();\n\n const relativePath = relative(normalize(fromParts.join('/')), normalize(toParts.join('/')));\n let pathPrefix = '';\n\n // Set the path prefix for same dir or child dir, parent dir starts with `..`\n if (!relativePath) {\n pathPrefix = '.';\n } else if (!relativePath.startsWith('.')) {\n pathPrefix = `./`;\n }\n if (pathPrefix && !pathPrefix.endsWith('/')) {\n pathPrefix += '/';\n }\n\n return pathPrefix + (relativePath ? relativePath + '/' : '') + toFileName;\n}\n"]}
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { Path, join, normalize, relative, strings } from '@angular-devkit/core';
|
|
9
|
-
import { DirEntry, Tree } from '@angular-devkit/schematics';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export interface ModuleOptions {
|
|
13
|
-
module?: string;
|
|
14
|
-
name: string;
|
|
15
|
-
flat?: boolean;
|
|
16
|
-
path?: string;
|
|
17
|
-
skipImport?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Find the module referred by a set of options passed to the schematics.
|
|
23
|
-
*/
|
|
24
|
-
export function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined {
|
|
25
|
-
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!options.module) {
|
|
30
|
-
const pathToCheck = (options.path || '')
|
|
31
|
-
+ (options.flat ? '' : '/' + strings.dasherize(options.name));
|
|
32
|
-
|
|
33
|
-
return normalize(findModule(host, pathToCheck));
|
|
34
|
-
} else {
|
|
35
|
-
const modulePath = normalize(
|
|
36
|
-
'/' + (options.path) + '/' + options.module);
|
|
37
|
-
const moduleBaseName = normalize(modulePath).split('/').pop();
|
|
38
|
-
|
|
39
|
-
if (host.exists(modulePath)) {
|
|
40
|
-
return normalize(modulePath);
|
|
41
|
-
} else if (host.exists(modulePath + '.ts')) {
|
|
42
|
-
return normalize(modulePath + '.ts');
|
|
43
|
-
} else if (host.exists(modulePath + '.module.ts')) {
|
|
44
|
-
return normalize(modulePath + '.module.ts');
|
|
45
|
-
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
|
|
46
|
-
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
|
|
47
|
-
} else {
|
|
48
|
-
throw new Error('Specified module does not exist');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Function to find the "closest" module to a generated file's path.
|
|
55
|
-
*/
|
|
56
|
-
export function findModule(host: Tree, generateDir: string): Path {
|
|
57
|
-
let dir: DirEntry | null = host.getDir('/' + generateDir);
|
|
58
|
-
|
|
59
|
-
const moduleRe = /\.module\.ts$/;
|
|
60
|
-
const routingModuleRe = /-routing\.module\.ts/;
|
|
61
|
-
|
|
62
|
-
while (dir) {
|
|
63
|
-
const matches = dir.subfiles.filter(p => moduleRe.test(p) && !routingModuleRe.test(p));
|
|
64
|
-
|
|
65
|
-
if (matches.length == 1) {
|
|
66
|
-
return join(dir.path, matches[0]);
|
|
67
|
-
} else if (matches.length > 1) {
|
|
68
|
-
throw new Error('More than one module matches. Use skip-import option to skip importing '
|
|
69
|
-
+ 'the component into the closest module.');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
dir = dir.parent;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
throw new Error('Could not find an NgModule. Use the skip-import '
|
|
76
|
-
+ 'option to skip importing in NgModule.');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Build a relative path from one file path to another file path.
|
|
81
|
-
*/
|
|
82
|
-
export function buildRelativePath(from: string, to: string): string {
|
|
83
|
-
from = normalize(from);
|
|
84
|
-
to = normalize(to);
|
|
85
|
-
|
|
86
|
-
// Convert to arrays.
|
|
87
|
-
const fromParts = from.split('/');
|
|
88
|
-
const toParts = to.split('/');
|
|
89
|
-
|
|
90
|
-
// Remove file names (preserving destination)
|
|
91
|
-
fromParts.pop();
|
|
92
|
-
const toFileName = toParts.pop();
|
|
93
|
-
|
|
94
|
-
const relativePath = relative(normalize(fromParts.join('/')), normalize(toParts.join('/')));
|
|
95
|
-
let pathPrefix = '';
|
|
96
|
-
|
|
97
|
-
// Set the path prefix for same dir or child dir, parent dir starts with `..`
|
|
98
|
-
if (!relativePath) {
|
|
99
|
-
pathPrefix = '.';
|
|
100
|
-
} else if (!relativePath.startsWith('.')) {
|
|
101
|
-
pathPrefix = `./`;
|
|
102
|
-
}
|
|
103
|
-
if (pathPrefix && !pathPrefix.endsWith('/')) {
|
|
104
|
-
pathPrefix += '/';
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return pathPrefix + (relativePath ? relativePath + '/' : '') + toFileName;
|
|
108
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import { Path, join, normalize, relative, strings } from '@angular-devkit/core';
|
|
9
|
+
import { DirEntry, Tree } from '@angular-devkit/schematics';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export interface ModuleOptions {
|
|
13
|
+
module?: string;
|
|
14
|
+
name: string;
|
|
15
|
+
flat?: boolean;
|
|
16
|
+
path?: string;
|
|
17
|
+
skipImport?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Find the module referred by a set of options passed to the schematics.
|
|
23
|
+
*/
|
|
24
|
+
export function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined {
|
|
25
|
+
if (options.hasOwnProperty('skipImport') && options.skipImport) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!options.module) {
|
|
30
|
+
const pathToCheck = (options.path || '')
|
|
31
|
+
+ (options.flat ? '' : '/' + strings.dasherize(options.name));
|
|
32
|
+
|
|
33
|
+
return normalize(findModule(host, pathToCheck));
|
|
34
|
+
} else {
|
|
35
|
+
const modulePath = normalize(
|
|
36
|
+
'/' + (options.path) + '/' + options.module);
|
|
37
|
+
const moduleBaseName = normalize(modulePath).split('/').pop();
|
|
38
|
+
|
|
39
|
+
if (host.exists(modulePath)) {
|
|
40
|
+
return normalize(modulePath);
|
|
41
|
+
} else if (host.exists(modulePath + '.ts')) {
|
|
42
|
+
return normalize(modulePath + '.ts');
|
|
43
|
+
} else if (host.exists(modulePath + '.module.ts')) {
|
|
44
|
+
return normalize(modulePath + '.module.ts');
|
|
45
|
+
} else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {
|
|
46
|
+
return normalize(modulePath + '/' + moduleBaseName + '.module.ts');
|
|
47
|
+
} else {
|
|
48
|
+
throw new Error('Specified module does not exist');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Function to find the "closest" module to a generated file's path.
|
|
55
|
+
*/
|
|
56
|
+
export function findModule(host: Tree, generateDir: string): Path {
|
|
57
|
+
let dir: DirEntry | null = host.getDir('/' + generateDir);
|
|
58
|
+
|
|
59
|
+
const moduleRe = /\.module\.ts$/;
|
|
60
|
+
const routingModuleRe = /-routing\.module\.ts/;
|
|
61
|
+
|
|
62
|
+
while (dir) {
|
|
63
|
+
const matches = dir.subfiles.filter(p => moduleRe.test(p) && !routingModuleRe.test(p));
|
|
64
|
+
|
|
65
|
+
if (matches.length == 1) {
|
|
66
|
+
return join(dir.path, matches[0]);
|
|
67
|
+
} else if (matches.length > 1) {
|
|
68
|
+
throw new Error('More than one module matches. Use skip-import option to skip importing '
|
|
69
|
+
+ 'the component into the closest module.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
dir = dir.parent;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
throw new Error('Could not find an NgModule. Use the skip-import '
|
|
76
|
+
+ 'option to skip importing in NgModule.');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Build a relative path from one file path to another file path.
|
|
81
|
+
*/
|
|
82
|
+
export function buildRelativePath(from: string, to: string): string {
|
|
83
|
+
from = normalize(from);
|
|
84
|
+
to = normalize(to);
|
|
85
|
+
|
|
86
|
+
// Convert to arrays.
|
|
87
|
+
const fromParts = from.split('/');
|
|
88
|
+
const toParts = to.split('/');
|
|
89
|
+
|
|
90
|
+
// Remove file names (preserving destination)
|
|
91
|
+
fromParts.pop();
|
|
92
|
+
const toFileName = toParts.pop();
|
|
93
|
+
|
|
94
|
+
const relativePath = relative(normalize(fromParts.join('/')), normalize(toParts.join('/')));
|
|
95
|
+
let pathPrefix = '';
|
|
96
|
+
|
|
97
|
+
// Set the path prefix for same dir or child dir, parent dir starts with `..`
|
|
98
|
+
if (!relativePath) {
|
|
99
|
+
pathPrefix = '.';
|
|
100
|
+
} else if (!relativePath.startsWith('.')) {
|
|
101
|
+
pathPrefix = `./`;
|
|
102
|
+
}
|
|
103
|
+
if (pathPrefix && !pathPrefix.endsWith('/')) {
|
|
104
|
+
pathPrefix += '/';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return pathPrefix + (relativePath ? relativePath + '/' : '') + toFileName;
|
|
108
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-ast-utils.js","sourceRoot":"","sources":["ng-ast-utils.ts"],"names":[],"mappings":";;AAaA,0DAiCC;AAED,0DA2BC;AAED,4CAMC;AAnFD;;;;;;GAMG;AACH,+CAAiD;AACjD,2DAAuE;AACvE,+BAA+B;AAC/B,iCAAiC;AACjC,2CAAuD;AAEvD,SAAgB,uBAAuB,CAAC,IAAU,EAAE,QAAgB;IAClE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,gCAAmB,CAAC,cAAc,QAAQ,aAAa,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,MAA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5E,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,GAAyB,EAAE,EAAE;QACjC,MAAM,uBAAuB,GAAsB,GAAG,CAAC,eAAe,CAAC;QAEvE,OAAO,uBAAuB,CAAC,IAAI,CAAC;IACtC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAER,OAAO,2BAA2B,CAAC;AACrC,CAAC;AAED,SAAgB,gBAAgB,CAAC,IAAU,EAAE,QAAgB;IAC3D,MAAM,kBAAkB,GAAG,uBAAuB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,IAAA,gBAAS,EAAC,IAAI,OAAO,IAAI,kBAAkB,KAAK,CAAC,CAAC;IAErE,OAAO,UAAU,CAAC;AACpB,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 { normalize } from '@angular-devkit/core';\nimport { SchematicsException, Tree } from '@angular-devkit/schematics';\nimport { dirname } from 'path';\nimport * as ts from 'typescript';\nimport { findNode, getSourceNodes } from './ast-utils';\n\nexport function findBootstrapModuleCall(host: Tree, mainPath: string): ts.CallExpression | null {\n const mainBuffer = host.read(mainPath);\n if (!mainBuffer) {\n throw new SchematicsException(`Main file (${mainPath}) not found`);\n }\n const mainText = mainBuffer.toString('utf-8');\n const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);\n\n const allNodes = getSourceNodes(source);\n\n let bootstrapCall: ts.CallExpression | null = null;\n\n for (const node of allNodes) {\n\n let bootstrapCallNode: ts.Node | null = null;\n bootstrapCallNode = findNode(node, ts.SyntaxKind.Identifier, 'bootstrapModule');\n\n // Walk up the parent until CallExpression is found.\n while (bootstrapCallNode && bootstrapCallNode.parent\n && bootstrapCallNode.parent.kind !== ts.SyntaxKind.CallExpression) {\n\n bootstrapCallNode = bootstrapCallNode.parent;\n }\n\n if (bootstrapCallNode !== null &&\n bootstrapCallNode.parent !== undefined &&\n bootstrapCallNode.parent.kind === ts.SyntaxKind.CallExpression) {\n bootstrapCall = bootstrapCallNode.parent as ts.CallExpression;\n break;\n }\n }\n\n return bootstrapCall;\n}\n\nexport function findBootstrapModulePath(host: Tree, mainPath: string): string {\n const bootstrapCall = findBootstrapModuleCall(host, mainPath);\n if (!bootstrapCall) {\n throw new SchematicsException('Bootstrap call not found');\n }\n\n const bootstrapModule = bootstrapCall.arguments[0];\n\n const mainBuffer = host.read(mainPath);\n if (!mainBuffer) {\n throw new SchematicsException(`Client app main file (${mainPath}) not found`);\n }\n const mainText = mainBuffer.toString('utf-8');\n const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);\n const allNodes = getSourceNodes(source);\n const bootstrapModuleRelativePath = allNodes\n .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)\n .filter(imp => {\n return findNode(imp, ts.SyntaxKind.Identifier, bootstrapModule.getText());\n })\n .map((imp: ts.ImportDeclaration) => {\n const modulePathStringLiteral = <ts.StringLiteral> imp.moduleSpecifier;\n\n return modulePathStringLiteral.text;\n })[0];\n\n return bootstrapModuleRelativePath;\n}\n\nexport function getAppModulePath(host: Tree, mainPath: string): string {\n const moduleRelativePath = findBootstrapModulePath(host, mainPath);\n const mainDir = dirname(mainPath);\n const modulePath = normalize(`/${mainDir}/${moduleRelativePath}.ts`);\n\n return modulePath;\n}\n"]}
|