@hippox/codegenie 3.11.2026-alpha.2 → 3.11.2026-alpha.4
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/bin/postinstall.js +53 -8
- package/lib/resolve-binary.js +3 -1
- package/package.json +2 -2
package/bin/postinstall.js
CHANGED
|
@@ -1,10 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { execFileSync } = require("child_process")
|
|
4
|
+
const { resolveBinary, resolvePackageName } = require("../lib/resolve-binary.js")
|
|
4
5
|
const { prewarmBinary, warmStartupBinary } = require("../lib/prewarm.js")
|
|
6
|
+
const packageJson = require("../package.json")
|
|
7
|
+
|
|
8
|
+
function tryInstallPlatformPackage() {
|
|
9
|
+
let platformPackageName
|
|
10
|
+
try {
|
|
11
|
+
platformPackageName = resolvePackageName()
|
|
12
|
+
} catch {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const platformVersion = packageJson.optionalDependencies && packageJson.optionalDependencies[platformPackageName]
|
|
17
|
+
const installSpec = platformVersion ? `${platformPackageName}@${platformVersion}` : platformPackageName
|
|
18
|
+
const npmExecutable = process.platform === "win32" ? "npm.cmd" : "npm"
|
|
19
|
+
|
|
20
|
+
console.log(`[codegenie] Platform package ${platformPackageName} not found, attempting to install...`)
|
|
21
|
+
try {
|
|
22
|
+
execFileSync(npmExecutable, ["install", "-g", installSpec], {
|
|
23
|
+
stdio: "inherit",
|
|
24
|
+
timeout: 120000,
|
|
25
|
+
})
|
|
26
|
+
return true
|
|
27
|
+
} catch (err) {
|
|
28
|
+
console.warn(`[codegenie] Failed to auto-install ${installSpec}: ${err && err.message ? err.message : String(err)}`)
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function runPostInstall() {
|
|
34
|
+
let resolved
|
|
35
|
+
try {
|
|
36
|
+
resolved = resolveBinary()
|
|
37
|
+
} catch (firstError) {
|
|
38
|
+
const attempted = tryInstallPlatformPackage()
|
|
39
|
+
if (!attempted) {
|
|
40
|
+
const message = firstError && firstError.message ? firstError.message : String(firstError)
|
|
41
|
+
console.warn("[codegenie] npm install completed, but platform binary verification will be deferred to first launch.")
|
|
42
|
+
console.warn(message)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
resolved = resolveBinary()
|
|
47
|
+
} catch (retryError) {
|
|
48
|
+
const message = retryError && retryError.message ? retryError.message : String(retryError)
|
|
49
|
+
console.warn("[codegenie] npm install completed, but platform binary verification will be deferred to first launch.")
|
|
50
|
+
console.warn(message)
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
}
|
|
5
54
|
|
|
6
|
-
try {
|
|
7
|
-
const resolved = resolveBinary()
|
|
8
55
|
console.log("[codegenie] npm install complete. Global command \"codegenie\" is ready.")
|
|
9
56
|
console.log(`[codegenie] Using platform package ${resolved.packageName}.`)
|
|
10
57
|
console.log("[codegenie] Prewarming runtime assets during npm install...")
|
|
@@ -22,7 +69,7 @@ try {
|
|
|
22
69
|
console.log("[codegenie] Runtime assets are ready. First launch should be faster.")
|
|
23
70
|
}
|
|
24
71
|
|
|
25
|
-
if (process.platform === "win32") {
|
|
72
|
+
if (process.platform === "win32" && process.env.CODEGENIE_SKIP_WARM_STARTUP !== "true") {
|
|
26
73
|
console.log("[codegenie] Finalizing hidden first-launch warmup...")
|
|
27
74
|
const startupWarm = warmStartupBinary(resolved.binaryPath, resolved.platformDir)
|
|
28
75
|
if (startupWarm.error) {
|
|
@@ -31,8 +78,6 @@ try {
|
|
|
31
78
|
console.warn(`[codegenie] Hidden startup warmup exited with code ${startupWarm.status}. First visible launch may still be slower.`)
|
|
32
79
|
}
|
|
33
80
|
}
|
|
34
|
-
} catch (error) {
|
|
35
|
-
const message = error && error.message ? error.message : String(error)
|
|
36
|
-
console.warn("[codegenie] npm install completed, but platform binary verification will be deferred to first launch.")
|
|
37
|
-
console.warn(message)
|
|
38
81
|
}
|
|
82
|
+
|
|
83
|
+
runPostInstall()
|
package/lib/resolve-binary.js
CHANGED
|
@@ -49,7 +49,9 @@ function resolveBinary() {
|
|
|
49
49
|
try {
|
|
50
50
|
platformDir = resolvePlatformPackageDir(packageName)
|
|
51
51
|
} catch (error) {
|
|
52
|
-
const metaPackageName =
|
|
52
|
+
const metaPackageName = (() => {
|
|
53
|
+
try { return require("../package.json").name } catch { return null }
|
|
54
|
+
})() || process.env.npm_package_name || "@hippox/codegenie"
|
|
53
55
|
const hint = [
|
|
54
56
|
`[codegenie] Failed to locate installed binary package for ${process.platform}/${process.arch}.`,
|
|
55
57
|
`[codegenie] Expected package: ${packageName}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hippox/codegenie",
|
|
3
|
-
"version": "3.11.2026-alpha.
|
|
3
|
+
"version": "3.11.2026-alpha.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "HarmonyOS AI 开发 CLI,binary-first 发布并通过 npm 分发平台二进制",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"ai"
|
|
27
27
|
],
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@hippox/codegenie-win32-x64": "3.11.2026-alpha.
|
|
29
|
+
"@hippox/codegenie-win32-x64": "3.11.2026-alpha.4"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|