@youlai/rn-tools 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +328 -2
- package/cli.js +11 -0
- package/cli.mjs +1148 -0
- package/index.js +9 -0
- package/index.mjs +881 -0
- package/package.json +60 -3
- package/typings/bundle-id.d.ts +6 -0
- package/typings/clean.d.ts +3 -0
- package/typings/cli.d.ts +9 -0
- package/typings/display-name.d.ts +4 -0
- package/typings/doctor.d.ts +3 -0
- package/typings/fs.d.ts +12 -0
- package/typings/icon.d.ts +3 -0
- package/typings/index.d.ts +15 -0
- package/typings/ios.d.ts +2 -0
- package/typings/logger.d.ts +3 -0
- package/typings/tasks.d.ts +9 -0
- package/typings/types.d.ts +129 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,881 @@
|
|
|
1
|
+
import s from "node:path";
|
|
2
|
+
import u from "node:fs";
|
|
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");
|
|
8
|
+
}
|
|
9
|
+
function A(e) {
|
|
10
|
+
return u.existsSync(e) ? se(e) : null;
|
|
11
|
+
}
|
|
12
|
+
function $(e, n, r) {
|
|
13
|
+
r || (u.mkdirSync(s.dirname(e), { recursive: !0 }), u.writeFileSync(e, n));
|
|
14
|
+
}
|
|
15
|
+
function C(e, n) {
|
|
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);
|
|
20
|
+
}
|
|
21
|
+
return { content: r, changed: o };
|
|
22
|
+
}
|
|
23
|
+
function L(e) {
|
|
24
|
+
if (!u.existsSync(e))
|
|
25
|
+
return [];
|
|
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);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return r(e), n;
|
|
33
|
+
}
|
|
34
|
+
function de(e, n, r) {
|
|
35
|
+
if (!u.existsSync(e) || e === n)
|
|
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))
|
|
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,
|
|
44
|
+
to: d
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return r || ce(e), i;
|
|
48
|
+
}
|
|
49
|
+
function ce(e) {
|
|
50
|
+
let n = e;
|
|
51
|
+
for (; n !== s.dirname(n); ) {
|
|
52
|
+
if (!u.existsSync(n)) {
|
|
53
|
+
n = s.dirname(n);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (u.readdirSync(n).length > 0)
|
|
57
|
+
break;
|
|
58
|
+
u.rmdirSync(n), n = s.dirname(n);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function H(e, n) {
|
|
62
|
+
return u.existsSync(e) ? (n || u.rmSync(e, { recursive: !0, force: !0 }), !0) : !1;
|
|
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");
|
|
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)
|
|
70
|
+
throw new Error(`Could not find an iOS ${n} file under ${o}`);
|
|
71
|
+
return a;
|
|
72
|
+
}
|
|
73
|
+
const W = {
|
|
74
|
+
debug: 0,
|
|
75
|
+
info: 1,
|
|
76
|
+
warn: 2,
|
|
77
|
+
error: 3,
|
|
78
|
+
silent: 4
|
|
79
|
+
}, le = {
|
|
80
|
+
debug: "DEBUG",
|
|
81
|
+
info: "INFO ",
|
|
82
|
+
warn: "WARN ",
|
|
83
|
+
error: "ERROR"
|
|
84
|
+
};
|
|
85
|
+
function ue(e) {
|
|
86
|
+
return e.level ? e.level : e.quiet ? "warn" : e.verbose || process.env.RN_TOOLS_DEBUG === "1" ? "debug" : "info";
|
|
87
|
+
}
|
|
88
|
+
function fe(e, n, r) {
|
|
89
|
+
return e === "debug" ? r.gray(n) : e === "info" ? r.cyan(n) : e === "warn" ? r.yellow(n) : r.red(n);
|
|
90
|
+
}
|
|
91
|
+
function me() {
|
|
92
|
+
const e = /* @__PURE__ */ new Date();
|
|
93
|
+
return [
|
|
94
|
+
e.getHours().toString().padStart(2, "0"),
|
|
95
|
+
e.getMinutes().toString().padStart(2, "0"),
|
|
96
|
+
e.getSeconds().toString().padStart(2, "0")
|
|
97
|
+
].join(":");
|
|
98
|
+
}
|
|
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(" ");
|
|
102
|
+
}
|
|
103
|
+
function B(e, n, r, o, i) {
|
|
104
|
+
if (W[e] < W[o])
|
|
105
|
+
return;
|
|
106
|
+
const a = pe(e, n, r, i);
|
|
107
|
+
if (e === "error") {
|
|
108
|
+
console.error(a);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (e === "warn") {
|
|
112
|
+
console.warn(a);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
console.log(a);
|
|
116
|
+
}
|
|
117
|
+
function ge(e = {}) {
|
|
118
|
+
const n = ue(e), r = ae.createColors(e.color ?? !0);
|
|
119
|
+
return {
|
|
120
|
+
info(o) {
|
|
121
|
+
B("info", o, e, n, r);
|
|
122
|
+
},
|
|
123
|
+
warn(o) {
|
|
124
|
+
B("warn", o, e, n, r);
|
|
125
|
+
},
|
|
126
|
+
error(o) {
|
|
127
|
+
B("error", o, e, n, r);
|
|
128
|
+
},
|
|
129
|
+
debug(o) {
|
|
130
|
+
B("debug", o, e, n, r);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function T(e, n = {}) {
|
|
135
|
+
return e ?? ge(n);
|
|
136
|
+
}
|
|
137
|
+
const Ie = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)+$/, ee = ["java", "kotlin"];
|
|
138
|
+
function Z(e) {
|
|
139
|
+
if (!Ie.test(e))
|
|
140
|
+
throw new Error(
|
|
141
|
+
`Invalid bundle id: ${e}. Use dot-separated Java package style names, for example com.example.app`
|
|
142
|
+
);
|
|
143
|
+
}
|
|
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, {
|
|
147
|
+
dryRun: r,
|
|
148
|
+
color: e.color,
|
|
149
|
+
quiet: e.quiet,
|
|
150
|
+
scope: "bundle-id",
|
|
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}"`]
|
|
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`
|
|
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}"`]
|
|
173
|
+
]);
|
|
174
|
+
p.changed && ($(c.manifest, p.content, r), d.add(c.manifest));
|
|
175
|
+
}
|
|
176
|
+
const y = Ae(n), N = A(y);
|
|
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(
|
|
184
|
+
/<key>CFBundleIdentifier<\/key>\s*<string>([^<]+)<\/string>/
|
|
185
|
+
);
|
|
186
|
+
if (p && ne(p[1]))
|
|
187
|
+
(O = i.debug) == null || O.call(i, `Kept build setting reference ${p[1]} in ${g}`);
|
|
188
|
+
else {
|
|
189
|
+
const x = C(l, [
|
|
190
|
+
[
|
|
191
|
+
/<key>CFBundleIdentifier<\/key>\s*<string>[^<]+<\/string>/,
|
|
192
|
+
`<key>CFBundleIdentifier</key>
|
|
193
|
+
<string>${t}</string>`
|
|
194
|
+
]
|
|
195
|
+
]);
|
|
196
|
+
x.changed && ($(g, x.content, r), d.add(g));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const p of ee) {
|
|
200
|
+
const x = s.join(
|
|
201
|
+
n,
|
|
202
|
+
"android/app/src/main",
|
|
203
|
+
p,
|
|
204
|
+
...v.split(".")
|
|
205
|
+
), k = s.join(
|
|
206
|
+
n,
|
|
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);
|
|
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)
|
|
218
|
+
continue;
|
|
219
|
+
const k = C(x, [
|
|
220
|
+
[
|
|
221
|
+
new RegExp(`^package\\s+${we(v)}$`, "m"),
|
|
222
|
+
`package ${a}`
|
|
223
|
+
]
|
|
224
|
+
]);
|
|
225
|
+
k.changed && ($(p, k.content, r), d.add(p));
|
|
226
|
+
}
|
|
227
|
+
const F = {
|
|
228
|
+
changedFiles: Array.from(d).sort(),
|
|
229
|
+
movedFiles: m,
|
|
230
|
+
warnings: Array.from(f).sort(),
|
|
231
|
+
dryRun: r
|
|
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;
|
|
234
|
+
}
|
|
235
|
+
function he(e, n) {
|
|
236
|
+
let r = 0;
|
|
237
|
+
const o = e.replace(
|
|
238
|
+
/PRODUCT_BUNDLE_IDENTIFIER = ("[^"\n]*"|[^;\n]+);/g,
|
|
239
|
+
(i, a) => (r += 1, `PRODUCT_BUNDLE_IDENTIFIER = ${a.startsWith('"') ? `"${n}"` : n};`)
|
|
240
|
+
);
|
|
241
|
+
return { content: o, changed: o !== e, matches: r };
|
|
242
|
+
}
|
|
243
|
+
function ne(e) {
|
|
244
|
+
return /\$[({][A-Za-z0-9_:]+[)}]/.test(e);
|
|
245
|
+
}
|
|
246
|
+
function Ne(e) {
|
|
247
|
+
const n = A(e);
|
|
248
|
+
if (!n)
|
|
249
|
+
return null;
|
|
250
|
+
const r = n.match(/namespace\s+"([^"]+)"/);
|
|
251
|
+
return (r == null ? void 0 : r[1]) ?? null;
|
|
252
|
+
}
|
|
253
|
+
function De(e) {
|
|
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")
|
|
259
|
+
};
|
|
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"));
|
|
263
|
+
}
|
|
264
|
+
function ve(e, n) {
|
|
265
|
+
const r = ee.map(
|
|
266
|
+
(i) => s.join(e, "android/app/src/main", i, ...n.split("."))
|
|
267
|
+
), o = [];
|
|
268
|
+
for (const i of r)
|
|
269
|
+
o.push(...L(i));
|
|
270
|
+
return o;
|
|
271
|
+
}
|
|
272
|
+
function we(e) {
|
|
273
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
274
|
+
}
|
|
275
|
+
const $e = [
|
|
276
|
+
"android/.gradle",
|
|
277
|
+
"android/app/build",
|
|
278
|
+
"ios/build",
|
|
279
|
+
".metro",
|
|
280
|
+
".expo"
|
|
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, {
|
|
285
|
+
dryRun: r,
|
|
286
|
+
color: e.color,
|
|
287
|
+
quiet: e.quiet,
|
|
288
|
+
scope: "clean",
|
|
289
|
+
verbose: o
|
|
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));
|
|
296
|
+
}
|
|
297
|
+
const d = {
|
|
298
|
+
changedFiles: Array.from(a).sort(),
|
|
299
|
+
movedFiles: [],
|
|
300
|
+
warnings: Array.from(t).sort(),
|
|
301
|
+
dryRun: r
|
|
302
|
+
};
|
|
303
|
+
return r ? i.info(`Dry-run completed with ${d.changedFiles.length} target(s)`) : i.info(`Cleaned ${d.changedFiles.length} target(s)`), d;
|
|
304
|
+
}
|
|
305
|
+
function xe(e) {
|
|
306
|
+
if (!e || !e.trim())
|
|
307
|
+
throw new Error("Display name cannot be empty");
|
|
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, {
|
|
312
|
+
dryRun: r,
|
|
313
|
+
color: e.color,
|
|
314
|
+
quiet: e.quiet,
|
|
315
|
+
scope: "display-name",
|
|
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)
|
|
321
|
+
try {
|
|
322
|
+
const D = {
|
|
323
|
+
...JSON.parse(m),
|
|
324
|
+
displayName: a
|
|
325
|
+
}, g = `${JSON.stringify(D, null, 2)}
|
|
326
|
+
`;
|
|
327
|
+
g !== m && ($(f, g, r), t.add(f));
|
|
328
|
+
} catch {
|
|
329
|
+
d.add(`Skipped invalid JSON file: ${f}`);
|
|
330
|
+
}
|
|
331
|
+
const c = q(n), h = A(c);
|
|
332
|
+
if (h) {
|
|
333
|
+
const N = [
|
|
334
|
+
[
|
|
335
|
+
/<key>CFBundleDisplayName<\/key>\s*<string>[^<]*<\/string>/,
|
|
336
|
+
`<key>CFBundleDisplayName</key>
|
|
337
|
+
<string>${a}</string>`
|
|
338
|
+
]
|
|
339
|
+
], D = h.match(
|
|
340
|
+
/<key>CFBundleName<\/key>\s*<string>([^<]*)<\/string>/
|
|
341
|
+
);
|
|
342
|
+
(!D || !ne(D[1])) && N.push([
|
|
343
|
+
/<key>CFBundleName<\/key>\s*<string>[^<]*<\/string>/,
|
|
344
|
+
`<key>CFBundleName</key>
|
|
345
|
+
<string>${a}</string>`
|
|
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}`);
|
|
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>`]
|
|
354
|
+
]);
|
|
355
|
+
N.changed ? ($(v, N.content, r), t.add(v)) : d.add(`No Android app_name changes were needed in ${v}`);
|
|
356
|
+
}
|
|
357
|
+
const I = {
|
|
358
|
+
changedFiles: Array.from(t).sort(),
|
|
359
|
+
movedFiles: [],
|
|
360
|
+
warnings: Array.from(d).sort(),
|
|
361
|
+
dryRun: r
|
|
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;
|
|
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, {
|
|
368
|
+
color: e.color,
|
|
369
|
+
quiet: e.quiet,
|
|
370
|
+
scope: "doctor",
|
|
371
|
+
verbose: r
|
|
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)
|
|
376
|
+
i.add(`Missing app.json: ${d}`);
|
|
377
|
+
else
|
|
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}`);
|
|
381
|
+
} catch {
|
|
382
|
+
i.add(`Invalid JSON: ${d}`);
|
|
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}`);
|
|
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}`);
|
|
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}`);
|
|
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}`);
|
|
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}`
|
|
403
|
+
);
|
|
404
|
+
for (const l of i)
|
|
405
|
+
o.warn(l);
|
|
406
|
+
return i.size === 0 ? o.info("Doctor check passed") : o.info(`Doctor found ${i.size} issue(s)`), {
|
|
407
|
+
changedFiles: a,
|
|
408
|
+
movedFiles: [],
|
|
409
|
+
warnings: Array.from(i).sort(),
|
|
410
|
+
dryRun: !0
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function M(e, n) {
|
|
414
|
+
var r;
|
|
415
|
+
return (r = e.match(new RegExp(`<key>${n}<\\/key>\\s*<string>([^<]*)<\\/string>`))) == null ? void 0 : r[1];
|
|
416
|
+
}
|
|
417
|
+
function E(e) {
|
|
418
|
+
return typeof e == "string" && !e.startsWith("$(") && !e.startsWith("${");
|
|
419
|
+
}
|
|
420
|
+
function ke(e, n) {
|
|
421
|
+
e.androidNamespace && e.androidApplicationId && e.androidNamespace !== e.androidApplicationId && n.add(
|
|
422
|
+
`Android namespace and applicationId differ: ${e.androidNamespace} vs ${e.androidApplicationId}`
|
|
423
|
+
), E(e.iosDisplayName) && E(e.iosName) && e.iosDisplayName !== e.iosName && n.add(
|
|
424
|
+
`iOS CFBundleDisplayName and CFBundleName differ: ${e.iosDisplayName} vs ${e.iosName}`
|
|
425
|
+
);
|
|
426
|
+
const r = e.displayName;
|
|
427
|
+
E(r) && (E(e.androidAppName) && e.androidAppName !== r && n.add(
|
|
428
|
+
`Android app_name does not match app.json displayName: ${e.androidAppName} vs ${r}`
|
|
429
|
+
), E(e.iosDisplayName) && e.iosDisplayName !== r && n.add(
|
|
430
|
+
`iOS CFBundleDisplayName does not match app.json displayName: ${e.iosDisplayName} vs ${r}`
|
|
431
|
+
));
|
|
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 = [
|
|
434
|
+
{ dir: "mipmap-mdpi", size: 48 },
|
|
435
|
+
{ dir: "mipmap-hdpi", size: 72 },
|
|
436
|
+
{ dir: "mipmap-xhdpi", size: 96 },
|
|
437
|
+
{ dir: "mipmap-xxhdpi", size: 144 },
|
|
438
|
+
{ dir: "mipmap-xxxhdpi", size: 192 }
|
|
439
|
+
], Ue = [
|
|
440
|
+
{ dir: "drawable-mdpi", size: 108 },
|
|
441
|
+
{ dir: "drawable-hdpi", size: 162 },
|
|
442
|
+
{ dir: "drawable-xhdpi", size: 216 },
|
|
443
|
+
{ dir: "drawable-xxhdpi", size: 324 },
|
|
444
|
+
{ dir: "drawable-xxxhdpi", size: 432 }
|
|
445
|
+
], V = [
|
|
446
|
+
{ idiom: "iphone", size: "20x20", scale: "2x", filename: "icon-20x20-2x-iphone.png" },
|
|
447
|
+
{ idiom: "iphone", size: "20x20", scale: "3x", filename: "icon-20x20-3x-iphone.png" },
|
|
448
|
+
{ idiom: "ipad", size: "20x20", scale: "1x", filename: "icon-20x20-1x-ipad.png" },
|
|
449
|
+
{ idiom: "ipad", size: "20x20", scale: "2x", filename: "icon-20x20-2x-ipad.png" },
|
|
450
|
+
{ idiom: "iphone", size: "29x29", scale: "2x", filename: "icon-29x29-2x-iphone.png" },
|
|
451
|
+
{ idiom: "iphone", size: "29x29", scale: "3x", filename: "icon-29x29-3x-iphone.png" },
|
|
452
|
+
{ idiom: "ipad", size: "29x29", scale: "1x", filename: "icon-29x29-1x-ipad.png" },
|
|
453
|
+
{ idiom: "ipad", size: "29x29", scale: "2x", filename: "icon-29x29-2x-ipad.png" },
|
|
454
|
+
{ idiom: "iphone", size: "40x40", scale: "2x", filename: "icon-40x40-2x-iphone.png" },
|
|
455
|
+
{ idiom: "iphone", size: "40x40", scale: "3x", filename: "icon-40x40-3x-iphone.png" },
|
|
456
|
+
{ idiom: "ipad", size: "40x40", scale: "1x", filename: "icon-40x40-1x-ipad.png" },
|
|
457
|
+
{ idiom: "ipad", size: "40x40", scale: "2x", filename: "icon-40x40-2x-ipad.png" },
|
|
458
|
+
{ idiom: "iphone", size: "60x60", scale: "2x", filename: "icon-60x60-2x-iphone.png" },
|
|
459
|
+
{ idiom: "iphone", size: "60x60", scale: "3x", filename: "icon-60x60-3x-iphone.png" },
|
|
460
|
+
{ idiom: "ipad", size: "76x76", scale: "1x", filename: "icon-76x76-1x-ipad.png" },
|
|
461
|
+
{ idiom: "ipad", size: "76x76", scale: "2x", filename: "icon-76x76-2x-ipad.png" },
|
|
462
|
+
{ idiom: "ipad", size: "83.5x83.5", scale: "2x", filename: "icon-83_5x83_5-2x-ipad.png" },
|
|
463
|
+
{ idiom: "ios-marketing", size: "1024x1024", scale: "1x", filename: "icon-1024x1024.png" }
|
|
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, {
|
|
468
|
+
dryRun: i,
|
|
469
|
+
color: e.color,
|
|
470
|
+
quiet: e.quiet,
|
|
471
|
+
scope: "icon",
|
|
472
|
+
verbose: a
|
|
473
|
+
}), d = G(
|
|
474
|
+
o,
|
|
475
|
+
r.sourceImage ?? Ce
|
|
476
|
+
), f = G(
|
|
477
|
+
o,
|
|
478
|
+
r.androidDestinationDir ?? Re
|
|
479
|
+
), m = G(
|
|
480
|
+
o,
|
|
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({
|
|
490
|
+
sourceImage: d,
|
|
491
|
+
destinationDir: f,
|
|
492
|
+
iconName: h,
|
|
493
|
+
roundIconName: v,
|
|
494
|
+
adaptiveIcon: w,
|
|
495
|
+
adaptiveIconBackgroundColor: I,
|
|
496
|
+
adaptiveIconForegroundScale: S,
|
|
497
|
+
dryRun: i
|
|
498
|
+
}), b = await Me({
|
|
499
|
+
sourceImage: d,
|
|
500
|
+
iconSetDir: c,
|
|
501
|
+
backgroundColor: y,
|
|
502
|
+
dryRun: i
|
|
503
|
+
});
|
|
504
|
+
(await P(d).stats()).isOpaque || g.add(
|
|
505
|
+
`Icon source has transparent pixels; iOS icons were filled with ${y}`
|
|
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(),
|
|
512
|
+
movedFiles: [],
|
|
513
|
+
warnings: Array.from(g).sort(),
|
|
514
|
+
dryRun: i
|
|
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;
|
|
517
|
+
}
|
|
518
|
+
function Le(e, n) {
|
|
519
|
+
return {
|
|
520
|
+
...e,
|
|
521
|
+
...n
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
async function qe(e) {
|
|
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);
|
|
529
|
+
}
|
|
530
|
+
if (e.adaptiveIcon) {
|
|
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(
|
|
535
|
+
e.sourceImage,
|
|
536
|
+
c,
|
|
537
|
+
f,
|
|
538
|
+
e.adaptiveIconForegroundScale
|
|
539
|
+
)), n.push(c);
|
|
540
|
+
}
|
|
541
|
+
const i = s.join(e.destinationDir, "values", `${o}.xml`), a = s.join(
|
|
542
|
+
e.destinationDir,
|
|
543
|
+
"mipmap-anydpi-v26",
|
|
544
|
+
`${e.iconName}.xml`
|
|
545
|
+
), t = s.join(
|
|
546
|
+
e.destinationDir,
|
|
547
|
+
"mipmap-anydpi-v26",
|
|
548
|
+
`${e.roundIconName}.xml`
|
|
549
|
+
);
|
|
550
|
+
e.dryRun || ($(
|
|
551
|
+
i,
|
|
552
|
+
He(o, e.adaptiveIconBackgroundColor),
|
|
553
|
+
!1
|
|
554
|
+
), $(a, X(o, r), !1), $(
|
|
555
|
+
t,
|
|
556
|
+
X(o, r),
|
|
557
|
+
!1
|
|
558
|
+
)), n.push(i, a, t);
|
|
559
|
+
}
|
|
560
|
+
return n;
|
|
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
|
|
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);
|
|
573
|
+
}
|
|
574
|
+
const o = s.join(e.iconSetDir, "Contents.json"), i = JSON.stringify(
|
|
575
|
+
{
|
|
576
|
+
images: r,
|
|
577
|
+
info: {
|
|
578
|
+
version: 1,
|
|
579
|
+
author: "xcode"
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
null,
|
|
583
|
+
2
|
|
584
|
+
);
|
|
585
|
+
return e.dryRun || $(o, `${i}
|
|
586
|
+
`, !1), n.push(o), n;
|
|
587
|
+
}
|
|
588
|
+
function Ge(e, n) {
|
|
589
|
+
const r = Number.parseFloat(e.split("x")[0] ?? "0"), o = Number.parseFloat(n.replace("x", ""));
|
|
590
|
+
return Math.round(r * o);
|
|
591
|
+
}
|
|
592
|
+
function Je(e, n) {
|
|
593
|
+
if (!u.existsSync(e))
|
|
594
|
+
throw new Error(`${n} not found: ${e}`);
|
|
595
|
+
}
|
|
596
|
+
function We(e, n) {
|
|
597
|
+
if (!e.width || !e.height)
|
|
598
|
+
throw new Error(`Unable to read image dimensions for ${n}`);
|
|
599
|
+
if (e.width !== e.height)
|
|
600
|
+
throw new Error(
|
|
601
|
+
`Icon source image must be square, but got ${e.width}x${e.height}: ${n}`
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
function Ze(e) {
|
|
605
|
+
if (!Number.isFinite(e) || e <= 0 || e > 1)
|
|
606
|
+
throw new Error(
|
|
607
|
+
`Android adaptive icon foreground scale must be a number between 0 and 1, but got ${e}`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function Ve(e, n, r) {
|
|
611
|
+
const o = re.map(
|
|
612
|
+
({ dir: a }) => s.join(n, a)
|
|
613
|
+
), i = [r, ...o].filter(
|
|
614
|
+
(a) => Xe(e, a)
|
|
615
|
+
);
|
|
616
|
+
if (i.length > 0)
|
|
617
|
+
throw new Error(
|
|
618
|
+
`Icon source image must be outside generated icon directories: ${i.join(", ")}
|
|
619
|
+
Use a source file such as assets/icon.png instead: ${e}`
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
function Xe(e, n) {
|
|
623
|
+
const r = s.relative(n, e);
|
|
624
|
+
return r === "" || !r.startsWith("..") && !s.isAbsolute(r);
|
|
625
|
+
}
|
|
626
|
+
function G(e, n) {
|
|
627
|
+
return s.isAbsolute(n) ? n : s.join(e, n);
|
|
628
|
+
}
|
|
629
|
+
async function Ke(e) {
|
|
630
|
+
return P(e).metadata();
|
|
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" });
|
|
635
|
+
o && i.flatten({ background: o }).removeAlpha(), await i.png().toFile(n);
|
|
636
|
+
}
|
|
637
|
+
async function Ye(e, n, r, o) {
|
|
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({
|
|
640
|
+
top: Math.floor((r - i) / 2),
|
|
641
|
+
bottom: Math.ceil((r - i) / 2),
|
|
642
|
+
left: Math.floor((r - i) / 2),
|
|
643
|
+
right: Math.ceil((r - i) / 2),
|
|
644
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
645
|
+
}).png().toFile(n);
|
|
646
|
+
}
|
|
647
|
+
function He(e, n) {
|
|
648
|
+
return [
|
|
649
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
650
|
+
"<resources>",
|
|
651
|
+
` <color name="${e}">${n}</color>`,
|
|
652
|
+
"</resources>",
|
|
653
|
+
""
|
|
654
|
+
].join(`
|
|
655
|
+
`);
|
|
656
|
+
}
|
|
657
|
+
function X(e, n) {
|
|
658
|
+
return [
|
|
659
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
660
|
+
'<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">',
|
|
661
|
+
` <background android:drawable="@color/${e}" />`,
|
|
662
|
+
` <foreground android:drawable="@drawable/${n}" />`,
|
|
663
|
+
"</adaptive-icon>",
|
|
664
|
+
""
|
|
665
|
+
].join(`
|
|
666
|
+
`);
|
|
667
|
+
}
|
|
668
|
+
async function Qe(e, n) {
|
|
669
|
+
if (!e) {
|
|
670
|
+
const i = rn(n);
|
|
671
|
+
return i ? K(i) : {};
|
|
672
|
+
}
|
|
673
|
+
nn(e);
|
|
674
|
+
const r = en(e, n), o = r.find((i) => u.existsSync(i));
|
|
675
|
+
if (!o)
|
|
676
|
+
throw new Error(`Icon config file not found: ${r[0] ?? s.resolve(e)}`);
|
|
677
|
+
return K(o);
|
|
678
|
+
}
|
|
679
|
+
function en(e, n) {
|
|
680
|
+
if (s.isAbsolute(e))
|
|
681
|
+
return [e];
|
|
682
|
+
const r = s.resolve(process.cwd(), e), o = n ? s.resolve(n, e) : null, i = [r];
|
|
683
|
+
return o && o !== r && i.push(o), i;
|
|
684
|
+
}
|
|
685
|
+
function nn(e) {
|
|
686
|
+
const n = s.basename(e);
|
|
687
|
+
if (n === "rn-tools.config" || n.startsWith("rn-tools.config."))
|
|
688
|
+
throw new Error(
|
|
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
|
+
);
|
|
691
|
+
}
|
|
692
|
+
function rn(e) {
|
|
693
|
+
const n = [e ? s.resolve(e) : null, process.cwd()].filter(
|
|
694
|
+
(o) => !!o
|
|
695
|
+
), r = [
|
|
696
|
+
".rn-toolsrc",
|
|
697
|
+
".rn-toolsrc.json",
|
|
698
|
+
".rn-toolsrc.js",
|
|
699
|
+
".rn-toolsrc.cjs",
|
|
700
|
+
".rn-toolsrc.mjs"
|
|
701
|
+
];
|
|
702
|
+
for (const o of n)
|
|
703
|
+
for (const i of r) {
|
|
704
|
+
const a = s.join(o, i);
|
|
705
|
+
if (u.existsSync(a))
|
|
706
|
+
return a;
|
|
707
|
+
}
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
async function K(e) {
|
|
711
|
+
const n = s.extname(e).toLowerCase();
|
|
712
|
+
if (n === ".json" || n === "") {
|
|
713
|
+
const o = A(e);
|
|
714
|
+
if (!o)
|
|
715
|
+
throw new Error(`Icon config file not found: ${e}`);
|
|
716
|
+
let i;
|
|
717
|
+
try {
|
|
718
|
+
i = JSON.parse(o);
|
|
719
|
+
} catch {
|
|
720
|
+
throw new Error(`Icon config file is not valid JSON: ${e}`);
|
|
721
|
+
}
|
|
722
|
+
return Y(i, e);
|
|
723
|
+
}
|
|
724
|
+
const r = await import(te(e).href);
|
|
725
|
+
return Y(r, e);
|
|
726
|
+
}
|
|
727
|
+
function Y(e, n) {
|
|
728
|
+
if (!e || typeof e != "object")
|
|
729
|
+
throw new Error(`Icon config file must contain an object: ${n}`);
|
|
730
|
+
const r = on(e);
|
|
731
|
+
if (!r)
|
|
732
|
+
throw new Error(`Icon config section must be an object: ${n}`);
|
|
733
|
+
return tn(r, s.dirname(n));
|
|
734
|
+
}
|
|
735
|
+
function on(e) {
|
|
736
|
+
if (!z(e))
|
|
737
|
+
return null;
|
|
738
|
+
const n = z(e.default) ? e.default : e;
|
|
739
|
+
return an(n) ? z(n.icon) ? n.icon : null : z(n) ? n : null;
|
|
740
|
+
}
|
|
741
|
+
function an(e) {
|
|
742
|
+
return Object.prototype.hasOwnProperty.call(e, "icon");
|
|
743
|
+
}
|
|
744
|
+
function z(e) {
|
|
745
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
746
|
+
}
|
|
747
|
+
function tn(e, n) {
|
|
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;
|
|
750
|
+
}
|
|
751
|
+
function U(e, n) {
|
|
752
|
+
return s.isAbsolute(n) ? n : s.resolve(e, n);
|
|
753
|
+
}
|
|
754
|
+
function sn(e) {
|
|
755
|
+
const n = q(e);
|
|
756
|
+
return s.join(s.dirname(n), "Images.xcassets");
|
|
757
|
+
}
|
|
758
|
+
const dn = {
|
|
759
|
+
name: "bundle-id",
|
|
760
|
+
description: "Rename the iOS bundle identifier and Android application package",
|
|
761
|
+
async run(e, n) {
|
|
762
|
+
return ye({
|
|
763
|
+
...n,
|
|
764
|
+
rootDir: n.rootDir ?? e.rootDir,
|
|
765
|
+
dryRun: n.dryRun ?? e.dryRun,
|
|
766
|
+
verbose: n.verbose ?? e.verbose,
|
|
767
|
+
quiet: n.quiet ?? e.quiet,
|
|
768
|
+
color: n.color ?? e.color,
|
|
769
|
+
logger: n.logger ?? e.logger
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
}, cn = {
|
|
773
|
+
name: "display-name",
|
|
774
|
+
description: "Update the app display name on iOS and Android",
|
|
775
|
+
async run(e, n) {
|
|
776
|
+
return Se({
|
|
777
|
+
...n,
|
|
778
|
+
rootDir: n.rootDir ?? e.rootDir,
|
|
779
|
+
dryRun: n.dryRun ?? e.dryRun,
|
|
780
|
+
verbose: n.verbose ?? e.verbose,
|
|
781
|
+
quiet: n.quiet ?? e.quiet,
|
|
782
|
+
color: n.color ?? e.color,
|
|
783
|
+
logger: n.logger ?? e.logger
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}, ln = {
|
|
787
|
+
name: "clean",
|
|
788
|
+
description: "Remove common build and cache artifacts",
|
|
789
|
+
async run(e, n) {
|
|
790
|
+
return be({
|
|
791
|
+
...n,
|
|
792
|
+
rootDir: n.rootDir ?? e.rootDir,
|
|
793
|
+
dryRun: n.dryRun ?? e.dryRun,
|
|
794
|
+
verbose: n.verbose ?? e.verbose,
|
|
795
|
+
quiet: n.quiet ?? e.quiet,
|
|
796
|
+
color: n.color ?? e.color,
|
|
797
|
+
logger: n.logger ?? e.logger
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
}, un = {
|
|
801
|
+
name: "doctor",
|
|
802
|
+
description: "Check common RN project health signals",
|
|
803
|
+
async run(e, n) {
|
|
804
|
+
return Fe({
|
|
805
|
+
...n,
|
|
806
|
+
rootDir: n.rootDir ?? e.rootDir,
|
|
807
|
+
verbose: n.verbose ?? e.verbose,
|
|
808
|
+
quiet: n.quiet ?? e.quiet,
|
|
809
|
+
color: n.color ?? e.color,
|
|
810
|
+
logger: n.logger ?? e.logger
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
}, fn = {
|
|
814
|
+
name: "icon",
|
|
815
|
+
description: "Generate Android and iOS app icons from a single source image",
|
|
816
|
+
async run(e, n) {
|
|
817
|
+
return Pe({
|
|
818
|
+
...n,
|
|
819
|
+
rootDir: n.rootDir ?? e.rootDir,
|
|
820
|
+
dryRun: n.dryRun ?? e.dryRun,
|
|
821
|
+
verbose: n.verbose ?? e.verbose,
|
|
822
|
+
quiet: n.quiet ?? e.quiet,
|
|
823
|
+
color: n.color ?? e.color,
|
|
824
|
+
logger: n.logger ?? e.logger
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
function mn(e = [
|
|
829
|
+
dn,
|
|
830
|
+
cn,
|
|
831
|
+
ln,
|
|
832
|
+
un,
|
|
833
|
+
fn
|
|
834
|
+
]) {
|
|
835
|
+
const n = /* @__PURE__ */ new Map();
|
|
836
|
+
for (const o of e)
|
|
837
|
+
n.set(o.name, o);
|
|
838
|
+
const r = {
|
|
839
|
+
listTasks() {
|
|
840
|
+
return Array.from(n.values());
|
|
841
|
+
},
|
|
842
|
+
getTask(o) {
|
|
843
|
+
return n.get(o);
|
|
844
|
+
},
|
|
845
|
+
registerTask(o) {
|
|
846
|
+
return n.set(o.name, o), r;
|
|
847
|
+
},
|
|
848
|
+
async runTask(o, i, a) {
|
|
849
|
+
const t = n.get(o);
|
|
850
|
+
if (!t) {
|
|
851
|
+
const d = Array.from(n.keys()).sort();
|
|
852
|
+
throw new Error(
|
|
853
|
+
`Unknown task "${o}". Available tasks: ${d.join(", ") || "(none)"}`
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
return t.run(i, a);
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
return r;
|
|
860
|
+
}
|
|
861
|
+
const pn = mn();
|
|
862
|
+
async function Dn(e, n, r, o = pn) {
|
|
863
|
+
return o.runTask(e, n, r);
|
|
864
|
+
}
|
|
865
|
+
export {
|
|
866
|
+
Pe as buildIconAssets,
|
|
867
|
+
dn as bundleIdTask,
|
|
868
|
+
be as cleanProject,
|
|
869
|
+
ln as cleanTask,
|
|
870
|
+
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,
|
|
878
|
+
ye as renameBundleId,
|
|
879
|
+
Dn as runProjectTask,
|
|
880
|
+
Se as updateDisplayName
|
|
881
|
+
};
|