@clickzetta/cz-cli 0.3.52 → 0.3.53

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
@@ -167,16 +167,19 @@ async function ensureInstalledBinary({
167
167
  resolvePackageDir: resolvePackageDirOverride,
168
168
  existsSync = fs.existsSync,
169
169
  installFromNpmRegistry: installFromNpmRegistryOverride = installFromNpmRegistry,
170
+ force = false,
170
171
  } = {}) {
171
172
  if (!spec) throw new Error(`Unsupported platform/arch: ${os.platform()}/${os.arch()}`);
172
173
 
173
- const installed = resolveInstalledBinary({
174
- spec,
175
- fallbackRoot,
176
- resolvePackageDirFn: resolvePackageDirOverride || resolvePackageDir,
177
- existsSync,
178
- });
179
- if (installed) return installed;
174
+ if (!force) {
175
+ const installed = resolveInstalledBinary({
176
+ spec,
177
+ fallbackRoot,
178
+ resolvePackageDirFn: resolvePackageDirOverride || resolvePackageDir,
179
+ existsSync,
180
+ });
181
+ if (installed) return installed;
182
+ }
180
183
 
181
184
  const destinationDir = path.join(fallbackRoot, `${spec.platform}-${spec.arch}`);
182
185
  fs.rmSync(destinationDir, { recursive: true, force: true });
@@ -24,10 +24,14 @@ 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
30
  const installed = await ensureInstalledBinary({
28
31
  spec,
29
32
  version,
30
33
  fallbackRoot: DEFAULT_FALLBACK_ROOT,
34
+ force: true,
31
35
  });
32
36
  const skillsSrc = path.join(installed.rootDir, "skills");
33
37
  const skills = fs.existsSync(skillsSrc)
package/bin/run.js CHANGED
@@ -2,23 +2,51 @@
2
2
  "use strict";
3
3
 
4
4
  const { execFileSync } = require("child_process");
5
- const { DEFAULT_FALLBACK_ROOT, getPlatformSpec, resolveInstalledBinary } = require("./platform");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const { DEFAULT_FALLBACK_ROOT, getPlatformSpec, resolveInstalledBinary, ensureInstalledBinary } = require("./platform");
6
8
 
7
9
  const spec = getPlatformSpec();
10
+ const expectedVersion = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8")).version;
8
11
 
9
- try {
10
- const installed = resolveInstalledBinary({
11
- spec,
12
- fallbackRoot: DEFAULT_FALLBACK_ROOT,
13
- });
14
- if (!installed) throw new Error("missing binary");
12
+ async function run() {
13
+ if (!spec) {
14
+ console.error("Error: Unsupported platform.");
15
+ process.exit(1);
16
+ }
17
+
18
+ let installed = resolveInstalledBinary({ spec, fallbackRoot: DEFAULT_FALLBACK_ROOT });
19
+
20
+ if (installed) {
21
+ try {
22
+ const binaryVersion = execFileSync(installed.binPath, ["--version"], {
23
+ stdio: ["ignore", "pipe", "ignore"],
24
+ encoding: "utf-8",
25
+ timeout: 5000,
26
+ }).trim();
27
+ // If launcher package has a real version (not placeholder) and binary differs, force update
28
+ if (expectedVersion !== "0.1.0" && binaryVersion && !binaryVersion.includes(expectedVersion)) {
29
+ installed = await ensureInstalledBinary({ spec, version: expectedVersion, fallbackRoot: DEFAULT_FALLBACK_ROOT, force: true });
30
+ }
31
+ } catch {
32
+ installed = await ensureInstalledBinary({ spec, version: expectedVersion, fallbackRoot: DEFAULT_FALLBACK_ROOT, force: true });
33
+ }
34
+ } else {
35
+ installed = await ensureInstalledBinary({ spec, version: expectedVersion, fallbackRoot: DEFAULT_FALLBACK_ROOT });
36
+ }
37
+
38
+ if (!installed) {
39
+ console.error(`Error: Platform binary not found (${spec.packageName}).`);
40
+ console.error("Fix: npm install -g @clickzetta/cz-cli@latest --ignore-scripts=false");
41
+ process.exit(1);
42
+ }
15
43
 
16
44
  execFileSync(installed.binPath, process.argv.slice(2), { stdio: "inherit", env: process.env });
17
- } catch (e) {
18
- if (e.status !== undefined) process.exit(e.status);
19
- console.error(`Error: Platform binary not found (${spec ? spec.packageName : "unsupported-platform"}).`);
20
- console.error("Fix: reinstall with npm so postinstall can repair the platform binary from npm registry");
21
- console.error(" npm install -g @clickzetta/cz-cli@latest --ignore-scripts=false");
22
- console.error("If this still fails, check npm config for omit=optional / optional=false and registry access.");
23
- process.exit(1);
24
45
  }
46
+
47
+ run().catch((e) => {
48
+ if (e && e.status !== undefined) process.exit(e.status);
49
+ console.error(`Error: ${e && e.message ? e.message : e}`);
50
+ console.error("Fix: npm install -g @clickzetta/cz-cli@latest --ignore-scripts=false");
51
+ process.exit(1);
52
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickzetta/cz-cli",
3
- "version": "0.3.52",
3
+ "version": "0.3.53",
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.52",
16
- "@clickzetta/cz-cli-darwin-x64": "0.3.52",
17
- "@clickzetta/cz-cli-linux-arm64": "0.3.52",
18
- "@clickzetta/cz-cli-linux-x64": "0.3.52",
19
- "@clickzetta/cz-cli-win32-x64": "0.3.52"
15
+ "@clickzetta/cz-cli-darwin-arm64": "0.3.53",
16
+ "@clickzetta/cz-cli-darwin-x64": "0.3.53",
17
+ "@clickzetta/cz-cli-linux-arm64": "0.3.53",
18
+ "@clickzetta/cz-cli-linux-x64": "0.3.53",
19
+ "@clickzetta/cz-cli-win32-x64": "0.3.53"
20
20
  },
21
21
  "license": "MIT",
22
22
  "repository": {