@deveco-test/deveco-code 0.1.0-TD.25 → 0.1.0-TD.26

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 +7 -5
  2. package/postinstall.mjs +16 -17
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "scripts": {
7
7
  "postinstall": "node ./postinstall.mjs"
8
8
  },
9
- "version": "0.1.0-TD.25",
9
+ "version": "0.1.0-TD.26",
10
10
  "license": "MIT",
11
11
  "os": [
12
12
  "darwin",
@@ -25,9 +25,11 @@
25
25
  "assets/**/*"
26
26
  ],
27
27
  "optionalDependencies": {
28
- "@deveco-test/deveco-code-windows-x64": "0.1.0-TD.25",
29
- "@deveco-test/deveco-code-darwin-x64": "0.1.0-TD.25",
30
- "@deveco-test/deveco-code-darwin-arm64": "0.1.0-TD.25",
31
- "@deveco-test/deveco-code": "0.1.0-TD.25"
28
+ "@deveco-test/deveco-code-windows-x64": "0.1.0-TD.26",
29
+ "@deveco-test/deveco-code-darwin-x64": "0.1.0-TD.26",
30
+ "@deveco-test/deveco-code-darwin-arm64": "0.1.0-TD.26"
31
+ },
32
+ "dependencies": {
33
+ "@deveco/deveco-cli": "1.2.2"
32
34
  }
33
35
  }
package/postinstall.mjs CHANGED
@@ -27,6 +27,20 @@ const arch = archMap[os.arch()] ?? os.arch()
27
27
  const base = `@deveco-test/deveco-code-${platform}-${arch}`
28
28
  const sourceBinary = platform === "windows" ? "deveco.exe" : "deveco"
29
29
  const targetBinary = path.join(__dirname, "bin", "deveco.exe")
30
+ const devecoCliEntryMarker = path.join(__dirname, "vendor", ".deveco-cli-entry")
31
+ const devecoCliPackageName = "@deveco/deveco-cli"
32
+
33
+ function resolveLocalDevecoCliEntry() {
34
+ const packageJsonPath = require.resolve(`${devecoCliPackageName}/package.json`)
35
+ const entry = path.join(path.dirname(packageJsonPath), "dist", "cli.js")
36
+ if (fs.existsSync(entry)) return entry
37
+ throw new Error(`Local dependency "${devecoCliPackageName}" has no CLI entry at ${entry}.`)
38
+ }
39
+
40
+ function writeDevecoCliEntryMarker() {
41
+ fs.mkdirSync(path.dirname(devecoCliEntryMarker), { recursive: true })
42
+ fs.writeFileSync(devecoCliEntryMarker, `${resolveLocalDevecoCliEntry()}\n`, "utf8")
43
+ }
30
44
 
31
45
  function supportsAvx2() {
32
46
  if (arch !== "x64") return false
@@ -148,29 +162,12 @@ function copyVendor(packageDir) {
148
162
  const vendorDst = path.join(__dirname, "vendor")
149
163
  if (fs.existsSync(vendorSrc)) {
150
164
  copyDir(vendorSrc, vendorDst)
151
- restoreDevecoCliDeps(path.join(vendorDst, "deveco-cli"))
152
- restoreDevecoCliDeps(path.join(packageDir, "vendor", "deveco-cli"))
153
165
  // Windows packs often drop Unix +x; force it back on macOS/Linux install.
154
166
  ensureVendorExecutables(vendorDst)
155
167
  ensureVendorExecutables(path.join(packageDir, "vendor"))
156
168
  }
157
169
  }
158
170
 
159
- function restoreDevecoCliDeps(cliDir) {
160
- const tarPath = path.join(cliDir, "deps.tar.gz")
161
- if (!fs.existsSync(tarPath)) return
162
- const result = childProcess.spawnSync("tar", ["-xzf", tarPath, "-C", cliDir], {
163
- stdio: "inherit",
164
- windowsHide: true,
165
- shell: true,
166
- })
167
- if (result.status !== 0) {
168
- console.warn("Warning: failed to restore deveco-cli dependencies")
169
- return
170
- }
171
- fs.unlinkSync(tarPath)
172
- }
173
-
174
171
  /** Restore execute bits lost when packages are built/published from Windows. */
175
172
  function ensureVendorExecutables(vendorRoot) {
176
173
  if (process.platform === "win32" || !fs.existsSync(vendorRoot)) return
@@ -246,6 +243,8 @@ function verifyBinary() {
246
243
  }
247
244
 
248
245
  function main() {
246
+ writeDevecoCliEntryMarker()
247
+
249
248
  for (const name of packageNames()) {
250
249
  try {
251
250
  copyBinary(resolveBinary(name), targetBinary)