@yi-agent/yi-agent-darwin-arm64 0.1.3 → 0.1.12
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/binaries/yi-agent +0 -0
- package/install-app.js +149 -0
- package/package.json +6 -2
- package/yi-agent.app/Contents/Info.plist +34 -0
- package/yi-agent.app/Contents/MacOS/desktop +0 -0
- package/yi-agent.app/Contents/MacOS/yi-agent +4 -0
- package/yi-agent.app/Contents/Resources/icon.icns +0 -0
- package/yi-agent.app/Contents/_CodeSignature/CodeResources +137 -0
package/binaries/yi-agent
CHANGED
|
Binary file
|
package/install-app.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// postinstall:把随包分发的 .app 复制到 /Applications。
|
|
3
|
+
//
|
|
4
|
+
// 硬性要求:任何情况下都退出 0。桌面 App 装不上不能拖垮 CLI 安装——
|
|
5
|
+
// 用户敲 `npm i -g` 的首要目的是拿到 yi-agent 命令。
|
|
6
|
+
//
|
|
7
|
+
// 只在 `npm i -g` 时动手,避免本包被当作依赖装进别人的 node_modules
|
|
8
|
+
// 时顺手污染 /Applications。
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const { execFileSync } = require('child_process');
|
|
14
|
+
|
|
15
|
+
const APP_NAME = 'yi-agent.app';
|
|
16
|
+
const TARGET_DIR = '/Applications';
|
|
17
|
+
|
|
18
|
+
/// 判断是否该在本机安装桌面 App。
|
|
19
|
+
/// 返回 { ok, reason };ok 为 false 时 reason 说明原因(便于日志排查)。
|
|
20
|
+
function shouldInstall(env, platform, arch) {
|
|
21
|
+
if (env.npm_config_global !== 'true') {
|
|
22
|
+
return { ok: false, reason: 'not a global install' };
|
|
23
|
+
}
|
|
24
|
+
if (platform !== 'darwin') {
|
|
25
|
+
return { ok: false, reason: `platform ${platform} is not darwin` };
|
|
26
|
+
}
|
|
27
|
+
if (arch !== 'arm64') {
|
|
28
|
+
return { ok: false, reason: `arch ${arch} is not arm64` };
|
|
29
|
+
}
|
|
30
|
+
return { ok: true, reason: 'ok' };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// 已有版本与待装版本不同才需要替换。没装过(任一侧为空)视为需要装。
|
|
34
|
+
function needsReplace(installedVersion, bundledVersion) {
|
|
35
|
+
if (!installedVersion) return true;
|
|
36
|
+
if (!bundledVersion) return true;
|
|
37
|
+
return installedVersion !== bundledVersion;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// 从 Info.plist 文本里取 CFBundleShortVersionString。
|
|
41
|
+
function parseAppVersion(plistText) {
|
|
42
|
+
const m = plistText.match(
|
|
43
|
+
/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/
|
|
44
|
+
);
|
|
45
|
+
return m ? m[1].trim() : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function readAppVersion(appPath) {
|
|
49
|
+
try {
|
|
50
|
+
const plist = fs.readFileSync(
|
|
51
|
+
path.join(appPath, 'Contents', 'Info.plist'),
|
|
52
|
+
'utf8'
|
|
53
|
+
);
|
|
54
|
+
return parseAppVersion(plist);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isWritable(dir) {
|
|
61
|
+
try {
|
|
62
|
+
fs.accessSync(dir, fs.constants.W_OK);
|
|
63
|
+
return true;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// 复制 .app 并清 quarantine。先复制到临时目录再原子替换,
|
|
70
|
+
/// 避免中途失败留下半个 App(沿用 desktop/packaging/install.sh 的做法)。
|
|
71
|
+
function installApp(sourceApp, targetApp) {
|
|
72
|
+
const staging = `${targetApp}.staging-${process.pid}`;
|
|
73
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
74
|
+
fs.cpSync(sourceApp, staging, { recursive: true, dereference: true });
|
|
75
|
+
|
|
76
|
+
// ad-hoc 重签。Tauri 产出的签名是坏的(codesign --verify 报
|
|
77
|
+
// "code has no resources but signature indicates they must be present"),
|
|
78
|
+
// 复制后重签可修复。失败不致命:签名坏了多半仍能启动。
|
|
79
|
+
try {
|
|
80
|
+
execFileSync('codesign', ['--force', '--deep', '--sign', '-', staging], {
|
|
81
|
+
stdio: 'ignore',
|
|
82
|
+
});
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.warn(`[yi-agent] codesign failed (non-fatal): ${e.message}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fs.rmSync(targetApp, { recursive: true, force: true });
|
|
88
|
+
fs.renameSync(staging, targetApp);
|
|
89
|
+
|
|
90
|
+
// 从 npm 装的包不带 quarantine,但用户若曾手工拷过同路径可能残留标记。
|
|
91
|
+
try {
|
|
92
|
+
execFileSync('xattr', ['-dr', 'com.apple.quarantine', targetApp], {
|
|
93
|
+
stdio: 'ignore',
|
|
94
|
+
});
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// 没有该属性时 xattr 返回非 0,忽略。
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function main() {
|
|
101
|
+
try {
|
|
102
|
+
const verdict = shouldInstall(process.env, process.platform, process.arch);
|
|
103
|
+
if (!verdict.ok) {
|
|
104
|
+
// 静默退出:本地开发安装不该有任何输出噪音。
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const sourceApp = path.join(__dirname, APP_NAME);
|
|
109
|
+
if (!fs.existsSync(sourceApp)) {
|
|
110
|
+
console.log('[yi-agent] desktop app not found in package, skipping');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const targetApp = path.join(TARGET_DIR, APP_NAME);
|
|
115
|
+
const bundledVersion = readAppVersion(sourceApp);
|
|
116
|
+
const installedVersion = readAppVersion(targetApp);
|
|
117
|
+
|
|
118
|
+
if (!needsReplace(installedVersion, bundledVersion)) {
|
|
119
|
+
console.log(
|
|
120
|
+
`[yi-agent] desktop app ${bundledVersion} already in ${TARGET_DIR}`
|
|
121
|
+
);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!fs.existsSync(TARGET_DIR) || !isWritable(TARGET_DIR)) {
|
|
126
|
+
console.log(
|
|
127
|
+
`[yi-agent] cannot write to ${TARGET_DIR} (needs admin). ` +
|
|
128
|
+
`CLI is installed; to add the desktop app run:\n` +
|
|
129
|
+
` sudo cp -R "${sourceApp}" "${TARGET_DIR}/"`
|
|
130
|
+
);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
installApp(sourceApp, targetApp);
|
|
135
|
+
console.log(
|
|
136
|
+
`[yi-agent] desktop app ${bundledVersion} installed to ${targetApp}`
|
|
137
|
+
);
|
|
138
|
+
} catch (e) {
|
|
139
|
+
// 兜底:绝不因装饰性功能让 install 失败。
|
|
140
|
+
console.warn(`[yi-agent] desktop app install skipped: ${e.message}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = { shouldInstall, needsReplace, parseAppVersion, isWritable };
|
|
145
|
+
|
|
146
|
+
if (require.main === module) {
|
|
147
|
+
main();
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yi-agent/yi-agent-darwin-arm64",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "yi-agent binary for darwin-arm64",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"os": ["darwin"],
|
|
7
7
|
"cpu": ["arm64"],
|
|
8
|
-
"
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install-app.js",
|
|
10
|
+
"test": "node --test test-install-app.js"
|
|
11
|
+
},
|
|
12
|
+
"files": ["binaries/", "yi-agent.app/", "install-app.js"]
|
|
9
13
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>English</string>
|
|
7
|
+
<key>CFBundleDisplayName</key>
|
|
8
|
+
<string>yi-agent</string>
|
|
9
|
+
<key>CFBundleExecutable</key>
|
|
10
|
+
<string>desktop</string>
|
|
11
|
+
<key>CFBundleIdentifier</key>
|
|
12
|
+
<string>com.gongyichen.desktop</string>
|
|
13
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
14
|
+
<string>6.0</string>
|
|
15
|
+
<key>CFBundleName</key>
|
|
16
|
+
<string>yi-agent</string>
|
|
17
|
+
<key>CFBundlePackageType</key>
|
|
18
|
+
<string>APPL</string>
|
|
19
|
+
<key>CFBundleShortVersionString</key>
|
|
20
|
+
<string>0.1.12</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>0.1.12</string>
|
|
23
|
+
<key>CSResourcesFileMapped</key>
|
|
24
|
+
<true/>
|
|
25
|
+
<key>LSMinimumSystemVersion</key>
|
|
26
|
+
<string>10.13</string>
|
|
27
|
+
<key>CFBundleIconFile</key>
|
|
28
|
+
<string>icon.icns</string>
|
|
29
|
+
<key>LSRequiresCarbon</key>
|
|
30
|
+
<true/>
|
|
31
|
+
<key>NSHighResolutionCapable</key>
|
|
32
|
+
<true/>
|
|
33
|
+
</dict>
|
|
34
|
+
</plist>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Resources/icon.icns</key>
|
|
8
|
+
<data>
|
|
9
|
+
LNkx333sdlPA8hOWSvMF4DAyGpk=
|
|
10
|
+
</data>
|
|
11
|
+
</dict>
|
|
12
|
+
<key>files2</key>
|
|
13
|
+
<dict>
|
|
14
|
+
<key>MacOS/yi-agent</key>
|
|
15
|
+
<dict>
|
|
16
|
+
<key>cdhash</key>
|
|
17
|
+
<data>
|
|
18
|
+
NA7kNJxgZNAsEHVE5PRg5oa7nGg=
|
|
19
|
+
</data>
|
|
20
|
+
<key>requirement</key>
|
|
21
|
+
<string>cdhash H"340ee4349c6064d02c107544e4f460e686bb9c68"</string>
|
|
22
|
+
</dict>
|
|
23
|
+
<key>Resources/icon.icns</key>
|
|
24
|
+
<dict>
|
|
25
|
+
<key>hash2</key>
|
|
26
|
+
<data>
|
|
27
|
+
+R3+KAwtoRtJzNtCIGUNp8T7LvwgCXpoj7uinsgQUuI=
|
|
28
|
+
</data>
|
|
29
|
+
</dict>
|
|
30
|
+
</dict>
|
|
31
|
+
<key>rules</key>
|
|
32
|
+
<dict>
|
|
33
|
+
<key>^Resources/</key>
|
|
34
|
+
<true/>
|
|
35
|
+
<key>^Resources/.*\.lproj/</key>
|
|
36
|
+
<dict>
|
|
37
|
+
<key>optional</key>
|
|
38
|
+
<true/>
|
|
39
|
+
<key>weight</key>
|
|
40
|
+
<real>1000</real>
|
|
41
|
+
</dict>
|
|
42
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
43
|
+
<dict>
|
|
44
|
+
<key>omit</key>
|
|
45
|
+
<true/>
|
|
46
|
+
<key>weight</key>
|
|
47
|
+
<real>1100</real>
|
|
48
|
+
</dict>
|
|
49
|
+
<key>^Resources/Base\.lproj/</key>
|
|
50
|
+
<dict>
|
|
51
|
+
<key>weight</key>
|
|
52
|
+
<real>1010</real>
|
|
53
|
+
</dict>
|
|
54
|
+
<key>^version.plist$</key>
|
|
55
|
+
<true/>
|
|
56
|
+
</dict>
|
|
57
|
+
<key>rules2</key>
|
|
58
|
+
<dict>
|
|
59
|
+
<key>.*\.dSYM($|/)</key>
|
|
60
|
+
<dict>
|
|
61
|
+
<key>weight</key>
|
|
62
|
+
<real>11</real>
|
|
63
|
+
</dict>
|
|
64
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
65
|
+
<dict>
|
|
66
|
+
<key>omit</key>
|
|
67
|
+
<true/>
|
|
68
|
+
<key>weight</key>
|
|
69
|
+
<real>2000</real>
|
|
70
|
+
</dict>
|
|
71
|
+
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
|
72
|
+
<dict>
|
|
73
|
+
<key>nested</key>
|
|
74
|
+
<true/>
|
|
75
|
+
<key>weight</key>
|
|
76
|
+
<real>10</real>
|
|
77
|
+
</dict>
|
|
78
|
+
<key>^.*</key>
|
|
79
|
+
<true/>
|
|
80
|
+
<key>^Info\.plist$</key>
|
|
81
|
+
<dict>
|
|
82
|
+
<key>omit</key>
|
|
83
|
+
<true/>
|
|
84
|
+
<key>weight</key>
|
|
85
|
+
<real>20</real>
|
|
86
|
+
</dict>
|
|
87
|
+
<key>^PkgInfo$</key>
|
|
88
|
+
<dict>
|
|
89
|
+
<key>omit</key>
|
|
90
|
+
<true/>
|
|
91
|
+
<key>weight</key>
|
|
92
|
+
<real>20</real>
|
|
93
|
+
</dict>
|
|
94
|
+
<key>^Resources/</key>
|
|
95
|
+
<dict>
|
|
96
|
+
<key>weight</key>
|
|
97
|
+
<real>20</real>
|
|
98
|
+
</dict>
|
|
99
|
+
<key>^Resources/.*\.lproj/</key>
|
|
100
|
+
<dict>
|
|
101
|
+
<key>optional</key>
|
|
102
|
+
<true/>
|
|
103
|
+
<key>weight</key>
|
|
104
|
+
<real>1000</real>
|
|
105
|
+
</dict>
|
|
106
|
+
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
|
107
|
+
<dict>
|
|
108
|
+
<key>omit</key>
|
|
109
|
+
<true/>
|
|
110
|
+
<key>weight</key>
|
|
111
|
+
<real>1100</real>
|
|
112
|
+
</dict>
|
|
113
|
+
<key>^Resources/Base\.lproj/</key>
|
|
114
|
+
<dict>
|
|
115
|
+
<key>weight</key>
|
|
116
|
+
<real>1010</real>
|
|
117
|
+
</dict>
|
|
118
|
+
<key>^[^/]+$</key>
|
|
119
|
+
<dict>
|
|
120
|
+
<key>nested</key>
|
|
121
|
+
<true/>
|
|
122
|
+
<key>weight</key>
|
|
123
|
+
<real>10</real>
|
|
124
|
+
</dict>
|
|
125
|
+
<key>^embedded\.provisionprofile$</key>
|
|
126
|
+
<dict>
|
|
127
|
+
<key>weight</key>
|
|
128
|
+
<real>20</real>
|
|
129
|
+
</dict>
|
|
130
|
+
<key>^version\.plist$</key>
|
|
131
|
+
<dict>
|
|
132
|
+
<key>weight</key>
|
|
133
|
+
<real>20</real>
|
|
134
|
+
</dict>
|
|
135
|
+
</dict>
|
|
136
|
+
</dict>
|
|
137
|
+
</plist>
|