@arcgis/codemod 5.2.0-next.5 → 5.2.0-next.51

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.
@@ -0,0 +1,138 @@
1
+ var p = (i, o) => (o = Symbol[i]) ? o : /* @__PURE__ */ Symbol.for("Symbol." + i), f = (i) => {
2
+ throw TypeError(i);
3
+ };
4
+ var g = (i, o, a) => {
5
+ if (o != null) {
6
+ typeof o != "object" && typeof o != "function" && f("Object expected");
7
+ var n, t;
8
+ a && (n = o[p("asyncDispose")]), n === void 0 && (n = o[p("dispose")], a && (t = n)), typeof n != "function" && f("Object not disposable"), t && (n = function() {
9
+ try {
10
+ t.call(this);
11
+ } catch (r) {
12
+ return Promise.reject(r);
13
+ }
14
+ }), i.push([a, n, o]);
15
+ } else a && i.push([a]);
16
+ return o;
17
+ }, m = (i, o, a) => {
18
+ var n = typeof SuppressedError == "function" ? SuppressedError : function(e, s, c, d) {
19
+ return d = Error(c), d.name = "SuppressedError", d.error = e, d.suppressed = s, d;
20
+ }, t = (e) => o = a ? new n(e, o, "An error was suppressed during disposal") : (a = !0, e), r = (e) => {
21
+ for (; e = i.pop(); )
22
+ try {
23
+ var s = e[1] && e[1].call(e[2]);
24
+ if (e[0]) return Promise.resolve(s).then(r, (c) => (t(c), r()));
25
+ } catch (c) {
26
+ t(c);
27
+ }
28
+ if (a) throw o;
29
+ };
30
+ return r();
31
+ };
32
+ import { f as h, p as P } from "./actions-CpvVerLh.js";
33
+ import { log as k } from "@arcgis/toolkit/log";
34
+ import { writeFile as u } from "node:fs/promises";
35
+ import { c as y } from "./useProjectInstance-CnTxT392.js";
36
+ import { p as x, g as J } from "./cli-BaxVArIQ.js";
37
+ async function v(i, o) {
38
+ const a = /* @__PURE__ */ new Set();
39
+ for (const n of i) {
40
+ const t = n.packageJson;
41
+ if (t === void 0 || a.has(t.filePath))
42
+ continue;
43
+ a.add(t.filePath);
44
+ const r = t.contents;
45
+ try {
46
+ const e = await o(r, t.filePath);
47
+ r !== e && await u(t.filePath, `${JSON.stringify(e, null, 2)}
48
+ `, "utf8");
49
+ } catch (e) {
50
+ process.exitCode = 1, k(
51
+ "error",
52
+ h(t.filePath),
53
+ `Error occurred while migrating: ${String(e)}`,
54
+ typeof e == "object" && e !== null && "stack" in e ? { detail: { stack: e.stack } } : void 0
55
+ );
56
+ }
57
+ }
58
+ }
59
+ function D(i, o) {
60
+ for (const a of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
61
+ const n = i[a];
62
+ if (n) {
63
+ const t = o(n, a);
64
+ t !== n && (i = { ...i, [a]: t });
65
+ }
66
+ }
67
+ return i;
68
+ }
69
+ const l = "@arcgis/components-build-utils", S = {
70
+ [l]: {
71
+ existsAsync: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
72
+ sh: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
73
+ sp: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
74
+ asyncSh: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
75
+ findPath: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
76
+ asyncFindPath: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
77
+ createFileIfNotExists: { do: "rename", specifier: "@arcgis/node-toolkit/file" },
78
+ gitIgnoreFileToGlobs: { do: "rename", specifier: "@arcgis/node-toolkit/glob" },
79
+ gitIgnoreToGlob: { do: "rename", specifier: "@arcgis/node-toolkit/glob" },
80
+ isPosix: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
81
+ toPosixPathSeparators: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
82
+ normalizePath: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
83
+ toSystemPathSeparators: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
84
+ getCwd: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
85
+ path: { do: "rename", specifier: "@arcgis/node-toolkit/path" },
86
+ PackageJson: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
87
+ retrievePackageJson: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
88
+ asyncRetrievePackageJson: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
89
+ fetchPackageLocation: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
90
+ detectPackageManager: { do: "rename", specifier: "@arcgis/node-toolkit/packageJson" },
91
+ DependencyManagementOptions: {
92
+ do: "rename",
93
+ specifier: "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin"
94
+ },
95
+ vitePresetPlugin: { do: "rename", specifier: "@arcgis/node-toolkit/vite/presetPlugin" },
96
+ externalizeDependencies: {
97
+ do: "rename",
98
+ specifier: "@arcgis/node-toolkit/vite/externalizeDependenciesPlugin"
99
+ }
100
+ }
101
+ }, C = {
102
+ meta: {
103
+ needsTypeInformation: !1
104
+ },
105
+ async run(i) {
106
+ await v(
107
+ i,
108
+ (r) => D(
109
+ r,
110
+ (e) => e[l] ? {
111
+ ...e,
112
+ [l]: void 0,
113
+ "@arcgis/node-toolkit": e[l]
114
+ } : e
115
+ )
116
+ );
117
+ for (const r of i) {
118
+ var o = [];
119
+ try {
120
+ const e = g(o, y(r));
121
+ for (const s of e.getCodemodFiles())
122
+ P(s, S);
123
+ } catch (a) {
124
+ var n = a, t = !0;
125
+ } finally {
126
+ m(o, n, t);
127
+ }
128
+ }
129
+ x(), k(
130
+ "info",
131
+ J.codemodName,
132
+ "Next step: run npm install/pnpm install/yarn install to get @arcgis/node-toolkit package installed."
133
+ );
134
+ }
135
+ };
136
+ export {
137
+ C as codemod
138
+ };
@@ -0,0 +1,74 @@
1
+ var c = (t, e) => (e = Symbol[t]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + t), d = (t) => {
2
+ throw TypeError(t);
3
+ };
4
+ var g = (t, e, s) => {
5
+ if (e != null) {
6
+ typeof e != "object" && typeof e != "function" && d("Object expected");
7
+ var i, r;
8
+ s && (i = e[c("asyncDispose")]), i === void 0 && (i = e[c("dispose")], s && (r = i)), typeof i != "function" && d("Object not disposable"), r && (i = function() {
9
+ try {
10
+ r.call(this);
11
+ } catch (n) {
12
+ return Promise.reject(n);
13
+ }
14
+ }), t.push([s, i, e]);
15
+ } else s && t.push([s]);
16
+ return e;
17
+ }, f = (t, e, s) => {
18
+ var i = typeof SuppressedError == "function" ? SuppressedError : function(o, a, l, m) {
19
+ return m = Error(l), m.name = "SuppressedError", m.error = o, m.suppressed = a, m;
20
+ }, r = (o) => e = s ? new i(o, e, "An error was suppressed during disposal") : (s = !0, o), n = (o) => {
21
+ for (; o = t.pop(); )
22
+ try {
23
+ var a = o[1] && o[1].call(o[2]);
24
+ if (o[0]) return Promise.resolve(a).then(n, (l) => (r(l), n()));
25
+ } catch (l) {
26
+ r(l);
27
+ }
28
+ if (s) throw e;
29
+ };
30
+ return n();
31
+ };
32
+ import { p } from "./actions-CpvVerLh.js";
33
+ import { c as k } from "./useProjectInstance-CnTxT392.js";
34
+ import { p as C } from "./cli-BaxVArIQ.js";
35
+ const j = {
36
+ meta: {
37
+ needsTypeInformation: !1
38
+ },
39
+ run(t) {
40
+ for (const n of t) {
41
+ var e = [];
42
+ try {
43
+ const o = g(e, k(n));
44
+ for (const a of o.getCodemodFiles())
45
+ p(a, {
46
+ "@arcgis/toolkit/intl": {
47
+ getElementLocale: { do: "rename", specifier: "@arcgis/toolkit/intl/dom" },
48
+ startLocaleObserver: { do: "rename", specifier: "@arcgis/toolkit/intl/dom" },
49
+ LocaleObserverResult: { do: "rename", specifier: "@arcgis/toolkit/intl/dom" }
50
+ },
51
+ "@arcgis/toolkit/dom": {
52
+ slotChangeHasContent: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
53
+ slotChangeGetTextContent: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
54
+ slotChangeHasTextContent: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
55
+ slotChangeHasAssignedNode: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
56
+ slotChangeGetAssignedNodes: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
57
+ slotChangeHasAssignedElement: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
58
+ slotChangeGetAssignedElements: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
59
+ getSlotAssignedElements: { do: "rename", specifier: "@arcgis/toolkit/dom/slots" },
60
+ resolveReferenceElement: { do: "rename", specifier: "@arcgis/toolkit/dom/referenceElement" }
61
+ }
62
+ });
63
+ } catch (s) {
64
+ var i = s, r = !0;
65
+ } finally {
66
+ f(e, i, r);
67
+ }
68
+ }
69
+ C();
70
+ }
71
+ };
72
+ export {
73
+ j as codemod
74
+ };
@@ -0,0 +1,50 @@
1
+ import { Project as l } from "ts-morph";
2
+ import { log as f } from "@arcgis/toolkit/log";
3
+ import { path as p } from "@arcgis/node-toolkit/path";
4
+ import { g as t, d } from "./cli-BaxVArIQ.js";
5
+ import { styleText as s } from "node:util";
6
+ function P(e) {
7
+ if (t.project !== void 0)
8
+ throw Error(
9
+ "A different ts-morph Project is already in use. Dispose of it before creating a new one. Example: using project = createProjectInstance(...)"
10
+ );
11
+ const i = t.codemod.meta.needsTypeInformation, o = new l({
12
+ // If tsconfig is missing, or project is untyped, use a permissive and
13
+ // compatible default config
14
+ compilerOptions: e.typeScriptConfig?.compilerOptions ?? {
15
+ ...d,
16
+ // Read types from JSDoc annotations if present
17
+ checkJs: i
18
+ },
19
+ // We take care of reading the config file
20
+ tsConfigFilePath: void 0,
21
+ // We add files manually below
22
+ skipAddingFilesFromTsConfig: !0,
23
+ // We call this manually if needed below.
24
+ skipFileDependencyResolution: !0,
25
+ skipLoadingLibFiles: !i
26
+ });
27
+ for (const n of e.filePaths)
28
+ o.addSourceFileAtPath(n);
29
+ i && o.resolveSourceFileDependencies();
30
+ const r = p.relative(process.cwd(), e.cwd);
31
+ process.stdout.write(""), f(
32
+ "info",
33
+ s("blue", r === "" ? process.cwd() : r),
34
+ `Running the codemod on ${s("blue", String(e.filePaths.length))} file${e.filePaths.length !== 1 ? "s" : ""}${e.packageJson?.contents.name === void 0 ? "" : ` from ${s("blue", e.packageJson.contents.name)}`}`
35
+ );
36
+ const c = {
37
+ [Symbol.dispose]() {
38
+ o.saveSync(), o.getRootDirectories().forEach((n) => n.forget()), t.project = void 0;
39
+ },
40
+ projectData: e,
41
+ // Any files added after projectData.filePaths are supporting files for type
42
+ // checking, but are not codemod targets.
43
+ getCodemodFiles: () => o.getSourceFiles().slice(0, e.filePaths.length),
44
+ tsMorph: o
45
+ };
46
+ return t.project = c, c;
47
+ }
48
+ export {
49
+ P as c
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/codemod",
3
- "version": "5.2.0-next.5",
3
+ "version": "5.2.0-next.51",
4
4
  "description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -12,13 +12,14 @@
12
12
  "bin": "./bin/cli.js",
13
13
  "license": "SEE LICENSE IN LICENSE.md",
14
14
  "dependencies": {
15
- "@commander-js/extra-typings": "^14.0.0",
16
- "commander": "^14.0.0",
17
- "tinyglobby": "^0.2.15",
15
+ "@commander-js/extra-typings": "^15.0.0",
16
+ "commander": "^15.0.0",
17
+ "tinyglobby": "~0.2.17",
18
18
  "ts-morph": "^28.0.0",
19
19
  "tslib": "^2.8.1",
20
- "typescript": "~6.0.2",
21
- "@arcgis/components-build-utils": "5.2.0-next.5",
22
- "@arcgis/toolkit": "5.2.0-next.5"
20
+ "typescript": "~6.0.3",
21
+ "@arcgis/api-extractor": "5.2.0-next.51",
22
+ "@arcgis/toolkit": "5.2.0-next.51",
23
+ "@arcgis/node-toolkit": "5.2.0-next.51"
23
24
  }
24
25
  }
