@openrewrite/recipes-angular 1.21.0 → 1.22.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.
Files changed (168) hide show
  1. package/dist/libraries/primeng/18/add-primeng-provider.d.ts.map +1 -1
  2. package/dist/libraries/primeng/18/add-primeng-provider.js +6 -22
  3. package/dist/libraries/primeng/18/add-primeng-provider.js.map +1 -1
  4. package/dist/libraries/primeng/18/mark-removed-primeng-modules.js +1 -1
  5. package/dist/libraries/primeng/18/mark-removed-primeng-modules.js.map +1 -1
  6. package/dist/libraries/primeng/18/migrate-p-fluid-to-wrapper.js +1 -1
  7. package/dist/libraries/primeng/18/migrate-p-fluid-to-wrapper.js.map +1 -1
  8. package/dist/migration/add-default-configuration.d.ts.map +1 -1
  9. package/dist/migration/add-default-configuration.js +8 -48
  10. package/dist/migration/add-default-configuration.js.map +1 -1
  11. package/dist/migration/add-eager-change-detection.js +1 -1
  12. package/dist/migration/add-eager-change-detection.js.map +1 -1
  13. package/dist/migration/add-istanbul-instrumenter.d.ts.map +1 -1
  14. package/dist/migration/add-istanbul-instrumenter.js +8 -22
  15. package/dist/migration/add-istanbul-instrumenter.js.map +1 -1
  16. package/dist/migration/add-module-with-providers-generic.js +1 -1
  17. package/dist/migration/add-module-with-providers-generic.js.map +1 -1
  18. package/dist/migration/add-static-false-to-view-queries.d.ts +11 -0
  19. package/dist/migration/add-static-false-to-view-queries.d.ts.map +1 -1
  20. package/dist/migration/add-static-false-to-view-queries.js +329 -36
  21. package/dist/migration/add-static-false-to-view-queries.js.map +1 -1
  22. package/dist/migration/add-strict-templates-false.d.ts.map +1 -1
  23. package/dist/migration/add-strict-templates-false.js +4 -35
  24. package/dist/migration/add-strict-templates-false.js.map +1 -1
  25. package/dist/migration/add-trust-proxy-headers.js +1 -1
  26. package/dist/migration/add-trust-proxy-headers.js.map +1 -1
  27. package/dist/migration/angular-http-support.d.ts +0 -1
  28. package/dist/migration/angular-http-support.d.ts.map +1 -1
  29. package/dist/migration/angular-http-support.js +1 -5
  30. package/dist/migration/angular-http-support.js.map +1 -1
  31. package/dist/migration/enable-aot-build.d.ts.map +1 -1
  32. package/dist/migration/enable-aot-build.js +8 -57
  33. package/dist/migration/enable-aot-build.js.map +1 -1
  34. package/dist/migration/explicit-standalone-flag.js +2 -2
  35. package/dist/migration/explicit-standalone-flag.js.map +1 -1
  36. package/dist/migration/js-support.d.ts +4 -0
  37. package/dist/migration/js-support.d.ts.map +1 -1
  38. package/dist/migration/js-support.js +12 -0
  39. package/dist/migration/js-support.js.map +1 -1
  40. package/dist/migration/json-support.d.ts +0 -11
  41. package/dist/migration/json-support.d.ts.map +1 -1
  42. package/dist/migration/json-support.js +1 -96
  43. package/dist/migration/json-support.js.map +1 -1
  44. package/dist/migration/migrate-input-to-signal.js +1 -1
  45. package/dist/migration/migrate-input-to-signal.js.map +1 -1
  46. package/dist/migration/migrate-model-with-output.js +1 -1
  47. package/dist/migration/migrate-model-with-output.js.map +1 -1
  48. package/dist/migration/migrate-query-to-signal.js +1 -1
  49. package/dist/migration/migrate-query-to-signal.js.map +1 -1
  50. package/dist/migration/migrate-to-solution-style-tsconfig.d.ts.map +1 -1
  51. package/dist/migration/migrate-to-solution-style-tsconfig.js +25 -56
  52. package/dist/migration/migrate-to-solution-style-tsconfig.js.map +1 -1
  53. package/dist/migration/remove-aot-summaries.js +1 -1
  54. package/dist/migration/remove-aot-summaries.js.map +1 -1
  55. package/dist/migration/remove-browser-module-with-server-transition.d.ts.map +1 -1
  56. package/dist/migration/remove-browser-module-with-server-transition.js +6 -16
  57. package/dist/migration/remove-browser-module-with-server-transition.js.map +1 -1
  58. package/dist/migration/remove-default-project.d.ts.map +1 -1
  59. package/dist/migration/remove-default-project.js +1 -17
  60. package/dist/migration/remove-default-project.js.map +1 -1
  61. package/dist/migration/remove-enable-ivy.d.ts.map +1 -1
  62. package/dist/migration/remove-enable-ivy.js +2 -15
  63. package/dist/migration/remove-enable-ivy.js.map +1 -1
  64. package/dist/migration/remove-entry-components.js +1 -1
  65. package/dist/migration/remove-entry-components.js.map +1 -1
  66. package/dist/migration/remove-es5-browser-support.d.ts.map +1 -1
  67. package/dist/migration/remove-es5-browser-support.js +2 -15
  68. package/dist/migration/remove-es5-browser-support.js.map +1 -1
  69. package/dist/migration/remove-extract-css.d.ts.map +1 -1
  70. package/dist/migration/remove-extract-css.js +2 -15
  71. package/dist/migration/remove-extract-css.js.map +1 -1
  72. package/dist/migration/remove-ie-polyfills.d.ts.map +1 -1
  73. package/dist/migration/remove-ie-polyfills.js +4 -18
  74. package/dist/migration/remove-ie-polyfills.js.map +1 -1
  75. package/dist/migration/remove-module-id.js +1 -1
  76. package/dist/migration/remove-module-id.js.map +1 -1
  77. package/dist/migration/remove-relative-link-resolution.js +1 -1
  78. package/dist/migration/remove-relative-link-resolution.js.map +1 -1
  79. package/dist/migration/remove-standalone-true.js +1 -1
  80. package/dist/migration/remove-standalone-true.js.map +1 -1
  81. package/dist/migration/remove-static-false.js +1 -1
  82. package/dist/migration/remove-static-false.js.map +1 -1
  83. package/dist/migration/remove-zone-js-polyfill.d.ts.map +1 -1
  84. package/dist/migration/remove-zone-js-polyfill.js +4 -18
  85. package/dist/migration/remove-zone-js-polyfill.js.map +1 -1
  86. package/dist/migration/rename-check-no-changes.d.ts.map +1 -1
  87. package/dist/migration/rename-check-no-changes.js +2 -4
  88. package/dist/migration/rename-check-no-changes.js.map +1 -1
  89. package/dist/migration/rename-ssr-experimental-platform.js +8 -28
  90. package/dist/migration/rename-ssr-experimental-platform.js.map +1 -1
  91. package/dist/migration/replace-deep-zone-js-imports.d.ts.map +1 -1
  92. package/dist/migration/replace-deep-zone-js-imports.js +6 -27
  93. package/dist/migration/replace-deep-zone-js-imports.js.map +1 -1
  94. package/dist/migration/replace-http-client-module.js +1 -1
  95. package/dist/migration/replace-http-client-module.js.map +1 -1
  96. package/dist/migration/replace-initial-navigation.d.ts.map +1 -1
  97. package/dist/migration/replace-initial-navigation.js +8 -8
  98. package/dist/migration/replace-initial-navigation.js.map +1 -1
  99. package/dist/migration/set-tsconfig-module-resolution-bundler.d.ts.map +1 -1
  100. package/dist/migration/set-tsconfig-module-resolution-bundler.js +7 -56
  101. package/dist/migration/set-tsconfig-module-resolution-bundler.js.map +1 -1
  102. package/dist/migration/suppress-safe-navigation-diagnostics.d.ts.map +1 -1
  103. package/dist/migration/suppress-safe-navigation-diagnostics.js +6 -8
  104. package/dist/migration/suppress-safe-navigation-diagnostics.js.map +1 -1
  105. package/dist/migration/update-component-template-url.d.ts.map +1 -1
  106. package/dist/migration/update-component-template-url.js +2 -2
  107. package/dist/migration/update-component-template-url.js.map +1 -1
  108. package/dist/migration/update-tsconfig-module.d.ts.map +1 -1
  109. package/dist/migration/update-tsconfig-module.js +8 -40
  110. package/dist/migration/update-tsconfig-module.js.map +1 -1
  111. package/dist/migration/update-tsconfig-target.d.ts.map +1 -1
  112. package/dist/migration/update-tsconfig-target.js +5 -34
  113. package/dist/migration/update-tsconfig-target.js.map +1 -1
  114. package/dist/migration/upgrade-angular-dependencies.js +2 -2
  115. package/dist/migration/upgrade-angular-dependencies.js.map +1 -1
  116. package/dist/migration/upgrade-to-angular-8.js +1 -1
  117. package/dist/migration/upgrade-to-angular-8.js.map +1 -1
  118. package/dist/search/find-empty-projectable-nodes.js +1 -1
  119. package/dist/search/find-empty-projectable-nodes.js.map +1 -1
  120. package/dist/search/find-provided-in-deprecated-usage.js +1 -1
  121. package/dist/search/find-provided-in-deprecated-usage.js.map +1 -1
  122. package/package.json +2 -2
  123. package/src/libraries/primeng/18/add-primeng-provider.ts +10 -36
  124. package/src/libraries/primeng/18/mark-removed-primeng-modules.ts +3 -3
  125. package/src/libraries/primeng/18/migrate-p-fluid-to-wrapper.ts +3 -3
  126. package/src/migration/add-default-configuration.ts +7 -71
  127. package/src/migration/add-eager-change-detection.ts +3 -3
  128. package/src/migration/add-istanbul-instrumenter.ts +9 -23
  129. package/src/migration/add-module-with-providers-generic.ts +3 -3
  130. package/src/migration/add-static-false-to-view-queries.ts +317 -40
  131. package/src/migration/add-strict-templates-false.ts +8 -39
  132. package/src/migration/add-trust-proxy-headers.ts +4 -4
  133. package/src/migration/angular-http-support.ts +2 -5
  134. package/src/migration/enable-aot-build.ts +10 -97
  135. package/src/migration/explicit-standalone-flag.ts +5 -5
  136. package/src/migration/js-support.ts +13 -1
  137. package/src/migration/json-support.ts +2 -102
  138. package/src/migration/migrate-input-to-signal.ts +3 -3
  139. package/src/migration/migrate-model-with-output.ts +3 -3
  140. package/src/migration/migrate-query-to-signal.ts +3 -3
  141. package/src/migration/migrate-to-solution-style-tsconfig.ts +29 -68
  142. package/src/migration/remove-aot-summaries.ts +3 -3
  143. package/src/migration/remove-browser-module-with-server-transition.ts +7 -27
  144. package/src/migration/remove-default-project.ts +2 -29
  145. package/src/migration/remove-enable-ivy.ts +3 -27
  146. package/src/migration/remove-entry-components.ts +3 -3
  147. package/src/migration/remove-es5-browser-support.ts +3 -27
  148. package/src/migration/remove-extract-css.ts +3 -27
  149. package/src/migration/remove-ie-polyfills.ts +5 -29
  150. package/src/migration/remove-module-id.ts +3 -3
  151. package/src/migration/remove-relative-link-resolution.ts +3 -3
  152. package/src/migration/remove-standalone-true.ts +3 -3
  153. package/src/migration/remove-static-false.ts +3 -3
  154. package/src/migration/remove-zone-js-polyfill.ts +5 -29
  155. package/src/migration/rename-check-no-changes.ts +3 -5
  156. package/src/migration/rename-ssr-experimental-platform.ts +8 -23
  157. package/src/migration/replace-deep-zone-js-imports.ts +11 -40
  158. package/src/migration/replace-http-client-module.ts +3 -3
  159. package/src/migration/replace-initial-navigation.ts +10 -14
  160. package/src/migration/set-tsconfig-module-resolution-bundler.ts +8 -52
  161. package/src/migration/suppress-safe-navigation-diagnostics.ts +8 -14
  162. package/src/migration/update-component-template-url.ts +4 -8
  163. package/src/migration/update-tsconfig-module.ts +10 -49
  164. package/src/migration/update-tsconfig-target.ts +6 -35
  165. package/src/migration/upgrade-angular-dependencies.ts +2 -2
  166. package/src/migration/upgrade-to-angular-8.ts +1 -1
  167. package/src/search/find-empty-projectable-nodes.ts +3 -3
  168. package/src/search/find-provided-in-deprecated-usage.ts +3 -3
