@usesocial/cli 0.2.3 → 0.2.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/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
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
- import { createEnv } from "@t3-oss/env-core";
9
9
  import { parseArgs, stripVTControlCharacters, styleText } from "node:util";
10
10
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
11
11
  import { createHash } from "node:crypto";
@@ -32,8 +32,8 @@ const exampleDeviceCode = "KN42-A98N";
32
32
  const brand = {
33
33
  org,
34
34
  name: "social",
35
- tagline: "Agent-run distribution",
36
- description: "One CLI that lets your AI agent run your distribution across X and LinkedIn: outreach, posting, and audience insights, programmatically."
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."
37
37
  };
38
38
  const brandURLs = {
39
39
  publicWebURL,
@@ -43,8 +43,8 @@ const brandURLs = {
43
43
  const cliBrand = {
44
44
  packageName: cliPackageName,
45
45
  bin: cliBin,
46
- packageDescription: "Agent-run distribution across X and LinkedIn: outreach, posting, and audience insights from any shell.",
47
- helpDescription: "social - Agent-run distribution across X and LinkedIn",
46
+ packageDescription: "A CLI for LinkedIn and X: outreach, posting, and audience insights from any shell.",
47
+ helpDescription: `social - ${brand.tagline}`,
48
48
  installCommands: {
49
49
  setup: `curl -fsSL ${setupScriptURL} | bash`,
50
50
  bun: `bun install -g ${cliPackageName}`,
@@ -4602,7 +4602,7 @@ function custom(fn, _params) {
4602
4602
  return /* @__PURE__ */ _custom(ZodMiniCustom, fn ?? (() => true), _params);
4603
4603
  }
4604
4604
  //#endregion
4605
- //#region ../../node_modules/.bun/autumn-js@1.2.27+85405b47aac05ddb/node_modules/autumn-js/dist/sdk/index.mjs
4605
+ //#region ../../node_modules/.bun/autumn-js@1.2.27+152b7c5be68329ef/node_modules/autumn-js/dist/sdk/index.mjs
4606
4606
  var __defProp = Object.defineProperty;
4607
4607
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
4608
4608
  enumerable: true,
@@ -6280,6 +6280,87 @@ function createPageIterator(page, halt) {
6280
6280
  }
6281
6281
  const MARKUP_BPS = 5e3;
6282
6282
  //#endregion
6283
+ //#region ../../node_modules/.bun/@t3-oss+env-core@0.13.11+1cd18485b0404aca/node_modules/@t3-oss/env-core/dist/standard.js
6284
+ function ensureSynchronous(value, message) {
6285
+ if (value instanceof Promise) throw new Error(message);
6286
+ }
6287
+ function parseWithDictionary(dictionary, value) {
6288
+ const result = {};
6289
+ const issues = [];
6290
+ for (const key in dictionary) {
6291
+ const propResult = dictionary[key]["~standard"].validate(value[key]);
6292
+ ensureSynchronous(propResult, `Validation must be synchronous, but ${key} returned a Promise.`);
6293
+ if (propResult.issues) {
6294
+ issues.push(...propResult.issues.map((issue) => ({
6295
+ ...issue,
6296
+ message: issue.message,
6297
+ path: [key, ...issue.path ?? []]
6298
+ })));
6299
+ continue;
6300
+ }
6301
+ result[key] = propResult.value;
6302
+ }
6303
+ if (issues.length) return { issues };
6304
+ return { value: result };
6305
+ }
6306
+ //#endregion
6307
+ //#region ../../node_modules/.bun/@t3-oss+env-core@0.13.11+1cd18485b0404aca/node_modules/@t3-oss/env-core/dist/index.js
6308
+ /**
6309
+ * Create a new environment variable schema.
6310
+ */
6311
+ function createEnv(opts) {
6312
+ const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
6313
+ if (opts.emptyStringAsUndefined ?? false) {
6314
+ for (const [key, value] of Object.entries(runtimeEnv)) if (value === "") delete runtimeEnv[key];
6315
+ }
6316
+ if (!!opts.skipValidation) {
6317
+ if (opts.extends) for (const preset of opts.extends) preset.skipValidation = true;
6318
+ return runtimeEnv;
6319
+ }
6320
+ const _client = typeof opts.client === "object" ? opts.client : {};
6321
+ const _server = typeof opts.server === "object" ? opts.server : {};
6322
+ const _shared = typeof opts.shared === "object" ? opts.shared : {};
6323
+ const isServer = opts.isServer ?? (typeof window === "undefined" || "Deno" in window);
6324
+ const finalSchemaShape = isServer ? {
6325
+ ..._server,
6326
+ ..._shared,
6327
+ ..._client
6328
+ } : {
6329
+ ..._client,
6330
+ ..._shared
6331
+ };
6332
+ const parsed = (opts.createFinalSchema?.(finalSchemaShape, isServer))?.["~standard"].validate(runtimeEnv) ?? parseWithDictionary(finalSchemaShape, runtimeEnv);
6333
+ ensureSynchronous(parsed, "Validation must be synchronous");
6334
+ const onValidationError = opts.onValidationError ?? ((issues) => {
6335
+ console.error("❌ Invalid environment variables:", issues);
6336
+ throw new Error("Invalid environment variables");
6337
+ });
6338
+ const onInvalidAccess = opts.onInvalidAccess ?? (() => {
6339
+ throw new Error("❌ Attempted to access a server-side environment variable on the client");
6340
+ });
6341
+ if (parsed.issues) return onValidationError(parsed.issues);
6342
+ const isServerAccess = (prop) => {
6343
+ if (!opts.clientPrefix) return true;
6344
+ return !prop.startsWith(opts.clientPrefix) && !(prop in _shared);
6345
+ };
6346
+ const isValidServerAccess = (prop) => {
6347
+ return isServer || !isServerAccess(prop);
6348
+ };
6349
+ const ignoreProp = (prop) => {
6350
+ return prop === "__esModule" || prop === "$$typeof";
6351
+ };
6352
+ const extendedObj = (opts.extends ?? []).reduce((acc, curr) => {
6353
+ return Object.assign(acc, curr);
6354
+ }, {});
6355
+ const fullObj = Object.assign(extendedObj, parsed.value);
6356
+ return new Proxy(fullObj, { get(target, prop) {
6357
+ if (typeof prop !== "string") return void 0;
6358
+ if (ignoreProp(prop)) return void 0;
6359
+ if (!isValidServerAccess(prop)) return onInvalidAccess(prop);
6360
+ return Reflect.get(target, prop);
6361
+ } });
6362
+ }
6363
+ //#endregion
6283
6364
  //#region ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/iso.js
6284
6365
  const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
6285
6366
  $ZodISODateTime.init(inst, def);
@@ -12440,7 +12521,7 @@ function kebabCase(str) {
12440
12521
  //#region ../../packages/codegen/src/naming.ts
12441
12522
  const flagName = (name) => kebabCase(name.replace(/[._]/g, "-"));
12442
12523
  //#endregion
12443
- //#region ../../packages/lib/src/path-template.ts
12524
+ //#region ../../packages/lib/src/routes.ts
12444
12525
  const colonParamSegmentPattern = /^:(?<name>[A-Za-z0-9_]+)$/;
12445
12526
  const braceParamSegmentPattern = /^\{(?<name>[A-Za-z0-9_]+)\}$/;
12446
12527
  const splitPathSegments = (path) => path.split("/").filter(Boolean);
@@ -20841,7 +20922,7 @@ const createInstance = (defaults) => {
20841
20922
  const ky = createInstance();
20842
20923
  //#endregion
20843
20924
  //#region package.json
20844
- var version$1 = "0.2.3";
20925
+ var version$1 = "0.2.5";
20845
20926
  //#endregion
20846
20927
  //#region src/lib/env.ts
20847
20928
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -20852,8 +20933,8 @@ const env = createEnv({
20852
20933
  SOCIAL_WEB_URL: process.env.SOCIAL_WEB_URL,
20853
20934
  WSL_DISTRO_NAME: process.env.WSL_DISTRO_NAME,
20854
20935
  WSL_INTEROP: process.env.WSL_INTEROP,
20855
- NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN: process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN,
20856
- NEXT_PUBLIC_POSTHOG_HOST: process.env.NEXT_PUBLIC_POSTHOG_HOST,
20936
+ NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN: "phc_xxr5gJRiRMMSoyxQYCpT5zJQZmF88uMXf7mmYjKzLdki",
20937
+ NEXT_PUBLIC_POSTHOG_HOST: "https://us.i.posthog.com",
20857
20938
  CI: process.env.CI,
20858
20939
  DO_NOT_TRACK: process.env.DO_NOT_TRACK,
20859
20940
  SOCIAL_DO_NOT_TRACK: process.env.SOCIAL_DO_NOT_TRACK
@@ -21227,11 +21308,15 @@ const writeStdoutBuffer = (buffer) => {
21227
21308
  const writeStdout = (value) => {
21228
21309
  writeStdoutBuffer(Buffer.from(`${value}\n`));
21229
21310
  };
21311
+ let outputWriters = {
21312
+ stdout: writeStdout,
21313
+ stderr: (value) => process.stderr.write(`${value}\n`)
21314
+ };
21230
21315
  const printLine = (value) => {
21231
- writeStdout(value);
21316
+ outputWriters.stdout(value);
21232
21317
  };
21233
21318
  const printData = (value) => {
21234
- writeStdout(JSON.stringify(value));
21319
+ outputWriters.stdout(JSON.stringify(value));
21235
21320
  };
21236
21321
  const valueAtPath = (value, path) => {
21237
21322
  if (!path) return;
@@ -21384,7 +21469,7 @@ const errorPayload = (error) => {
21384
21469
  };
21385
21470
  };
21386
21471
  const printError = (error) => {
21387
- console.error(JSON.stringify(errorPayload(error)));
21472
+ outputWriters.stderr(JSON.stringify(errorPayload(error)));
21388
21473
  };
21389
21474
  //#endregion
21390
21475
  //#region src/lib/validation.ts
@@ -28776,9 +28861,9 @@ const resolveCommandPath = async (command, rawArgs) => {
28776
28861
  };
28777
28862
  let commandContext;
28778
28863
  const ANALYTICS_FLUSH_MS = 1500;
28779
- const captureCommandFinished = (exitCode) => {
28864
+ const captureCommandFinished = (exitCode, telemetry) => {
28780
28865
  if (!commandContext) return;
28781
- analytics.capture("command_executed", {
28866
+ telemetry.capture("command_executed", {
28782
28867
  command: commandContext.command,
28783
28868
  group: commandContext.group,
28784
28869
  exit_code: exitCode,
@@ -28786,33 +28871,54 @@ const captureCommandFinished = (exitCode) => {
28786
28871
  duration_ms: Date.now() - commandContext.startedAt
28787
28872
  });
28788
28873
  };
28789
- const finish = async (code) => {
28790
- captureCommandFinished(code);
28791
- await analytics.shutdown(ANALYTICS_FLUSH_MS);
28792
- process.exit(code);
28874
+ const finish = async (code, telemetry) => {
28875
+ captureCommandFinished(code, telemetry);
28876
+ await telemetry.shutdown(ANALYTICS_FLUSH_MS);
28877
+ return code;
28793
28878
  };
28794
28879
  const printUsage = async (command, rawArgs) => {
28795
28880
  const usage = await commandForUsage(command, rawArgs);
28796
- console.log(`${await renderUsage(usage.command, usage.parent)}\n`);
28881
+ printLine(`${await renderUsage(usage.command, usage.parent)}\n`);
28797
28882
  };
28798
- const runSocial = async (command, rawArgs = process.argv.slice(2)) => {
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;
28902
+ };
28903
+ const runSocial = async ({ command = createSocialCommand(), rawArgs = process.argv.slice(2), telemetry = analytics } = {}) => {
28904
+ commandContext = void 0;
28799
28905
  if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
28800
28906
  const unknown = await unknownSubCommandFor(command, rawArgs);
28801
28907
  if (unknown) {
28802
28908
  await printUsage(command, rawArgs);
28803
28909
  printError(/* @__PURE__ */ new Error(`Unknown command: ${unknown}`));
28804
- return await finish(2);
28910
+ return await finish(2, telemetry);
28805
28911
  }
28806
28912
  await printUsage(command, rawArgs);
28807
- return await finish(0);
28913
+ return await finish(0, telemetry);
28808
28914
  }
28809
28915
  if (rawArgs.length === 1 && (rawArgs[0] === "--version" || rawArgs[0] === "-v")) {
28810
- console.log(VERSION);
28811
- return await finish(0);
28916
+ printLine(VERSION);
28917
+ return await finish(0, telemetry);
28812
28918
  }
28813
28919
  if (await groupInvocationFor(command, rawArgs)) {
28814
28920
  await printUsage(command, rawArgs);
28815
- return await finish(0);
28921
+ return await finish(0, telemetry);
28816
28922
  }
28817
28923
  const path = await resolveCommandPath(command, rawArgs);
28818
28924
  if (path.length > 0) commandContext = {
@@ -28825,31 +28931,25 @@ const runSocial = async (command, rawArgs = process.argv.slice(2)) => {
28825
28931
  if (loginArgError) throw loginArgError;
28826
28932
  await runCommand$1(command, { rawArgs });
28827
28933
  } catch (error) {
28828
- if (error instanceof SilentExit) return await finish(error.code);
28934
+ if (error instanceof SilentExit) return await finish(error.code, telemetry);
28829
28935
  if (isCittyUsageError(error) && process.stderr.isTTY) await printUsage(command, rawArgs);
28830
28936
  printError(error);
28831
- return await finish(exitCodeFor(error));
28937
+ return await finish(exitCodeFor(error), telemetry);
28832
28938
  }
28833
- return await finish(0);
28939
+ return await finish(0, telemetry);
28834
28940
  };
28835
- const deps = createCLIDeps();
28836
- const accountCommand = createAccountCommand(deps);
28837
- const linkedinCommand = createLinkedinCommands(deps);
28838
- const xCommand = createXCommands(deps);
28839
- const socialCommand = defineCommand({
28840
- meta: {
28841
- name: "social",
28842
- version: VERSION,
28843
- description: cliBrand.helpDescription
28844
- },
28845
- subCommands: {
28846
- account: accountCommand,
28847
- schema: schemaCommand,
28848
- x: xCommand,
28849
- 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;
28850
28951
  }
28851
- });
28852
- setSchemaRootCommand(socialCommand);
28853
- await runSocial(socialCommand);
28952
+ };
28953
+ if (directEntryPath()) await main();
28854
28954
  //#endregion
28855
- 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": "Agent-run distribution across X and LinkedIn: outreach, posting, and audience insights from any shell.",
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.3",
14
+ "version": "0.2.5",
15
15
  "type": "module",
16
16
  "engines": {
17
17
  "node": ">=22.5.0"
@@ -29,7 +29,7 @@
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
35
  "@t3-oss/env-core": "^0.13.11",
@@ -39,7 +39,6 @@
39
39
  "@clack/prompts": "^1.4.0",
40
40
  "@orpc/client": "^1.14.2",
41
41
  "@orpc/contract": "^1.14.2",
42
- "@t3-oss/env-core": "^0.13.11",
43
42
  "@usesocial/api": "workspace:*",
44
43
  "@usesocial/billing": "workspace:*",
45
44
  "@usesocial/constants": "workspace:*",