qatools-cli 1.1.10 → 1.1.11
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/package.json +1 -1
- package/qatools.js +44 -31
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qatools-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "CLI for QA Tools — requirements, epics, sprints, sessions, App Context sync, project agenda. The companion to qa-tools.com.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"release": "npm version patch --no-git-tag-version && npm publish",
|
package/qatools.js
CHANGED
|
@@ -129,6 +129,50 @@ program
|
|
|
129
129
|
.description("CLI for QA Tools")
|
|
130
130
|
.version(require("./package.json").version);
|
|
131
131
|
|
|
132
|
+
// Update nudge: before every command, print (from cache) if the installed CLI is behind npm,
|
|
133
|
+
// and refresh the cache in the background (throttled to once/day). sync can't upgrade the tool itself.
|
|
134
|
+
// Kept fully non-blocking and fail-open so it never slows or breaks a command (parse() is sync).
|
|
135
|
+
const VERSION_CACHE_FILE = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".qatools-version");
|
|
136
|
+
function cmpVersion(a, b) {
|
|
137
|
+
const pa = String(a).split(".").map(Number), pb = String(b).split(".").map(Number);
|
|
138
|
+
for (let i = 0; i < 3; i++) { const d = (pa[i] || 0) - (pb[i] || 0); if (d) return d < 0 ? -1 : 1; }
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
function printUpdateNoticeFromCache() {
|
|
142
|
+
try {
|
|
143
|
+
const current = require("./package.json").version;
|
|
144
|
+
const cache = JSON.parse(fs.readFileSync(VERSION_CACHE_FILE, "utf8"));
|
|
145
|
+
if (cache.latest && cmpVersion(current, cache.latest) < 0) {
|
|
146
|
+
// stderr so it never corrupts parseable stdout (e.g. -o json output)
|
|
147
|
+
console.error(`\n⚠ qatools-cli ${current} → ${cache.latest} available. Upgrade: npm i -g qatools-cli@latest\n`);
|
|
148
|
+
}
|
|
149
|
+
} catch { /* no cache yet or unreadable — skip */ }
|
|
150
|
+
}
|
|
151
|
+
function refreshVersionCacheInBackground() {
|
|
152
|
+
try {
|
|
153
|
+
let cache = {};
|
|
154
|
+
try { cache = JSON.parse(fs.readFileSync(VERSION_CACHE_FILE, "utf8")); } catch { /* none */ }
|
|
155
|
+
if (cache.checkedAt && Date.now() - cache.checkedAt < 24 * 3600 * 1000) return; // throttled: at most once/day
|
|
156
|
+
const req = require("https").get("https://registry.npmjs.org/qatools-cli/latest", { timeout: 3000 }, (res) => {
|
|
157
|
+
let body = "";
|
|
158
|
+
res.on("data", (c) => (body += c));
|
|
159
|
+
res.on("end", () => {
|
|
160
|
+
try {
|
|
161
|
+
const latest = JSON.parse(body).version;
|
|
162
|
+
if (latest) fs.writeFileSync(VERSION_CACHE_FILE, JSON.stringify({ latest, checkedAt: Date.now() }));
|
|
163
|
+
} catch { /* malformed — skip */ }
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
req.on("error", () => {});
|
|
167
|
+
req.on("timeout", () => req.destroy());
|
|
168
|
+
if (req.unref) req.unref(); // don't keep the process alive for this
|
|
169
|
+
} catch { /* never block the command */ }
|
|
170
|
+
}
|
|
171
|
+
program.hook("preAction", () => {
|
|
172
|
+
printUpdateNoticeFromCache();
|
|
173
|
+
refreshVersionCacheInBackground();
|
|
174
|
+
});
|
|
175
|
+
|
|
132
176
|
program
|
|
133
177
|
.command("upload-analysis")
|
|
134
178
|
.description("Upload a Claude analysis JSON to a test session")
|
|
@@ -740,36 +784,6 @@ program
|
|
|
740
784
|
process.exit(0);
|
|
741
785
|
});
|
|
742
786
|
|
|
743
|
-
// Non-blocking: warn if a newer qatools-cli is published on npm (sync can't upgrade the tool itself)
|
|
744
|
-
function cmpVersion(a, b) {
|
|
745
|
-
const pa = String(a).split(".").map(Number), pb = String(b).split(".").map(Number);
|
|
746
|
-
for (let i = 0; i < 3; i++) { const d = (pa[i] || 0) - (pb[i] || 0); if (d) return d < 0 ? -1 : 1; }
|
|
747
|
-
return 0;
|
|
748
|
-
}
|
|
749
|
-
function checkCliVersion() {
|
|
750
|
-
return new Promise((resolve) => {
|
|
751
|
-
try {
|
|
752
|
-
const current = require("./package.json").version;
|
|
753
|
-
const req = require("https").get("https://registry.npmjs.org/qatools-cli/latest", { timeout: 3000 }, (res) => {
|
|
754
|
-
let body = "";
|
|
755
|
-
res.on("data", (c) => (body += c));
|
|
756
|
-
res.on("end", () => {
|
|
757
|
-
try {
|
|
758
|
-
const latest = JSON.parse(body).version;
|
|
759
|
-
if (latest && cmpVersion(current, latest) < 0) {
|
|
760
|
-
console.log(`\n⚠ A newer qatools-cli is available: ${current} → ${latest}`);
|
|
761
|
-
console.log(` Upgrade so commands, skills and rules are current: npm i -g qatools-cli@latest\n`);
|
|
762
|
-
}
|
|
763
|
-
} catch { /* malformed response — skip */ }
|
|
764
|
-
resolve();
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
req.on("error", () => resolve());
|
|
768
|
-
req.on("timeout", () => { req.destroy(); resolve(); });
|
|
769
|
-
} catch { resolve(); }
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
|
|
773
787
|
program
|
|
774
788
|
.command("sync")
|
|
775
789
|
.description("Sync App Context from qa-tools into a CLAUDE.md block")
|
|
@@ -780,7 +794,6 @@ program
|
|
|
780
794
|
.option("-e, --email <email>", "Login email")
|
|
781
795
|
.option("-p, --password <password>", "Login password")
|
|
782
796
|
.action(async (options) => {
|
|
783
|
-
await checkCliVersion();
|
|
784
797
|
await authenticate(options);
|
|
785
798
|
const creds = getCredentials();
|
|
786
799
|
const projectId = options.project || creds?.projectId;
|