@clickzetta/cz-cli 0.3.58 → 0.3.60

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.
package/bin/platform.js CHANGED
@@ -133,10 +133,15 @@ async function installFromNpmRegistry({
133
133
  } = {}) {
134
134
  const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "cz-cli-npm-pack-"));
135
135
 
136
+ const cleanEnv = Object.fromEntries(
137
+ Object.entries(process.env).filter(([k]) => !k.startsWith("npm_")),
138
+ );
139
+
136
140
  try {
137
141
  const packed = execFileSync("npm", ["pack", `${packageName}@${version}`, "--silent"], {
138
142
  cwd: tempRoot,
139
143
  encoding: "utf-8",
144
+ env: cleanEnv,
140
145
  stdio: ["ignore", "pipe", "pipe"],
141
146
  })
142
147
  .trim()
@@ -171,16 +176,34 @@ async function ensureInstalledBinary({
171
176
  } = {}) {
172
177
  if (!spec) throw new Error(`Unsupported platform/arch: ${os.platform()}/${os.arch()}`);
173
178
 
179
+ const resolveFn = resolvePackageDirOverride || resolvePackageDir;
180
+
174
181
  if (!force) {
175
182
  const installed = resolveInstalledBinary({
176
183
  spec,
177
184
  fallbackRoot,
178
- resolvePackageDirFn: resolvePackageDirOverride || resolvePackageDir,
185
+ resolvePackageDirFn: resolveFn,
179
186
  existsSync,
180
187
  });
181
188
  if (installed) return installed;
182
189
  }
183
190
 
191
+ // When force is true, still prefer the optionalDependency package if its
192
+ // version matches — avoids a nested npm pack call that can fail inside
193
+ // postinstall (inherited npm env/lock conflicts).
194
+ if (force) {
195
+ const pkgDir = resolveFn(spec);
196
+ if (pkgDir) {
197
+ try {
198
+ const pkgJson = JSON.parse(fs.readFileSync(path.join(pkgDir, "package.json"), "utf-8"));
199
+ if (pkgJson.version === version) {
200
+ const packaged = resolveBinaryFromRoot(path.join(pkgDir, "bin"), spec, existsSync);
201
+ if (packaged) return { ...packaged, source: "package" };
202
+ }
203
+ } catch {}
204
+ }
205
+ }
206
+
184
207
  const destinationDir = path.join(fallbackRoot, `${spec.platform}-${spec.arch}`);
185
208
  fs.rmSync(destinationDir, { recursive: true, force: true });
186
209
  fs.mkdirSync(destinationDir, { recursive: true });
@@ -24,9 +24,9 @@ async function main() {
24
24
  const spec = getPlatformSpec();
25
25
  if (!spec) return;
26
26
 
27
- // Always force re-install during postinstall to ensure the platform binary
28
- // matches the version being installed. Without this, npm may keep a stale
29
- // optionalDependency binary from a previous version.
27
+ // Force re-install to ensure the platform binary matches the version being
28
+ // installed. ensureInstalledBinary will prefer the optionalDependency package
29
+ // when available, falling back to npm pack only when necessary.
30
30
  const installed = await ensureInstalledBinary({
31
31
  spec,
32
32
  version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickzetta/cz-cli",
3
- "version": "0.3.58",
3
+ "version": "0.3.60",
4
4
  "description": "AI-Agent-friendly CLI for ClickZetta Lakehouse",
5
5
  "bin": {
6
6
  "cz-cli": "bin/run.js"
@@ -12,11 +12,11 @@
12
12
  "bin/"
13
13
  ],
14
14
  "optionalDependencies": {
15
- "@clickzetta/cz-cli-darwin-arm64": "0.3.58",
16
- "@clickzetta/cz-cli-darwin-x64": "0.3.58",
17
- "@clickzetta/cz-cli-linux-arm64": "0.3.58",
18
- "@clickzetta/cz-cli-linux-x64": "0.3.58",
19
- "@clickzetta/cz-cli-win32-x64": "0.3.58"
15
+ "@clickzetta/cz-cli-darwin-arm64": "0.3.60",
16
+ "@clickzetta/cz-cli-darwin-x64": "0.3.60",
17
+ "@clickzetta/cz-cli-linux-arm64": "0.3.60",
18
+ "@clickzetta/cz-cli-linux-x64": "0.3.60",
19
+ "@clickzetta/cz-cli-win32-x64": "0.3.60"
20
20
  },
21
21
  "license": "MIT",
22
22
  "repository": {