@@ -5,29 +5,17 @@
5
5
  */
6
6
 
7
7
  import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
- import {getMemberKeyName, isLiteral, isMember, isObject, Json, JsonVisitor} from "@openrewrite/rewrite/json";
8
+ import {Json, jsonLiteral, JsonVisitor, toPlain, updateAt, valueAt} from "@openrewrite/rewrite/json";
9
9
 
10
10
  function isTsconfig(sourcePath: string): boolean {
11
11
  const basename = sourcePath.split('/').pop() ?? '';
12
12
  return basename.startsWith('tsconfig') && basename.endsWith('.json');
13
13
  }
14
14
 
15
- function compilerOptionValue(root: Json.Object, key: string): string | undefined {
16
- const co = root.members
17
- .map(rp => rp.element)
18
- .filter(isMember)
19
- .find(m => getMemberKeyName(m as Json.Member) === 'compilerOptions');
20
- if (!co || !isObject((co as Json.Member).value)) return undefined;
21
- const options = (co as Json.Member).value as Json.Object;
22
- const found = options.members
23
- .map(rp => rp.element)
24
- .filter(isMember)
25
- .find(m => getMemberKeyName(m as Json.Member) === key);
26
- if (!found) return undefined;
27
- const val = (found as Json.Member).value;
28
- if (!isLiteral(val)) return undefined;
29
- const literal = (val as Json.Literal).value;
30
- return typeof literal === 'string' ? literal : undefined;
15
+ function compilerOptionValue(doc: Json.Document, key: string): string | undefined {
16
+ const value = valueAt(doc, ['compilerOptions', key]);
17
+ const plain = value && toPlain(value);
18
+ return typeof plain === 'string' ? plain : undefined;
31
19
  }
32
20
 
33
21
  export class SetTsconfigModuleResolutionBundler extends Recipe {
@@ -39,48 +27,16 @@ export class SetTsconfigModuleResolutionBundler extends Recipe {
39
27
 
40
28
  async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
41
29
  return new class extends JsonVisitor<ExecutionContext> {
42
- private inCompilerOptions = false;
43
-
44
30
  protected async visitDocument(doc: Json.Document, p: ExecutionContext): Promise<Json | undefined> {
45
31
  if (!isTsconfig(doc.sourcePath)) return doc;
46
- const root = doc.value;
47
- if (!isObject(root)) return doc;
48
32
 
49
- const moduleResolution = compilerOptionValue(root as Json.Object, 'moduleResolution');
33
+ const moduleResolution = compilerOptionValue(doc, 'moduleResolution');
50
34
  if (moduleResolution === undefined || moduleResolution.toLowerCase() === 'bundler') return doc;
51
35
 
52
- const module = compilerOptionValue(root as Json.Object, 'module');
36
+ const module = compilerOptionValue(doc, 'module');
53
37
  if (module !== undefined && module.toLowerCase() === 'preserve') return doc;
54
38
 
55
- return super.visitDocument(doc, p);
56
- }
57
-
58
- protected async visitMember(member: Json.Member, p: ExecutionContext): Promise<Json | undefined> {
59
- const key = getMemberKeyName(member);
60
- if (key === 'compilerOptions' && isObject(member.value)) {
61
- this.inCompilerOptions = true;
62
- try {
63
- return await super.visitMember(member, p);
64
- } finally {
65
- this.inCompilerOptions = false;
66
- }
67
- }
68
-
69
- if (this.inCompilerOptions && key === 'moduleResolution' && isLiteral(member.value)) {
70
- const literal = member.value as Json.Literal;
71
- if (typeof literal.value === 'string' && literal.value.toLowerCase() !== 'bundler') {
72
- return {
73
- ...member,
74
- value: {
75
- ...literal,
76
- value: 'bundler',
77
- source: literal.source.replace(literal.value as string, 'bundler')
78
- } as Json.Literal
79
- } as Json.Member;
80
- }
81
- }
82
-
83
- return member;
39
+ return updateAt(doc, ['compilerOptions', 'moduleResolution'], () => jsonLiteral('bundler'));
84
40
  }
85
41
  }();
86
42
  }
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
- import {detectIndent, isObject, Json, JsonVisitor} from "@openrewrite/rewrite/json";
9
- import {addMemberPath, declaresAngularCompilerOptions, isRootTsconfig, literal, memberIndent} from "./json-support";
8
+ import {Json, jsonLiteral, JsonVisitor, setAt, valueAt} from "@openrewrite/rewrite/json";
9
+ import {declaresAngularCompilerOptions, isRootTsconfig} from "./json-support";
10
10
 
11
11
  const SUPPRESSED_CHECKS = ['nullishCoalescingNotNullable', 'optionalChainNotNullable'];
12
12
 
@@ -22,20 +22,14 @@ export class SuppressSafeNavigationDiagnostics extends Recipe {
22
22
  protected async visitDocument(doc: Json.Document, p: ExecutionContext): Promise<Json | undefined> {
23
23
  if (!isRootTsconfig(doc.sourcePath) && !declaresAngularCompilerOptions(doc)) return doc;
24
24
 
25
- const root = doc.value;
26
- if (!isObject(root)) return doc;
27
-
28
- const indentUnit = detectIndent(doc);
29
- const indent = memberIndent(root, indentUnit);
30
-
31
- let value = root;
25
+ let updated = doc;
32
26
  for (const check of SUPPRESSED_CHECKS) {
33
- value = addMemberPath(value,
34
- ['angularCompilerOptions', 'extendedDiagnostics', 'checks', check],
35
- literal('"suppress"', 'suppress'), indent, indentUnit);
27
+ const path = ['angularCompilerOptions', 'extendedDiagnostics', 'checks', check];
28
+ if (valueAt(updated, path) === undefined) {
29
+ updated = setAt(updated, path, jsonLiteral('suppress'), {createMissing: true});
30
+ }
36
31
  }
37
-
38
- return value === root ? doc : {...doc, value} as Json.Document;
32
+ return updated;
39
33
  }
40
34
  }();
41
35
  }
@@ -4,7 +4,7 @@
4
4
  * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
5
  */
6
6
  import {ExecutionContext, Option, Recipe, TreeVisitor} from "@openrewrite/rewrite";
7
- import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
7
+ import {JavaScriptVisitor, isObjectLiteral, JS, withStringValue} from "@openrewrite/rewrite/javascript";
8
8
  import {J, isIdentifier, isLiteral} from "@openrewrite/rewrite/java";
9
9
  import {create} from "mutative";
10
10
 
@@ -85,11 +85,11 @@ export class UpdateComponentTemplateUrl extends Recipe {
85
85
  }
86
86
 
87
87
  const firstArg = a.arguments.elements[0].element;
88
- if (firstArg.kind !== J.Kind.NewClass) {
88
+ if (!isObjectLiteral(firstArg)) {
89
89
  return a;
90
90
  }
91
91
 
92
- const newClass = firstArg as J.NewClass;
92
+ const newClass = firstArg;
93
93
  if (!newClass.body) {
94
94
  return a;
95
95
  }
@@ -161,11 +161,7 @@ export class UpdateComponentTemplateUrl extends Recipe {
161
161
 
162
162
  if (initializer && isLiteral(initializer)) {
163
163
  // Create a new literal with the updated URL
164
- const newLiteral: J.Literal = {
165
- ...initializer,
166
- value: finalUpdatedUrl,
167
- valueSource: `'${finalUpdatedUrl.replace(/'/g, "\\'")}'`
168
- };
164
+ const newLiteral = withStringValue(initializer, finalUpdatedUrl);
169
165
 
170
166
  // Create new property assignment with updated literal
171
167
  const newPropAssignment: JS.PropertyAssignment = {
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
- import {JsonVisitor, Json, getMemberKeyName, isObject, isLiteral} from "@openrewrite/rewrite/json";
8
+ import {Json, jsonLiteral, JsonVisitor, toPlain, updateAt} from "@openrewrite/rewrite/json";
9
9
 
10
10
  const OUTDATED_MODULES = ['commonjs', 'amd', 'umd', 'system', 'es2015', 'es6', 'none'];
11
11
  const OUTDATED_MODULE_RESOLUTIONS = ['classic'];
@@ -24,55 +24,16 @@ export class UpdateTsconfigModule extends Recipe {
24
24
  !doc.sourcePath.endsWith('tsconfig.lib.json')) {
25
25
  return doc;
26
26
  }
27
- return super.visitDocument(doc, p);
28
- }
29
-
30
- private inCompilerOptions = false;
31
-
32
- protected async visitMember(member: Json.Member, p: ExecutionContext): Promise<Json | undefined> {
33
- const keyName = getMemberKeyName(member);
34
-
35
- if (keyName === 'compilerOptions' && isObject(member.value)) {
36
- this.inCompilerOptions = true;
37
- try {
38
- return await super.visitMember(member, p);
39
- } finally {
40
- this.inCompilerOptions = false;
41
- }
42
- }
43
-
44
- if (!this.inCompilerOptions || !isLiteral(member.value)) return member;
45
- if (keyName !== 'module' && keyName !== 'moduleResolution') return member;
46
-
47
- const literal = member.value as Json.Literal;
48
- if (typeof literal.value !== 'string') return member;
49
-
50
- const value = literal.value.toLowerCase();
51
-
52
- if (keyName === 'module' && OUTDATED_MODULES.includes(value)) {
53
- return {
54
- ...member,
55
- value: {
56
- ...literal,
57
- value: 'esnext',
58
- source: literal.source.replace(literal.value as string, 'esnext')
59
- } as Json.Literal
60
- } as Json.Member;
61
- }
62
-
63
- if (keyName === 'moduleResolution' && OUTDATED_MODULE_RESOLUTIONS.includes(value)) {
64
- return {
65
- ...member,
66
- value: {
67
- ...literal,
68
- value: 'node',
69
- source: literal.source.replace(literal.value as string, 'node')
70
- } as Json.Literal
71
- } as Json.Member;
72
- }
73
-
74
- return member;
27
+ const updated = replaceOutdated(doc, 'module', OUTDATED_MODULES, 'esnext');
28
+ return replaceOutdated(updated, 'moduleResolution', OUTDATED_MODULE_RESOLUTIONS, 'node');
75
29
  }
76
30
  }();
77
31
  }
78
32
  }
33
+
34
+ function replaceOutdated(doc: Json.Document, option: string, outdated: string[], replacement: string): Json.Document {
35
+ return updateAt(doc, ['compilerOptions', option], old => {
36
+ const value = toPlain(old);
37
+ return typeof value === 'string' && outdated.includes(value.toLowerCase()) ? jsonLiteral(replacement) : old;
38
+ });
39
+ }
@@ -5,9 +5,9 @@
5
5
  */
6
6
 
7
7
  import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
- import {JsonVisitor, Json, getMemberKeyName, isObject, isLiteral} from "@openrewrite/rewrite/json";
8
+ import {Json, jsonLiteral, JsonVisitor, toPlain, updateAt} from "@openrewrite/rewrite/json";
9
9
 
10
- const OUTDATED_TARGETS = ['es5', 'es2015', 'es2016', 'ES5', 'ES2015', 'ES2016'];
10
+ const OUTDATED_TARGETS = ['es5', 'es2015', 'es2016'];
11
11
 
12
12
  export class UpdateTsconfigTarget extends Recipe {
13
13
  readonly name = "org.openrewrite.angular.migration.update-tsconfig-target";
@@ -23,39 +23,10 @@ export class UpdateTsconfigTarget extends Recipe {
23
23
  !doc.sourcePath.endsWith('tsconfig.lib.json')) {
24
24
  return doc;
25
25
  }
26
- return super.visitDocument(doc, p);
27
- }
28
-
29
- private inCompilerOptions = false;
30
-
31
- protected async visitMember(member: Json.Member, p: ExecutionContext): Promise<Json | undefined> {
32
- const keyName = getMemberKeyName(member);
33
-
34
- if (keyName === 'compilerOptions' && isObject(member.value)) {
35
- this.inCompilerOptions = true;
36
- try {
37
- return await super.visitMember(member, p);
38
- } finally {
39
- this.inCompilerOptions = false;
40
- }
41
- }
42
-
43
- if (this.inCompilerOptions && keyName === 'target' && isLiteral(member.value)) {
44
- const literal = member.value as Json.Literal;
45
- const value = literal.value as string;
46
- if (OUTDATED_TARGETS.includes(value)) {
47
- return {
48
- ...member,
49
- value: {
50
- ...literal,
51
- value: 'es2017',
52
- source: literal.source.replace(value, 'es2017')
53
- } as Json.Literal
54
- } as Json.Member;
55
- }
56
- }
57
-
58
- return member;
26
+ return updateAt(doc, ['compilerOptions', 'target'], old => {
27
+ const target = toPlain(old);
28
+ return typeof target === 'string' && OUTDATED_TARGETS.includes(target.toLowerCase()) ? jsonLiteral('es2017') : old;
29
+ });
59
30
  }
60
31
  }();
