@kangyishuai/dsh-casefile 0.5.0 → 0.5.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/actions.js +23 -2
- package/package.json +1 -1
package/lib/actions.js
CHANGED
|
@@ -97,6 +97,26 @@ export function createActions(options) {
|
|
|
97
97
|
};
|
|
98
98
|
const checkers = createCheckers({ runner: checkerRunner });
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* 把 Info.plist(XML 或二进制)转成 JSON 对象。
|
|
102
|
+
* @param {string} plistPath
|
|
103
|
+
* @returns {Promise<Record<string, any>>}
|
|
104
|
+
*/
|
|
105
|
+
const readPlistAsJson = async (/** @type {string} */ plistPath) => {
|
|
106
|
+
if (runner != null) {
|
|
107
|
+
const result = await runner(`plutil -convert json -o - ${JSON.stringify(plistPath)}`);
|
|
108
|
+
const text = String(result?.stdout ?? "").trim();
|
|
109
|
+
if (text !== "") return JSON.parse(text);
|
|
110
|
+
}
|
|
111
|
+
// 没有 runner 或 plutil 没输出:只在文件本身就是 JSON 形式时接受
|
|
112
|
+
const raw = readFileSync(plistPath, "utf8").trim();
|
|
113
|
+
if (raw.startsWith("{")) return JSON.parse(raw);
|
|
114
|
+
throw new CasefileInputError(
|
|
115
|
+
"invalid-input",
|
|
116
|
+
"无法解析 Info.plist:它可能是 XML 或二进制,需要在 macOS 上用 plutil 转换(runner 不可用)",
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
100
120
|
/**
|
|
101
121
|
* @param {string} projectId
|
|
102
122
|
* @returns {Record<string, any>}
|
|
@@ -1227,8 +1247,9 @@ export function createActions(options) {
|
|
|
1227
1247
|
if (!existsSync(plistPath)) {
|
|
1228
1248
|
throw new CasefileInputError("invalid-input", `不是 macOS 应用包:缺 ${plistPath}`);
|
|
1229
1249
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1250
|
+
// Info.plist 可能是 XML(实测 Bob.app 就是),也可能是二进制;统一交给 plutil 转 JSON。
|
|
1251
|
+
// 直接 JSON.parse 会在 XML 上炸——真实使用一轮就踩到了。
|
|
1252
|
+
const plist = await readPlistAsJson(plistPath);
|
|
1232
1253
|
const executableName =
|
|
1233
1254
|
typeof plist.CFBundleExecutable === "string" ? plist.CFBundleExecutable : null;
|
|
1234
1255
|
const executablePath =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kangyishuai/dsh-casefile",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Evidence-first reverse-engineering workbench on top of REA: observations become citable evidence, a handoff spec pack, and recomputable acceptance checks. No bridge, no engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|