nero-review 0.1.3 → 0.1.4
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/cli/runCommand.js +2 -0
- package/dist/helper/ui/assertEnvironment.js +8 -0
- package/dist/index.js +20 -4
- package/dist/update.js +15 -13
- package/package.json +3 -2
package/dist/cli/runCommand.js
CHANGED
|
@@ -9,9 +9,11 @@ import { formatReview } from "../printer/formatReview.js";
|
|
|
9
9
|
import { PrettyPrinter } from "../printer/PrettyPrinter.js";
|
|
10
10
|
import { step } from "./loader.js";
|
|
11
11
|
import { theme } from "../helper/ui/theme.js";
|
|
12
|
+
import { assertEnvironment } from "../helper/ui/assertEnvironment.js";
|
|
12
13
|
export async function runCommand(args) {
|
|
13
14
|
const filePath = args;
|
|
14
15
|
try {
|
|
16
|
+
await assertEnvironment();
|
|
15
17
|
await assertFile(filePath);
|
|
16
18
|
const readStep = step(theme.muted(" Reading file")).start();
|
|
17
19
|
const fileMetadata = await readFileContent(filePath);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function assertEnvironment() {
|
|
2
|
+
if (!process.env.NERO_API_KEY) {
|
|
3
|
+
throw new Error("NERO_API_KEY is not set.\nRun `nero-review --help` for setup instructions.");
|
|
4
|
+
}
|
|
5
|
+
if (!process.env.NERO_MODEL) {
|
|
6
|
+
throw new Error("NERO_MODEL is not set.\nRun `nero-review --help` for setup instructions.");
|
|
7
|
+
}
|
|
8
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "dotenv/config";
|
|
3
3
|
import { runCommand } from "./cli/runCommand.js";
|
|
4
|
-
import {
|
|
4
|
+
import { checkForUpdate } from "./update.js";
|
|
5
5
|
import { options } from "./cli/options.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { CLI_NAME, CLI_VERSION } from "./meta.js";
|
|
7
|
+
import { theme } from "./helper/ui/theme.js";
|
|
8
|
+
const opts = options(); // { filePath: string }
|
|
9
|
+
// Fire-and-forget update check
|
|
10
|
+
let updateMessage = null;
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
try {
|
|
13
|
+
const latest = checkForUpdate(CLI_NAME, CLI_VERSION);
|
|
14
|
+
if (latest) {
|
|
15
|
+
updateMessage = `Update available: ${CLI_VERSION} → ${latest}\nRun npm i -g nero-review`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch { }
|
|
19
|
+
}, 0);
|
|
20
|
+
// Main execution (never blocked)
|
|
21
|
+
await runCommand(opts.filePath);
|
|
22
|
+
if (updateMessage) {
|
|
23
|
+
console.log("\n" + theme.muted(updateMessage));
|
|
24
|
+
}
|
package/dist/update.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
export function checkForUpdate(pkgName, currentVersion) {
|
|
4
|
+
try {
|
|
5
|
+
const latest = execSync(`npm view ${pkgName} version`, {
|
|
6
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
7
|
+
encoding: "utf8",
|
|
8
|
+
}).trim();
|
|
9
|
+
if (semver.lt(currentVersion, latest)) {
|
|
10
|
+
return latest;
|
|
11
|
+
}
|
|
12
|
+
return latest ?? null;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
14
16
|
}
|
|
15
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nero-review",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Review code directly from your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,10 +52,11 @@
|
|
|
52
52
|
"commander": "^14.0.2",
|
|
53
53
|
"dotenv": "^17.2.3",
|
|
54
54
|
"ora": "^9.0.0",
|
|
55
|
-
"
|
|
55
|
+
"semver": "^7.7.3"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/node": "^25.0.3",
|
|
59
|
+
"@types/semver": "^7.7.1",
|
|
59
60
|
"@types/update-notifier": "^6.0.8",
|
|
60
61
|
"tsx": "^4.21.0",
|
|
61
62
|
"typescript": "^5.9.3"
|