chofex-cli 0.1.145 → 0.1.147

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.
Files changed (2) hide show
  1. package/dist/index.js +90 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -58564,7 +58564,7 @@ var challengeCatalog = [
58564
58564
  format: "accuracy",
58565
58565
  formatLabel: "Accuracy score",
58566
58566
  opensAt: "2026-09-17T14:00:00.000Z",
58567
- rankingVisibleAt: "2026-09-19T02:00:00.000Z",
58567
+ rankingVisibleAt: "2026-09-23T20:00:00.000Z",
58568
58568
  queryLimit: 25,
58569
58569
  evaluationLimit: 3,
58570
58570
  hiddenSampleSize: 1000,
@@ -58725,6 +58725,7 @@ var ParticipantChallengeProgressSchema = exports_Schema.Struct({
58725
58725
  evaluationsLimit: exports_Schema.Number,
58726
58726
  bestAccuracy: exports_Schema.optional(exports_Schema.Number),
58727
58727
  bestExactCount: exports_Schema.optional(exports_Schema.Number),
58728
+ completionDurationMs: exports_Schema.optional(exports_Schema.Number),
58728
58729
  shareCode: exports_Schema.optional(exports_Schema.String),
58729
58730
  rank: exports_Schema.optional(exports_Schema.Number)
58730
58731
  });
@@ -59138,11 +59139,11 @@ import { createHash as createHash2, randomBytes as randomBytes4 } from "node:cry
59138
59139
  import { createServer } from "node:http";
59139
59140
 
59140
59141
  // src/config.ts
59141
- var oauthIssuer = process.env.CHOFEX_OAUTH_ISSUER ?? "https://close-newt-8265.clerk.accounts.dev";
59142
+ var oauthIssuer = process.env.CHOFEX_OAUTH_ISSUER ?? "https://clerk.hacktheandes.com";
59142
59143
  var config = {
59143
59144
  apiUrl: process.env.CHOFEX_API_URL ?? "https://hacktheandes.com",
59144
59145
  publicSiteUrl: process.env.CHOFEX_PUBLIC_SITE_URL ?? "https://hacktheandes.com",
59145
- oauthClientId: process.env.CHOFEX_OAUTH_CLIENT_ID ?? "1YfuXKgOXkdH094s",
59146
+ oauthClientId: process.env.CHOFEX_OAUTH_CLIENT_ID ?? "HddO78wKpq5PFIEl",
59146
59147
  authorizationUrl: `${oauthIssuer}/oauth/authorize`,
59147
59148
  tokenUrl: `${oauthIssuer}/oauth/token`,
59148
59149
  revocationUrl: `${oauthIssuer}/oauth/token/revoke`
@@ -59463,7 +59464,9 @@ If the browser did not open automatically, open that URL yourself.`);
59463
59464
  redirect_uri: redirectUri,
59464
59465
  code_verifier: verifier
59465
59466
  });
59466
- await saveCredentials(credentialsFromToken(body));
59467
+ const credentials = credentialsFromToken(body);
59468
+ await saveCredentials(credentials);
59469
+ return credentials.accessToken;
59467
59470
  } finally {
59468
59471
  clearTimeout(timeout3);
59469
59472
  server.close();
@@ -62459,7 +62462,7 @@ var uploadPicture = exports_Effect.fn("uploadPicture")(function* (options, path4
62459
62462
  import { spawn as spawn3 } from "node:child_process";
62460
62463
  import { mkdtemp as mkdtemp2, rm as rm2 } from "node:fs/promises";
62461
62464
  import { tmpdir as tmpdir2 } from "node:os";
62462
- import { join as join3 } from "node:path";
62465
+ import { dirname as dirname2, join as join3 } from "node:path";
62463
62466
  var cliPackageName = "chofex-cli";
62464
62467
  var upgradeVersion = "latest";
62465
62468
  var npmUpgradeArguments = (cacheDirectory) => [
@@ -62470,31 +62473,81 @@ var npmUpgradeArguments = (cacheDirectory) => [
62470
62473
  "--prefer-online",
62471
62474
  `--cache=${cacheDirectory}`
62472
62475
  ];
62473
- var runNpm = (arguments_) => new Promise((resolve4, reject) => {
62474
- const executable = process.platform === "win32" ? "npm.cmd" : "npm";
62476
+ var runProcess = (executable, arguments_, input) => new Promise((resolve4, reject) => {
62477
+ const stdin = input === undefined ? "ignore" : "pipe";
62475
62478
  const child = spawn3(executable, arguments_, {
62476
- stdio: ["ignore", "ignore", "pipe"]
62479
+ stdio: [stdin, "ignore", "pipe"]
62477
62480
  });
62478
62481
  let stderr = "";
62479
- child.stderr.setEncoding("utf8");
62480
- child.stderr.on("data", (chunk) => {
62482
+ const stderrStream = child.stderr;
62483
+ if (stderrStream === null) {
62484
+ child.kill();
62485
+ reject(new Error(`Could not capture stderr from ${executable}`));
62486
+ return;
62487
+ }
62488
+ stderrStream.setEncoding("utf8");
62489
+ stderrStream.on("data", (chunk) => {
62481
62490
  stderr += chunk;
62482
62491
  });
62483
62492
  child.on("error", reject);
62484
62493
  child.on("close", (exitCode) => {
62485
62494
  resolve4({ exitCode: exitCode ?? 1, stderr: stderr.trim() });
62486
62495
  });
62496
+ if (input !== undefined) {
62497
+ const stdinStream = child.stdin;
62498
+ if (stdinStream === null) {
62499
+ child.kill();
62500
+ reject(new Error(`Could not send input to ${executable}`));
62501
+ return;
62502
+ }
62503
+ stdinStream.end(input);
62504
+ }
62487
62505
  });
62488
- var upgradeCli = async (runner = runNpm) => {
62506
+ var runNpm = (arguments_) => {
62507
+ const executable = process.platform === "win32" ? "npm.cmd" : "npm";
62508
+ return runProcess(executable, arguments_);
62509
+ };
62510
+ var installerUrl = "https://hacktheandes.com/install";
62511
+ var runInstaller = async (installDirectory) => {
62512
+ const response = await fetch(installerUrl);
62513
+ if (!response.ok) {
62514
+ throw new Error(`installer download returned HTTP ${response.status}`);
62515
+ }
62516
+ const script = await response.text();
62517
+ const arguments_ = [
62518
+ "-s",
62519
+ "--",
62520
+ "--install-dir",
62521
+ installDirectory,
62522
+ "--no-modify-path"
62523
+ ];
62524
+ if (process.platform === "win32") {
62525
+ arguments_.push("--defer-until-pid", String(process.pid));
62526
+ }
62527
+ return runProcess("bash", arguments_, script);
62528
+ };
62529
+ var isStandaloneExecutable = () => typeof Bun !== "undefined" && Bun.isStandaloneExecutable;
62530
+ var assertSuccessful = (result3, program) => {
62531
+ if (result3.exitCode === 0)
62532
+ return;
62533
+ let detail = "";
62534
+ if (result3.stderr)
62535
+ detail = `: ${result3.stderr}`;
62536
+ throw new Error(`${program} exited with code ${result3.exitCode}${detail}`);
62537
+ };
62538
+ var upgradeCli = async (options = {}) => {
62539
+ const standalone = options.standalone ?? isStandaloneExecutable();
62540
+ if (standalone) {
62541
+ const runner2 = options.installerRunner ?? runInstaller;
62542
+ const result3 = await runner2(dirname2(process.execPath));
62543
+ assertSuccessful(result3, "installer");
62544
+ return;
62545
+ }
62546
+ const runner = options.npmRunner ?? runNpm;
62489
62547
  const cacheDirectory = await mkdtemp2(join3(tmpdir2(), "chofex-npm-cache-"));
62490
62548
  try {
62491
62549
  const result3 = await runner(npmUpgradeArguments(cacheDirectory));
62492
- if (result3.exitCode === 0)
62493
- return;
62494
- let detail = "";
62495
- if (result3.stderr)
62496
- detail = `: ${result3.stderr}`;
62497
- throw new Error(`npm exited with code ${result3.exitCode}${detail}`);
62550
+ assertSuccessful(result3, "npm");
62498
62551
  } finally {
62499
62552
  await rm2(cacheDirectory, { recursive: true, force: true });
62500
62553
  }
@@ -62632,17 +62685,18 @@ var confirmCommand = exports_Command.make("confirm", {
62632
62685
  ]));
62633
62686
  var loginCommand = exports_Command.make("login", {}, exports_Effect.fn("loginCommand")(function* () {
62634
62687
  const options = yield* root;
62635
- const operation = exports_Effect.tryPromise({
62636
- try: async () => {
62637
- await login();
62638
- return {
62639
- version: 1,
62640
- ok: true,
62641
- requestId: crypto.randomUUID(),
62642
- data: { authenticated: true }
62643
- };
62644
- },
62645
- catch: (error2) => cliError("LOGIN_FAILED", String(error2))
62688
+ const operation = exports_Effect.gen(function* () {
62689
+ const token = yield* exports_Effect.tryPromise({
62690
+ try: () => login(),
62691
+ catch: (error2) => cliError("LOGIN_FAILED", String(error2))
62692
+ });
62693
+ yield* getCurrentUser({ apiUrl: options.apiUrl, token }).pipe(exports_Effect.catch(() => exports_Effect.succeed(undefined)));
62694
+ return {
62695
+ version: 1,
62696
+ ok: true,
62697
+ requestId: crypto.randomUUID(),
62698
+ data: { authenticated: true }
62699
+ };
62646
62700
  });
62647
62701
  yield* execute(options.output, operation, () => "Signed in successfully.");
62648
62702
  })).pipe(exports_Command.withDescription("Sign in through Clerk OAuth in your browser"));
@@ -62692,7 +62746,7 @@ var makeUpgradeCommand = (name) => exports_Command.make(name, {}, exports_Effect
62692
62746
  }
62693
62747
  };
62694
62748
  },
62695
- catch: (error2) => cliError("UPGRADE_FAILED", `npm could not update ${cliPackageName}`, false, String(error2))
62749
+ catch: (error2) => cliError("UPGRADE_FAILED", `Could not update ${cliPackageName}`, false, String(error2))
62696
62750
  });
62697
62751
  yield* execute(options.output, operation, () => `Updated ${cliPackageName} to the ${upgradeVersion} version.`);
62698
62752
  })).pipe(exports_Command.withDescription("Update chofex-cli to the latest version"));
@@ -62928,8 +62982,13 @@ ${shortcuts.flatMap((line) => wrap(line, width)).join(`
62928
62982
  };
62929
62983
 
62930
62984
  // src/index.ts
62931
- var packageMetadata = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
62932
- var cliVersion = packageMetadata.version;
62985
+ var readCliVersion = () => {
62986
+ if (typeof CHOFEX_VERSION !== "undefined")
62987
+ return CHOFEX_VERSION;
62988
+ const packageMetadata = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
62989
+ return packageMetadata.version;
62990
+ };
62991
+ var cliVersion = readCliVersion();
62933
62992
  var arguments_ = process.argv.slice(2);
62934
62993
  var jsonOutputRequested = (arguments_2) => {
62935
62994
  if (arguments_2.includes("--output=json"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chofex-cli",
3
- "version": "0.1.145",
3
+ "version": "0.1.147",
4
4
  "description": "Command-line client for Hack the Andes",
5
5
  "type": "module",
6
6
  "bin": {