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.
- package/bin/ocx-cursor.mjs +1 -1
- package/package.json +1 -1
- package/src/install.mjs +24 -12
package/bin/ocx-cursor.mjs
CHANGED
package/package.json
CHANGED
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 {
|
|
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) =>
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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() {
|