@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/README.md +41 -0
- package/cli.js +11 -10
- package/cli.mjs +579 -439
- package/index.js +10 -9
- package/index.mjs +455 -347
- package/package.json +2 -2
- package/typings/index.d.ts +3 -2
- package/typings/tasks.d.ts +2 -1
- package/typings/types.d.ts +11 -0
- package/typings/version.d.ts +3 -0
package/cli.mjs
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import s from "node:path";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { pathToFileURL as
|
|
6
|
-
import
|
|
7
|
-
function
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
function
|
|
14
|
-
o || (
|
|
15
|
-
}
|
|
16
|
-
function
|
|
17
|
-
let o = n,
|
|
18
|
-
for (const [
|
|
19
|
-
const t = o.replace(
|
|
20
|
-
t !== o && (o = t,
|
|
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:
|
|
22
|
+
return { content: o, changed: r };
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
24
|
+
function G(n) {
|
|
25
|
+
if (!w.existsSync(n))
|
|
26
26
|
return [];
|
|
27
|
-
const e = [], o = (
|
|
28
|
-
for (const
|
|
29
|
-
const a = s.join(
|
|
30
|
-
|
|
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 (!
|
|
36
|
+
if (!w.existsSync(n) || n === e)
|
|
37
37
|
return [];
|
|
38
|
-
const
|
|
39
|
-
for (const a of
|
|
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 (
|
|
41
|
+
if (w.existsSync(d))
|
|
42
42
|
throw new Error(`Destination path already exists: ${d}`);
|
|
43
|
-
o || (
|
|
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 ||
|
|
48
|
+
return o || vn(n), i;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function vn(n) {
|
|
51
51
|
let e = n;
|
|
52
52
|
for (; e !== s.dirname(e); ) {
|
|
53
|
-
if (!
|
|
53
|
+
if (!w.existsSync(e)) {
|
|
54
54
|
e = s.dirname(e);
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
57
|
+
if (w.readdirSync(e).length > 0)
|
|
58
58
|
break;
|
|
59
|
-
|
|
59
|
+
w.rmdirSync(e), e = s.dirname(e);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
62
|
+
function sn(n, e) {
|
|
63
|
+
return w.existsSync(n) ? (e || w.rmSync(n, { recursive: !0, force: !0 }), !0) : !1;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
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
|
|
69
|
-
const
|
|
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 ${
|
|
71
|
+
throw new Error(`Could not find an iOS ${e} file under ${r}`);
|
|
72
72
|
return a;
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const X = {
|
|
75
75
|
debug: 0,
|
|
76
76
|
info: 1,
|
|
77
77
|
warn: 2,
|
|
78
78
|
error: 3,
|
|
79
79
|
silent: 4
|
|
80
|
-
},
|
|
80
|
+
}, In = {
|
|
81
81
|
debug: "DEBUG",
|
|
82
82
|
info: "INFO ",
|
|
83
83
|
warn: "WARN ",
|
|
84
84
|
error: "ERROR"
|
|
85
85
|
};
|
|
86
|
-
function
|
|
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
|
|
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,
|
|
101
|
-
const
|
|
102
|
-
return (o.timestamps ?? !0) &&
|
|
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
|
|
105
|
-
if (
|
|
104
|
+
function q(n, e, o, r, i) {
|
|
105
|
+
if (X[n] < X[r])
|
|
106
106
|
return;
|
|
107
|
-
const a = Nn(n, e, o,
|
|
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
|
|
119
|
-
const e =
|
|
118
|
+
function dn(n = {}) {
|
|
119
|
+
const e = bn(n), o = gn.createColors(n.color ?? !0);
|
|
120
120
|
return {
|
|
121
|
-
info(
|
|
122
|
-
|
|
121
|
+
info(r) {
|
|
122
|
+
q("info", r, n, e, o);
|
|
123
123
|
},
|
|
124
|
-
warn(
|
|
125
|
-
|
|
124
|
+
warn(r) {
|
|
125
|
+
q("warn", r, n, e, o);
|
|
126
126
|
},
|
|
127
|
-
error(
|
|
128
|
-
|
|
127
|
+
error(r) {
|
|
128
|
+
q("error", r, n, e, o);
|
|
129
129
|
},
|
|
130
|
-
debug(
|
|
131
|
-
|
|
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 ??
|
|
136
|
+
return n ?? dn(e);
|
|
137
137
|
}
|
|
138
|
-
const
|
|
139
|
-
function
|
|
140
|
-
if (!
|
|
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
|
|
146
|
-
var
|
|
147
|
-
const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1,
|
|
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:
|
|
152
|
+
verbose: r
|
|
153
153
|
}), a = n.androidPackage ?? n.bundleId, t = n.iosBundleId ?? n.bundleId;
|
|
154
|
-
|
|
155
|
-
const d = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), c = [],
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
159
|
-
throw new Error(`Android build file not found: ${
|
|
160
|
-
const
|
|
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
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
`applicationId in ${
|
|
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
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
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
|
-
|
|
175
|
+
A.changed && (S(f.manifest, A.content, o), d.add(f.manifest));
|
|
176
176
|
}
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
throw new Error(`iOS project file not found: ${
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
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 (
|
|
188
|
-
(
|
|
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
|
|
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
|
-
|
|
197
|
+
R.changed && (S(m, R.content, o), d.add(m));
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
for (const
|
|
201
|
-
const
|
|
200
|
+
for (const A of cn) {
|
|
201
|
+
const R = s.join(
|
|
202
202
|
e,
|
|
203
203
|
"android/app/src/main",
|
|
204
|
-
|
|
205
|
-
...
|
|
206
|
-
),
|
|
204
|
+
A,
|
|
205
|
+
...N.split(".")
|
|
206
|
+
), j = s.join(
|
|
207
207
|
e,
|
|
208
208
|
"android/app/src/main",
|
|
209
|
-
|
|
209
|
+
A,
|
|
210
210
|
...a.split(".")
|
|
211
|
-
),
|
|
212
|
-
for (const
|
|
213
|
-
c.push(
|
|
211
|
+
), pn = yn(R, j, o);
|
|
212
|
+
for (const mn of pn)
|
|
213
|
+
c.push(mn);
|
|
214
214
|
}
|
|
215
|
-
const
|
|
216
|
-
for (const
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
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
|
|
220
|
+
const j = _(R, [
|
|
221
221
|
[
|
|
222
|
-
new RegExp(`^package\\s+${
|
|
222
|
+
new RegExp(`^package\\s+${En(N)}$`, "m"),
|
|
223
223
|
`package ${a}`
|
|
224
224
|
]
|
|
225
225
|
]);
|
|
226
|
-
|
|
226
|
+
j.changed && (S(A, j.content, o), d.add(A));
|
|
227
227
|
}
|
|
228
|
-
const
|
|
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 ?
|
|
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
|
|
236
|
+
function xn(n, e) {
|
|
237
237
|
let o = 0;
|
|
238
|
-
const
|
|
238
|
+
const r = n.replace(
|
|
239
239
|
/PRODUCT_BUNDLE_IDENTIFIER = ("[^"\n]*"|[^;\n]+);/g,
|
|
240
|
-
(
|
|
240
|
+
(i, a) => (o += 1, `PRODUCT_BUNDLE_IDENTIFIER = ${a.startsWith('"') ? `"${e}"` : e};`)
|
|
241
241
|
);
|
|
242
|
-
return { content:
|
|
242
|
+
return { content: r, changed: r !== n, matches: o };
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function ln(n) {
|
|
245
245
|
return /\$[({][A-Za-z0-9_:]+[)}]/.test(n);
|
|
246
246
|
}
|
|
247
247
|
function kn(n) {
|
|
248
|
-
const e =
|
|
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
|
|
263
|
-
return
|
|
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
|
|
266
|
-
const o =
|
|
267
|
-
(
|
|
268
|
-
),
|
|
269
|
-
for (const
|
|
270
|
-
|
|
271
|
-
return
|
|
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
|
|
273
|
+
function En(n) {
|
|
274
274
|
return n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
275
275
|
}
|
|
276
|
-
const
|
|
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
|
|
283
|
+
async function On(n) {
|
|
284
284
|
var u;
|
|
285
|
-
const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1,
|
|
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:
|
|
290
|
+
verbose: r
|
|
291
291
|
});
|
|
292
|
-
|
|
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
|
|
295
|
-
const
|
|
296
|
-
|
|
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 ?
|
|
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
|
|
312
|
-
const e = s.resolve(n.rootDir ?? process.cwd()), o = n.dryRun ?? !1,
|
|
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:
|
|
317
|
+
verbose: r
|
|
318
318
|
}), a = n.displayName.trim();
|
|
319
|
-
jn(a),
|
|
320
|
-
const t = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), u = s.join(e, "app.json"), c =
|
|
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
|
|
323
|
+
const v = {
|
|
324
324
|
...JSON.parse(c),
|
|
325
325
|
displayName: a
|
|
326
|
-
},
|
|
326
|
+
}, m = `${JSON.stringify(v, null, 2)}
|
|
327
327
|
`;
|
|
328
|
-
|
|
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
|
|
333
|
-
if (
|
|
334
|
-
const
|
|
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
|
-
],
|
|
340
|
+
], v = g.match(
|
|
341
341
|
/<key>CFBundleName<\/key>\s*<string>([^<]*)<\/string>/
|
|
342
342
|
);
|
|
343
|
-
(!
|
|
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
|
|
349
|
-
|
|
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
|
|
352
|
-
if (
|
|
353
|
-
const
|
|
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
|
-
|
|
356
|
+
$.changed ? (S(N, $.content, o), t.add(N)) : d.add(`No Android app_name changes were needed in ${N}`);
|
|
357
357
|
}
|
|
358
|
-
const
|
|
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 ?
|
|
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
|
|
367
|
-
var
|
|
368
|
-
const e = s.resolve(n.rootDir ?? process.cwd()), o = n.verbose ?? !1,
|
|
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 && ((
|
|
375
|
-
const
|
|
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
|
-
|
|
377
|
+
i.add(`Missing app.json: ${d}`);
|
|
378
378
|
else
|
|
379
379
|
try {
|
|
380
|
-
const
|
|
381
|
-
t.appName =
|
|
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
|
-
|
|
383
|
+
i.add(`Invalid JSON: ${d}`);
|
|
384
384
|
}
|
|
385
|
-
const c = s.join(e, "android/app/build.gradle"),
|
|
386
|
-
if (!
|
|
387
|
-
|
|
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
|
|
390
|
-
t.androidNamespace =
|
|
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
|
|
393
|
-
if (!
|
|
394
|
-
|
|
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
|
|
397
|
-
t.androidAppName =
|
|
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
|
|
400
|
-
|
|
401
|
-
(
|
|
402
|
-
).length === 0 &&
|
|
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
|
|
406
|
-
|
|
407
|
-
return
|
|
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(
|
|
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
|
|
418
|
+
function P(n) {
|
|
419
419
|
return typeof n == "string" && !n.startsWith("$(") && !n.startsWith("${");
|
|
420
420
|
}
|
|
421
|
-
function
|
|
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
|
-
),
|
|
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
|
-
|
|
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
|
-
),
|
|
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
|
|
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
|
-
],
|
|
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
|
-
],
|
|
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
|
|
467
|
-
var
|
|
468
|
-
const e = await se(n.configPath, n.rootDir), o =
|
|
469
|
-
dryRun:
|
|
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
|
-
|
|
476
|
-
o.sourceImage ??
|
|
475
|
+
r,
|
|
476
|
+
o.sourceImage ?? Pn
|
|
477
477
|
), u = W(
|
|
478
|
-
|
|
479
|
-
o.androidDestinationDir ??
|
|
478
|
+
r,
|
|
479
|
+
o.androidDestinationDir ?? Un
|
|
480
480
|
), c = W(
|
|
481
|
-
|
|
482
|
-
o.iosAssetsDir ?? me(
|
|
483
|
-
),
|
|
481
|
+
r,
|
|
482
|
+
o.iosAssetsDir ?? me(r)
|
|
483
|
+
), f = s.join(
|
|
484
484
|
c,
|
|
485
485
|
o.iosIconSetName ?? zn
|
|
486
|
-
),
|
|
487
|
-
a && ((
|
|
488
|
-
const
|
|
489
|
-
ne(
|
|
490
|
-
const
|
|
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:
|
|
494
|
-
roundIconName:
|
|
495
|
-
adaptiveIcon:
|
|
496
|
-
adaptiveIconBackgroundColor:
|
|
497
|
-
adaptiveIconForegroundScale:
|
|
498
|
-
dryRun:
|
|
499
|
-
}),
|
|
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:
|
|
502
|
-
backgroundColor:
|
|
503
|
-
dryRun:
|
|
501
|
+
iconSetDir: f,
|
|
502
|
+
backgroundColor: y,
|
|
503
|
+
dryRun: i
|
|
504
504
|
});
|
|
505
|
-
(await
|
|
506
|
-
`Icon source has transparent pixels; iOS icons were filled with ${
|
|
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
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
const
|
|
512
|
-
changedFiles: Array.from(
|
|
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(
|
|
515
|
-
dryRun:
|
|
514
|
+
warnings: Array.from(m).sort(),
|
|
515
|
+
dryRun: i
|
|
516
516
|
};
|
|
517
|
-
return
|
|
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
|
|
519
|
+
function Zn(n, e) {
|
|
520
520
|
return {
|
|
521
521
|
...n,
|
|
522
522
|
...e
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
|
-
async function
|
|
525
|
+
async function Xn(n) {
|
|
526
526
|
const e = [];
|
|
527
|
-
for (const { dir: o, size:
|
|
528
|
-
const
|
|
529
|
-
n.dryRun || (
|
|
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`,
|
|
533
|
-
for (const { dir: d, size: u } of
|
|
534
|
-
const c = s.join(n.destinationDir, d),
|
|
535
|
-
n.dryRun || (
|
|
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
|
-
|
|
537
|
+
f,
|
|
538
538
|
u,
|
|
539
539
|
n.adaptiveIconForegroundScale
|
|
540
|
-
)), e.push(
|
|
540
|
+
)), e.push(f);
|
|
541
541
|
}
|
|
542
|
-
const
|
|
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 || (
|
|
552
|
-
|
|
553
|
-
ae(
|
|
551
|
+
n.dryRun || (S(
|
|
552
|
+
i,
|
|
553
|
+
ae(r, n.adaptiveIconBackgroundColor),
|
|
554
554
|
!1
|
|
555
|
-
),
|
|
555
|
+
), S(a, Q(r, o), !1), S(
|
|
556
556
|
t,
|
|
557
|
-
|
|
557
|
+
Q(r, o),
|
|
558
558
|
!1
|
|
559
|
-
)), e.push(
|
|
559
|
+
)), e.push(i, a, t);
|
|
560
560
|
}
|
|
561
561
|
return e;
|
|
562
562
|
}
|
|
563
563
|
async function Yn(n) {
|
|
564
|
-
const e = [], o =
|
|
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 || (
|
|
571
|
-
for (const a of
|
|
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
|
|
573
|
+
n.dryRun || await K(n.sourceImage, t, d, n.backgroundColor), e.push(t);
|
|
574
574
|
}
|
|
575
|
-
const
|
|
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 ||
|
|
587
|
-
`, !1), e.push(
|
|
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"),
|
|
591
|
-
return Math.round(o *
|
|
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 (!
|
|
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
|
|
612
|
+
const r = un.map(
|
|
613
613
|
({ dir: a }) => s.join(e, a)
|
|
614
|
-
),
|
|
615
|
-
(a) =>
|
|
614
|
+
), i = [o, ...r].filter(
|
|
615
|
+
(a) => re(n, a)
|
|
616
616
|
);
|
|
617
|
-
if (
|
|
617
|
+
if (i.length > 0)
|
|
618
618
|
throw new Error(
|
|
619
|
-
`Icon source image must be outside generated icon directories: ${
|
|
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
|
|
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
|
|
631
|
-
return
|
|
632
|
-
}
|
|
633
|
-
async function
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
async function te(n, e, o,
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
top: Math.floor((o -
|
|
642
|
-
bottom: Math.ceil((o -
|
|
643
|
-
left: Math.floor((o -
|
|
644
|
-
right: Math.ceil((o -
|
|
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
|
|
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
|
|
672
|
-
return
|
|
671
|
+
const i = le(e);
|
|
672
|
+
return i ? nn(i) : {};
|
|
673
673
|
}
|
|
674
674
|
ce(n);
|
|
675
|
-
const o = de(n, e),
|
|
676
|
-
if (!
|
|
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
|
|
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),
|
|
684
|
-
return
|
|
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
|
-
(
|
|
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
|
|
704
|
-
for (const
|
|
705
|
-
const a = s.join(
|
|
706
|
-
if (
|
|
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
|
|
711
|
+
async function nn(n) {
|
|
712
712
|
const e = s.extname(n).toLowerCase();
|
|
713
713
|
if (e === ".json" || e === "") {
|
|
714
|
-
const
|
|
715
|
-
if (!
|
|
714
|
+
const r = k(n);
|
|
715
|
+
if (!r)
|
|
716
716
|
throw new Error(`Icon config file not found: ${n}`);
|
|
717
|
-
let
|
|
717
|
+
let i;
|
|
718
718
|
try {
|
|
719
|
-
|
|
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
|
|
723
|
+
return en(i, n);
|
|
724
724
|
}
|
|
725
|
-
const o = await import(
|
|
726
|
-
return
|
|
725
|
+
const o = await import(hn(n).href);
|
|
726
|
+
return en(o, n);
|
|
727
727
|
}
|
|
728
|
-
function
|
|
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 (!
|
|
737
|
+
if (!M(n))
|
|
738
738
|
return null;
|
|
739
|
-
const e =
|
|
740
|
-
return fe(e) ?
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
|
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
|
-
},
|
|
906
|
+
}, we = {
|
|
802
907
|
name: "doctor",
|
|
803
908
|
description: "Check common RN project health signals",
|
|
804
909
|
async run(n, e) {
|
|
805
|
-
return
|
|
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
|
-
},
|
|
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
|
|
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
|
|
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
|
|
838
|
-
e.set(
|
|
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(
|
|
844
|
-
return e.get(
|
|
949
|
+
getTask(r) {
|
|
950
|
+
return e.get(r);
|
|
845
951
|
},
|
|
846
|
-
registerTask(
|
|
847
|
-
return e.set(
|
|
952
|
+
registerTask(r) {
|
|
953
|
+
return e.set(r.name, r), o;
|
|
848
954
|
},
|
|
849
|
-
async runTask(
|
|
850
|
-
const t = e.get(
|
|
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 "${
|
|
960
|
+
`Unknown task "${r}". Available tasks: ${d.join(", ") || "(none)"}`
|
|
855
961
|
);
|
|
856
962
|
}
|
|
857
|
-
return t.run(
|
|
963
|
+
return t.run(i, a);
|
|
858
964
|
}
|
|
859
965
|
};
|
|
860
966
|
return o;
|
|
861
967
|
}
|
|
862
|
-
|
|
863
|
-
async function
|
|
864
|
-
const e =
|
|
968
|
+
fn();
|
|
969
|
+
async function Ne(n) {
|
|
970
|
+
const e = De(n);
|
|
865
971
|
if (e.kind === "help")
|
|
866
|
-
return
|
|
867
|
-
const o = e.options.quiet ?? !1,
|
|
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:
|
|
975
|
+
dryRun: i,
|
|
870
976
|
quiet: o,
|
|
871
977
|
scope: e.kind,
|
|
872
|
-
verbose:
|
|
873
|
-
}), d =
|
|
978
|
+
verbose: r
|
|
979
|
+
}), d = fn(), u = {
|
|
874
980
|
rootDir: e.options.rootDir ?? process.cwd(),
|
|
875
981
|
color: a,
|
|
876
|
-
dryRun:
|
|
982
|
+
dryRun: i,
|
|
877
983
|
quiet: o,
|
|
878
|
-
verbose:
|
|
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
|
|
892
|
-
var
|
|
893
|
-
return c.dryRun ? t.info(
|
|
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
|
|
896
|
-
|
|
897
|
-
` ${c.dryRun ? "would change" : "changed"} ${s.relative(u.rootDir,
|
|
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
|
|
900
|
-
|
|
901
|
-
` ${c.dryRun ? "would move" : "moved"} ${s.relative(u.rootDir,
|
|
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
|
|
904
|
-
t.warn(
|
|
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
|
|
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
|
|
916
|
-
return
|
|
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:
|
|
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
|
|
921
|
-
const e = [...n], o = [],
|
|
1028
|
+
function on(n) {
|
|
1029
|
+
const e = [...n], o = [], r = {
|
|
922
1030
|
bundleId: ""
|
|
923
1031
|
};
|
|
924
1032
|
for (; e.length > 0; ) {
|
|
925
|
-
const
|
|
926
|
-
if (
|
|
927
|
-
if (!
|
|
928
|
-
o.push(
|
|
1033
|
+
const i = e.shift();
|
|
1034
|
+
if (i) {
|
|
1035
|
+
if (!i.startsWith("-")) {
|
|
1036
|
+
o.push(i);
|
|
929
1037
|
continue;
|
|
930
1038
|
}
|
|
931
|
-
if (
|
|
932
|
-
|
|
1039
|
+
if (i === "--root") {
|
|
1040
|
+
r.rootDir = b("--root", e);
|
|
933
1041
|
continue;
|
|
934
1042
|
}
|
|
935
|
-
if (
|
|
936
|
-
|
|
1043
|
+
if (i === "--android-package") {
|
|
1044
|
+
r.androidPackage = b("--android-package", e);
|
|
937
1045
|
continue;
|
|
938
1046
|
}
|
|
939
|
-
if (
|
|
940
|
-
|
|
1047
|
+
if (i === "--ios-bundle-id") {
|
|
1048
|
+
r.iosBundleId = b("--ios-bundle-id", e);
|
|
941
1049
|
continue;
|
|
942
1050
|
}
|
|
943
|
-
if (!
|
|
944
|
-
if (
|
|
945
|
-
|
|
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: ${
|
|
1056
|
+
throw new Error(`Unknown flag: ${i}`);
|
|
949
1057
|
}
|
|
950
1058
|
}
|
|
951
1059
|
}
|
|
952
|
-
if (!
|
|
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
|
|
1062
|
+
return r;
|
|
955
1063
|
}
|
|
956
|
-
function
|
|
957
|
-
const e = [...n], o = [],
|
|
1064
|
+
function rn(n) {
|
|
1065
|
+
const e = [...n], o = [], r = {
|
|
958
1066
|
displayName: ""
|
|
959
1067
|
};
|
|
960
1068
|
for (; e.length > 0; ) {
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
963
|
-
if (!
|
|
964
|
-
o.push(
|
|
1069
|
+
const i = e.shift();
|
|
1070
|
+
if (i) {
|
|
1071
|
+
if (!i.startsWith("-")) {
|
|
1072
|
+
o.push(i);
|
|
965
1073
|
continue;
|
|
966
1074
|
}
|
|
967
|
-
if (
|
|
968
|
-
|
|
1075
|
+
if (i === "--root") {
|
|
1076
|
+
r.rootDir = b("--root", e);
|
|
969
1077
|
continue;
|
|
970
1078
|
}
|
|
971
|
-
if (!
|
|
972
|
-
if (
|
|
973
|
-
|
|
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: ${
|
|
1084
|
+
throw new Error(`Unknown flag: ${i}`);
|
|
977
1085
|
}
|
|
978
1086
|
}
|
|
979
1087
|
}
|
|
980
|
-
if (!
|
|
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
|
|
1090
|
+
return r;
|
|
983
1091
|
}
|
|
984
|
-
function
|
|
1092
|
+
function Ae(n) {
|
|
985
1093
|
const e = [...n], o = {};
|
|
986
1094
|
for (; e.length > 0; ) {
|
|
987
|
-
const
|
|
988
|
-
if (
|
|
989
|
-
if (
|
|
990
|
-
o.rootDir =
|
|
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 (!
|
|
994
|
-
throw new Error(`Unknown flag: ${
|
|
1128
|
+
if (!B(r, o))
|
|
1129
|
+
throw new Error(`Unknown flag: ${r}`);
|
|
995
1130
|
}
|
|
996
1131
|
}
|
|
997
1132
|
return o;
|
|
998
1133
|
}
|
|
999
|
-
function
|
|
1134
|
+
function an(n) {
|
|
1000
1135
|
const e = [...n], o = {};
|
|
1001
1136
|
for (; e.length > 0; ) {
|
|
1002
|
-
const
|
|
1003
|
-
if (
|
|
1004
|
-
if (
|
|
1005
|
-
o.rootDir =
|
|
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 (!
|
|
1009
|
-
throw new Error(`Unknown flag: ${
|
|
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
|
|
1149
|
+
function xe(n) {
|
|
1015
1150
|
const e = [...n], o = {};
|
|
1016
1151
|
for (; e.length > 0; ) {
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
if (!
|
|
1020
|
-
o.sourceImage =
|
|
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 (
|
|
1024
|
-
o.rootDir =
|
|
1158
|
+
if (r === "--root") {
|
|
1159
|
+
o.rootDir = b("--root", e);
|
|
1025
1160
|
continue;
|
|
1026
1161
|
}
|
|
1027
|
-
if (
|
|
1028
|
-
o.sourceImage =
|
|
1162
|
+
if (r === "--source") {
|
|
1163
|
+
o.sourceImage = b("--source", e);
|
|
1029
1164
|
continue;
|
|
1030
1165
|
}
|
|
1031
|
-
if (
|
|
1032
|
-
o.configPath =
|
|
1166
|
+
if (r === "--config") {
|
|
1167
|
+
o.configPath = b("--config", e);
|
|
1033
1168
|
continue;
|
|
1034
1169
|
}
|
|
1035
|
-
if (
|
|
1036
|
-
o.androidDestinationDir =
|
|
1170
|
+
if (r === "--android-output") {
|
|
1171
|
+
o.androidDestinationDir = b("--android-output", e);
|
|
1037
1172
|
continue;
|
|
1038
1173
|
}
|
|
1039
|
-
if (
|
|
1174
|
+
if (r === "--android-adaptive-icon") {
|
|
1040
1175
|
o.androidAdaptiveIcon = !0;
|
|
1041
1176
|
continue;
|
|
1042
1177
|
}
|
|
1043
|
-
if (
|
|
1178
|
+
if (r === "--no-android-adaptive-icon") {
|
|
1044
1179
|
o.androidAdaptiveIcon = !1;
|
|
1045
1180
|
continue;
|
|
1046
1181
|
}
|
|
1047
|
-
if (
|
|
1048
|
-
o.androidAdaptiveIconBackgroundColor =
|
|
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 (
|
|
1055
|
-
o.iosIconBackgroundColor =
|
|
1189
|
+
if (r === "--ios-icon-background") {
|
|
1190
|
+
o.iosIconBackgroundColor = b("--ios-icon-background", e);
|
|
1056
1191
|
continue;
|
|
1057
1192
|
}
|
|
1058
|
-
if (
|
|
1193
|
+
if (r === "--android-adaptive-icon-foreground-scale") {
|
|
1059
1194
|
o.androidAdaptiveIconForegroundScale = Number.parseFloat(
|
|
1060
|
-
|
|
1195
|
+
b("--android-adaptive-icon-foreground-scale", e)
|
|
1061
1196
|
);
|
|
1062
1197
|
continue;
|
|
1063
1198
|
}
|
|
1064
|
-
if (
|
|
1065
|
-
o.iosAssetsDir =
|
|
1199
|
+
if (r === "--ios-assets") {
|
|
1200
|
+
o.iosAssetsDir = b("--ios-assets", e);
|
|
1066
1201
|
continue;
|
|
1067
1202
|
}
|
|
1068
|
-
if (
|
|
1069
|
-
o.iosIconSetName =
|
|
1203
|
+
if (r === "--ios-icon-set-name") {
|
|
1204
|
+
o.iosIconSetName = b("--ios-icon-set-name", e);
|
|
1070
1205
|
continue;
|
|
1071
1206
|
}
|
|
1072
|
-
if (
|
|
1073
|
-
o.androidIconName =
|
|
1207
|
+
if (r === "--android-icon-name") {
|
|
1208
|
+
o.androidIconName = b("--android-icon-name", e);
|
|
1074
1209
|
continue;
|
|
1075
1210
|
}
|
|
1076
|
-
if (
|
|
1077
|
-
o.androidRoundIconName =
|
|
1211
|
+
if (r === "--android-round-icon-name") {
|
|
1212
|
+
o.androidRoundIconName = b("--android-round-icon-name", e);
|
|
1078
1213
|
continue;
|
|
1079
1214
|
}
|
|
1080
|
-
if (!
|
|
1081
|
-
throw new Error(`Unknown flag: ${
|
|
1215
|
+
if (!B(r, o))
|
|
1216
|
+
throw new Error(`Unknown flag: ${r}`);
|
|
1082
1217
|
}
|
|
1083
1218
|
}
|
|
1084
1219
|
return o;
|
|
1085
1220
|
}
|
|
1086
|
-
function
|
|
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
|
|
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
|
|
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
|
-
|
|
1288
|
+
Ne(process.argv.slice(2));
|