@kairainy/ck 0.1.23 → 0.1.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kairainy/ck",
3
- "version": "0.1.23",
3
+ "version": "0.1.52",
4
4
  "description": "npm wrapper for the Code Knowledge Graph CLI (ck)",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -100,6 +100,21 @@ async function downloadRelease() {
100
100
  // 3. Fallback: CodeKnowledge Live Portal CDN/API
101
101
  candidates.push(`https://codeknowledge.io.vn/downloads/${archive}`);
102
102
 
103
+ // macOS: also try Universal2 binary as candidate fallback
104
+ if (process.platform === "darwin") {
105
+ const univArchive = "ck-universal2-apple-darwin.tar.gz";
106
+ candidates.push(`${base}/download/v${version}/${univArchive}`);
107
+ candidates.push(`${base}/latest/download/${univArchive}`);
108
+ candidates.push(`https://codeknowledge.io.vn/downloads/${univArchive}`);
109
+ }
110
+
111
+ // Proactively remove stale binary before download to ensure no old version is retained
112
+ if (fs.existsSync(dest)) {
113
+ try {
114
+ fs.rmSync(dest, { force: true });
115
+ } catch (_) {}
116
+ }
117
+
103
118
  const tmpDir = fs.mkdtempSync(path.join(require("node:os").tmpdir(), "ck-npm-"));
104
119
  const archivePath = path.join(tmpDir, archive);
105
120
 
@@ -158,6 +173,17 @@ async function downloadRelease() {
158
173
  fs.copyFileSync(found, dest);
159
174
  if (!isWin) fs.chmodSync(dest, 0o755);
160
175
  console.log(`[ck] Installed → ${dest}`);
176
+
177
+ // Verify installed version matches package.json
178
+ try {
179
+ const out = execFileSync(dest, ["--version"], { encoding: "utf8" }).trim();
180
+ console.log(`[ck] Verified: ${out}`);
181
+ if (!out.includes(version)) {
182
+ console.warn(`[ck] Note: Installed binary reports '${out}', expected 'ck ${version}'.`);
183
+ }
184
+ } catch (e) {
185
+ console.warn(`[ck] Note: could not verify ${dest} --version: ${e.message}`);
186
+ }
161
187
  } finally {
162
188
  fs.rmSync(tmpDir, { recursive: true, force: true });
163
189
  }
@@ -185,10 +211,13 @@ async function main() {
185
211
  await downloadRelease();
186
212
  } catch (err) {
187
213
  if (fs.existsSync(dest)) {
188
- console.warn(
189
- `[ck] Release download failed; using bundled binary.\n${err.message}`
190
- );
191
- return;
214
+ try {
215
+ const out = execFileSync(dest, ["--version"], { encoding: "utf8" }).trim();
216
+ if (out.includes(version)) {
217
+ console.log(`[ck] Existing binary matches requested version (${out}).`);
218
+ return;
219
+ }
220
+ } catch (_) {}
192
221
  }
193
222
  throw err;
194
223
  }