@dosu/cli 0.9.0 → 0.9.1
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/bin/dosu.js +15 -5
- package/package.json +1 -1
package/bin/dosu.js
CHANGED
|
@@ -2192,7 +2192,7 @@ var require_picocolors = __commonJS((exports, module) => {
|
|
|
2192
2192
|
function getVersionString() {
|
|
2193
2193
|
return `v${VERSION}`;
|
|
2194
2194
|
}
|
|
2195
|
-
var VERSION = "0.9.
|
|
2195
|
+
var VERSION = "0.9.1";
|
|
2196
2196
|
|
|
2197
2197
|
// src/debug/logger.ts
|
|
2198
2198
|
import {
|
|
@@ -5171,15 +5171,18 @@ init_providers();
|
|
|
5171
5171
|
init_config();
|
|
5172
5172
|
init_logger();
|
|
5173
5173
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
5174
|
-
import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
5174
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
5175
5175
|
import { join as join17 } from "node:path";
|
|
5176
5176
|
var CACHE_FILENAME = "update-check.json";
|
|
5177
5177
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
5178
5178
|
var FETCH_TIMEOUT_MS = 5000;
|
|
5179
5179
|
var REGISTRY_URL = "https://registry.npmjs.org/-/package/@dosu/cli/dist-tags";
|
|
5180
|
+
function stripPrerelease(version) {
|
|
5181
|
+
return version.replace(/[-+].*$/, "");
|
|
5182
|
+
}
|
|
5180
5183
|
function isNewerVersion(latest, current) {
|
|
5181
|
-
const a = latest.split(".").map(Number);
|
|
5182
|
-
const b = current.split(".").map(Number);
|
|
5184
|
+
const a = stripPrerelease(latest).split(".").map(Number);
|
|
5185
|
+
const b = stripPrerelease(current).split(".").map(Number);
|
|
5183
5186
|
const len = Math.max(a.length, b.length);
|
|
5184
5187
|
for (let i = 0;i < len; i++) {
|
|
5185
5188
|
const av = a[i] ?? 0;
|
|
@@ -5210,6 +5213,10 @@ function readCache() {
|
|
|
5210
5213
|
}
|
|
5211
5214
|
function writeCache(cache) {
|
|
5212
5215
|
try {
|
|
5216
|
+
const dir = getConfigDir();
|
|
5217
|
+
if (!existsSync7(dir)) {
|
|
5218
|
+
mkdirSync5(dir, { recursive: true, mode: 448 });
|
|
5219
|
+
}
|
|
5213
5220
|
writeFileSync5(getCachePath(), JSON.stringify(cache), { mode: 384 });
|
|
5214
5221
|
} catch {}
|
|
5215
5222
|
}
|
|
@@ -5245,8 +5252,11 @@ function checkForUpdates() {
|
|
|
5245
5252
|
const isStale = !cache || Date.now() - cache.lastCheck > CHECK_INTERVAL_MS;
|
|
5246
5253
|
if (isStale) {
|
|
5247
5254
|
fetchLatestVersion().then((latest) => {
|
|
5255
|
+
writeCache({
|
|
5256
|
+
lastCheck: Date.now(),
|
|
5257
|
+
latestVersion: latest ?? cache?.latestVersion ?? VERSION
|
|
5258
|
+
});
|
|
5248
5259
|
if (latest) {
|
|
5249
|
-
writeCache({ lastCheck: Date.now(), latestVersion: latest });
|
|
5250
5260
|
logger.debug("update-check", `Cached latest version: ${latest}`);
|
|
5251
5261
|
}
|
|
5252
5262
|
}).catch((err) => {
|