chofex-cli 0.1.9 → 0.1.11

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 (3) hide show
  1. package/README.md +3 -0
  2. package/dist/index.js +148 -22
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -22,3 +22,6 @@ token with `CHOFEX_TOKEN`.
22
22
 
23
23
  Use `CHOFEX_API_URL` to override the API URL when running against a hosted or
24
24
  local Chofex instance.
25
+
26
+ Registration links use `https://andres.crafter.run` by default. Local or preview
27
+ environments can override that origin with `CHOFEX_PUBLIC_SITE_URL`.
package/dist/index.js CHANGED
@@ -30971,6 +30971,7 @@ import { createServer } from "node:http";
30971
30971
  var oauthIssuer = process.env.CHOFEX_OAUTH_ISSUER ?? "https://close-newt-8265.clerk.accounts.dev";
30972
30972
  var config = {
30973
30973
  apiUrl: process.env.CHOFEX_API_URL ?? "http://localhost:3000",
30974
+ publicSiteUrl: process.env.CHOFEX_PUBLIC_SITE_URL ?? "https://andres.crafter.run",
30974
30975
  oauthClientId: process.env.CHOFEX_OAUTH_CLIENT_ID ?? "1YfuXKgOXkdH094s",
30975
30976
  authorizationUrl: `${oauthIssuer}/oauth/authorize`,
30976
30977
  tokenUrl: `${oauthIssuer}/oauth/token`,
@@ -31422,6 +31423,142 @@ var confirmAttendance = (options, input) => request3(options, "/api/v1/registrat
31422
31423
 
31423
31424
  // src/input.ts
31424
31425
  import { readFile as readFile3 } from "node:fs/promises";
31426
+
31427
+ // src/profile-username-prompt.ts
31428
+ var ansi = {
31429
+ bold: "\x1B[1m",
31430
+ underlined: "\x1B[4m",
31431
+ italicized: "\x1B[3m",
31432
+ reset: "\x1B[0m",
31433
+ eraseLine: "\x1B[2K",
31434
+ cursorStart: "\x1B[G",
31435
+ cursorSave: "\x1B[s",
31436
+ cursorRestore: "\x1B[u",
31437
+ cursorUp: "\x1B[1A",
31438
+ cursorDown: "\x1B[1B",
31439
+ beep: "\x07"
31440
+ };
31441
+ var annotate5 = (text2, ...styles) => {
31442
+ if (text2 === "")
31443
+ return "";
31444
+ return `${styles.join("")}${text2}${ansi.reset}`;
31445
+ };
31446
+ var nextFrame = (state) => ({
31447
+ _tag: "NextFrame",
31448
+ state
31449
+ });
31450
+ var beep2 = () => ({
31451
+ _tag: "Beep"
31452
+ });
31453
+ var renderProfileUsername = (state, message, profilePrefix, submitted) => {
31454
+ const theme = exports_Prompt.makeTheme();
31455
+ const leadingSymbol = submitted ? theme.tick : theme.prefix;
31456
+ const trailingSymbol = submitted ? theme.ellipsis : theme.pointerSmall;
31457
+ const leadingColor = submitted ? theme.successColor : theme.primaryColor;
31458
+ let valueColor = `${ansi.underlined}${theme.primaryColor}`;
31459
+ if (submitted)
31460
+ valueColor = theme.submittedColor;
31461
+ if (state.error !== undefined)
31462
+ valueColor = theme.errorColor;
31463
+ const line = [
31464
+ annotate5(leadingSymbol, leadingColor),
31465
+ annotate5(message, ansi.bold),
31466
+ annotate5(trailingSymbol, theme.mutedColor),
31467
+ `${annotate5(profilePrefix, theme.mutedColor)}${annotate5(state.value, valueColor)}`
31468
+ ].join(" ");
31469
+ const cursorOffset = state.cursor - state.value.length;
31470
+ let output = line;
31471
+ if (cursorOffset < 0)
31472
+ output += `\x1B[${-cursorOffset}D`;
31473
+ if (state.error !== undefined && !submitted) {
31474
+ const error2 = `${annotate5(theme.pointerSmall, theme.errorColor)} ${annotate5(state.error, ansi.italicized, theme.errorColor)}`;
31475
+ output += `${ansi.cursorSave}
31476
+ ${error2}${ansi.cursorRestore}`;
31477
+ }
31478
+ if (submitted)
31479
+ output += `
31480
+ `;
31481
+ return output;
31482
+ };
31483
+ var clearProfileUsername = (state) => {
31484
+ if (state.error === undefined) {
31485
+ return ansi.eraseLine + ansi.cursorStart;
31486
+ }
31487
+ return ansi.cursorDown + ansi.eraseLine + ansi.cursorUp + ansi.eraseLine + ansi.cursorStart;
31488
+ };
31489
+ var insertInput = (state, input) => {
31490
+ const beforeCursor = state.value.slice(0, state.cursor);
31491
+ const afterCursor = state.value.slice(state.cursor);
31492
+ return nextFrame({
31493
+ cursor: state.cursor + input.length,
31494
+ value: `${beforeCursor}${input}${afterCursor}`
31495
+ });
31496
+ };
31497
+ var processProfileUsername = (input, state) => {
31498
+ if (input.key.ctrl) {
31499
+ if (input.key.name === "u") {
31500
+ return exports_Effect.succeed(nextFrame({ cursor: 0, value: "" }));
31501
+ }
31502
+ if (input.key.name === "a") {
31503
+ return exports_Effect.succeed(nextFrame({ ...state, cursor: 0 }));
31504
+ }
31505
+ if (input.key.name === "e") {
31506
+ return exports_Effect.succeed(nextFrame({ ...state, cursor: state.value.length }));
31507
+ }
31508
+ return exports_Effect.succeed(beep2());
31509
+ }
31510
+ if (input.key.name === "backspace") {
31511
+ if (state.cursor === 0)
31512
+ return exports_Effect.succeed(beep2());
31513
+ return exports_Effect.succeed(nextFrame({
31514
+ cursor: state.cursor - 1,
31515
+ value: state.value.slice(0, state.cursor - 1) + state.value.slice(state.cursor)
31516
+ }));
31517
+ }
31518
+ if (input.key.name === "left") {
31519
+ if (state.cursor === 0)
31520
+ return exports_Effect.succeed(beep2());
31521
+ return exports_Effect.succeed(nextFrame({ ...state, cursor: state.cursor - 1, error: undefined }));
31522
+ }
31523
+ if (input.key.name === "right") {
31524
+ if (state.cursor === state.value.length)
31525
+ return exports_Effect.succeed(beep2());
31526
+ return exports_Effect.succeed(nextFrame({ ...state, cursor: state.cursor + 1, error: undefined }));
31527
+ }
31528
+ if (input.key.name === "home") {
31529
+ return exports_Effect.succeed(nextFrame({ ...state, cursor: 0, error: undefined }));
31530
+ }
31531
+ if (input.key.name === "end") {
31532
+ return exports_Effect.succeed(nextFrame({
31533
+ ...state,
31534
+ cursor: state.value.length,
31535
+ error: undefined
31536
+ }));
31537
+ }
31538
+ if (input.key.name === "enter" || input.key.name === "return") {
31539
+ if (state.value === "" || /^[A-Za-z0-9._-]+$/.test(state.value)) {
31540
+ return exports_Effect.succeed({ _tag: "Submit", value: state.value });
31541
+ }
31542
+ return exports_Effect.succeed(nextFrame({ ...state, error: "Enter only your username" }));
31543
+ }
31544
+ if (input.key.meta)
31545
+ return exports_Effect.succeed(beep2());
31546
+ return exports_Effect.succeed(exports_Option.match(input.input, {
31547
+ onNone: beep2,
31548
+ onSome: (value3) => insertInput(state, value3)
31549
+ }));
31550
+ };
31551
+ var profileUsernamePrompt = (message, profilePrefix) => exports_Prompt.custom({ cursor: 0, value: "" }, {
31552
+ render: (state, action2) => {
31553
+ if (action2._tag === "Beep")
31554
+ return exports_Effect.succeed(ansi.beep);
31555
+ return exports_Effect.succeed(renderProfileUsername(state, message, profilePrefix, action2._tag === "Submit"));
31556
+ },
31557
+ process: processProfileUsername,
31558
+ clear: (state) => exports_Effect.succeed(clearProfileUsername(state))
31559
+ });
31560
+
31561
+ // src/input.ts
31425
31562
  var requiredText = (message) => exports_Prompt.text({
31426
31563
  message,
31427
31564
  validate: (value3) => {
@@ -31431,20 +31568,8 @@ var requiredText = (message) => exports_Prompt.text({
31431
31568
  }
31432
31569
  });
31433
31570
  var optionalText2 = (message) => exports_Prompt.text({ message, default: "" });
31434
- var optionalProfileUsername = (message, profilePrefix) => exports_Prompt.text({
31435
- message,
31436
- default: "",
31437
- theme: {
31438
- pointerSmall: profilePrefix,
31439
- ellipsis: profilePrefix
31440
- },
31441
- validate: (value3) => {
31442
- if (value3 === "" || /^[A-Za-z0-9._-]+$/.test(value3)) {
31443
- return exports_Effect.succeed(value3);
31444
- }
31445
- return exports_Effect.fail("Enter only your username");
31446
- }
31447
- });
31571
+ var githubProfilePrefix = "github.com/";
31572
+ var linkedInProfilePrefix = "linkedin.com/in/";
31448
31573
  var withoutEmptyStrings = (input) => Object.fromEntries(Object.entries(input).filter(([, value3]) => value3 !== "" && value3 !== undefined));
31449
31574
  var readStdin = async () => {
31450
31575
  const chunks = [];
@@ -31494,8 +31619,8 @@ var applicationDetailsPrompts = exports_Prompt.all({
31494
31619
  }),
31495
31620
  skills: exports_Prompt.list({ message: "Skills (comma-separated)", delimiter: "," }),
31496
31621
  bio: requiredText("Short bio"),
31497
- githubUrl: optionalProfileUsername("GitHub username (optional)", "github.com/"),
31498
- linkedInUrl: optionalProfileUsername("LinkedIn username (optional)", "linkedin.com/in/"),
31622
+ githubUsername: profileUsernamePrompt("GitHub username (optional)", githubProfilePrefix),
31623
+ linkedInUsername: profileUsernamePrompt("LinkedIn username (optional)", linkedInProfilePrefix),
31499
31624
  portfolioUrl: optionalText2("Portfolio URL (optional)")
31500
31625
  });
31501
31626
  var teamPreferencePrompt = exports_Prompt.select({
@@ -31548,15 +31673,16 @@ var interactiveApplication = (publicBaseUrl) => exports_Effect.gen(function* ()
31548
31673
  mediaConsent
31549
31674
  };
31550
31675
  }).pipe(exports_Effect.map((input) => {
31551
- const normalized = withoutEmptyStrings(input);
31676
+ const { githubUsername, linkedInUsername, ...application } = input;
31677
+ const normalized = withoutEmptyStrings(application);
31552
31678
  if (input.graduationYear !== "") {
31553
31679
  normalized.graduationYear = Number(input.graduationYear);
31554
31680
  }
31555
- if (input.githubUrl !== "") {
31556
- normalized.githubUrl = `github.com/${input.githubUrl}`;
31681
+ if (githubUsername !== "") {
31682
+ normalized.githubUrl = `${githubProfilePrefix}${githubUsername}`;
31557
31683
  }
31558
- if (input.linkedInUrl !== "") {
31559
- normalized.linkedInUrl = `linkedin.com/in/${input.linkedInUrl}`;
31684
+ if (linkedInUsername !== "") {
31685
+ normalized.linkedInUrl = `${linkedInProfilePrefix}${linkedInUsername}`;
31560
31686
  }
31561
31687
  return normalized;
31562
31688
  }));
@@ -31698,7 +31824,7 @@ var registerCommand = exports_Command.make("register", { input: inputFlag }, exp
31698
31824
  const options = yield* root;
31699
31825
  const operation = exports_Effect.gen(function* () {
31700
31826
  const token = exports_Option.getOrUndefined(options.token);
31701
- const body = yield* applicationInput(exports_Option.getOrUndefined(input), options.apiUrl);
31827
+ const body = yield* applicationInput(exports_Option.getOrUndefined(input), config.publicSiteUrl);
31702
31828
  return yield* register({ apiUrl: options.apiUrl, token }, body);
31703
31829
  });
31704
31830
  yield* execute(options.output, operation, createdText);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chofex-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Command-line client for the Chofex Hackathon",
5
5
  "type": "module",
6
6
  "bin": {