mateooo93-cortex 0.25.21 → 0.25.23
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 +35 -7
- package/lib/install.js +2 -0
- package/lib/path-check.js +109 -0
- package/lib/run.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
# mateooo93
|
|
1
|
+
# @mateooo93/cortex (npm)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
npm wrapper that downloads the native `cortex` binary for your OS on `postinstall`.
|
|
4
4
|
|
|
5
|
-
> **Note:** The
|
|
5
|
+
> **Note:** The package `cortex-cli` on npmjs.org is a different product (CognitiveScale). Use `@mateooo93/cortex`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @mateooo93/cortex --registry=https://npm.pkg.github.com
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or set the scope once in `~/.npmrc`:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
@mateooo93:registry=https://npm.pkg.github.com
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g @mateooo93/cortex
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The global `cortex` command must point at `.../node_modules/@mateooo93/cortex/shims/cortex.js` (or your package manager's global bin shim).
|
|
26
|
+
|
|
27
|
+
## Publish (maintainers)
|
|
28
|
+
|
|
29
|
+
**GitHub Packages** (default — uses `GITHUB_TOKEN` in Actions):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
./script/publish-npm.sh v0.25.19 --yes
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**npmjs.org** (optional legacy `mateooo93-cortex` — requires npm Automation token):
|
|
6
36
|
|
|
7
37
|
```bash
|
|
8
|
-
npm
|
|
9
|
-
npm install -g mateooo93-cortex
|
|
10
|
-
cortex
|
|
38
|
+
./script/publish-npm.sh v0.25.19 --yes --registry npmjs
|
|
11
39
|
```
|
|
12
40
|
|
|
13
|
-
|
|
41
|
+
After the first GitHub Packages publish, set the package visibility to **Public** under the repo's **Packages** tab so anyone can install without a token.
|
package/lib/install.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require("fs");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
|
|
6
6
|
const { downloadBinary } = require("./download");
|
|
7
|
+
const { warnIfShadowed } = require("./path-check");
|
|
7
8
|
const { resolveAsset } = require("./platform");
|
|
8
9
|
const { cacheDir, readPackageVersion, releaseBase } = require("./paths");
|
|
9
10
|
|
|
@@ -51,6 +52,7 @@ async function main() {
|
|
|
51
52
|
if (dest) {
|
|
52
53
|
console.log(`cortex-cli: installed native binary to ${dest}`);
|
|
53
54
|
}
|
|
55
|
+
warnIfShadowed();
|
|
54
56
|
} catch (err) {
|
|
55
57
|
console.error(`cortex-cli: postinstall failed: ${err.message}`);
|
|
56
58
|
process.exit(1);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { execSync } = require("child_process");
|
|
6
|
+
|
|
7
|
+
const CONFLICT_MARKERS = [
|
|
8
|
+
"cortex-cli/bin/cortex",
|
|
9
|
+
"node_modules/cortex-cli/",
|
|
10
|
+
"CognitiveScale",
|
|
11
|
+
"cortex actions",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function npmGlobalBin() {
|
|
15
|
+
try {
|
|
16
|
+
const prefix = execSync("npm prefix -g", {
|
|
17
|
+
encoding: "utf8",
|
|
18
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
19
|
+
}).trim();
|
|
20
|
+
return path.join(prefix, "bin", "cortex");
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function pathEntries() {
|
|
27
|
+
return (process.env.PATH || "")
|
|
28
|
+
.split(path.delimiter)
|
|
29
|
+
.map((entry) => entry.trim())
|
|
30
|
+
.filter(Boolean);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function resolveCortexOnPath() {
|
|
34
|
+
for (const dir of pathEntries()) {
|
|
35
|
+
const candidate = path.join(dir, process.platform === "win32" ? "cortex.cmd" : "cortex");
|
|
36
|
+
if (!fs.existsSync(candidate)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return fs.realpathSync(candidate);
|
|
41
|
+
} catch {
|
|
42
|
+
return candidate;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function looksLikeCognitiveScale(target) {
|
|
49
|
+
if (!target) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const normalized = target.replace(/\\/g, "/");
|
|
53
|
+
if (CONFLICT_MARKERS.some((marker) => normalized.includes(marker))) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (normalized.endsWith("/shims/cortex.js")) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (normalized.includes("/mateooo93-cortex/") || normalized.includes("/@mateooo93/cortex/")) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (normalized.includes("/.cortex/npm/")) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
// Heuristic: CognitiveScale ships a cortex.js launcher, not our shim layout.
|
|
66
|
+
if (
|
|
67
|
+
normalized.endsWith("/cortex.js") &&
|
|
68
|
+
!normalized.includes("mateooo93-cortex") &&
|
|
69
|
+
!normalized.includes("@mateooo93/cortex")
|
|
70
|
+
) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function warnIfShadowed() {
|
|
77
|
+
const shimPath = npmGlobalBin();
|
|
78
|
+
const firstOnPath = resolveCortexOnPath();
|
|
79
|
+
|
|
80
|
+
if (!shimPath || !firstOnPath) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let same = false;
|
|
85
|
+
try {
|
|
86
|
+
same = fs.realpathSync(shimPath) === fs.realpathSync(firstOnPath);
|
|
87
|
+
} catch {
|
|
88
|
+
same = shimPath === firstOnPath;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (same || !looksLikeCognitiveScale(firstOnPath)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.warn("");
|
|
96
|
+
console.warn("cortex-cli: another `cortex` command comes first on your PATH:");
|
|
97
|
+
console.warn(` ${firstOnPath}`);
|
|
98
|
+
console.warn(`@mateooo93/cortex shim: ${shimPath}`);
|
|
99
|
+
console.warn("");
|
|
100
|
+
console.warn("Remove the conflicting CognitiveScale CLI, then open a new terminal:");
|
|
101
|
+
console.warn(" npm uninstall -g cortex-cli");
|
|
102
|
+
console.warn(" bun remove -g cortex-cli # if installed via bun");
|
|
103
|
+
console.warn("");
|
|
104
|
+
console.warn("Or run this package directly until PATH is fixed:");
|
|
105
|
+
console.warn(` ${shimPath}`);
|
|
106
|
+
console.warn("");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = { warnIfShadowed, resolveCortexOnPath, looksLikeCognitiveScale };
|
package/lib/run.js
CHANGED
|
@@ -4,6 +4,7 @@ const { spawn } = require("child_process");
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
|
|
6
6
|
const { ensureBinary } = require("./install");
|
|
7
|
+
const { name: packageName } = require("../package.json");
|
|
7
8
|
|
|
8
9
|
async function main() {
|
|
9
10
|
let binaryPath;
|
|
@@ -16,14 +17,14 @@ async function main() {
|
|
|
16
17
|
|
|
17
18
|
if (!binaryPath || !fs.existsSync(binaryPath)) {
|
|
18
19
|
console.error(
|
|
19
|
-
|
|
20
|
+
`cortex-cli: native binary not installed. Re-run: npm install -g ${packageName} --registry=https://npm.pkg.github.com`
|
|
20
21
|
);
|
|
21
22
|
process.exit(1);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const env = {
|
|
25
26
|
...process.env,
|
|
26
|
-
CORTEX_NPM_PACKAGE:
|
|
27
|
+
CORTEX_NPM_PACKAGE: packageName,
|
|
27
28
|
CORTEX_NPM_SHIM: __filename,
|
|
28
29
|
};
|
|
29
30
|
|
package/package.json
CHANGED