@@ -1,156 +0,0 @@
1
- var m = (o, i) => (i = Symbol[o]) ? i : /* @__PURE__ */ Symbol.for("Symbol." + o), d = (o) => {
2
- throw TypeError(o);
3
- };
4
- var p = (o, i, r) => {
5
- if (i != null) {
6
- typeof i != "object" && typeof i != "function" && d("Object expected");
7
- var a, t;
8
- r && (a = i[m("asyncDispose")]), a === void 0 && (a = i[m("dispose")], r && (t = a)), typeof a != "function" && d("Object not disposable"), t && (a = function() {
9
- try {
10
- t.call(this);
11
- } catch (s) {
12
- return Promise.reject(s);
13
- }
14
- }), o.push([r, a, i]);
15
- } else r && o.push([r]);
16
- return i;
17
- }, f = (o, i, r) => {
18
- var a = typeof SuppressedError == "function" ? SuppressedError : function(e, n, c, l) {
19
- return l = Error(c), l.name = "SuppressedError", l.error = e, l.suppressed = n, l;
20
- }, t = (e) => i = r ? new a(e, i, "An error was suppressed during disposal") : (r = !0, e), s = (e) => {
21
- for (; e = o.pop(); )
22
- try {
23
- var n = e[1] && e[1].call(e[2]);
24
- if (e[0]) return Promise.resolve(n).then(s, (c) => (t(c), s()));
25
- } catch (c) {
26
- t(c);
27
- }
28
- if (r) throw i;
29
- };
30
- return s();
31
- };
32
- import { f as k, c as u, p as E } from "./useProjectInstance-BeTuT4eH.js";
33
- import { log as g } from "@arcgis/toolkit/log";
34
- import { writeFile as b } from "node:fs/promises";
35
- import { p as h, g as y } from "./cli-mQ3ZNyiH.js";
36
- async function L(o, i) {
37
- const r = /* @__PURE__ */ new Set();
38
- for (const a of o) {
39
- const t = a.packageJson;
40
- if (t === void 0 || r.has(t.filePath))
41
- continue;
42
- r.add(t.filePath);
43
- const s = t.contents;
44
- try {
45
- const e = await i(s, t.filePath);
46
- s !== e && await b(t.filePath, `${JSON.stringify(e, null, 2)}
47
- `, "utf8");
48
- } catch (e) {
49
- process.exitCode = 1, g(
50
- "error",
51
- k(t.filePath),
52
- `Error occurred while migrating: ${String(e)}`,
53
- typeof e == "object" && e !== null && "stack" in e ? { detail: { stack: e.stack } } : void 0
54
- );
55
- }
56
- }
57
- }
58
- function P(o, i) {
59
- for (const r of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]) {
60
- const a = o[r];
61
- if (a) {
62
- const t = i(a, r);
63
- t !== a && (o = { ...o, [r]: t });
64
- }
65
- }
66
- return o;
67
- }
68
- const C = {
69
- meta: {
70
- needsTypeInformation: !1
71
- },
72
- async run(o) {
73
- await L(
74
- o,
75
- (s) => P(
76
- s,
77
- (e) => e["@arcgis/components-utils"] ? {
78
- ...e,
79
- "@arcgis/components-utils": void 0,
80
- "@arcgis/toolkit": e["@arcgis/components-utils"]
81
- } : e
82
- )
83
- );
84
- for (const s of o) {
85
- var i = [];
86
- try {
87
- const e = p(i, u(s));
88
- for (const n of e.getCodemodFiles())
89
- E(n, {
90
- "@arcgis/components-utils": {
91
- // Deprecated
92
- setFocusOnElement: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/dom" }],
93
- setValuesInString: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/string" }],
94
- IHandle: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/type" }],
95
- Deferred: [{ do: "deprecate" }, { do: "rename", specifier: "@arcgis/toolkit/promise" }],
96
- // Renamed
97
- addLTRMark: { do: "rename", specifier: "@arcgis/toolkit/string", name: "addLtrMark" },
98
- getElementTheme: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "unsafeGetCalciteModeName" },
99
- getElementDir: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "unsafeGetElementDirection" },
100
- unsafeGetModeName: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "unsafeGetCalciteModeName" },
101
- getElementLocales: { do: "rename", specifier: "@arcgis/toolkit/intl", name: "getElementLocale" },
102
- LocaleObserver: { do: "rename", specifier: "@arcgis/toolkit/intl", name: "LocaleObserverResult" },
103
- Nil: { do: "rename", specifier: "@arcgis/toolkit/type", name: "nil" },
104
- closestElement: { do: "rename", specifier: "@arcgis/toolkit/dom", name: "getClosestElement" },
105
- extractMinorVersion: { do: "rename", specifier: "@arcgis/toolkit/string", name: "getMinorVersion" },
106
- isURL: { do: "rename", specifier: "@arcgis/toolkit/string", name: "isUrl" },
107
- mappedFind: { do: "rename", specifier: "@arcgis/toolkit/array" },
108
- classes: { do: "rename", specifier: "@arcgis/toolkit/dom" },
109
- // Relocated
110
- observeAncestorsMutation: { do: "rename", specifier: "@arcgis/toolkit/dom" },
111
- getElementAttribute: { do: "rename", specifier: "@arcgis/toolkit/dom" },
112
- FocusableElement: { do: "rename", specifier: "@arcgis/toolkit/dom" },
113
- focusElement: { do: "rename", specifier: "@arcgis/toolkit/dom" },
114
- devToolsAwareTimeout: { do: "rename", specifier: "@arcgis/toolkit/promise" },
115
- isEsriInternalEnv: { do: "rename", specifier: "@arcgis/toolkit/error" },
116
- safeCall: { do: "rename", specifier: "@arcgis/toolkit/error" },
117
- safeAsyncCall: { do: "rename", specifier: "@arcgis/toolkit/error" },
118
- generateGuid: { do: "rename", specifier: "@arcgis/toolkit/string" },
119
- getPreamble: { do: "rename", specifier: "@arcgis/toolkit/string" },
120
- quoteString: { do: "rename", specifier: "@arcgis/toolkit/string" },
121
- createFilterExpression: { do: "rename", specifier: "@arcgis/toolkit/string" },
122
- kebabToPascal: { do: "rename", specifier: "@arcgis/toolkit/string" },
123
- camelToKebab: { do: "rename", specifier: "@arcgis/toolkit/string" },
124
- camelToHuman: { do: "rename", specifier: "@arcgis/toolkit/string" },
125
- capitalize: { do: "rename", specifier: "@arcgis/toolkit/string" },
126
- uncapitalize: { do: "rename", specifier: "@arcgis/toolkit/string" },
127
- GenericT9nStrings: { do: "rename", specifier: "@arcgis/toolkit/intl" },
128
- supportedLocales: { do: "rename", specifier: "@arcgis/toolkit/intl" },
129
- SupportedLocale: { do: "rename", specifier: "@arcgis/toolkit/intl" },
130
- defaultLocale: { do: "rename", specifier: "@arcgis/toolkit/intl" },
131
- fetchT9nStringsBundle: { do: "rename", specifier: "@arcgis/toolkit/intl" },
132
- normalizeLocale: { do: "rename", specifier: "@arcgis/toolkit/intl" },
133
- startLocaleObserver: { do: "rename", specifier: "@arcgis/toolkit/intl" },
134
- isNotNull: { do: "rename", specifier: "@arcgis/toolkit/predicate" },
135
- isNotUndefined: { do: "rename", specifier: "@arcgis/toolkit/predicate" },
136
- debounce: { do: "rename", specifier: "@arcgis/toolkit/function" },
137
- identity: { do: "rename", specifier: "@arcgis/toolkit/function" },
138
- hasSameOrigin: { do: "rename", specifier: "@arcgis/toolkit/url" }
139
- }
140
- });
141
- } catch (r) {
142
- var a = r, t = !0;
143
- } finally {
144
- f(i, a, t);
145
- }
146
- }
147
- h(), g(
148
- "info",
149
- y.codemodName,
150
- "Next step: run npm install/pnpm install/yarn install to get @arcgis/toolkit package installed."
151
- );
152
- }
153
- };
154
- export {
155
- C as codemod
156
- };