@usesocial/cli 0.3.4 → 0.3.5
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/CHANGELOG.md +6 -0
- package/dist/index.mjs +21 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @usesocial/cli
|
|
2
2
|
|
|
3
|
+
## 0.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#18](https://github.com/usesocial/monorepo/pull/18) [`831fe99`](https://github.com/usesocial/monorepo/commit/831fe99ed1d8ebc045e053fd53a8c5372ec7f49a) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Resume existing CLI login sessions at the billing step when a seat is missing, and show account-connect guidance only after login and seat setup complete.
|
|
8
|
+
|
|
3
9
|
## 0.3.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.mjs
CHANGED
|
@@ -21059,7 +21059,7 @@ const createInstance = (defaults) => {
|
|
|
21059
21059
|
const ky = createInstance();
|
|
21060
21060
|
//#endregion
|
|
21061
21061
|
//#region package.json
|
|
21062
|
-
var version$1 = "0.3.
|
|
21062
|
+
var version$1 = "0.3.5";
|
|
21063
21063
|
//#endregion
|
|
21064
21064
|
//#region src/lib/env.ts
|
|
21065
21065
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -27444,7 +27444,6 @@ const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
|
27444
27444
|
const MAGIC_LINK_PATH = "/api/auth/sign-in/magic-link";
|
|
27445
27445
|
const TERMS_URL = new URL(siteConfig.links.terms, siteConfig.publicWebURL).toString();
|
|
27446
27446
|
const LOGIN_SUCCESS_MESSAGE = "Logged in! 🎉";
|
|
27447
|
-
const NEXT_COMMANDS_MESSAGE = "Now run `social account connect linkedin` or `social account connect x`.";
|
|
27448
27447
|
const formatUserCode = (code) => `${code.slice(0, 4)}-${code.slice(4)}`;
|
|
27449
27448
|
const isRecord$2 = (value) => typeof value === "object" && value !== null;
|
|
27450
27449
|
const isAuthErrorResponse = (data) => isRecord$2(data) && (typeof data.error === "string" || typeof data.error_description === "string" || typeof data.message === "string");
|
|
@@ -27563,7 +27562,6 @@ const waitForDeviceToken = async (ctx, deviceCode, phoneNumber) => {
|
|
|
27563
27562
|
await updatePhoneNumber(ctx, phoneNumber);
|
|
27564
27563
|
clearTick();
|
|
27565
27564
|
spinner.stop(LOGIN_SUCCESS_MESSAGE);
|
|
27566
|
-
ctx.ui.info(NEXT_COMMANDS_MESSAGE);
|
|
27567
27565
|
return token;
|
|
27568
27566
|
} catch (error) {
|
|
27569
27567
|
clearTick();
|
|
@@ -27834,6 +27832,8 @@ const assertInteractiveTerminal = () => {
|
|
|
27834
27832
|
if (!(process.stdin.isTTY && process.stdout.isTTY)) throw new UsageError("social account login requires an interactive terminal.");
|
|
27835
27833
|
};
|
|
27836
27834
|
const nextCommands = ["social account connect linkedin", "social account connect x"];
|
|
27835
|
+
const nextCommandsMessage = `Now run \`${nextCommands[0]}\` or \`${nextCommands[1]}\`.`;
|
|
27836
|
+
const billingReady = (billing) => billing.seats.available > 0;
|
|
27837
27837
|
const alreadyLoggedInOutput = ({ credential, session }) => ({
|
|
27838
27838
|
status: "already_logged_in",
|
|
27839
27839
|
message: "Already logged in.",
|
|
@@ -27849,16 +27849,19 @@ const offlineOutput = () => ({
|
|
|
27849
27849
|
code: "offline",
|
|
27850
27850
|
message: "Couldn't reach the server. Check your network connection and try again."
|
|
27851
27851
|
});
|
|
27852
|
-
const runLogin = async (ctx) => {
|
|
27852
|
+
const runLogin = async (ctx, loginPhases = phases, deps = {}) => {
|
|
27853
|
+
const bearerIsValid = deps.isBearerValid ?? isBearerValid;
|
|
27854
|
+
const readLocalCredentials = deps.readCredentials ?? readCredentials;
|
|
27853
27855
|
analytics.capture("login_started");
|
|
27854
|
-
for (const phase of
|
|
27855
|
-
if (phase.
|
|
27856
|
+
for (const phase of loginPhases) {
|
|
27857
|
+
if (phase.name !== "access" && phase.name !== "sign-in" && deps.authenticated !== true && !bearerIsValid(await readLocalCredentials())) throw new AuthError("Session expired before login finished. Run `social account login` again.");
|
|
27856
27858
|
const result = await phase.run(ctx);
|
|
27857
27859
|
if (result.status !== "done") return result;
|
|
27858
27860
|
analytics.capture("login_phase_completed", { phase: phase.name });
|
|
27859
27861
|
}
|
|
27860
27862
|
const session = await ctx.client.cli.session.me();
|
|
27861
27863
|
const billing = await ctx.client.billing.status();
|
|
27864
|
+
ctx.ui.info(nextCommandsMessage);
|
|
27862
27865
|
return {
|
|
27863
27866
|
status: "ok",
|
|
27864
27867
|
user: session.user,
|
|
@@ -27906,7 +27909,18 @@ const loginCommand = defineCommand({
|
|
|
27906
27909
|
try {
|
|
27907
27910
|
const client = createORPCAPIClient();
|
|
27908
27911
|
const existing = await readExistingAuthSession(client);
|
|
27909
|
-
if (existing.kind === "existing") output = alreadyLoggedInOutput(existing.session);
|
|
27912
|
+
if (existing.kind === "existing") if (billingReady(await client.billing.status())) output = alreadyLoggedInOutput(existing.session);
|
|
27913
|
+
else {
|
|
27914
|
+
assertInteractiveTerminal();
|
|
27915
|
+
output = await runLogin({
|
|
27916
|
+
ui: createUI(process.stdout.isTTY === true),
|
|
27917
|
+
client,
|
|
27918
|
+
args: loginArgs
|
|
27919
|
+
}, [{
|
|
27920
|
+
name: "seat",
|
|
27921
|
+
run: seatPhase
|
|
27922
|
+
}], { authenticated: true });
|
|
27923
|
+
}
|
|
27910
27924
|
else if (existing.kind === "offline") output = offlineOutput();
|
|
27911
27925
|
else {
|
|
27912
27926
|
assertInteractiveTerminal();
|