ardent-cli 0.0.7 → 0.0.9
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 +27 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104,9 +104,10 @@ async function bootstrapCache() {
|
|
|
104
104
|
"Content-Type": "application/json",
|
|
105
105
|
"Authorization": `Bearer ${token}`
|
|
106
106
|
};
|
|
107
|
-
const [connectorsRes, branchesRes] = await Promise.all([
|
|
107
|
+
const [connectorsRes, branchesRes, meRes] = await Promise.all([
|
|
108
108
|
fetch(`${apiUrl}/v1/cli/connectors`, { headers }),
|
|
109
|
-
fetch(`${apiUrl}/v1/cli/branches`, { headers })
|
|
109
|
+
fetch(`${apiUrl}/v1/cli/branches`, { headers }),
|
|
110
|
+
fetch(`${apiUrl}/v1/cli/me`, { headers })
|
|
110
111
|
]);
|
|
111
112
|
let connectorCount = 0;
|
|
112
113
|
let branchCount = 0;
|
|
@@ -122,6 +123,10 @@ async function bootstrapCache() {
|
|
|
122
123
|
setCacheEntry("branches", branches);
|
|
123
124
|
branchCount = branches.length;
|
|
124
125
|
}
|
|
126
|
+
if (meRes.ok) {
|
|
127
|
+
const user = await meRes.json();
|
|
128
|
+
setConfig("user", user);
|
|
129
|
+
}
|
|
125
130
|
return { connectors: connectorCount, branches: branchCount };
|
|
126
131
|
}
|
|
127
132
|
|
|
@@ -222,6 +227,7 @@ function isPermissionError(err) {
|
|
|
222
227
|
// src/commands/branch/create.ts
|
|
223
228
|
async function createAction(name, options) {
|
|
224
229
|
try {
|
|
230
|
+
const startTime = performance.now();
|
|
225
231
|
const job = await api.post("/v1/cli/jobs/create", {
|
|
226
232
|
name
|
|
227
233
|
});
|
|
@@ -249,7 +255,8 @@ async function createAction(name, options) {
|
|
|
249
255
|
cachedBranches.push(branch);
|
|
250
256
|
setCacheEntry("branches", cachedBranches);
|
|
251
257
|
setCurrentBranch(name);
|
|
252
|
-
|
|
258
|
+
const elapsed = ((performance.now() - startTime) / 1e3).toFixed(1);
|
|
259
|
+
console.log(`\u2713 Branch '${name}' created and checked out in ${elapsed}s`);
|
|
253
260
|
if (branch.branch_url) {
|
|
254
261
|
console.log(`
|
|
255
262
|
${branch.branch_url}`);
|
|
@@ -1232,12 +1239,25 @@ function logoutAction() {
|
|
|
1232
1239
|
// src/commands/auth/status.ts
|
|
1233
1240
|
function statusAction() {
|
|
1234
1241
|
const token = getConfig("token");
|
|
1235
|
-
if (token) {
|
|
1236
|
-
console.log("\u2713 Authenticated");
|
|
1237
|
-
console.log(` Token: ${token.slice(0, 8)}...${token.slice(-4)}`);
|
|
1238
|
-
} else {
|
|
1242
|
+
if (!token) {
|
|
1239
1243
|
console.log("\u2717 Not authenticated");
|
|
1240
1244
|
console.log(" Run: ardent login");
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
const user = getConfig("user");
|
|
1248
|
+
console.log("\u2713 Authenticated");
|
|
1249
|
+
if (user?.full_name) {
|
|
1250
|
+
console.log(` Account: ${user.full_name}`);
|
|
1251
|
+
}
|
|
1252
|
+
if (user?.email) {
|
|
1253
|
+
console.log(` Email: ${user.email}`);
|
|
1254
|
+
}
|
|
1255
|
+
if (user?.org_name) {
|
|
1256
|
+
console.log(` Org: ${user.org_name}`);
|
|
1257
|
+
}
|
|
1258
|
+
if (!user) {
|
|
1259
|
+
console.log(` Token: ${token.slice(0, 8)}...${token.slice(-4)}`);
|
|
1260
|
+
console.log(" Run: ardent login to refresh profile info");
|
|
1241
1261
|
}
|
|
1242
1262
|
}
|
|
1243
1263
|
|