@openrewrite/recipes-angular 1.33.0 → 1.34.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/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/libraries/components/lst.d.ts +7 -0
- package/dist/libraries/components/lst.d.ts.map +1 -1
- package/dist/libraries/components/lst.js +11 -0
- package/dist/libraries/components/lst.js.map +1 -1
- package/dist/libraries/components/package-version.d.ts +7 -2
- package/dist/libraries/components/package-version.d.ts.map +1 -1
- package/dist/libraries/components/package-version.js +5 -3
- package/dist/libraries/components/package-version.js.map +1 -1
- package/dist/libraries/components/symbols.d.ts +3 -0
- package/dist/libraries/components/symbols.d.ts.map +1 -1
- package/dist/libraries/components/symbols.js +8 -0
- package/dist/libraries/components/symbols.js.map +1 -1
- package/dist/libraries/ng-inline-svg/migrate-ng-inline-svg.d.ts +127 -0
- package/dist/libraries/ng-inline-svg/migrate-ng-inline-svg.d.ts.map +1 -0
- package/dist/libraries/ng-inline-svg/migrate-ng-inline-svg.js +708 -0
- package/dist/libraries/ng-inline-svg/migrate-ng-inline-svg.js.map +1 -0
- package/dist/libraries/ng2-cookies/migrate-ng2-cookies.d.ts +60 -0
- package/dist/libraries/ng2-cookies/migrate-ng2-cookies.d.ts.map +1 -0
- package/dist/libraries/ng2-cookies/migrate-ng2-cookies.js +472 -0
- package/dist/libraries/ng2-cookies/migrate-ng2-cookies.js.map +1 -0
- package/dist/migration/package-major.d.ts +43 -0
- package/dist/migration/package-major.d.ts.map +1 -0
- package/dist/migration/package-major.js +100 -0
- package/dist/migration/package-major.js.map +1 -0
- package/dist/migration/replace-platform-browser-dynamic.d.ts +32 -0
- package/dist/migration/replace-platform-browser-dynamic.d.ts.map +1 -0
- package/dist/migration/replace-platform-browser-dynamic.js +212 -0
- package/dist/migration/replace-platform-browser-dynamic.js.map +1 -0
- package/dist/migration/upgrade-to-angular-20.d.ts.map +1 -1
- package/dist/migration/upgrade-to-angular-20.js +4 -1
- package/dist/migration/upgrade-to-angular-20.js.map +1 -1
- package/dist/migration/use-angular-build-builders.d.ts +51 -0
- package/dist/migration/use-angular-build-builders.d.ts.map +1 -0
- package/dist/migration/use-angular-build-builders.js +280 -0
- package/dist/migration/use-angular-build-builders.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +19 -0
- package/src/libraries/components/lst.ts +11 -0
- package/src/libraries/components/package-version.ts +7 -7
- package/src/libraries/components/symbols.ts +7 -0
- package/src/libraries/ng-inline-svg/migrate-ng-inline-svg.ts +613 -0
- package/src/libraries/ng2-cookies/migrate-ng2-cookies.ts +425 -0
- package/src/migration/package-major.ts +93 -0
- package/src/migration/replace-platform-browser-dynamic.ts +197 -0
- package/src/migration/upgrade-to-angular-20.ts +4 -1
- package/src/migration/use-angular-build-builders.ts +285 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, ScanningRecipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
/** The result of moving the `[inlineSVG]` elements of a template, and whether one was left for a hand migration. */
|
|
3
|
+
interface Migrated {
|
|
4
|
+
text: string;
|
|
5
|
+
flagged: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Moves each `[inlineSVG]` of a template into an `<svg-icon>` child of the element it was on: the element keeps its
|
|
9
|
+
* other attributes and structural directives, and the SVG is inserted below it as before, one element deeper.
|
|
10
|
+
*/
|
|
11
|
+
export declare function migrateTemplate(template: string, major: number): Migrated;
|
|
12
|
+
/** Moves `[inlineSVG]` to `<svg-icon>` in `.html` templates and in the inline `template` of components. */
|
|
13
|
+
export declare class MigrateInlineSvgTemplates extends ScanningRecipe<Map<string, number>> {
|
|
14
|
+
private readonly requires?;
|
|
15
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.MigrateInlineSvgTemplates";
|
|
16
|
+
readonly displayName: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
/** @param requires a package that the `package.json` of a project must declare for its code to move. */
|
|
19
|
+
constructor(requires?: string | undefined);
|
|
20
|
+
initialValue(_ctx: ExecutionContext): Map<string, number>;
|
|
21
|
+
scanner(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
22
|
+
editorWithData(majors: Map<string, number>): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
23
|
+
}
|
|
24
|
+
/** The projects of a repository, by the directories of their `package.json`, and the Angular major each tells within one major. */
|
|
25
|
+
interface Packages {
|
|
26
|
+
dirs: Map<string, string>;
|
|
27
|
+
majors: Map<string, number>;
|
|
28
|
+
}
|
|
29
|
+
/** What each project does with `InlineSVGModule`. */
|
|
30
|
+
interface Projects extends Packages {
|
|
31
|
+
/** The projects that call `InlineSVGModule.forRoot()` somewhere. */
|
|
32
|
+
forRoot: Set<string>;
|
|
33
|
+
/** The projects with an `@NgModule` that imports `InlineSVGModule`. */
|
|
34
|
+
ngModuleImports: Set<string>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Calls `InlineSVGModule.forRoot()` in the `imports` of each `@NgModule` of a project that never calls it, since
|
|
38
|
+
* `ng-inline-svg` provides its cache from the root injector by itself, while `angular-svg-icon` provides its registry only
|
|
39
|
+
* through `forRoot()`. Its registry reuses one that a parent injector has, so a lazy module that calls `forRoot()` too
|
|
40
|
+
* shares the root one. A standalone component of a project with no `@NgModule` to provide it is flagged.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ProvideSvgIconRegistry extends ScanningRecipe<Projects> {
|
|
43
|
+
private readonly requires?;
|
|
44
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.ProvideSvgIconRegistry";
|
|
45
|
+
readonly displayName: string;
|
|
46
|
+
readonly description: string;
|
|
47
|
+
/** @param requires a package that the `package.json` of a project must declare for its code to move. */
|
|
48
|
+
constructor(requires?: string | undefined);
|
|
49
|
+
initialValue(_ctx: ExecutionContext): Projects;
|
|
50
|
+
scanner(projects: Projects): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
51
|
+
editorWithData(projects: Projects): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The files with a template that `MigrateInlineSvgTemplates` flags, on the majors that carry every option of `CARRIED`
|
|
55
|
+
* over (`flagged`) and on those that carry none (`flaggedEarlier`). The majors are not all known while the scan runs.
|
|
56
|
+
*/
|
|
57
|
+
interface Templates extends Packages {
|
|
58
|
+
flagged: Set<string>;
|
|
59
|
+
flaggedEarlier: Set<string>;
|
|
60
|
+
/** The `.html` files among the sources. */
|
|
61
|
+
html: Set<string>;
|
|
62
|
+
/** The file each `templateUrl` names, by the component that names it. */
|
|
63
|
+
templateUrls: Map<string, string>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Moves the imports of `InlineSVGModule` and `InlineSVGDirective` to `AngularSvgIconModule` and `SvgIconComponent`. A
|
|
67
|
+
* project with a template that `MigrateInlineSvgTemplates` flags still needs `ng-inline-svg` for it, so there each
|
|
68
|
+
* stays, and its counterpart joins it in the `imports` of each decorator: the `<svg-icon>` of the migrated templates
|
|
69
|
+
* then compiles beside the `[inlineSVG]` left.
|
|
70
|
+
*/
|
|
71
|
+
export declare class MoveInlineSvgImports extends ScanningRecipe<Templates> {
|
|
72
|
+
private readonly requires?;
|
|
73
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.MoveInlineSvgImports";
|
|
74
|
+
readonly displayName: string;
|
|
75
|
+
readonly description: string;
|
|
76
|
+
/** @param requires a package that the `package.json` of a project must declare for its code to move. */
|
|
77
|
+
constructor(requires?: string | undefined);
|
|
78
|
+
initialValue(_ctx: ExecutionContext): Templates;
|
|
79
|
+
scanner(templates: Templates): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
80
|
+
editorWithData(templates: Templates): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
81
|
+
}
|
|
82
|
+
/** Flags `InlineSVGModule.forRoot(config)`, whose options `angular-svg-icon` does not have. */
|
|
83
|
+
export declare class FindInlineSvgForRootConfig extends Recipe {
|
|
84
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.FindInlineSvgForRootConfig";
|
|
85
|
+
readonly displayName: string;
|
|
86
|
+
readonly description: string;
|
|
87
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
88
|
+
}
|
|
89
|
+
/** Flags each import of `ng-inline-svg` that the migration left, such as `SVGCacheService` or `InlineSVGConfig`. */
|
|
90
|
+
export declare class FindNgInlineSvgUsage extends Recipe {
|
|
91
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.FindNgInlineSvgUsage";
|
|
92
|
+
readonly displayName: string;
|
|
93
|
+
readonly description: string;
|
|
94
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Migrates `ng-inline-svg`, unmaintained since Angular 12, to `angular-svg-icon`.
|
|
98
|
+
*
|
|
99
|
+
* Both fetch the SVG with `HttpClient` and insert it into the page. `InlineSVGModule` becomes `AngularSvgIconModule`
|
|
100
|
+
* (with `forRoot()` where it had it), `InlineSVGDirective` in the `imports` of a standalone component becomes
|
|
101
|
+
* `SvgIconComponent`, and each `[inlineSVG]` of a template becomes an `<svg-icon [src]>` inside its element.
|
|
102
|
+
*
|
|
103
|
+
* @see https://github.com/arkon/ng-inline-svg
|
|
104
|
+
* @see https://github.com/czeckd/angular-svg-icon
|
|
105
|
+
*/
|
|
106
|
+
export declare class MigrateNgInlineSvgCodeChanges extends Recipe {
|
|
107
|
+
private readonly requires?;
|
|
108
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.MigrateNgInlineSvgCodeChanges";
|
|
109
|
+
readonly displayName: string;
|
|
110
|
+
readonly description: string;
|
|
111
|
+
/** @param requires a package that the `package.json` of a project must declare for its code to move. */
|
|
112
|
+
constructor(requires?: string | undefined);
|
|
113
|
+
recipeList(): Promise<Recipe[]>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `angular-svg-icon` at the Angular major of each `package.json` that declares `ng-inline-svg`, then the code changes
|
|
117
|
+
* where it was added, in the next cycle, and then `ng-inline-svg` removed where nothing imports it any more.
|
|
118
|
+
*/
|
|
119
|
+
export declare class MigrateNgInlineSvgToAngularSvgIcon extends Recipe {
|
|
120
|
+
readonly name = "org.openrewrite.angular.nginlinesvg.MigrateNgInlineSvgToAngularSvgIcon";
|
|
121
|
+
readonly displayName: string;
|
|
122
|
+
readonly description: string;
|
|
123
|
+
readonly causesAnotherCycle = true;
|
|
124
|
+
recipeList(): Promise<Recipe[]>;
|
|
125
|
+
}
|
|
126
|
+
export {};
|
|
127
|
+
//# sourceMappingURL=migrate-ng-inline-svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-ng-inline-svg.d.ts","sourceRoot":"","sources":["../../../src/libraries/ng-inline-svg/migrate-ng-inline-svg.ts"],"names":[],"mappings":"AAMA,OAAO,EAAe,gBAAgB,EAAqB,MAAM,EAAE,cAAc,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAiD5H,oHAAoH;AACpH,UAAU,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAuBzE;AAED,2GAA2G;AAC3G,qBAAa,yBAA0B,SAAQ,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAWlE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAVtC,QAAQ,CAAC,IAAI,mEAAmE;IAChF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAqD;IACjF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAK6E;IAEzG,wGAAwG;gBAC3E,QAAQ,CAAC,EAAE,MAAM,YAAA;I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