@openrewrite/recipes-angular 1.33.0 → 1.35.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-inject-flags.js +2 -2
- package/dist/migration/replace-inject-flags.js.map +1 -1
- 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-inject-flags.ts +2 -2
- 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,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 the original author or authors.
|
|
4
|
+
*
|
|
5
|
+
* Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
|
|
6
|
+
*/
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UseAngularBuildBuilders = exports.MoveToAngularBuildBuilders = void 0;
|
|
18
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
19
|
+
const json_1 = require("@openrewrite/rewrite/json");
|
|
20
|
+
const package_major_1 = require("./package-major");
|
|
21
|
+
const package_version_1 = require("../libraries/components/package-version");
|
|
22
|
+
const path_1 = require("path");
|
|
23
|
+
const lst_1 = require("../libraries/components/lst");
|
|
24
|
+
const json_support_1 = require("./json-support");
|
|
25
|
+
const DEVKIT = '@angular-devkit/build-angular';
|
|
26
|
+
const DEVKIT_PREFIX = `${DEVKIT}:`;
|
|
27
|
+
/**
|
|
28
|
+
* The `@angular-devkit/build-angular` builders that `@angular/build` has a builder of the same name and options for,
|
|
29
|
+
* by the first `@angular/build` major that has it. `@angular/build` is released in step with Angular from 18 on.
|
|
30
|
+
*/
|
|
31
|
+
const COUNTERPARTS = {
|
|
32
|
+
'application': 18,
|
|
33
|
+
'dev-server': 18,
|
|
34
|
+
'extract-i18n': 18,
|
|
35
|
+
'karma': 19,
|
|
36
|
+
'ng-packagr': 19,
|
|
37
|
+
};
|
|
38
|
+
/** The first major of `@angular-devkit/build-angular` whose projects can move to `@angular/build`. */
|
|
39
|
+
const FIRST_MAJOR = 18;
|
|
40
|
+
/** The `@angular/build` that `UseAngularBuildBuilders` adds, by the major of `@angular-devkit/build-angular`. */
|
|
41
|
+
const ANGULAR_BUILD_VERSIONS = (0, package_major_1.caretMajors)(FIRST_MAJOR, 22);
|
|
42
|
+
const blocked = (builder) => `\`${builder}\` has no counterpart in \`@angular/build\`, so this workspace keeps ` +
|
|
43
|
+
`\`${DEVKIT}\`. Move it to the \`application\` builder first, as \`ng update @angular/cli --name use-application-builder\` ` +
|
|
44
|
+
"does for `browser` and `browser-esbuild`, and the other builders of the workspace then move to `@angular/build`.";
|
|
45
|
+
const BLOCKED_MARK = 'has no counterpart in `@angular/build`';
|
|
46
|
+
const UNDECLARED = "Every builder of this workspace has a counterpart in `@angular/build`, but its `package.json` does not " +
|
|
47
|
+
"declare `@angular/build`, and the recipe adds it only where the lock file, or a constraint within one major, shows " +
|
|
48
|
+
"which major of `" + DEVKIT + "` it resolves, so the builders stay on `" + DEVKIT + "`. npm may nest `@angular/build` " +
|
|
49
|
+
"under `" + DEVKIT + "`, and pnpm always does, where the Angular CLI does not find it. Declare `@angular/build` at the " +
|
|
50
|
+
"version of `" + DEVKIT + "`, as `ng update @angular/cli --name use-application-builder` does, and the builders then move.";
|
|
51
|
+
const UNDECLARED_MARK = 'does not declare `@angular/build`';
|
|
52
|
+
/** Whether `UseAngularBuildBuilders` adds `@angular/build` to a `package.json`, as its `addDependency` gates decide. */
|
|
53
|
+
function addsAngularBuild(doc) {
|
|
54
|
+
if ((0, package_version_1.declaredVersion)(doc, DEVKIT) === undefined)
|
|
55
|
+
return false;
|
|
56
|
+
const major = (0, package_major_1.singleMajor)(doc, DEVKIT);
|
|
57
|
+
return ANGULAR_BUILD_VERSIONS.some(v => v.major === major);
|
|
58
|
+
}
|
|
59
|
+
/** Applies `fn` to every target of every project, under `architect` or its alias `targets`. */
|
|
60
|
+
function mapTargets(root, fn) {
|
|
61
|
+
return (0, json_support_1.mapObjectMember)(root, 'projects', projects => (0, json_support_1.mapObjectMembers)(projects, project => {
|
|
62
|
+
const architect = (0, json_support_1.mapObjectMember)(project, 'architect', targets => (0, json_support_1.mapObjectMembers)(targets, fn));
|
|
63
|
+
return (0, json_support_1.mapObjectMember)(architect, 'targets', targets => (0, json_support_1.mapObjectMembers)(targets, fn));
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
/** The `builder` of a target, if it is a string. */
|
|
67
|
+
function builderOf(target) {
|
|
68
|
+
var _a;
|
|
69
|
+
const value = (_a = (0, json_1.findMember)(target, 'builder')) === null || _a === void 0 ? void 0 : _a.value;
|
|
70
|
+
return value && (0, json_1.isLiteral)(value) && typeof value.value === 'string' ? value.value : undefined;
|
|
71
|
+
}
|
|
72
|
+
/** The builders of the workspace that `@angular/build` at `major` has no counterpart for. */
|
|
73
|
+
function blockers(root, major) {
|
|
74
|
+
const found = new Set();
|
|
75
|
+
mapTargets(root, target => {
|
|
76
|
+
const builder = builderOf(target);
|
|
77
|
+
if (builder === null || builder === void 0 ? void 0 : builder.startsWith(DEVKIT_PREFIX)) {
|
|
78
|
+
const since = COUNTERPARTS[builder.substring(DEVKIT_PREFIX.length)];
|
|
79
|
+
if (since === undefined || since > major)
|
|
80
|
+
found.add(builder);
|
|
81
|
+
}
|
|
82
|
+
return target;
|
|
83
|
+
});
|
|
84
|
+
return found;
|
|
85
|
+
}
|
|
86
|
+
const ZONE_POLYFILLS = ['zone.js', 'zone.js/testing'];
|
|
87
|
+
function useAngularBuild(zone) {
|
|
88
|
+
return target => {
|
|
89
|
+
const builder = builderOf(target);
|
|
90
|
+
if (!(builder === null || builder === void 0 ? void 0 : builder.startsWith(DEVKIT_PREFIX)))
|
|
91
|
+
return target;
|
|
92
|
+
const name = builder.substring(DEVKIT_PREFIX.length);
|
|
93
|
+
const moved = (0, json_1.updateMember)(target, 'builder', old => (0, json_1.jsonLiteral)(`@angular/build:${name}`, old.prefix));
|
|
94
|
+
if (name !== 'karma')
|
|
95
|
+
return moved;
|
|
96
|
+
// `@angular/build:karma` always builds with the `application` builder, so it has no `builderMode` to choose one.
|
|
97
|
+
return (0, json_support_1.mapTargetOptions)(moved, options => {
|
|
98
|
+
const withoutMode = (0, json_1.removeMember)(options, 'builderMode');
|
|
99
|
+
return zone ? zoneTestingInPolyfills(withoutMode) : withoutMode;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Lists `zone.js` and `zone.js/testing` in the `polyfills` of Karma options that have a `main`.
|
|
105
|
+
* `@angular/build:karma` builds `main` as one more entry point beside each spec, and sets up zone testing only from
|
|
106
|
+
* `polyfills`, so a `main` that imports `zone.js/testing` itself, as the `test.ts` of projects generated before Angular 15
|
|
107
|
+
* does, no longer sets it up for the specs, and every `fakeAsync` fails.
|
|
108
|
+
*/
|
|
109
|
+
function zoneTestingInPolyfills(options) {
|
|
110
|
+
var _a;
|
|
111
|
+
if (!(0, json_1.findMember)(options, 'main'))
|
|
112
|
+
return options;
|
|
113
|
+
const current = (_a = (0, json_1.findMember)(options, 'polyfills')) === null || _a === void 0 ? void 0 : _a.value;
|
|
114
|
+
let polyfills;
|
|
115
|
+
if (current === undefined) {
|
|
116
|
+
polyfills = (0, json_1.emptyArray)((0, json_1.space)(' '));
|
|
117
|
+
}
|
|
118
|
+
else if ((0, json_1.isLiteral)(current) && typeof current.value === 'string') {
|
|
119
|
+
polyfills = (0, json_1.appendElement)((0, json_1.emptyArray)(current.prefix), (0, json_1.jsonLiteral)(current.value));
|
|
120
|
+
}
|
|
121
|
+
else if ((0, json_1.isArray)(current)) {
|
|
122
|
+
polyfills = current;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return options;
|
|
126
|
+
}
|
|
127
|
+
const listed = new Set((0, json_1.elementsOf)(polyfills).map(e => (0, json_1.isLiteral)(e) ? e.value : undefined));
|
|
128
|
+
for (const entry of ZONE_POLYFILLS) {
|
|
129
|
+
if (!listed.has(entry))
|
|
130
|
+
polyfills = (0, json_1.appendElement)(polyfills, (0, json_1.jsonLiteral)(entry, (0, json_1.elementsOf)(polyfills).length ? (0, json_1.space)(' ') : undefined));
|
|
131
|
+
}
|
|
132
|
+
return polyfills === current ? options : (0, json_1.setMember)(options, 'polyfills', polyfills);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Moves the builders of an `angular.json` workspace from `@angular-devkit/build-angular` to `@angular/build`, as the
|
|
136
|
+
* last step of the Angular CLI's `use-application-builder` migration does once nothing in the workspace needs the
|
|
137
|
+
* webpack-based builders.
|
|
138
|
+
*
|
|
139
|
+
* A workspace moves only as a whole, since otherwise it would need both packages. One that still uses a builder
|
|
140
|
+
* that `@angular/build` lacks (`browser`, `server`, `app-shell`, `prerender`, `ssr-dev-server`, `jest`,
|
|
141
|
+
* `web-test-runner`, `protractor`, and `browser-esbuild`, whose migration changes the output location) keeps its
|
|
142
|
+
* builders, and that builder is flagged. So is a workspace on a major before `karma` and `ng-packagr` came to
|
|
143
|
+
* `@angular/build` (19) that uses them. Workspaces before Angular 18, or whose version it cannot tell, are left alone.
|
|
144
|
+
*
|
|
145
|
+
* The builders resolve from `@angular/build` only where the `package.json` declares it.
|
|
146
|
+
* `@angular-devkit/build-angular` depends on `@angular/build` of the same version from 18 on, but npm can nest it under
|
|
147
|
+
* `@angular-devkit/build-angular` and pnpm always does, where the CLI does not resolve builders. So a workspace moves
|
|
148
|
+
* only when its `package.json` declares `@angular/build`, or `UseAngularBuildBuilders` adds it there in the same run,
|
|
149
|
+
* and is flagged otherwise. The `package.json` keeps `@angular-devkit/build-angular`, so Karma configurations that load
|
|
150
|
+
* its plugin keep working.
|
|
151
|
+
*
|
|
152
|
+
* @see https://github.com/angular/angular-cli/blob/main/packages/schematics/angular/migrations/use-application-builder/migration.ts
|
|
153
|
+
*/
|
|
154
|
+
class MoveToAngularBuildBuilders extends rewrite_1.ScanningRecipe {
|
|
155
|
+
constructor() {
|
|
156
|
+
super(...arguments);
|
|
157
|
+
this.name = "org.openrewrite.angular.migration.move-to-angular-build-builders";
|
|
158
|
+
this.displayName = "Move the builders of `angular.json` to `@angular/build`";
|
|
159
|
+
this.description = "Moves the `application`, `dev-server`, `extract-i18n`, `karma` and `ng-packagr` builders " +
|
|
160
|
+
"of an `angular.json` workspace from `@angular-devkit/build-angular` to `@angular/build`, as the Angular CLI's " +
|
|
161
|
+
"`use-application-builder` migration does, and drops the `builderMode` option that `@angular/build:karma` does " +
|
|
162
|
+
"not have. A Karma target with a `main` gets `zone.js` and `zone.js/testing` in its `polyfills` where the project " +
|
|
163
|
+
"depends on `zone.js`, since `@angular/build:karma` sets zone testing up only from there. " +
|
|
164
|
+
"A workspace moves only when every one of its builders has a counterpart in `@angular/build` " +
|
|
165
|
+
"at its Angular version (18 for the first three, 19 for `karma` and `ng-packagr`). Otherwise the builders " +
|
|
166
|
+
"that block it, such as the webpack-based `browser` and `server`, are flagged and the workspace is left as it is. " +
|
|
167
|
+
"So is a workspace whose `package.json` neither declares `@angular/build`, which the builders need to resolve, nor " +
|
|
168
|
+
"gets it from `UseAngularBuildBuilders`.";
|
|
169
|
+
}
|
|
170
|
+
initialValue(_ctx) {
|
|
171
|
+
return { majors: new Map(), declaring: new Map(), zone: new Map() };
|
|
172
|
+
}
|
|
173
|
+
scanner(_a) {
|
|
174
|
+
return __awaiter(this, arguments, void 0, function* ({ majors, declaring, zone }) {
|
|
175
|
+
return new class extends json_1.JsonVisitor {
|
|
176
|
+
visitDocument(doc, _p) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
if (path_1.posix.basename(doc.sourcePath) === 'package.json') {
|
|
179
|
+
const dir = (0, package_version_1.directoryOf)(doc.sourcePath);
|
|
180
|
+
const major = (0, package_version_1.packageMajor)(doc, DEVKIT);
|
|
181
|
+
if (major !== undefined)
|
|
182
|
+
majors.set(dir, major);
|
|
183
|
+
declaring.set(dir, (0, package_version_1.declaredVersion)(doc, '@angular/build') !== undefined || addsAngularBuild(doc));
|
|
184
|
+
zone.set(dir, (0, package_version_1.declaredVersion)(doc, 'zone.js') !== undefined);
|
|
185
|
+
}
|
|
186
|
+
return doc;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
editorWithData(_a) {
|
|
193
|
+
return __awaiter(this, arguments, void 0, function* ({ majors, declaring, zone }) {
|
|
194
|
+
return new class extends json_1.JsonVisitor {
|
|
195
|
+
visitDocument(doc, p) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
var _a;
|
|
198
|
+
if (path_1.posix.basename(doc.sourcePath) !== 'angular.json' || !(0, json_1.isObject)(doc.value))
|
|
199
|
+
return doc;
|
|
200
|
+
const major = (0, package_version_1.majorFor)(majors, doc.sourcePath);
|
|
201
|
+
if (major === undefined || major < FIRST_MAJOR)
|
|
202
|
+
return doc;
|
|
203
|
+
const root = doc.value;
|
|
204
|
+
const blocking = blockers(root, major);
|
|
205
|
+
if (blocking.size === 0 && !declaresAngularBuild(declaring, doc.sourcePath)) {
|
|
206
|
+
const flagged = mapTargets(root, flagFirstDevkitBuilder());
|
|
207
|
+
return flagged === root ? doc : Object.assign(Object.assign({}, doc), { value: flagged });
|
|
208
|
+
}
|
|
209
|
+
if (blocking.size === 0) {
|
|
210
|
+
const updated = mapTargets(root, useAngularBuild((_a = (0, package_version_1.majorFor)(zone, doc.sourcePath)) !== null && _a !== void 0 ? _a : false));
|
|
211
|
+
return updated === root ? doc : Object.assign(Object.assign({}, doc), { value: updated });
|
|
212
|
+
}
|
|
213
|
+
const flagged = mapTargets(root, target => flagBuilder(target, blocking));
|
|
214
|
+
return flagged === root ? doc : Object.assign(Object.assign({}, doc), { value: flagged });
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.MoveToAngularBuildBuilders = MoveToAngularBuildBuilders;
|
|
222
|
+
/**
|
|
223
|
+
* Moves the builders of `angular.json` to `@angular/build` and declares `@angular/build` in `devDependencies` at the
|
|
224
|
+
* major of `@angular-devkit/build-angular`, as the Angular CLI's `use-application-builder` migration does.
|
|
225
|
+
*/
|
|
226
|
+
class UseAngularBuildBuilders extends rewrite_1.Recipe {
|
|
227
|
+
constructor() {
|
|
228
|
+
super(...arguments);
|
|
229
|
+
this.name = "org.openrewrite.angular.migration.use-angular-build-builders";
|
|
230
|
+
this.displayName = "Use the `@angular/build` builders in `angular.json`";
|
|
231
|
+
this.description = "Moves the `application`, `dev-server`, `extract-i18n`, `karma` and `ng-packagr` builders " +
|
|
232
|
+
"of an `angular.json` workspace from `@angular-devkit/build-angular` to `@angular/build`, as the Angular CLI's " +
|
|
233
|
+
"`use-application-builder` migration does, and drops the `builderMode` option that `@angular/build:karma` does " +
|
|
234
|
+
"not have. A Karma target with a `main` gets `zone.js` and `zone.js/testing` in its `polyfills` where the project " +
|
|
235
|
+
"depends on `zone.js`, since `@angular/build:karma` sets zone testing up only from there. " +
|
|
236
|
+
"A workspace moves only when every one of its builders has a counterpart in `@angular/build` " +
|
|
237
|
+
"at its Angular version (18 for the first three, 19 for `karma` and `ng-packagr`). Otherwise the builders " +
|
|
238
|
+
"that block it, such as the webpack-based `browser` and `server`, are flagged and the workspace is left as it is. " +
|
|
239
|
+
"Each `package.json` that declares `@angular-devkit/build-angular` 18 or later gets `@angular/build` of the same " +
|
|
240
|
+
"major in `devDependencies`, which the builders need to resolve. It keeps `@angular-devkit/build-angular`, " +
|
|
241
|
+
"which Karma configurations may still load a plugin from.";
|
|
242
|
+
}
|
|
243
|
+
recipeList() {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
return [
|
|
246
|
+
new MoveToAngularBuildBuilders(),
|
|
247
|
+
...yield (0, package_major_1.addDependencyByMajor)('@angular/build', 'devDependencies', [DEVKIT], DEVKIT, ANGULAR_BUILD_VERSIONS),
|
|
248
|
+
];
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
exports.UseAngularBuildBuilders = UseAngularBuildBuilders;
|
|
253
|
+
/** Whether the closest `package.json` at or above `sourcePath` declares `@angular/build`, or gets it added. */
|
|
254
|
+
function declaresAngularBuild(declaring, sourcePath) {
|
|
255
|
+
var _a;
|
|
256
|
+
return (_a = (0, package_version_1.majorFor)(declaring, sourcePath)) !== null && _a !== void 0 ? _a : false;
|
|
257
|
+
}
|
|
258
|
+
/** Flags the `builder` of the first target on `@angular-devkit/build-angular`, once for the whole workspace. */
|
|
259
|
+
function flagFirstDevkitBuilder() {
|
|
260
|
+
let done = false;
|
|
261
|
+
return target => {
|
|
262
|
+
var _a;
|
|
263
|
+
if (done || !((_a = builderOf(target)) === null || _a === void 0 ? void 0 : _a.startsWith(DEVKIT_PREFIX)))
|
|
264
|
+
return target;
|
|
265
|
+
done = true;
|
|
266
|
+
return markBuilder(target, UNDECLARED_MARK, UNDECLARED);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function markBuilder(target, mark, message) {
|
|
270
|
+
const members = target.members.map(rp => {
|
|
271
|
+
const m = rp.element;
|
|
272
|
+
return (0, json_1.isMember)(m) && (0, json_1.getMemberKeyName)(m) === 'builder' && !(0, lst_1.hasSearchResult)(m, mark) ? Object.assign(Object.assign({}, rp), { element: (0, rewrite_1.foundSearchResult)(m, message) }) : rp;
|
|
273
|
+
});
|
|
274
|
+
return members.some((rp, i) => rp !== target.members[i]) ? Object.assign(Object.assign({}, target), { members }) : target;
|
|
275
|
+
}
|
|
276
|
+
function flagBuilder(target, blocking) {
|
|
277
|
+
const builder = builderOf(target);
|
|
278
|
+
return builder && blocking.has(builder) ? markBuilder(target, BLOCKED_MARK, blocked(builder)) : target;
|
|
279
|
+
}
|
|
280
|
+
//# sourceMappingURL=use-angular-build-builders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-angular-build-builders.js","sourceRoot":"","sources":["../../src/migration/use-angular-build-builders.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;AAEH,kDAA8G;AAC9G,oDAiBmC;AACnC,mDAA+E;AAC/E,6EAA6G;AAC7G,+BAA2B;AAC3B,qDAA4D;AAC5D,iDAAmF;AAEnF,MAAM,MAAM,GAAG,+BAA+B,CAAC;AAC/C,MAAM,aAAa,GAAG,GAAG,MAAM,GAAG,CAAC;AAEnC;;;GAGG;AACH,MAAM,YAAY,GAA2B;IACzC,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE;IACX,YAAY,EAAE,EAAE;CACnB,CAAC;AAEF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AAC;AACN,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB,EAAE,IAAY,EAAE,OAAe;IACnE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;QACrB,OAAO,IAAA,eAAQ,EAAC,CAAC,CAAC,IAAI,IAAA,uBAAgB,EAAC,CAAC,CAAC,KAAK,SAAS,IAAI,CAAC,IAAA,qBAAe,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,iCAC9E,EAAE,KAAE,OAAO,EAAE,IAAA,2BAAiB,EAAC,CAAC,EAAE,OAAO,CAAC,IAAE,CAAC,CAAC,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,iCAAK,MAAM,KAAE,OAAO,IAAE,CAAC,CAAC,MAAM,CAAC;AAC7F,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB,EAAE,QAAqB;IAC3D,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC3G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/recipes-angular",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"license": "Moderne Proprietary",
|
|
5
5
|
"description": "OpenRewrite recipes for Angular.",
|
|
6
6
|
"homepage": "https://github.com/openrewrite/rewrite",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"ci:test": "npm run typecheck && NODE_OPTIONS=--max-old-space-size=4096 vitest run"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@openrewrite/rewrite": "^8.
|
|
27
|
+
"@openrewrite/rewrite": "^8.112.0",
|
|
28
28
|
"mutative": "^1.3.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -133,6 +133,10 @@ import {AddIstanbulInstrumenter} from './migration/add-istanbul-instrumenter';
|
|
|
133
133
|
import {MigrateModelWithOutput} from './migration/migrate-model-with-output';
|
|
134
134
|
import {FindTemplateSafeNavigation} from './search/find-template-safe-navigation';
|
|
135
135
|
import {RenameSsrExperimentalPlatform} from './migration/rename-ssr-experimental-platform';
|
|
136
|
+
import {ReplacePlatformBrowserDynamic} from './migration/replace-platform-browser-dynamic';
|
|
137
|
+
import {UseAngularBuildBuilders} from './migration/use-angular-build-builders';
|
|
138
|
+
import {FindNg2CookiesUsage, MigrateNg2Cookies, MigrateNg2CookiesCodeChanges, MigrateNg2CookiesToNgxCookieService} from './libraries/ng2-cookies/migrate-ng2-cookies';
|
|
139
|
+
import {FindInlineSvgForRootConfig, FindNgInlineSvgUsage, MigrateInlineSvgTemplates, MigrateNgInlineSvgCodeChanges, MigrateNgInlineSvgToAngularSvgIcon} from './libraries/ng-inline-svg/migrate-ng-inline-svg';
|
|
136
140
|
import {UpgradeToPrimeNG18} from './libraries/primeng/18/upgrade-to-primeng-18';
|
|
137
141
|
import {UpgradeComponentsTo18} from './libraries/primeng/18/upgrade-components-to-18';
|
|
138
142
|
import {MigratePrimeNgConfigToPrimeNG} from './libraries/primeng/18/migrate-primeng-config';
|
|
@@ -415,6 +419,17 @@ export async function activate(marketplace: RecipeMarketplace) {
|
|
|
415
419
|
await marketplace.install(MigrateModelWithOutput, AngularMigration);
|
|
416
420
|
await marketplace.install(FindTemplateSafeNavigation, AngularSearch);
|
|
417
421
|
await marketplace.install(RenameSsrExperimentalPlatform, AngularMigration);
|
|
422
|
+
await marketplace.install(ReplacePlatformBrowserDynamic, AngularMigration);
|
|
423
|
+
await marketplace.install(UseAngularBuildBuilders, AngularMigration);
|
|
424
|
+
await marketplace.install(MigrateNg2Cookies, AngularMigration);
|
|
425
|
+
await marketplace.install(MigrateNg2CookiesCodeChanges, AngularMigration);
|
|
426
|
+
await marketplace.install(MigrateNg2CookiesToNgxCookieService, AngularMigration);
|
|
427
|
+
await marketplace.install(FindNg2CookiesUsage, AngularSearch);
|
|
428
|
+
await marketplace.install(MigrateNgInlineSvgToAngularSvgIcon, AngularMigration);
|
|
429
|
+
await marketplace.install(MigrateNgInlineSvgCodeChanges, AngularMigration);
|
|
430
|
+
await marketplace.install(MigrateInlineSvgTemplates, AngularMigration);
|
|
431
|
+
await marketplace.install(FindInlineSvgForRootConfig, AngularSearch);
|
|
432
|
+
await marketplace.install(FindNgInlineSvgUsage, AngularSearch);
|
|
418
433
|
// PrimeNG
|
|
419
434
|
await marketplace.install(UpgradeToPrimeNG18, PrimeNG);
|
|
420
435
|
await marketplace.install(UpgradeComponentsTo18, PrimeNG);
|
|
@@ -697,6 +712,10 @@ export {AddIstanbulInstrumenter} from './migration/add-istanbul-instrumenter';
|
|
|
697
712
|
export {MigrateModelWithOutput} from './migration/migrate-model-with-output';
|
|
698
713
|
export {FindTemplateSafeNavigation} from './search/find-template-safe-navigation';
|
|
699
714
|
export {RenameSsrExperimentalPlatform} from './migration/rename-ssr-experimental-platform';
|
|
715
|
+
export {ReplacePlatformBrowserDynamic} from './migration/replace-platform-browser-dynamic';
|
|
716
|
+
export {UseAngularBuildBuilders} from './migration/use-angular-build-builders';
|
|
717
|
+
export {FindNg2CookiesUsage, MigrateNg2Cookies, MigrateNg2CookiesCodeChanges, MigrateNg2CookiesToNgxCookieService} from './libraries/ng2-cookies/migrate-ng2-cookies';
|
|
718
|
+
export {FindInlineSvgForRootConfig, FindNgInlineSvgUsage, MigrateInlineSvgTemplates, MigrateNgInlineSvgCodeChanges, MigrateNgInlineSvgToAngularSvgIcon} from './libraries/ng-inline-svg/migrate-ng-inline-svg';
|
|
700
719
|
export {MigrateAngularHttpToCommonHttp, MigrateAngularHttpToCommonHttpCodeChanges} from './migration/migrate-angular-http-to-common-http';
|
|
701
720
|
export {KeepResponseBodyUnparsed} from './migration/keep-response-body-unparsed';
|
|
702
721
|
export {ReplaceAngularHttpImports} from './migration/replace-angular-http-imports';
|
|
@@ -13,6 +13,17 @@ export function hasSearchResult(tree: {markers: Markers}, text: string): boolean
|
|
|
13
13
|
return tree.markers.markers.some(m => m.kind === MarkersKind.SearchResult && ((m as SearchResult).description ?? '').includes(text));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The tree without the search results whose description contains `text`, as one recipe takes back a flag it set in an
|
|
18
|
+
* earlier cycle once what it flagged has changed.
|
|
19
|
+
*/
|
|
20
|
+
export function withoutSearchResult<T extends {markers: Markers}>(tree: T, text: string): T {
|
|
21
|
+
if (!hasSearchResult(tree, text)) return tree;
|
|
22
|
+
const markers = tree.markers.markers.filter(m =>
|
|
23
|
+
!(m.kind === MarkersKind.SearchResult && ((m as SearchResult).description ?? '').includes(text)));
|
|
24
|
+
return {...tree, markers: {...tree.markers, markers}};
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
/** The name of an object property, written as an identifier or as a quoted string. */
|
|
17
28
|
export function propertyName(name: J | undefined): string | undefined {
|
|
18
29
|
if (name && isIdentifier(name)) return name.simpleName;
|
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {ExecutionContext, TreeVisitor} from "@openrewrite/rewrite";
|
|
8
|
-
import {findNodeResolutionResult
|
|
8
|
+
import {findNodeResolutionResult} from "@openrewrite/rewrite/javascript";
|
|
9
9
|
import {getMemberKeyName, isLiteral, isMember, isObject, Json, JsonVisitor} from "@openrewrite/rewrite/json";
|
|
10
10
|
|
|
11
|
-
/** The major
|
|
12
|
-
function packageMajor(packageJson: Json.Document, packageName: string): number | undefined {
|
|
11
|
+
/** The major of a package that a `package.json` installs, ignoring `peerDependencies`, which state a compatible range rather than the installed version. */
|
|
12
|
+
export function packageMajor(packageJson: Json.Document, packageName: string): number | undefined {
|
|
13
13
|
const marker = findNodeResolutionResult(packageJson);
|
|
14
|
-
const dependency = marker &&
|
|
14
|
+
const dependency = marker && [...marker.dependencies, ...marker.devDependencies].find(d => d.name === packageName);
|
|
15
15
|
const version = dependency ? dependency.resolved?.version ?? dependency.versionConstraint : declaredVersion(packageJson, packageName);
|
|
16
16
|
const major = version?.match(/\d+/)?.[0];
|
|
17
17
|
return major === undefined ? undefined : Number(major);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** The version of a package that the `dependencies` or `devDependencies` of a `package.json` declare. */
|
|
21
|
-
function declaredVersion(packageJson: Json.Document, packageName: string): string | undefined {
|
|
21
|
+
export function declaredVersion(packageJson: Json.Document, packageName: string): string | undefined {
|
|
22
22
|
for (const scope of ['dependencies', 'devDependencies']) {
|
|
23
23
|
const value = member(packageJson.value, scope);
|
|
24
24
|
const version = value && member(value, packageName);
|
|
@@ -38,8 +38,8 @@ export function directoryOf(sourcePath: string): string {
|
|
|
38
38
|
return slash < 0 ? '' : sourcePath.substring(0, slash);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/** The
|
|
42
|
-
export function majorFor(majors: Map<string,
|
|
41
|
+
/** The value recorded for the closest `package.json` above a source file, such as the major of a package it declares. */
|
|
42
|
+
export function majorFor<T = number>(majors: Map<string, T>, sourcePath: string): T | undefined {
|
|
43
43
|
for (let dir = directoryOf(sourcePath); ; dir = directoryOf(dir)) {
|
|
44
44
|
const major = majors.get(dir);
|
|
45
45
|
if (major !== undefined || dir === '') return major;
|
|
@@ -96,6 +96,13 @@ export function moduleOf(declaration: JS.Import | JS.ExportDeclaration): string
|
|
|
96
96
|
return specifier?.kind === J.Kind.Literal ? (specifier as J.Literal).value as string : undefined;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** The module that a CommonJS `require('<module>')` call loads, if it is one. */
|
|
100
|
+
export function requiredModule(call: J.MethodInvocation): string | undefined {
|
|
101
|
+
const arg = call.arguments.elements[0]?.element;
|
|
102
|
+
return call.name.simpleName === 'require' && !call.select && call.arguments.elements.length === 1 &&
|
|
103
|
+
arg?.kind === J.Kind.Literal && typeof (arg as J.Literal).value === 'string' ? (arg as J.Literal).value as string : undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
/** The name taken from the module, such as `Old` in `{Old as New}`. */
|
|
100
107
|
export function importedName(spec: JS.ImportSpecifier | JS.ExportSpecifier): string | undefined {
|
|
101
108
|
const specifier = spec.specifier;
|