@novastorm-ai/cli 0.0.6 → 0.0.8
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/bin/nova.js
CHANGED
|
@@ -38,6 +38,7 @@ import { Command } from "commander";
|
|
|
38
38
|
|
|
39
39
|
// src/commands/start.ts
|
|
40
40
|
import { exec } from "child_process";
|
|
41
|
+
import * as net from "net";
|
|
41
42
|
import * as path from "path";
|
|
42
43
|
import chalk6 from "chalk";
|
|
43
44
|
import ora2 from "ora";
|
|
@@ -878,6 +879,17 @@ Available: ${SETTABLE_FIELDS.map((f) => f.path).join(", ")}`);
|
|
|
878
879
|
|
|
879
880
|
// src/commands/start.ts
|
|
880
881
|
var PROXY_PORT_OFFSET = 1;
|
|
882
|
+
function isPortInUse(port) {
|
|
883
|
+
return new Promise((resolve4) => {
|
|
884
|
+
const server = net.createServer();
|
|
885
|
+
server.once("error", () => resolve4(true));
|
|
886
|
+
server.once("listening", () => {
|
|
887
|
+
server.close();
|
|
888
|
+
resolve4(false);
|
|
889
|
+
});
|
|
890
|
+
server.listen(port, "127.0.0.1");
|
|
891
|
+
});
|
|
892
|
+
}
|
|
881
893
|
function findOverlayScript() {
|
|
882
894
|
const candidates = [
|
|
883
895
|
// From cli/dist/ (when imported as module)
|
|
@@ -943,7 +955,7 @@ async function startCommand() {
|
|
|
943
955
|
projectHash = createHash2("sha256").update(cwd).digest("hex");
|
|
944
956
|
}
|
|
945
957
|
const telemetry = new Telemetry();
|
|
946
|
-
const cliPkg = await import("./package-
|
|
958
|
+
const cliPkg = await import("./package-4SPN5HTE.js").catch(
|
|
947
959
|
() => ({ default: { version: "0.0.1" } })
|
|
948
960
|
);
|
|
949
961
|
telemetry.send({
|
|
@@ -1064,6 +1076,25 @@ ${nudgeMessage}
|
|
|
1064
1076
|
}
|
|
1065
1077
|
const projectMapApi = new ProjectMapApi();
|
|
1066
1078
|
const proxyPort = devPort + PROXY_PORT_OFFSET;
|
|
1079
|
+
spinner.start("Checking ports...");
|
|
1080
|
+
const devPortBusy = await isPortInUse(devPort);
|
|
1081
|
+
const proxyPortBusy = await isPortInUse(proxyPort);
|
|
1082
|
+
if (devPortBusy || proxyPortBusy) {
|
|
1083
|
+
spinner.fail("Port conflict detected:");
|
|
1084
|
+
if (devPortBusy) {
|
|
1085
|
+
console.log(chalk6.red(` \u2717 Port ${devPort} is already in use (dev server)`));
|
|
1086
|
+
console.log(chalk6.gray(` Kill the process: ${chalk6.cyan(`lsof -ti :${devPort} | xargs kill`)}`));
|
|
1087
|
+
}
|
|
1088
|
+
if (proxyPortBusy) {
|
|
1089
|
+
console.log(chalk6.red(` \u2717 Port ${proxyPort} is already in use (proxy)`));
|
|
1090
|
+
console.log(chalk6.gray(` Kill the process: ${chalk6.cyan(`lsof -ti :${proxyPort} | xargs kill`)}`));
|
|
1091
|
+
}
|
|
1092
|
+
console.log(chalk6.gray(`
|
|
1093
|
+
Or change the port in nova.toml: ${chalk6.cyan("port = <number>")}
|
|
1094
|
+
`));
|
|
1095
|
+
process.exit(1);
|
|
1096
|
+
}
|
|
1097
|
+
spinner.succeed("Ports available");
|
|
1067
1098
|
spinner.start(`Starting dev server (${chalk6.dim(devCommand)})...`);
|
|
1068
1099
|
try {
|
|
1069
1100
|
await devServer.spawn(devCommand, cwd, devPort);
|
|
@@ -2018,6 +2049,15 @@ import { execFile as execFile2 } from "child_process";
|
|
|
2018
2049
|
import chalk10 from "chalk";
|
|
2019
2050
|
import ora3 from "ora";
|
|
2020
2051
|
var PKG_NAME = "@novastorm-ai/cli";
|
|
2052
|
+
function isNewer(remote, local) {
|
|
2053
|
+
const r = remote.split(".").map(Number);
|
|
2054
|
+
const l = local.split(".").map(Number);
|
|
2055
|
+
for (let i = 0; i < 3; i++) {
|
|
2056
|
+
if ((r[i] ?? 0) > (l[i] ?? 0)) return true;
|
|
2057
|
+
if ((r[i] ?? 0) < (l[i] ?? 0)) return false;
|
|
2058
|
+
}
|
|
2059
|
+
return false;
|
|
2060
|
+
}
|
|
2021
2061
|
async function getLatestVersion() {
|
|
2022
2062
|
try {
|
|
2023
2063
|
const controller = new AbortController();
|
|
@@ -2066,8 +2106,8 @@ async function updateCommand() {
|
|
|
2066
2106
|
currentVersion = pkg2.version;
|
|
2067
2107
|
} catch {
|
|
2068
2108
|
}
|
|
2069
|
-
if (currentVersion
|
|
2070
|
-
spinner.succeed(`Already on the latest version ${chalk10.green(
|
|
2109
|
+
if (!isNewer(latest, currentVersion)) {
|
|
2110
|
+
spinner.succeed(`Already on the latest version ${chalk10.green(currentVersion)}`);
|
|
2071
2111
|
return;
|
|
2072
2112
|
}
|
|
2073
2113
|
spinner.text = `Updating ${chalk10.gray(currentVersion)} \u2192 ${chalk10.green(latest)}...`;
|
|
@@ -2082,15 +2122,28 @@ async function updateCommand() {
|
|
|
2082
2122
|
}
|
|
2083
2123
|
}
|
|
2084
2124
|
}
|
|
2125
|
+
var updateBannerInterval = null;
|
|
2085
2126
|
async function checkForUpdates(currentVersion) {
|
|
2086
2127
|
try {
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
`)
|
|
2128
|
+
let renderBanner2 = function() {
|
|
2129
|
+
if (!process.stdout.isTTY) return;
|
|
2130
|
+
process.stdout.write(
|
|
2131
|
+
`\x1B7\x1B[${rows};${x}H${msg}\x1B8`
|
|
2092
2132
|
);
|
|
2093
|
-
}
|
|
2133
|
+
};
|
|
2134
|
+
var renderBanner = renderBanner2;
|
|
2135
|
+
const latest = await getLatestVersion();
|
|
2136
|
+
if (!latest || !isNewer(latest, currentVersion)) return;
|
|
2137
|
+
const msg = chalk10.bgYellow.black(` UPDATE `) + chalk10.yellow(` ${currentVersion} \u2192 ${latest} `) + chalk10.gray(`run ${chalk10.cyan("nova update")}`);
|
|
2138
|
+
const columns = process.stdout.columns || 80;
|
|
2139
|
+
const rows = process.stdout.rows || 24;
|
|
2140
|
+
const plain = msg.replace(/\x1b\[[0-9;]*m/g, "");
|
|
2141
|
+
const x = Math.max(columns - plain.length - 1, 0);
|
|
2142
|
+
renderBanner2();
|
|
2143
|
+
updateBannerInterval = setInterval(renderBanner2, 5e3);
|
|
2144
|
+
process.on("exit", () => {
|
|
2145
|
+
if (updateBannerInterval) clearInterval(updateBannerInterval);
|
|
2146
|
+
});
|
|
2094
2147
|
} catch {
|
|
2095
2148
|
}
|
|
2096
2149
|
}
|
|
@@ -2177,8 +2230,16 @@ async function run(argv = process.argv) {
|
|
|
2177
2230
|
const suppressBanner = args.includes("--version") || args.includes("-V") || args.includes("--help") || args.includes("-h");
|
|
2178
2231
|
if (!suppressBanner) {
|
|
2179
2232
|
console.log(BANNER);
|
|
2180
|
-
|
|
2181
|
-
|
|
2233
|
+
const isLocal = !import.meta.url.includes("node_modules");
|
|
2234
|
+
if (isLocal) {
|
|
2235
|
+
console.log("\x1B[43m\x1B[30m LOCAL BUILD \x1B[0m");
|
|
2236
|
+
}
|
|
2237
|
+
console.log(`\x1B[90m v${pkg.version}\x1B[0m
|
|
2238
|
+
`);
|
|
2239
|
+
if (!isLocal) {
|
|
2240
|
+
checkForUpdates(pkg.version).catch(() => {
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2182
2243
|
}
|
|
2183
2244
|
const program = createCli();
|
|
2184
2245
|
await program.parseAsync(argv);
|
package/dist/index.js
CHANGED