@deveco-test/deveco-code 0.1.0-TD.1 → 0.1.0-TD.1.1

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 +4 -4
  2. package/postinstall.mjs +29 -2
package/package.json CHANGED
@@ -6,11 +6,11 @@
6
6
  "scripts": {
7
7
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
8
  },
9
- "version": "0.1.0-TD.1",
9
+ "version": "0.1.0-TD.1.1",
10
10
  "license": "MIT",
11
11
  "optionalDependencies": {
12
- "@deveco-test/deveco-code-windows-x64": "0.1.0-TD.1",
13
- "@deveco-test/deveco-code-darwin-x64": "0.1.0-TD.1",
14
- "@deveco-test/deveco-code-darwin-arm64": "0.1.0-TD.1"
12
+ "@deveco-test/deveco-code-windows-x64": "0.1.0-TD.1.1",
13
+ "@deveco-test/deveco-code-darwin-x64": "0.1.0-TD.1.1",
14
+ "@deveco-test/deveco-code-darwin-arm64": "0.1.0-TD.1.1"
15
15
  }
16
16
  }
package/postinstall.mjs CHANGED
@@ -116,13 +116,38 @@ function packageNames() {
116
116
  return [base]
117
117
  }
118
118
 
119
- function resolveBinary(name) {
119
+ function resolvePackageDir(name) {
120
120
  const packageJsonPath = require.resolve(`${name}/package.json`)
121
- const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
121
+ return path.dirname(packageJsonPath)
122
+ }
123
+
124
+ function resolveBinary(name) {
125
+ const binaryPath = path.join(resolvePackageDir(name), "bin", sourceBinary)
122
126
  if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
123
127
  return binaryPath
124
128
  }
125
129
 
130
+ function copyDir(src, dst) {
131
+ if (!fs.existsSync(dst)) fs.mkdirSync(dst, { recursive: true })
132
+ for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
133
+ const srcPath = path.join(src, entry.name)
134
+ const dstPath = path.join(dst, entry.name)
135
+ if (entry.isDirectory()) {
136
+ copyDir(srcPath, dstPath)
137
+ } else {
138
+ fs.copyFileSync(srcPath, dstPath)
139
+ }
140
+ }
141
+ }
142
+
143
+ function copyVendor(packageDir) {
144
+ const vendorSrc = path.join(packageDir, "vendor")
145
+ const vendorDst = path.join(__dirname, "vendor")
146
+ if (fs.existsSync(vendorSrc)) {
147
+ copyDir(vendorSrc, vendorDst)
148
+ }
149
+ }
150
+
126
151
  function installPackage(name) {
127
152
  const version = packageJson.optionalDependencies?.[name]
128
153
  if (!version) return
@@ -137,6 +162,7 @@ function installPackage(name) {
137
162
  if (result.status !== 0) return
138
163
  const packageDir = path.join(temp, "node_modules", name)
139
164
  copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
165
+ copyVendor(packageDir)
140
166
  return true
141
167
  } finally {
142
168
  fs.rmSync(temp, { recursive: true, force: true })
@@ -168,6 +194,7 @@ function main() {
168
194
  for (const name of packageNames()) {
169
195
  try {
170
196
  copyBinary(resolveBinary(name), targetBinary)
197
+ copyVendor(resolvePackageDir(name))
171
198
  if (verifyBinary()) return
172
199
  } catch {
173
200
  if (installPackage(name) && verifyBinary()) return