commet 1.7.0 → 1.8.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/dist/index.js +236 -73
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -24,13 +24,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/index.ts
|
|
27
|
-
var
|
|
28
|
-
var
|
|
27
|
+
var import_chalk14 = __toESM(require("chalk"));
|
|
28
|
+
var import_commander12 = require("commander");
|
|
29
29
|
|
|
30
30
|
// package.json
|
|
31
31
|
var package_default = {
|
|
32
32
|
name: "commet",
|
|
33
|
-
version: "1.
|
|
33
|
+
version: "1.8.1",
|
|
34
34
|
description: "Commet CLI - Manage your billing platform from the command line",
|
|
35
35
|
bin: {
|
|
36
36
|
commet: "./bin/commet"
|
|
@@ -58,6 +58,7 @@ var package_default = {
|
|
|
58
58
|
license: "MIT",
|
|
59
59
|
dependencies: {
|
|
60
60
|
"@inquirer/prompts": "8.0.1",
|
|
61
|
+
ably: "^2.21.0",
|
|
61
62
|
chalk: "5.6.2",
|
|
62
63
|
commander: "14.0.2",
|
|
63
64
|
"jsonc-parser": "3.3.1",
|
|
@@ -986,14 +987,175 @@ var listCommand = new import_commander4.Command("list").description("List featur
|
|
|
986
987
|
}
|
|
987
988
|
});
|
|
988
989
|
|
|
989
|
-
// src/commands/
|
|
990
|
+
// src/commands/listen.ts
|
|
991
|
+
var import_ably = __toESM(require("ably"));
|
|
990
992
|
var import_chalk7 = __toESM(require("chalk"));
|
|
991
993
|
var import_commander5 = require("commander");
|
|
992
|
-
|
|
994
|
+
function printEventLine(line) {
|
|
995
|
+
const time = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false });
|
|
996
|
+
const eventName = import_chalk7.default.yellow(line.event.padEnd(28));
|
|
997
|
+
const timing = import_chalk7.default.dim(`(${line.ms}ms)`);
|
|
998
|
+
if ("error" in line) {
|
|
999
|
+
console.log(
|
|
1000
|
+
` ${import_chalk7.default.dim(time)} ${eventName} \u2192 ${import_chalk7.default.red("Error")} ${timing}`
|
|
1001
|
+
);
|
|
1002
|
+
console.log(` ${" ".repeat(12)}${import_chalk7.default.red(line.error)}`);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const status = line.statusCode < 400 ? import_chalk7.default.green(`${line.statusCode} OK`) : import_chalk7.default.red(`${line.statusCode} Error`);
|
|
1006
|
+
console.log(` ${import_chalk7.default.dim(time)} ${eventName} \u2192 ${status} ${timing}`);
|
|
1007
|
+
}
|
|
1008
|
+
function isListenMessage(data) {
|
|
1009
|
+
if (typeof data !== "object" || data === null) return false;
|
|
1010
|
+
const obj = data;
|
|
1011
|
+
return typeof obj.payload === "object" && obj.payload !== null && typeof obj.headers === "object" && obj.headers !== null;
|
|
1012
|
+
}
|
|
1013
|
+
var listenCommand = new import_commander5.Command("listen").description("Forward webhook events to your local server").requiredOption("--port <number>", "Local port to forward to").option("--events <types>", "Comma-separated event types to filter").option("--path <path>", "Path within localhost", "/").action(async (options) => {
|
|
1014
|
+
const auth = loadAuth();
|
|
1015
|
+
if (!auth) {
|
|
1016
|
+
console.log(import_chalk7.default.red("Not authenticated. Run: commet login"));
|
|
1017
|
+
process.exit(1);
|
|
1018
|
+
}
|
|
1019
|
+
const projectConfig = loadProjectConfig();
|
|
1020
|
+
if (!projectConfig) {
|
|
1021
|
+
console.log(import_chalk7.default.red("No project linked. Run: commet link"));
|
|
1022
|
+
process.exit(1);
|
|
1023
|
+
}
|
|
1024
|
+
const port = Number(options.port);
|
|
1025
|
+
if (Number.isNaN(port) || port <= 0 || port > 65535) {
|
|
1026
|
+
console.log(import_chalk7.default.red("Invalid port number"));
|
|
1027
|
+
process.exit(1);
|
|
1028
|
+
}
|
|
1029
|
+
async function fetchTokenRequest() {
|
|
1030
|
+
const result = await apiRequest(
|
|
1031
|
+
`${BASE_URL}/api/cli/listen/start`,
|
|
1032
|
+
{
|
|
1033
|
+
method: "POST",
|
|
1034
|
+
body: JSON.stringify({ organizationId: projectConfig.orgId })
|
|
1035
|
+
}
|
|
1036
|
+
);
|
|
1037
|
+
if (result.error || !result.data) {
|
|
1038
|
+
console.log(import_chalk7.default.red("Failed to start listen session"));
|
|
1039
|
+
if (result.error) {
|
|
1040
|
+
console.log(import_chalk7.default.dim(result.error));
|
|
1041
|
+
}
|
|
1042
|
+
process.exit(1);
|
|
1043
|
+
}
|
|
1044
|
+
return result.data;
|
|
1045
|
+
}
|
|
1046
|
+
const initialSession = await fetchTokenRequest();
|
|
1047
|
+
const { sessionId, channelName, signingSecret, tokenRequest } = initialSession;
|
|
1048
|
+
async function refreshToken() {
|
|
1049
|
+
const result = await apiRequest(
|
|
1050
|
+
`${BASE_URL}/api/cli/listen/refresh`,
|
|
1051
|
+
{
|
|
1052
|
+
method: "POST",
|
|
1053
|
+
body: JSON.stringify({
|
|
1054
|
+
sessionId,
|
|
1055
|
+
organizationId: projectConfig.orgId
|
|
1056
|
+
})
|
|
1057
|
+
}
|
|
1058
|
+
);
|
|
1059
|
+
if (result.error || !result.data) {
|
|
1060
|
+
throw new Error(result.error ?? "Failed to refresh token");
|
|
1061
|
+
}
|
|
1062
|
+
return result.data.tokenRequest;
|
|
1063
|
+
}
|
|
1064
|
+
let isFirstToken = true;
|
|
1065
|
+
const ably = new import_ably.default.Realtime({
|
|
1066
|
+
authCallback: async (_tokenParams, callback) => {
|
|
1067
|
+
try {
|
|
1068
|
+
if (isFirstToken) {
|
|
1069
|
+
isFirstToken = false;
|
|
1070
|
+
callback(null, tokenRequest);
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
const refreshed = await refreshToken();
|
|
1074
|
+
callback(null, refreshed);
|
|
1075
|
+
} catch (error) {
|
|
1076
|
+
callback(
|
|
1077
|
+
error instanceof Error ? error.message : "Token refresh failed",
|
|
1078
|
+
null
|
|
1079
|
+
);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
let wasConnected = false;
|
|
1084
|
+
ably.connection.on("connected", () => {
|
|
1085
|
+
if (wasConnected) {
|
|
1086
|
+
console.log(import_chalk7.default.green(" \u2713 Reconnected"));
|
|
1087
|
+
}
|
|
1088
|
+
wasConnected = true;
|
|
1089
|
+
});
|
|
1090
|
+
ably.connection.on("disconnected", () => {
|
|
1091
|
+
console.log(import_chalk7.default.yellow("\n \u26A0 Disconnected. Reconnecting..."));
|
|
1092
|
+
});
|
|
1093
|
+
ably.connection.on("failed", () => {
|
|
1094
|
+
console.log(
|
|
1095
|
+
import_chalk7.default.red("\n \u2717 Connection failed. Check your authentication.")
|
|
1096
|
+
);
|
|
1097
|
+
process.exit(1);
|
|
1098
|
+
});
|
|
1099
|
+
const channel = ably.channels.get(channelName);
|
|
1100
|
+
const targetUrl = `http://localhost:${port}${options.path}`;
|
|
1101
|
+
console.log("");
|
|
1102
|
+
console.log(
|
|
1103
|
+
import_chalk7.default.green(` \u2713 Authenticated (org: ${projectConfig.orgName})`)
|
|
1104
|
+
);
|
|
1105
|
+
console.log(import_chalk7.default.green(" \u2713 Connected to Commet webhook stream"));
|
|
1106
|
+
console.log(import_chalk7.default.cyan(` \u27F6 Forwarding to ${targetUrl}`));
|
|
1107
|
+
console.log(import_chalk7.default.dim(` \u27F6 Signing secret: ${signingSecret}`));
|
|
1108
|
+
console.log("");
|
|
1109
|
+
console.log(" Ready! Listening for webhook events...");
|
|
1110
|
+
console.log("");
|
|
1111
|
+
const eventFilter = options.events?.split(",").map((e) => e.trim()).filter(Boolean);
|
|
1112
|
+
channel.subscribe((message) => {
|
|
1113
|
+
if (!message.name || !isListenMessage(message.data)) return;
|
|
1114
|
+
const event = message.name;
|
|
1115
|
+
const { payload, headers } = message.data;
|
|
1116
|
+
if (eventFilter && !eventFilter.includes(event)) return;
|
|
1117
|
+
const start = performance.now();
|
|
1118
|
+
fetch(targetUrl, {
|
|
1119
|
+
method: "POST",
|
|
1120
|
+
headers,
|
|
1121
|
+
body: JSON.stringify(payload)
|
|
1122
|
+
}).then((response) => {
|
|
1123
|
+
const ms = Math.round(performance.now() - start);
|
|
1124
|
+
printEventLine({ event, statusCode: response.status, ms });
|
|
1125
|
+
}).catch((error) => {
|
|
1126
|
+
const ms = Math.round(performance.now() - start);
|
|
1127
|
+
printEventLine({
|
|
1128
|
+
event,
|
|
1129
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
1130
|
+
ms
|
|
1131
|
+
});
|
|
1132
|
+
});
|
|
1133
|
+
});
|
|
1134
|
+
let isShuttingDown = false;
|
|
1135
|
+
process.on("SIGINT", async () => {
|
|
1136
|
+
if (isShuttingDown) return;
|
|
1137
|
+
isShuttingDown = true;
|
|
1138
|
+
console.log(import_chalk7.default.dim("\n Disconnecting..."));
|
|
1139
|
+
ably.close();
|
|
1140
|
+
await apiRequest(`${BASE_URL}/api/cli/listen/stop`, {
|
|
1141
|
+
method: "POST",
|
|
1142
|
+
body: JSON.stringify({
|
|
1143
|
+
sessionId,
|
|
1144
|
+
organizationId: projectConfig.orgId
|
|
1145
|
+
})
|
|
1146
|
+
});
|
|
1147
|
+
process.exit(0);
|
|
1148
|
+
});
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
// src/commands/login.ts
|
|
1152
|
+
var import_chalk8 = __toESM(require("chalk"));
|
|
1153
|
+
var import_commander6 = require("commander");
|
|
1154
|
+
var loginCommand = new import_commander6.Command("login").description("Authenticate with Commet").action(async () => {
|
|
993
1155
|
if (authExists()) {
|
|
994
|
-
console.log(
|
|
1156
|
+
console.log(import_chalk8.default.yellow("\u26A0 You are already logged in."));
|
|
995
1157
|
console.log(
|
|
996
|
-
|
|
1158
|
+
import_chalk8.default.dim(
|
|
997
1159
|
"Run `commet logout` first if you want to login with a different account."
|
|
998
1160
|
)
|
|
999
1161
|
);
|
|
@@ -1001,9 +1163,9 @@ var loginCommand = new import_commander5.Command("login").description("Authentic
|
|
|
1001
1163
|
}
|
|
1002
1164
|
const success = await performLogin();
|
|
1003
1165
|
if (success) {
|
|
1004
|
-
console.log(
|
|
1166
|
+
console.log(import_chalk8.default.green("\n\u2713 Authentication complete"));
|
|
1005
1167
|
console.log(
|
|
1006
|
-
|
|
1168
|
+
import_chalk8.default.dim(
|
|
1007
1169
|
"\nNext steps:\n 1. Run `commet link` to connect a project\n 2. Run `commet pull` to generate types\n"
|
|
1008
1170
|
)
|
|
1009
1171
|
);
|
|
@@ -1011,22 +1173,22 @@ var loginCommand = new import_commander5.Command("login").description("Authentic
|
|
|
1011
1173
|
});
|
|
1012
1174
|
|
|
1013
1175
|
// src/commands/logout.ts
|
|
1014
|
-
var
|
|
1015
|
-
var
|
|
1016
|
-
var logoutCommand = new
|
|
1176
|
+
var import_chalk9 = __toESM(require("chalk"));
|
|
1177
|
+
var import_commander7 = require("commander");
|
|
1178
|
+
var logoutCommand = new import_commander7.Command("logout").description("Log out of Commet").action(async () => {
|
|
1017
1179
|
if (!authExists()) {
|
|
1018
|
-
console.log(
|
|
1180
|
+
console.log(import_chalk9.default.yellow("\u26A0 You are not logged in."));
|
|
1019
1181
|
return;
|
|
1020
1182
|
}
|
|
1021
1183
|
clearAuth();
|
|
1022
|
-
console.log(
|
|
1184
|
+
console.log(import_chalk9.default.green("\u2713 Successfully logged out"));
|
|
1023
1185
|
});
|
|
1024
1186
|
|
|
1025
1187
|
// src/commands/pull.ts
|
|
1026
1188
|
var fs6 = __toESM(require("fs"));
|
|
1027
1189
|
var path6 = __toESM(require("path"));
|
|
1028
|
-
var
|
|
1029
|
-
var
|
|
1190
|
+
var import_chalk10 = __toESM(require("chalk"));
|
|
1191
|
+
var import_commander8 = require("commander");
|
|
1030
1192
|
var import_ora5 = __toESM(require("ora"));
|
|
1031
1193
|
|
|
1032
1194
|
// src/utils/environment-validator.ts
|
|
@@ -1131,23 +1293,23 @@ function updateTsConfig(entry) {
|
|
|
1131
1293
|
}
|
|
1132
1294
|
|
|
1133
1295
|
// src/commands/pull.ts
|
|
1134
|
-
var pullCommand = new
|
|
1296
|
+
var pullCommand = new import_commander8.Command("pull").description("Pull type definitions from Commet").action(async () => {
|
|
1135
1297
|
if (!authExists()) {
|
|
1136
|
-
console.log(
|
|
1137
|
-
console.log(
|
|
1298
|
+
console.log(import_chalk10.default.red("\u2717 Not authenticated"));
|
|
1299
|
+
console.log(import_chalk10.default.dim("Run `commet login` first"));
|
|
1138
1300
|
return;
|
|
1139
1301
|
}
|
|
1140
1302
|
const hasTsConfig = validateTypeScriptProject();
|
|
1141
1303
|
if (!projectConfigExists()) {
|
|
1142
|
-
console.log(
|
|
1304
|
+
console.log(import_chalk10.default.red("\u2717 Project not linked"));
|
|
1143
1305
|
console.log(
|
|
1144
|
-
|
|
1306
|
+
import_chalk10.default.dim("Run `commet link` first to connect to an organization")
|
|
1145
1307
|
);
|
|
1146
1308
|
return;
|
|
1147
1309
|
}
|
|
1148
1310
|
const projectConfig = loadProjectConfig();
|
|
1149
1311
|
if (!projectConfig) {
|
|
1150
|
-
console.log(
|
|
1312
|
+
console.log(import_chalk10.default.red("\u2717 Invalid project configuration"));
|
|
1151
1313
|
return;
|
|
1152
1314
|
}
|
|
1153
1315
|
const spinner = (0, import_ora5.default)("Fetching type definitions...").start();
|
|
@@ -1156,7 +1318,7 @@ var pullCommand = new import_commander7.Command("pull").description("Pull type d
|
|
|
1156
1318
|
);
|
|
1157
1319
|
if (result.error || !result.data) {
|
|
1158
1320
|
spinner.fail("Failed to fetch types");
|
|
1159
|
-
console.error(
|
|
1321
|
+
console.error(import_chalk10.default.red("Error:"), result.error);
|
|
1160
1322
|
return;
|
|
1161
1323
|
}
|
|
1162
1324
|
const { seatTypes, features, plans } = result.data;
|
|
@@ -1169,52 +1331,52 @@ var pullCommand = new import_commander7.Command("pull").description("Pull type d
|
|
|
1169
1331
|
if (hasTsConfig) {
|
|
1170
1332
|
const tsconfigResult = updateTsConfig(".commet/types.d.ts");
|
|
1171
1333
|
if (tsconfigResult.success) {
|
|
1172
|
-
console.log(
|
|
1334
|
+
console.log(import_chalk10.default.green("\u2713 Updated tsconfig.json"));
|
|
1173
1335
|
} else {
|
|
1174
|
-
console.log(
|
|
1336
|
+
console.log(import_chalk10.default.yellow("\u26A0 Could not update tsconfig.json"));
|
|
1175
1337
|
console.log(
|
|
1176
|
-
|
|
1338
|
+
import_chalk10.default.dim(
|
|
1177
1339
|
'Add ".commet/types.d.ts" to your tsconfig.json include array'
|
|
1178
1340
|
)
|
|
1179
1341
|
);
|
|
1180
1342
|
}
|
|
1181
1343
|
} else {
|
|
1182
|
-
console.log(
|
|
1344
|
+
console.log(import_chalk10.default.yellow("\u26A0 No tsconfig.json found"));
|
|
1183
1345
|
console.log(
|
|
1184
|
-
|
|
1346
|
+
import_chalk10.default.dim(
|
|
1185
1347
|
'Add ".commet/types.d.ts" to your tsconfig.json to enable types'
|
|
1186
1348
|
)
|
|
1187
1349
|
);
|
|
1188
1350
|
}
|
|
1189
1351
|
const gitignoreResult = updateGitignore(".commet/");
|
|
1190
1352
|
if (gitignoreResult.success) {
|
|
1191
|
-
console.log(
|
|
1353
|
+
console.log(import_chalk10.default.green("\u2713 Updated .gitignore"));
|
|
1192
1354
|
} else {
|
|
1193
|
-
console.log(
|
|
1194
|
-
console.log(
|
|
1355
|
+
console.log(import_chalk10.default.yellow("\u26A0 No .gitignore found"));
|
|
1356
|
+
console.log(import_chalk10.default.dim("Add .commet/ to your .gitignore file"));
|
|
1195
1357
|
}
|
|
1196
|
-
console.log(
|
|
1197
|
-
console.log(
|
|
1358
|
+
console.log(import_chalk10.default.green("\nSuccess!"));
|
|
1359
|
+
console.log(import_chalk10.default.dim("\nGenerated types:"));
|
|
1198
1360
|
console.log(
|
|
1199
|
-
|
|
1361
|
+
import_chalk10.default.dim(
|
|
1200
1362
|
` Features: ${features.length > 0 ? features.map((f) => f.code).join(", ") : "none"}`
|
|
1201
1363
|
)
|
|
1202
1364
|
);
|
|
1203
1365
|
console.log(
|
|
1204
|
-
|
|
1366
|
+
import_chalk10.default.dim(
|
|
1205
1367
|
` Seat types: ${seatTypes.length > 0 ? seatTypes.map((s) => s.code).join(", ") : "none"}`
|
|
1206
1368
|
)
|
|
1207
1369
|
);
|
|
1208
1370
|
console.log(
|
|
1209
|
-
|
|
1371
|
+
import_chalk10.default.dim(
|
|
1210
1372
|
` Plans: ${plans.length > 0 ? plans.map((p) => p.code).join(", ") : "none"}`
|
|
1211
1373
|
)
|
|
1212
1374
|
);
|
|
1213
|
-
console.log(
|
|
1375
|
+
console.log(import_chalk10.default.dim(`
|
|
1214
1376
|
Output: ${outputPath}`));
|
|
1215
1377
|
if (seatTypes.length === 0 && plans.length === 0 && features.length === 0) {
|
|
1216
1378
|
console.log(
|
|
1217
|
-
|
|
1379
|
+
import_chalk10.default.yellow(
|
|
1218
1380
|
"\n\u26A0 No types found. Create features, seat types, and plans in your Commet dashboard."
|
|
1219
1381
|
)
|
|
1220
1382
|
);
|
|
@@ -1223,19 +1385,19 @@ Output: ${outputPath}`));
|
|
|
1223
1385
|
|
|
1224
1386
|
// src/commands/switch.ts
|
|
1225
1387
|
var import_prompts3 = require("@inquirer/prompts");
|
|
1226
|
-
var
|
|
1227
|
-
var
|
|
1388
|
+
var import_chalk11 = __toESM(require("chalk"));
|
|
1389
|
+
var import_commander9 = require("commander");
|
|
1228
1390
|
var import_ora6 = __toESM(require("ora"));
|
|
1229
|
-
var switchCommand = new
|
|
1391
|
+
var switchCommand = new import_commander9.Command("switch").description("Switch to a different organization").action(async () => {
|
|
1230
1392
|
if (!authExists()) {
|
|
1231
|
-
console.log(
|
|
1232
|
-
console.log(
|
|
1393
|
+
console.log(import_chalk11.default.red("\u2717 Not authenticated"));
|
|
1394
|
+
console.log(import_chalk11.default.dim("Run `commet login` first"));
|
|
1233
1395
|
return;
|
|
1234
1396
|
}
|
|
1235
1397
|
if (!projectConfigExists()) {
|
|
1236
|
-
console.log(
|
|
1398
|
+
console.log(import_chalk11.default.yellow("\u26A0 Project not linked"));
|
|
1237
1399
|
console.log(
|
|
1238
|
-
|
|
1400
|
+
import_chalk11.default.dim("Run `commet link` first to connect to an organization")
|
|
1239
1401
|
);
|
|
1240
1402
|
return;
|
|
1241
1403
|
}
|
|
@@ -1245,13 +1407,13 @@ var switchCommand = new import_commander8.Command("switch").description("Switch
|
|
|
1245
1407
|
);
|
|
1246
1408
|
if (result.error || !result.data) {
|
|
1247
1409
|
spinner.fail("Failed to fetch organizations");
|
|
1248
|
-
console.error(
|
|
1410
|
+
console.error(import_chalk11.default.red("Error:"), result.error);
|
|
1249
1411
|
return;
|
|
1250
1412
|
}
|
|
1251
1413
|
const { organizations } = result.data;
|
|
1252
1414
|
if (organizations.length === 0) {
|
|
1253
1415
|
spinner.stop();
|
|
1254
|
-
console.log(
|
|
1416
|
+
console.log(import_chalk11.default.yellow("\u26A0 No organizations found"));
|
|
1255
1417
|
return;
|
|
1256
1418
|
}
|
|
1257
1419
|
spinner.stop();
|
|
@@ -1260,18 +1422,18 @@ var switchCommand = new import_commander8.Command("switch").description("Switch
|
|
|
1260
1422
|
orgId = await (0, import_prompts3.select)({
|
|
1261
1423
|
message: "Select organization:",
|
|
1262
1424
|
choices: organizations.map((org) => ({
|
|
1263
|
-
name: `${org.name} ${
|
|
1425
|
+
name: `${org.name} ${import_chalk11.default.dim(`(${org.slug}) \xB7 ${org.mode}`)}`,
|
|
1264
1426
|
value: org.id
|
|
1265
1427
|
})),
|
|
1266
1428
|
theme: promptTheme
|
|
1267
1429
|
});
|
|
1268
1430
|
} catch (_error) {
|
|
1269
|
-
console.log(
|
|
1431
|
+
console.log(import_chalk11.default.yellow("\n\u26A0 Switch cancelled"));
|
|
1270
1432
|
return;
|
|
1271
1433
|
}
|
|
1272
1434
|
const selectedOrg = organizations.find((org) => org.id === orgId);
|
|
1273
1435
|
if (!selectedOrg) {
|
|
1274
|
-
console.log(
|
|
1436
|
+
console.log(import_chalk11.default.red("\u2717 Organization not found"));
|
|
1275
1437
|
return;
|
|
1276
1438
|
}
|
|
1277
1439
|
saveProjectConfig({
|
|
@@ -1279,55 +1441,55 @@ var switchCommand = new import_commander8.Command("switch").description("Switch
|
|
|
1279
1441
|
orgName: selectedOrg.name,
|
|
1280
1442
|
mode: selectedOrg.mode
|
|
1281
1443
|
});
|
|
1282
|
-
console.log(
|
|
1444
|
+
console.log(import_chalk11.default.green("\n\u2713 Switched organization successfully!"));
|
|
1283
1445
|
console.log(
|
|
1284
|
-
|
|
1446
|
+
import_chalk11.default.dim(`
|
|
1285
1447
|
Organization: ${selectedOrg.name} \xB7 ${selectedOrg.mode}`)
|
|
1286
1448
|
);
|
|
1287
1449
|
console.log(
|
|
1288
|
-
|
|
1450
|
+
import_chalk11.default.dim(
|
|
1289
1451
|
"\nRun `commet pull` to update TypeScript types for this organization"
|
|
1290
1452
|
)
|
|
1291
1453
|
);
|
|
1292
1454
|
});
|
|
1293
1455
|
|
|
1294
1456
|
// src/commands/unlink.ts
|
|
1295
|
-
var
|
|
1296
|
-
var
|
|
1297
|
-
var unlinkCommand = new
|
|
1457
|
+
var import_chalk12 = __toESM(require("chalk"));
|
|
1458
|
+
var import_commander10 = require("commander");
|
|
1459
|
+
var unlinkCommand = new import_commander10.Command("unlink").description("Unlink this project from Commet").action(async () => {
|
|
1298
1460
|
if (!projectConfigExists()) {
|
|
1299
1461
|
console.log(
|
|
1300
|
-
|
|
1462
|
+
import_chalk12.default.yellow("\u26A0 This project is not linked to any organization")
|
|
1301
1463
|
);
|
|
1302
1464
|
return;
|
|
1303
1465
|
}
|
|
1304
1466
|
clearProjectConfig();
|
|
1305
|
-
console.log(
|
|
1306
|
-
console.log(
|
|
1467
|
+
console.log(import_chalk12.default.green("\u2713 Project unlinked successfully"));
|
|
1468
|
+
console.log(import_chalk12.default.dim("\u2713 Removed .commet/ directory"));
|
|
1307
1469
|
console.log(
|
|
1308
|
-
|
|
1470
|
+
import_chalk12.default.dim("\nRun `commet link` to connect to a different organization")
|
|
1309
1471
|
);
|
|
1310
1472
|
});
|
|
1311
1473
|
|
|
1312
1474
|
// src/commands/whoami.ts
|
|
1313
|
-
var
|
|
1314
|
-
var
|
|
1315
|
-
var whoamiCommand = new
|
|
1475
|
+
var import_chalk13 = __toESM(require("chalk"));
|
|
1476
|
+
var import_commander11 = require("commander");
|
|
1477
|
+
var whoamiCommand = new import_commander11.Command("whoami").description("Display current authentication and project status").action(async () => {
|
|
1316
1478
|
if (!authExists()) {
|
|
1317
|
-
console.log(
|
|
1318
|
-
console.log(
|
|
1479
|
+
console.log(import_chalk13.default.yellow("\u26A0 Not logged in"));
|
|
1480
|
+
console.log(import_chalk13.default.dim("Run `commet login` to authenticate"));
|
|
1319
1481
|
return;
|
|
1320
1482
|
}
|
|
1321
|
-
console.log(
|
|
1483
|
+
console.log(import_chalk13.default.green("\u2713 Logged in"));
|
|
1322
1484
|
const projectConfig = loadProjectConfig();
|
|
1323
1485
|
if (projectConfig) {
|
|
1324
|
-
console.log(
|
|
1325
|
-
console.log(
|
|
1326
|
-
console.log(
|
|
1486
|
+
console.log(import_chalk13.default.bold("\nProject:"));
|
|
1487
|
+
console.log(import_chalk13.default.dim("Organization:"), projectConfig.orgName);
|
|
1488
|
+
console.log(import_chalk13.default.dim("Mode:"), projectConfig.mode);
|
|
1327
1489
|
} else {
|
|
1328
|
-
console.log(
|
|
1490
|
+
console.log(import_chalk13.default.yellow("\n\u26A0 No project linked"));
|
|
1329
1491
|
console.log(
|
|
1330
|
-
|
|
1492
|
+
import_chalk13.default.dim(
|
|
1331
1493
|
"Run `commet link` to connect this directory to an organization"
|
|
1332
1494
|
)
|
|
1333
1495
|
);
|
|
@@ -1335,7 +1497,7 @@ var whoamiCommand = new import_commander10.Command("whoami").description("Displa
|
|
|
1335
1497
|
});
|
|
1336
1498
|
|
|
1337
1499
|
// src/index.ts
|
|
1338
|
-
var program = new
|
|
1500
|
+
var program = new import_commander12.Command();
|
|
1339
1501
|
program.name("commet").description(
|
|
1340
1502
|
"Commet CLI - Manage your billing platform from the command line"
|
|
1341
1503
|
).version(package_default.version);
|
|
@@ -1349,6 +1511,7 @@ program.addCommand(switchCommand);
|
|
|
1349
1511
|
program.addCommand(infoCommand);
|
|
1350
1512
|
program.addCommand(pullCommand);
|
|
1351
1513
|
program.addCommand(listCommand);
|
|
1514
|
+
program.addCommand(listenCommand);
|
|
1352
1515
|
program.exitOverride();
|
|
1353
1516
|
try {
|
|
1354
1517
|
program.parse(process.argv);
|
|
@@ -1358,7 +1521,7 @@ try {
|
|
|
1358
1521
|
if (code === "commander.version" || code === "commander.help" || code === "commander.helpDisplayed") {
|
|
1359
1522
|
process.exit(0);
|
|
1360
1523
|
}
|
|
1361
|
-
console.error(
|
|
1524
|
+
console.error(import_chalk14.default.red("Error:"), error.message);
|
|
1362
1525
|
}
|
|
1363
1526
|
process.exit(1);
|
|
1364
1527
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Commet CLI - Manage your billing platform from the command line",
|
|
5
5
|
"bin": {
|
|
6
6
|
"commet": "./bin/commet"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@inquirer/prompts": "8.0.1",
|
|
23
|
+
"ably": "^2.21.0",
|
|
23
24
|
"chalk": "5.6.2",
|
|
24
25
|
"commander": "14.0.2",
|
|
25
26
|
"jsonc-parser": "3.3.1",
|