@usesocial/cli 0.2.4 → 0.2.6
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 +12 -0
- package/README.md +2 -2
- package/bin/social.mjs +6 -4
- package/dist/index.d.mts +1394 -1
- package/dist/index.mjs +69 -49
- package/package.json +3 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { createInterface } from "node:readline/promises";
|
|
4
3
|
import * as fs from "node:fs";
|
|
5
|
-
import { createReadStream, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { createReadStream, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { createInterface } from "node:readline/promises";
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
8
|
import { dirname, join, resolve } from "node:path";
|
|
8
9
|
import { parseArgs, stripVTControlCharacters, styleText } from "node:util";
|
|
@@ -31,8 +32,8 @@ const exampleDeviceCode = "KN42-A98N";
|
|
|
31
32
|
const brand = {
|
|
32
33
|
org,
|
|
33
34
|
name: "social",
|
|
34
|
-
tagline: "
|
|
35
|
-
description: "
|
|
35
|
+
tagline: "Let your agent manage LinkedIn & X for you",
|
|
36
|
+
description: "A CLI for LinkedIn and X: outreach, posting, and audience insights from any shell."
|
|
36
37
|
};
|
|
37
38
|
const brandURLs = {
|
|
38
39
|
publicWebURL,
|
|
@@ -42,8 +43,8 @@ const brandURLs = {
|
|
|
42
43
|
const cliBrand = {
|
|
43
44
|
packageName: cliPackageName,
|
|
44
45
|
bin: cliBin,
|
|
45
|
-
packageDescription: "
|
|
46
|
-
helpDescription:
|
|
46
|
+
packageDescription: "A CLI for LinkedIn and X: outreach, posting, and audience insights from any shell.",
|
|
47
|
+
helpDescription: `social - ${brand.tagline}`,
|
|
47
48
|
installCommands: {
|
|
48
49
|
setup: `curl -fsSL ${setupScriptURL} | bash`,
|
|
49
50
|
bun: `bun install -g ${cliPackageName}`,
|
|
@@ -4601,7 +4602,7 @@ function custom(fn, _params) {
|
|
|
4601
4602
|
return /* @__PURE__ */ _custom(ZodMiniCustom, fn ?? (() => true), _params);
|
|
4602
4603
|
}
|
|
4603
4604
|
//#endregion
|
|
4604
|
-
//#region ../../node_modules/.bun/autumn-js@1.2.27+
|
|
4605
|
+
//#region ../../node_modules/.bun/autumn-js@1.2.27+152b7c5be68329ef/node_modules/autumn-js/dist/sdk/index.mjs
|
|
4605
4606
|
var __defProp = Object.defineProperty;
|
|
4606
4607
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
4607
4608
|
enumerable: true,
|
|
@@ -12520,7 +12521,7 @@ function kebabCase(str) {
|
|
|
12520
12521
|
//#region ../../packages/codegen/src/naming.ts
|
|
12521
12522
|
const flagName = (name) => kebabCase(name.replace(/[._]/g, "-"));
|
|
12522
12523
|
//#endregion
|
|
12523
|
-
//#region ../../packages/lib/src/
|
|
12524
|
+
//#region ../../packages/lib/src/routes.ts
|
|
12524
12525
|
const colonParamSegmentPattern = /^:(?<name>[A-Za-z0-9_]+)$/;
|
|
12525
12526
|
const braceParamSegmentPattern = /^\{(?<name>[A-Za-z0-9_]+)\}$/;
|
|
12526
12527
|
const splitPathSegments = (path) => path.split("/").filter(Boolean);
|
|
@@ -20921,7 +20922,7 @@ const createInstance = (defaults) => {
|
|
|
20921
20922
|
const ky = createInstance();
|
|
20922
20923
|
//#endregion
|
|
20923
20924
|
//#region package.json
|
|
20924
|
-
var version$1 = "0.2.
|
|
20925
|
+
var version$1 = "0.2.6";
|
|
20925
20926
|
//#endregion
|
|
20926
20927
|
//#region src/lib/env.ts
|
|
20927
20928
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -20932,8 +20933,8 @@ const env = createEnv({
|
|
|
20932
20933
|
SOCIAL_WEB_URL: process.env.SOCIAL_WEB_URL,
|
|
20933
20934
|
WSL_DISTRO_NAME: process.env.WSL_DISTRO_NAME,
|
|
20934
20935
|
WSL_INTEROP: process.env.WSL_INTEROP,
|
|
20935
|
-
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN:
|
|
20936
|
-
NEXT_PUBLIC_POSTHOG_HOST:
|
|
20936
|
+
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN: "phc_xxr5gJRiRMMSoyxQYCpT5zJQZmF88uMXf7mmYjKzLdki",
|
|
20937
|
+
NEXT_PUBLIC_POSTHOG_HOST: "https://us.i.posthog.com",
|
|
20937
20938
|
CI: process.env.CI,
|
|
20938
20939
|
DO_NOT_TRACK: process.env.DO_NOT_TRACK,
|
|
20939
20940
|
SOCIAL_DO_NOT_TRACK: process.env.SOCIAL_DO_NOT_TRACK
|
|
@@ -21307,11 +21308,15 @@ const writeStdoutBuffer = (buffer) => {
|
|
|
21307
21308
|
const writeStdout = (value) => {
|
|
21308
21309
|
writeStdoutBuffer(Buffer.from(`${value}\n`));
|
|
21309
21310
|
};
|
|
21311
|
+
let outputWriters = {
|
|
21312
|
+
stdout: writeStdout,
|
|
21313
|
+
stderr: (value) => process.stderr.write(`${value}\n`)
|
|
21314
|
+
};
|
|
21310
21315
|
const printLine = (value) => {
|
|
21311
|
-
|
|
21316
|
+
outputWriters.stdout(value);
|
|
21312
21317
|
};
|
|
21313
21318
|
const printData = (value) => {
|
|
21314
|
-
|
|
21319
|
+
outputWriters.stdout(JSON.stringify(value));
|
|
21315
21320
|
};
|
|
21316
21321
|
const valueAtPath = (value, path) => {
|
|
21317
21322
|
if (!path) return;
|
|
@@ -21464,7 +21469,7 @@ const errorPayload = (error) => {
|
|
|
21464
21469
|
};
|
|
21465
21470
|
};
|
|
21466
21471
|
const printError = (error) => {
|
|
21467
|
-
|
|
21472
|
+
outputWriters.stderr(JSON.stringify(errorPayload(error)));
|
|
21468
21473
|
};
|
|
21469
21474
|
//#endregion
|
|
21470
21475
|
//#region src/lib/validation.ts
|
|
@@ -28856,9 +28861,9 @@ const resolveCommandPath = async (command, rawArgs) => {
|
|
|
28856
28861
|
};
|
|
28857
28862
|
let commandContext;
|
|
28858
28863
|
const ANALYTICS_FLUSH_MS = 1500;
|
|
28859
|
-
const captureCommandFinished = (exitCode) => {
|
|
28864
|
+
const captureCommandFinished = (exitCode, telemetry) => {
|
|
28860
28865
|
if (!commandContext) return;
|
|
28861
|
-
|
|
28866
|
+
telemetry.capture("command_executed", {
|
|
28862
28867
|
command: commandContext.command,
|
|
28863
28868
|
group: commandContext.group,
|
|
28864
28869
|
exit_code: exitCode,
|
|
@@ -28866,33 +28871,54 @@ const captureCommandFinished = (exitCode) => {
|
|
|
28866
28871
|
duration_ms: Date.now() - commandContext.startedAt
|
|
28867
28872
|
});
|
|
28868
28873
|
};
|
|
28869
|
-
const finish = async (code) => {
|
|
28870
|
-
captureCommandFinished(code);
|
|
28871
|
-
await
|
|
28872
|
-
|
|
28874
|
+
const finish = async (code, telemetry) => {
|
|
28875
|
+
captureCommandFinished(code, telemetry);
|
|
28876
|
+
await telemetry.shutdown(ANALYTICS_FLUSH_MS);
|
|
28877
|
+
return code;
|
|
28873
28878
|
};
|
|
28874
28879
|
const printUsage = async (command, rawArgs) => {
|
|
28875
28880
|
const usage = await commandForUsage(command, rawArgs);
|
|
28876
|
-
|
|
28881
|
+
printLine(`${await renderUsage(usage.command, usage.parent)}\n`);
|
|
28882
|
+
};
|
|
28883
|
+
const createSocialCommand = (deps = createCLIDeps()) => {
|
|
28884
|
+
const accountCommand = createAccountCommand(deps);
|
|
28885
|
+
const linkedinCommand = createLinkedinCommands(deps);
|
|
28886
|
+
const xCommand = createXCommands(deps);
|
|
28887
|
+
const socialCommand = defineCommand({
|
|
28888
|
+
meta: {
|
|
28889
|
+
name: "social",
|
|
28890
|
+
version: VERSION,
|
|
28891
|
+
description: cliBrand.helpDescription
|
|
28892
|
+
},
|
|
28893
|
+
subCommands: {
|
|
28894
|
+
account: accountCommand,
|
|
28895
|
+
schema: schemaCommand,
|
|
28896
|
+
x: xCommand,
|
|
28897
|
+
linkedin: linkedinCommand
|
|
28898
|
+
}
|
|
28899
|
+
});
|
|
28900
|
+
setSchemaRootCommand(socialCommand);
|
|
28901
|
+
return socialCommand;
|
|
28877
28902
|
};
|
|
28878
|
-
const runSocial = async (command, rawArgs = process.argv.slice(2)) => {
|
|
28903
|
+
const runSocial = async ({ command = createSocialCommand(), rawArgs = process.argv.slice(2), telemetry = analytics } = {}) => {
|
|
28904
|
+
commandContext = void 0;
|
|
28879
28905
|
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
28880
28906
|
const unknown = await unknownSubCommandFor(command, rawArgs);
|
|
28881
28907
|
if (unknown) {
|
|
28882
28908
|
await printUsage(command, rawArgs);
|
|
28883
28909
|
printError(/* @__PURE__ */ new Error(`Unknown command: ${unknown}`));
|
|
28884
|
-
return await finish(2);
|
|
28910
|
+
return await finish(2, telemetry);
|
|
28885
28911
|
}
|
|
28886
28912
|
await printUsage(command, rawArgs);
|
|
28887
|
-
return await finish(0);
|
|
28913
|
+
return await finish(0, telemetry);
|
|
28888
28914
|
}
|
|
28889
28915
|
if (rawArgs.length === 1 && (rawArgs[0] === "--version" || rawArgs[0] === "-v")) {
|
|
28890
|
-
|
|
28891
|
-
return await finish(0);
|
|
28916
|
+
printLine(VERSION);
|
|
28917
|
+
return await finish(0, telemetry);
|
|
28892
28918
|
}
|
|
28893
28919
|
if (await groupInvocationFor(command, rawArgs)) {
|
|
28894
28920
|
await printUsage(command, rawArgs);
|
|
28895
|
-
return await finish(0);
|
|
28921
|
+
return await finish(0, telemetry);
|
|
28896
28922
|
}
|
|
28897
28923
|
const path = await resolveCommandPath(command, rawArgs);
|
|
28898
28924
|
if (path.length > 0) commandContext = {
|
|
@@ -28905,31 +28931,25 @@ const runSocial = async (command, rawArgs = process.argv.slice(2)) => {
|
|
|
28905
28931
|
if (loginArgError) throw loginArgError;
|
|
28906
28932
|
await runCommand$1(command, { rawArgs });
|
|
28907
28933
|
} catch (error) {
|
|
28908
|
-
if (error instanceof SilentExit) return await finish(error.code);
|
|
28934
|
+
if (error instanceof SilentExit) return await finish(error.code, telemetry);
|
|
28909
28935
|
if (isCittyUsageError(error) && process.stderr.isTTY) await printUsage(command, rawArgs);
|
|
28910
28936
|
printError(error);
|
|
28911
|
-
return await finish(exitCodeFor(error));
|
|
28937
|
+
return await finish(exitCodeFor(error), telemetry);
|
|
28912
28938
|
}
|
|
28913
|
-
return await finish(0);
|
|
28939
|
+
return await finish(0, telemetry);
|
|
28914
28940
|
};
|
|
28915
|
-
const
|
|
28916
|
-
|
|
28917
|
-
|
|
28918
|
-
const
|
|
28919
|
-
const
|
|
28920
|
-
|
|
28921
|
-
|
|
28922
|
-
|
|
28923
|
-
|
|
28924
|
-
|
|
28925
|
-
subCommands: {
|
|
28926
|
-
account: accountCommand,
|
|
28927
|
-
schema: schemaCommand,
|
|
28928
|
-
x: xCommand,
|
|
28929
|
-
linkedin: linkedinCommand
|
|
28941
|
+
const main = async () => {
|
|
28942
|
+
process.exit(await runSocial());
|
|
28943
|
+
};
|
|
28944
|
+
const directEntryPath = () => {
|
|
28945
|
+
const entry = process.argv[1];
|
|
28946
|
+
if (!entry) return false;
|
|
28947
|
+
try {
|
|
28948
|
+
return realpathSync(entry) === fileURLToPath(import.meta.url);
|
|
28949
|
+
} catch {
|
|
28950
|
+
return false;
|
|
28930
28951
|
}
|
|
28931
|
-
}
|
|
28932
|
-
|
|
28933
|
-
await runSocial(socialCommand);
|
|
28952
|
+
};
|
|
28953
|
+
if (directEntryPath()) await main();
|
|
28934
28954
|
//#endregion
|
|
28935
|
-
export { resolveCommandPath };
|
|
28955
|
+
export { createSocialCommand, main, resolveCommandPath, runSocial };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usesocial/cli",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "A CLI for LinkedIn and X: outreach, posting, and audience insights from any shell.",
|
|
4
4
|
"homepage": "https://usesocial.dev",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"private": false,
|
|
14
|
-
"version": "0.2.
|
|
14
|
+
"version": "0.2.6",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=22.5.0"
|
|
@@ -29,10 +29,9 @@
|
|
|
29
29
|
"build": "tsdown",
|
|
30
30
|
"dev": "bun src/index.ts",
|
|
31
31
|
"prepack": "bun run build",
|
|
32
|
-
"test": "bun test"
|
|
32
|
+
"test": "bun test --parallel=${BUN_TEST_PARALLEL:-8}"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@t3-oss/env-core": "^0.13.11",
|
|
36
35
|
"@napi-rs/keyring": "^1.3.0"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|