@deveco-test/deveco-code 0.1.0-TD.24.test → 0.1.0-TD.24.test3

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 +22 -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.24.test",
9
+ "version": "0.1.0-TD.24.test3",
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.24.test",
29
- "@deveco-test/deveco-code-darwin-x64": "0.1.0-TD.24.test",
30
- "@deveco-test/deveco-code-darwin-arm64": "0.1.0-TD.24.test",
31
- "@deveco-test/deveco-code": "0.1.0-TD.24.test"
28
+ "@deveco-test/deveco-code-windows-x64": "0.1.0-TD.24.test3",
29
+ "@deveco-test/deveco-code-darwin-x64": "0.1.0-TD.24.test3",
30
+ "@deveco-test/deveco-code-darwin-arm64": "0.1.0-TD.24.test3"
31
+ },
32
+ "dependencies": {
33
+ "@deveco/deveco-cli": "1.2.1"
32
34
  }
33
35
  }
package/postinstall.mjs CHANGED
@@ -27,6 +27,26 @@ 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
+
32
+ function resolveLocalDevecoCliEntry() {
33
+ const roots = [
34
+ path.join(__dirname, "node_modules", "@deveco", "deveco-cli"),
35
+ path.join(__dirname, "..", "deveco-cli"),
36
+ ]
37
+ for (const root of roots) {
38
+ const entry = path.join(root, "dist", "cli.js")
39
+ if (fs.existsSync(entry)) return entry
40
+ }
41
+ throw new Error(
42
+ 'Local dependency "@deveco/deveco-cli" was not installed. Reinstall @deveco/deveco-code without omitting dependencies.',
43
+ )
44
+ }
45
+
46
+ function writeDevecoCliEntryMarker() {
47
+ fs.mkdirSync(path.dirname(devecoCliEntryMarker), { recursive: true })
48
+ fs.writeFileSync(devecoCliEntryMarker, `${resolveLocalDevecoCliEntry()}\n`, "utf8")
49
+ }
30
50
 
31
51
  function supportsAvx2() {
32
52
  if (arch !== "x64") return false
@@ -148,29 +168,12 @@ function copyVendor(packageDir) {
148
168
  const vendorDst = path.join(__dirname, "vendor")
149
169
  if (fs.existsSync(vendorSrc)) {
150
170
  copyDir(vendorSrc, vendorDst)
151
- restoreDevecoCliDeps(path.join(vendorDst, "deveco-cli"))
152
- restoreDevecoCliDeps(path.join(packageDir, "vendor", "deveco-cli"))
153
171
  // Windows packs often drop Unix +x; force it back on macOS/Linux install.
154
172
  ensureVendorExecutables(vendorDst)
155
173
  ensureVendorExecutables(path.join(packageDir, "vendor"))
156
174
  }
157
175
  }
158
176
 
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
177
  /** Restore execute bits lost when packages are built/published from Windows. */
175
178
  function ensureVendorExecutables(vendorRoot) {
176
179
  if (process.platform === "win32" || !fs.existsSync(vendorRoot)) return
@@ -246,6 +249,8 @@ function verifyBinary() {
246
249
  }
247
250
 
248
251
  function main() {
252
+ writeDevecoCliEntryMarker()
253
+
249
254
  for (const name of packageNames()) {
250
255
  try {
251
256
  copyBinary(resolveBinary(name), targetBinary)