@usesocial/cli 0.2.1 → 0.2.2
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 +45 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -17919,8 +17919,9 @@ const CONNECTED_STATUS = "connected";
|
|
|
17919
17919
|
const LEADING_AT_PATTERN$1 = /^@+/;
|
|
17920
17920
|
const LINKEDIN_PROFILE_HOST_PATTERN = /(^|\.)linkedin\.com$/i;
|
|
17921
17921
|
const isInteractiveTerminal$1 = (deps) => deps.isInteractiveTerminal?.() ?? process.stdout.isTTY === true;
|
|
17922
|
-
const openURL = async (deps, url) => {
|
|
17923
|
-
|
|
17922
|
+
const openURL = async (deps, url, options = {}) => {
|
|
17923
|
+
const log = deps.log ?? console.error;
|
|
17924
|
+
if (options.log ?? true) log(`Opening ${url}`);
|
|
17924
17925
|
if (!(isInteractiveTerminal$1(deps) && deps.openURL)) return {
|
|
17925
17926
|
opened: false,
|
|
17926
17927
|
url
|
|
@@ -17998,6 +17999,10 @@ const pollForAccount$1 = async (deps, predicate, errorMessage) => {
|
|
|
17998
17999
|
}
|
|
17999
18000
|
throw new Error(errorMessage);
|
|
18000
18001
|
};
|
|
18002
|
+
const authURLFor$1 = async (deps, operation) => ({
|
|
18003
|
+
url: deps.handshakeAuthURL ? await deps.handshakeAuthURL(operation) : await operation(),
|
|
18004
|
+
openingLogged: deps.handshakeAuthURL !== void 0
|
|
18005
|
+
});
|
|
18001
18006
|
const accountForIdentifier = async (deps, identifier) => {
|
|
18002
18007
|
const target = linkedinReconnectTargetFrom(identifier);
|
|
18003
18008
|
const account = (await listLinkedinLifecycleAccounts(deps)).find((candidate) => accountMatchesReconnectTarget(candidate, target));
|
|
@@ -18014,10 +18019,11 @@ const connectLinkedinAccount = async (deps) => {
|
|
|
18014
18019
|
await prepareAccountConnect$1(deps);
|
|
18015
18020
|
const before = await listLinkedinLifecycleAccounts(deps);
|
|
18016
18021
|
const existingProfileIds = new Set(before.map((account) => account.profileId));
|
|
18017
|
-
await
|
|
18022
|
+
const authURL = await authURLFor$1(deps, async () => (await deps.client.createHostedAuthURL({
|
|
18018
18023
|
platform: LINKEDIN_PLATFORM,
|
|
18019
18024
|
mode: "create"
|
|
18020
18025
|
})).url);
|
|
18026
|
+
await openURL(deps, authURL.url, { log: !authURL.openingLogged });
|
|
18021
18027
|
return {
|
|
18022
18028
|
platform: LINKEDIN_PLATFORM,
|
|
18023
18029
|
status: "connected",
|
|
@@ -18026,11 +18032,12 @@ const connectLinkedinAccount = async (deps) => {
|
|
|
18026
18032
|
};
|
|
18027
18033
|
const reconnectLinkedinAccount = async (deps, identifier) => {
|
|
18028
18034
|
const account = await reconnectAccountForIdentifier(deps, identifier);
|
|
18029
|
-
await
|
|
18035
|
+
const authURL = await authURLFor$1(deps, async () => (await deps.client.createHostedAuthURL({
|
|
18030
18036
|
platform: LINKEDIN_PLATFORM,
|
|
18031
18037
|
mode: "reconnect",
|
|
18032
18038
|
account: reconnectCommandTargetFor(account)
|
|
18033
18039
|
})).url);
|
|
18040
|
+
await openURL(deps, authURL.url, { log: !authURL.openingLogged });
|
|
18034
18041
|
return {
|
|
18035
18042
|
platform: LINKEDIN_PLATFORM,
|
|
18036
18043
|
status: "connected",
|
|
@@ -18078,8 +18085,9 @@ const connectURLFor = async (deps, reconnectProfileId) => {
|
|
|
18078
18085
|
return url.toString();
|
|
18079
18086
|
};
|
|
18080
18087
|
const isInteractiveTerminal = (deps) => deps.isInteractiveTerminal?.() ?? process.stdout.isTTY === true;
|
|
18081
|
-
const openOrPrint = async (deps, url) => {
|
|
18082
|
-
|
|
18088
|
+
const openOrPrint = async (deps, url, options = {}) => {
|
|
18089
|
+
const log = deps.log ?? console.error;
|
|
18090
|
+
if (options.log ?? true) log(`Opening ${url}`);
|
|
18083
18091
|
if (!(isInteractiveTerminal(deps) && deps.openBrowser)) return;
|
|
18084
18092
|
await deps.openBrowser(url);
|
|
18085
18093
|
};
|
|
@@ -18097,6 +18105,10 @@ const pollForAccount = async (deps, matches) => {
|
|
|
18097
18105
|
}
|
|
18098
18106
|
throw new Error("x_connect_timed_out");
|
|
18099
18107
|
};
|
|
18108
|
+
const authURLFor = async (deps, operation) => ({
|
|
18109
|
+
url: deps.handshakeAuthURL ? await deps.handshakeAuthURL(operation) : await operation(),
|
|
18110
|
+
openingLogged: deps.handshakeAuthURL !== void 0
|
|
18111
|
+
});
|
|
18100
18112
|
const pollForSeat$1 = async (deps) => {
|
|
18101
18113
|
const sleep = deps.sleep ?? defaultSleep;
|
|
18102
18114
|
const now = deps.now ?? Date.now;
|
|
@@ -18143,7 +18155,8 @@ const connectXAccount = async (deps) => {
|
|
|
18143
18155
|
const before = await listXLifecycleAccounts(deps, true);
|
|
18144
18156
|
const connectedBefore = new Set(before.filter((account) => account.status === "connected").map(accountKey));
|
|
18145
18157
|
await prepareAccountConnect(deps);
|
|
18146
|
-
await
|
|
18158
|
+
const authURL = await authURLFor(deps, () => connectURLFor(deps));
|
|
18159
|
+
await openOrPrint(deps, authURL.url, { log: !authURL.openingLogged });
|
|
18147
18160
|
return {
|
|
18148
18161
|
platform: "x",
|
|
18149
18162
|
status: "connected",
|
|
@@ -18154,7 +18167,8 @@ const reconnectXAccount = async (deps, args) => {
|
|
|
18154
18167
|
assertXAccountSelector(args.account);
|
|
18155
18168
|
const existing = findAccount(await listXLifecycleAccounts(deps, true), args.account);
|
|
18156
18169
|
if (!existing) throw new Error("x_account_not_found");
|
|
18157
|
-
await
|
|
18170
|
+
const authURL = await authURLFor(deps, () => connectURLFor(deps, existing.profileId));
|
|
18171
|
+
await openOrPrint(deps, authURL.url, { log: !authURL.openingLogged });
|
|
18158
18172
|
return {
|
|
18159
18173
|
platform: "x",
|
|
18160
18174
|
status: "connected",
|
|
@@ -20767,7 +20781,7 @@ const env = createEnv({
|
|
|
20767
20781
|
}
|
|
20768
20782
|
});
|
|
20769
20783
|
const SERVICE_NAME = "social-cli";
|
|
20770
|
-
const VERSION = "0.2.
|
|
20784
|
+
const VERSION = "0.2.2";
|
|
20771
20785
|
const apiURL = (path) => createAbsoluteURL(env.SOCIAL_API_URL, path);
|
|
20772
20786
|
//#endregion
|
|
20773
20787
|
//#region src/lib/bearer.ts
|
|
@@ -27830,12 +27844,30 @@ const lifecycleConnectContract = {
|
|
|
27830
27844
|
confirmation: false
|
|
27831
27845
|
};
|
|
27832
27846
|
const handleFor = (account) => account.handle.startsWith("@") ? account.handle : `@${account.handle}`;
|
|
27847
|
+
const authHandshakeMessage = "Handshaking auth...";
|
|
27833
27848
|
const lifecycleDepsWithTextLogs = (deps) => ({
|
|
27834
27849
|
...deps,
|
|
27835
|
-
log: (message) => writeText(deps, message)
|
|
27850
|
+
log: (message) => writeText(deps, message),
|
|
27851
|
+
handshakeAuthURL: async (operation) => {
|
|
27852
|
+
if (deps.ui) {
|
|
27853
|
+
const spinner = deps.ui.spinner();
|
|
27854
|
+
spinner.start(authHandshakeMessage);
|
|
27855
|
+
try {
|
|
27856
|
+
const url = await operation();
|
|
27857
|
+
spinner.stop(`Opening ${url}`);
|
|
27858
|
+
return url;
|
|
27859
|
+
} catch (error) {
|
|
27860
|
+
spinner.error(authHandshakeMessage);
|
|
27861
|
+
throw error;
|
|
27862
|
+
}
|
|
27863
|
+
}
|
|
27864
|
+
writeText(deps, authHandshakeMessage);
|
|
27865
|
+
const url = await operation();
|
|
27866
|
+
writeText(deps, `Opening ${url}`);
|
|
27867
|
+
return url;
|
|
27868
|
+
}
|
|
27836
27869
|
});
|
|
27837
27870
|
const runConnectOutput = async (deps, connect) => {
|
|
27838
|
-
writeText(deps, "Handshaking auth...");
|
|
27839
27871
|
writeText(deps, `${handleFor((await connect(lifecycleDepsWithTextLogs(deps))).account)} connected!`);
|
|
27840
27872
|
};
|
|
27841
27873
|
const createConnectPlatformCommand = (platform, run) => defineCommand({
|
|
@@ -28216,7 +28248,8 @@ const createCLIDeps = () => {
|
|
|
28216
28248
|
url
|
|
28217
28249
|
};
|
|
28218
28250
|
},
|
|
28219
|
-
writeOutput: printData
|
|
28251
|
+
writeOutput: printData,
|
|
28252
|
+
ui: createUI(process.stdout.isTTY === true)
|
|
28220
28253
|
};
|
|
28221
28254
|
};
|
|
28222
28255
|
//#endregion
|