@deveco-test/deveco-code 1.10.28 → 1.10.30

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/postinstall.mjs +55 -7
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "scripts": {
7
7
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
8
  },
9
- "version": "1.10.28",
9
+ "version": "1.10.30",
10
10
  "license": "MIT",
11
11
  "files": [
12
12
  "bin/**/*",
@@ -16,10 +16,10 @@
16
16
  "CHANGELOG.md"
17
17
  ],
18
18
  "optionalDependencies": {
19
- "@deveco-test/deveco-code-darwin-x64": "1.10.28",
20
- "@deveco-test/deveco-code-darwin-arm64": "1.10.28",
21
- "@deveco-test/deveco-code-windows-x64-baseline": "1.10.28",
22
- "@deveco-test/deveco-code-windows-x64": "1.10.28"
19
+ "@deveco-test/deveco-code-darwin-x64": "1.10.30",
20
+ "@deveco-test/deveco-code-darwin-arm64": "1.10.30",
21
+ "@deveco-test/deveco-code-windows-x64-baseline": "1.10.30",
22
+ "@deveco-test/deveco-code-windows-x64": "1.10.30"
23
23
  },
24
24
  "dependencies": {
25
25
  "@deveco/deveco-cli": "1.3.2"
package/postinstall.mjs CHANGED
@@ -30,6 +30,34 @@ const sourceBinary = platform === "windows" ? "deveco.exe" : "deveco"
30
30
  const targetBinary = path.join(__dirname, "bin", "deveco.exe")
31
31
  const devecoCliPackageName = "@deveco/deveco-cli"
32
32
 
33
+ // Mirrors packages/tui isOhos(): OHOS PCs report linux/arm64 to npm but need
34
+ // the cross-built hmos artifact instead of a generic linux platform package.
35
+ function isOhos() {
36
+ if (os.platform() === "openharmony") return true
37
+ if (os.platform() !== "linux") return false
38
+ let filePara = false
39
+ let fileRelease = false
40
+ try {
41
+ filePara = fs.existsSync("/system/etc/ohos.para")
42
+ fileRelease = fs.existsSync("/etc/ohos-release")
43
+ } catch {
44
+ // Ignore filesystem probes that are blocked by the host.
45
+ }
46
+ const rel = os.release().toLowerCase()
47
+ return (
48
+ Boolean(process.env.HOS_VERSION) ||
49
+ Boolean(process.env.OHOS_API_VERSION) ||
50
+ rel.includes("ohos") ||
51
+ rel.includes("hongmeng") ||
52
+ filePara ||
53
+ fileRelease
54
+ )
55
+ }
56
+
57
+ function binaryName(name) {
58
+ return name.includes("-hmos-") ? "hmos" : sourceBinary
59
+ }
60
+
33
61
  function resolveLocalDevecoCliEntry() {
34
62
  const packageJsonPath = require.resolve(`${devecoCliPackageName}/package.json`)
35
63
  const entry = path.join(path.dirname(packageJsonPath), "dist", "cli.js")
@@ -109,6 +137,7 @@ function isMusl() {
109
137
  }
110
138
 
111
139
  function packageNames() {
140
+ if (isOhos()) return [`${scope}/deveco-code-hmos-${arch}`]
112
141
  const baseline = arch === "x64" && !supportsAvx2()
113
142
 
114
143
  if (platform === "linux") {
@@ -137,7 +166,7 @@ function resolvePackageDir(name) {
137
166
  }
138
167
 
139
168
  function resolveBinary(name) {
140
- const binaryPath = path.join(resolvePackageDir(name), "bin", sourceBinary)
169
+ const binaryPath = path.join(resolvePackageDir(name), "bin", binaryName(name))
141
170
  if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
142
171
  return binaryPath
143
172
  }
@@ -202,8 +231,9 @@ function ensureVendorExecutables(vendorRoot) {
202
231
  }
203
232
 
204
233
  function installPackage(name) {
205
- const version = packageJson.optionalDependencies?.[name]
206
- if (!version) return
234
+ // hmos artifacts stay out of optionalDependencies (no os/cpu tuple), so fall
235
+ // back to the release version shared by every package in this train.
236
+ const version = packageJson.optionalDependencies?.[name] ?? packageJson.version
207
237
 
208
238
  const temp = fs.mkdtempSync(path.join(os.tmpdir(), "opencode-install-"))
209
239
  try {
@@ -214,7 +244,7 @@ function installPackage(name) {
214
244
  )
215
245
  if (result.status !== 0) return
216
246
  const packageDir = path.join(temp, "node_modules", name)
217
- copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
247
+ copyBinary(path.join(packageDir, "bin", binaryName(name)), targetBinary)
218
248
  copyVendor(packageDir)
219
249
  return true
220
250
  } finally {
@@ -243,18 +273,36 @@ function verifyBinary() {
243
273
  return result.status === 0
244
274
  }
245
275
 
276
+ function writeVendorEntryMarker(installRoot) {
277
+ const vendorRoot = path.join(installRoot, "vendor", "deveco-cli")
278
+ const names = ["@deveco-test/hmos-deveco-cli", "@deveco/deveco-cli", "@deveco-test/deveco-cli"]
279
+ for (const name of names) {
280
+ const entry = path.join(vendorRoot, "node_modules", ...name.split("/"), "dist", "cli.js")
281
+ if (!fs.existsSync(entry)) continue
282
+ fs.mkdirSync(path.join(installRoot, "vendor"), { recursive: true })
283
+ fs.writeFileSync(path.join(installRoot, "vendor", ".deveco-cli-entry"), `${entry}\n`, "utf8")
284
+ return
285
+ }
286
+ }
287
+
246
288
  function main() {
247
- writeDevecoCliEntryMarker(__dirname)
289
+ // On OHOS the npm dependency cli must not win over the vendored hmos cli, so
290
+ // the dependency marker is skipped and the vendor marker is written instead.
291
+ if (!isOhos()) writeDevecoCliEntryMarker(__dirname)
248
292
 
249
293
  for (const name of packageNames()) {
250
294
  try {
251
295
  const packageDir = resolvePackageDir(name)
252
296
  copyBinary(resolveBinary(name), targetBinary)
253
297
  copyVendor(packageDir)
254
- writeDevecoCliEntryMarker(packageDir)
298
+ if (isOhos()) writeVendorEntryMarker(__dirname)
299
+ else writeDevecoCliEntryMarker(packageDir)
255
300
  if (verifyBinary()) return
256
301
  } catch {
257
- if (installPackage(name) && verifyBinary()) return
302
+ if (installPackage(name)) {
303
+ if (isOhos()) writeVendorEntryMarker(__dirname)
304
+ if (verifyBinary()) return
305
+ }
258
306
  }
259
307
  }
260
308