mobbdev 1.0.36 → 1.0.37
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.mjs +39 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1627,13 +1627,35 @@ async function keypress() {
|
|
|
1627
1627
|
import {
|
|
1628
1628
|
createSpinner as _createSpinner
|
|
1629
1629
|
} from "nanospinner";
|
|
1630
|
+
function printToStdError(opts) {
|
|
1631
|
+
if (opts?.text)
|
|
1632
|
+
console.error(opts.text);
|
|
1633
|
+
}
|
|
1630
1634
|
var mockSpinner = {
|
|
1631
|
-
success: () =>
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1635
|
+
success: (opts) => {
|
|
1636
|
+
printToStdError(opts);
|
|
1637
|
+
return mockSpinner;
|
|
1638
|
+
},
|
|
1639
|
+
error: (opts) => {
|
|
1640
|
+
printToStdError(opts);
|
|
1641
|
+
return mockSpinner;
|
|
1642
|
+
},
|
|
1643
|
+
warn: (opts) => {
|
|
1644
|
+
printToStdError(opts);
|
|
1645
|
+
return mockSpinner;
|
|
1646
|
+
},
|
|
1647
|
+
stop: (opts) => {
|
|
1648
|
+
printToStdError(opts);
|
|
1649
|
+
return mockSpinner;
|
|
1650
|
+
},
|
|
1651
|
+
start: (opts) => {
|
|
1652
|
+
printToStdError(opts);
|
|
1653
|
+
return mockSpinner;
|
|
1654
|
+
},
|
|
1655
|
+
update: (opts) => {
|
|
1656
|
+
printToStdError(opts);
|
|
1657
|
+
return mockSpinner;
|
|
1658
|
+
},
|
|
1637
1659
|
reset: () => mockSpinner,
|
|
1638
1660
|
clear: () => mockSpinner,
|
|
1639
1661
|
spin: () => mockSpinner
|
|
@@ -7520,13 +7542,14 @@ var GQLClient = class {
|
|
|
7520
7542
|
}
|
|
7521
7543
|
async verifyToken() {
|
|
7522
7544
|
await this.createCommunityUser();
|
|
7545
|
+
let info;
|
|
7523
7546
|
try {
|
|
7524
|
-
await this.getUserInfo();
|
|
7547
|
+
info = await this.getUserInfo();
|
|
7525
7548
|
} catch (e) {
|
|
7526
7549
|
debug11("verify token failed %o", e);
|
|
7527
7550
|
return false;
|
|
7528
7551
|
}
|
|
7529
|
-
return true;
|
|
7552
|
+
return info?.email || true;
|
|
7530
7553
|
}
|
|
7531
7554
|
async getOrgAndProjectId(params = {}) {
|
|
7532
7555
|
const { projectName, userDefinedOrganizationId } = params;
|
|
@@ -8869,9 +8892,10 @@ async function handleMobbLogin({
|
|
|
8869
8892
|
skipPrompts
|
|
8870
8893
|
}) {
|
|
8871
8894
|
const { createSpinner: createSpinner5 } = Spinner({ ci: skipPrompts });
|
|
8872
|
-
|
|
8895
|
+
const userVerify = await inGqlClient.verifyToken();
|
|
8896
|
+
if (userVerify) {
|
|
8873
8897
|
createSpinner5().start().success({
|
|
8874
|
-
text:
|
|
8898
|
+
text: `\u{1F513} Login to Mobb succeeded. ${typeof userVerify === "string" ? `Logged in as ${userVerify}` : ""}`
|
|
8875
8899
|
});
|
|
8876
8900
|
return inGqlClient;
|
|
8877
8901
|
} else if (apiKey) {
|
|
@@ -8922,10 +8946,13 @@ async function handleMobbLogin({
|
|
|
8922
8946
|
throw new CliError();
|
|
8923
8947
|
}
|
|
8924
8948
|
const newGqlClient = new GQLClient({ apiKey: newApiToken, type: "apiKey" });
|
|
8925
|
-
|
|
8949
|
+
const loginSuccess = await newGqlClient.verifyToken();
|
|
8950
|
+
if (loginSuccess) {
|
|
8926
8951
|
debug17("set api token %s", newApiToken);
|
|
8927
8952
|
config3.set("apiToken", newApiToken);
|
|
8928
|
-
loginSpinner.success({
|
|
8953
|
+
loginSpinner.success({
|
|
8954
|
+
text: `\u{1F513} Login to Mobb successful! ${typeof loginSpinner === "string" ? `Logged in as ${loginSuccess}` : ""}`
|
|
8955
|
+
});
|
|
8929
8956
|
} else {
|
|
8930
8957
|
loginSpinner.error({
|
|
8931
8958
|
text: "Something went wrong, API token is invalid."
|