@heybox/hb-sdk 0.9.2-alpha.6 → 0.9.2-alpha.8
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/CHANGELOG.md +22 -0
- package/README.md +4 -2
- package/dist/cli-chunks/{build-ffQNXsFk.cjs → build-BinntZJf.cjs} +5 -5
- package/dist/cli-chunks/{context-DlFt5Q7p.cjs → context-BI3QMxw2.cjs} +2 -2
- package/dist/cli-chunks/{create-BtmA7deR.cjs → create-BK028Mlk.cjs} +1 -1
- package/dist/cli-chunks/deploy-lock-pKDDxTKm.cjs +148 -0
- package/dist/cli-chunks/{dev-CNDIlDmL.cjs → dev-DeNzUY6g.cjs} +75 -66
- package/dist/cli-chunks/{doctor-BkFUZH17.cjs → doctor-BOfbKnN2.cjs} +1 -1
- package/dist/cli-chunks/games-yqu20laX.cjs +140 -0
- package/dist/cli-chunks/{index-DrlSotEe.cjs → index-C7nrP0tt.cjs} +1 -1
- package/dist/cli-chunks/{index-CN_l895H.cjs → index-CY67PpQk.cjs} +35 -16
- package/dist/cli-chunks/{index.esm-mmJekGrr.cjs → index.esm-DQdwzMhB.cjs} +6 -6
- package/dist/cli-chunks/{login-qupR7tLT.cjs → login-PJdMmFoB.cjs} +1 -1
- package/dist/cli-chunks/{project-vite-CNubrzp5.cjs → project-vite-Dm128JTE.cjs} +1 -1
- package/dist/cli-chunks/{remote-CbZlAq6Z.cjs → remote-CZuy1lmn.cjs} +33 -146
- package/dist/cli-chunks/{runtime-gate-BcKHky95.cjs → runtime-gate-g3afiufR.cjs} +2 -2
- package/dist/cli-chunks/{runtime-permission-env-BQ7lPfhg.cjs → runtime-permission-env-CDx5qO-T.cjs} +2 -2
- package/dist/cli-chunks/{skill-KmRvlkMJ.cjs → skill-Bdy5Ehue.cjs} +2 -2
- package/dist/cli-chunks/{version-ai8lcNbJ.cjs → version-D40WHkF9.cjs} +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/devtools/browser-dev-host/assets/{browser-dev-host-DIkT9EVT.js → browser-dev-host-BW7iWnpt.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{desktop-app-launch-CXLBQXPW.js → desktop-app-launch-lmlBUG16.js} +1 -1
- package/dist/devtools/browser-dev-host/assets/{index-Dn9OFySi.js → index-D7F2y1lF.js} +3 -3
- package/dist/devtools/browser-dev-host/index.html +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/miniapp-publish.cjs.js +22 -0
- package/dist/miniapp-publish.esm.js +22 -1
- package/dist/templates/vanilla-vite-js/README.md.ejs +4 -0
- package/dist/vite.cjs.js +46 -3
- package/dist/vite.esm.js +46 -3
- package/docs/runtime-host-migration.md +1 -1
- package/package.json +6 -6
- package/skill/SKILL.md +9 -0
- package/skill/skill.json +5 -5
- package/types/miniapp-publish/index.d.ts +15 -2
- package/types/vite/index.d.ts +7 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node_crypto = require('node:crypto');
|
|
4
|
+
var fs = require('node:fs/promises');
|
|
5
|
+
var path = require('node:path');
|
|
6
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
7
|
+
var deployLock = require('./deploy-lock-pKDDxTKm.cjs');
|
|
8
|
+
require('node:module');
|
|
9
|
+
require('readline');
|
|
10
|
+
require('os');
|
|
11
|
+
require('tty');
|
|
12
|
+
require('assert');
|
|
13
|
+
require('events');
|
|
14
|
+
require('stream');
|
|
15
|
+
require('buffer');
|
|
16
|
+
require('util');
|
|
17
|
+
require('path');
|
|
18
|
+
require('fs');
|
|
19
|
+
require('constants');
|
|
20
|
+
require('node:fs');
|
|
21
|
+
require('node:zlib');
|
|
22
|
+
|
|
23
|
+
const WINDOW_MS = 30 * 60 * 1000;
|
|
24
|
+
const MAX_REQUESTS = 50;
|
|
25
|
+
const INTERVAL_MS = 1000;
|
|
26
|
+
/** 仅限制当前设备 CLI 的出站搜索,账号隔离并跨进程、跨项目持久保存。 */
|
|
27
|
+
async function reserveGameSearchRequest(account, apiBaseUrl, options = {}) {
|
|
28
|
+
const cacheRoot = options.cacheRoot ?? index.envPaths('hb-sdk', { suffix: '' }).cache;
|
|
29
|
+
const scope = node_crypto.createHash('sha256').update(`${apiBaseUrl}\0${account}`).digest('hex');
|
|
30
|
+
let lock;
|
|
31
|
+
try {
|
|
32
|
+
lock = await deployLock.acquireDeployLock({ apiBaseUrl, miniProgramId: `game-search:${scope}`, version: 'rate-limit-v1' }, { cacheRoot });
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof Error && error.message === deployLock.DEPLOY_LOCKED_MESSAGE) {
|
|
36
|
+
throw new Error('游戏搜索请求正在处理中,请稍后重试');
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
const directory = path.join(cacheRoot, 'game-search-limits');
|
|
41
|
+
const file = path.join(directory, `${scope}.json`);
|
|
42
|
+
const temp = `${file}.${node_crypto.randomUUID()}.tmp`;
|
|
43
|
+
try {
|
|
44
|
+
const now = (options.now ?? Date.now)();
|
|
45
|
+
let timestamps = [];
|
|
46
|
+
try {
|
|
47
|
+
const raw = await fs.readFile(file, 'utf8');
|
|
48
|
+
let stored;
|
|
49
|
+
try {
|
|
50
|
+
stored = JSON.parse(raw);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (!(error instanceof SyntaxError))
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(stored) && stored.length <= MAX_REQUESTS && stored.every((value) => Number.isSafeInteger(value) && value >= 0)) {
|
|
57
|
+
timestamps = stored.filter((value) => value > now - WINDOW_MS).sort((a, b) => a - b);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// 在账号锁内清除损坏的辅助缓存,本次按新记录继续,避免永久阻断搜索。
|
|
61
|
+
await fs.rm(file, { force: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error.code !== 'ENOENT')
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
const last = timestamps.at(-1);
|
|
69
|
+
const intervalWait = last === undefined ? 0 : last + INTERVAL_MS - now;
|
|
70
|
+
const windowWait = timestamps.length < MAX_REQUESTS ? 0 : timestamps[0] + WINDOW_MS - now;
|
|
71
|
+
const wait = Math.max(intervalWait, windowWait);
|
|
72
|
+
if (wait > 0) {
|
|
73
|
+
throw new Error(`游戏搜索过于频繁,请 ${Math.ceil(wait / 1000)} 秒后重试`);
|
|
74
|
+
}
|
|
75
|
+
timestamps.push(now);
|
|
76
|
+
await fs.mkdir(directory, { recursive: true, mode: 0o700 });
|
|
77
|
+
await fs.writeFile(temp, JSON.stringify(timestamps), { mode: 0o600, flag: 'wx' });
|
|
78
|
+
await fs.rename(temp, file);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
await fs.rm(temp, { force: true }).finally(() => lock.release());
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const GAME_SEARCH_API_PATH = '/bbs/app/topic/search_game';
|
|
86
|
+
/** 查询平台游戏候选,不依赖项目绑定,也不写入本地配置或远端状态。 */
|
|
87
|
+
async function runGameSearchCommand(query, options = {}, runtime = {}) {
|
|
88
|
+
const q = query.trim();
|
|
89
|
+
if (!q || Array.from(q).length > 100)
|
|
90
|
+
throw new Error('游戏搜索关键词须为 1–100 个字符');
|
|
91
|
+
const offset = parsePagination(options.offset ?? '0', 'offset', 0, 10_000);
|
|
92
|
+
const limit = parsePagination(options.limit ?? '10', 'limit', 1, 20);
|
|
93
|
+
const session = runtime.session ?? (await (runtime.requireAuthSession ?? index.requireHeyboxAuthSession)());
|
|
94
|
+
const context = index.createHeyboxOpenPlatformRequestContext(session, GAME_SEARCH_API_PATH);
|
|
95
|
+
await reserveGameSearchRequest(session.heyboxId, context.baseUrl, runtime.rateLimit);
|
|
96
|
+
const response = await (runtime.fetchImpl ?? fetch)(index.createHeyboxApiUrl(context.baseUrl, GAME_SEARCH_API_PATH, { ...context.platformParams, q, offset, limit: limit + 1 }), { headers: context.headers, redirect: 'error', signal: AbortSignal.timeout(15_000) });
|
|
97
|
+
const result = await index.readHeyboxApiEnvelope(response, { pathWithQuery: GAME_SEARCH_API_PATH, requireResult: true });
|
|
98
|
+
if (!Array.isArray(result?.games))
|
|
99
|
+
throw new Error('游戏搜索返回格式异常:缺少 games 数组');
|
|
100
|
+
const games = result.games.slice(0, limit).map(normalizeGame);
|
|
101
|
+
const output = {
|
|
102
|
+
games,
|
|
103
|
+
has_more: result.games.length > limit,
|
|
104
|
+
next_offset: offset + games.length,
|
|
105
|
+
};
|
|
106
|
+
const message = options.json
|
|
107
|
+
? JSON.stringify(output, null, 2)
|
|
108
|
+
: [
|
|
109
|
+
...(games.length ? games.map((game) => `${game.appid}\t${game.name}${game.name_en ? `(${game.name_en})` : ''}`) : ['未找到匹配游戏,请尝试中文名或英文名。']),
|
|
110
|
+
'搜索结果为游戏候选,请核对具体游戏及平台;能否绑定以部署预检为准。',
|
|
111
|
+
...(output.has_more ? [`更多结果:--offset ${output.next_offset} --limit ${limit}`] : []),
|
|
112
|
+
].join('\n');
|
|
113
|
+
(runtime.write ?? ((text) => process.stdout.write(`${text}\n`)))(message);
|
|
114
|
+
return output;
|
|
115
|
+
}
|
|
116
|
+
function parsePagination(value, name, min, max) {
|
|
117
|
+
if (!/^(0|[1-9]\d*)$/.test(value))
|
|
118
|
+
throw new Error(`--${name} 必须为 ${min}–${max} 的整数`);
|
|
119
|
+
const parsed = Number(value);
|
|
120
|
+
if (!Number.isSafeInteger(parsed) || parsed < min || parsed > max)
|
|
121
|
+
throw new Error(`--${name} 必须为 ${min}–${max} 的整数`);
|
|
122
|
+
return parsed;
|
|
123
|
+
}
|
|
124
|
+
function normalizeGame(value) {
|
|
125
|
+
if (!value || typeof value !== 'object')
|
|
126
|
+
throw new Error('游戏搜索返回格式异常');
|
|
127
|
+
const game = value;
|
|
128
|
+
const appid = typeof game.appid === 'number' || typeof game.appid === 'string' ? String(game.appid) : '';
|
|
129
|
+
if (!/^[1-9]\d*$/.test(appid) ||
|
|
130
|
+
!Number.isSafeInteger(Number(appid)) ||
|
|
131
|
+
Number(appid) > 2_147_483_647 ||
|
|
132
|
+
typeof game.name !== 'string' ||
|
|
133
|
+
!game.name.trim()) {
|
|
134
|
+
throw new Error('游戏搜索返回无效 appid 或名称');
|
|
135
|
+
}
|
|
136
|
+
const icon = typeof game.vertical_image === 'string' && game.vertical_image ? game.vertical_image : game.image;
|
|
137
|
+
return { appid, name: game.name, ...(typeof game.name_en === 'string' && game.name_en.trim() ? { name_en: game.name_en } : {}), ...(typeof icon === 'string' && icon ? { icon_url: icon } : {}) };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
exports.runGameSearchCommand = runGameSearchCommand;
|
|
@@ -238,19 +238,19 @@ function requireArgument () {
|
|
|
238
238
|
|
|
239
239
|
var command = {};
|
|
240
240
|
|
|
241
|
-
const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
241
|
+
const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CY67PpQk.cjs', document.baseURI).href)));
|
|
242
242
|
function __require$4() { return require$5("node:events"); }
|
|
243
243
|
|
|
244
|
-
const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
244
|
+
const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CY67PpQk.cjs', document.baseURI).href)));
|
|
245
245
|
function __require$3() { return require$4("node:child_process"); }
|
|
246
246
|
|
|
247
|
-
const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
247
|
+
const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CY67PpQk.cjs', document.baseURI).href)));
|
|
248
248
|
function __require$2() { return require$3("node:path"); }
|
|
249
249
|
|
|
250
|
-
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
250
|
+
const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CY67PpQk.cjs', document.baseURI).href)));
|
|
251
251
|
function __require$1() { return require$2("node:fs"); }
|
|
252
252
|
|
|
253
|
-
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-
|
|
253
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CY67PpQk.cjs', document.baseURI).href)));
|
|
254
254
|
function __require() { return require$1("node:process"); }
|
|
255
255
|
|
|
256
256
|
var help = {};
|
|
@@ -17249,7 +17249,7 @@ async function inspectFeedbackLog(file, size) {
|
|
|
17249
17249
|
return { mimeType: 'text/plain', width: 0, height: 0 };
|
|
17250
17250
|
}
|
|
17251
17251
|
async function createFeedbackCosClient(getToken) {
|
|
17252
|
-
const { default: COS } = await Promise.resolve().then(function () { return require('./index-
|
|
17252
|
+
const { default: COS } = await Promise.resolve().then(function () { return require('./index-C7nrP0tt.cjs'); }).then(function (n) { return n.index; });
|
|
17253
17253
|
const cos = new COS({
|
|
17254
17254
|
getAuthorization(_options, callback) {
|
|
17255
17255
|
void getToken().then((token) => callback({
|
|
@@ -20900,7 +20900,7 @@ function readEnvNameArgFromArgv(argv) {
|
|
|
20900
20900
|
}
|
|
20901
20901
|
|
|
20902
20902
|
const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
|
|
20903
|
-
const BUILT_CLI_VERSION = '0.9.2-alpha.
|
|
20903
|
+
const BUILT_CLI_VERSION = '0.9.2-alpha.8';
|
|
20904
20904
|
const PACKAGE_JSON_CANDIDATES = [
|
|
20905
20905
|
path.resolve(__dirname, '..', '..', 'package.json'),
|
|
20906
20906
|
path.resolve(__dirname, '..', 'package.json'),
|
|
@@ -20966,6 +20966,7 @@ function createCliProgram(overrides = {}) {
|
|
|
20966
20966
|
runDevCommand: defaultRunDevCommand,
|
|
20967
20967
|
runDoctorCommand: defaultRunDoctorCommand,
|
|
20968
20968
|
runRemoteCommand: defaultRunRemoteCommand,
|
|
20969
|
+
runGameSearchCommand: defaultRunGameSearchCommand,
|
|
20969
20970
|
runSkillInstallCommand: defaultRunSkillInstallCommand,
|
|
20970
20971
|
...overrides,
|
|
20971
20972
|
};
|
|
@@ -21070,6 +21071,20 @@ function addRemotePublicOptions(command) {
|
|
|
21070
21071
|
}
|
|
21071
21072
|
function installRemoteCommands(program, handlers, resolveLogger) {
|
|
21072
21073
|
const remote = addRemotePublicOptions(program.command('remote').description('管理当前项目绑定的远程 Heybox 工坊小程序'));
|
|
21074
|
+
const games = addVerboseOption(remote.command('games').description('查询平台游戏信息'));
|
|
21075
|
+
addVerboseOption(games.command('search').description('按名称查找游戏 appid,不修改绑定')
|
|
21076
|
+
.argument('<query>', '中文或英文游戏名')
|
|
21077
|
+
.option('--offset <offset>', '结果偏移量,0–10000', '0')
|
|
21078
|
+
.option('--limit <limit>', '每页数量,1–20', '10')
|
|
21079
|
+
.option('--json', '输出 JSON'))
|
|
21080
|
+
.action(async (query, _options, command) => {
|
|
21081
|
+
const options = readCommandOptionsWithAncestors(command);
|
|
21082
|
+
await handlers.runGameSearchCommand(query, {
|
|
21083
|
+
offset: readStringOption(options.offset),
|
|
21084
|
+
limit: readStringOption(options.limit),
|
|
21085
|
+
json: Boolean(options.json),
|
|
21086
|
+
});
|
|
21087
|
+
});
|
|
21073
21088
|
addRemotePublicOptions(remote.command('access').description('查看当前账号的小程序工坊访问权限')).action(createRemoteAction(handlers, resolveLogger, 'access'));
|
|
21074
21089
|
const entity = addRemotePublicOptions(remote.command('entity').description('查看和切换当前开发者主体'));
|
|
21075
21090
|
addRemotePublicOptions(entity.command('list').description('列出当前账号可切换的开发者主体')).action(createRemoteAction(handlers, resolveLogger, 'entity:list'));
|
|
@@ -21269,39 +21284,39 @@ function createCommandLoggerResolver(options) {
|
|
|
21269
21284
|
};
|
|
21270
21285
|
}
|
|
21271
21286
|
const defaultClearLoginStatus = async (...args) => {
|
|
21272
|
-
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
21287
|
+
const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-PJdMmFoB.cjs'); });
|
|
21273
21288
|
return clearLoginStatus(...args);
|
|
21274
21289
|
};
|
|
21275
21290
|
const defaultLoginToHeybox = async (...args) => {
|
|
21276
|
-
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-
|
|
21291
|
+
const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-PJdMmFoB.cjs'); });
|
|
21277
21292
|
return loginToHeybox(...args);
|
|
21278
21293
|
};
|
|
21279
21294
|
const defaultPrintLoginStatus = async (...args) => {
|
|
21280
|
-
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-
|
|
21295
|
+
const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-PJdMmFoB.cjs'); });
|
|
21281
21296
|
return printLoginStatus(...args);
|
|
21282
21297
|
};
|
|
21283
21298
|
const defaultRunBuildCommand = async (...args) => {
|
|
21284
|
-
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-
|
|
21299
|
+
const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-BinntZJf.cjs'); });
|
|
21285
21300
|
return runBuildCommand(...args);
|
|
21286
21301
|
};
|
|
21287
21302
|
const defaultRunCreateCommand = async (...args) => {
|
|
21288
|
-
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-
|
|
21303
|
+
const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-BK028Mlk.cjs'); });
|
|
21289
21304
|
return runCreateCommand(...args);
|
|
21290
21305
|
};
|
|
21291
21306
|
const defaultRunDevCommand = async (...args) => {
|
|
21292
|
-
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-
|
|
21307
|
+
const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-DeNzUY6g.cjs'); }).then(function (n) { return n.dev; });
|
|
21293
21308
|
return runDevCommand(...args);
|
|
21294
21309
|
};
|
|
21295
21310
|
const defaultRunDoctorCommand = async (...args) => {
|
|
21296
|
-
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-
|
|
21311
|
+
const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-BOfbKnN2.cjs'); });
|
|
21297
21312
|
return runDoctorCommand(...args);
|
|
21298
21313
|
};
|
|
21299
21314
|
const defaultRunSkillInstallCommand = async (...args) => {
|
|
21300
|
-
const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-
|
|
21315
|
+
const { runSkillInstallCommand } = await Promise.resolve().then(function () { return require('./skill-Bdy5Ehue.cjs'); });
|
|
21301
21316
|
return runSkillInstallCommand(...args);
|
|
21302
21317
|
};
|
|
21303
21318
|
const defaultRunRemoteCommand = async (...args) => {
|
|
21304
|
-
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-
|
|
21319
|
+
const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-CZuy1lmn.cjs'); });
|
|
21305
21320
|
return runRemoteCommand(...args);
|
|
21306
21321
|
};
|
|
21307
21322
|
function resolveStandaloneLogger(options, verbose) {
|
|
@@ -21392,6 +21407,10 @@ function parseNonNegativeInteger(value) {
|
|
|
21392
21407
|
}
|
|
21393
21408
|
return parsed;
|
|
21394
21409
|
}
|
|
21410
|
+
const defaultRunGameSearchCommand = async (...args) => {
|
|
21411
|
+
const { runGameSearchCommand } = await Promise.resolve().then(function () { return require('./games-yqu20laX.cjs'); });
|
|
21412
|
+
return runGameSearchCommand(...args);
|
|
21413
|
+
};
|
|
21395
21414
|
|
|
21396
21415
|
exports.CliError = CliError;
|
|
21397
21416
|
exports.HB_SDK_PACKAGE_NAME = HB_SDK_PACKAGE_NAME;
|
|
@@ -11,8 +11,8 @@ var require$$0$3 = require('url');
|
|
|
11
11
|
var require$$5 = require('zlib');
|
|
12
12
|
var require$$0 = require('buffer');
|
|
13
13
|
var require$$1 = require('util');
|
|
14
|
-
var index = require('./index-
|
|
15
|
-
var dev = require('./dev-
|
|
14
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
15
|
+
var dev = require('./dev-DeNzUY6g.cjs');
|
|
16
16
|
require('node:module');
|
|
17
17
|
require('readline');
|
|
18
18
|
require('os');
|
|
@@ -26,9 +26,9 @@ require('constants');
|
|
|
26
26
|
require('node:fs');
|
|
27
27
|
require('node:fs/promises');
|
|
28
28
|
require('node:zlib');
|
|
29
|
-
require('./context-
|
|
30
|
-
require('./runtime-permission-env-
|
|
31
|
-
require('./version-
|
|
29
|
+
require('./context-BI3QMxw2.cjs');
|
|
30
|
+
require('./runtime-permission-env-CDx5qO-T.cjs');
|
|
31
|
+
require('./version-D40WHkF9.cjs');
|
|
32
32
|
require('node:async_hooks');
|
|
33
33
|
require('sharp');
|
|
34
34
|
require('node:os');
|
|
@@ -42,7 +42,7 @@ require('node:buffer');
|
|
|
42
42
|
require('node:url');
|
|
43
43
|
require('node:util');
|
|
44
44
|
require('node:child_process');
|
|
45
|
-
require('./project-vite-
|
|
45
|
+
require('./project-vite-Dm128JTE.cjs');
|
|
46
46
|
|
|
47
47
|
var bufferUtil = {exports: {}};
|
|
48
48
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var promises = require('node:readline/promises');
|
|
4
4
|
var node_crypto = require('node:crypto');
|
|
5
5
|
var node_http = require('node:http');
|
|
6
|
-
var index = require('./index-
|
|
6
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
7
7
|
var browser = require('./browser-RAy8e8cV.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('readline');
|
|
@@ -5,7 +5,7 @@ var fs$1 = require('node:fs/promises');
|
|
|
5
5
|
var node_module = require('node:module');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var node_url = require('node:url');
|
|
8
|
-
var index = require('./index-
|
|
8
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
9
9
|
|
|
10
10
|
function findProjectRoot(startDir) {
|
|
11
11
|
let current = path.resolve(startDir);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
4
|
-
var context = require('./context-
|
|
3
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CDx5qO-T.cjs');
|
|
4
|
+
var context = require('./context-BI3QMxw2.cjs');
|
|
5
5
|
var promises = require('node:readline/promises');
|
|
6
|
-
var index = require('./index-
|
|
7
|
-
var runtimeGate = require('./runtime-gate-
|
|
6
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
7
|
+
var runtimeGate = require('./runtime-gate-g3afiufR.cjs');
|
|
8
8
|
var childProcess = require('node:child_process');
|
|
9
9
|
var fs = require('node:fs');
|
|
10
10
|
var fs$1 = require('node:fs/promises');
|
|
11
11
|
var path = require('node:path');
|
|
12
12
|
var node_crypto = require('node:crypto');
|
|
13
13
|
require('node:zlib');
|
|
14
|
-
require('./
|
|
14
|
+
var deployLock = require('./deploy-lock-pKDDxTKm.cjs');
|
|
15
|
+
require('./version-D40WHkF9.cjs');
|
|
15
16
|
require('node:async_hooks');
|
|
16
17
|
require('sharp');
|
|
17
18
|
require('node:module');
|
|
@@ -33,6 +34,27 @@ require('inspector');
|
|
|
33
34
|
// 脚手架开发占位图;构建可用,提审前必须替换。
|
|
34
35
|
const BASIC_INFO_PLACEHOLDER_SHA256 = 'd14e54b30f5e6d1bcbf51267bc82b06a0af7c333f2945bcc16b4e1adc3b123dd';
|
|
35
36
|
|
|
37
|
+
/** 根据当前项目声明或实际版本 Manifest 检查资料完整性,不联网、不修改输入。 */
|
|
38
|
+
function getMiniappMetadataWarnings(metadata) {
|
|
39
|
+
const warnings = [];
|
|
40
|
+
if (metadata.desc === undefined || (typeof metadata.desc === 'string' && !metadata.desc.trim())) {
|
|
41
|
+
warnings.push({
|
|
42
|
+
code: 'MINIAPP_DESC_MISSING',
|
|
43
|
+
field: 'desc',
|
|
44
|
+
message: '尚未填写小程序简介。建议在 package.json#heybox.desc 中说明主要功能和适用场景,修改后重新构建。',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (metadata.category === 'tool' &&
|
|
48
|
+
(metadata.bindAppIds === undefined || (Array.isArray(metadata.bindAppIds) && metadata.bindAppIds.length === 0))) {
|
|
49
|
+
warnings.push({
|
|
50
|
+
code: 'MINIAPP_TOOL_GAME_BINDING_MISSING',
|
|
51
|
+
field: 'bindAppIds',
|
|
52
|
+
message: '当前小程序为工具类,尚未关联游戏。如服务于特定 PC 游戏,可通过 hb-sdk remote games search "游戏名" 查询 appid 并填写 package.json#heybox.bindAppIds,修改后重新构建;通用工具可保持为空。',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return warnings;
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
const CREATE_USER_MINIPROGRAM_UPLOAD_SESSION_API_PATH = '/mall/developer/user_miniprogram/version/upload_session/create';
|
|
37
59
|
const RECORD_USER_MINIPROGRAM_UPLOAD_RESULT_API_PATH = '/mall/developer/user_miniprogram/version/upload_session/record';
|
|
38
60
|
const COMPANION_FINALIZATION_TIMEOUT_MS = 30 * 60_000;
|
|
@@ -286,7 +308,7 @@ function createDefaultCosClient(uploadToken, COS) {
|
|
|
286
308
|
};
|
|
287
309
|
}
|
|
288
310
|
async function loadCosConstructor() {
|
|
289
|
-
const cosModule = await Promise.resolve().then(function () { return require('./index-
|
|
311
|
+
const cosModule = await Promise.resolve().then(function () { return require('./index-C7nrP0tt.cjs'); }).then(function (n) { return n.index; });
|
|
290
312
|
return cosModule.default;
|
|
291
313
|
}
|
|
292
314
|
function formatSize(bytes) {
|
|
@@ -353,144 +375,6 @@ async function computeMiniappArtifactReceipt(files, runtime = {}) {
|
|
|
353
375
|
return { artifactSignature: hash.digest('hex'), files: preparedFiles };
|
|
354
376
|
}
|
|
355
377
|
|
|
356
|
-
const DEPLOY_LOCKED_MESSAGE = '当前设备已有同版本产物正在上传,请等待完成后重试';
|
|
357
|
-
const DEPLOY_LOCK_DIRECTORY_NAME = 'deploy-locks';
|
|
358
|
-
const DEPLOY_LOCK_OWNER_FILE = 'owner.json';
|
|
359
|
-
const INCOMPLETE_LOCK_GRACE_MS = 30_000;
|
|
360
|
-
const defaultPaths = index.envPaths('hb-sdk', { suffix: '' });
|
|
361
|
-
class DeployLockConflictError extends Error {
|
|
362
|
-
}
|
|
363
|
-
async function withDeployLock(scope, operation, options = {}) {
|
|
364
|
-
let lock;
|
|
365
|
-
try {
|
|
366
|
-
lock = await acquireDeployLock(scope, options);
|
|
367
|
-
}
|
|
368
|
-
catch (error) {
|
|
369
|
-
if (error instanceof DeployLockConflictError) {
|
|
370
|
-
throw error;
|
|
371
|
-
}
|
|
372
|
-
// 本地文件锁只减少重复操作,文件系统异常不阻断服务端上传流程。
|
|
373
|
-
return operation();
|
|
374
|
-
}
|
|
375
|
-
try {
|
|
376
|
-
return await operation();
|
|
377
|
-
}
|
|
378
|
-
finally {
|
|
379
|
-
await lock.release().catch(() => undefined);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
async function acquireDeployLock(scope, options = {}) {
|
|
383
|
-
const lockDirectory = getDeployLockDirectory(scope, options.cacheRoot);
|
|
384
|
-
const ownerFile = path.join(lockDirectory, DEPLOY_LOCK_OWNER_FILE);
|
|
385
|
-
const owner = {
|
|
386
|
-
version: 1,
|
|
387
|
-
pid: options.pid ?? process.pid,
|
|
388
|
-
token: options.token ?? node_crypto.randomBytes(16).toString('hex'),
|
|
389
|
-
};
|
|
390
|
-
await fs$1.mkdir(path.dirname(lockDirectory), { recursive: true, mode: 0o700 });
|
|
391
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
392
|
-
let created = false;
|
|
393
|
-
try {
|
|
394
|
-
await fs$1.mkdir(lockDirectory, { mode: 0o700 });
|
|
395
|
-
created = true;
|
|
396
|
-
await fs$1.writeFile(ownerFile, `${JSON.stringify(owner)}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
397
|
-
return createDeployLock(lockDirectory, ownerFile, owner.token);
|
|
398
|
-
}
|
|
399
|
-
catch (error) {
|
|
400
|
-
if (created) {
|
|
401
|
-
await fs$1.rm(lockDirectory, { force: true, recursive: true });
|
|
402
|
-
throw error;
|
|
403
|
-
}
|
|
404
|
-
if (!isNodeError(error) || error.code !== 'EEXIST') {
|
|
405
|
-
throw error;
|
|
406
|
-
}
|
|
407
|
-
if (!(await canReclaimDeployLock(lockDirectory, ownerFile, options))) {
|
|
408
|
-
throw new DeployLockConflictError(DEPLOY_LOCKED_MESSAGE);
|
|
409
|
-
}
|
|
410
|
-
await reclaimDeployLock(lockDirectory, owner.token);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
throw new DeployLockConflictError(DEPLOY_LOCKED_MESSAGE);
|
|
414
|
-
}
|
|
415
|
-
function getDeployLockDirectory(scope, cacheRoot = defaultPaths.cache) {
|
|
416
|
-
const scopeHash = node_crypto.createHash('sha256').update(`${scope.apiBaseUrl}\0${scope.miniProgramId}\0${scope.version}`).digest('hex');
|
|
417
|
-
return path.join(cacheRoot, DEPLOY_LOCK_DIRECTORY_NAME, scopeHash);
|
|
418
|
-
}
|
|
419
|
-
function createDeployLock(lockDirectory, ownerFile, token) {
|
|
420
|
-
let released = false;
|
|
421
|
-
return {
|
|
422
|
-
async release() {
|
|
423
|
-
if (released)
|
|
424
|
-
return;
|
|
425
|
-
released = true;
|
|
426
|
-
await removeOwnedLock(lockDirectory, ownerFile, token);
|
|
427
|
-
},
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
async function canReclaimDeployLock(lockDirectory, ownerFile, options) {
|
|
431
|
-
const owner = await readDeployLockOwner(ownerFile);
|
|
432
|
-
if (owner) {
|
|
433
|
-
return !(options.isProcessRunning ?? isProcessRunning)(owner.pid);
|
|
434
|
-
}
|
|
435
|
-
try {
|
|
436
|
-
const lockStat = await fs$1.stat(lockDirectory);
|
|
437
|
-
return (options.now ?? Date.now)() - lockStat.mtimeMs >= INCOMPLETE_LOCK_GRACE_MS;
|
|
438
|
-
}
|
|
439
|
-
catch (error) {
|
|
440
|
-
return isNodeError(error) && error.code === 'ENOENT';
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
async function removeOwnedLock(lockDirectory, ownerFile, token) {
|
|
444
|
-
const owner = await readDeployLockOwner(ownerFile);
|
|
445
|
-
if (owner?.token === token) {
|
|
446
|
-
await fs$1.rm(lockDirectory, { force: true, recursive: true });
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
async function reclaimDeployLock(lockDirectory, token) {
|
|
450
|
-
const reclaimDirectory = `${lockDirectory}.reclaim-${node_crypto.createHash('sha256').update(token).digest('hex')}`;
|
|
451
|
-
try {
|
|
452
|
-
await fs$1.rename(lockDirectory, reclaimDirectory);
|
|
453
|
-
}
|
|
454
|
-
catch (error) {
|
|
455
|
-
if (isNodeError(error) && error.code === 'ENOENT')
|
|
456
|
-
return;
|
|
457
|
-
throw error;
|
|
458
|
-
}
|
|
459
|
-
await fs$1.rm(reclaimDirectory, { force: true, recursive: true });
|
|
460
|
-
}
|
|
461
|
-
async function readDeployLockOwner(ownerFile) {
|
|
462
|
-
try {
|
|
463
|
-
const value = JSON.parse(await fs$1.readFile(ownerFile, 'utf8'));
|
|
464
|
-
return isDeployLockOwner(value) ? value : null;
|
|
465
|
-
}
|
|
466
|
-
catch (error) {
|
|
467
|
-
if (isNodeError(error) && error.code === 'ENOENT')
|
|
468
|
-
return null;
|
|
469
|
-
if (error instanceof SyntaxError)
|
|
470
|
-
return null;
|
|
471
|
-
throw error;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
function isDeployLockOwner(value) {
|
|
475
|
-
return (typeof value === 'object' &&
|
|
476
|
-
value !== null &&
|
|
477
|
-
value.version === 1 &&
|
|
478
|
-
Number.isInteger(value.pid) &&
|
|
479
|
-
typeof value.token === 'string');
|
|
480
|
-
}
|
|
481
|
-
function isProcessRunning(pid) {
|
|
482
|
-
try {
|
|
483
|
-
process.kill(pid, 0);
|
|
484
|
-
return true;
|
|
485
|
-
}
|
|
486
|
-
catch (error) {
|
|
487
|
-
return !isNodeError(error) || error.code !== 'ESRCH';
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
function isNodeError(error) {
|
|
491
|
-
return error instanceof Error && 'code' in error;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
378
|
/** 发布提示使用显式声明与远端主体批准策略,不消费本地调试授权。 */
|
|
495
379
|
function getUnapprovedPermissionWarning(local, approvals, partyType) {
|
|
496
380
|
if (!local.declared)
|
|
@@ -610,7 +494,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
610
494
|
const buildScript = await readProjectBuildScript(projectRoot);
|
|
611
495
|
logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode, buildScript).join(' ')}`);
|
|
612
496
|
await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
|
|
613
|
-
env: runtimePermissionEnv.createMiniappPlatformCspEnv(env, skipPlatformCsp),
|
|
497
|
+
env: { ...runtimePermissionEnv.createMiniappPlatformCspEnv(env, skipPlatformCsp), HB_SDK_DEFER_METADATA_WARNINGS: '1' },
|
|
614
498
|
mode: buildMode,
|
|
615
499
|
outputMode: options.buildOutputMode ?? 'inherit',
|
|
616
500
|
platform,
|
|
@@ -627,6 +511,9 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
627
511
|
const distDir = path.join(projectRoot, 'dist');
|
|
628
512
|
const parsedManifest = await readDeployManifest(projectRoot, logger);
|
|
629
513
|
({ manifest, version } = parsedManifest);
|
|
514
|
+
for (const warning of getMiniappMetadataWarnings(manifest)) {
|
|
515
|
+
logger.warn(`[${warning.code}] ${warning.message}`, { stream: 'stderr' });
|
|
516
|
+
}
|
|
630
517
|
if (manifest.category !== declaredCategory) {
|
|
631
518
|
throw new Error('dist/manifest.json.category 与 package.json#heybox.category 不一致,请重新 build 后再 deploy');
|
|
632
519
|
}
|
|
@@ -792,7 +679,7 @@ async function runDeployCommand(options, runtime = {}) {
|
|
|
792
679
|
version,
|
|
793
680
|
};
|
|
794
681
|
};
|
|
795
|
-
return (runtime.withDeployLock ?? withDeployLock)({ apiBaseUrl, miniProgramId, version: uploadVersion }, deploy);
|
|
682
|
+
return (runtime.withDeployLock ?? deployLock.withDeployLock)({ apiBaseUrl, miniProgramId, version: uploadVersion }, deploy);
|
|
796
683
|
}
|
|
797
684
|
function printDeploySuccess(options) {
|
|
798
685
|
options.logger.success(`提交审核成功:${options.miniProgramId} ${options.version}`);
|
|
@@ -5,8 +5,8 @@ require('node:module');
|
|
|
5
5
|
require('node:url');
|
|
6
6
|
var fs = require('node:fs');
|
|
7
7
|
var path = require('node:path');
|
|
8
|
-
var runtimePermissionEnv = require('./runtime-permission-env-
|
|
9
|
-
var index = require('./index-
|
|
8
|
+
var runtimePermissionEnv = require('./runtime-permission-env-CDx5qO-T.cjs');
|
|
9
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
10
10
|
var _commonjsDynamicModules = require('./_commonjs-dynamic-modules-DUamuDzp.cjs');
|
|
11
11
|
var require$$0$1 = require('fs');
|
|
12
12
|
var require$$1 = require('path');
|
package/dist/cli-chunks/{runtime-permission-env-BQ7lPfhg.cjs → runtime-permission-env-CDx5qO-T.cjs}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
4
4
|
var fs = require('node:fs');
|
|
5
5
|
var path = require('node:path');
|
|
6
|
-
var version$1 = require('./version-
|
|
6
|
+
var version$1 = require('./version-D40WHkF9.cjs');
|
|
7
7
|
require('node:crypto');
|
|
8
8
|
var node_async_hooks = require('node:async_hooks');
|
|
9
9
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = require('./version-
|
|
3
|
+
var version = require('./version-D40WHkF9.cjs');
|
|
4
4
|
var fs = require('node:fs/promises');
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var childProcess = require('node:child_process');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-CY67PpQk.cjs');
|
|
8
8
|
require('node:module');
|
|
9
9
|
require('readline');
|
|
10
10
|
require('os');
|