@insforge/cli 0.1.11 → 0.1.12
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 +80 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -710,6 +710,44 @@ async function installSkills(json) {
|
|
|
710
710
|
} catch {
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
+
async function reportCliUsage(toolName, success, maxRetries = 1) {
|
|
714
|
+
let config;
|
|
715
|
+
try {
|
|
716
|
+
config = getProjectConfig();
|
|
717
|
+
} catch {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (!config) return;
|
|
721
|
+
const payload = JSON.stringify({
|
|
722
|
+
tool_name: toolName,
|
|
723
|
+
success,
|
|
724
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
725
|
+
});
|
|
726
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
727
|
+
try {
|
|
728
|
+
const controller = new AbortController();
|
|
729
|
+
const timer = setTimeout(() => controller.abort(), 3e3);
|
|
730
|
+
try {
|
|
731
|
+
const res = await fetch(`${config.oss_host}/api/usage/mcp`, {
|
|
732
|
+
method: "POST",
|
|
733
|
+
headers: {
|
|
734
|
+
"Content-Type": "application/json",
|
|
735
|
+
"x-api-key": config.api_key
|
|
736
|
+
},
|
|
737
|
+
body: payload,
|
|
738
|
+
signal: controller.signal
|
|
739
|
+
});
|
|
740
|
+
if (res.status < 500) return;
|
|
741
|
+
} finally {
|
|
742
|
+
clearTimeout(timer);
|
|
743
|
+
}
|
|
744
|
+
} catch {
|
|
745
|
+
}
|
|
746
|
+
if (attempt < maxRetries - 1) {
|
|
747
|
+
await new Promise((r) => setTimeout(r, 5e3));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
713
751
|
|
|
714
752
|
// src/commands/projects/link.ts
|
|
715
753
|
function buildOssHost(appkey, region) {
|
|
@@ -781,7 +819,9 @@ function registerProjectLinkCommand(program2) {
|
|
|
781
819
|
outputSuccess(`Linked to project "${project.name}" (${project.appkey}.${project.region})`);
|
|
782
820
|
}
|
|
783
821
|
await installSkills(json);
|
|
822
|
+
await reportCliUsage("cli.link", true, 6);
|
|
784
823
|
} catch (err) {
|
|
824
|
+
await reportCliUsage("cli.link", false);
|
|
785
825
|
handleError(err, json);
|
|
786
826
|
}
|
|
787
827
|
});
|
|
@@ -845,7 +885,9 @@ function registerDbCommands(dbCmd2) {
|
|
|
845
885
|
}
|
|
846
886
|
}
|
|
847
887
|
}
|
|
888
|
+
await reportCliUsage("cli.db.query", true);
|
|
848
889
|
} catch (err) {
|
|
890
|
+
await reportCliUsage("cli.db.query", false);
|
|
849
891
|
handleError(err, json);
|
|
850
892
|
}
|
|
851
893
|
});
|
|
@@ -871,7 +913,9 @@ function registerDbTablesCommand(dbCmd2) {
|
|
|
871
913
|
tables.map((t) => [t])
|
|
872
914
|
);
|
|
873
915
|
}
|
|
916
|
+
await reportCliUsage("cli.db.tables", true);
|
|
874
917
|
} catch (err) {
|
|
918
|
+
await reportCliUsage("cli.db.tables", false);
|
|
875
919
|
handleError(err, json);
|
|
876
920
|
}
|
|
877
921
|
});
|
|
@@ -898,7 +942,9 @@ function registerDbFunctionsCommand(dbCmd2) {
|
|
|
898
942
|
functions.map((f) => [f.functionName, f.functionDef, f.kind])
|
|
899
943
|
);
|
|
900
944
|
}
|
|
945
|
+
await reportCliUsage("cli.db.functions", true);
|
|
901
946
|
} catch (err) {
|
|
947
|
+
await reportCliUsage("cli.db.functions", false);
|
|
902
948
|
handleError(err, json);
|
|
903
949
|
}
|
|
904
950
|
});
|
|
@@ -931,7 +977,9 @@ function registerDbIndexesCommand(dbCmd2) {
|
|
|
931
977
|
])
|
|
932
978
|
);
|
|
933
979
|
}
|
|
980
|
+
await reportCliUsage("cli.db.indexes", true);
|
|
934
981
|
} catch (err) {
|
|
982
|
+
await reportCliUsage("cli.db.indexes", false);
|
|
935
983
|
handleError(err, json);
|
|
936
984
|
}
|
|
937
985
|
});
|
|
@@ -965,7 +1013,9 @@ function registerDbPoliciesCommand(dbCmd2) {
|
|
|
965
1013
|
])
|
|
966
1014
|
);
|
|
967
1015
|
}
|
|
1016
|
+
await reportCliUsage("cli.db.policies", true);
|
|
968
1017
|
} catch (err) {
|
|
1018
|
+
await reportCliUsage("cli.db.policies", false);
|
|
969
1019
|
handleError(err, json);
|
|
970
1020
|
}
|
|
971
1021
|
});
|
|
@@ -1000,7 +1050,9 @@ function registerDbTriggersCommand(dbCmd2) {
|
|
|
1000
1050
|
])
|
|
1001
1051
|
);
|
|
1002
1052
|
}
|
|
1053
|
+
await reportCliUsage("cli.db.triggers", true);
|
|
1003
1054
|
} catch (err) {
|
|
1055
|
+
await reportCliUsage("cli.db.triggers", false);
|
|
1004
1056
|
handleError(err, json);
|
|
1005
1057
|
}
|
|
1006
1058
|
});
|
|
@@ -1023,6 +1075,7 @@ function registerDbRpcCommand(dbCmd2) {
|
|
|
1023
1075
|
} else {
|
|
1024
1076
|
console.log(JSON.stringify(result, null, 2));
|
|
1025
1077
|
}
|
|
1078
|
+
await reportCliUsage("cli.db.rpc", true);
|
|
1026
1079
|
} catch (err) {
|
|
1027
1080
|
handleError(err, json);
|
|
1028
1081
|
}
|
|
@@ -1297,7 +1350,9 @@ function registerFunctionsCommands(functionsCmd2) {
|
|
|
1297
1350
|
])
|
|
1298
1351
|
);
|
|
1299
1352
|
}
|
|
1353
|
+
await reportCliUsage("cli.functions.list", true);
|
|
1300
1354
|
} catch (err) {
|
|
1355
|
+
await reportCliUsage("cli.functions.list", false);
|
|
1301
1356
|
handleError(err, json);
|
|
1302
1357
|
}
|
|
1303
1358
|
});
|
|
@@ -1344,7 +1399,9 @@ Specify --file <path> or create ${join3("insforge", "functions", slug, "index.ts
|
|
|
1344
1399
|
} else {
|
|
1345
1400
|
outputSuccess(`Function "${slug}" ${exists ? "updated" : "created"} successfully.`);
|
|
1346
1401
|
}
|
|
1402
|
+
await reportCliUsage("cli.functions.deploy", true);
|
|
1347
1403
|
} catch (err) {
|
|
1404
|
+
await reportCliUsage("cli.functions.deploy", false);
|
|
1348
1405
|
handleError(err, json);
|
|
1349
1406
|
}
|
|
1350
1407
|
});
|
|
@@ -1444,7 +1501,9 @@ function registerStorageBucketsCommand(storageCmd2) {
|
|
|
1444
1501
|
buckets.map((b) => [b.name, b.public ? "Yes" : "No"])
|
|
1445
1502
|
);
|
|
1446
1503
|
}
|
|
1504
|
+
await reportCliUsage("cli.storage.buckets", true);
|
|
1447
1505
|
} catch (err) {
|
|
1506
|
+
await reportCliUsage("cli.storage.buckets", false);
|
|
1448
1507
|
handleError(err, json);
|
|
1449
1508
|
}
|
|
1450
1509
|
});
|
|
@@ -1545,7 +1604,9 @@ function registerStorageCreateBucketCommand(storageCmd2) {
|
|
|
1545
1604
|
} else {
|
|
1546
1605
|
outputSuccess(`Bucket "${name}" created (${isPublic ? "public" : "private"}).`);
|
|
1547
1606
|
}
|
|
1607
|
+
await reportCliUsage("cli.storage.create-bucket", true);
|
|
1548
1608
|
} catch (err) {
|
|
1609
|
+
await reportCliUsage("cli.storage.create-bucket", false);
|
|
1549
1610
|
handleError(err, json);
|
|
1550
1611
|
}
|
|
1551
1612
|
});
|
|
@@ -1630,7 +1691,9 @@ function registerStorageListObjectsCommand(storageCmd2) {
|
|
|
1630
1691
|
])
|
|
1631
1692
|
);
|
|
1632
1693
|
}
|
|
1694
|
+
await reportCliUsage("cli.storage.list-objects", true);
|
|
1633
1695
|
} catch (err) {
|
|
1696
|
+
await reportCliUsage("cli.storage.list-objects", false);
|
|
1634
1697
|
handleError(err, json);
|
|
1635
1698
|
}
|
|
1636
1699
|
});
|
|
@@ -1793,7 +1856,9 @@ function registerDeploymentsDeployCommand(deploymentsCmd2) {
|
|
|
1793
1856
|
clack8.log.info(`Check status with: insforge deployments status ${result.deploymentId}`);
|
|
1794
1857
|
}
|
|
1795
1858
|
}
|
|
1859
|
+
await reportCliUsage("cli.deployments.deploy", true);
|
|
1796
1860
|
} catch (err) {
|
|
1861
|
+
await reportCliUsage("cli.deployments.deploy", false);
|
|
1797
1862
|
handleError(err, json);
|
|
1798
1863
|
}
|
|
1799
1864
|
});
|
|
@@ -1905,6 +1970,7 @@ function registerCreateCommand(program2) {
|
|
|
1905
1970
|
await downloadTemplate(template, projectConfig, projectName, json, apiUrl);
|
|
1906
1971
|
}
|
|
1907
1972
|
await installSkills(json);
|
|
1973
|
+
await reportCliUsage("cli.create", true, 6);
|
|
1908
1974
|
if (hasTemplate) {
|
|
1909
1975
|
const installSpinner = !json ? clack9.spinner() : null;
|
|
1910
1976
|
installSpinner?.start("Installing dependencies...");
|
|
@@ -2139,7 +2205,9 @@ function registerDeploymentsListCommand(deploymentsCmd2) {
|
|
|
2139
2205
|
])
|
|
2140
2206
|
);
|
|
2141
2207
|
}
|
|
2208
|
+
await reportCliUsage("cli.deployments.list", true);
|
|
2142
2209
|
} catch (err) {
|
|
2210
|
+
await reportCliUsage("cli.deployments.list", false);
|
|
2143
2211
|
handleError(err, json);
|
|
2144
2212
|
}
|
|
2145
2213
|
});
|
|
@@ -2224,6 +2292,7 @@ Examples:
|
|
|
2224
2292
|
const { json } = getRootOpts(cmd);
|
|
2225
2293
|
try {
|
|
2226
2294
|
await requireAuth();
|
|
2295
|
+
await reportCliUsage("cli.docs", true);
|
|
2227
2296
|
if (!feature) {
|
|
2228
2297
|
await listDocs(json);
|
|
2229
2298
|
return;
|
|
@@ -2308,7 +2377,9 @@ function registerSecretsListCommand(secretsCmd2) {
|
|
|
2308
2377
|
})
|
|
2309
2378
|
);
|
|
2310
2379
|
}
|
|
2380
|
+
await reportCliUsage("cli.secrets.list", true);
|
|
2311
2381
|
} catch (err) {
|
|
2382
|
+
await reportCliUsage("cli.secrets.list", false);
|
|
2312
2383
|
handleError(err, json);
|
|
2313
2384
|
}
|
|
2314
2385
|
});
|
|
@@ -2353,7 +2424,9 @@ function registerSecretsAddCommand(secretsCmd2) {
|
|
|
2353
2424
|
} else {
|
|
2354
2425
|
outputSuccess(data.message ?? `Secret ${key} created.`);
|
|
2355
2426
|
}
|
|
2427
|
+
await reportCliUsage("cli.secrets.add", true);
|
|
2356
2428
|
} catch (err) {
|
|
2429
|
+
await reportCliUsage("cli.secrets.add", false);
|
|
2357
2430
|
handleError(err, json);
|
|
2358
2431
|
}
|
|
2359
2432
|
});
|
|
@@ -2427,7 +2500,7 @@ function registerSchedulesListCommand(schedulesCmd2) {
|
|
|
2427
2500
|
await requireAuth();
|
|
2428
2501
|
const res = await ossFetch("/api/schedules");
|
|
2429
2502
|
const data = await res.json();
|
|
2430
|
-
const schedules =
|
|
2503
|
+
const schedules = data;
|
|
2431
2504
|
if (json) {
|
|
2432
2505
|
outputJson(schedules);
|
|
2433
2506
|
} else {
|
|
@@ -2448,7 +2521,9 @@ function registerSchedulesListCommand(schedulesCmd2) {
|
|
|
2448
2521
|
])
|
|
2449
2522
|
);
|
|
2450
2523
|
}
|
|
2524
|
+
await reportCliUsage("cli.schedules.list", true);
|
|
2451
2525
|
} catch (err) {
|
|
2526
|
+
await reportCliUsage("cli.schedules.list", false);
|
|
2452
2527
|
handleError(err, json);
|
|
2453
2528
|
}
|
|
2454
2529
|
});
|
|
@@ -2520,7 +2595,9 @@ function registerSchedulesCreateCommand(schedulesCmd2) {
|
|
|
2520
2595
|
} else {
|
|
2521
2596
|
outputSuccess(`Schedule "${opts.name}" created (ID: ${data.id ?? "unknown"}).`);
|
|
2522
2597
|
}
|
|
2598
|
+
await reportCliUsage("cli.schedules.create", true);
|
|
2523
2599
|
} catch (err) {
|
|
2600
|
+
await reportCliUsage("cli.schedules.create", false);
|
|
2524
2601
|
handleError(err, json);
|
|
2525
2602
|
}
|
|
2526
2603
|
});
|
|
@@ -2752,7 +2829,9 @@ function registerMetadataCommand(program2) {
|
|
|
2752
2829
|
Version: ${data.version}`);
|
|
2753
2830
|
}
|
|
2754
2831
|
console.log("");
|
|
2832
|
+
await reportCliUsage("cli.metadata", true);
|
|
2755
2833
|
} catch (err) {
|
|
2834
|
+
await reportCliUsage("cli.metadata", false);
|
|
2756
2835
|
handleError(err, json);
|
|
2757
2836
|
}
|
|
2758
2837
|
});
|