awarts 0.2.7 → 0.2.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/index.js +54 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7210,6 +7210,48 @@ async function seedCommand(opts) {
|
|
|
7210
7210
|
console.log();
|
|
7211
7211
|
}
|
|
7212
7212
|
|
|
7213
|
+
// src/commands/cleanup.ts
|
|
7214
|
+
async function cleanupCommand(opts) {
|
|
7215
|
+
banner();
|
|
7216
|
+
const auth = await loadAuth();
|
|
7217
|
+
if (!auth) {
|
|
7218
|
+
error("Not logged in. Run awarts login first.");
|
|
7219
|
+
return;
|
|
7220
|
+
}
|
|
7221
|
+
const spin = spinner("Cleaning up invalid usage data...");
|
|
7222
|
+
spin.start();
|
|
7223
|
+
try {
|
|
7224
|
+
const body = {};
|
|
7225
|
+
if (opts.beforeDate)
|
|
7226
|
+
body.before_date = opts.beforeDate;
|
|
7227
|
+
if (opts.dates)
|
|
7228
|
+
body.dates = opts.dates;
|
|
7229
|
+
const res = await post("/api/usage/cleanup", body);
|
|
7230
|
+
if (!res.ok) {
|
|
7231
|
+
spin.fail("Cleanup failed.");
|
|
7232
|
+
if (res.status === 401) {
|
|
7233
|
+
error("Authentication expired. Run awarts login to re-authenticate.");
|
|
7234
|
+
} else {
|
|
7235
|
+
error(`Server returned status ${res.status}`);
|
|
7236
|
+
}
|
|
7237
|
+
return;
|
|
7238
|
+
}
|
|
7239
|
+
const { deleted, posts_deleted } = res.data;
|
|
7240
|
+
if (deleted === 0 && posts_deleted === 0) {
|
|
7241
|
+
spin.info("No invalid data found — nothing to clean up.");
|
|
7242
|
+
} else {
|
|
7243
|
+
spin.succeed(source_default.green("Cleanup complete!"));
|
|
7244
|
+
console.log();
|
|
7245
|
+
kv("Usage entries deleted", deleted);
|
|
7246
|
+
kv("Posts deleted", posts_deleted);
|
|
7247
|
+
}
|
|
7248
|
+
console.log();
|
|
7249
|
+
} catch (err) {
|
|
7250
|
+
spin.fail("Could not reach the AWARTS server.");
|
|
7251
|
+
error(err instanceof Error ? err.message : String(err));
|
|
7252
|
+
}
|
|
7253
|
+
}
|
|
7254
|
+
|
|
7213
7255
|
// src/commands/daemon.ts
|
|
7214
7256
|
async function daemonStartCommand(intervalMs) {
|
|
7215
7257
|
banner();
|
|
@@ -7350,7 +7392,7 @@ async function checkForUpdates() {
|
|
|
7350
7392
|
|
|
7351
7393
|
// src/index.ts
|
|
7352
7394
|
var program2 = new Command;
|
|
7353
|
-
program2.name("awarts").description("Track your AI coding spend across Claude, Codex, Gemini & Antigravity").version("0.2.
|
|
7395
|
+
program2.name("awarts").description("Track your AI coding spend across Claude, Codex, Gemini & Antigravity").version("0.2.8").hook("preAction", () => checkForUpdates());
|
|
7354
7396
|
program2.command("login").description("Authenticate with your AWARTS account via device auth").option("--force", "Re-authenticate even if already logged in").action(async (opts) => {
|
|
7355
7397
|
try {
|
|
7356
7398
|
if (opts.force) {
|
|
@@ -7391,6 +7433,17 @@ program2.command("seed").description("Generate sample usage data for providers w
|
|
|
7391
7433
|
process.exit(1);
|
|
7392
7434
|
}
|
|
7393
7435
|
});
|
|
7436
|
+
program2.command("cleanup").description("Remove invalid/old usage data from AWARTS (e.g. entries with wrong dates)").option("--before <date>", "Delete entries before this date (default: 2020-01-01)", "2020-01-01").option("--date <dates...>", "Delete entries for specific dates (YYYY-MM-DD)").action(async (opts) => {
|
|
7437
|
+
try {
|
|
7438
|
+
await cleanupCommand({
|
|
7439
|
+
beforeDate: opts.before,
|
|
7440
|
+
dates: opts.date
|
|
7441
|
+
});
|
|
7442
|
+
} catch (err) {
|
|
7443
|
+
error(err instanceof Error ? err.message : String(err));
|
|
7444
|
+
process.exit(1);
|
|
7445
|
+
}
|
|
7446
|
+
});
|
|
7394
7447
|
program2.command("status").description("Show auth status, configuration, and detected providers").action(async () => {
|
|
7395
7448
|
try {
|
|
7396
7449
|
await statusCommand();
|