ocx-cursor 0.3.0 → 0.3.2

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.
@@ -112,7 +112,7 @@ async function main() {
112
112
  }
113
113
  if (command === "update") {
114
114
  process.stdout.write("Updating OpenCodex Cursor Bridge from npm...\n");
115
- updateService();
115
+ await updateService();
116
116
  return;
117
117
  }
118
118
  if (command === "sync") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ocx-cursor",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "OpenCodex companion service for Cursor custom models",
5
5
  "keywords": [
6
6
  "opencodex",
package/src/install.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { randomBytes } from "node:crypto";
3
- import { access, chmod, copyFile, cp, lstat, mkdir, readFile, readlink, rename, rm, symlink, writeFile } from "node:fs/promises";
4
- import { dirname, join, resolve } from "node:path";
3
+ import { access, chmod, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readlink, rename, rm, symlink, writeFile } from "node:fs/promises";
4
+ import { tmpdir } from "node:os";
5
+ import { dirname, join, relative, resolve, sep } from "node:path";
5
6
  import { fileURLToPath } from "node:url";
6
7
  import {
7
8
  cliLinkFile,
@@ -97,13 +98,18 @@ export async function prepareInstallSecret() {
97
98
  };
98
99
  }
99
100
 
101
+ export function shouldCopyPackagePath(source, packageRoot = sourcePackageRoot) {
102
+ const segments = relative(packageRoot, source).split(sep);
103
+ return !segments.includes("node_modules") && !segments.includes(".git");
104
+ }
105
+
100
106
  async function copyPackage() {
101
107
  if (resolve(sourcePackageRoot) === resolve(installedPackageRoot)) return;
102
108
  const temporary = `${installedPackageRoot}.tmp-${process.pid}`;
103
109
  await rm(temporary, { recursive: true, force: true });
104
110
  await cp(sourcePackageRoot, temporary, {
105
111
  recursive: true,
106
- filter: (source) => !source.includes("/node_modules/") && !source.includes("/.git/"),
112
+ filter: (source) => shouldCopyPackagePath(source),
107
113
  });
108
114
  await rm(installedPackageRoot, { recursive: true, force: true });
109
115
  await rename(temporary, installedPackageRoot);
@@ -176,16 +182,22 @@ export async function installService() {
176
182
  return { installRoot, launchAgentFile, cliLinkFile, secretStatus };
177
183
  }
178
184
 
179
- export function updateService(options = {}) {
185
+ export async function updateService(options = {}) {
180
186
  const execute = options.execFileSync || execFileSync;
181
- execute(options.npmCommand || "npm", [
182
- "exec",
183
- "--yes",
184
- "--package=ocx-cursor@latest",
185
- "--",
186
- "ocx-cursor",
187
- "install",
188
- ], { stdio: "inherit" });
187
+ const ownsTemporaryDirectory = !options.temporaryDirectory;
188
+ const temporaryDirectory = options.temporaryDirectory || await mkdtemp(join(tmpdir(), "ocx-cursor-update-"));
189
+ try {
190
+ execute(options.npmCommand || "npm", [
191
+ "exec",
192
+ "--yes",
193
+ "--package=ocx-cursor@latest",
194
+ "--",
195
+ "ocx-cursor",
196
+ "install",
197
+ ], { cwd: temporaryDirectory, stdio: "inherit" });
198
+ } finally {
199
+ if (ownsTemporaryDirectory) await rm(temporaryDirectory, { recursive: true, force: true });
200
+ }
189
201
  }
190
202
 
191
203
  export async function uninstallService() {