sidecarsync 1.1.0 → 1.2.0
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/README.md +1 -1
- package/dist/cli.js +23 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ Sidecar takes over branch management there —
|
|
|
86
86
|
- [Standalone repos](docs/standalone.md) — a repo that is its own sidecar
|
|
87
87
|
- [Redaction](docs/redaction.md) — what's stripped from pushes, reviewing it, opting out
|
|
88
88
|
- [Editor search visibility](docs/editors.md) — making gitignored files searchable
|
|
89
|
-
- [Global vs local installs](docs/install.md) —
|
|
89
|
+
- [Global vs local installs](docs/install.md) — the newest install wins
|
|
90
90
|
- [All commands](docs/commands.md)
|
|
91
91
|
- [Uninstall & troubleshooting](docs/uninstall.md) — removing the daemon, service, and state
|
|
92
92
|
|
package/dist/cli.js
CHANGED
|
@@ -238,6 +238,15 @@ function projectDependsOnSidecar(projectRoot) {
|
|
|
238
238
|
return false;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
+
function installedPackageVersion(projectRoot) {
|
|
242
|
+
const manifestPath = path2.join(projectRoot, "node_modules", PACKAGE_NAME, "package.json");
|
|
243
|
+
try {
|
|
244
|
+
const manifest = JSON.parse(fs2.readFileSync(manifestPath, "utf8"));
|
|
245
|
+
return manifest.name === PACKAGE_NAME ? manifest.version : undefined;
|
|
246
|
+
} catch {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
241
250
|
function shouldUseGlobalRegistry() {
|
|
242
251
|
return process.env[GLOBAL_EXEC_ENV] === "1" || !findDependencyRoot(process.cwd());
|
|
243
252
|
}
|
|
@@ -4175,10 +4184,9 @@ function localSidecarCliPath(root) {
|
|
|
4175
4184
|
const candidate = path9.join(root, "node_modules", PACKAGE_NAME, "dist", "cli.js");
|
|
4176
4185
|
if (!isFile(candidate))
|
|
4177
4186
|
return;
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
} catch {}
|
|
4187
|
+
const localVersion = installedPackageVersion(root);
|
|
4188
|
+
if (localVersion === undefined || compareVersions(localVersion, packageVersion()) <= 0)
|
|
4189
|
+
return;
|
|
4182
4190
|
return candidate;
|
|
4183
4191
|
}
|
|
4184
4192
|
function currentCliPath() {
|
|
@@ -5098,12 +5106,11 @@ var GLOBAL_EXEC_ENV3 = "SIDECAR_GLOBAL_EXEC";
|
|
|
5098
5106
|
var PACKAGE_NAME2 = "sidecarsync";
|
|
5099
5107
|
var GLOBAL_ONLY_COMMANDS = new Set(["daemon", "deinit", "register-install", "set-install-source", "update"]);
|
|
5100
5108
|
if (!process.env[SKIP_LOCAL_EXEC_ENV3]) {
|
|
5101
|
-
const
|
|
5102
|
-
if (
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
const result = spawnSync5(process.execPath, [localExecutable, ...process.argv.slice(2)], {
|
|
5109
|
+
const local = findLocalInstall(process.cwd(), fileURLToPath4(import.meta.url));
|
|
5110
|
+
if (local) {
|
|
5111
|
+
process.env[GLOBAL_EXEC_ENV3] = "1";
|
|
5112
|
+
if (local.newer && !GLOBAL_ONLY_COMMANDS.has(process.argv[2])) {
|
|
5113
|
+
const result = spawnSync5(process.execPath, [local.executable, ...process.argv.slice(2)], {
|
|
5107
5114
|
stdio: "inherit",
|
|
5108
5115
|
env: {
|
|
5109
5116
|
...process.env,
|
|
@@ -5119,13 +5126,13 @@ if (!process.env[SKIP_LOCAL_EXEC_ENV3]) {
|
|
|
5119
5126
|
}
|
|
5120
5127
|
}
|
|
5121
5128
|
process.exit(await main());
|
|
5122
|
-
function
|
|
5129
|
+
function findLocalInstall(start, self) {
|
|
5123
5130
|
let current = path11.resolve(start);
|
|
5124
5131
|
while (true) {
|
|
5125
5132
|
if (projectDependsOnSidecar2(current)) {
|
|
5126
5133
|
const candidate = path11.join(current, "node_modules", PACKAGE_NAME2, "dist", "cli.js");
|
|
5127
5134
|
if (isFile2(candidate) && !sameFile(candidate, self)) {
|
|
5128
|
-
return candidate;
|
|
5135
|
+
return { executable: candidate, newer: localIsNewer(current) };
|
|
5129
5136
|
}
|
|
5130
5137
|
}
|
|
5131
5138
|
const parent = path11.dirname(current);
|
|
@@ -5134,6 +5141,10 @@ function findLocalExecutable(start, self) {
|
|
|
5134
5141
|
current = parent;
|
|
5135
5142
|
}
|
|
5136
5143
|
}
|
|
5144
|
+
function localIsNewer(projectRoot) {
|
|
5145
|
+
const localVersion = installedPackageVersion(projectRoot);
|
|
5146
|
+
return localVersion !== undefined && compareVersions(localVersion, packageVersion()) > 0;
|
|
5147
|
+
}
|
|
5137
5148
|
function projectDependsOnSidecar2(projectRoot) {
|
|
5138
5149
|
const manifestPath = path11.join(projectRoot, "package.json");
|
|
5139
5150
|
if (!isFile2(manifestPath))
|