@youlai/rn-tools 0.1.2 → 0.1.3

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/index.mjs CHANGED
@@ -1,46 +1,46 @@
1
- import s from "node:path";
2
- import u from "node:fs";
1
+ import a from "node:path";
2
+ import $ from "node:fs";
3
3
  import ae from "picocolors";
4
- import { pathToFileURL as te } from "node:url";
5
- import P from "sharp";
6
- function se(e) {
7
- return u.readFileSync(e, "utf8");
4
+ import { pathToFileURL as se } from "node:url";
5
+ import M from "sharp";
6
+ function B(e) {
7
+ return $.readFileSync(e, "utf8");
8
8
  }
9
- function A(e) {
10
- return u.existsSync(e) ? se(e) : null;
9
+ function S(e) {
10
+ return $.existsSync(e) ? B(e) : null;
11
11
  }
12
- function $(e, n, r) {
13
- r || (u.mkdirSync(s.dirname(e), { recursive: !0 }), u.writeFileSync(e, n));
12
+ function x(e, n, r) {
13
+ r || ($.mkdirSync(a.dirname(e), { recursive: !0 }), $.writeFileSync(e, n));
14
14
  }
15
- function C(e, n) {
15
+ function _(e, n) {
16
16
  let r = e, o = !1;
17
- for (const [i, a] of n) {
18
- const t = r.replace(i, a);
19
- t !== r && (r = t, o = !0);
17
+ for (const [i, t] of n) {
18
+ const s = r.replace(i, t);
19
+ s !== r && (r = s, o = !0);
20
20
  }
21
21
  return { content: r, changed: o };
22
22
  }
23
- function L(e) {
24
- if (!u.existsSync(e))
23
+ function q(e) {
24
+ if (!$.existsSync(e))
25
25
  return [];
26
26
  const n = [], r = (o) => {
27
- for (const i of u.readdirSync(o, { withFileTypes: !0 })) {
28
- const a = s.join(o, i.name);
29
- i.isDirectory() ? r(a) : n.push(a);
27
+ for (const i of $.readdirSync(o, { withFileTypes: !0 })) {
28
+ const t = a.join(o, i.name);
29
+ i.isDirectory() ? r(t) : n.push(t);
30
30
  }
31
31
  };
32
32
  return r(e), n;
33
33
  }
34
34
  function de(e, n, r) {
35
- if (!u.existsSync(e) || e === n)
35
+ if (!$.existsSync(e) || e === n)
36
36
  return [];
37
- const o = L(e), i = [];
38
- for (const a of o) {
39
- const t = s.relative(e, a), d = s.join(n, t);
40
- if (u.existsSync(d))
37
+ const o = q(e), i = [];
38
+ for (const t of o) {
39
+ const s = a.relative(e, t), d = a.join(n, s);
40
+ if ($.existsSync(d))
41
41
  throw new Error(`Destination path already exists: ${d}`);
42
- r || (u.mkdirSync(s.dirname(d), { recursive: !0 }), u.renameSync(a, d)), i.push({
43
- from: a,
42
+ r || ($.mkdirSync(a.dirname(d), { recursive: !0 }), $.renameSync(t, d)), i.push({
43
+ from: t,
44
44
  to: d
45
45
  });
46
46
  }
@@ -48,29 +48,29 @@ function de(e, n, r) {
48
48
  }
49
49
  function ce(e) {
50
50
  let n = e;
51
- for (; n !== s.dirname(n); ) {
52
- if (!u.existsSync(n)) {
53
- n = s.dirname(n);
51
+ for (; n !== a.dirname(n); ) {
52
+ if (!$.existsSync(n)) {
53
+ n = a.dirname(n);
54
54
  continue;
55
55
  }
56
- if (u.readdirSync(n).length > 0)
56
+ if ($.readdirSync(n).length > 0)
57
57
  break;
58
- u.rmdirSync(n), n = s.dirname(n);
58
+ $.rmdirSync(n), n = a.dirname(n);
59
59
  }
60
60
  }
61
- function H(e, n) {
62
- return u.existsSync(e) ? (n || u.rmSync(e, { recursive: !0, force: !0 }), !0) : !1;
61
+ function ee(e, n) {
62
+ return $.existsSync(e) ? (n || $.rmSync(e, { recursive: !0, force: !0 }), !0) : !1;
63
63
  }
64
- function q(e) {
65
- return Q(e, "Info.plist", (n, r) => s.relative(n, r).split(s.sep).length === 2 && s.basename(r) === "Info.plist");
64
+ function P(e) {
65
+ return W(e, "Info.plist", (n, r) => a.relative(n, r).split(a.sep).length === 2 && a.basename(r) === "Info.plist");
66
66
  }
67
- function Q(e, n, r) {
68
- const o = s.join(e, "ios"), a = L(o).find((t) => r(o, t));
69
- if (!a)
67
+ function W(e, n, r) {
68
+ const o = a.join(e, "ios"), t = q(o).find((s) => r(o, s));
69
+ if (!t)
70
70
  throw new Error(`Could not find an iOS ${n} file under ${o}`);
71
- return a;
71
+ return t;
72
72
  }
73
- const W = {
73
+ const K = {
74
74
  debug: 0,
75
75
  info: 1,
76
76
  warn: 2,
@@ -97,340 +97,340 @@ function me() {
97
97
  ].join(":");
98
98
  }
99
99
  function pe(e, n, r, o) {
100
- const i = [], a = r.prefix ?? "rn-tools";
101
- return (r.timestamps ?? !0) && i.push(o.gray(me())), i.push(o.bold(a)), r.scope && i.push(o.magenta(r.scope)), r.dryRun && i.push(o.bgYellow(o.black(" DRY-RUN "))), i.push(fe(e, le[e], o)), i.push(n), i.join(" ");
100
+ const i = [], t = r.prefix ?? "rn-tools";
101
+ return (r.timestamps ?? !0) && i.push(o.gray(me())), i.push(o.bold(t)), r.scope && i.push(o.magenta(r.scope)), r.dryRun && i.push(o.bgYellow(o.black(" DRY-RUN "))), i.push(fe(e, le[e], o)), i.push(n), i.join(" ");
102
102
  }
103
- function B(e, n, r, o, i) {
104
- if (W[e] < W[o])
103
+ function U(e, n, r, o, i) {
104
+ if (K[e] < K[o])
105
105
  return;
106
- const a = pe(e, n, r, i);
106
+ const t = pe(e, n, r, i);
107
107
  if (e === "error") {
108
- console.error(a);
108
+ console.error(t);
109
109
  return;
110
110
  }
111
111
  if (e === "warn") {
112
- console.warn(a);
112
+ console.warn(t);
113
113
  return;
114
114
  }
115
- console.log(a);
115
+ console.log(t);
116
116
  }
117
117
  function ge(e = {}) {
118
118
  const n = ue(e), r = ae.createColors(e.color ?? !0);
119
119
  return {
120
120
  info(o) {
121
- B("info", o, e, n, r);
121
+ U("info", o, e, n, r);
122
122
  },
123
123
  warn(o) {
124
- B("warn", o, e, n, r);
124
+ U("warn", o, e, n, r);
125
125
  },
126
126
  error(o) {
127
- B("error", o, e, n, r);
127
+ U("error", o, e, n, r);
128
128
  },
129
129
  debug(o) {
130
- B("debug", o, e, n, r);
130
+ U("debug", o, e, n, r);
131
131
  }
132
132
  };
133
133
  }
134
- function T(e, n = {}) {
134
+ function O(e, n = {}) {
135
135
  return e ?? ge(n);
136
136
  }
137
- const Ie = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+$/, ee = ["java", "kotlin"];
137
+ const he = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+$/, ne = ["java", "kotlin"];
138
138
  function Z(e) {
139
- if (!Ie.test(e))
139
+ if (!he.test(e))
140
140
  throw new Error(
141
141
  `Invalid bundle id: ${e}. Use dot-separated Java package style names, for example com.example.app`
142
142
  );
143
143
  }
144
144
  async function ye(e) {
145
- var R, j, _, O;
146
- const n = s.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.verbose ?? !1, i = T(e.logger, {
145
+ var C, k, E, F;
146
+ const n = a.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.verbose ?? !1, i = O(e.logger, {
147
147
  dryRun: r,
148
148
  color: e.color,
149
149
  quiet: e.quiet,
150
150
  scope: "bundle-id",
151
151
  verbose: o
152
- }), a = e.androidPackage ?? e.bundleId, t = e.iosBundleId ?? e.bundleId;
153
- Z(a), Z(t);
154
- const d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), m = [], c = De(n);
155
- o && ((R = i.debug) == null || R.call(i, `rootDir=${n}`), (j = i.debug) == null || j.call(i, `androidPackage=${a}`), (_ = i.debug) == null || _.call(i, `iosBundleId=${t}`));
156
- const h = A(c.gradle);
157
- if (!h)
158
- throw new Error(`Android build file not found: ${c.gradle}`);
159
- const v = Ne(c.gradle) ?? a, w = C(h, [
160
- [/namespace\s+"[^"]+"/, `namespace "${a}"`],
161
- [/applicationId\s+"[^"]+"/, `applicationId "${a}"`]
152
+ }), t = e.androidPackage ?? e.bundleId, s = e.iosBundleId ?? e.bundleId;
153
+ Z(t), Z(s);
154
+ const d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), y = [], l = Ne(n);
155
+ o && ((C = i.debug) == null || C.call(i, `rootDir=${n}`), (k = i.debug) == null || k.call(i, `androidPackage=${t}`), (E = i.debug) == null || E.call(i, `iosBundleId=${s}`));
156
+ const b = S(l.gradle);
157
+ if (!b)
158
+ throw new Error(`Android build file not found: ${l.gradle}`);
159
+ const w = $e(l.gradle) ?? t, p = _(b, [
160
+ [/namespace\s+"[^"]+"/, `namespace "${t}"`],
161
+ [/applicationId\s+"[^"]+"/, `applicationId "${t}"`]
162
162
  ]);
163
- w.changed ? ($(c.gradle, w.content, r), d.add(c.gradle)) : f.add(`No namespace/applicationId changes were needed in ${c.gradle}`);
164
- const I = h.match(/^\s*applicationId\b(.*)$/m);
165
- I && !/^\s+"[^"]+"\s*$/.test(I[1]) && !I[1].includes(`"${a}"`) && f.add(
166
- `applicationId in ${c.gradle} is not a string literal; update it manually`
163
+ p.changed ? (x(l.gradle, p.content, r), d.add(l.gradle)) : u.add(`No namespace/applicationId changes were needed in ${l.gradle}`);
164
+ const f = b.match(/^\s*applicationId\b(.*)$/m);
165
+ f && !/^\s+"[^"]+"\s*$/.test(f[1]) && !f[1].includes(`"${t}"`) && u.add(
166
+ `applicationId in ${l.gradle} is not a string literal; update it manually`
167
167
  );
168
- const S = A(c.manifest);
169
- if (S) {
170
- const p = C(S, [
171
- [/package="[^"]+"/, `package="${a}"`],
172
- [/package\s*=\s*"[^"]+"/, `package="${a}"`]
168
+ const v = S(l.manifest);
169
+ if (v) {
170
+ const D = _(v, [
171
+ [/package="[^"]+"/, `package="${t}"`],
172
+ [/package\s*=\s*"[^"]+"/, `package="${t}"`]
173
173
  ]);
174
- p.changed && ($(c.manifest, p.content, r), d.add(c.manifest));
174
+ D.changed && (x(l.manifest, D.content, r), d.add(l.manifest));
175
175
  }
176
- const y = Ae(n), N = A(y);
176
+ const g = ve(n), N = S(g);
177
177
  if (!N)
178
- throw new Error(`iOS project file not found: ${y}`);
179
- const D = he(N, t);
180
- D.changed ? ($(y, D.content, r), d.add(y)) : D.matches === 0 ? f.add(`No PRODUCT_BUNDLE_IDENTIFIER setting found in ${y}`) : f.add(`No PRODUCT_BUNDLE_IDENTIFIER changes were needed in ${y}`);
181
- const g = q(n), l = A(g);
182
- if (l) {
183
- const p = l.match(
178
+ throw new Error(`iOS project file not found: ${g}`);
179
+ const h = Ie(N, s);
180
+ h.changed ? (x(g, h.content, r), d.add(g)) : h.matches === 0 ? u.add(`No PRODUCT_BUNDLE_IDENTIFIER setting found in ${g}`) : u.add(`No PRODUCT_BUNDLE_IDENTIFIER changes were needed in ${g}`);
181
+ const m = P(n), c = S(m);
182
+ if (c) {
183
+ const D = c.match(
184
184
  /<key>CFBundleIdentifier<\/key>\s*<string>([^<]+)<\/string>/
185
185
  );
186
- if (p && ne(p[1]))
187
- (O = i.debug) == null || O.call(i, `Kept build setting reference ${p[1]} in ${g}`);
186
+ if (D && re(D[1]))
187
+ (F = i.debug) == null || F.call(i, `Kept build setting reference ${D[1]} in ${m}`);
188
188
  else {
189
- const x = C(l, [
189
+ const R = _(c, [
190
190
  [
191
191
  /<key>CFBundleIdentifier<\/key>\s*<string>[^<]+<\/string>/,
192
192
  `<key>CFBundleIdentifier</key>
193
- <string>${t}</string>`
193
+ <string>${s}</string>`
194
194
  ]
195
195
  ]);
196
- x.changed && ($(g, x.content, r), d.add(g));
196
+ R.changed && (x(m, R.content, r), d.add(m));
197
197
  }
198
198
  }
199
- for (const p of ee) {
200
- const x = s.join(
199
+ for (const D of ne) {
200
+ const R = a.join(
201
201
  n,
202
202
  "android/app/src/main",
203
- p,
204
- ...v.split(".")
205
- ), k = s.join(
203
+ D,
204
+ ...w.split(".")
205
+ ), j = a.join(
206
206
  n,
207
207
  "android/app/src/main",
208
- p,
209
- ...a.split(".")
210
- ), ie = de(x, k, r);
211
- for (const oe of ie)
212
- m.push(oe);
208
+ D,
209
+ ...t.split(".")
210
+ ), oe = de(R, j, r);
211
+ for (const te of oe)
212
+ y.push(te);
213
213
  }
214
- const b = m.length > 0 ? m.map((p) => r ? p.from : p.to) : ve(n, v);
215
- for (const p of b) {
216
- const x = A(p);
217
- if (!x)
214
+ const I = y.length > 0 ? y.map((D) => r ? D.from : D.to) : De(n, w);
215
+ for (const D of I) {
216
+ const R = S(D);
217
+ if (!R)
218
218
  continue;
219
- const k = C(x, [
219
+ const j = _(R, [
220
220
  [
221
- new RegExp(`^package\\s+${we(v)}$`, "m"),
222
- `package ${a}`
221
+ new RegExp(`^package\\s+${be(w)}$`, "m"),
222
+ `package ${t}`
223
223
  ]
224
224
  ]);
225
- k.changed && ($(p, k.content, r), d.add(p));
225
+ j.changed && (x(D, j.content, r), d.add(D));
226
226
  }
227
- const F = {
227
+ const A = {
228
228
  changedFiles: Array.from(d).sort(),
229
- movedFiles: m,
230
- warnings: Array.from(f).sort(),
229
+ movedFiles: y,
230
+ warnings: Array.from(u).sort(),
231
231
  dryRun: r
232
232
  };
233
- return r ? i.info(`Dry-run completed with ${F.changedFiles.length} pending change(s)`) : i.info(`Updated ${F.changedFiles.length} file(s)`), F;
233
+ return r ? i.info(`Dry-run completed with ${A.changedFiles.length} pending change(s)`) : i.info(`Updated ${A.changedFiles.length} file(s)`), A;
234
234
  }
235
- function he(e, n) {
235
+ function Ie(e, n) {
236
236
  let r = 0;
237
237
  const o = e.replace(
238
238
  /PRODUCT_BUNDLE_IDENTIFIER = ("[^"\n]*"|[^;\n]+);/g,
239
- (i, a) => (r += 1, `PRODUCT_BUNDLE_IDENTIFIER = ${a.startsWith('"') ? `"${n}"` : n};`)
239
+ (i, t) => (r += 1, `PRODUCT_BUNDLE_IDENTIFIER = ${t.startsWith('"') ? `"${n}"` : n};`)
240
240
  );
241
241
  return { content: o, changed: o !== e, matches: r };
242
242
  }
243
- function ne(e) {
243
+ function re(e) {
244
244
  return /\$[({][A-Za-z0-9_:]+[)}]/.test(e);
245
245
  }
246
- function Ne(e) {
247
- const n = A(e);
246
+ function $e(e) {
247
+ const n = S(e);
248
248
  if (!n)
249
249
  return null;
250
250
  const r = n.match(/namespace\s+"([^"]+)"/);
251
251
  return (r == null ? void 0 : r[1]) ?? null;
252
252
  }
253
- function De(e) {
253
+ function Ne(e) {
254
254
  return {
255
- gradle: s.join(e, "android/app/build.gradle"),
256
- manifest: s.join(e, "android/app/src/main/AndroidManifest.xml"),
257
- javaRoot: s.join(e, "android/app/src/main/java"),
258
- kotlinRoot: s.join(e, "android/app/src/main/kotlin")
255
+ gradle: a.join(e, "android/app/build.gradle"),
256
+ manifest: a.join(e, "android/app/src/main/AndroidManifest.xml"),
257
+ javaRoot: a.join(e, "android/app/src/main/java"),
258
+ kotlinRoot: a.join(e, "android/app/src/main/kotlin")
259
259
  };
260
260
  }
261
- function Ae(e) {
262
- return Q(e, "project.pbxproj", (n, r) => s.relative(n, r).split(s.sep).length === 2 && r.endsWith(".xcodeproj/project.pbxproj"));
261
+ function ve(e) {
262
+ return W(e, "project.pbxproj", (n, r) => a.relative(n, r).split(a.sep).length === 2 && r.endsWith(".xcodeproj/project.pbxproj"));
263
263
  }
264
- function ve(e, n) {
265
- const r = ee.map(
266
- (i) => s.join(e, "android/app/src/main", i, ...n.split("."))
264
+ function De(e, n) {
265
+ const r = ne.map(
266
+ (i) => a.join(e, "android/app/src/main", i, ...n.split("."))
267
267
  ), o = [];
268
268
  for (const i of r)
269
- o.push(...L(i));
269
+ o.push(...q(i));
270
270
  return o;
271
271
  }
272
- function we(e) {
272
+ function be(e) {
273
273
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
274
274
  }
275
- const $e = [
275
+ const we = [
276
276
  "android/.gradle",
277
277
  "android/app/build",
278
278
  "ios/build",
279
279
  ".metro",
280
280
  ".expo"
281
281
  ];
282
- async function be(e) {
283
- var f;
284
- const n = s.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.verbose ?? !1, i = T(e.logger, {
282
+ async function Ae(e) {
283
+ var u;
284
+ const n = a.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.verbose ?? !1, i = O(e.logger, {
285
285
  dryRun: r,
286
286
  color: e.color,
287
287
  quiet: e.quiet,
288
288
  scope: "clean",
289
289
  verbose: o
290
290
  });
291
- o && ((f = i.debug) == null || f.call(i, `rootDir=${n}`));
292
- const a = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
293
- for (const m of $e) {
294
- const c = s.join(n, m);
295
- H(c, r) && (o && i.info(`${r ? "[dry-run] " : ""}clean target: ${c}`), a.add(c));
291
+ o && ((u = i.debug) == null || u.call(i, `rootDir=${n}`));
292
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
293
+ for (const y of we) {
294
+ const l = a.join(n, y);
295
+ ee(l, r) && (o && i.info(`${r ? "[dry-run] " : ""}clean target: ${l}`), t.add(l));
296
296
  }
297
297
  const d = {
298
- changedFiles: Array.from(a).sort(),
298
+ changedFiles: Array.from(t).sort(),
299
299
  movedFiles: [],
300
- warnings: Array.from(t).sort(),
300
+ warnings: Array.from(s).sort(),
301
301
  dryRun: r
302
302
  };
303
303
  return r ? i.info(`Dry-run completed with ${d.changedFiles.length} target(s)`) : i.info(`Cleaned ${d.changedFiles.length} target(s)`), d;
304
304
  }
305
- function xe(e) {
305
+ function Se(e) {
306
306
  if (!e || !e.trim())
307
307
  throw new Error("Display name cannot be empty");
308
308
  }
309
- async function Se(e) {
310
- var S, y;
311
- const n = s.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.verbose ?? !1, i = T(e.logger, {
309
+ async function xe(e) {
310
+ var v, g;
311
+ const n = a.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.verbose ?? !1, i = O(e.logger, {
312
312
  dryRun: r,
313
313
  color: e.color,
314
314
  quiet: e.quiet,
315
315
  scope: "display-name",
316
316
  verbose: o
317
- }), a = e.displayName.trim();
318
- xe(a), o && ((S = i.debug) == null || S.call(i, `rootDir=${n}`), (y = i.debug) == null || y.call(i, `displayName=${a}`));
319
- const t = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = s.join(n, "app.json"), m = A(f);
320
- if (m)
317
+ }), t = e.displayName.trim();
318
+ Se(t), o && ((v = i.debug) == null || v.call(i, `rootDir=${n}`), (g = i.debug) == null || g.call(i, `displayName=${t}`));
319
+ const s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), u = a.join(n, "app.json"), y = S(u);
320
+ if (y)
321
321
  try {
322
- const D = {
323
- ...JSON.parse(m),
324
- displayName: a
325
- }, g = `${JSON.stringify(D, null, 2)}
322
+ const h = {
323
+ ...JSON.parse(y),
324
+ displayName: t
325
+ }, m = `${JSON.stringify(h, null, 2)}
326
326
  `;
327
- g !== m && ($(f, g, r), t.add(f));
327
+ m !== y && (x(u, m, r), s.add(u));
328
328
  } catch {
329
- d.add(`Skipped invalid JSON file: ${f}`);
329
+ d.add(`Skipped invalid JSON file: ${u}`);
330
330
  }
331
- const c = q(n), h = A(c);
332
- if (h) {
331
+ const l = P(n), b = S(l);
332
+ if (b) {
333
333
  const N = [
334
334
  [
335
335
  /<key>CFBundleDisplayName<\/key>\s*<string>[^<]*<\/string>/,
336
336
  `<key>CFBundleDisplayName</key>
337
- <string>${a}</string>`
337
+ <string>${t}</string>`
338
338
  ]
339
- ], D = h.match(
339
+ ], h = b.match(
340
340
  /<key>CFBundleName<\/key>\s*<string>([^<]*)<\/string>/
341
341
  );
342
- (!D || !ne(D[1])) && N.push([
342
+ (!h || !re(h[1])) && N.push([
343
343
  /<key>CFBundleName<\/key>\s*<string>[^<]*<\/string>/,
344
344
  `<key>CFBundleName</key>
345
- <string>${a}</string>`
345
+ <string>${t}</string>`
346
346
  ]);
347
- const g = C(h, N);
348
- g.changed ? ($(c, g.content, r), t.add(c)) : d.add(`No iOS display-name changes were needed in ${c}`);
347
+ const m = _(b, N);
348
+ m.changed ? (x(l, m.content, r), s.add(l)) : d.add(`No iOS display-name changes were needed in ${l}`);
349
349
  }
350
- const v = s.join(n, "android/app/src/main/res/values/strings.xml"), w = A(v);
351
- if (w) {
352
- const N = C(w, [
353
- [/<string name="app_name">[^<]*<\/string>/, `<string name="app_name">${a}</string>`]
350
+ const w = a.join(n, "android/app/src/main/res/values/strings.xml"), p = S(w);
351
+ if (p) {
352
+ const N = _(p, [
353
+ [/<string name="app_name">[^<]*<\/string>/, `<string name="app_name">${t}</string>`]
354
354
  ]);
355
- N.changed ? ($(v, N.content, r), t.add(v)) : d.add(`No Android app_name changes were needed in ${v}`);
355
+ N.changed ? (x(w, N.content, r), s.add(w)) : d.add(`No Android app_name changes were needed in ${w}`);
356
356
  }
357
- const I = {
358
- changedFiles: Array.from(t).sort(),
357
+ const f = {
358
+ changedFiles: Array.from(s).sort(),
359
359
  movedFiles: [],
360
360
  warnings: Array.from(d).sort(),
361
361
  dryRun: r
362
362
  };
363
- return r ? i.info(`Dry-run completed with ${I.changedFiles.length} pending change(s)`) : i.info(`Updated ${I.changedFiles.length} file(s)`), I;
363
+ return r ? i.info(`Dry-run completed with ${f.changedFiles.length} pending change(s)`) : i.info(`Updated ${f.changedFiles.length} file(s)`), f;
364
364
  }
365
- async function Fe(e) {
366
- var y, N, D, g;
367
- const n = s.resolve(e.rootDir ?? process.cwd()), r = e.verbose ?? !1, o = T(e.logger, {
365
+ async function Re(e) {
366
+ var g, N, h, m;
367
+ const n = a.resolve(e.rootDir ?? process.cwd()), r = e.verbose ?? !1, o = O(e.logger, {
368
368
  color: e.color,
369
369
  quiet: e.quiet,
370
370
  scope: "doctor",
371
371
  verbose: r
372
372
  });
373
- r && ((y = o.debug) == null || y.call(o, `rootDir=${n}`));
374
- const i = /* @__PURE__ */ new Set(), a = [], t = {}, d = s.join(n, "app.json"), f = A(d);
375
- if (!f)
373
+ r && ((g = o.debug) == null || g.call(o, `rootDir=${n}`));
374
+ const i = /* @__PURE__ */ new Set(), t = [], s = {}, d = a.join(n, "app.json"), u = S(d);
375
+ if (!u)
376
376
  i.add(`Missing app.json: ${d}`);
377
377
  else
378
378
  try {
379
- const l = JSON.parse(f);
380
- t.appName = l.name, t.displayName = l.displayName, l.name || i.add(`Missing "name" in app.json: ${d}`), l.displayName || i.add(`Missing "displayName" in app.json: ${d}`);
379
+ const c = JSON.parse(u);
380
+ s.appName = c.name, s.displayName = c.displayName, c.name || i.add(`Missing "name" in app.json: ${d}`), c.displayName || i.add(`Missing "displayName" in app.json: ${d}`);
381
381
  } catch {
382
382
  i.add(`Invalid JSON: ${d}`);
383
383
  }
384
- const m = s.join(n, "android/app/build.gradle"), c = A(m);
385
- if (!c)
386
- i.add(`Missing Android build file: ${m}`);
384
+ const y = a.join(n, "android/app/build.gradle"), l = S(y);
385
+ if (!l)
386
+ i.add(`Missing Android build file: ${y}`);
387
387
  else {
388
- const l = (N = c.match(/namespace\s+"([^"]+)"/)) == null ? void 0 : N[1], b = (D = c.match(/applicationId\s+"([^"]+)"/)) == null ? void 0 : D[1];
389
- t.androidNamespace = l, t.androidApplicationId = b, l || i.add(`Missing namespace in ${m}`), b || i.add(`Missing applicationId in ${m}`), l && b && l !== b && i.add(`Android namespace and applicationId differ: ${l} vs ${b}`);
388
+ const c = (N = l.match(/namespace\s+"([^"]+)"/)) == null ? void 0 : N[1], I = (h = l.match(/applicationId\s+"([^"]+)"/)) == null ? void 0 : h[1];
389
+ s.androidNamespace = c, s.androidApplicationId = I, c || i.add(`Missing namespace in ${y}`), I || i.add(`Missing applicationId in ${y}`), c && I && c !== I && i.add(`Android namespace and applicationId differ: ${c} vs ${I}`);
390
390
  }
391
- const h = s.join(n, "android/app/src/main/res/values/strings.xml"), v = A(h);
392
- if (!v)
393
- i.add(`Missing Android strings: ${h}`);
391
+ const b = a.join(n, "android/app/src/main/res/values/strings.xml"), w = S(b);
392
+ if (!w)
393
+ i.add(`Missing Android strings: ${b}`);
394
394
  else {
395
- const l = (g = v.match(/<string name="app_name">([^<]+)<\/string>/)) == null ? void 0 : g[1];
396
- t.androidAppName = l, l || i.add(`Missing app_name in ${h}`);
395
+ const c = (m = w.match(/<string name="app_name">([^<]+)<\/string>/)) == null ? void 0 : m[1];
396
+ s.androidAppName = c, c || i.add(`Missing app_name in ${b}`);
397
397
  }
398
- const w = q(n), I = A(w);
399
- I ? (t.iosBundleId = M(I, "CFBundleIdentifier"), t.iosDisplayName = M(I, "CFBundleDisplayName"), t.iosName = M(I, "CFBundleName"), /<key>CFBundleIdentifier<\/key>/.test(I) || i.add(`Missing CFBundleIdentifier in ${w}`), /<key>CFBundleDisplayName<\/key>/.test(I) || i.add(`Missing CFBundleDisplayName in ${w}`)) : i.add(`Missing iOS Info.plist: ${w}`), L(s.join(n, "android/app/src/main")).filter(
400
- (l) => /\.(kt|java)$/.test(l)
401
- ).length === 0 && i.add("No Android source files found under android/app/src/main"), ke(t, i), t.appName && t.displayName && t.appName !== t.displayName && i.add(
402
- `app.json "name" and "displayName" differ: ${t.appName} vs ${t.displayName}`
398
+ const p = P(n), f = S(p);
399
+ f ? (s.iosBundleId = J(f, "CFBundleIdentifier"), s.iosDisplayName = J(f, "CFBundleDisplayName"), s.iosName = J(f, "CFBundleName"), /<key>CFBundleIdentifier<\/key>/.test(f) || i.add(`Missing CFBundleIdentifier in ${p}`), /<key>CFBundleDisplayName<\/key>/.test(f) || i.add(`Missing CFBundleDisplayName in ${p}`)) : i.add(`Missing iOS Info.plist: ${p}`), q(a.join(n, "android/app/src/main")).filter(
400
+ (c) => /\.(kt|java)$/.test(c)
401
+ ).length === 0 && i.add("No Android source files found under android/app/src/main"), Ce(s, i), s.appName && s.displayName && s.appName !== s.displayName && i.add(
402
+ `app.json "name" and "displayName" differ: ${s.appName} vs ${s.displayName}`
403
403
  );
404
- for (const l of i)
405
- o.warn(l);
404
+ for (const c of i)
405
+ o.warn(c);
406
406
  return i.size === 0 ? o.info("Doctor check passed") : o.info(`Doctor found ${i.size} issue(s)`), {
407
- changedFiles: a,
407
+ changedFiles: t,
408
408
  movedFiles: [],
409
409
  warnings: Array.from(i).sort(),
410
410
  dryRun: !0
411
411
  };
412
412
  }
413
- function M(e, n) {
413
+ function J(e, n) {
414
414
  var r;
415
415
  return (r = e.match(new RegExp(`<key>${n}<\\/key>\\s*<string>([^<]*)<\\/string>`))) == null ? void 0 : r[1];
416
416
  }
417
- function E(e) {
417
+ function T(e) {
418
418
  return typeof e == "string" && !e.startsWith("$(") && !e.startsWith("${");
419
419
  }
420
- function ke(e, n) {
420
+ function Ce(e, n) {
421
421
  e.androidNamespace && e.androidApplicationId && e.androidNamespace !== e.androidApplicationId && n.add(
422
422
  `Android namespace and applicationId differ: ${e.androidNamespace} vs ${e.androidApplicationId}`
423
- ), E(e.iosDisplayName) && E(e.iosName) && e.iosDisplayName !== e.iosName && n.add(
423
+ ), T(e.iosDisplayName) && T(e.iosName) && e.iosDisplayName !== e.iosName && n.add(
424
424
  `iOS CFBundleDisplayName and CFBundleName differ: ${e.iosDisplayName} vs ${e.iosName}`
425
425
  );
426
426
  const r = e.displayName;
427
- E(r) && (E(e.androidAppName) && e.androidAppName !== r && n.add(
427
+ T(r) && (T(e.androidAppName) && e.androidAppName !== r && n.add(
428
428
  `Android app_name does not match app.json displayName: ${e.androidAppName} vs ${r}`
429
- ), E(e.iosDisplayName) && e.iosDisplayName !== r && n.add(
429
+ ), T(e.iosDisplayName) && e.iosDisplayName !== r && n.add(
430
430
  `iOS CFBundleDisplayName does not match app.json displayName: ${e.iosDisplayName} vs ${r}`
431
431
  ));
432
432
  }
433
- const Ce = "assets/icon.png", Re = "android/app/src/main/res", je = "AppIcon.appiconset", _e = "ic_launcher", Oe = "ic_launcher_round", Ee = !0, Te = "#FFFFFF", Be = 0.72, ze = "#FFFFFF", re = [
433
+ const ke = "assets/icon.png", Fe = "android/app/src/main/res", Ee = "AppIcon.appiconset", je = "ic_launcher", _e = "ic_launcher_round", Oe = !0, Te = "#FFFFFF", Be = 0.72, Pe = "#FFFFFF", ie = [
434
434
  { dir: "mipmap-mdpi", size: 48 },
435
435
  { dir: "mipmap-hdpi", size: 72 },
436
436
  { dir: "mipmap-xhdpi", size: 96 },
@@ -442,7 +442,7 @@ const Ce = "assets/icon.png", Re = "android/app/src/main/res", je = "AppIcon.app
442
442
  { dir: "drawable-xhdpi", size: 216 },
443
443
  { dir: "drawable-xxhdpi", size: 324 },
444
444
  { dir: "drawable-xxxhdpi", size: 432 }
445
- ], V = [
445
+ ], X = [
446
446
  { idiom: "iphone", size: "20x20", scale: "2x", filename: "icon-20x20-2x-iphone.png" },
447
447
  { idiom: "iphone", size: "20x20", scale: "3x", filename: "icon-20x20-3x-iphone.png" },
448
448
  { idiom: "ipad", size: "20x20", scale: "1x", filename: "icon-20x20-1x-ipad.png" },
@@ -462,58 +462,58 @@ const Ce = "assets/icon.png", Re = "android/app/src/main/res", je = "AppIcon.app
462
462
  { idiom: "ipad", size: "83.5x83.5", scale: "2x", filename: "icon-83_5x83_5-2x-ipad.png" },
463
463
  { idiom: "ios-marketing", size: "1024x1024", scale: "1x", filename: "icon-1024x1024.png" }
464
464
  ];
465
- async function Pe(e) {
466
- var R, j, _, O, p, x;
467
- const n = await Qe(e.configPath, e.rootDir), r = Le(n, e), o = s.resolve(r.rootDir ?? process.cwd()), i = e.dryRun ?? !1, a = e.verbose ?? !1, t = T(e.logger, {
465
+ async function ze(e) {
466
+ var C, k, E, F, D, R;
467
+ const n = await Qe(e.configPath, e.rootDir), r = Le(n, e), o = a.resolve(r.rootDir ?? process.cwd()), i = e.dryRun ?? !1, t = e.verbose ?? !1, s = O(e.logger, {
468
468
  dryRun: i,
469
469
  color: e.color,
470
470
  quiet: e.quiet,
471
471
  scope: "icon",
472
- verbose: a
473
- }), d = G(
472
+ verbose: t
473
+ }), d = V(
474
474
  o,
475
- r.sourceImage ?? Ce
476
- ), f = G(
475
+ r.sourceImage ?? ke
476
+ ), u = V(
477
477
  o,
478
- r.androidDestinationDir ?? Re
479
- ), m = G(
478
+ r.androidDestinationDir ?? Fe
479
+ ), y = V(
480
480
  o,
481
481
  r.iosAssetsDir ?? sn(o)
482
- ), c = s.join(
483
- m,
484
- r.iosIconSetName ?? je
485
- ), h = r.androidIconName ?? _e, v = r.androidRoundIconName ?? Oe, w = r.androidAdaptiveIcon ?? Ee, I = r.androidAdaptiveIconBackgroundColor ?? Te, S = r.androidAdaptiveIconForegroundScale ?? Be, y = r.iosIconBackgroundColor ?? ze;
486
- a && ((R = t.debug) == null || R.call(t, `rootDir=${o}`), (j = t.debug) == null || j.call(t, `sourceImage=${d}`), (_ = t.debug) == null || _.call(t, `androidDestinationDir=${f}`), (O = t.debug) == null || O.call(t, `androidAdaptiveIcon=${w}`), (p = t.debug) == null || p.call(t, `iosAssetsDir=${m}`), (x = t.debug) == null || x.call(t, `iosIconSetDir=${c}`)), Je(d, "Icon source image"), Ze(S), Ve(d, f, c);
487
- const N = await Ke(d);
488
- We(N, d);
489
- const D = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set(), l = await qe({
482
+ ), l = a.join(
483
+ y,
484
+ r.iosIconSetName ?? Ee
485
+ ), b = r.androidIconName ?? je, w = r.androidRoundIconName ?? _e, p = r.androidAdaptiveIcon ?? Oe, f = r.androidAdaptiveIconBackgroundColor ?? Te, v = r.androidAdaptiveIconForegroundScale ?? Be, g = r.iosIconBackgroundColor ?? Pe;
486
+ t && ((C = s.debug) == null || C.call(s, `rootDir=${o}`), (k = s.debug) == null || k.call(s, `sourceImage=${d}`), (E = s.debug) == null || E.call(s, `androidDestinationDir=${u}`), (F = s.debug) == null || F.call(s, `androidAdaptiveIcon=${p}`), (D = s.debug) == null || D.call(s, `iosAssetsDir=${y}`), (R = s.debug) == null || R.call(s, `iosIconSetDir=${l}`)), Ve(d, "Icon source image"), We(v), Ke(d, u, l);
487
+ const N = await Xe(d);
488
+ Ge(N, d);
489
+ const h = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), c = await Me({
490
490
  sourceImage: d,
491
- destinationDir: f,
492
- iconName: h,
493
- roundIconName: v,
494
- adaptiveIcon: w,
495
- adaptiveIconBackgroundColor: I,
496
- adaptiveIconForegroundScale: S,
491
+ destinationDir: u,
492
+ iconName: b,
493
+ roundIconName: w,
494
+ adaptiveIcon: p,
495
+ adaptiveIconBackgroundColor: f,
496
+ adaptiveIconForegroundScale: v,
497
497
  dryRun: i
498
- }), b = await Me({
498
+ }), I = await qe({
499
499
  sourceImage: d,
500
- iconSetDir: c,
501
- backgroundColor: y,
500
+ iconSetDir: l,
501
+ backgroundColor: g,
502
502
  dryRun: i
503
503
  });
504
- (await P(d).stats()).isOpaque || g.add(
505
- `Icon source has transparent pixels; iOS icons were filled with ${y}`
504
+ (await M(d).stats()).isOpaque || m.add(
505
+ `Icon source has transparent pixels; iOS icons were filled with ${g}`
506
506
  );
507
- for (const k of [...l, ...b])
508
- D.add(k);
509
- l.length === 0 && g.add(`No Android icon files were generated from ${d}`), b.length === 0 && g.add(`No iOS icon files were generated from ${d}`);
510
- const F = {
511
- changedFiles: Array.from(D).sort(),
507
+ for (const j of [...c, ...I])
508
+ h.add(j);
509
+ c.length === 0 && m.add(`No Android icon files were generated from ${d}`), I.length === 0 && m.add(`No iOS icon files were generated from ${d}`);
510
+ const A = {
511
+ changedFiles: Array.from(h).sort(),
512
512
  movedFiles: [],
513
- warnings: Array.from(g).sort(),
513
+ warnings: Array.from(m).sort(),
514
514
  dryRun: i
515
515
  };
516
- return i ? t.info(`Dry-run completed with ${F.changedFiles.length} pending icon file(s)`) : t.info(`Generated ${F.changedFiles.length} icon file(s)`), F;
516
+ return i ? s.info(`Dry-run completed with ${A.changedFiles.length} pending icon file(s)`) : s.info(`Generated ${A.changedFiles.length} icon file(s)`), A;
517
517
  }
518
518
  function Le(e, n) {
519
519
  return {
@@ -521,57 +521,57 @@ function Le(e, n) {
521
521
  ...n
522
522
  };
523
523
  }
524
- async function qe(e) {
524
+ async function Me(e) {
525
525
  const n = [];
526
- for (const { dir: r, size: o } of re) {
527
- const i = s.join(e.destinationDir, r), a = s.join(i, `${e.iconName}.png`), t = s.join(i, `${e.roundIconName}.png`);
528
- e.dryRun || (u.mkdirSync(i, { recursive: !0 }), await J(e.sourceImage, a, o), await J(e.sourceImage, t, o)), n.push(a, t);
526
+ for (const { dir: r, size: o } of ie) {
527
+ const i = a.join(e.destinationDir, r), t = a.join(i, `${e.iconName}.png`), s = a.join(i, `${e.roundIconName}.png`);
528
+ e.dryRun || ($.mkdirSync(i, { recursive: !0 }), await G(e.sourceImage, t, o), await G(e.sourceImage, s, o)), n.push(t, s);
529
529
  }
530
530
  if (e.adaptiveIcon) {
531
531
  const r = `${e.iconName}_foreground`, o = `${e.iconName}_background`;
532
- for (const { dir: d, size: f } of Ue) {
533
- const m = s.join(e.destinationDir, d), c = s.join(m, `${r}.png`);
534
- e.dryRun || (u.mkdirSync(m, { recursive: !0 }), await Ye(
532
+ for (const { dir: d, size: u } of Ue) {
533
+ const y = a.join(e.destinationDir, d), l = a.join(y, `${r}.png`);
534
+ e.dryRun || ($.mkdirSync(y, { recursive: !0 }), await Ye(
535
535
  e.sourceImage,
536
- c,
537
- f,
536
+ l,
537
+ u,
538
538
  e.adaptiveIconForegroundScale
539
- )), n.push(c);
539
+ )), n.push(l);
540
540
  }
541
- const i = s.join(e.destinationDir, "values", `${o}.xml`), a = s.join(
541
+ const i = a.join(e.destinationDir, "values", `${o}.xml`), t = a.join(
542
542
  e.destinationDir,
543
543
  "mipmap-anydpi-v26",
544
544
  `${e.iconName}.xml`
545
- ), t = s.join(
545
+ ), s = a.join(
546
546
  e.destinationDir,
547
547
  "mipmap-anydpi-v26",
548
548
  `${e.roundIconName}.xml`
549
549
  );
550
- e.dryRun || ($(
550
+ e.dryRun || (x(
551
551
  i,
552
552
  He(o, e.adaptiveIconBackgroundColor),
553
553
  !1
554
- ), $(a, X(o, r), !1), $(
555
- t,
556
- X(o, r),
554
+ ), x(t, Y(o, r), !1), x(
555
+ s,
556
+ Y(o, r),
557
557
  !1
558
- )), n.push(i, a, t);
558
+ )), n.push(i, t, s);
559
559
  }
560
560
  return n;
561
561
  }
562
- async function Me(e) {
563
- const n = [], r = V.map((a) => ({
564
- idiom: a.idiom,
565
- size: a.size,
566
- scale: a.scale,
567
- filename: a.filename
562
+ async function qe(e) {
563
+ const n = [], r = X.map((t) => ({
564
+ idiom: t.idiom,
565
+ size: t.size,
566
+ scale: t.scale,
567
+ filename: t.filename
568
568
  }));
569
- e.dryRun || (H(e.iconSetDir, !1), u.mkdirSync(e.iconSetDir, { recursive: !0 }));
570
- for (const a of V) {
571
- const t = s.join(e.iconSetDir, a.filename), d = Ge(a.size, a.scale);
572
- e.dryRun || await J(e.sourceImage, t, d, e.backgroundColor), n.push(t);
569
+ e.dryRun || (ee(e.iconSetDir, !1), $.mkdirSync(e.iconSetDir, { recursive: !0 }));
570
+ for (const t of X) {
571
+ const s = a.join(e.iconSetDir, t.filename), d = Je(t.size, t.scale);
572
+ e.dryRun || await G(e.sourceImage, s, d, e.backgroundColor), n.push(s);
573
573
  }
574
- const o = s.join(e.iconSetDir, "Contents.json"), i = JSON.stringify(
574
+ const o = a.join(e.iconSetDir, "Contents.json"), i = JSON.stringify(
575
575
  {
576
576
  images: r,
577
577
  info: {
@@ -582,18 +582,18 @@ async function Me(e) {
582
582
  null,
583
583
  2
584
584
  );
585
- return e.dryRun || $(o, `${i}
585
+ return e.dryRun || x(o, `${i}
586
586
  `, !1), n.push(o), n;
587
587
  }
588
- function Ge(e, n) {
588
+ function Je(e, n) {
589
589
  const r = Number.parseFloat(e.split("x")[0] ?? "0"), o = Number.parseFloat(n.replace("x", ""));
590
590
  return Math.round(r * o);
591
591
  }
592
- function Je(e, n) {
593
- if (!u.existsSync(e))
592
+ function Ve(e, n) {
593
+ if (!$.existsSync(e))
594
594
  throw new Error(`${n} not found: ${e}`);
595
595
  }
596
- function We(e, n) {
596
+ function Ge(e, n) {
597
597
  if (!e.width || !e.height)
598
598
  throw new Error(`Unable to read image dimensions for ${n}`);
599
599
  if (e.width !== e.height)
@@ -601,17 +601,17 @@ function We(e, n) {
601
601
  `Icon source image must be square, but got ${e.width}x${e.height}: ${n}`
602
602
  );
603
603
  }
604
- function Ze(e) {
604
+ function We(e) {
605
605
  if (!Number.isFinite(e) || e <= 0 || e > 1)
606
606
  throw new Error(
607
607
  `Android adaptive icon foreground scale must be a number between 0 and 1, but got ${e}`
608
608
  );
609
609
  }
610
- function Ve(e, n, r) {
611
- const o = re.map(
612
- ({ dir: a }) => s.join(n, a)
610
+ function Ke(e, n, r) {
611
+ const o = ie.map(
612
+ ({ dir: t }) => a.join(n, t)
613
613
  ), i = [r, ...o].filter(
614
- (a) => Xe(e, a)
614
+ (t) => Ze(e, t)
615
615
  );
616
616
  if (i.length > 0)
617
617
  throw new Error(
@@ -619,24 +619,24 @@ function Ve(e, n, r) {
619
619
  Use a source file such as assets/icon.png instead: ${e}`
620
620
  );
621
621
  }
622
- function Xe(e, n) {
623
- const r = s.relative(n, e);
624
- return r === "" || !r.startsWith("..") && !s.isAbsolute(r);
622
+ function Ze(e, n) {
623
+ const r = a.relative(n, e);
624
+ return r === "" || !r.startsWith("..") && !a.isAbsolute(r);
625
625
  }
626
- function G(e, n) {
627
- return s.isAbsolute(n) ? n : s.join(e, n);
626
+ function V(e, n) {
627
+ return a.isAbsolute(n) ? n : a.join(e, n);
628
628
  }
629
- async function Ke(e) {
630
- return P(e).metadata();
629
+ async function Xe(e) {
630
+ return M(e).metadata();
631
631
  }
632
- async function J(e, n, r, o) {
633
- u.mkdirSync(s.dirname(n), { recursive: !0 });
634
- const i = P(e).resize(r, r, { fit: "fill" });
632
+ async function G(e, n, r, o) {
633
+ $.mkdirSync(a.dirname(n), { recursive: !0 });
634
+ const i = M(e).resize(r, r, { fit: "fill" });
635
635
  o && i.flatten({ background: o }).removeAlpha(), await i.png().toFile(n);
636
636
  }
637
637
  async function Ye(e, n, r, o) {
638
638
  const i = Math.max(1, Math.round(r * o));
639
- u.mkdirSync(s.dirname(n), { recursive: !0 }), await P(e).resize(i, i, { fit: "contain" }).extend({
639
+ $.mkdirSync(a.dirname(n), { recursive: !0 }), await M(e).resize(i, i, { fit: "contain" }).extend({
640
640
  top: Math.floor((r - i) / 2),
641
641
  bottom: Math.ceil((r - i) / 2),
642
642
  left: Math.floor((r - i) / 2),
@@ -654,7 +654,7 @@ function He(e, n) {
654
654
  ].join(`
655
655
  `);
656
656
  }
657
- function X(e, n) {
657
+ function Y(e, n) {
658
658
  return [
659
659
  '<?xml version="1.0" encoding="utf-8"?>',
660
660
  '<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">',
@@ -668,29 +668,29 @@ function X(e, n) {
668
668
  async function Qe(e, n) {
669
669
  if (!e) {
670
670
  const i = rn(n);
671
- return i ? K(i) : {};
671
+ return i ? H(i) : {};
672
672
  }
673
673
  nn(e);
674
- const r = en(e, n), o = r.find((i) => u.existsSync(i));
674
+ const r = en(e, n), o = r.find((i) => $.existsSync(i));
675
675
  if (!o)
676
- throw new Error(`Icon config file not found: ${r[0] ?? s.resolve(e)}`);
677
- return K(o);
676
+ throw new Error(`Icon config file not found: ${r[0] ?? a.resolve(e)}`);
677
+ return H(o);
678
678
  }
679
679
  function en(e, n) {
680
- if (s.isAbsolute(e))
680
+ if (a.isAbsolute(e))
681
681
  return [e];
682
- const r = s.resolve(process.cwd(), e), o = n ? s.resolve(n, e) : null, i = [r];
682
+ const r = a.resolve(process.cwd(), e), o = n ? a.resolve(n, e) : null, i = [r];
683
683
  return o && o !== r && i.push(o), i;
684
684
  }
685
685
  function nn(e) {
686
- const n = s.basename(e);
686
+ const n = a.basename(e);
687
687
  if (n === "rn-tools.config" || n.startsWith("rn-tools.config."))
688
688
  throw new Error(
689
689
  `Legacy visible config filenames are not supported: ${e}. Use .rn-toolsrc, .rn-toolsrc.json, .rn-toolsrc.js, .rn-toolsrc.cjs, or .rn-toolsrc.mjs instead.`
690
690
  );
691
691
  }
692
692
  function rn(e) {
693
- const n = [e ? s.resolve(e) : null, process.cwd()].filter(
693
+ const n = [e ? a.resolve(e) : null, process.cwd()].filter(
694
694
  (o) => !!o
695
695
  ), r = [
696
696
  ".rn-toolsrc",
@@ -701,16 +701,16 @@ function rn(e) {
701
701
  ];
702
702
  for (const o of n)
703
703
  for (const i of r) {
704
- const a = s.join(o, i);
705
- if (u.existsSync(a))
706
- return a;
704
+ const t = a.join(o, i);
705
+ if ($.existsSync(t))
706
+ return t;
707
707
  }
708
708
  return null;
709
709
  }
710
- async function K(e) {
711
- const n = s.extname(e).toLowerCase();
710
+ async function H(e) {
711
+ const n = a.extname(e).toLowerCase();
712
712
  if (n === ".json" || n === "") {
713
- const o = A(e);
713
+ const o = S(e);
714
714
  if (!o)
715
715
  throw new Error(`Icon config file not found: ${e}`);
716
716
  let i;
@@ -719,43 +719,134 @@ async function K(e) {
719
719
  } catch {
720
720
  throw new Error(`Icon config file is not valid JSON: ${e}`);
721
721
  }
722
- return Y(i, e);
722
+ return Q(i, e);
723
723
  }
724
- const r = await import(te(e).href);
725
- return Y(r, e);
724
+ const r = await import(se(e).href);
725
+ return Q(r, e);
726
726
  }
727
- function Y(e, n) {
727
+ function Q(e, n) {
728
728
  if (!e || typeof e != "object")
729
729
  throw new Error(`Icon config file must contain an object: ${n}`);
730
730
  const r = on(e);
731
731
  if (!r)
732
732
  throw new Error(`Icon config section must be an object: ${n}`);
733
- return tn(r, s.dirname(n));
733
+ return an(r, a.dirname(n));
734
734
  }
735
735
  function on(e) {
736
736
  if (!z(e))
737
737
  return null;
738
738
  const n = z(e.default) ? e.default : e;
739
- return an(n) ? z(n.icon) ? n.icon : null : z(n) ? n : null;
739
+ return tn(n) ? z(n.icon) ? n.icon : null : z(n) ? n : null;
740
740
  }
741
- function an(e) {
741
+ function tn(e) {
742
742
  return Object.prototype.hasOwnProperty.call(e, "icon");
743
743
  }
744
744
  function z(e) {
745
745
  return !!e && typeof e == "object" && !Array.isArray(e);
746
746
  }
747
- function tn(e, n) {
747
+ function an(e, n) {
748
748
  const r = {};
749
- return e.rootDir && (r.rootDir = U(n, e.rootDir)), e.sourceImage && (r.sourceImage = U(n, e.sourceImage)), e.androidDestinationDir && (r.androidDestinationDir = U(n, e.androidDestinationDir)), typeof e.androidAdaptiveIcon == "boolean" && (r.androidAdaptiveIcon = e.androidAdaptiveIcon), e.androidAdaptiveIconBackgroundColor && (r.androidAdaptiveIconBackgroundColor = e.androidAdaptiveIconBackgroundColor), typeof e.androidAdaptiveIconForegroundScale == "number" && (r.androidAdaptiveIconForegroundScale = e.androidAdaptiveIconForegroundScale), e.iosAssetsDir && (r.iosAssetsDir = U(n, e.iosAssetsDir)), e.iosIconSetName && (r.iosIconSetName = e.iosIconSetName), e.iosIconBackgroundColor && (r.iosIconBackgroundColor = e.iosIconBackgroundColor), e.androidIconName && (r.androidIconName = e.androidIconName), e.androidRoundIconName && (r.androidRoundIconName = e.androidRoundIconName), r;
749
+ return e.rootDir && (r.rootDir = L(n, e.rootDir)), e.sourceImage && (r.sourceImage = L(n, e.sourceImage)), e.androidDestinationDir && (r.androidDestinationDir = L(n, e.androidDestinationDir)), typeof e.androidAdaptiveIcon == "boolean" && (r.androidAdaptiveIcon = e.androidAdaptiveIcon), e.androidAdaptiveIconBackgroundColor && (r.androidAdaptiveIconBackgroundColor = e.androidAdaptiveIconBackgroundColor), typeof e.androidAdaptiveIconForegroundScale == "number" && (r.androidAdaptiveIconForegroundScale = e.androidAdaptiveIconForegroundScale), e.iosAssetsDir && (r.iosAssetsDir = L(n, e.iosAssetsDir)), e.iosIconSetName && (r.iosIconSetName = e.iosIconSetName), e.iosIconBackgroundColor && (r.iosIconBackgroundColor = e.iosIconBackgroundColor), e.androidIconName && (r.androidIconName = e.androidIconName), e.androidRoundIconName && (r.androidRoundIconName = e.androidRoundIconName), r;
750
750
  }
751
- function U(e, n) {
752
- return s.isAbsolute(n) ? n : s.resolve(e, n);
751
+ function L(e, n) {
752
+ return a.isAbsolute(n) ? n : a.resolve(e, n);
753
753
  }
754
754
  function sn(e) {
755
- const n = q(e);
756
- return s.join(s.dirname(n), "Images.xcassets");
755
+ const n = P(e);
756
+ return a.join(a.dirname(n), "Images.xcassets");
757
+ }
758
+ const dn = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
759
+ async function cn(e = {}) {
760
+ const n = a.resolve(e.rootDir ?? process.cwd()), r = e.dryRun ?? !1, o = e.platform ?? "all";
761
+ if (!["all", "android", "ios"].includes(o))
762
+ throw new Error("Platform must be all, android, or ios");
763
+ const i = a.join(n, "package.json"), t = B(i), s = JSON.parse(t), d = e.version ?? s.version;
764
+ if (typeof d != "string" || !dn.test(d))
765
+ throw new Error("Version must contain three non-negative integers, for example 1.2.3");
766
+ const u = e.buildNumber === void 0 ? void 0 : String(e.buildNumber);
767
+ if (u !== void 0 && (!/^[1-9]\d*$/.test(u) || Number(u) > 21e8))
768
+ throw new Error("Build number must be a positive integer no greater than 2100000000");
769
+ const y = O(e.logger, {
770
+ dryRun: r,
771
+ verbose: e.verbose,
772
+ quiet: e.quiet,
773
+ color: e.color,
774
+ scope: "version"
775
+ }), l = /* @__PURE__ */ new Map(), b = (p, f, v) => {
776
+ v !== f && l.set(p, v);
777
+ }, w = (p, f, v, g, N) => {
778
+ const h = p.match(f) ?? [], m = p.match(new RegExp(`^[ \\t]*${g}\\b[^\\r\\n]*`, "gm")) ?? [];
779
+ if (h.length === 0 || h.length !== m.length)
780
+ throw new Error(`Could not find a literal ${g} in ${N}`);
781
+ return f.lastIndex = 0, p.replace(f, v);
782
+ };
783
+ if (o === "all" || o === "android") {
784
+ const p = a.join(n, "android/app/build.gradle"), f = a.join(n, "android/app/build.gradle.kts"), v = S(p), g = v === null ? f : p, N = v ?? B(f);
785
+ let h = w(
786
+ N,
787
+ /^([ \t]*versionName[ \t]*(?:=[ \t]*)?)(["'])([^"'\r\n]*)\2([ \t]*;?[ \t]*(?:\/\/[^\r\n]*)?\r?)$/gm,
788
+ (m, c, I, A, C) => `${c}${I}${d}${I}${C}`,
789
+ "versionName",
790
+ g
791
+ );
792
+ u !== void 0 && (h = w(
793
+ h,
794
+ /^([ \t]*versionCode[ \t]*(?:=[ \t]*)?)(\d+)([ \t]*;?[ \t]*(?:\/\/[^\r\n]*)?\r?)$/gm,
795
+ (m, c, I, A) => `${c}${u}${A}`,
796
+ "versionCode",
797
+ g
798
+ )), b(g, N, h);
799
+ }
800
+ if (o === "all" || o === "ios") {
801
+ const p = W(
802
+ n,
803
+ "project.pbxproj",
804
+ (m, c) => a.relative(m, c).split(a.sep).length === 2 && a.dirname(c).endsWith(".xcodeproj") && a.basename(c) === "project.pbxproj"
805
+ ), f = B(p);
806
+ let v = w(
807
+ f,
808
+ /^([ \t]*MARKETING_VERSION[ \t]*=[ \t]*)("?)[\d.]+\2([ \t]*;[^\r\n]*\r?)$/gm,
809
+ (m, c, I, A) => `${c}${I}${d}${I}${A}`,
810
+ "MARKETING_VERSION",
811
+ p
812
+ );
813
+ u !== void 0 && (v = w(
814
+ v,
815
+ /^([ \t]*CURRENT_PROJECT_VERSION[ \t]*=[ \t]*)("?)[\d.]+\2([ \t]*;[^\r\n]*\r?)$/gm,
816
+ (m, c, I, A) => `${c}${I}${u}${I}${A}`,
817
+ "CURRENT_PROJECT_VERSION",
818
+ p
819
+ )), b(p, f, v);
820
+ const g = P(n), N = B(g);
821
+ let h = N;
822
+ for (const [m, c, I] of [
823
+ ["CFBundleShortVersionString", "MARKETING_VERSION", d],
824
+ ["CFBundleVersion", "CURRENT_PROJECT_VERSION", u]
825
+ ]) {
826
+ if (I === void 0) continue;
827
+ const A = new RegExp(`(<key>${m}</key>\\s*<string>)([^<]*)(</string>)`), C = h.match(A);
828
+ if (!C) throw new Error(`Could not find ${m} in ${g}`);
829
+ const k = C[2];
830
+ if (!(k === `$(${c})` || k === "${" + c + "}")) {
831
+ if (/\$[({]/.test(k))
832
+ throw new Error(`Unsupported ${m} reference ${k} in ${g}`);
833
+ h = h.replace(
834
+ A,
835
+ (E, F, D, R) => `${F}${I}${R}`
836
+ );
837
+ }
838
+ }
839
+ b(g, N, h);
840
+ }
841
+ e.version !== void 0 && s.version !== d && b(i, t, `${JSON.stringify({ ...s, version: d }, null, 2)}
842
+ `);
843
+ for (const [p, f] of l)
844
+ x(p, f, r);
845
+ return y.info(
846
+ `${r ? "Would set" : "Set"} version ${d}${u === void 0 ? "" : ` (${u})`}`
847
+ ), { changedFiles: [...l.keys()].sort(), movedFiles: [], warnings: [], dryRun: r };
757
848
  }
758
- const dn = {
849
+ const ln = {
759
850
  name: "bundle-id",
760
851
  description: "Rename the iOS bundle identifier and Android application package",
761
852
  async run(e, n) {
@@ -769,11 +860,11 @@ const dn = {
769
860
  logger: n.logger ?? e.logger
770
861
  });
771
862
  }
772
- }, cn = {
863
+ }, un = {
773
864
  name: "display-name",
774
865
  description: "Update the app display name on iOS and Android",
775
866
  async run(e, n) {
776
- return Se({
867
+ return xe({
777
868
  ...n,
778
869
  rootDir: n.rootDir ?? e.rootDir,
779
870
  dryRun: n.dryRun ?? e.dryRun,
@@ -783,11 +874,25 @@ const dn = {
783
874
  logger: n.logger ?? e.logger
784
875
  });
785
876
  }
786
- }, ln = {
877
+ }, fn = {
878
+ name: "version",
879
+ description: "Sync the app version and build number to Android and iOS",
880
+ async run(e, n) {
881
+ return cn({
882
+ ...n,
883
+ rootDir: n.rootDir ?? e.rootDir,
884
+ dryRun: n.dryRun ?? e.dryRun,
885
+ verbose: n.verbose ?? e.verbose,
886
+ quiet: n.quiet ?? e.quiet,
887
+ color: n.color ?? e.color,
888
+ logger: n.logger ?? e.logger
889
+ });
890
+ }
891
+ }, mn = {
787
892
  name: "clean",
788
893
  description: "Remove common build and cache artifacts",
789
894
  async run(e, n) {
790
- return be({
895
+ return Ae({
791
896
  ...n,
792
897
  rootDir: n.rootDir ?? e.rootDir,
793
898
  dryRun: n.dryRun ?? e.dryRun,
@@ -797,11 +902,11 @@ const dn = {
797
902
  logger: n.logger ?? e.logger
798
903
  });
799
904
  }
800
- }, un = {
905
+ }, pn = {
801
906
  name: "doctor",
802
907
  description: "Check common RN project health signals",
803
908
  async run(e, n) {
804
- return Fe({
909
+ return Re({
805
910
  ...n,
806
911
  rootDir: n.rootDir ?? e.rootDir,
807
912
  verbose: n.verbose ?? e.verbose,
@@ -810,11 +915,11 @@ const dn = {
810
915
  logger: n.logger ?? e.logger
811
916
  });
812
917
  }
813
- }, fn = {
918
+ }, gn = {
814
919
  name: "icon",
815
920
  description: "Generate Android and iOS app icons from a single source image",
816
921
  async run(e, n) {
817
- return Pe({
922
+ return ze({
818
923
  ...n,
819
924
  rootDir: n.rootDir ?? e.rootDir,
820
925
  dryRun: n.dryRun ?? e.dryRun,
@@ -825,12 +930,13 @@ const dn = {
825
930
  });
826
931
  }
827
932
  };
828
- function mn(e = [
829
- dn,
830
- cn,
933
+ function hn(e = [
831
934
  ln,
832
935
  un,
833
- fn
936
+ fn,
937
+ mn,
938
+ pn,
939
+ gn
834
940
  ]) {
835
941
  const n = /* @__PURE__ */ new Map();
836
942
  for (const o of e)
@@ -845,37 +951,39 @@ function mn(e = [
845
951
  registerTask(o) {
846
952
  return n.set(o.name, o), r;
847
953
  },
848
- async runTask(o, i, a) {
849
- const t = n.get(o);
850
- if (!t) {
954
+ async runTask(o, i, t) {
955
+ const s = n.get(o);
956
+ if (!s) {
851
957
  const d = Array.from(n.keys()).sort();
852
958
  throw new Error(
853
959
  `Unknown task "${o}". Available tasks: ${d.join(", ") || "(none)"}`
854
960
  );
855
961
  }
856
- return t.run(i, a);
962
+ return s.run(i, t);
857
963
  }
858
964
  };
859
965
  return r;
860
966
  }
861
- const pn = mn();
862
- async function Dn(e, n, r, o = pn) {
967
+ const yn = hn();
968
+ async function bn(e, n, r, o = yn) {
863
969
  return o.runTask(e, n, r);
864
970
  }
865
971
  export {
866
- Pe as buildIconAssets,
867
- dn as bundleIdTask,
868
- be as cleanProject,
869
- ln as cleanTask,
972
+ ze as buildIconAssets,
973
+ ln as bundleIdTask,
974
+ Ae as cleanProject,
975
+ mn as cleanTask,
870
976
  ge as createConsoleLogger,
871
- mn as createProjectToolRunner,
872
- pn as defaultProjectToolRunner,
873
- cn as displayNameTask,
874
- Fe as doctorProject,
875
- un as doctorTask,
876
- T as getLogger,
877
- fn as iconTask,
977
+ hn as createProjectToolRunner,
978
+ yn as defaultProjectToolRunner,
979
+ un as displayNameTask,
980
+ Re as doctorProject,
981
+ pn as doctorTask,
982
+ O as getLogger,
983
+ gn as iconTask,
878
984
  ye as renameBundleId,
879
- Dn as runProjectTask,
880
- Se as updateDisplayName
985
+ bn as runProjectTask,
986
+ xe as updateDisplayName,
987
+ cn as updateVersion,
988
+ fn as versionTask
881
989
  };