@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.
@@ -1,11 +1,11 @@
1
- var S = (n, e) => (e = Symbol[n]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + n), L = (n) => {
1
+ var L = (n, e) => (e = Symbol[n]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + n), D = (n) => {
2
2
  throw TypeError(n);
3
3
  };
4
- var D = (n, e, i) => {
4
+ var E = (n, e, i) => {
5
5
  if (e != null) {
6
- typeof e != "object" && typeof e != "function" && L("Object expected");
6
+ typeof e != "object" && typeof e != "function" && D("Object expected");
7
7
  var d, r;
8
- i && (d = e[S("asyncDispose")]), d === void 0 && (d = e[S("dispose")], i && (r = d)), typeof d != "function" && L("Object not disposable"), r && (d = function() {
8
+ i && (d = e[L("asyncDispose")]), d === void 0 && (d = e[L("dispose")], i && (r = d)), typeof d != "function" && D("Object not disposable"), r && (d = function() {
9
9
  try {
10
10
  r.call(this);
11
11
  } catch (s) {
@@ -14,7 +14,7 @@ var D = (n, e, i) => {
14
14
  }), n.push([i, d, e]);
15
15
  } else i && n.push([i]);
16
16
  return e;
17
- }, E = (n, e, i) => {
17
+ }, F = (n, e, i) => {
18
18
  var d = typeof SuppressedError == "function" ? SuppressedError : function(t, c, o, a) {
19
19
  return a = Error(o), a.name = "SuppressedError", a.error = t, a.suppressed = c, a;
20
20
  }, r = (t) => e = i ? new d(t, e, "An error was suppressed during disposal") : (i = !0, t), s = (t) => {
@@ -31,10 +31,10 @@ var D = (n, e, i) => {
31
31
  };
32
32
  import { log as y } from "@arcgis/toolkit/log";
33
33
  import { c as V } from "./useProjectInstance.js";
34
- import { mergeApiExtractorConfigs as O, loadApiExtractorConfig as _ } from "@arcgis/api-extractor/extractor/config";
35
- import { g as F } from "./cli.js";
36
- import { writeFile as I, readFile as j } from "node:fs/promises";
37
- import { join as W, relative as Q } from "node:path";
34
+ import { mergeApiExtractorConfigs as j, loadApiExtractorConfig as _ } from "@arcgis/api-extractor/extractor/config";
35
+ import { g as J } from "./cli.js";
36
+ import { writeFile as I, readFile as W } from "node:fs/promises";
37
+ import { path as K } from "@arcgis/node-toolkit/path";
38
38
  import { existsAsync as U } from "@arcgis/node-toolkit/file";
39
39
  import { ApiExtractor as Y } from "@arcgis/api-extractor/extractor/ApiExtractor";
40
40
  import { SyntaxKind as f } from "ts-morph";
@@ -68,11 +68,11 @@ function A(n) {
68
68
  return " (internal)";
69
69
  return "";
70
70
  }
71
- function X(n, e) {
71
+ function Q(n, e) {
72
72
  return H(n, e, "").join(`
73
73
  `);
74
74
  }
75
- const J = {};
75
+ const M = {};
76
76
  function H(n, e, i) {
77
77
  const r = [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(e)])].sort(), s = [];
78
78
  for (let t = 0; t < r.length; ++t) {
@@ -82,7 +82,7 @@ function H(n, e, i) {
82
82
  continue;
83
83
  s.push(`${i}- ${c}`);
84
84
  }
85
- const l = H(o ?? J, a ?? J, `${i} `);
85
+ const l = H(o ?? M, a ?? M, `${i} `);
86
86
  l.length > 0 && (o !== void 0 && a !== void 0 && s.push(`${i}${c}`), s.push(...l));
87
87
  }
88
88
  return s;
@@ -101,10 +101,10 @@ function x(n, e, i, d) {
101
101
  !t.tags.some((u) => u.tagName === "public") && !a && (s = !0, t.tags.unshift({ tagName: d ? "internal" : "public" }));
102
102
  }
103
103
  for (const a of t.tags) {
104
- const l = M(a.text ?? "", i);
104
+ const l = O(a.text ?? "", i);
105
105
  l !== a.text && (s = !0, a.text = l);
106
106
  }
107
- const o = Z(e);
107
+ const o = X(e);
108
108
  if (o !== void 0)
109
109
  for (const a of o)
110
110
  t.tags.some(
@@ -114,16 +114,16 @@ function x(n, e, i, d) {
114
114
  text: a.name.startsWith("_") ? a.name.slice(1) : a.name
115
115
  }));
116
116
  if (t.description !== void 0) {
117
- const a = M(t.description, i);
117
+ const a = O(t.description, i);
118
118
  a !== t.description && (s = !0, t.description = a);
119
119
  }
120
120
  s && (r === void 0 ? n.addJsDoc(t) : r.set(t));
121
121
  }
122
- function Z(n) {
122
+ function X(n) {
123
123
  if (n !== void 0)
124
124
  return "parameters" in n ? n.parameters : "kind" in n && n.kind === "interface" && n.supertypes === void 0 && n.type === void 0 && n.members?.length === 1 && (n.members[0].kind === "call-signature" || n.members[0].kind === "constructor") ? n.members[0].parameters : void 0;
125
125
  }
126
- function M(n, e) {
126
+ function O(n, e) {
127
127
  return n.replace(/\{@link +([^}]+)\}/gu, (i, d) => {
128
128
  const r = d.trim(), s = r.indexOf(" "), t = s === -1 ? r : r.slice(0, s), c = s === -1 ? "" : r.slice(s + 1).trim();
129
129
  if (t.startsWith("https://"))
@@ -151,8 +151,8 @@ function M(n, e) {
151
151
  return `{@link ${T}${v === void 0 ? "" : `#${v}`}${c === "" ? "" : ` ${c}`}}`;
152
152
  });
153
153
  }
154
- async function ee(n, e, i, d) {
155
- const r = [], s = O(e, {
154
+ async function Z(n, e, i, d) {
155
+ const r = [], s = j(e, {
156
156
  strict: !0,
157
157
  context: {
158
158
  logger: {
@@ -172,7 +172,7 @@ ${r.join(`
172
172
  `)}
173
173
  You don't need to run the codemod again - run \`${d}\` from inside ${n.logName} to verify the fixes.`
174
174
  );
175
- const o = G(c), a = X(i, o);
175
+ const o = G(c), a = Q(i, o);
176
176
  a.length > 0 && y(
177
177
  "error",
178
178
  n.logName,
@@ -182,14 +182,14 @@ ${a}
182
182
  For each added declaration, remove @public from it if it is not supposed to be public. For each removed declaration, add @public JSDoc tag if it needs to remain public.`
183
183
  );
184
184
  }
185
- const te = "1.0.0-0", ne = {
186
- version: te
185
+ const ee = "1.0.0-0", te = {
186
+ version: ee
187
187
  };
188
- async function oe(n) {
188
+ async function ne(n) {
189
189
  const e = n.contents.dependencies ?? {}, i = n.contents.devDependencies ?? {};
190
190
  if (i["@arcgis/api-extractor"] !== void 0)
191
191
  return;
192
- const d = i["@arcgis/lumina-compiler"] ?? e["@arcgis/typescript-config"] ?? e["@arcgis/toolkit"] ?? `^${ne.version}`;
192
+ const d = i["@arcgis/lumina-compiler"] ?? e["@arcgis/typescript-config"] ?? e["@arcgis/toolkit"] ?? `^${te.version}`;
193
193
  n.contents.devDependencies = {
194
194
  ...i,
195
195
  "@arcgis/api-extractor": d
@@ -201,19 +201,19 @@ async function oe(n) {
201
201
  `
202
202
  );
203
203
  }
204
- const we = {
204
+ const be = {
205
205
  meta: {
206
206
  needsTypeInformation: !1
207
207
  },
208
208
  async run() {
209
209
  y(
210
210
  "warn",
211
- F.codemodName,
211
+ J.codemodName,
212
212
  `This codemod automates most of the changes. It may print warnings or errors for manual follow-up work - ${$(["bold", "magenta"], "Carefully review the following log messages.")}
213
213
  `
214
214
  );
215
215
  const n = /* @__PURE__ */ new Set();
216
- for (const e of F.projectsData) {
216
+ for (const e of J.projectsData) {
217
217
  if (e.packageJson === void 0 || n.has(e.packageJson.filePath))
218
218
  continue;
219
219
  n.add(e.packageJson.filePath);
@@ -226,8 +226,8 @@ const we = {
226
226
  );
227
227
  continue;
228
228
  }
229
- await re(e);
230
- const s = W(e.cwd, "api-extractor.config.ts");
229
+ await ie(e);
230
+ const s = K.join(e.cwd, "api-extractor.config.ts");
231
231
  let t;
232
232
  const c = d ? "npm run build" : "npx api-extractor run";
233
233
  if (await U(s) && (t = await _(e.cwd, "api-extractor.config.ts"), t.strict === !0)) {
@@ -241,7 +241,7 @@ const we = {
241
241
  );
242
242
  continue;
243
243
  }
244
- const o = O(t ?? {}, {
244
+ const o = j(t ?? {}, {
245
245
  context: {
246
246
  cwd: e.cwd,
247
247
  // Explicitly don't write to disk, just in case config says otherwise
@@ -253,7 +253,7 @@ const we = {
253
253
  error: console.error
254
254
  }
255
255
  }
256
- }), a = await ie(o, d, e);
256
+ }), a = await oe(o, d, e);
257
257
  if (a !== void 0) {
258
258
  if (t === void 0)
259
259
  await I(
@@ -266,7 +266,7 @@ export const config: ApiExtractorConfig = {
266
266
  `
267
267
  );
268
268
  else {
269
- const l = await j(s, "utf-8"), u = l.replace(
269
+ const l = await W(s, "utf-8"), u = l.replace(
270
270
  /ApiExtractorConfig\s*=\s*\{\r?\n/u,
271
271
  `ApiExtractorConfig = {
272
272
  strict: true,
@@ -278,12 +278,12 @@ export const config: ApiExtractorConfig = {
278
278
  `Could not automatically add "strict: true" option to ${s}.`
279
279
  ) : await I(s, u);
280
280
  }
281
- await oe(e.packageJson), await ee(e, o, a, c);
281
+ await ne(e.packageJson), await Z(e, o, a, c);
282
282
  }
283
283
  }
284
284
  }
285
285
  };
286
- async function ie(n, e, i) {
286
+ async function oe(n, e, i) {
287
287
  var o = [];
288
288
  try {
289
289
  const d = new Y(n);
@@ -301,10 +301,10 @@ async function ie(n, e, i) {
301
301
  );
302
302
  T !== void 0 && (t[T.name] = { component: T, modulePath: h.path });
303
303
  }
304
- const c = D(o, V(i));
304
+ const c = E(o, V(i));
305
305
  for (const h of c.getCodemodFiles()) {
306
- const T = Q(i.cwd, h.getFilePath());
307
- se(h);
306
+ const T = K.relative(i.cwd, h.getFilePath());
307
+ re(h);
308
308
  const v = s.get(T), N = v?.declarations.find(
309
309
  (m) => m.kind === "class" && m.customElement === !0
310
310
  )?.docsTags?.some((m) => m.name === "internal") ?? !1, w = v?.declarations.find((m) => m.kind === "class"), b = v === void 0 ? void 0 : new Map(v.declarations.map((m) => [m.name, m]));
@@ -316,9 +316,9 @@ async function ie(n, e, i) {
316
316
  const p = m.getName(), g = b?.get(p) ?? (p.endsWith("Properties") && w?.name === p.slice(0, -10) ? w : void 0);
317
317
  if (x(m, g, t, N), g !== void 0) {
318
318
  const P = m.getTypeNode();
319
- (P === void 0 ? [] : P.isKind(f.IntersectionType) ? P.getTypeNodes() : [P]).forEach((K) => {
320
- if (K.isKind(f.TypeLiteral)) {
321
- let k = K;
319
+ (P === void 0 ? [] : P.isKind(f.IntersectionType) ? P.getTypeNodes() : [P]).forEach((S) => {
320
+ if (S.isKind(f.TypeLiteral)) {
321
+ let k = S;
322
322
  if (!k.getText().includes(`
323
323
  `) && k.getMembers().length > 0) {
324
324
  const R = k.getMembers().map((z) => ` ${z.getFullText()}`).join(`
@@ -351,14 +351,14 @@ ${R}
351
351
  } catch (a) {
352
352
  var l = a, u = !0;
353
353
  } finally {
354
- E(o, l, u);
354
+ F(o, l, u);
355
355
  }
356
356
  }
357
- async function re(n) {
358
- const e = W(n.cwd, "vite.config.ts");
357
+ async function ie(n) {
358
+ const e = K.join(n.cwd, "vite.config.ts");
359
359
  if (!await U(e))
360
360
  return;
361
- const i = await j(e, "utf-8");
361
+ const i = await W(e, "utf-8");
362
362
  if (!i.includes("useLumina"))
363
363
  return;
364
364
  const r = [
@@ -386,7 +386,7 @@ async function re(n) {
386
386
  `
387
387
  );
388
388
  }
389
- function se(n) {
389
+ function re(n) {
390
390
  const e = n.getFullText(), i = e.indexOf("identity<typeof");
391
391
  if (i === -1)
392
392
  return;
@@ -432,5 +432,5 @@ function C(n, e, i, d) {
432
432
  );
433
433
  }
434
434
  export {
435
- we as codemod
435
+ be as codemod
436
436
  };