61
32
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import {Recipe} from "@openrewrite/rewrite";
8
- import {prepareJavaRecipe} from "@openrewrite/rewrite/rpc";
8
+ import {upgradeDependencyVersions} from "@openrewrite/rewrite/javascript";
9
9
 
10
10
  // Upgrade the maintained framework and tooling packages, rather than every package in the scope.
11
11
  // For example, @angular/flex-layout ended at 15.0.0-beta.42 and has no Angular 16 release.
@@ -18,7 +18,7 @@ const angularPackages = [
18
18
  ];
19
19
 
20
20
  export function upgradeAngularDependencies(major: number, versions: Record<string, string>): Promise<Recipe> {
21
- return prepareJavaRecipe("org.openrewrite.javascript.UpgradeDependencyVersions", {
21
+ return upgradeDependencyVersions({
22
22
  versions: {
23
23
  ...Object.fromEntries(angularPackages.map(name => [`@angular/${name}`, `${major}.x`])),
24
24
  ...versions,
@@ -44,7 +44,7 @@ export class UpgradeToAngular8 extends Recipe {
44
44
  readonly name = "org.openrewrite.angular.UpgradeToAngular8";
45
45
  readonly displayName = "Upgrade to Angular 8";
46
46
  readonly description = "Migrates Angular 7.x applications to Angular 8. " +
47
- "This includes adding the now-required `static: false` to `@ViewChild` and `@ContentChild` decorators, " +
47
+ "This includes adding the `static` flag that `@ViewChild` and `@ContentChild` now require, with the timing each query had in Angular 7 where the class shows it, " +
48
48
  "moving the `DOCUMENT` import from `@angular/platform-browser` to `@angular/common`, " +
49
49
  "removing `rxjs-compat` and flagging any remaining RxJS 5-style imports, " +
50
50
  "migrating `@angular/http` to `@angular/common/http` and flagging what has no equivalent, " +
@@ -4,7 +4,7 @@
4
4
  * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
5
  */
6
6
  import {ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
7
- import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
7
+ import {JavaScriptVisitor, isObjectLiteral, JS} from "@openrewrite/rewrite/javascript";
8
8
  import {J, isIdentifier, Type} from "@openrewrite/rewrite/java";
9
9
 
10
10
  export class FindEmptyProjectableNodes extends Recipe {
@@ -30,9 +30,9 @@ export class FindEmptyProjectableNodes extends Recipe {
30
30
 
31
31
  // The second argument is the options object { projectableNodes: [...] }
32
32
  const optionsArg = args[1].element;
33
- if (optionsArg.kind !== J.Kind.NewClass) return m;
33
+ if (!isObjectLiteral(optionsArg)) return m;
34
34
 
35
- const optionsObj = optionsArg as J.NewClass;
35
+ const optionsObj = optionsArg;
36
36
  if (!optionsObj.body) return m;
37
37
 
38
38
  for (const stmt of optionsObj.body.statements) {
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import {ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
- import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
8
+ import {JavaScriptVisitor, isObjectLiteral, JS} from "@openrewrite/rewrite/javascript";
9
9
  import {J, isIdentifier, isLiteral} from "@openrewrite/rewrite/java";
10
10
 
11
11
  const VALID_STRING_VALUES = new Set(['root', 'platform']);
@@ -29,9 +29,9 @@ export class FindProvidedInDeprecatedUsage extends Recipe {
29
29
 
30
30
  if (!a.arguments?.elements?.length) return a;
31
31
  const firstArg = a.arguments.elements[0].element;
32
- if (firstArg.kind !== J.Kind.NewClass) return a;
32
+ if (!isObjectLiteral(firstArg)) return a;
33
33
 
34
- const newClass = firstArg as J.NewClass;
34
+ const newClass = firstArg;
35
35
  if (!newClass.body) return a;
36
36
 
37
37
  for (const stmtPadded of newClass.body.statements) {