@deveco-test/deveco-code 0.2.0-1.5 → 0.2.0-1.7

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