@eve-horizon/cli 0.2.39 → 0.2.41
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/dist/index.js +53 -20
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -62220,7 +62220,7 @@ var import_child_process = require("child_process");
|
|
|
62220
62220
|
var import_util4 = require("util");
|
|
62221
62221
|
var execFileAsync = (0, import_util4.promisify)(import_child_process.execFile);
|
|
62222
62222
|
|
|
62223
|
-
//
|
|
62223
|
+
// ../shared/dist/log-normalize.js
|
|
62224
62224
|
function normalizeLogLine(line) {
|
|
62225
62225
|
const kind = line.kind;
|
|
62226
62226
|
const raw = line.raw;
|
|
@@ -67380,32 +67380,46 @@ async function resolveGitRef(context2, projectId, ref, repoDir) {
|
|
|
67380
67380
|
return ref;
|
|
67381
67381
|
}
|
|
67382
67382
|
const resolvedRepoDir = repoDir ?? getGitRoot();
|
|
67383
|
-
|
|
67384
|
-
|
|
67385
|
-
`Failed to resolve git ref '${ref}': not in a git repository.
|
|
67386
|
-
Run the command from the project repository, pass --repo-dir <path>, or use a 40-character SHA.`
|
|
67387
|
-
);
|
|
67388
|
-
}
|
|
67383
|
+
let useLocal = !!resolvedRepoDir;
|
|
67384
|
+
let projectRepoUrl;
|
|
67389
67385
|
if (projectId) {
|
|
67390
67386
|
const project = await requestJson(context2, `/projects/${projectId}`);
|
|
67387
|
+
projectRepoUrl = project.repo_url;
|
|
67391
67388
|
const expected = normalizeRepoIdentity(project.repo_url);
|
|
67392
|
-
const actual = normalizeRepoIdentity(getGitOriginUrl(resolvedRepoDir));
|
|
67393
|
-
const repoDirIdentity = normalizeRepoIdentity(resolvedRepoDir);
|
|
67389
|
+
const actual = resolvedRepoDir ? normalizeRepoIdentity(getGitOriginUrl(resolvedRepoDir)) : null;
|
|
67390
|
+
const repoDirIdentity = resolvedRepoDir ? normalizeRepoIdentity(resolvedRepoDir) : null;
|
|
67394
67391
|
if (expected && actual && expected !== actual) {
|
|
67395
|
-
|
|
67396
|
-
`Failed to resolve git ref '${ref}': current repo does not match project repo.
|
|
67397
|
-
Project repo: ${project.repo_url}
|
|
67398
|
-
Current repo: ${getGitOriginUrl(resolvedRepoDir)}
|
|
67399
|
-
Run the command from the project repository, pass --repo-dir <path>, or use a 40-character SHA.`
|
|
67400
|
-
);
|
|
67392
|
+
useLocal = false;
|
|
67401
67393
|
}
|
|
67402
67394
|
if (expected && !actual && (!repoDirIdentity || repoDirIdentity !== expected)) {
|
|
67403
|
-
|
|
67404
|
-
|
|
67405
|
-
|
|
67406
|
-
|
|
67407
|
-
|
|
67395
|
+
useLocal = false;
|
|
67396
|
+
}
|
|
67397
|
+
}
|
|
67398
|
+
if (useLocal && resolvedRepoDir) {
|
|
67399
|
+
try {
|
|
67400
|
+
return (0, import_node_child_process5.execSync)(`git rev-parse ${ref}`, {
|
|
67401
|
+
cwd: resolvedRepoDir,
|
|
67402
|
+
encoding: "utf-8",
|
|
67403
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
67404
|
+
}).trim();
|
|
67405
|
+
} catch {
|
|
67406
|
+
}
|
|
67407
|
+
}
|
|
67408
|
+
if (projectRepoUrl) {
|
|
67409
|
+
const sha = resolveRefRemote(projectRepoUrl, ref);
|
|
67410
|
+
if (sha) {
|
|
67411
|
+
return sha;
|
|
67408
67412
|
}
|
|
67413
|
+
throw new Error(
|
|
67414
|
+
`Failed to resolve git ref '${ref}' against remote '${projectRepoUrl}'.
|
|
67415
|
+
Make sure the ref (branch or tag) exists in the remote repository, or use a 40-character SHA.`
|
|
67416
|
+
);
|
|
67417
|
+
}
|
|
67418
|
+
if (!resolvedRepoDir) {
|
|
67419
|
+
throw new Error(
|
|
67420
|
+
`Failed to resolve git ref '${ref}': not in a git repository.
|
|
67421
|
+
Run the command from the project repository, pass --repo-dir <path>, or use a 40-character SHA.`
|
|
67422
|
+
);
|
|
67409
67423
|
}
|
|
67410
67424
|
try {
|
|
67411
67425
|
return (0, import_node_child_process5.execSync)(`git rev-parse ${ref}`, {
|
|
@@ -67470,6 +67484,25 @@ function resolveGitBranch(repoDir, ref) {
|
|
|
67470
67484
|
return null;
|
|
67471
67485
|
}
|
|
67472
67486
|
}
|
|
67487
|
+
function resolveRefRemote(repoUrl, ref) {
|
|
67488
|
+
try {
|
|
67489
|
+
const output = (0, import_node_child_process5.execSync)(`git ls-remote ${repoUrl} ${ref}`, {
|
|
67490
|
+
encoding: "utf-8",
|
|
67491
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
67492
|
+
timeout: 15e3
|
|
67493
|
+
}).trim();
|
|
67494
|
+
for (const line of output.split("\n")) {
|
|
67495
|
+
const [sha, refName] = line.split(" ");
|
|
67496
|
+
if (!sha || !refName) continue;
|
|
67497
|
+
if (refName === `refs/heads/${ref}` || refName === `refs/tags/${ref}` || refName === ref) {
|
|
67498
|
+
return sha;
|
|
67499
|
+
}
|
|
67500
|
+
}
|
|
67501
|
+
return null;
|
|
67502
|
+
} catch {
|
|
67503
|
+
return null;
|
|
67504
|
+
}
|
|
67505
|
+
}
|
|
67473
67506
|
function getGitOriginUrl(repoDir) {
|
|
67474
67507
|
try {
|
|
67475
67508
|
const url = (0, import_node_child_process5.execSync)("git config --get remote.origin.url", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eve-horizon/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.41",
|
|
4
4
|
"description": "Eve Horizon CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"assets",
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "rm -rf dist && esbuild src/index.ts --bundle --platform=node --target=node22 --outfile=dist/index.js --format=cjs --external:yaml"
|
|
23
|
-
},
|
|
24
21
|
"publishConfig": {
|
|
25
22
|
"access": "public"
|
|
26
23
|
},
|
|
@@ -31,11 +28,14 @@
|
|
|
31
28
|
"yaml": "^2.5.1"
|
|
32
29
|
},
|
|
33
30
|
"devDependencies": {
|
|
34
|
-
"@eve/migrate": "workspace:*",
|
|
35
|
-
"@eve/shared": "workspace:*",
|
|
36
31
|
"@types/node": "^22.0.0",
|
|
37
32
|
"esbuild": "^0.27.3",
|
|
38
33
|
"postgres": "^3.4.0",
|
|
39
|
-
"typescript": "^5.7.0"
|
|
34
|
+
"typescript": "^5.7.0",
|
|
35
|
+
"@eve/migrate": "0.0.1",
|
|
36
|
+
"@eve/shared": "0.0.1"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "rm -rf dist && esbuild src/index.ts --bundle --platform=node --target=node22 --outfile=dist/index.js --format=cjs --external:yaml"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|