@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/cli.mjs CHANGED
@@ -1,95 +1,95 @@
1
1
  #!/usr/bin/env node
2
2
  import s from "node:path";
3
- import m from "node:fs";
4
- import mn from "picocolors";
5
- import { pathToFileURL as gn } from "node:url";
6
- import L from "sharp";
7
- function hn(n) {
8
- return m.readFileSync(n, "utf8");
9
- }
10
- function N(n) {
11
- return m.existsSync(n) ? hn(n) : null;
12
- }
13
- function x(n, e, o) {
14
- o || (m.mkdirSync(s.dirname(n), { recursive: !0 }), m.writeFileSync(n, e));
15
- }
16
- function R(n, e) {
17
- let o = n, i = !1;
18
- for (const [r, a] of e) {
19
- const t = o.replace(r, a);
20
- t !== o && (o = t, i = !0);
3
+ import w from "node:fs";
4
+ import gn from "picocolors";
5
+ import { pathToFileURL as hn } from "node:url";
6
+ import V from "sharp";
7
+ function U(n) {
8
+ return w.readFileSync(n, "utf8");
9
+ }
10
+ function k(n) {
11
+ return w.existsSync(n) ? U(n) : null;
12
+ }
13
+ function S(n, e, o) {
14
+ o || (w.mkdirSync(s.dirname(n), { recursive: !0 }), w.writeFileSync(n, e));
15
+ }
16
+ function _(n, e) {
17
+ let o = n, r = !1;
18
+ for (const [i, a] of e) {
19
+ const t = o.replace(i, a);
20
+ t !== o && (o = t, r = !0);
21
21
  }
22
- return { content: o, changed: i };
22
+ return { content: o, changed: r };
23
23
  }
24
- function M(n) {
25
- if (!m.existsSync(n))
24
+ function G(n) {
25
+ if (!w.existsSync(n))
26
26
  return [];
27
- const e = [], o = (i) => {
28
- for (const r of m.readdirSync(i, { withFileTypes: !0 })) {
29
- const a = s.join(i, r.name);
30
- r.isDirectory() ? o(a) : e.push(a);
27
+ const e = [], o = (r) => {
28
+ for (const i of w.readdirSync(r, { withFileTypes: !0 })) {
29
+ const a = s.join(r, i.name);
30
+ i.isDirectory() ? o(a) : e.push(a);
31
31
  }
32
32
  };
33
33
  return o(n), e;
34
34
  }
35
35
  function yn(n, e, o) {
36
- if (!m.existsSync(n) || n === e)
36
+ if (!w.existsSync(n) || n === e)
37
37
  return [];
38
- const i = M(n), r = [];
39
- for (const a of i) {
38
+ const r = G(n), i = [];
39
+ for (const a of r) {
40
40
  const t = s.relative(n, a), d = s.join(e, t);
41
- if (m.existsSync(d))
41
+ if (w.existsSync(d))
42
42
  throw new Error(`Destination path already exists: ${d}`);
43
- o || (m.mkdirSync(s.dirname(d), { recursive: !0 }), m.renameSync(a, d)), r.push({
43
+ o || (w.mkdirSync(s.dirname(d), { recursive: !0 }), w.renameSync(a, d)), i.push({
44
44
  from: a,
45
45
  to: d
46
46
  });
47
47
  }
48
- return o || In(n), r;
48
+ return o || vn(n), i;
49
49
  }
50
- function In(n) {
50
+ function vn(n) {
51
51
  let e = n;
52
52
  for (; e !== s.dirname(e); ) {
53
- if (!m.existsSync(e)) {
53
+ if (!w.existsSync(e)) {
54
54
  e = s.dirname(e);
55
55
  continue;
56
56
  }
57
- if (m.readdirSync(e).length > 0)
57
+ if (w.readdirSync(e).length > 0)
58
58
  break;
59
- m.rmdirSync(e), e = s.dirname(e);
59
+ w.rmdirSync(e), e = s.dirname(e);
60
60
  }
61
61
  }
62
- function tn(n, e) {
63
- return m.existsSync(n) ? (e || m.rmSync(n, { recursive: !0, force: !0 }), !0) : !1;
62
+ function sn(n, e) {
63
+ return w.existsSync(n) ? (e || w.rmSync(n, { recursive: !0, force: !0 }), !0) : !1;
64
64
  }
65
- function G(n) {
66
- return an(n, "Info.plist", (e, o) => s.relative(e, o).split(s.sep).length === 2 && s.basename(o) === "Info.plist");
65
+ function z(n) {
66
+ return Z(n, "Info.plist", (e, o) => s.relative(e, o).split(s.sep).length === 2 && s.basename(o) === "Info.plist");
67
67
  }
68
- function an(n, e, o) {
69
- const i = s.join(n, "ios"), a = M(i).find((t) => o(i, t));
68
+ function Z(n, e, o) {
69
+ const r = s.join(n, "ios"), a = G(r).find((t) => o(r, t));
70
70
  if (!a)
71
- throw new Error(`Could not find an iOS ${e} file under ${i}`);
71
+ throw new Error(`Could not find an iOS ${e} file under ${r}`);
72
72
  return a;
73
73
  }
74
- const Z = {
74
+ const X = {
75
75
  debug: 0,
76
76
  info: 1,
77
77
  warn: 2,
78
78
  error: 3,
79
79
  silent: 4
80
- }, bn = {
80
+ }, In = {
81
81
  debug: "DEBUG",
82
82
  info: "INFO ",
83
83
  warn: "WARN ",
84
84
  error: "ERROR"
85
85
  };
86
- function vn(n) {
86
+ function bn(n) {
87
87
  return n.level ? n.level : n.quiet ? "warn" : n.verbose || process.env.RN_TOOLS_DEBUG === "1" ? "debug" : "info";
88
88
  }
89
89
  function wn(n, e, o) {
90
90
  return n === "debug" ? o.gray(e) : n === "info" ? o.cyan(e) : n === "warn" ? o.yellow(e) : o.red(e);
91
91
  }
92
- function Dn() {
92
+ function $n() {
93
93
  const n = /* @__PURE__ */ new Date();
94
94
  return [
95
95
  n.getHours().toString().padStart(2, "0"),
@@ -97,14 +97,14 @@ function Dn() {
97
97
  n.getSeconds().toString().padStart(2, "0")
98
98
  ].join(":");
99
99
  }
100
- function Nn(n, e, o, i) {
101
- const r = [], a = o.prefix ?? "rn-tools";
102
- return (o.timestamps ?? !0) && r.push(i.gray(Dn())), r.push(i.bold(a)), o.scope && r.push(i.magenta(o.scope)), o.dryRun && r.push(i.bgYellow(i.black(" DRY-RUN "))), r.push(wn(n, bn[n], i)), r.push(e), r.join(" ");
100
+ function Nn(n, e, o, r) {
101
+ const i = [], a = o.prefix ?? "rn-tools";
102
+ return (o.timestamps ?? !0) && i.push(r.gray($n())), i.push(r.bold(a)), o.scope && i.push(r.magenta(o.scope)), o.dryRun && i.push(r.bgYellow(r.black(" DRY-RUN "))), i.push(wn(n, In[n], r)), i.push(e), i.join(" ");
103
103
  }
104
- function P(n, e, o, i, r) {
105
- if (Z[n] < Z[i])
104
+ function q(n, e, o, r, i) {
105
+ if (X[n] < X[r])
106
106
  return;
107
- const a = Nn(n, e, o, r);
107
+ const a = Nn(n, e, o, i);
108
108
  if (n === "error") {
109
109
  console.error(a);
110
110
  return;
@@ -115,137 +115,137 @@ function P(n, e, o, i, r) {
115
115
  }
116
116
  console.log(a);
117
117
  }
118
- function sn(n = {}) {
119
- const e = vn(n), o = mn.createColors(n.color ?? !0);
118
+ function dn(n = {}) {
119
+ const e = bn(n), o = gn.createColors(n.color ?? !0);
120
120
  return {
121
- info(i) {
122
- P("info", i, n, e, o);
121
+ info(r) {
122
+ q("info", r, n, e, o);
123
123
  },
124
- warn(i) {
125
- P("warn", i, n, e, o);
124
+ warn(r) {
125
+ q("warn", r, n, e, o);
126
126
  },
127
- error(i) {
128
- P("error", i, n, e, o);
127
+ error(r) {
128
+ q("error", r, n, e, o);
129
129
  },
130
- debug(i) {
131
- P("debug", i, n, e, o);
130
+ debug(r) {
131
+ q("debug", r, n, e, o);
132
132
  }
133
133
  };
134
134
  }
135
135
  function T(n, e = {}) {
136
- return n ?? sn(e);
136
+ return n ?? dn(e);
137
137
  }
138
- const An = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+$/, dn = ["java", "kotlin"];
139
- function X(n) {
140
- if (!An.test(n))
138
+ const Dn = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+$/, cn = ["java", "kotlin"];
139
+ function Y(n) {
140
+ if (!Dn.test(n))
141
141
  throw new Error(
142
142
  `Invalid bundle id: ${n}. Use dot-separated Java package style names, for example com.example.app`
143
143
  );
144
144
  }
145
- async function xn(n) {
146
- var O, E, j, _;
147
- const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, i = n.verbose ?? !1, r = T(n.logger, {
145
+ async function An(n) {
146
+ var F, E, O, C;
147
+ const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, r = n.verbose ?? !1, i = T(n.logger, {
148
148
  dryRun: o,
149
149
  color: n.color,
150
150
  quiet: n.quiet,
151
151
  scope: "bundle-id",
152
- verbose: i
152
+ verbose: r
153
153
  }), a = n.androidPackage ?? n.bundleId, t = n.iosBundleId ?? n.bundleId;
154
- X(a), X(t);
155
- const d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), c = [], l = Sn(e);
156
- i && ((O = r.debug) == null || O.call(r, `rootDir=${e}`), (E = r.debug) == null || E.call(r, `androidPackage=${a}`), (j = r.debug) == null || j.call(r, `iosBundleId=${t}`));
157
- const f = N(l.gradle);
158
- if (!f)
159
- throw new Error(`Android build file not found: ${l.gradle}`);
160
- const I = kn(l.gradle) ?? a, A = R(f, [
154
+ Y(a), Y(t);
155
+ const d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), c = [], f = Sn(e);
156
+ r && ((F = i.debug) == null || F.call(i, `rootDir=${e}`), (E = i.debug) == null || E.call(i, `androidPackage=${a}`), (O = i.debug) == null || O.call(i, `iosBundleId=${t}`));
157
+ const g = k(f.gradle);
158
+ if (!g)
159
+ throw new Error(`Android build file not found: ${f.gradle}`);
160
+ const N = kn(f.gradle) ?? a, h = _(g, [
161
161
  [/namespace\s+"[^"]+"/, `namespace "${a}"`],
162
162
  [/applicationId\s+"[^"]+"/, `applicationId "${a}"`]
163
163
  ]);
164
- A.changed ? (x(l.gradle, A.content, o), d.add(l.gradle)) : u.add(`No namespace/applicationId changes were needed in ${l.gradle}`);
165
- const b = f.match(/^\s*applicationId\b(.*)$/m);
166
- b && !/^\s+"[^"]+"\s*$/.test(b[1]) && !b[1].includes(`"${a}"`) && u.add(
167
- `applicationId in ${l.gradle} is not a string literal; update it manually`
164
+ h.changed ? (S(f.gradle, h.content, o), d.add(f.gradle)) : u.add(`No namespace/applicationId changes were needed in ${f.gradle}`);
165
+ const p = g.match(/^\s*applicationId\b(.*)$/m);
166
+ p && !/^\s+"[^"]+"\s*$/.test(p[1]) && !p[1].includes(`"${a}"`) && u.add(
167
+ `applicationId in ${f.gradle} is not a string literal; update it manually`
168
168
  );
169
- const S = N(l.manifest);
170
- if (S) {
171
- const g = R(S, [
169
+ const D = k(f.manifest);
170
+ if (D) {
171
+ const A = _(D, [
172
172
  [/package="[^"]+"/, `package="${a}"`],
173
173
  [/package\s*=\s*"[^"]+"/, `package="${a}"`]
174
174
  ]);
175
- g.changed && (x(l.manifest, g.content, o), d.add(l.manifest));
175
+ A.changed && (S(f.manifest, A.content, o), d.add(f.manifest));
176
176
  }
177
- const v = Fn(e), w = N(v);
178
- if (!w)
179
- throw new Error(`iOS project file not found: ${v}`);
180
- const D = $n(w, t);
181
- D.changed ? (x(v, D.content, o), d.add(v)) : D.matches === 0 ? u.add(`No PRODUCT_BUNDLE_IDENTIFIER setting found in ${v}`) : u.add(`No PRODUCT_BUNDLE_IDENTIFIER changes were needed in ${v}`);
182
- const y = G(e), p = N(y);
183
- if (p) {
184
- const g = p.match(
177
+ const y = Rn(e), $ = k(y);
178
+ if (!$)
179
+ throw new Error(`iOS project file not found: ${y}`);
180
+ const v = xn($, t);
181
+ v.changed ? (S(y, v.content, o), d.add(y)) : v.matches === 0 ? u.add(`No PRODUCT_BUNDLE_IDENTIFIER setting found in ${y}`) : u.add(`No PRODUCT_BUNDLE_IDENTIFIER changes were needed in ${y}`);
182
+ const m = z(e), l = k(m);
183
+ if (l) {
184
+ const A = l.match(
185
185
  /<key>CFBundleIdentifier<\/key>\s*<string>([^<]+)<\/string>/
186
186
  );
187
- if (g && cn(g[1]))
188
- (_ = r.debug) == null || _.call(r, `Kept build setting reference ${g[1]} in ${y}`);
187
+ if (A && ln(A[1]))
188
+ (C = i.debug) == null || C.call(i, `Kept build setting reference ${A[1]} in ${m}`);
189
189
  else {
190
- const k = R(p, [
190
+ const R = _(l, [
191
191
  [
192
192
  /<key>CFBundleIdentifier<\/key>\s*<string>[^<]+<\/string>/,
193
193
  `<key>CFBundleIdentifier</key>
194
194
  <string>${t}</string>`
195
195
  ]
196
196
  ]);
197
- k.changed && (x(y, k.content, o), d.add(y));
197
+ R.changed && (S(m, R.content, o), d.add(m));
198
198
  }
199
199
  }
200
- for (const g of dn) {
201
- const k = s.join(
200
+ for (const A of cn) {
201
+ const R = s.join(
202
202
  e,
203
203
  "android/app/src/main",
204
- g,
205
- ...I.split(".")
206
- ), C = s.join(
204
+ A,
205
+ ...N.split(".")
206
+ ), j = s.join(
207
207
  e,
208
208
  "android/app/src/main",
209
- g,
209
+ A,
210
210
  ...a.split(".")
211
- ), fn = yn(k, C, o);
212
- for (const pn of fn)
213
- c.push(pn);
211
+ ), pn = yn(R, j, o);
212
+ for (const mn of pn)
213
+ c.push(mn);
214
214
  }
215
- const $ = c.length > 0 ? c.map((g) => o ? g.from : g.to) : Cn(e, I);
216
- for (const g of $) {
217
- const k = N(g);
218
- if (!k)
215
+ const I = c.length > 0 ? c.map((A) => o ? A.from : A.to) : Fn(e, N);
216
+ for (const A of I) {
217
+ const R = k(A);
218
+ if (!R)
219
219
  continue;
220
- const C = R(k, [
220
+ const j = _(R, [
221
221
  [
222
- new RegExp(`^package\\s+${Rn(I)}$`, "m"),
222
+ new RegExp(`^package\\s+${En(N)}$`, "m"),
223
223
  `package ${a}`
224
224
  ]
225
225
  ]);
226
- C.changed && (x(g, C.content, o), d.add(g));
226
+ j.changed && (S(A, j.content, o), d.add(A));
227
227
  }
228
- const F = {
228
+ const x = {
229
229
  changedFiles: Array.from(d).sort(),
230
230
  movedFiles: c,
231
231
  warnings: Array.from(u).sort(),
232
232
  dryRun: o
233
233
  };
234
- return o ? r.info(`Dry-run completed with ${F.changedFiles.length} pending change(s)`) : r.info(`Updated ${F.changedFiles.length} file(s)`), F;
234
+ return o ? i.info(`Dry-run completed with ${x.changedFiles.length} pending change(s)`) : i.info(`Updated ${x.changedFiles.length} file(s)`), x;
235
235
  }
236
- function $n(n, e) {
236
+ function xn(n, e) {
237
237
  let o = 0;
238
- const i = n.replace(
238
+ const r = n.replace(
239
239
  /PRODUCT_BUNDLE_IDENTIFIER = ("[^"\n]*"|[^;\n]+);/g,
240
- (r, a) => (o += 1, `PRODUCT_BUNDLE_IDENTIFIER = ${a.startsWith('"') ? `"${e}"` : e};`)
240
+ (i, a) => (o += 1, `PRODUCT_BUNDLE_IDENTIFIER = ${a.startsWith('"') ? `"${e}"` : e};`)
241
241
  );
242
- return { content: i, changed: i !== n, matches: o };
242
+ return { content: r, changed: r !== n, matches: o };
243
243
  }
244
- function cn(n) {
244
+ function ln(n) {
245
245
  return /\$[({][A-Za-z0-9_:]+[)}]/.test(n);
246
246
  }
247
247
  function kn(n) {
248
- const e = N(n);
248
+ const e = k(n);
249
249
  if (!e)
250
250
  return null;
251
251
  const o = e.match(/namespace\s+"([^"]+)"/);
@@ -259,41 +259,41 @@ function Sn(n) {
259
259
  kotlinRoot: s.join(n, "android/app/src/main/kotlin")
260
260
  };
261
261
  }
262
- function Fn(n) {
263
- return an(n, "project.pbxproj", (e, o) => s.relative(e, o).split(s.sep).length === 2 && o.endsWith(".xcodeproj/project.pbxproj"));
262
+ function Rn(n) {
263
+ return Z(n, "project.pbxproj", (e, o) => s.relative(e, o).split(s.sep).length === 2 && o.endsWith(".xcodeproj/project.pbxproj"));
264
264
  }
265
- function Cn(n, e) {
266
- const o = dn.map(
267
- (r) => s.join(n, "android/app/src/main", r, ...e.split("."))
268
- ), i = [];
269
- for (const r of o)
270
- i.push(...M(r));
271
- return i;
265
+ function Fn(n, e) {
266
+ const o = cn.map(
267
+ (i) => s.join(n, "android/app/src/main", i, ...e.split("."))
268
+ ), r = [];
269
+ for (const i of o)
270
+ r.push(...G(i));
271
+ return r;
272
272
  }
273
- function Rn(n) {
273
+ function En(n) {
274
274
  return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
275
275
  }
276
- const On = [
276
+ const Cn = [
277
277
  "android/.gradle",
278
278
  "android/app/build",
279
279
  "ios/build",
280
280
  ".metro",
281
281
  ".expo"
282
282
  ];
283
- async function En(n) {
283
+ async function On(n) {
284
284
  var u;
285
- const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, i = n.verbose ?? !1, r = T(n.logger, {
285
+ const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, r = n.verbose ?? !1, i = T(n.logger, {
286
286
  dryRun: o,
287
287
  color: n.color,
288
288
  quiet: n.quiet,
289
289
  scope: "clean",
290
- verbose: i
290
+ verbose: r
291
291
  });
292
- i && ((u = r.debug) == null || u.call(r, `rootDir=${e}`));
292
+ r && ((u = i.debug) == null || u.call(i, `rootDir=${e}`));
293
293
  const a = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
294
- for (const c of On) {
295
- const l = s.join(e, c);
296
- tn(l, o) && (i && r.info(`${o ? "[dry-run] " : ""}clean target: ${l}`), a.add(l));
294
+ for (const c of Cn) {
295
+ const f = s.join(e, c);
296
+ sn(f, o) && (r && i.info(`${o ? "[dry-run] " : ""}clean target: ${f}`), a.add(f));
297
297
  }
298
298
  const d = {
299
299
  changedFiles: Array.from(a).sort(),
@@ -301,113 +301,113 @@ async function En(n) {
301
301
  warnings: Array.from(t).sort(),
302
302
  dryRun: o
303
303
  };
304
- return o ? r.info(`Dry-run completed with ${d.changedFiles.length} target(s)`) : r.info(`Cleaned ${d.changedFiles.length} target(s)`), d;
304
+ return o ? i.info(`Dry-run completed with ${d.changedFiles.length} target(s)`) : i.info(`Cleaned ${d.changedFiles.length} target(s)`), d;
305
305
  }
306
306
  function jn(n) {
307
307
  if (!n || !n.trim())
308
308
  throw new Error("Display name cannot be empty");
309
309
  }
310
310
  async function _n(n) {
311
- var S, v;
312
- const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, i = n.verbose ?? !1, r = T(n.logger, {
311
+ var D, y;
312
+ const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, r = n.verbose ?? !1, i = T(n.logger, {
313
313
  dryRun: o,
314
314
  color: n.color,
315
315
  quiet: n.quiet,
316
316
  scope: "display-name",
317
- verbose: i
317
+ verbose: r
318
318
  }), a = n.displayName.trim();
319
- jn(a), i && ((S = r.debug) == null || S.call(r, `rootDir=${e}`), (v = r.debug) == null || v.call(r, `displayName=${a}`));
320
- const t = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), u = s.join(e, "app.json"), c = N(u);
319
+ jn(a), r && ((D = i.debug) == null || D.call(i, `rootDir=${e}`), (y = i.debug) == null || y.call(i, `displayName=${a}`));
320
+ const t = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), u = s.join(e, "app.json"), c = k(u);
321
321
  if (c)
322
322
  try {
323
- const D = {
323
+ const v = {
324
324
  ...JSON.parse(c),
325
325
  displayName: a
326
- }, y = `${JSON.stringify(D, null, 2)}
326
+ }, m = `${JSON.stringify(v, null, 2)}
327
327
  `;
328
- y !== c && (x(u, y, o), t.add(u));
328
+ m !== c && (S(u, m, o), t.add(u));
329
329
  } catch {
330
330
  d.add(`Skipped invalid JSON file: ${u}`);
331
331
  }
332
- const l = G(e), f = N(l);
333
- if (f) {
334
- const w = [
332
+ const f = z(e), g = k(f);
333
+ if (g) {
334
+ const $ = [
335
335
  [
336
336
  /<key>CFBundleDisplayName<\/key>\s*<string>[^<]*<\/string>/,
337
337
  `<key>CFBundleDisplayName</key>
338
338
  <string>${a}</string>`
339
339
  ]
340
- ], D = f.match(
340
+ ], v = g.match(
341
341
  /<key>CFBundleName<\/key>\s*<string>([^<]*)<\/string>/
342
342
  );
343
- (!D || !cn(D[1])) && w.push([
343
+ (!v || !ln(v[1])) && $.push([
344
344
  /<key>CFBundleName<\/key>\s*<string>[^<]*<\/string>/,
345
345
  `<key>CFBundleName</key>
346
346
  <string>${a}</string>`
347
347
  ]);
348
- const y = R(f, w);
349
- y.changed ? (x(l, y.content, o), t.add(l)) : d.add(`No iOS display-name changes were needed in ${l}`);
348
+ const m = _(g, $);
349
+ m.changed ? (S(f, m.content, o), t.add(f)) : d.add(`No iOS display-name changes were needed in ${f}`);
350
350
  }
351
- const I = s.join(e, "android/app/src/main/res/values/strings.xml"), A = N(I);
352
- if (A) {
353
- const w = R(A, [
351
+ const N = s.join(e, "android/app/src/main/res/values/strings.xml"), h = k(N);
352
+ if (h) {
353
+ const $ = _(h, [
354
354
  [/<string name="app_name">[^<]*<\/string>/, `<string name="app_name">${a}</string>`]
355
355
  ]);
356
- w.changed ? (x(I, w.content, o), t.add(I)) : d.add(`No Android app_name changes were needed in ${I}`);
356
+ $.changed ? (S(N, $.content, o), t.add(N)) : d.add(`No Android app_name changes were needed in ${N}`);
357
357
  }
358
- const b = {
358
+ const p = {
359
359
  changedFiles: Array.from(t).sort(),
360
360
  movedFiles: [],
361
361
  warnings: Array.from(d).sort(),
362
362
  dryRun: o
363
363
  };
364
- return o ? r.info(`Dry-run completed with ${b.changedFiles.length} pending change(s)`) : r.info(`Updated ${b.changedFiles.length} file(s)`), b;
364
+ return o ? i.info(`Dry-run completed with ${p.changedFiles.length} pending change(s)`) : i.info(`Updated ${p.changedFiles.length} file(s)`), p;
365
365
  }
366
- async function Bn(n) {
367
- var v, w, D, y;
368
- const e = s.resolve(n.rootDir ?? process.cwd()), o = n.verbose ?? !1, i = T(n.logger, {
366
+ async function Tn(n) {
367
+ var y, $, v, m;
368
+ const e = s.resolve(n.rootDir ?? process.cwd()), o = n.verbose ?? !1, r = T(n.logger, {
369
369
  color: n.color,
370
370
  quiet: n.quiet,
371
371
  scope: "doctor",
372
372
  verbose: o
373
373
  });
374
- o && ((v = i.debug) == null || v.call(i, `rootDir=${e}`));
375
- const r = /* @__PURE__ */ new Set(), a = [], t = {}, d = s.join(e, "app.json"), u = N(d);
374
+ o && ((y = r.debug) == null || y.call(r, `rootDir=${e}`));
375
+ const i = /* @__PURE__ */ new Set(), a = [], t = {}, d = s.join(e, "app.json"), u = k(d);
376
376
  if (!u)
377
- r.add(`Missing app.json: ${d}`);
377
+ i.add(`Missing app.json: ${d}`);
378
378
  else
379
379
  try {
380
- const p = JSON.parse(u);
381
- t.appName = p.name, t.displayName = p.displayName, p.name || r.add(`Missing "name" in app.json: ${d}`), p.displayName || r.add(`Missing "displayName" in app.json: ${d}`);
380
+ const l = JSON.parse(u);
381
+ 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}`);
382
382
  } catch {
383
- r.add(`Invalid JSON: ${d}`);
383
+ i.add(`Invalid JSON: ${d}`);
384
384
  }
385
- const c = s.join(e, "android/app/build.gradle"), l = N(c);
386
- if (!l)
387
- r.add(`Missing Android build file: ${c}`);
385
+ const c = s.join(e, "android/app/build.gradle"), f = k(c);
386
+ if (!f)
387
+ i.add(`Missing Android build file: ${c}`);
388
388
  else {
389
- const p = (w = l.match(/namespace\s+"([^"]+)"/)) == null ? void 0 : w[1], $ = (D = l.match(/applicationId\s+"([^"]+)"/)) == null ? void 0 : D[1];
390
- t.androidNamespace = p, t.androidApplicationId = $, p || r.add(`Missing namespace in ${c}`), $ || r.add(`Missing applicationId in ${c}`), p && $ && p !== $ && r.add(`Android namespace and applicationId differ: ${p} vs ${$}`);
389
+ const l = ($ = f.match(/namespace\s+"([^"]+)"/)) == null ? void 0 : $[1], I = (v = f.match(/applicationId\s+"([^"]+)"/)) == null ? void 0 : v[1];
390
+ t.androidNamespace = l, t.androidApplicationId = I, l || i.add(`Missing namespace in ${c}`), I || i.add(`Missing applicationId in ${c}`), l && I && l !== I && i.add(`Android namespace and applicationId differ: ${l} vs ${I}`);
391
391
  }
392
- const f = s.join(e, "android/app/src/main/res/values/strings.xml"), I = N(f);
393
- if (!I)
394
- r.add(`Missing Android strings: ${f}`);
392
+ const g = s.join(e, "android/app/src/main/res/values/strings.xml"), N = k(g);
393
+ if (!N)
394
+ i.add(`Missing Android strings: ${g}`);
395
395
  else {
396
- const p = (y = I.match(/<string name="app_name">([^<]+)<\/string>/)) == null ? void 0 : y[1];
397
- t.androidAppName = p, p || r.add(`Missing app_name in ${f}`);
396
+ const l = (m = N.match(/<string name="app_name">([^<]+)<\/string>/)) == null ? void 0 : m[1];
397
+ t.androidAppName = l, l || i.add(`Missing app_name in ${g}`);
398
398
  }
399
- const A = G(e), b = N(A);
400
- b ? (t.iosBundleId = J(b, "CFBundleIdentifier"), t.iosDisplayName = J(b, "CFBundleDisplayName"), t.iosName = J(b, "CFBundleName"), /<key>CFBundleIdentifier<\/key>/.test(b) || r.add(`Missing CFBundleIdentifier in ${A}`), /<key>CFBundleDisplayName<\/key>/.test(b) || r.add(`Missing CFBundleDisplayName in ${A}`)) : r.add(`Missing iOS Info.plist: ${A}`), M(s.join(e, "android/app/src/main")).filter(
401
- (p) => /\.(kt|java)$/.test(p)
402
- ).length === 0 && r.add("No Android source files found under android/app/src/main"), Tn(t, r), t.appName && t.displayName && t.appName !== t.displayName && r.add(
399
+ const h = z(e), p = k(h);
400
+ p ? (t.iosBundleId = J(p, "CFBundleIdentifier"), t.iosDisplayName = J(p, "CFBundleDisplayName"), t.iosName = J(p, "CFBundleName"), /<key>CFBundleIdentifier<\/key>/.test(p) || i.add(`Missing CFBundleIdentifier in ${h}`), /<key>CFBundleDisplayName<\/key>/.test(p) || i.add(`Missing CFBundleDisplayName in ${h}`)) : i.add(`Missing iOS Info.plist: ${h}`), G(s.join(e, "android/app/src/main")).filter(
401
+ (l) => /\.(kt|java)$/.test(l)
402
+ ).length === 0 && i.add("No Android source files found under android/app/src/main"), Bn(t, i), t.appName && t.displayName && t.appName !== t.displayName && i.add(
403
403
  `app.json "name" and "displayName" differ: ${t.appName} vs ${t.displayName}`
404
404
  );
405
- for (const p of r)
406
- i.warn(p);
407
- return r.size === 0 ? i.info("Doctor check passed") : i.info(`Doctor found ${r.size} issue(s)`), {
405
+ for (const l of i)
406
+ r.warn(l);
407
+ return i.size === 0 ? r.info("Doctor check passed") : r.info(`Doctor found ${i.size} issue(s)`), {
408
408
  changedFiles: a,
409
409
  movedFiles: [],
410
- warnings: Array.from(r).sort(),
410
+ warnings: Array.from(i).sort(),
411
411
  dryRun: !0
412
412
  };
413
413
  }
@@ -415,35 +415,35 @@ function J(n, e) {
415
415
  var o;
416
416
  return (o = n.match(new RegExp(`<key>${e}<\\/key>\\s*<string>([^<]*)<\\/string>`))) == null ? void 0 : o[1];
417
417
  }
418
- function B(n) {
418
+ function P(n) {
419
419
  return typeof n == "string" && !n.startsWith("$(") && !n.startsWith("${");
420
420
  }
421
- function Tn(n, e) {
421
+ function Bn(n, e) {
422
422
  n.androidNamespace && n.androidApplicationId && n.androidNamespace !== n.androidApplicationId && e.add(
423
423
  `Android namespace and applicationId differ: ${n.androidNamespace} vs ${n.androidApplicationId}`
424
- ), B(n.iosDisplayName) && B(n.iosName) && n.iosDisplayName !== n.iosName && e.add(
424
+ ), P(n.iosDisplayName) && P(n.iosName) && n.iosDisplayName !== n.iosName && e.add(
425
425
  `iOS CFBundleDisplayName and CFBundleName differ: ${n.iosDisplayName} vs ${n.iosName}`
426
426
  );
427
427
  const o = n.displayName;
428
- B(o) && (B(n.androidAppName) && n.androidAppName !== o && e.add(
428
+ P(o) && (P(n.androidAppName) && n.androidAppName !== o && e.add(
429
429
  `Android app_name does not match app.json displayName: ${n.androidAppName} vs ${o}`
430
- ), B(n.iosDisplayName) && n.iosDisplayName !== o && e.add(
430
+ ), P(n.iosDisplayName) && n.iosDisplayName !== o && e.add(
431
431
  `iOS CFBundleDisplayName does not match app.json displayName: ${n.iosDisplayName} vs ${o}`
432
432
  ));
433
433
  }
434
- const Un = "assets/icon.png", Pn = "android/app/src/main/res", zn = "AppIcon.appiconset", qn = "ic_launcher", Ln = "ic_launcher_round", Mn = !0, Gn = "#FFFFFF", Jn = 0.72, Wn = "#FFFFFF", ln = [
434
+ const Pn = "assets/icon.png", Un = "android/app/src/main/res", zn = "AppIcon.appiconset", qn = "ic_launcher", Mn = "ic_launcher_round", Ln = !0, Vn = "#FFFFFF", Gn = 0.72, Jn = "#FFFFFF", un = [
435
435
  { dir: "mipmap-mdpi", size: 48 },
436
436
  { dir: "mipmap-hdpi", size: 72 },
437
437
  { dir: "mipmap-xhdpi", size: 96 },
438
438
  { dir: "mipmap-xxhdpi", size: 144 },
439
439
  { dir: "mipmap-xxxhdpi", size: 192 }
440
- ], Vn = [
440
+ ], Wn = [
441
441
  { dir: "drawable-mdpi", size: 108 },
442
442
  { dir: "drawable-hdpi", size: 162 },
443
443
  { dir: "drawable-xhdpi", size: 216 },
444
444
  { dir: "drawable-xxhdpi", size: 324 },
445
445
  { dir: "drawable-xxxhdpi", size: 432 }
446
- ], K = [
446
+ ], H = [
447
447
  { idiom: "iphone", size: "20x20", scale: "2x", filename: "icon-20x20-2x-iphone.png" },
448
448
  { idiom: "iphone", size: "20x20", scale: "3x", filename: "icon-20x20-3x-iphone.png" },
449
449
  { idiom: "ipad", size: "20x20", scale: "1x", filename: "icon-20x20-1x-ipad.png" },
@@ -463,83 +463,83 @@ const Un = "assets/icon.png", Pn = "android/app/src/main/res", zn = "AppIcon.app
463
463
  { idiom: "ipad", size: "83.5x83.5", scale: "2x", filename: "icon-83_5x83_5-2x-ipad.png" },
464
464
  { idiom: "ios-marketing", size: "1024x1024", scale: "1x", filename: "icon-1024x1024.png" }
465
465
  ];
466
- async function Zn(n) {
467
- var O, E, j, _, g, k;
468
- const e = await se(n.configPath, n.rootDir), o = Xn(e, n), i = s.resolve(o.rootDir ?? process.cwd()), r = n.dryRun ?? !1, a = n.verbose ?? !1, t = T(n.logger, {
469
- dryRun: r,
466
+ async function Kn(n) {
467
+ var F, E, O, C, A, R;
468
+ const e = await se(n.configPath, n.rootDir), o = Zn(e, n), r = s.resolve(o.rootDir ?? process.cwd()), i = n.dryRun ?? !1, a = n.verbose ?? !1, t = T(n.logger, {
469
+ dryRun: i,
470
470
  color: n.color,
471
471
  quiet: n.quiet,
472
472
  scope: "icon",
473
473
  verbose: a
474
474
  }), d = W(
475
- i,
476
- o.sourceImage ?? Un
475
+ r,
476
+ o.sourceImage ?? Pn
477
477
  ), u = W(
478
- i,
479
- o.androidDestinationDir ?? Pn
478
+ r,
479
+ o.androidDestinationDir ?? Un
480
480
  ), c = W(
481
- i,
482
- o.iosAssetsDir ?? me(i)
483
- ), l = s.join(
481
+ r,
482
+ o.iosAssetsDir ?? me(r)
483
+ ), f = s.join(
484
484
  c,
485
485
  o.iosIconSetName ?? zn
486
- ), f = o.androidIconName ?? qn, I = o.androidRoundIconName ?? Ln, A = o.androidAdaptiveIcon ?? Mn, b = o.androidAdaptiveIconBackgroundColor ?? Gn, S = o.androidAdaptiveIconForegroundScale ?? Jn, v = o.iosIconBackgroundColor ?? Wn;
487
- a && ((O = t.debug) == null || O.call(t, `rootDir=${i}`), (E = t.debug) == null || E.call(t, `sourceImage=${d}`), (j = t.debug) == null || j.call(t, `androidDestinationDir=${u}`), (_ = t.debug) == null || _.call(t, `androidAdaptiveIcon=${A}`), (g = t.debug) == null || g.call(t, `iosAssetsDir=${c}`), (k = t.debug) == null || k.call(t, `iosIconSetDir=${l}`)), Qn(d, "Icon source image"), ee(S), oe(d, u, l);
488
- const w = await re(d);
489
- ne(w, d);
490
- const D = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), p = await Kn({
486
+ ), g = o.androidIconName ?? qn, N = o.androidRoundIconName ?? Mn, h = o.androidAdaptiveIcon ?? Ln, p = o.androidAdaptiveIconBackgroundColor ?? Vn, D = o.androidAdaptiveIconForegroundScale ?? Gn, y = o.iosIconBackgroundColor ?? Jn;
487
+ a && ((F = t.debug) == null || F.call(t, `rootDir=${r}`), (E = t.debug) == null || E.call(t, `sourceImage=${d}`), (O = t.debug) == null || O.call(t, `androidDestinationDir=${u}`), (C = t.debug) == null || C.call(t, `androidAdaptiveIcon=${h}`), (A = t.debug) == null || A.call(t, `iosAssetsDir=${c}`), (R = t.debug) == null || R.call(t, `iosIconSetDir=${f}`)), Qn(d, "Icon source image"), ee(D), oe(d, u, f);
488
+ const $ = await ie(d);
489
+ ne($, d);
490
+ const v = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), l = await Xn({
491
491
  sourceImage: d,
492
492
  destinationDir: u,
493
- iconName: f,
494
- roundIconName: I,
495
- adaptiveIcon: A,
496
- adaptiveIconBackgroundColor: b,
497
- adaptiveIconForegroundScale: S,
498
- dryRun: r
499
- }), $ = await Yn({
493
+ iconName: g,
494
+ roundIconName: N,
495
+ adaptiveIcon: h,
496
+ adaptiveIconBackgroundColor: p,
497
+ adaptiveIconForegroundScale: D,
498
+ dryRun: i
499
+ }), I = await Yn({
500
500
  sourceImage: d,
501
- iconSetDir: l,
502
- backgroundColor: v,
503
- dryRun: r
501
+ iconSetDir: f,
502
+ backgroundColor: y,
503
+ dryRun: i
504
504
  });
505
- (await L(d).stats()).isOpaque || y.add(
506
- `Icon source has transparent pixels; iOS icons were filled with ${v}`
505
+ (await V(d).stats()).isOpaque || m.add(
506
+ `Icon source has transparent pixels; iOS icons were filled with ${y}`
507
507
  );
508
- for (const C of [...p, ...$])
509
- D.add(C);
510
- p.length === 0 && y.add(`No Android icon files were generated from ${d}`), $.length === 0 && y.add(`No iOS icon files were generated from ${d}`);
511
- const F = {
512
- changedFiles: Array.from(D).sort(),
508
+ for (const j of [...l, ...I])
509
+ v.add(j);
510
+ l.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}`);
511
+ const x = {
512
+ changedFiles: Array.from(v).sort(),
513
513
  movedFiles: [],
514
- warnings: Array.from(y).sort(),
515
- dryRun: r
514
+ warnings: Array.from(m).sort(),
515
+ dryRun: i
516
516
  };
517
- return r ? t.info(`Dry-run completed with ${F.changedFiles.length} pending icon file(s)`) : t.info(`Generated ${F.changedFiles.length} icon file(s)`), F;
517
+ return i ? t.info(`Dry-run completed with ${x.changedFiles.length} pending icon file(s)`) : t.info(`Generated ${x.changedFiles.length} icon file(s)`), x;
518
518
  }
519
- function Xn(n, e) {
519
+ function Zn(n, e) {
520
520
  return {
521
521
  ...n,
522
522
  ...e
523
523
  };
524
524
  }
525
- async function Kn(n) {
525
+ async function Xn(n) {
526
526
  const e = [];
527
- for (const { dir: o, size: i } of ln) {
528
- const r = s.join(n.destinationDir, o), a = s.join(r, `${n.iconName}.png`), t = s.join(r, `${n.roundIconName}.png`);
529
- n.dryRun || (m.mkdirSync(r, { recursive: !0 }), await V(n.sourceImage, a, i), await V(n.sourceImage, t, i)), e.push(a, t);
527
+ for (const { dir: o, size: r } of un) {
528
+ const i = s.join(n.destinationDir, o), a = s.join(i, `${n.iconName}.png`), t = s.join(i, `${n.roundIconName}.png`);
529
+ n.dryRun || (w.mkdirSync(i, { recursive: !0 }), await K(n.sourceImage, a, r), await K(n.sourceImage, t, r)), e.push(a, t);
530
530
  }
531
531
  if (n.adaptiveIcon) {
532
- const o = `${n.iconName}_foreground`, i = `${n.iconName}_background`;
533
- for (const { dir: d, size: u } of Vn) {
534
- const c = s.join(n.destinationDir, d), l = s.join(c, `${o}.png`);
535
- n.dryRun || (m.mkdirSync(c, { recursive: !0 }), await te(
532
+ const o = `${n.iconName}_foreground`, r = `${n.iconName}_background`;
533
+ for (const { dir: d, size: u } of Wn) {
534
+ const c = s.join(n.destinationDir, d), f = s.join(c, `${o}.png`);
535
+ n.dryRun || (w.mkdirSync(c, { recursive: !0 }), await te(
536
536
  n.sourceImage,
537
- l,
537
+ f,
538
538
  u,
539
539
  n.adaptiveIconForegroundScale
540
- )), e.push(l);
540
+ )), e.push(f);
541
541
  }
542
- const r = s.join(n.destinationDir, "values", `${i}.xml`), a = s.join(
542
+ const i = s.join(n.destinationDir, "values", `${r}.xml`), a = s.join(
543
543
  n.destinationDir,
544
544
  "mipmap-anydpi-v26",
545
545
  `${n.iconName}.xml`
@@ -548,31 +548,31 @@ async function Kn(n) {
548
548
  "mipmap-anydpi-v26",
549
549
  `${n.roundIconName}.xml`
550
550
  );
551
- n.dryRun || (x(
552
- r,
553
- ae(i, n.adaptiveIconBackgroundColor),
551
+ n.dryRun || (S(
552
+ i,
553
+ ae(r, n.adaptiveIconBackgroundColor),
554
554
  !1
555
- ), x(a, Y(i, o), !1), x(
555
+ ), S(a, Q(r, o), !1), S(
556
556
  t,
557
- Y(i, o),
557
+ Q(r, o),
558
558
  !1
559
- )), e.push(r, a, t);
559
+ )), e.push(i, a, t);
560
560
  }
561
561
  return e;
562
562
  }
563
563
  async function Yn(n) {
564
- const e = [], o = K.map((a) => ({
564
+ const e = [], o = H.map((a) => ({
565
565
  idiom: a.idiom,
566
566
  size: a.size,
567
567
  scale: a.scale,
568
568
  filename: a.filename
569
569
  }));
570
- n.dryRun || (tn(n.iconSetDir, !1), m.mkdirSync(n.iconSetDir, { recursive: !0 }));
571
- for (const a of K) {
570
+ n.dryRun || (sn(n.iconSetDir, !1), w.mkdirSync(n.iconSetDir, { recursive: !0 }));
571
+ for (const a of H) {
572
572
  const t = s.join(n.iconSetDir, a.filename), d = Hn(a.size, a.scale);
573
- n.dryRun || await V(n.sourceImage, t, d, n.backgroundColor), e.push(t);
573
+ n.dryRun || await K(n.sourceImage, t, d, n.backgroundColor), e.push(t);
574
574
  }
575
- const i = s.join(n.iconSetDir, "Contents.json"), r = JSON.stringify(
575
+ const r = s.join(n.iconSetDir, "Contents.json"), i = JSON.stringify(
576
576
  {
577
577
  images: o,
578
578
  info: {
@@ -583,15 +583,15 @@ async function Yn(n) {
583
583
  null,
584
584
  2
585
585
  );
586
- return n.dryRun || x(i, `${r}
587
- `, !1), e.push(i), e;
586
+ return n.dryRun || S(r, `${i}
587
+ `, !1), e.push(r), e;
588
588
  }
589
589
  function Hn(n, e) {
590
- const o = Number.parseFloat(n.split("x")[0] ?? "0"), i = Number.parseFloat(e.replace("x", ""));
591
- return Math.round(o * i);
590
+ const o = Number.parseFloat(n.split("x")[0] ?? "0"), r = Number.parseFloat(e.replace("x", ""));
591
+ return Math.round(o * r);
592
592
  }
593
593
  function Qn(n, e) {
594
- if (!m.existsSync(n))
594
+ if (!w.existsSync(n))
595
595
  throw new Error(`${e} not found: ${n}`);
596
596
  }
597
597
  function ne(n, e) {
@@ -609,39 +609,39 @@ function ee(n) {
609
609
  );
610
610
  }
611
611
  function oe(n, e, o) {
612
- const i = ln.map(
612
+ const r = un.map(
613
613
  ({ dir: a }) => s.join(e, a)
614
- ), r = [o, ...i].filter(
615
- (a) => ie(n, a)
614
+ ), i = [o, ...r].filter(
615
+ (a) => re(n, a)
616
616
  );
617
- if (r.length > 0)
617
+ if (i.length > 0)
618
618
  throw new Error(
619
- `Icon source image must be outside generated icon directories: ${r.join(", ")}
619
+ `Icon source image must be outside generated icon directories: ${i.join(", ")}
620
620
  Use a source file such as assets/icon.png instead: ${n}`
621
621
  );
622
622
  }
623
- function ie(n, e) {
623
+ function re(n, e) {
624
624
  const o = s.relative(e, n);
625
625
  return o === "" || !o.startsWith("..") && !s.isAbsolute(o);
626
626
  }
627
627
  function W(n, e) {
628
628
  return s.isAbsolute(e) ? e : s.join(n, e);
629
629
  }
630
- async function re(n) {
631
- return L(n).metadata();
632
- }
633
- async function V(n, e, o, i) {
634
- m.mkdirSync(s.dirname(e), { recursive: !0 });
635
- const r = L(n).resize(o, o, { fit: "fill" });
636
- i && r.flatten({ background: i }).removeAlpha(), await r.png().toFile(e);
637
- }
638
- async function te(n, e, o, i) {
639
- const r = Math.max(1, Math.round(o * i));
640
- m.mkdirSync(s.dirname(e), { recursive: !0 }), await L(n).resize(r, r, { fit: "contain" }).extend({
641
- top: Math.floor((o - r) / 2),
642
- bottom: Math.ceil((o - r) / 2),
643
- left: Math.floor((o - r) / 2),
644
- right: Math.ceil((o - r) / 2),
630
+ async function ie(n) {
631
+ return V(n).metadata();
632
+ }
633
+ async function K(n, e, o, r) {
634
+ w.mkdirSync(s.dirname(e), { recursive: !0 });
635
+ const i = V(n).resize(o, o, { fit: "fill" });
636
+ r && i.flatten({ background: r }).removeAlpha(), await i.png().toFile(e);
637
+ }
638
+ async function te(n, e, o, r) {
639
+ const i = Math.max(1, Math.round(o * r));
640
+ w.mkdirSync(s.dirname(e), { recursive: !0 }), await V(n).resize(i, i, { fit: "contain" }).extend({
641
+ top: Math.floor((o - i) / 2),
642
+ bottom: Math.ceil((o - i) / 2),
643
+ left: Math.floor((o - i) / 2),
644
+ right: Math.ceil((o - i) / 2),
645
645
  background: { r: 0, g: 0, b: 0, alpha: 0 }
646
646
  }).png().toFile(e);
647
647
  }
@@ -655,7 +655,7 @@ function ae(n, e) {
655
655
  ].join(`
656
656
  `);
657
657
  }
658
- function Y(n, e) {
658
+ function Q(n, e) {
659
659
  return [
660
660
  '<?xml version="1.0" encoding="utf-8"?>',
661
661
  '<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">',
@@ -668,20 +668,20 @@ function Y(n, e) {
668
668
  }
669
669
  async function se(n, e) {
670
670
  if (!n) {
671
- const r = le(e);
672
- return r ? H(r) : {};
671
+ const i = le(e);
672
+ return i ? nn(i) : {};
673
673
  }
674
674
  ce(n);
675
- const o = de(n, e), i = o.find((r) => m.existsSync(r));
676
- if (!i)
675
+ const o = de(n, e), r = o.find((i) => w.existsSync(i));
676
+ if (!r)
677
677
  throw new Error(`Icon config file not found: ${o[0] ?? s.resolve(n)}`);
678
- return H(i);
678
+ return nn(r);
679
679
  }
680
680
  function de(n, e) {
681
681
  if (s.isAbsolute(n))
682
682
  return [n];
683
- const o = s.resolve(process.cwd(), n), i = e ? s.resolve(e, n) : null, r = [o];
684
- return i && i !== o && r.push(i), r;
683
+ const o = s.resolve(process.cwd(), n), r = e ? s.resolve(e, n) : null, i = [o];
684
+ return r && r !== o && i.push(r), i;
685
685
  }
686
686
  function ce(n) {
687
687
  const e = s.basename(n);
@@ -692,7 +692,7 @@ function ce(n) {
692
692
  }
693
693
  function le(n) {
694
694
  const e = [n ? s.resolve(n) : null, process.cwd()].filter(
695
- (i) => !!i
695
+ (r) => !!r
696
696
  ), o = [
697
697
  ".rn-toolsrc",
698
698
  ".rn-toolsrc.json",
@@ -700,32 +700,32 @@ function le(n) {
700
700
  ".rn-toolsrc.cjs",
701
701
  ".rn-toolsrc.mjs"
702
702
  ];
703
- for (const i of e)
704
- for (const r of o) {
705
- const a = s.join(i, r);
706
- if (m.existsSync(a))
703
+ for (const r of e)
704
+ for (const i of o) {
705
+ const a = s.join(r, i);
706
+ if (w.existsSync(a))
707
707
  return a;
708
708
  }
709
709
  return null;
710
710
  }
711
- async function H(n) {
711
+ async function nn(n) {
712
712
  const e = s.extname(n).toLowerCase();
713
713
  if (e === ".json" || e === "") {
714
- const i = N(n);
715
- if (!i)
714
+ const r = k(n);
715
+ if (!r)
716
716
  throw new Error(`Icon config file not found: ${n}`);
717
- let r;
717
+ let i;
718
718
  try {
719
- r = JSON.parse(i);
719
+ i = JSON.parse(r);
720
720
  } catch {
721
721
  throw new Error(`Icon config file is not valid JSON: ${n}`);
722
722
  }
723
- return Q(r, n);
723
+ return en(i, n);
724
724
  }
725
- const o = await import(gn(n).href);
726
- return Q(o, n);
725
+ const o = await import(hn(n).href);
726
+ return en(o, n);
727
727
  }
728
- function Q(n, e) {
728
+ function en(n, e) {
729
729
  if (!n || typeof n != "object")
730
730
  throw new Error(`Icon config file must contain an object: ${e}`);
731
731
  const o = ue(n);
@@ -734,33 +734,124 @@ function Q(n, e) {
734
734
  return pe(o, s.dirname(e));
735
735
  }
736
736
  function ue(n) {
737
- if (!z(n))
737
+ if (!M(n))
738
738
  return null;
739
- const e = z(n.default) ? n.default : n;
740
- return fe(e) ? z(e.icon) ? e.icon : null : z(e) ? e : null;
739
+ const e = M(n.default) ? n.default : n;
740
+ return fe(e) ? M(e.icon) ? e.icon : null : M(e) ? e : null;
741
741
  }
742
742
  function fe(n) {
743
743
  return Object.prototype.hasOwnProperty.call(n, "icon");
744
744
  }
745
- function z(n) {
745
+ function M(n) {
746
746
  return !!n && typeof n == "object" && !Array.isArray(n);
747
747
  }
748
748
  function pe(n, e) {
749
749
  const o = {};
750
- return n.rootDir && (o.rootDir = q(e, n.rootDir)), n.sourceImage && (o.sourceImage = q(e, n.sourceImage)), n.androidDestinationDir && (o.androidDestinationDir = q(e, n.androidDestinationDir)), typeof n.androidAdaptiveIcon == "boolean" && (o.androidAdaptiveIcon = n.androidAdaptiveIcon), n.androidAdaptiveIconBackgroundColor && (o.androidAdaptiveIconBackgroundColor = n.androidAdaptiveIconBackgroundColor), typeof n.androidAdaptiveIconForegroundScale == "number" && (o.androidAdaptiveIconForegroundScale = n.androidAdaptiveIconForegroundScale), n.iosAssetsDir && (o.iosAssetsDir = q(e, n.iosAssetsDir)), n.iosIconSetName && (o.iosIconSetName = n.iosIconSetName), n.iosIconBackgroundColor && (o.iosIconBackgroundColor = n.iosIconBackgroundColor), n.androidIconName && (o.androidIconName = n.androidIconName), n.androidRoundIconName && (o.androidRoundIconName = n.androidRoundIconName), o;
750
+ return n.rootDir && (o.rootDir = L(e, n.rootDir)), n.sourceImage && (o.sourceImage = L(e, n.sourceImage)), n.androidDestinationDir && (o.androidDestinationDir = L(e, n.androidDestinationDir)), typeof n.androidAdaptiveIcon == "boolean" && (o.androidAdaptiveIcon = n.androidAdaptiveIcon), n.androidAdaptiveIconBackgroundColor && (o.androidAdaptiveIconBackgroundColor = n.androidAdaptiveIconBackgroundColor), typeof n.androidAdaptiveIconForegroundScale == "number" && (o.androidAdaptiveIconForegroundScale = n.androidAdaptiveIconForegroundScale), n.iosAssetsDir && (o.iosAssetsDir = L(e, n.iosAssetsDir)), n.iosIconSetName && (o.iosIconSetName = n.iosIconSetName), n.iosIconBackgroundColor && (o.iosIconBackgroundColor = n.iosIconBackgroundColor), n.androidIconName && (o.androidIconName = n.androidIconName), n.androidRoundIconName && (o.androidRoundIconName = n.androidRoundIconName), o;
751
751
  }
752
- function q(n, e) {
752
+ function L(n, e) {
753
753
  return s.isAbsolute(e) ? e : s.resolve(n, e);
754
754
  }
755
755
  function me(n) {
756
- const e = G(n);
756
+ const e = z(n);
757
757
  return s.join(s.dirname(e), "Images.xcassets");
758
758
  }
759
- const ge = {
759
+ const ge = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
760
+ async function he(n = {}) {
761
+ const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1, r = n.platform ?? "all";
762
+ if (!["all", "android", "ios"].includes(r))
763
+ throw new Error("Platform must be all, android, or ios");
764
+ const i = s.join(e, "package.json"), a = U(i), t = JSON.parse(a), d = n.version ?? t.version;
765
+ if (typeof d != "string" || !ge.test(d))
766
+ throw new Error("Version must contain three non-negative integers, for example 1.2.3");
767
+ const u = n.buildNumber === void 0 ? void 0 : String(n.buildNumber);
768
+ if (u !== void 0 && (!/^[1-9]\d*$/.test(u) || Number(u) > 21e8))
769
+ throw new Error("Build number must be a positive integer no greater than 2100000000");
770
+ const c = T(n.logger, {
771
+ dryRun: o,
772
+ verbose: n.verbose,
773
+ quiet: n.quiet,
774
+ color: n.color,
775
+ scope: "version"
776
+ }), f = /* @__PURE__ */ new Map(), g = (h, p, D) => {
777
+ D !== p && f.set(h, D);
778
+ }, N = (h, p, D, y, $) => {
779
+ const v = h.match(p) ?? [], m = h.match(new RegExp(`^[ \\t]*${y}\\b[^\\r\\n]*`, "gm")) ?? [];
780
+ if (v.length === 0 || v.length !== m.length)
781
+ throw new Error(`Could not find a literal ${y} in ${$}`);
782
+ return p.lastIndex = 0, h.replace(p, D);
783
+ };
784
+ if (r === "all" || r === "android") {
785
+ const h = s.join(e, "android/app/build.gradle"), p = s.join(e, "android/app/build.gradle.kts"), D = k(h), y = D === null ? p : h, $ = D ?? U(p);
786
+ let v = N(
787
+ $,
788
+ /^([ \t]*versionName[ \t]*(?:=[ \t]*)?)(["'])([^"'\r\n]*)\2([ \t]*;?[ \t]*(?:\/\/[^\r\n]*)?\r?)$/gm,
789
+ (m, l, I, x, F) => `${l}${I}${d}${I}${F}`,
790
+ "versionName",
791
+ y
792
+ );
793
+ u !== void 0 && (v = N(
794
+ v,
795
+ /^([ \t]*versionCode[ \t]*(?:=[ \t]*)?)(\d+)([ \t]*;?[ \t]*(?:\/\/[^\r\n]*)?\r?)$/gm,
796
+ (m, l, I, x) => `${l}${u}${x}`,
797
+ "versionCode",
798
+ y
799
+ )), g(y, $, v);
800
+ }
801
+ if (r === "all" || r === "ios") {
802
+ const h = Z(
803
+ e,
804
+ "project.pbxproj",
805
+ (m, l) => s.relative(m, l).split(s.sep).length === 2 && s.dirname(l).endsWith(".xcodeproj") && s.basename(l) === "project.pbxproj"
806
+ ), p = U(h);
807
+ let D = N(
808
+ p,
809
+ /^([ \t]*MARKETING_VERSION[ \t]*=[ \t]*)("?)[\d.]+\2([ \t]*;[^\r\n]*\r?)$/gm,
810
+ (m, l, I, x) => `${l}${I}${d}${I}${x}`,
811
+ "MARKETING_VERSION",
812
+ h
813
+ );
814
+ u !== void 0 && (D = N(
815
+ D,
816
+ /^([ \t]*CURRENT_PROJECT_VERSION[ \t]*=[ \t]*)("?)[\d.]+\2([ \t]*;[^\r\n]*\r?)$/gm,
817
+ (m, l, I, x) => `${l}${I}${u}${I}${x}`,
818
+ "CURRENT_PROJECT_VERSION",
819
+ h
820
+ )), g(h, p, D);
821
+ const y = z(e), $ = U(y);
822
+ let v = $;
823
+ for (const [m, l, I] of [
824
+ ["CFBundleShortVersionString", "MARKETING_VERSION", d],
825
+ ["CFBundleVersion", "CURRENT_PROJECT_VERSION", u]
826
+ ]) {
827
+ if (I === void 0) continue;
828
+ const x = new RegExp(`(<key>${m}</key>\\s*<string>)([^<]*)(</string>)`), F = v.match(x);
829
+ if (!F) throw new Error(`Could not find ${m} in ${y}`);
830
+ const E = F[2];
831
+ if (!(E === `$(${l})` || E === "${" + l + "}")) {
832
+ if (/\$[({]/.test(E))
833
+ throw new Error(`Unsupported ${m} reference ${E} in ${y}`);
834
+ v = v.replace(
835
+ x,
836
+ (O, C, A, R) => `${C}${I}${R}`
837
+ );
838
+ }
839
+ }
840
+ g(y, $, v);
841
+ }
842
+ n.version !== void 0 && t.version !== d && g(i, a, `${JSON.stringify({ ...t, version: d }, null, 2)}
843
+ `);
844
+ for (const [h, p] of f)
845
+ S(h, p, o);
846
+ return c.info(
847
+ `${o ? "Would set" : "Set"} version ${d}${u === void 0 ? "" : ` (${u})`}`
848
+ ), { changedFiles: [...f.keys()].sort(), movedFiles: [], warnings: [], dryRun: o };
849
+ }
850
+ const ye = {
760
851
  name: "bundle-id",
761
852
  description: "Rename the iOS bundle identifier and Android application package",
762
853
  async run(n, e) {
763
- return xn({
854
+ return An({
764
855
  ...e,
765
856
  rootDir: e.rootDir ?? n.rootDir,
766
857
  dryRun: e.dryRun ?? n.dryRun,
@@ -770,7 +861,7 @@ const ge = {
770
861
  logger: e.logger ?? n.logger
771
862
  });
772
863
  }
773
- }, he = {
864
+ }, ve = {
774
865
  name: "display-name",
775
866
  description: "Update the app display name on iOS and Android",
776
867
  async run(n, e) {
@@ -784,11 +875,25 @@ const ge = {
784
875
  logger: e.logger ?? n.logger
785
876
  });
786
877
  }
787
- }, ye = {
878
+ }, Ie = {
879
+ name: "version",
880
+ description: "Sync the app version and build number to Android and iOS",
881
+ async run(n, e) {
882
+ return he({
883
+ ...e,
884
+ rootDir: e.rootDir ?? n.rootDir,
885
+ dryRun: e.dryRun ?? n.dryRun,
886
+ verbose: e.verbose ?? n.verbose,
887
+ quiet: e.quiet ?? n.quiet,
888
+ color: e.color ?? n.color,
889
+ logger: e.logger ?? n.logger
890
+ });
891
+ }
892
+ }, be = {
788
893
  name: "clean",
789
894
  description: "Remove common build and cache artifacts",
790
895
  async run(n, e) {
791
- return En({
896
+ return On({
792
897
  ...e,
793
898
  rootDir: e.rootDir ?? n.rootDir,
794
899
  dryRun: e.dryRun ?? n.dryRun,
@@ -798,11 +903,11 @@ const ge = {
798
903
  logger: e.logger ?? n.logger
799
904
  });
800
905
  }
801
- }, Ie = {
906
+ }, we = {
802
907
  name: "doctor",
803
908
  description: "Check common RN project health signals",
804
909
  async run(n, e) {
805
- return Bn({
910
+ return Tn({
806
911
  ...e,
807
912
  rootDir: e.rootDir ?? n.rootDir,
808
913
  verbose: e.verbose ?? n.verbose,
@@ -811,11 +916,11 @@ const ge = {
811
916
  logger: e.logger ?? n.logger
812
917
  });
813
918
  }
814
- }, be = {
919
+ }, $e = {
815
920
  name: "icon",
816
921
  description: "Generate Android and iOS app icons from a single source image",
817
922
  async run(n, e) {
818
- return Zn({
923
+ return Kn({
819
924
  ...e,
820
925
  rootDir: e.rootDir ?? n.rootDir,
821
926
  dryRun: e.dryRun ?? n.dryRun,
@@ -826,56 +931,57 @@ const ge = {
826
931
  });
827
932
  }
828
933
  };
829
- function un(n = [
830
- ge,
831
- he,
934
+ function fn(n = [
832
935
  ye,
936
+ ve,
833
937
  Ie,
834
- be
938
+ be,
939
+ we,
940
+ $e
835
941
  ]) {
836
942
  const e = /* @__PURE__ */ new Map();
837
- for (const i of n)
838
- e.set(i.name, i);
943
+ for (const r of n)
944
+ e.set(r.name, r);
839
945
  const o = {
840
946
  listTasks() {
841
947
  return Array.from(e.values());
842
948
  },
843
- getTask(i) {
844
- return e.get(i);
949
+ getTask(r) {
950
+ return e.get(r);
845
951
  },
846
- registerTask(i) {
847
- return e.set(i.name, i), o;
952
+ registerTask(r) {
953
+ return e.set(r.name, r), o;
848
954
  },
849
- async runTask(i, r, a) {
850
- const t = e.get(i);
955
+ async runTask(r, i, a) {
956
+ const t = e.get(r);
851
957
  if (!t) {
852
958
  const d = Array.from(e.keys()).sort();
853
959
  throw new Error(
854
- `Unknown task "${i}". Available tasks: ${d.join(", ") || "(none)"}`
960
+ `Unknown task "${r}". Available tasks: ${d.join(", ") || "(none)"}`
855
961
  );
856
962
  }
857
- return t.run(r, a);
963
+ return t.run(i, a);
858
964
  }
859
965
  };
860
966
  return o;
861
967
  }
862
- un();
863
- async function ve(n) {
864
- const e = we(n);
968
+ fn();
969
+ async function Ne(n) {
970
+ const e = De(n);
865
971
  if (e.kind === "help")
866
- return Ne(), Promise.resolve();
867
- const o = e.options.quiet ?? !1, i = e.options.verbose ?? process.env.RN_TOOLS_DEBUG === "1", r = e.options.dryRun ?? !1, a = e.options.color ?? !0, t = sn({
972
+ return ke(), Promise.resolve();
973
+ const o = e.options.quiet ?? !1, r = e.options.verbose ?? process.env.RN_TOOLS_DEBUG === "1", i = e.options.dryRun ?? !1, a = e.options.color ?? !0, t = dn({
868
974
  color: a,
869
- dryRun: r,
975
+ dryRun: i,
870
976
  quiet: o,
871
977
  scope: e.kind,
872
- verbose: i
873
- }), d = un(), u = {
978
+ verbose: r
979
+ }), d = fn(), u = {
874
980
  rootDir: e.options.rootDir ?? process.cwd(),
875
981
  color: a,
876
- dryRun: r,
982
+ dryRun: i,
877
983
  quiet: o,
878
- verbose: i,
984
+ verbose: r,
879
985
  logger: t
880
986
  };
881
987
  return d.runTask(e.kind, u, e.options).then((c) => {
@@ -888,216 +994,246 @@ async function ve(n) {
888
994
  t.info(
889
995
  `Task completed: ${c.dryRun ? "dry-run" : "write"} mode, ${c.changedFiles.length} file(s) changed, ${c.movedFiles.length} file(s) moved`
890
996
  );
891
- const l = (f) => {
892
- var I;
893
- return c.dryRun ? t.info(f) : (I = t.debug) == null ? void 0 : I.call(t, f);
997
+ const f = (g) => {
998
+ var N;
999
+ return c.dryRun ? t.info(g) : (N = t.debug) == null ? void 0 : N.call(t, g);
894
1000
  };
895
- for (const f of c.changedFiles)
896
- l(
897
- ` ${c.dryRun ? "would change" : "changed"} ${s.relative(u.rootDir, f)}`
1001
+ for (const g of c.changedFiles)
1002
+ f(
1003
+ ` ${c.dryRun ? "would change" : "changed"} ${s.relative(u.rootDir, g)}`
898
1004
  );
899
- for (const f of c.movedFiles)
900
- l(
901
- ` ${c.dryRun ? "would move" : "moved"} ${s.relative(u.rootDir, f.from)} -> ${s.relative(u.rootDir, f.to)}`
1005
+ for (const g of c.movedFiles)
1006
+ f(
1007
+ ` ${c.dryRun ? "would move" : "moved"} ${s.relative(u.rootDir, g.from)} -> ${s.relative(u.rootDir, g.to)}`
902
1008
  );
903
- for (const f of c.warnings)
904
- t.warn(f);
1009
+ for (const g of c.warnings)
1010
+ t.warn(g);
905
1011
  }).catch((c) => {
906
1012
  t.error(c instanceof Error ? c.message : String(c)), process.exitCode = 1;
907
1013
  });
908
1014
  }
909
- function we(n) {
1015
+ function De(n) {
910
1016
  const e = [...n];
911
1017
  if (e.length === 0 || e.includes("--help") || e.includes("-h"))
912
1018
  return { kind: "help" };
913
1019
  const o = e.shift();
1020
+ if (o === "version")
1021
+ return { kind: "version", options: Ae(e) };
914
1022
  if (o === "rename") {
915
- const i = e.shift();
916
- return i === "bundle-id" ? { kind: "bundle-id", options: nn(e) } : i === "display-name" ? { kind: "display-name", options: en(e) } : i === "clean" ? { kind: "clean", options: on(e) } : i === "doctor" ? { kind: "doctor", options: rn(e) } : { kind: "help" };
1023
+ const r = e.shift();
1024
+ return r === "bundle-id" ? { kind: "bundle-id", options: on(e) } : r === "display-name" ? { kind: "display-name", options: rn(e) } : r === "clean" ? { kind: "clean", options: tn(e) } : r === "doctor" ? { kind: "doctor", options: an(e) } : { kind: "help" };
917
1025
  }
918
- return o === "bundle-id" ? { kind: "bundle-id", options: nn(e) } : o === "display-name" || o === "name" ? { kind: "display-name", options: en(e) } : o === "clean" ? { kind: "clean", options: on(e) } : o === "doctor" || o === "check" ? { kind: "doctor", options: rn(e) } : o === "icon" ? { kind: "icon", options: De(e) } : { kind: "help" };
1026
+ return o === "bundle-id" ? { kind: "bundle-id", options: on(e) } : o === "display-name" || o === "name" ? { kind: "display-name", options: rn(e) } : o === "clean" ? { kind: "clean", options: tn(e) } : o === "doctor" || o === "check" ? { kind: "doctor", options: an(e) } : o === "icon" ? { kind: "icon", options: xe(e) } : { kind: "help" };
919
1027
  }
920
- function nn(n) {
921
- const e = [...n], o = [], i = {
1028
+ function on(n) {
1029
+ const e = [...n], o = [], r = {
922
1030
  bundleId: ""
923
1031
  };
924
1032
  for (; e.length > 0; ) {
925
- const r = e.shift();
926
- if (r) {
927
- if (!r.startsWith("-")) {
928
- o.push(r);
1033
+ const i = e.shift();
1034
+ if (i) {
1035
+ if (!i.startsWith("-")) {
1036
+ o.push(i);
929
1037
  continue;
930
1038
  }
931
- if (r === "--root") {
932
- i.rootDir = h("--root", e);
1039
+ if (i === "--root") {
1040
+ r.rootDir = b("--root", e);
933
1041
  continue;
934
1042
  }
935
- if (r === "--android-package") {
936
- i.androidPackage = h("--android-package", e);
1043
+ if (i === "--android-package") {
1044
+ r.androidPackage = b("--android-package", e);
937
1045
  continue;
938
1046
  }
939
- if (r === "--ios-bundle-id") {
940
- i.iosBundleId = h("--ios-bundle-id", e);
1047
+ if (i === "--ios-bundle-id") {
1048
+ r.iosBundleId = b("--ios-bundle-id", e);
941
1049
  continue;
942
1050
  }
943
- if (!U(r, i)) {
944
- if (r === "--bundle-id") {
945
- i.bundleId = h("--bundle-id", e);
1051
+ if (!B(i, r)) {
1052
+ if (i === "--bundle-id") {
1053
+ r.bundleId = b("--bundle-id", e);
946
1054
  continue;
947
1055
  }
948
- throw new Error(`Unknown flag: ${r}`);
1056
+ throw new Error(`Unknown flag: ${i}`);
949
1057
  }
950
1058
  }
951
1059
  }
952
- if (!i.bundleId && o.length > 0 && (i.bundleId = o.shift() ?? ""), !i.bundleId)
1060
+ if (!r.bundleId && o.length > 0 && (r.bundleId = o.shift() ?? ""), !r.bundleId)
953
1061
  throw new Error("Missing bundle id. Example: bundle-id com.example.app");
954
- return i;
1062
+ return r;
955
1063
  }
956
- function en(n) {
957
- const e = [...n], o = [], i = {
1064
+ function rn(n) {
1065
+ const e = [...n], o = [], r = {
958
1066
  displayName: ""
959
1067
  };
960
1068
  for (; e.length > 0; ) {
961
- const r = e.shift();
962
- if (r) {
963
- if (!r.startsWith("-")) {
964
- o.push(r);
1069
+ const i = e.shift();
1070
+ if (i) {
1071
+ if (!i.startsWith("-")) {
1072
+ o.push(i);
965
1073
  continue;
966
1074
  }
967
- if (r === "--root") {
968
- i.rootDir = h("--root", e);
1075
+ if (i === "--root") {
1076
+ r.rootDir = b("--root", e);
969
1077
  continue;
970
1078
  }
971
- if (!U(r, i)) {
972
- if (r === "--display-name") {
973
- i.displayName = h("--display-name", e);
1079
+ if (!B(i, r)) {
1080
+ if (i === "--display-name") {
1081
+ r.displayName = b("--display-name", e);
974
1082
  continue;
975
1083
  }
976
- throw new Error(`Unknown flag: ${r}`);
1084
+ throw new Error(`Unknown flag: ${i}`);
977
1085
  }
978
1086
  }
979
1087
  }
980
- if (!i.displayName && o.length > 0 && (i.displayName = o.shift() ?? ""), !i.displayName)
1088
+ if (!r.displayName && o.length > 0 && (r.displayName = o.shift() ?? ""), !r.displayName)
981
1089
  throw new Error('Missing display name. Example: display-name "Youlai 医生"');
982
- return i;
1090
+ return r;
983
1091
  }
984
- function on(n) {
1092
+ function Ae(n) {
985
1093
  const e = [...n], o = {};
986
1094
  for (; e.length > 0; ) {
987
- const i = e.shift();
988
- if (i) {
989
- if (i === "--root") {
990
- o.rootDir = h("--root", e);
1095
+ const r = e.shift();
1096
+ if (r)
1097
+ if (r === "--root")
1098
+ o.rootDir = b(r, e);
1099
+ else if (r === "--version")
1100
+ o.version = b(r, e);
1101
+ else if (r === "--build-number")
1102
+ o.buildNumber = b(r, e);
1103
+ else if (r === "--platform") {
1104
+ const i = b(r, e);
1105
+ if (i !== "all" && i !== "android" && i !== "ios")
1106
+ throw new Error("Platform must be all, android, or ios");
1107
+ o.platform = i;
1108
+ } else {
1109
+ if (B(r, o))
1110
+ continue;
1111
+ if (!r.startsWith("-") && o.version === void 0)
1112
+ o.version = r;
1113
+ else
1114
+ throw new Error(`Unexpected version argument: ${r}`);
1115
+ }
1116
+ }
1117
+ return o;
1118
+ }
1119
+ function tn(n) {
1120
+ const e = [...n], o = {};
1121
+ for (; e.length > 0; ) {
1122
+ const r = e.shift();
1123
+ if (r) {
1124
+ if (r === "--root") {
1125
+ o.rootDir = b("--root", e);
991
1126
  continue;
992
1127
  }
993
- if (!U(i, o))
994
- throw new Error(`Unknown flag: ${i}`);
1128
+ if (!B(r, o))
1129
+ throw new Error(`Unknown flag: ${r}`);
995
1130
  }
996
1131
  }
997
1132
  return o;
998
1133
  }
999
- function rn(n) {
1134
+ function an(n) {
1000
1135
  const e = [...n], o = {};
1001
1136
  for (; e.length > 0; ) {
1002
- const i = e.shift();
1003
- if (i) {
1004
- if (i === "--root") {
1005
- o.rootDir = h("--root", e);
1137
+ const r = e.shift();
1138
+ if (r) {
1139
+ if (r === "--root") {
1140
+ o.rootDir = b("--root", e);
1006
1141
  continue;
1007
1142
  }
1008
- if (!U(i, o, { allowDryRun: !1 }))
1009
- throw new Error(`Unknown flag: ${i}`);
1143
+ if (!B(r, o, { allowDryRun: !1 }))
1144
+ throw new Error(`Unknown flag: ${r}`);
1010
1145
  }
1011
1146
  }
1012
1147
  return o;
1013
1148
  }
1014
- function De(n) {
1149
+ function xe(n) {
1015
1150
  const e = [...n], o = {};
1016
1151
  for (; e.length > 0; ) {
1017
- const i = e.shift();
1018
- if (i) {
1019
- if (!i.startsWith("-") && !o.sourceImage) {
1020
- o.sourceImage = i;
1152
+ const r = e.shift();
1153
+ if (r) {
1154
+ if (!r.startsWith("-") && !o.sourceImage) {
1155
+ o.sourceImage = r;
1021
1156
  continue;
1022
1157
  }
1023
- if (i === "--root") {
1024
- o.rootDir = h("--root", e);
1158
+ if (r === "--root") {
1159
+ o.rootDir = b("--root", e);
1025
1160
  continue;
1026
1161
  }
1027
- if (i === "--source") {
1028
- o.sourceImage = h("--source", e);
1162
+ if (r === "--source") {
1163
+ o.sourceImage = b("--source", e);
1029
1164
  continue;
1030
1165
  }
1031
- if (i === "--config") {
1032
- o.configPath = h("--config", e);
1166
+ if (r === "--config") {
1167
+ o.configPath = b("--config", e);
1033
1168
  continue;
1034
1169
  }
1035
- if (i === "--android-output") {
1036
- o.androidDestinationDir = h("--android-output", e);
1170
+ if (r === "--android-output") {
1171
+ o.androidDestinationDir = b("--android-output", e);
1037
1172
  continue;
1038
1173
  }
1039
- if (i === "--android-adaptive-icon") {
1174
+ if (r === "--android-adaptive-icon") {
1040
1175
  o.androidAdaptiveIcon = !0;
1041
1176
  continue;
1042
1177
  }
1043
- if (i === "--no-android-adaptive-icon") {
1178
+ if (r === "--no-android-adaptive-icon") {
1044
1179
  o.androidAdaptiveIcon = !1;
1045
1180
  continue;
1046
1181
  }
1047
- if (i === "--android-adaptive-icon-background") {
1048
- o.androidAdaptiveIconBackgroundColor = h(
1182
+ if (r === "--android-adaptive-icon-background") {
1183
+ o.androidAdaptiveIconBackgroundColor = b(
1049
1184
  "--android-adaptive-icon-background",
1050
1185
  e
1051
1186
  );
1052
1187
  continue;
1053
1188
  }
1054
- if (i === "--ios-icon-background") {
1055
- o.iosIconBackgroundColor = h("--ios-icon-background", e);
1189
+ if (r === "--ios-icon-background") {
1190
+ o.iosIconBackgroundColor = b("--ios-icon-background", e);
1056
1191
  continue;
1057
1192
  }
1058
- if (i === "--android-adaptive-icon-foreground-scale") {
1193
+ if (r === "--android-adaptive-icon-foreground-scale") {
1059
1194
  o.androidAdaptiveIconForegroundScale = Number.parseFloat(
1060
- h("--android-adaptive-icon-foreground-scale", e)
1195
+ b("--android-adaptive-icon-foreground-scale", e)
1061
1196
  );
1062
1197
  continue;
1063
1198
  }
1064
- if (i === "--ios-assets") {
1065
- o.iosAssetsDir = h("--ios-assets", e);
1199
+ if (r === "--ios-assets") {
1200
+ o.iosAssetsDir = b("--ios-assets", e);
1066
1201
  continue;
1067
1202
  }
1068
- if (i === "--ios-icon-set-name") {
1069
- o.iosIconSetName = h("--ios-icon-set-name", e);
1203
+ if (r === "--ios-icon-set-name") {
1204
+ o.iosIconSetName = b("--ios-icon-set-name", e);
1070
1205
  continue;
1071
1206
  }
1072
- if (i === "--android-icon-name") {
1073
- o.androidIconName = h("--android-icon-name", e);
1207
+ if (r === "--android-icon-name") {
1208
+ o.androidIconName = b("--android-icon-name", e);
1074
1209
  continue;
1075
1210
  }
1076
- if (i === "--android-round-icon-name") {
1077
- o.androidRoundIconName = h("--android-round-icon-name", e);
1211
+ if (r === "--android-round-icon-name") {
1212
+ o.androidRoundIconName = b("--android-round-icon-name", e);
1078
1213
  continue;
1079
1214
  }
1080
- if (!U(i, o))
1081
- throw new Error(`Unknown flag: ${i}`);
1215
+ if (!B(r, o))
1216
+ throw new Error(`Unknown flag: ${r}`);
1082
1217
  }
1083
1218
  }
1084
1219
  return o;
1085
1220
  }
1086
- function h(n, e) {
1221
+ function b(n, e) {
1087
1222
  const o = e.shift();
1088
1223
  if (!o || o.startsWith("-"))
1089
1224
  throw new Error(`Missing value for ${n}`);
1090
1225
  return o;
1091
1226
  }
1092
- function U(n, e, o = {}) {
1227
+ function B(n, e, o = {}) {
1093
1228
  return (o.allowDryRun ?? !0) && n === "--dry-run" ? (e.dryRun = !0, !0) : n === "--verbose" ? (e.verbose = !0, e.quiet = !1, !0) : n === "--quiet" ? (e.quiet = !0, !0) : n === "--color" ? (e.color = !0, !0) : n === "--no-color" ? (e.color = !1, !0) : !1;
1094
1229
  }
1095
- function Ne() {
1230
+ function ke() {
1096
1231
  process.stdout.write(
1097
1232
  [
1098
1233
  "rn-tools",
1099
1234
  "",
1100
1235
  "Usage:",
1236
+ " rn-tools version [version] [--build-number <integer>] [--platform all|android|ios] [--root <path>] [--dry-run]",
1101
1237
  " rn-tools bundle-id <bundleId> [--root <path>] [--dry-run] [--verbose]",
1102
1238
  " rn-tools display-name <name> [--root <path>] [--dry-run] [--verbose]",
1103
1239
  " rn-tools clean [--root <path>] [--dry-run] [--verbose]",
@@ -1109,6 +1245,7 @@ function Ne() {
1109
1245
  " rn-tools rename doctor [--root <path>] [--verbose]",
1110
1246
  "",
1111
1247
  "npx:",
1248
+ " npx @youlai/rn-tools version --build-number 38",
1112
1249
  " npx @youlai/rn-tools bundle-id <bundleId>",
1113
1250
  " npx rn-tools bundle-id <bundleId>",
1114
1251
  " npx @youlai/rn-tools display-name <name>",
@@ -1121,6 +1258,9 @@ function Ne() {
1121
1258
  " npx rn-tools icon",
1122
1259
  "",
1123
1260
  "Flags:",
1261
+ " --version <x.y.z> Set app version (default: project package.json version)",
1262
+ " --build-number <integer> Set Android versionCode and iOS build number; omitted values stay unchanged",
1263
+ " --platform <platform> Version command target: all (default), android, or ios",
1124
1264
  " --android-package <id> Override Android namespace/applicationId",
1125
1265
  " --ios-bundle-id <id> Override iOS bundle identifier",
1126
1266
  " --display-name <name> Explicit display name flag form",
@@ -1145,4 +1285,4 @@ function Ne() {
1145
1285
  `)
1146
1286
  );
1147
1287
  }
1148
- ve(process.argv.slice(2));
1288
+ Ne(process.argv.slice(2));