@envpilot/cli 1.12.1 → 1.13.0
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.
|
@@ -7,7 +7,7 @@ function initSentry() {
|
|
|
7
7
|
Sentry.init({
|
|
8
8
|
dsn,
|
|
9
9
|
environment: "cli",
|
|
10
|
-
release: true ? "1.
|
|
10
|
+
release: true ? "1.13.0" : "0.0.0",
|
|
11
11
|
// All EnvPilot surfaces report to one Sentry project; the surface tag
|
|
12
12
|
// is how dashboards tell web / cli / extension events apart.
|
|
13
13
|
initialScope: { tags: { surface: "cli" } },
|
|
@@ -463,7 +463,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
463
463
|
async function openTUI() {
|
|
464
464
|
const [{ render }, { CLIApp }, { PressAnyKey }] = await Promise.all([
|
|
465
465
|
import("ink"),
|
|
466
|
-
import("./app-
|
|
466
|
+
import("./app-HOZQ2K3E.js"),
|
|
467
467
|
import("./press-any-key-64XFP4O2.js")
|
|
468
468
|
]);
|
|
469
469
|
while (true) {
|
package/dist/index.js
CHANGED
|
@@ -6,18 +6,17 @@ import {
|
|
|
6
6
|
getTopLevelCommandCatalog,
|
|
7
7
|
initSentry,
|
|
8
8
|
openTUI
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MHAVTX6S.js";
|
|
10
10
|
|
|
11
11
|
// src/lib/program.ts
|
|
12
12
|
import { Command } from "commander";
|
|
13
13
|
|
|
14
14
|
// src/lib/cli-version.ts
|
|
15
|
-
var CLI_VERSION = true ? "1.
|
|
15
|
+
var CLI_VERSION = true ? "1.13.0" : "0.0.0";
|
|
16
16
|
|
|
17
17
|
// src/lib/version-check.ts
|
|
18
18
|
import chalk from "chalk";
|
|
19
19
|
import Conf from "conf";
|
|
20
|
-
var CLI_VERSION2 = true ? "1.12.1" : "0.0.0";
|
|
21
20
|
var CHECK_INTERVAL = 60 * 60 * 1e3;
|
|
22
21
|
var _cache = null;
|
|
23
22
|
function getCache() {
|
|
@@ -29,39 +28,108 @@ function getCache() {
|
|
|
29
28
|
}
|
|
30
29
|
return _cache;
|
|
31
30
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
function compareVersions(a, b) {
|
|
32
|
+
const parse = (v) => v.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
|
|
33
|
+
const pa = parse(a);
|
|
34
|
+
const pb = parse(b);
|
|
35
|
+
for (let i = 0; i < 3; i++) {
|
|
36
|
+
const diff = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
37
|
+
if (diff !== 0) return diff < 0 ? -1 : 1;
|
|
38
|
+
}
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
function evaluateVersion(current, latest, min) {
|
|
42
|
+
const blocked = !!min && compareVersions(current, min) < 0;
|
|
43
|
+
const updateAvailable = !!latest && compareVersions(current, latest) < 0 ? latest : null;
|
|
44
|
+
return { blocked, updateAvailable };
|
|
45
|
+
}
|
|
46
|
+
async function fetchVersionInfo() {
|
|
38
47
|
const controller = new AbortController();
|
|
39
|
-
const timer = setTimeout(() => controller.abort(),
|
|
48
|
+
const timer = setTimeout(() => controller.abort(), 3e3);
|
|
40
49
|
timer.unref?.();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
chalk.dim(CLI_VERSION2),
|
|
51
|
-
chalk.yellow("\u2192"),
|
|
52
|
-
chalk.green(data.cli)
|
|
53
|
-
);
|
|
54
|
-
console.log(
|
|
55
|
-
chalk.dim(" Run"),
|
|
56
|
-
chalk.cyan("npm update -g @envpilot/cli"),
|
|
57
|
-
chalk.dim("to update")
|
|
58
|
-
);
|
|
59
|
-
console.log();
|
|
60
|
-
}
|
|
61
|
-
}).catch(() => {
|
|
62
|
-
}).finally(() => {
|
|
50
|
+
try {
|
|
51
|
+
const res = await fetch(`${getApiUrl()}/api/version`, {
|
|
52
|
+
signal: controller.signal
|
|
53
|
+
});
|
|
54
|
+
if (!res.ok) return null;
|
|
55
|
+
return await res.json();
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
} finally {
|
|
63
59
|
clearTimeout(timer);
|
|
64
|
-
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function printHardBlock(min, latest) {
|
|
63
|
+
const target = latest && compareVersions(latest, min) >= 0 ? latest : min;
|
|
64
|
+
console.error();
|
|
65
|
+
console.error(chalk.red(" \u2716 This CLI version is no longer supported."));
|
|
66
|
+
console.error(
|
|
67
|
+
chalk.dim(` You have ${CLI_VERSION}; ${min} or newer is required.`)
|
|
68
|
+
);
|
|
69
|
+
console.error(
|
|
70
|
+
chalk.dim(" Update with"),
|
|
71
|
+
chalk.cyan("npm install -g @envpilot/cli@latest"),
|
|
72
|
+
chalk.dim(`(\u2192 ${target})`)
|
|
73
|
+
);
|
|
74
|
+
console.error();
|
|
75
|
+
}
|
|
76
|
+
function printUpdateAvailable(latest) {
|
|
77
|
+
console.log();
|
|
78
|
+
console.log(
|
|
79
|
+
chalk.yellow(" Update available:"),
|
|
80
|
+
chalk.dim(CLI_VERSION),
|
|
81
|
+
chalk.yellow("\u2192"),
|
|
82
|
+
chalk.green(latest)
|
|
83
|
+
);
|
|
84
|
+
console.log(
|
|
85
|
+
chalk.dim(" Run"),
|
|
86
|
+
chalk.cyan("npm install -g @envpilot/cli@latest"),
|
|
87
|
+
chalk.dim("to update")
|
|
88
|
+
);
|
|
89
|
+
console.log();
|
|
90
|
+
}
|
|
91
|
+
async function refreshCache(cache) {
|
|
92
|
+
try {
|
|
93
|
+
const info = await fetchVersionInfo();
|
|
94
|
+
if (!info) return;
|
|
95
|
+
if (info.cli) cache.set("latest", info.cli);
|
|
96
|
+
if (info.minCli) cache.set("min", info.minCli);
|
|
97
|
+
} catch {
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function enforceVersion() {
|
|
101
|
+
try {
|
|
102
|
+
const cache = getCache();
|
|
103
|
+
const now = Date.now();
|
|
104
|
+
const lastCheck = cache.get("lastVersionCheck") ?? 0;
|
|
105
|
+
const hasData = cache.get("min") != null || cache.get("latest") != null;
|
|
106
|
+
const stale = now - lastCheck >= CHECK_INTERVAL;
|
|
107
|
+
if (stale) {
|
|
108
|
+
cache.set("lastVersionCheck", now);
|
|
109
|
+
if (hasData) {
|
|
110
|
+
void refreshCache(cache);
|
|
111
|
+
} else {
|
|
112
|
+
await refreshCache(cache);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const latest = cache.get("latest");
|
|
116
|
+
const min = cache.get("min");
|
|
117
|
+
const { blocked, updateAvailable } = evaluateVersion(
|
|
118
|
+
CLI_VERSION,
|
|
119
|
+
latest,
|
|
120
|
+
min
|
|
121
|
+
);
|
|
122
|
+
if (blocked) {
|
|
123
|
+
printHardBlock(min, latest);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
if (updateAvailable) {
|
|
127
|
+
printUpdateAvailable(updateAvailable);
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
} catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
65
133
|
}
|
|
66
134
|
|
|
67
135
|
// src/lib/program.ts
|
|
@@ -73,8 +141,9 @@ function createProgram() {
|
|
|
73
141
|
program.addCommand(command.createCommand());
|
|
74
142
|
}
|
|
75
143
|
}
|
|
76
|
-
program.hook("
|
|
77
|
-
|
|
144
|
+
program.hook("preAction", async () => {
|
|
145
|
+
const blocked = await enforceVersion();
|
|
146
|
+
if (blocked) process.exit(1);
|
|
78
147
|
});
|
|
79
148
|
return program;
|
|
80
149
|
}
|