@arcgis/codemod 6.0.0-next.44 → 6.0.0-next.45
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 +73 -6
- package/dist/chunks/actions.js +261 -249
- package/dist/chunks/aggregateUsages.js +11 -10
- package/dist/chunks/apiName.js +123 -0
- package/dist/chunks/auditDefinitions.js +49 -47
- package/dist/chunks/auditUsages.js +649 -647
- package/dist/chunks/classification.js +73 -192
- package/dist/chunks/cli.js +52 -52
- package/dist/chunks/codemod.js +46 -46
- package/dist/chunks/codemod10.js +6039 -63
- package/dist/chunks/codemod11.js +54 -45
- package/dist/chunks/codemod12.js +74 -0
- package/dist/chunks/codemod9.js +218 -6017
- package/dist/chunks/componentAudit.js +141 -216
- package/dist/chunks/format.js +8 -7
- package/dist/chunks/hardcodedBehavior.js +96 -0
- package/dist/chunks/sync.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.
|
|
4
4
|
|
|
5
5
|
This package provides automated refactors to help migrate away from deprecated or legacy patterns.
|
|
6
|
-
These include codemods for removing the `__esri` namespace and
|
|
7
|
-
converting global namespace types to explicit `@arcgis/core` imports,
|
|
8
|
-
normalizing legacy Calcite icon names,
|
|
9
|
-
updating geometry operator usage,
|
|
10
|
-
and migrating the Feature (next) and Features (next) components.
|
|
11
6
|
|
|
12
7
|
## Requirements
|
|
13
8
|
|
|
@@ -17,7 +12,11 @@ and migrating the Feature (next) and Features (next) components.
|
|
|
17
12
|
|
|
18
13
|
## Before you begin
|
|
19
14
|
|
|
20
|
-
Ensure your project's dependencies are up to date, for example by running `
|
|
15
|
+
Ensure your project's dependencies are up to date, for example by running `npm install`.
|
|
16
|
+
|
|
17
|
+
In a monorepo environment, build your project before running the codemod.
|
|
18
|
+
|
|
19
|
+
Before running a codemod that migrates to newer APIs, update the affected dependencies to versions that include those newer APIs.
|
|
21
20
|
|
|
22
21
|
If your project uses **ESLint, Prettier, or other formatters/linters**, run them after the codemod to ensure consistent formatting.
|
|
23
22
|
|
|
@@ -34,6 +33,7 @@ Codemods respect `.gitignore` files and will not modify any files ignored by the
|
|
|
34
33
|
## Available codemods
|
|
35
34
|
|
|
36
35
|
- [`refactor-out-esri-namespace`](#refactor-out-the-__esri-namespace)
|
|
36
|
+
- [`refactor-component-types`](#refactor-component-types)
|
|
37
37
|
- [`normalize-calcite-icon-names`](#normalize-calcite-icon-names)
|
|
38
38
|
- [`geometry-operator-renames`](#rename-geometry-operators)
|
|
39
39
|
- [`rename-next-list-components`](#rename-next-list-components)
|
|
@@ -80,6 +80,73 @@ The codemod will emit warnings for cases it cannot safely rewrite, including:
|
|
|
80
80
|
|
|
81
81
|
These will be reported in the console. Manually review all changes before committing.
|
|
82
82
|
|
|
83
|
+
### Refactor component types
|
|
84
|
+
|
|
85
|
+
Migrates deprecated global component types to explicit component imports and framework helpers.
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
npx @arcgis/codemod@latest run refactor-component-types [<target-directory>]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Update component dependencies before running; the codemod assumes the replacement APIs are available.
|
|
92
|
+
|
|
93
|
+
Codemod edits:
|
|
94
|
+
|
|
95
|
+
Replace global `HTML*Element` types with the exported component class.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
// Before
|
|
99
|
+
const map = document.querySelector<HTMLArcgisMapElement>("#map");
|
|
100
|
+
|
|
101
|
+
// After
|
|
102
|
+
import type { ArcgisMap } from "@arcgis/map-components/components/arcgis-map";
|
|
103
|
+
const map = document.querySelector<ArcgisMap>("#map");
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Replace generic `*CustomEvent<T>` type helpers with specific event type:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
// Before
|
|
110
|
+
import type { ArcgisMapCustomEvent } from "@arcgis/map-components";
|
|
111
|
+
|
|
112
|
+
map.addEventListener("arcgisViewReadyChange", handleReadyChange);
|
|
113
|
+
function handleReadyChange(event: ArcgisMapCustomEvent<void>) {
|
|
114
|
+
console.log(event.currentTarget.zoom);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// After
|
|
118
|
+
import type { ArcgisMap } from "@arcgis/map-components/components/arcgis-map";
|
|
119
|
+
|
|
120
|
+
map.addEventListener("arcgisViewReadyChange", handleReadyChange);
|
|
121
|
+
function handleReadyChange(event: ArcgisMap["arcgisViewReadyChange"]) {
|
|
122
|
+
console.log(event.currentTarget.zoom);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Use JSX prop helpers with explicitly imported component types:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
// Before
|
|
130
|
+
import type { ReactArcgisMap } from "@arcgis/map-components/types/react";
|
|
131
|
+
|
|
132
|
+
function Map(props: ReactArcgisMap) {
|
|
133
|
+
return <arcgis-map {...props} />;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// After
|
|
137
|
+
import type { ArcgisMap } from "@arcgis/map-components/components/arcgis-map";
|
|
138
|
+
import type { ToReactProps } from "@arcgis/map-components/types/react";
|
|
139
|
+
|
|
140
|
+
function Map(props: ToReactProps<ArcgisMap>) {
|
|
141
|
+
return <arcgis-map {...props} />;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
For Preact, use `ToPreactProps<ArcgisMap>` from `@arcgis/map-components/types/preact`.
|
|
146
|
+
For Stencil, use `ToStencilProps<ArcgisMap>` from `@arcgis/map-components/types/stencil`.
|
|
147
|
+
|
|
148
|
+
Global event payload maps like `HTMLArcgisMapElementEventMap` become `ArcgisMap["@eventTypes"]`.
|
|
149
|
+
|
|
83
150
|
### Normalize Calcite icon names
|
|
84
151
|
|
|
85
152
|
The `normalize-calcite-icon-names` codemod updates camelCase and legacy Calcite icon names to their normalized
|