react-native-update-cli 2.26.2 → 2.27.1
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/lib/account-worker.d.ts +1 -0
- package/lib/account-worker.js +45 -0
- package/lib/account.d.ts +11 -0
- package/lib/account.js +100 -0
- package/lib/bin.js +4 -0
- package/lib/locales/en.d.ts +5 -0
- package/lib/locales/en.js +5 -0
- package/lib/locales/zh.d.ts +5 -0
- package/lib/locales/zh.js +5 -0
- package/lib/user.js +2 -0
- package/lib/utils/hermes-base.js +22 -4
- package/lib/utils/hermes-cached-object.d.ts +3 -0
- package/lib/utils/hermes-cached-object.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const api_1 = require("./api");
|
|
9
|
+
// Isolated from the command: even DNS, endpoint probing and slow sockets cannot
|
|
10
|
+
// keep the CLI alive. Bound the detached worker's lifetime as well.
|
|
11
|
+
if (require.main === module) {
|
|
12
|
+
const deadline = setTimeout(() => process.exit(0), 15000);
|
|
13
|
+
process.once('message', async (input) => {
|
|
14
|
+
try {
|
|
15
|
+
(0, api_1.replaceSession)({ token: input.token });
|
|
16
|
+
if (input.apiToken)
|
|
17
|
+
(0, api_1.setApiToken)(input.apiToken);
|
|
18
|
+
const result = await (0, api_1.get)('/user/me');
|
|
19
|
+
const account = {
|
|
20
|
+
name: result.name,
|
|
21
|
+
email: result.email,
|
|
22
|
+
tier: result.tier,
|
|
23
|
+
tierExpiresAt: result.tierExpiresAt,
|
|
24
|
+
serverTime: result.serverTime,
|
|
25
|
+
};
|
|
26
|
+
const entry = { account, fetchedAt: Date.now() };
|
|
27
|
+
fs_1.default.mkdirSync(path_1.default.dirname(input.cacheFile), {
|
|
28
|
+
recursive: true,
|
|
29
|
+
mode: 0o700,
|
|
30
|
+
});
|
|
31
|
+
const temporary = `${input.cacheFile}.${process.pid}.tmp`;
|
|
32
|
+
fs_1.default.writeFileSync(temporary, JSON.stringify(entry), { mode: 0o600 });
|
|
33
|
+
fs_1.default.renameSync(temporary, input.cacheFile);
|
|
34
|
+
if (process.connected) {
|
|
35
|
+
process.send?.(entry, () => process.exit(0));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Background refresh is best effort; retain the last successful cache.
|
|
41
|
+
}
|
|
42
|
+
clearTimeout(deadline);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
});
|
|
45
|
+
}
|
package/lib/account.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface AccountInfo {
|
|
2
|
+
name?: string;
|
|
3
|
+
email?: string;
|
|
4
|
+
tier?: string;
|
|
5
|
+
tierExpiresAt?: string | null;
|
|
6
|
+
serverTime?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function printAccountInfo(account: AccountInfo, isCresc?: boolean, now?: number): void;
|
|
9
|
+
export declare function accountCacheFile(token: string, apiToken?: string): string;
|
|
10
|
+
/** Cache first; the detached refresh never keeps the command process alive. */
|
|
11
|
+
export declare function showCurrentAccount(): void;
|
package/lib/account.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.printAccountInfo = printAccountInfo;
|
|
7
|
+
exports.accountCacheFile = accountCacheFile;
|
|
8
|
+
exports.showCurrentAccount = showCurrentAccount;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const crypto_1 = require("crypto");
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const os_1 = __importDefault(require("os"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const api_1 = require("./api");
|
|
16
|
+
const constants_1 = require("./utils/constants");
|
|
17
|
+
const i18n_1 = require("./utils/i18n");
|
|
18
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
19
|
+
function printAccountInfo(account, isCresc = constants_1.IS_CRESC, now = Date.now()) {
|
|
20
|
+
const expiresAt = account.tierExpiresAt
|
|
21
|
+
? Date.parse(account.tierExpiresAt)
|
|
22
|
+
: NaN;
|
|
23
|
+
const serverTime = account.serverTime ? Date.parse(account.serverTime) : NaN;
|
|
24
|
+
const remaining = expiresAt - (Number.isFinite(serverTime) ? serverTime : now);
|
|
25
|
+
console.log((0, i18n_1.t)('accountSummary', {
|
|
26
|
+
account: account.email || account.name || (0, i18n_1.t)('accountUnknown'),
|
|
27
|
+
tier: account.tier || (0, i18n_1.t)('accountUnknown'),
|
|
28
|
+
expiry: Number.isFinite(expiresAt)
|
|
29
|
+
? new Date(expiresAt).toISOString()
|
|
30
|
+
: (0, i18n_1.t)('accountNoExpiry'),
|
|
31
|
+
}));
|
|
32
|
+
if (!isCresc &&
|
|
33
|
+
account.tier &&
|
|
34
|
+
account.tier !== 'free' &&
|
|
35
|
+
remaining >= 0 &&
|
|
36
|
+
remaining < 30 * DAY_MS) {
|
|
37
|
+
console.warn(chalk_1.default.yellow.bold((0, i18n_1.t)('accountRenewalWarning', {
|
|
38
|
+
days: Math.ceil(remaining / DAY_MS),
|
|
39
|
+
url: constants_1.pricingPageUrl,
|
|
40
|
+
})));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function accountCacheFile(token, apiToken = '') {
|
|
44
|
+
const key = (0, crypto_1.createHash)('sha256')
|
|
45
|
+
.update(JSON.stringify([constants_1.IS_CRESC, process.cwd(), token, apiToken]))
|
|
46
|
+
.digest('hex');
|
|
47
|
+
return path_1.default.join(os_1.default.homedir(), '.cache', 'react-native-update-cli', 'accounts', `${key}.json`);
|
|
48
|
+
}
|
|
49
|
+
function printCachedAccount(entry) {
|
|
50
|
+
const serverTime = Date.parse(entry.account.serverTime || '');
|
|
51
|
+
// Advance cached server time by elapsed local time, instead of freezing the
|
|
52
|
+
// remaining subscription duration at the moment the cache was written.
|
|
53
|
+
printAccountInfo({
|
|
54
|
+
...entry.account,
|
|
55
|
+
serverTime: Number.isFinite(serverTime)
|
|
56
|
+
? new Date(serverTime + Math.max(0, Date.now() - entry.fetchedAt)).toISOString()
|
|
57
|
+
: undefined,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** Cache first; the detached refresh never keeps the command process alive. */
|
|
61
|
+
function showCurrentAccount() {
|
|
62
|
+
const token = (0, api_1.getSession)()?.token;
|
|
63
|
+
if (!token)
|
|
64
|
+
return;
|
|
65
|
+
const apiToken = (0, api_1.getApiToken)();
|
|
66
|
+
const cacheFile = accountCacheFile(token, apiToken);
|
|
67
|
+
let cached = false;
|
|
68
|
+
try {
|
|
69
|
+
const entry = JSON.parse(fs_1.default.readFileSync(cacheFile, 'utf8'));
|
|
70
|
+
if (entry.account &&
|
|
71
|
+
typeof entry.account === 'object' &&
|
|
72
|
+
Number.isFinite(entry.fetchedAt)) {
|
|
73
|
+
printCachedAccount(entry);
|
|
74
|
+
cached = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Missing or corrupt cache is a cache miss.
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const worker = (0, child_process_1.fork)(path_1.default.join(__dirname, `account-worker${path_1.default.extname(__filename)}`), [], {
|
|
82
|
+
detached: true,
|
|
83
|
+
stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
|
|
84
|
+
execArgv: [],
|
|
85
|
+
});
|
|
86
|
+
worker.on('error', () => { });
|
|
87
|
+
worker.on('message', (entry) => {
|
|
88
|
+
if (!cached) {
|
|
89
|
+
printCachedAccount(entry);
|
|
90
|
+
cached = true;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
worker.send({ token, apiToken, cacheFile }, () => { });
|
|
94
|
+
worker.unref();
|
|
95
|
+
worker.channel?.unref();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Starting a background worker is also best effort.
|
|
99
|
+
}
|
|
100
|
+
}
|
package/lib/bin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const account_1 = require("./account");
|
|
4
5
|
const api_1 = require("./api");
|
|
5
6
|
const commands_1 = require("./commands");
|
|
6
7
|
const utils_1 = require("./utils");
|
|
@@ -74,6 +75,9 @@ async function run() {
|
|
|
74
75
|
if (!handler) {
|
|
75
76
|
throw new Error((0, i18n_1.t)('unknownCommand', { command: argv.command }));
|
|
76
77
|
}
|
|
78
|
+
if (argv.command !== 'me') {
|
|
79
|
+
(0, account_1.showCurrentAccount)();
|
|
80
|
+
}
|
|
77
81
|
await handler(argv);
|
|
78
82
|
// a check still in flight (cold cache) gets a short grace period; the
|
|
79
83
|
// registry request itself is unref'd, so exiting never waits on it
|
package/lib/locales/en.d.ts
CHANGED
package/lib/locales/en.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
|
+
accountSummary: 'Account: {{account}} | Plan: {{tier}} | Expires at: {{expiry}}',
|
|
5
|
+
accountUnknown: 'Unknown',
|
|
6
|
+
accountNoExpiry: 'No expiry specified',
|
|
7
|
+
accountRenewalWarning: '[Notice] Your Pushy paid plan expires in {{days}} days. Renew soon to avoid service disruption: {{url}}',
|
|
8
|
+
accountLookupFailed: '[Warning] Unable to retrieve account information. Continuing with the command.',
|
|
4
9
|
addedToGitignore: 'Added {{line}} to .gitignore',
|
|
5
10
|
androidCrunchPngsWarning: 'The crunchPngs option of android seems not disabled (Please ignore this warning if already disabled), which may cause abnormal consumption of mobile network traffic. Please refer to https://cresc.dev/docs/getting-started#disable-crunchpngs-on-android \n',
|
|
6
11
|
aabOpenApksFailed: 'Failed to open generated .apks file',
|
package/lib/locales/zh.d.ts
CHANGED
package/lib/locales/zh.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
|
+
accountSummary: '当前账号:{{account}} | 等级:{{tier}} | 有效期至:{{expiry}}',
|
|
5
|
+
accountUnknown: '未知',
|
|
6
|
+
accountNoExpiry: '未设置有效期',
|
|
7
|
+
accountRenewalWarning: '[注意] 您的 Pushy 付费套餐将在 {{days}} 天内到期,请及时续费,以免影响服务:{{url}}',
|
|
8
|
+
accountLookupFailed: '[警告] 暂时无法获取账号信息,将继续执行命令。',
|
|
4
9
|
addedToGitignore: '已将 {{line}} 添加到 .gitignore',
|
|
5
10
|
androidCrunchPngsWarning: 'android 的 crunchPngs 选项似乎尚未禁用(如已禁用则请忽略此提示),这可能导致热更包体积异常增大,具体请参考 https://pushy.reactnative.cn/docs/getting-started.html#%E7%A6%81%E7%94%A8-android-%E7%9A%84-crunch-%E4%BC%98%E5%8C%96 \n',
|
|
6
11
|
aabOpenApksFailed: '无法打开生成的 .apks 文件',
|
package/lib/user.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.userCommands = void 0;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const account_1 = require("./account");
|
|
8
9
|
const api_1 = require("./api");
|
|
9
10
|
const utils_1 = require("./utils");
|
|
10
11
|
const add_gitignore_1 = require("./utils/add-gitignore");
|
|
@@ -39,6 +40,7 @@ exports.userCommands = {
|
|
|
39
40
|
},
|
|
40
41
|
me: async () => {
|
|
41
42
|
const me = await (0, api_1.get)('/user/me');
|
|
43
|
+
(0, account_1.printAccountInfo)(me);
|
|
42
44
|
for (const k in me) {
|
|
43
45
|
if (k !== 'ok') {
|
|
44
46
|
console.log(`${k}: ${me[k]}`);
|
package/lib/utils/hermes-base.js
CHANGED
|
@@ -82,6 +82,7 @@ const stream_1 = require("stream");
|
|
|
82
82
|
const promises_1 = require("stream/promises");
|
|
83
83
|
const constants_1 = require("./constants");
|
|
84
84
|
const hbcTransform_1 = require("./hbcTransform");
|
|
85
|
+
const hermes_cached_object_1 = require("./hermes-cached-object");
|
|
85
86
|
const hermes_literals_1 = require("./hermes-literals");
|
|
86
87
|
const hermes_raw_1 = require("./hermes-raw");
|
|
87
88
|
const hermes_timeout_1 = require("./hermes-timeout");
|
|
@@ -898,6 +899,9 @@ function normalizeDisassemblyLine(line, strings, literals) {
|
|
|
898
899
|
if (opcode === 'Offset' && line.startsWith('Offset in debug table', indent)) {
|
|
899
900
|
return null;
|
|
900
901
|
}
|
|
902
|
+
if (opcode === 'CacheNewObject') {
|
|
903
|
+
return (0, hermes_cached_object_1.normalizeCachedObjectInstruction)(line, literals);
|
|
904
|
+
}
|
|
901
905
|
let m;
|
|
902
906
|
if (opcode.startsWith('New') && opcode.includes('WithBuffer')) {
|
|
903
907
|
// v98's AndParent form takes the parent object in a second register,
|
|
@@ -925,12 +929,26 @@ function normalizeDisassemblyLine(line, strings, literals) {
|
|
|
925
929
|
return `${m[1]} ${m[3]}${normalizeOperandSpacing(m[4])}`;
|
|
926
930
|
}
|
|
927
931
|
if (opcode.startsWith('DefineOwnById')) {
|
|
928
|
-
|
|
932
|
+
// BytecodeList.def annotates the string operand of DefineOwnByIdLong but
|
|
933
|
+
// not of DefineOwnById, so one instruction has two pretty renderings: the
|
|
934
|
+
// plain compile keeps small ids and prints the bare id, while a base
|
|
935
|
+
// compile inherits the base's string table, spills past 16 bits, picks the
|
|
936
|
+
// Long form and prints the *text* — cut to hermesc's display budget
|
|
937
|
+
// (`"equivalenceCheckP"...` for `equivalenceCheckPropertyName`). Neither side can
|
|
938
|
+
// be turned into the other: that budget also drops non-ASCII silently and
|
|
939
|
+
// without a marker (`ab\u4e2d` prints as `"ab"`), so a resolved name never
|
|
940
|
+
// equals a printed one. The operand is folded away here and the property
|
|
941
|
+
// name is compared by the raw audit, which decodes it from the string
|
|
942
|
+
// table in full (STRING_OPERANDS supplies the missing annotation).
|
|
943
|
+
m = /^(\s*DefineOwnById\w*\s+r\d+, r\d+, \d+, )(\d+)?.*$/.exec(line);
|
|
929
944
|
if (m) {
|
|
930
|
-
|
|
931
|
-
|
|
945
|
+
// An id form whose id is not in the table means the string table was
|
|
946
|
+
// not read at all; that still fails closed rather than folding an
|
|
947
|
+
// operand nothing could resolve.
|
|
948
|
+
if (m[2] !== undefined && !strings.has(Number(m[2]))) {
|
|
932
949
|
throw new Error(`unresolved string id ${m[2]}`);
|
|
933
|
-
|
|
950
|
+
}
|
|
951
|
+
line = `${m[1]}<str>`;
|
|
934
952
|
}
|
|
935
953
|
}
|
|
936
954
|
// Operand-width variants of one instruction (GetByIdShort/GetById/GetByIdLong,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeCachedObjectInstruction = normalizeCachedObjectInstruction;
|
|
4
|
+
/** Normalize the shape reference, not the registers or the per-function cache. */
|
|
5
|
+
function normalizeCachedObjectInstruction(line, literals) {
|
|
6
|
+
const m = /^(\s*)CacheNewObject\s+(r\d+),\s*(r\d+),\s*(\d+),\s*(\d+)\s*$/.exec(line);
|
|
7
|
+
if (!m)
|
|
8
|
+
throw new Error(`unsupported cached object operands: ${line.trim()}`);
|
|
9
|
+
const prefix = `${m[1]}CacheNewObject ${m[2]}, ${m[3]}, `;
|
|
10
|
+
// Diagnostic-only fallback: compareHermesBytecode still requires readable
|
|
11
|
+
// binary data and a successful raw audit before returning equivalent.
|
|
12
|
+
if (!literals)
|
|
13
|
+
return `${prefix}<shape>, ${m[5]}`;
|
|
14
|
+
const shape = literals.shape(Number(m[4]));
|
|
15
|
+
const keys = shape && literals.objectKeys(shape.keyOffset, shape.count);
|
|
16
|
+
if (!shape || !keys) {
|
|
17
|
+
throw new Error(`undecodable cached object shape ${m[4]}`);
|
|
18
|
+
}
|
|
19
|
+
// JSON preserves key order, complete string contents and significant spaces.
|
|
20
|
+
return `${prefix}keys=${JSON.stringify(keys)}, ${m[5]}`;
|
|
21
|
+
}
|
package/package.json
CHANGED