@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,66 +1,66 @@
|
|
|
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
|
-
export interface Host {
|
|
9
|
-
write(path: string, content: string): Promise<void>;
|
|
10
|
-
read(path: string): Promise<string>;
|
|
11
|
-
}
|
|
12
|
-
export interface Change {
|
|
13
|
-
apply(host: Host): Promise<void>;
|
|
14
|
-
readonly path: string | null;
|
|
15
|
-
readonly order: number;
|
|
16
|
-
readonly description: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* An operation that does nothing.
|
|
20
|
-
*/
|
|
21
|
-
export declare class NoopChange implements Change {
|
|
22
|
-
description: string;
|
|
23
|
-
order: number;
|
|
24
|
-
path: any;
|
|
25
|
-
apply(): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Will add text to the source code.
|
|
29
|
-
*/
|
|
30
|
-
export declare class InsertChange implements Change {
|
|
31
|
-
path: string;
|
|
32
|
-
pos: number;
|
|
33
|
-
toAdd: string;
|
|
34
|
-
order: number;
|
|
35
|
-
description: string;
|
|
36
|
-
constructor(path: string, pos: number, toAdd: string);
|
|
37
|
-
/**
|
|
38
|
-
* This method does not insert spaces if there is none in the original string.
|
|
39
|
-
*/
|
|
40
|
-
apply(host: Host): Promise<void>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Will remove text from the source code.
|
|
44
|
-
*/
|
|
45
|
-
export declare class RemoveChange implements Change {
|
|
46
|
-
path: string;
|
|
47
|
-
private pos;
|
|
48
|
-
private toRemove;
|
|
49
|
-
order: number;
|
|
50
|
-
description: string;
|
|
51
|
-
constructor(path: string, pos: number, toRemove: string);
|
|
52
|
-
apply(host: Host): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Will replace text from the source code.
|
|
56
|
-
*/
|
|
57
|
-
export declare class ReplaceChange implements Change {
|
|
58
|
-
path: string;
|
|
59
|
-
private pos;
|
|
60
|
-
private oldText;
|
|
61
|
-
private newText;
|
|
62
|
-
order: number;
|
|
63
|
-
description: string;
|
|
64
|
-
constructor(path: string, pos: number, oldText: string, newText: string);
|
|
65
|
-
apply(host: Host): Promise<void>;
|
|
66
|
-
}
|
|
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
|
+
export interface Host {
|
|
9
|
+
write(path: string, content: string): Promise<void>;
|
|
10
|
+
read(path: string): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
export interface Change {
|
|
13
|
+
apply(host: Host): Promise<void>;
|
|
14
|
+
readonly path: string | null;
|
|
15
|
+
readonly order: number;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* An operation that does nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare class NoopChange implements Change {
|
|
22
|
+
description: string;
|
|
23
|
+
order: number;
|
|
24
|
+
path: any;
|
|
25
|
+
apply(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Will add text to the source code.
|
|
29
|
+
*/
|
|
30
|
+
export declare class InsertChange implements Change {
|
|
31
|
+
path: string;
|
|
32
|
+
pos: number;
|
|
33
|
+
toAdd: string;
|
|
34
|
+
order: number;
|
|
35
|
+
description: string;
|
|
36
|
+
constructor(path: string, pos: number, toAdd: string);
|
|
37
|
+
/**
|
|
38
|
+
* This method does not insert spaces if there is none in the original string.
|
|
39
|
+
*/
|
|
40
|
+
apply(host: Host): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Will remove text from the source code.
|
|
44
|
+
*/
|
|
45
|
+
export declare class RemoveChange implements Change {
|
|
46
|
+
path: string;
|
|
47
|
+
private pos;
|
|
48
|
+
private toRemove;
|
|
49
|
+
order: number;
|
|
50
|
+
description: string;
|
|
51
|
+
constructor(path: string, pos: number, toRemove: string);
|
|
52
|
+
apply(host: Host): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Will replace text from the source code.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ReplaceChange implements Change {
|
|
58
|
+
path: string;
|
|
59
|
+
private pos;
|
|
60
|
+
private oldText;
|
|
61
|
+
private newText;
|
|
62
|
+
order: number;
|
|
63
|
+
description: string;
|
|
64
|
+
constructor(path: string, pos: number, oldText: string, newText: string);
|
|
65
|
+
apply(host: Host): Promise<void>;
|
|
66
|
+
}
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* An operation that does nothing.
|
|
6
|
-
*/
|
|
7
|
-
class NoopChange {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.description = 'No operation.';
|
|
10
|
-
this.order = Infinity;
|
|
11
|
-
this.path = null;
|
|
12
|
-
}
|
|
13
|
-
apply() { return Promise.resolve(); }
|
|
14
|
-
}
|
|
15
|
-
exports.NoopChange = NoopChange;
|
|
16
|
-
/**
|
|
17
|
-
* Will add text to the source code.
|
|
18
|
-
*/
|
|
19
|
-
class InsertChange {
|
|
20
|
-
constructor(path, pos, toAdd) {
|
|
21
|
-
this.path = path;
|
|
22
|
-
this.pos = pos;
|
|
23
|
-
this.toAdd = toAdd;
|
|
24
|
-
if (pos < 0) {
|
|
25
|
-
throw new Error('Negative positions are invalid');
|
|
26
|
-
}
|
|
27
|
-
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
28
|
-
this.order = pos;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* This method does not insert spaces if there is none in the original string.
|
|
32
|
-
*/
|
|
33
|
-
apply(host) {
|
|
34
|
-
return host.read(this.path).then(content => {
|
|
35
|
-
const prefix = content.substring(0, this.pos);
|
|
36
|
-
const suffix = content.substring(this.pos);
|
|
37
|
-
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.InsertChange = InsertChange;
|
|
42
|
-
/**
|
|
43
|
-
* Will remove text from the source code.
|
|
44
|
-
*/
|
|
45
|
-
class RemoveChange {
|
|
46
|
-
constructor(path, pos, toRemove) {
|
|
47
|
-
this.path = path;
|
|
48
|
-
this.pos = pos;
|
|
49
|
-
this.toRemove = toRemove;
|
|
50
|
-
if (pos < 0) {
|
|
51
|
-
throw new Error('Negative positions are invalid');
|
|
52
|
-
}
|
|
53
|
-
this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
|
|
54
|
-
this.order = pos;
|
|
55
|
-
}
|
|
56
|
-
apply(host) {
|
|
57
|
-
return host.read(this.path).then(content => {
|
|
58
|
-
const prefix = content.substring(0, this.pos);
|
|
59
|
-
const suffix = content.substring(this.pos + this.toRemove.length);
|
|
60
|
-
// TODO: throw error if toRemove doesn't match removed string.
|
|
61
|
-
return host.write(this.path, `${prefix}${suffix}`);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.RemoveChange = RemoveChange;
|
|
66
|
-
/**
|
|
67
|
-
* Will replace text from the source code.
|
|
68
|
-
*/
|
|
69
|
-
class ReplaceChange {
|
|
70
|
-
constructor(path, pos, oldText, newText) {
|
|
71
|
-
this.path = path;
|
|
72
|
-
this.pos = pos;
|
|
73
|
-
this.oldText = oldText;
|
|
74
|
-
this.newText = newText;
|
|
75
|
-
if (pos < 0) {
|
|
76
|
-
throw new Error('Negative positions are invalid');
|
|
77
|
-
}
|
|
78
|
-
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
79
|
-
this.order = pos;
|
|
80
|
-
}
|
|
81
|
-
apply(host) {
|
|
82
|
-
return host.read(this.path).then(content => {
|
|
83
|
-
const prefix = content.substring(0, this.pos);
|
|
84
|
-
const suffix = content.substring(this.pos + this.oldText.length);
|
|
85
|
-
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
86
|
-
if (text !== this.oldText) {
|
|
87
|
-
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
88
|
-
}
|
|
89
|
-
// TODO: throw error if oldText doesn't match removed string.
|
|
90
|
-
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.ReplaceChange = ReplaceChange;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplaceChange = exports.RemoveChange = exports.InsertChange = exports.NoopChange = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* An operation that does nothing.
|
|
6
|
+
*/
|
|
7
|
+
class NoopChange {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.description = 'No operation.';
|
|
10
|
+
this.order = Infinity;
|
|
11
|
+
this.path = null;
|
|
12
|
+
}
|
|
13
|
+
apply() { return Promise.resolve(); }
|
|
14
|
+
}
|
|
15
|
+
exports.NoopChange = NoopChange;
|
|
16
|
+
/**
|
|
17
|
+
* Will add text to the source code.
|
|
18
|
+
*/
|
|
19
|
+
class InsertChange {
|
|
20
|
+
constructor(path, pos, toAdd) {
|
|
21
|
+
this.path = path;
|
|
22
|
+
this.pos = pos;
|
|
23
|
+
this.toAdd = toAdd;
|
|
24
|
+
if (pos < 0) {
|
|
25
|
+
throw new Error('Negative positions are invalid');
|
|
26
|
+
}
|
|
27
|
+
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
28
|
+
this.order = pos;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This method does not insert spaces if there is none in the original string.
|
|
32
|
+
*/
|
|
33
|
+
apply(host) {
|
|
34
|
+
return host.read(this.path).then(content => {
|
|
35
|
+
const prefix = content.substring(0, this.pos);
|
|
36
|
+
const suffix = content.substring(this.pos);
|
|
37
|
+
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.InsertChange = InsertChange;
|
|
42
|
+
/**
|
|
43
|
+
* Will remove text from the source code.
|
|
44
|
+
*/
|
|
45
|
+
class RemoveChange {
|
|
46
|
+
constructor(path, pos, toRemove) {
|
|
47
|
+
this.path = path;
|
|
48
|
+
this.pos = pos;
|
|
49
|
+
this.toRemove = toRemove;
|
|
50
|
+
if (pos < 0) {
|
|
51
|
+
throw new Error('Negative positions are invalid');
|
|
52
|
+
}
|
|
53
|
+
this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
|
|
54
|
+
this.order = pos;
|
|
55
|
+
}
|
|
56
|
+
apply(host) {
|
|
57
|
+
return host.read(this.path).then(content => {
|
|
58
|
+
const prefix = content.substring(0, this.pos);
|
|
59
|
+
const suffix = content.substring(this.pos + this.toRemove.length);
|
|
60
|
+
// TODO: throw error if toRemove doesn't match removed string.
|
|
61
|
+
return host.write(this.path, `${prefix}${suffix}`);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.RemoveChange = RemoveChange;
|
|
66
|
+
/**
|
|
67
|
+
* Will replace text from the source code.
|
|
68
|
+
*/
|
|
69
|
+
class ReplaceChange {
|
|
70
|
+
constructor(path, pos, oldText, newText) {
|
|
71
|
+
this.path = path;
|
|
72
|
+
this.pos = pos;
|
|
73
|
+
this.oldText = oldText;
|
|
74
|
+
this.newText = newText;
|
|
75
|
+
if (pos < 0) {
|
|
76
|
+
throw new Error('Negative positions are invalid');
|
|
77
|
+
}
|
|
78
|
+
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
79
|
+
this.order = pos;
|
|
80
|
+
}
|
|
81
|
+
apply(host) {
|
|
82
|
+
return host.read(this.path).then(content => {
|
|
83
|
+
const prefix = content.substring(0, this.pos);
|
|
84
|
+
const suffix = content.substring(this.pos + this.oldText.length);
|
|
85
|
+
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
86
|
+
if (text !== this.oldText) {
|
|
87
|
+
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
88
|
+
}
|
|
89
|
+
// TODO: throw error if oldText doesn't match removed string.
|
|
90
|
+
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.ReplaceChange = ReplaceChange;
|
|
95
95
|
//# sourceMappingURL=change.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change.js","sourceRoot":"","sources":["change.ts"],"names":[],"mappings":";;;AA6BA;;GAEG;AACH,MAAa,UAAU;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,GAAG,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,sCA2BC","sourcesContent":["/**\r\n * @license\r\n * Copyright Google Inc. All Rights Reserved.\r\n *\r\n * Use of this source code is governed by an MIT-style license that can be\r\n * found in the LICENSE file at https://angular.io/license\r\n */\r\nexport interface Host {\r\n write(path: string, content: string): Promise<void>;\r\n read(path: string): Promise<string>;\r\n}\r\n\r\n\r\nexport interface Change {\r\n apply(host: Host): Promise<void>;\r\n\r\n // The file this change should be applied to. Some changes might not apply to\r\n // a file (maybe the config).\r\n readonly path: string | null;\r\n\r\n // The order this change should be applied. Normally the position inside the file.\r\n // Changes are applied from the bottom of a file to the top.\r\n readonly order: number;\r\n\r\n // The description of this change. This will be outputted in a dry or verbose run.\r\n readonly description: string;\r\n}\r\n\r\n\r\n/**\r\n * An operation that does nothing.\r\n */\r\nexport class NoopChange implements Change {\r\n description = 'No operation.';\r\n order = Infinity;\r\n path = null;\r\n apply() { return Promise.resolve(); }\r\n}\r\n\r\n\r\n/**\r\n * Will add text to the source code.\r\n */\r\nexport class InsertChange implements Change {\r\n\r\n order: number;\r\n description: string;\r\n\r\n constructor(public path: string, public pos: number, public toAdd: string) {\r\n if (pos < 0) {\r\n throw new Error('Negative positions are invalid');\r\n }\r\n this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;\r\n this.order = pos;\r\n }\r\n\r\n /**\r\n * This method does not insert spaces if there is none in the original string.\r\n */\r\n apply(host: Host) {\r\n return host.read(this.path).then(content => {\r\n const prefix = content.substring(0, this.pos);\r\n const suffix = content.substring(this.pos);\r\n\r\n return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Will remove text from the source code.\r\n */\r\nexport class RemoveChange implements Change {\r\n\r\n order: number;\r\n description: string;\r\n\r\n constructor(public path: string, private pos: number, private toRemove: string) {\r\n if (pos < 0) {\r\n throw new Error('Negative positions are invalid');\r\n }\r\n this.description = `Removed ${toRemove} into position ${pos} of ${path}`;\r\n this.order = pos;\r\n }\r\n\r\n apply(host: Host): Promise<void> {\r\n return host.read(this.path).then(content => {\r\n const prefix = content.substring(0, this.pos);\r\n const suffix = content.substring(this.pos + this.toRemove.length);\r\n\r\n // TODO: throw error if toRemove doesn't match removed string.\r\n return host.write(this.path, `${prefix}${suffix}`);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Will replace text from the source code.\r\n */\r\nexport class ReplaceChange implements Change {\r\n order: number;\r\n description: string;\r\n\r\n constructor(public path: string, private pos: number, private oldText: string,\r\n private newText: string) {\r\n if (pos < 0) {\r\n throw new Error('Negative positions are invalid');\r\n }\r\n this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;\r\n this.order = pos;\r\n }\r\n\r\n apply(host: Host): Promise<void> {\r\n return host.read(this.path).then(content => {\r\n const prefix = content.substring(0, this.pos);\r\n const suffix = content.substring(this.pos + this.oldText.length);\r\n const text = content.substring(this.pos, this.pos + this.oldText.length);\r\n\r\n if (text !== this.oldText) {\r\n return Promise.reject(new Error(`Invalid replace: \"${text}\" != \"${this.oldText}\".`));\r\n }\r\n\r\n // TODO: throw error if oldText doesn't match removed string.\r\n return host.write(this.path, `${prefix}${this.newText}${suffix}`);\r\n });\r\n }\r\n}\r\n"]}
|
|
@@ -1,127 +1,127 @@
|
|
|
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
|
-
export interface Host {
|
|
9
|
-
write(path: string, content: string): Promise<void>;
|
|
10
|
-
read(path: string): Promise<string>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export interface Change {
|
|
15
|
-
apply(host: Host): Promise<void>;
|
|
16
|
-
|
|
17
|
-
// The file this change should be applied to. Some changes might not apply to
|
|
18
|
-
// a file (maybe the config).
|
|
19
|
-
readonly path: string | null;
|
|
20
|
-
|
|
21
|
-
// The order this change should be applied. Normally the position inside the file.
|
|
22
|
-
// Changes are applied from the bottom of a file to the top.
|
|
23
|
-
readonly order: number;
|
|
24
|
-
|
|
25
|
-
// The description of this change. This will be outputted in a dry or verbose run.
|
|
26
|
-
readonly description: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* An operation that does nothing.
|
|
32
|
-
*/
|
|
33
|
-
export class NoopChange implements Change {
|
|
34
|
-
description = 'No operation.';
|
|
35
|
-
order = Infinity;
|
|
36
|
-
path = null;
|
|
37
|
-
apply() { return Promise.resolve(); }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Will add text to the source code.
|
|
43
|
-
*/
|
|
44
|
-
export class InsertChange implements Change {
|
|
45
|
-
|
|
46
|
-
order: number;
|
|
47
|
-
description: string;
|
|
48
|
-
|
|
49
|
-
constructor(public path: string, public pos: number, public toAdd: string) {
|
|
50
|
-
if (pos < 0) {
|
|
51
|
-
throw new Error('Negative positions are invalid');
|
|
52
|
-
}
|
|
53
|
-
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
54
|
-
this.order = pos;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* This method does not insert spaces if there is none in the original string.
|
|
59
|
-
*/
|
|
60
|
-
apply(host: Host) {
|
|
61
|
-
return host.read(this.path).then(content => {
|
|
62
|
-
const prefix = content.substring(0, this.pos);
|
|
63
|
-
const suffix = content.substring(this.pos);
|
|
64
|
-
|
|
65
|
-
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Will remove text from the source code.
|
|
72
|
-
*/
|
|
73
|
-
export class RemoveChange implements Change {
|
|
74
|
-
|
|
75
|
-
order: number;
|
|
76
|
-
description: string;
|
|
77
|
-
|
|
78
|
-
constructor(public path: string, private pos: number, private toRemove: string) {
|
|
79
|
-
if (pos < 0) {
|
|
80
|
-
throw new Error('Negative positions are invalid');
|
|
81
|
-
}
|
|
82
|
-
this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
|
|
83
|
-
this.order = pos;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
apply(host: Host): Promise<void> {
|
|
87
|
-
return host.read(this.path).then(content => {
|
|
88
|
-
const prefix = content.substring(0, this.pos);
|
|
89
|
-
const suffix = content.substring(this.pos + this.toRemove.length);
|
|
90
|
-
|
|
91
|
-
// TODO: throw error if toRemove doesn't match removed string.
|
|
92
|
-
return host.write(this.path, `${prefix}${suffix}`);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Will replace text from the source code.
|
|
99
|
-
*/
|
|
100
|
-
export class ReplaceChange implements Change {
|
|
101
|
-
order: number;
|
|
102
|
-
description: string;
|
|
103
|
-
|
|
104
|
-
constructor(public path: string, private pos: number, private oldText: string,
|
|
105
|
-
private newText: string) {
|
|
106
|
-
if (pos < 0) {
|
|
107
|
-
throw new Error('Negative positions are invalid');
|
|
108
|
-
}
|
|
109
|
-
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
110
|
-
this.order = pos;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
apply(host: Host): Promise<void> {
|
|
114
|
-
return host.read(this.path).then(content => {
|
|
115
|
-
const prefix = content.substring(0, this.pos);
|
|
116
|
-
const suffix = content.substring(this.pos + this.oldText.length);
|
|
117
|
-
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
118
|
-
|
|
119
|
-
if (text !== this.oldText) {
|
|
120
|
-
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// TODO: throw error if oldText doesn't match removed string.
|
|
124
|
-
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
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
|
+
export interface Host {
|
|
9
|
+
write(path: string, content: string): Promise<void>;
|
|
10
|
+
read(path: string): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export interface Change {
|
|
15
|
+
apply(host: Host): Promise<void>;
|
|
16
|
+
|
|
17
|
+
// The file this change should be applied to. Some changes might not apply to
|
|
18
|
+
// a file (maybe the config).
|
|
19
|
+
readonly path: string | null;
|
|
20
|
+
|
|
21
|
+
// The order this change should be applied. Normally the position inside the file.
|
|
22
|
+
// Changes are applied from the bottom of a file to the top.
|
|
23
|
+
readonly order: number;
|
|
24
|
+
|
|
25
|
+
// The description of this change. This will be outputted in a dry or verbose run.
|
|
26
|
+
readonly description: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* An operation that does nothing.
|
|
32
|
+
*/
|
|
33
|
+
export class NoopChange implements Change {
|
|
34
|
+
description = 'No operation.';
|
|
35
|
+
order = Infinity;
|
|
36
|
+
path = null;
|
|
37
|
+
apply() { return Promise.resolve(); }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Will add text to the source code.
|
|
43
|
+
*/
|
|
44
|
+
export class InsertChange implements Change {
|
|
45
|
+
|
|
46
|
+
order: number;
|
|
47
|
+
description: string;
|
|
48
|
+
|
|
49
|
+
constructor(public path: string, public pos: number, public toAdd: string) {
|
|
50
|
+
if (pos < 0) {
|
|
51
|
+
throw new Error('Negative positions are invalid');
|
|
52
|
+
}
|
|
53
|
+
this.description = `Inserted ${toAdd} into position ${pos} of ${path}`;
|
|
54
|
+
this.order = pos;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* This method does not insert spaces if there is none in the original string.
|
|
59
|
+
*/
|
|
60
|
+
apply(host: Host) {
|
|
61
|
+
return host.read(this.path).then(content => {
|
|
62
|
+
const prefix = content.substring(0, this.pos);
|
|
63
|
+
const suffix = content.substring(this.pos);
|
|
64
|
+
|
|
65
|
+
return host.write(this.path, `${prefix}${this.toAdd}${suffix}`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Will remove text from the source code.
|
|
72
|
+
*/
|
|
73
|
+
export class RemoveChange implements Change {
|
|
74
|
+
|
|
75
|
+
order: number;
|
|
76
|
+
description: string;
|
|
77
|
+
|
|
78
|
+
constructor(public path: string, private pos: number, private toRemove: string) {
|
|
79
|
+
if (pos < 0) {
|
|
80
|
+
throw new Error('Negative positions are invalid');
|
|
81
|
+
}
|
|
82
|
+
this.description = `Removed ${toRemove} into position ${pos} of ${path}`;
|
|
83
|
+
this.order = pos;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
apply(host: Host): Promise<void> {
|
|
87
|
+
return host.read(this.path).then(content => {
|
|
88
|
+
const prefix = content.substring(0, this.pos);
|
|
89
|
+
const suffix = content.substring(this.pos + this.toRemove.length);
|
|
90
|
+
|
|
91
|
+
// TODO: throw error if toRemove doesn't match removed string.
|
|
92
|
+
return host.write(this.path, `${prefix}${suffix}`);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Will replace text from the source code.
|
|
99
|
+
*/
|
|
100
|
+
export class ReplaceChange implements Change {
|
|
101
|
+
order: number;
|
|
102
|
+
description: string;
|
|
103
|
+
|
|
104
|
+
constructor(public path: string, private pos: number, private oldText: string,
|
|
105
|
+
private newText: string) {
|
|
106
|
+
if (pos < 0) {
|
|
107
|
+
throw new Error('Negative positions are invalid');
|
|
108
|
+
}
|
|
109
|
+
this.description = `Replaced ${oldText} into position ${pos} of ${path} with ${newText}`;
|
|
110
|
+
this.order = pos;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
apply(host: Host): Promise<void> {
|
|
114
|
+
return host.read(this.path).then(content => {
|
|
115
|
+
const prefix = content.substring(0, this.pos);
|
|
116
|
+
const suffix = content.substring(this.pos + this.oldText.length);
|
|
117
|
+
const text = content.substring(this.pos, this.pos + this.oldText.length);
|
|
118
|
+
|
|
119
|
+
if (text !== this.oldText) {
|
|
120
|
+
return Promise.reject(new Error(`Invalid replace: "${text}" != "${this.oldText}".`));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// TODO: throw error if oldText doesn't match removed string.
|
|
124
|
+
return host.write(this.path, `${prefix}${this.newText}${suffix}`);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
-
export declare function buildComponent(options: any): Rule;
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
export declare function buildComponent(options: any): Rule;
|