@magic-xpa/cli 4.1000.0 → 4.1100.0-dev000.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/README.md +28 -28
- package/index.d.ts +1 -1
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/collection.json +75 -75
- package/src/public_api.d.ts +3 -3
- package/src/public_api.js +6 -6
- package/src/public_api.js.map +1 -1
- package/src/public_api.ts +5 -5
- package/src/schematics/magic-utils/Util.d.ts +6 -6
- package/src/schematics/magic-utils/Util.js +26 -26
- package/src/schematics/magic-utils/Util.js.map +1 -1
- package/src/schematics/magic-utils/config.d.ts +12 -12
- package/src/schematics/magic-utils/config.js +56 -56
- 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.d.ts +23 -23
- package/src/schematics/magic-utils/env.js +39 -39
- 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.d.ts +11 -11
- package/src/schematics/magic-utils/manifest.js +40 -40
- 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.d.ts +51 -51
- package/src/schematics/magic-utils/metadata.class.js +124 -124
- 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/process-json.d.ts +2 -2
- package/src/schematics/magic-utils/process-json.js +157 -158
- package/src/schematics/magic-utils/process-json.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-control.rule.d.ts +5 -5
- package/src/schematics/magic-utils/rules/build-control.rule.js +73 -74
- package/src/schematics/magic-utils/rules/build-control.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-view.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/build-view.rule.js +82 -80
- package/src/schematics/magic-utils/rules/build-view.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/build-view.rule.ts +4 -0
- package/src/schematics/magic-utils/rules/component-list.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/component-list.rule.js +316 -317
- package/src/schematics/magic-utils/rules/component-list.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/generate.rule.d.ts +5 -5
- package/src/schematics/magic-utils/rules/generate.rule.js +53 -54
- 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.d.ts +12 -12
- package/src/schematics/magic-utils/rules/init-add-modules.rule.js +295 -296
- 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-gen-components.rule.d.ts +4 -4
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js +65 -66
- package/src/schematics/magic-utils/rules/init-gen-components.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/init-magic-metadata.rule.js +17 -18
- 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/load-views-gen.rule.d.ts +3 -3
- package/src/schematics/magic-utils/rules/load-views-gen.rule.js +28 -29
- package/src/schematics/magic-utils/rules/load-views-gen.rule.js.map +1 -1
- package/src/schematics/magic-utils/rules/magic-option.scheme.d.ts +22 -21
- package/src/schematics/magic-utils/rules/magic-option.scheme.js +2 -2
- package/src/schematics/magic-utils/rules/magic-option.scheme.js.map +1 -1
- package/src/schematics/magic-utils/rules/magic-option.scheme.ts +24 -23
- package/src/schematics/magic-utils/utils.d.ts +12 -12
- package/src/schematics/magic-utils/utils.js +116 -117
- 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.d.ts +3 -3
- package/src/schematics/mg-Install-prerequisites/index.js +24 -25
- 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/app/magic/lazy-loader.service.ts +2 -1
- package/src/schematics/mg-add/files/src/app/magic/magic.gen.lib.module.ts +19 -19
- package/src/schematics/mg-add/files/src/magic-styles.css +131 -131
- package/src/schematics/mg-add/index.d.ts +3 -3
- package/src/schematics/mg-add/index.js +150 -151
- package/src/schematics/mg-add/index.js.map +1 -1
- package/src/schematics/mg-add/schema.json +29 -29
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.d.ts +2 -2
- package/src/schematics/mg-add/utils/add-declaration-to-root-module.js +10 -11
- 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.d.ts +3 -3
- package/src/schematics/mg-add-tasks/index.js +29 -30
- 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.d.ts +3 -3
- package/src/schematics/mg-delete-files/index.js +12 -13
- 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.d.ts +3 -3
- package/src/schematics/mg-gen-module/index.js +14 -15
- 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.d.ts +3 -3
- package/src/schematics/mg-generate/index.js +12 -13
- 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-generate-component/index.d.ts +3 -3
- package/src/schematics/mg-generate-component/index.js +34 -35
- package/src/schematics/mg-generate-component/index.js.map +1 -1
- package/src/schematics/mg-generate-component/schema.json +6 -0
- package/src/schematics/mg-install/index.d.ts +3 -3
- package/src/schematics/mg-install/index.js +29 -30
- 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/index.d.ts +6 -6
- package/src/schematics/mg-routes/index.js +62 -63
- package/src/schematics/mg-routes/index.js.map +1 -1
- package/src/schematics/mg-routes/schema.json +14 -14
- package/src/schematics/mg-single-control/index.d.ts +3 -3
- package/src/schematics/mg-single-control/index.js +28 -29
- package/src/schematics/mg-single-control/index.js.map +1 -1
- package/src/schematics/mg-single-control/schema.json +24 -24
- package/src/schematics/utils/ast.d.ts +21 -21
- package/src/schematics/utils/ast.js +90 -91
- 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.d.ts +87 -87
- package/src/schematics/utils/devkit-utils/ast-utils.js +489 -490
- 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.d.ts +68 -68
- package/src/schematics/utils/devkit-utils/ast-utils_old.js +419 -420
- 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.d.ts +66 -66
- package/src/schematics/utils/devkit-utils/change.js +94 -94
- 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.d.ts +2 -2
- package/src/schematics/utils/devkit-utils/component.js +96 -97
- 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.d.ts +78 -78
- package/src/schematics/utils/devkit-utils/config.js +52 -52
- 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.d.ts +28 -28
- package/src/schematics/utils/devkit-utils/find-module.js +92 -93
- 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.d.ts +5 -5
- package/src/schematics/utils/devkit-utils/ng-ast-utils.js +73 -74
- 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.d.ts +13 -13
- package/src/schematics/utils/devkit-utils/parse-name.js +19 -20
- 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.d.ts +20 -20
- package/src/schematics/utils/devkit-utils/route-utils.js +133 -134
- 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.d.ts +1 -1
- package/src/schematics/utils/devkit-utils/validation.js +18 -19
- 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.d.ts +18 -18
- package/src/schematics/utils/html.js +59 -60
- package/src/schematics/utils/html.js.map +1 -1
- package/src/schematics/utils/html.ts +63 -63
- package/src/schematics/utils/lib-versions.d.ts +3 -3
- package/src/schematics/utils/lib-versions.js +6 -6
- package/src/schematics/utils/lib-versions.js.map +1 -1
- package/src/schematics/utils/lib-versions.ts +3 -3
- package/src/schematics/utils/package.d.ts +5 -5
- package/src/schematics/utils/package.js +20 -21
- package/src/schematics/utils/package.js.map +1 -1
- package/src/schematics/utils/package.ts +22 -22
- package/src/schematics/utils/testing.d.ts +5 -5
- package/src/schematics/utils/testing.js +26 -27
- package/src/schematics/utils/testing.js.map +1 -1
- package/src/schematics/utils/testing.ts +25 -25
- package/src/types/enums/Enums.d.ts +1646 -1646
- package/src/types/enums/Enums.js +1862 -1862
- 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.d.ts +6 -6
- package/src/types/enums/generated-file-types.enum.js +10 -10
- 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.d.ts +5 -5
- package/src/types/enums/horizontal-alignments.enum.js +9 -9
- 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.d.ts +6 -6
- package/src/types/enums/themes.enum.js +10 -10
- package/src/types/enums/themes.enum.js.map +1 -1
- package/src/types/enums/themes.enum.ts +6 -6
- package/src/types/index.d.ts +7 -7
- package/src/types/index.js +10 -10
- package/src/types/index.js.map +1 -1
- package/src/types/index.ts +8 -8
- package/src/types/interfaces/app.d.ts +53 -53
- package/src/types/interfaces/app.js +9 -9
- package/src/types/interfaces/app.js.map +1 -1
- package/src/types/interfaces/app.ts +89 -89
- package/src/types/interfaces/control.d.ts +82 -82
- package/src/types/interfaces/control.js +2 -2
- package/src/types/interfaces/control.js.map +1 -1
- package/src/types/interfaces/control.ts +106 -106
- package/src/types/interfaces/env.interface.d.ts +19 -19
- package/src/types/interfaces/env.interface.js +10 -10
- package/src/types/interfaces/template.config.d.ts +8 -8
- package/src/types/interfaces/template.config.js +2 -2
- 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 +14 -14
- 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 +123 -122
- package/templates/themes/basicHTML/Code/theme.module.ts +10 -10
- package/templates/themes/basicHTML/checkbox.ejs +1 -1
- package/templates/themes/basicHTML/combobox.ejs +37 -37
- package/templates/themes/basicHTML/edit.ejs +169 -168
- 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/checkbox.ejs +1 -1
- package/templates/themes/material/combobox.ejs +43 -43
- package/templates/themes/material/edit.ejs +204 -204
- package/templates/themes/material/group.ejs +3 -3
- package/templates/themes/material/listbox.ejs +22 -23
- 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/columnHeader.ejs +3 -1
- 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/column.ejs +3 -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,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "SchematicsMagicRoute",
|
|
4
|
-
"title": "Magic Options Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"skipInstall": {
|
|
8
|
-
"type": "boolean",
|
|
9
|
-
"default": false,
|
|
10
|
-
"description": "Do not install the new packages (e.g., --skipInstall)"
|
|
11
|
-
},
|
|
12
|
-
"skipPackageJson": {
|
|
13
|
-
"type": "boolean",
|
|
14
|
-
"default": false,
|
|
15
|
-
"description": "Do not add magic dependencies to package.json (e.g., --skipPackageJson)"
|
|
16
|
-
},
|
|
17
|
-
"project":{
|
|
18
|
-
"type": "string",
|
|
19
|
-
"description": "The name of the project",
|
|
20
|
-
"aliases" : ["p"]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"required": []
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SchematicsMagicRoute",
|
|
4
|
+
"title": "Magic Options Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"skipInstall": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"default": false,
|
|
10
|
+
"description": "Do not install the new packages (e.g., --skipInstall)"
|
|
11
|
+
},
|
|
12
|
+
"skipPackageJson": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"default": false,
|
|
15
|
+
"description": "Do not add magic dependencies to package.json (e.g., --skipPackageJson)"
|
|
16
|
+
},
|
|
17
|
+
"project":{
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "The name of the project",
|
|
20
|
+
"aliases" : ["p"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": []
|
|
24
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
-
import * as ts from 'typescript';
|
|
3
|
-
import { Project } from './devkit-utils/config';
|
|
4
|
-
/** Reads file given path and returns TypeScript source file. */
|
|
5
|
-
export declare function getSourceFile(host: Tree, path: string): ts.SourceFile;
|
|
6
|
-
/** Import and add module to root app module. */
|
|
7
|
-
export declare function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project): void;
|
|
8
|
-
/**
|
|
9
|
-
* Import and add module to specific module path.
|
|
10
|
-
* @param host the tree we are updating
|
|
11
|
-
* @param modulePath src location of the module to import
|
|
12
|
-
* @param moduleName name of module to import
|
|
13
|
-
* @param src src location to import
|
|
14
|
-
*/
|
|
15
|
-
export declare function addModuleImportToModule(host: Tree, modulePath: string, moduleName: string, src: string): void;
|
|
16
|
-
/** Gets the app index.html file */
|
|
17
|
-
export declare function getIndexHtmlPath(host: Tree, project: Project): string;
|
|
18
|
-
/** Get the root stylesheet file. */
|
|
19
|
-
export declare function getStylesPath(host: Tree, project: Project): string;
|
|
20
|
-
/** Wraps the internal find module from options with undefined path handling */
|
|
21
|
-
export declare function findModuleFromOptions(host: Tree, options: any): import("@angular-devkit/core").Path;
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import * as ts from 'typescript';
|
|
3
|
+
import { Project } from './devkit-utils/config';
|
|
4
|
+
/** Reads file given path and returns TypeScript source file. */
|
|
5
|
+
export declare function getSourceFile(host: Tree, path: string): ts.SourceFile;
|
|
6
|
+
/** Import and add module to root app module. */
|
|
7
|
+
export declare function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project): void;
|
|
8
|
+
/**
|
|
9
|
+
* Import and add module to specific module path.
|
|
10
|
+
* @param host the tree we are updating
|
|
11
|
+
* @param modulePath src location of the module to import
|
|
12
|
+
* @param moduleName name of module to import
|
|
13
|
+
* @param src src location to import
|
|
14
|
+
*/
|
|
15
|
+
export declare function addModuleImportToModule(host: Tree, modulePath: string, moduleName: string, src: string): void;
|
|
16
|
+
/** Gets the app index.html file */
|
|
17
|
+
export declare function getIndexHtmlPath(host: Tree, project: Project): string;
|
|
18
|
+
/** Get the root stylesheet file. */
|
|
19
|
+
export declare function getStylesPath(host: Tree, project: Project): string;
|
|
20
|
+
/** Wraps the internal find module from options with undefined path handling */
|
|
21
|
+
export declare function findModuleFromOptions(host: Tree, options: any): import("@angular-devkit/core").Path;
|
|
@@ -1,92 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
* @param
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// "
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/** Wraps the internal find module from options with undefined path handling */
|
|
80
|
-
function findModuleFromOptions(host, options) {
|
|
81
|
-
const workspace = (0, config_1.getWorkspace)(host);
|
|
82
|
-
if (!options.project) {
|
|
83
|
-
options.project = Object.keys(workspace.projects)[0];
|
|
84
|
-
}
|
|
85
|
-
const project = workspace.projects[options.project];
|
|
86
|
-
if (options.path === undefined) {
|
|
87
|
-
options.path = `/${project.root}/src/app`;
|
|
88
|
-
}
|
|
89
|
-
return (0, find_module_1.findModuleFromOptions)(host, options);
|
|
90
|
-
}
|
|
91
|
-
exports.findModuleFromOptions = findModuleFromOptions;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSourceFile = getSourceFile;
|
|
4
|
+
exports.addModuleImportToRootModule = addModuleImportToRootModule;
|
|
5
|
+
exports.addModuleImportToModule = addModuleImportToModule;
|
|
6
|
+
exports.getIndexHtmlPath = getIndexHtmlPath;
|
|
7
|
+
exports.getStylesPath = getStylesPath;
|
|
8
|
+
exports.findModuleFromOptions = findModuleFromOptions;
|
|
9
|
+
const core_1 = require("@angular-devkit/core");
|
|
10
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
11
|
+
const ts = require("typescript");
|
|
12
|
+
const ast_utils_1 = require("./devkit-utils/ast-utils");
|
|
13
|
+
const change_1 = require("./devkit-utils/change");
|
|
14
|
+
const config_1 = require("./devkit-utils/config");
|
|
15
|
+
const ng_ast_utils_1 = require("./devkit-utils/ng-ast-utils");
|
|
16
|
+
const find_module_1 = require("./devkit-utils/find-module");
|
|
17
|
+
/** Reads file given path and returns TypeScript source file. */
|
|
18
|
+
function getSourceFile(host, path) {
|
|
19
|
+
const buffer = host.read(path);
|
|
20
|
+
if (!buffer) {
|
|
21
|
+
throw new schematics_1.SchematicsException(`Could not find file for path: ${path}`);
|
|
22
|
+
}
|
|
23
|
+
const content = buffer.toString();
|
|
24
|
+
return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
25
|
+
}
|
|
26
|
+
/** Import and add module to root app module. */
|
|
27
|
+
function addModuleImportToRootModule(host, moduleName, src, project) {
|
|
28
|
+
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, project.architect.build.options.browser);
|
|
29
|
+
addModuleImportToModule(host, modulePath, moduleName, src);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Import and add module to specific module path.
|
|
33
|
+
* @param host the tree we are updating
|
|
34
|
+
* @param modulePath src location of the module to import
|
|
35
|
+
* @param moduleName name of module to import
|
|
36
|
+
* @param src src location to import
|
|
37
|
+
*/
|
|
38
|
+
function addModuleImportToModule(host, modulePath, moduleName, src) {
|
|
39
|
+
const moduleSource = getSourceFile(host, modulePath);
|
|
40
|
+
if (!moduleSource) {
|
|
41
|
+
throw new schematics_1.SchematicsException(`Module not found: ${modulePath}`);
|
|
42
|
+
}
|
|
43
|
+
const changes = (0, ast_utils_1.addImportToModule)(moduleSource, modulePath, moduleName, src);
|
|
44
|
+
const recorder = host.beginUpdate(modulePath);
|
|
45
|
+
changes.forEach((change) => {
|
|
46
|
+
if (change instanceof change_1.InsertChange) {
|
|
47
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
host.commitUpdate(recorder);
|
|
51
|
+
}
|
|
52
|
+
/** Gets the app index.html file */
|
|
53
|
+
function getIndexHtmlPath(host, project) {
|
|
54
|
+
const buildTarget = project.architect.build.options;
|
|
55
|
+
if (buildTarget.index && buildTarget.index.endsWith('index.html')) {
|
|
56
|
+
return buildTarget.index;
|
|
57
|
+
}
|
|
58
|
+
throw new schematics_1.SchematicsException('No index.html file was found.');
|
|
59
|
+
}
|
|
60
|
+
/** Get the root stylesheet file. */
|
|
61
|
+
function getStylesPath(host, project) {
|
|
62
|
+
const buildTarget = project.architect['build'];
|
|
63
|
+
if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {
|
|
64
|
+
const styles = buildTarget.options.styles.map(s => s.input);
|
|
65
|
+
// First, see if any of the assets is called "styles.(le|sc|c)ss", which is the default
|
|
66
|
+
// "main" style sheet.
|
|
67
|
+
const defaultMainStylePath = styles.find(a => /styles\.(c|le|sc)ss/.test(a));
|
|
68
|
+
if (defaultMainStylePath) {
|
|
69
|
+
return (0, core_1.normalize)(defaultMainStylePath);
|
|
70
|
+
}
|
|
71
|
+
// If there was no obvious default file, use the first style asset.
|
|
72
|
+
const fallbackStylePath = styles.find(a => /\.(c|le|sc)ss/.test(a));
|
|
73
|
+
if (fallbackStylePath) {
|
|
74
|
+
return (0, core_1.normalize)(fallbackStylePath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
throw new schematics_1.SchematicsException('No style files could be found into which a theme could be added');
|
|
78
|
+
}
|
|
79
|
+
/** Wraps the internal find module from options with undefined path handling */
|
|
80
|
+
function findModuleFromOptions(host, options) {
|
|
81
|
+
const workspace = (0, config_1.getWorkspace)(host);
|
|
82
|
+
if (!options.project) {
|
|
83
|
+
options.project = Object.keys(workspace.projects)[0];
|
|
84
|
+
}
|
|
85
|
+
const project = workspace.projects[options.project];
|
|
86
|
+
if (options.path === undefined) {
|
|
87
|
+
options.path = `/${project.root}/src/app`;
|
|
88
|
+
}
|
|
89
|
+
return (0, find_module_1.findModuleFromOptions)(host, options);
|
|
90
|
+
}
|
|
92
91
|
//# sourceMappingURL=ast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["ast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["ast.ts"],"names":[],"mappings":"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","sourcesContent":["import {normalize} from '@angular-devkit/core';\r\nimport {SchematicsException, Tree} from '@angular-devkit/schematics';\r\nimport * as ts from 'typescript';\r\nimport {addImportToModule} from './devkit-utils/ast-utils';\r\nimport {InsertChange} from './devkit-utils/change';\r\nimport {Project, getWorkspace} from './devkit-utils/config';\r\nimport {findBootstrapModulePath, getAppModulePath} from './devkit-utils/ng-ast-utils';\r\nimport {ModuleOptions, findModuleFromOptions as internalFindModule} from './devkit-utils/find-module';\r\n\r\n\r\n/** Reads file given path and returns TypeScript source file. */\r\nexport function getSourceFile(host: Tree, path: string): ts.SourceFile {\r\n const buffer = host.read(path);\r\n if (!buffer) {\r\n throw new SchematicsException(`Could not find file for path: ${path}`);\r\n }\r\n const content = buffer.toString();\r\n return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);\r\n}\r\n\r\n/** Import and add module to root app module. */\r\nexport function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project) {\r\n const modulePath = getAppModulePath(host, project.architect.build.options.browser);\r\n addModuleImportToModule(host, modulePath, moduleName, src);\r\n}\r\n\r\n/**\r\n * Import and add module to specific module path.\r\n * @param host the tree we are updating\r\n * @param modulePath src location of the module to import\r\n * @param moduleName name of module to import\r\n * @param src src location to import\r\n */\r\nexport function addModuleImportToModule(\r\n host: Tree, modulePath: string, moduleName: string, src: string) {\r\n const moduleSource = getSourceFile(host, modulePath);\r\n\r\n if (!moduleSource) {\r\n throw new SchematicsException(`Module not found: ${modulePath}`);\r\n }\r\n\r\n const changes = addImportToModule(moduleSource, modulePath, moduleName, src);\r\n const recorder = host.beginUpdate(modulePath);\r\n\r\n changes.forEach((change) => {\r\n if (change instanceof InsertChange) {\r\n recorder.insertLeft(change.pos, change.toAdd);\r\n }\r\n });\r\n\r\n host.commitUpdate(recorder);\r\n}\r\n\r\n/** Gets the app index.html file */\r\nexport function getIndexHtmlPath(host: Tree, project: Project): string {\r\n const buildTarget = project.architect.build.options;\r\n\r\n if (buildTarget.index && buildTarget.index.endsWith('index.html')) {\r\n return buildTarget.index;\r\n }\r\n\r\n throw new SchematicsException('No index.html file was found.');\r\n}\r\n\r\n/** Get the root stylesheet file. */\r\nexport function getStylesPath(host: Tree, project: Project): string {\r\n const buildTarget = project.architect['build'];\r\n\r\n if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {\r\n const styles = buildTarget.options.styles.map(s => s.input);\r\n\r\n // First, see if any of the assets is called \"styles.(le|sc|c)ss\", which is the default\r\n // \"main\" style sheet.\r\n const defaultMainStylePath = styles.find(a => /styles\\.(c|le|sc)ss/.test(a));\r\n if (defaultMainStylePath) {\r\n return normalize(defaultMainStylePath);\r\n }\r\n\r\n // If there was no obvious default file, use the first style asset.\r\n const fallbackStylePath = styles.find(a => /\\.(c|le|sc)ss/.test(a));\r\n if (fallbackStylePath) {\r\n return normalize(fallbackStylePath);\r\n }\r\n }\r\n\r\n throw new SchematicsException('No style files could be found into which a theme could be added');\r\n}\r\n\r\n/** Wraps the internal find module from options with undefined path handling */\r\nexport function findModuleFromOptions(host: Tree, options: any) {\r\n const workspace = getWorkspace(host);\r\n if (!options.project) {\r\n options.project = Object.keys(workspace.projects)[0];\r\n }\r\n\r\n const project = workspace.projects[options.project];\r\n\r\n if (options.path === undefined) {\r\n options.path = `/${project.root}/src/app`;\r\n }\r\n\r\n return internalFindModule(host, options);\r\n}\r\n"]}
|
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
import {normalize} from '@angular-devkit/core';
|
|
2
|
-
import {SchematicsException, Tree} from '@angular-devkit/schematics';
|
|
3
|
-
import * as ts from 'typescript';
|
|
4
|
-
import {addImportToModule} from './devkit-utils/ast-utils';
|
|
5
|
-
import {InsertChange} from './devkit-utils/change';
|
|
6
|
-
import {Project, getWorkspace} from './devkit-utils/config';
|
|
7
|
-
import {findBootstrapModulePath, getAppModulePath} from './devkit-utils/ng-ast-utils';
|
|
8
|
-
import {ModuleOptions, findModuleFromOptions as internalFindModule} from './devkit-utils/find-module';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** Reads file given path and returns TypeScript source file. */
|
|
12
|
-
export function getSourceFile(host: Tree, path: string): ts.SourceFile {
|
|
13
|
-
const buffer = host.read(path);
|
|
14
|
-
if (!buffer) {
|
|
15
|
-
throw new SchematicsException(`Could not find file for path: ${path}`);
|
|
16
|
-
}
|
|
17
|
-
const content = buffer.toString();
|
|
18
|
-
return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Import and add module to root app module. */
|
|
22
|
-
export function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project) {
|
|
23
|
-
const modulePath = getAppModulePath(host, project.architect.build.options.
|
|
24
|
-
addModuleImportToModule(host, modulePath, moduleName, src);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Import and add module to specific module path.
|
|
29
|
-
* @param host the tree we are updating
|
|
30
|
-
* @param modulePath src location of the module to import
|
|
31
|
-
* @param moduleName name of module to import
|
|
32
|
-
* @param src src location to import
|
|
33
|
-
*/
|
|
34
|
-
export function addModuleImportToModule(
|
|
35
|
-
host: Tree, modulePath: string, moduleName: string, src: string) {
|
|
36
|
-
const moduleSource = getSourceFile(host, modulePath);
|
|
37
|
-
|
|
38
|
-
if (!moduleSource) {
|
|
39
|
-
throw new SchematicsException(`Module not found: ${modulePath}`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const changes = addImportToModule(moduleSource, modulePath, moduleName, src);
|
|
43
|
-
const recorder = host.beginUpdate(modulePath);
|
|
44
|
-
|
|
45
|
-
changes.forEach((change) => {
|
|
46
|
-
if (change instanceof InsertChange) {
|
|
47
|
-
recorder.insertLeft(change.pos, change.toAdd);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
host.commitUpdate(recorder);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Gets the app index.html file */
|
|
55
|
-
export function getIndexHtmlPath(host: Tree, project: Project): string {
|
|
56
|
-
const buildTarget = project.architect.build.options;
|
|
57
|
-
|
|
58
|
-
if (buildTarget.index && buildTarget.index.endsWith('index.html')) {
|
|
59
|
-
return buildTarget.index;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new SchematicsException('No index.html file was found.');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Get the root stylesheet file. */
|
|
66
|
-
export function getStylesPath(host: Tree, project: Project): string {
|
|
67
|
-
const buildTarget = project.architect['build'];
|
|
68
|
-
|
|
69
|
-
if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {
|
|
70
|
-
const styles = buildTarget.options.styles.map(s => s.input);
|
|
71
|
-
|
|
72
|
-
// First, see if any of the assets is called "styles.(le|sc|c)ss", which is the default
|
|
73
|
-
// "main" style sheet.
|
|
74
|
-
const defaultMainStylePath = styles.find(a => /styles\.(c|le|sc)ss/.test(a));
|
|
75
|
-
if (defaultMainStylePath) {
|
|
76
|
-
return normalize(defaultMainStylePath);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// If there was no obvious default file, use the first style asset.
|
|
80
|
-
const fallbackStylePath = styles.find(a => /\.(c|le|sc)ss/.test(a));
|
|
81
|
-
if (fallbackStylePath) {
|
|
82
|
-
return normalize(fallbackStylePath);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
throw new SchematicsException('No style files could be found into which a theme could be added');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Wraps the internal find module from options with undefined path handling */
|
|
90
|
-
export function findModuleFromOptions(host: Tree, options: any) {
|
|
91
|
-
const workspace = getWorkspace(host);
|
|
92
|
-
if (!options.project) {
|
|
93
|
-
options.project = Object.keys(workspace.projects)[0];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const project = workspace.projects[options.project];
|
|
97
|
-
|
|
98
|
-
if (options.path === undefined) {
|
|
99
|
-
options.path = `/${project.root}/src/app`;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return internalFindModule(host, options);
|
|
103
|
-
}
|
|
1
|
+
import {normalize} from '@angular-devkit/core';
|
|
2
|
+
import {SchematicsException, Tree} from '@angular-devkit/schematics';
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
|
+
import {addImportToModule} from './devkit-utils/ast-utils';
|
|
5
|
+
import {InsertChange} from './devkit-utils/change';
|
|
6
|
+
import {Project, getWorkspace} from './devkit-utils/config';
|
|
7
|
+
import {findBootstrapModulePath, getAppModulePath} from './devkit-utils/ng-ast-utils';
|
|
8
|
+
import {ModuleOptions, findModuleFromOptions as internalFindModule} from './devkit-utils/find-module';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/** Reads file given path and returns TypeScript source file. */
|
|
12
|
+
export function getSourceFile(host: Tree, path: string): ts.SourceFile {
|
|
13
|
+
const buffer = host.read(path);
|
|
14
|
+
if (!buffer) {
|
|
15
|
+
throw new SchematicsException(`Could not find file for path: ${path}`);
|
|
16
|
+
}
|
|
17
|
+
const content = buffer.toString();
|
|
18
|
+
return ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Import and add module to root app module. */
|
|
22
|
+
export function addModuleImportToRootModule(host: Tree, moduleName: string, src: string, project: Project) {
|
|
23
|
+
const modulePath = getAppModulePath(host, project.architect.build.options.browser);
|
|
24
|
+
addModuleImportToModule(host, modulePath, moduleName, src);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Import and add module to specific module path.
|
|
29
|
+
* @param host the tree we are updating
|
|
30
|
+
* @param modulePath src location of the module to import
|
|
31
|
+
* @param moduleName name of module to import
|
|
32
|
+
* @param src src location to import
|
|
33
|
+
*/
|
|
34
|
+
export function addModuleImportToModule(
|
|
35
|
+
host: Tree, modulePath: string, moduleName: string, src: string) {
|
|
36
|
+
const moduleSource = getSourceFile(host, modulePath);
|
|
37
|
+
|
|
38
|
+
if (!moduleSource) {
|
|
39
|
+
throw new SchematicsException(`Module not found: ${modulePath}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const changes = addImportToModule(moduleSource, modulePath, moduleName, src);
|
|
43
|
+
const recorder = host.beginUpdate(modulePath);
|
|
44
|
+
|
|
45
|
+
changes.forEach((change) => {
|
|
46
|
+
if (change instanceof InsertChange) {
|
|
47
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
host.commitUpdate(recorder);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Gets the app index.html file */
|
|
55
|
+
export function getIndexHtmlPath(host: Tree, project: Project): string {
|
|
56
|
+
const buildTarget = project.architect.build.options;
|
|
57
|
+
|
|
58
|
+
if (buildTarget.index && buildTarget.index.endsWith('index.html')) {
|
|
59
|
+
return buildTarget.index;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
throw new SchematicsException('No index.html file was found.');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Get the root stylesheet file. */
|
|
66
|
+
export function getStylesPath(host: Tree, project: Project): string {
|
|
67
|
+
const buildTarget = project.architect['build'];
|
|
68
|
+
|
|
69
|
+
if (buildTarget.options && buildTarget.options.styles && buildTarget.options.styles.length) {
|
|
70
|
+
const styles = buildTarget.options.styles.map(s => s.input);
|
|
71
|
+
|
|
72
|
+
// First, see if any of the assets is called "styles.(le|sc|c)ss", which is the default
|
|
73
|
+
// "main" style sheet.
|
|
74
|
+
const defaultMainStylePath = styles.find(a => /styles\.(c|le|sc)ss/.test(a));
|
|
75
|
+
if (defaultMainStylePath) {
|
|
76
|
+
return normalize(defaultMainStylePath);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// If there was no obvious default file, use the first style asset.
|
|
80
|
+
const fallbackStylePath = styles.find(a => /\.(c|le|sc)ss/.test(a));
|
|
81
|
+
if (fallbackStylePath) {
|
|
82
|
+
return normalize(fallbackStylePath);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
throw new SchematicsException('No style files could be found into which a theme could be added');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Wraps the internal find module from options with undefined path handling */
|
|
90
|
+
export function findModuleFromOptions(host: Tree, options: any) {
|
|
91
|
+
const workspace = getWorkspace(host);
|
|
92
|
+
if (!options.project) {
|
|
93
|
+
options.project = Object.keys(workspace.projects)[0];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const project = workspace.projects[options.project];
|
|
97
|
+
|
|
98
|
+
if (options.path === undefined) {
|
|
99
|
+
options.path = `/${project.root}/src/app`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return internalFindModule(host, options);
|
|
103
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# NOTE
|
|
1
|
+
# NOTE
|
|
2
2
|
This code is directly taken from [angular schematics package](https://github.com/angular/devkit/tree/master/packages/schematics/angular/utility).
|