@novastorm-ai/cli 0.0.7 → 0.0.9
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)
|
|
@@ -927,13 +939,13 @@ async function startCommand() {
|
|
|
927
939
|
if (config.telemetry.enabled && process.env["NOVA_TELEMETRY"] !== "false") {
|
|
928
940
|
const { createHash: createHash2 } = await import("crypto");
|
|
929
941
|
const os = await import("os");
|
|
930
|
-
const { execFile:
|
|
942
|
+
const { execFile: execFile4 } = await import("child_process");
|
|
931
943
|
const mac = Object.values(os.networkInterfaces()).flat().find((i) => !i?.internal && i?.mac !== "00:00:00:00:00:00")?.mac ?? "";
|
|
932
944
|
const machineId = createHash2("sha256").update(os.hostname() + os.userInfo().username + mac).digest("hex");
|
|
933
945
|
let projectHash;
|
|
934
946
|
try {
|
|
935
947
|
const remoteUrl = await new Promise((resolve4, reject) => {
|
|
936
|
-
|
|
948
|
+
execFile4("git", ["remote", "get-url", "origin"], { cwd }, (err, stdout3) => {
|
|
937
949
|
if (err) reject(err);
|
|
938
950
|
else resolve4(stdout3.trim());
|
|
939
951
|
});
|
|
@@ -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-RIMA2PN2.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);
|
|
@@ -2117,6 +2148,40 @@ async function checkForUpdates(currentVersion) {
|
|
|
2117
2148
|
}
|
|
2118
2149
|
}
|
|
2119
2150
|
|
|
2151
|
+
// src/commands/uninstall.ts
|
|
2152
|
+
import { execFile as execFile3 } from "child_process";
|
|
2153
|
+
import chalk11 from "chalk";
|
|
2154
|
+
import ora4 from "ora";
|
|
2155
|
+
var PKG_NAME2 = "@novastorm-ai/cli";
|
|
2156
|
+
function runCommand(cmd, args) {
|
|
2157
|
+
return new Promise((resolve4) => {
|
|
2158
|
+
execFile3(cmd, args, { timeout: 3e4 }, (error, stdout3, stderr) => {
|
|
2159
|
+
if (error) {
|
|
2160
|
+
resolve4({ ok: false, output: stderr || error.message });
|
|
2161
|
+
} else {
|
|
2162
|
+
resolve4({ ok: true, output: stdout3 });
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
async function uninstallCommand() {
|
|
2168
|
+
const spinner = ora4("Uninstalling Novastorm CLI...").start();
|
|
2169
|
+
let result = await runCommand("npm", ["uninstall", "-g", PKG_NAME2]);
|
|
2170
|
+
if (!result.ok) {
|
|
2171
|
+
result = await runCommand("pnpm", ["uninstall", "-g", PKG_NAME2]);
|
|
2172
|
+
}
|
|
2173
|
+
if (result.ok) {
|
|
2174
|
+
spinner.succeed("Novastorm CLI uninstalled.");
|
|
2175
|
+
console.log(chalk11.gray("\n Thanks for trying Novastorm."));
|
|
2176
|
+
console.log(chalk11.gray(` Feedback? ${chalk11.cyan("https://github.com/novastorm-cli/nova/issues")}`));
|
|
2177
|
+
console.log(chalk11.gray(` Come back anytime: ${chalk11.cyan(`npm install -g ${PKG_NAME2}`)}
|
|
2178
|
+
`));
|
|
2179
|
+
} else {
|
|
2180
|
+
spinner.fail("Uninstall failed. Try manually:");
|
|
2181
|
+
console.log(chalk11.cyan(` npm uninstall -g ${PKG_NAME2}`));
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2120
2185
|
// src/index.ts
|
|
2121
2186
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
2122
2187
|
var pkg = JSON.parse(
|
|
@@ -2180,6 +2245,9 @@ function createCli() {
|
|
|
2180
2245
|
program.command("update").description("Update Novastorm CLI to the latest version").action(async () => {
|
|
2181
2246
|
await updateCommand();
|
|
2182
2247
|
});
|
|
2248
|
+
program.command("uninstall").description("Uninstall Novastorm CLI from your system").action(async () => {
|
|
2249
|
+
await uninstallCommand();
|
|
2250
|
+
});
|
|
2183
2251
|
return program;
|
|
2184
2252
|
}
|
|
2185
2253
|
var BANNER = `\x1B[96m
|
|
@@ -2199,8 +2267,16 @@ async function run(argv = process.argv) {
|
|
|
2199
2267
|
const suppressBanner = args.includes("--version") || args.includes("-V") || args.includes("--help") || args.includes("-h");
|
|
2200
2268
|
if (!suppressBanner) {
|
|
2201
2269
|
console.log(BANNER);
|
|
2202
|
-
|
|
2203
|
-
|
|
2270
|
+
const isLocal = !import.meta.url.includes("node_modules");
|
|
2271
|
+
if (isLocal) {
|
|
2272
|
+
console.log("\x1B[43m\x1B[30m LOCAL BUILD \x1B[0m");
|
|
2273
|
+
}
|
|
2274
|
+
console.log(`\x1B[90m v${pkg.version}\x1B[0m
|
|
2275
|
+
`);
|
|
2276
|
+
if (!isLocal) {
|
|
2277
|
+
checkForUpdates(pkg.version).catch(() => {
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2204
2280
|
}
|
|
2205
2281
|
const program = createCli();
|
|
2206
2282
|
await program.parseAsync(argv);
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.9",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"tsup": "^8.4.0",
|
|
37
37
|
"typescript": "^5.7.0",
|
|
38
38
|
"@novastorm-ai/core": "0.0.1",
|
|
39
|
-
"@novastorm-ai/
|
|
40
|
-
"@novastorm-ai/
|
|
39
|
+
"@novastorm-ai/proxy": "0.0.1",
|
|
40
|
+
"@novastorm-ai/licensing": "0.0.1"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsup",
|