chofex-cli 0.1.8 → 0.1.9

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 +63 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31431,6 +31431,20 @@ var requiredText = (message) => exports_Prompt.text({
31431
31431
  }
31432
31432
  });
31433
31433
  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
+ });
31434
31448
  var withoutEmptyStrings = (input) => Object.fromEntries(Object.entries(input).filter(([, value3]) => value3 !== "" && value3 !== undefined));
31435
31449
  var readStdin = async () => {
31436
31450
  const chunks = [];
@@ -31480,8 +31494,8 @@ var applicationDetailsPrompts = exports_Prompt.all({
31480
31494
  }),
31481
31495
  skills: exports_Prompt.list({ message: "Skills (comma-separated)", delimiter: "," }),
31482
31496
  bio: requiredText("Short bio"),
31483
- githubUrl: optionalText2("GitHub URL (optional)"),
31484
- linkedInUrl: optionalText2("LinkedIn URL (optional)"),
31497
+ githubUrl: optionalProfileUsername("GitHub username (optional)", "github.com/"),
31498
+ linkedInUrl: optionalProfileUsername("LinkedIn username (optional)", "linkedin.com/in/"),
31485
31499
  portfolioUrl: optionalText2("Portfolio URL (optional)")
31486
31500
  });
31487
31501
  var teamPreferencePrompt = exports_Prompt.select({
@@ -31492,31 +31506,58 @@ var teamPreferencePrompt = exports_Prompt.select({
31492
31506
  { title: "I will participate solo", value: "solo" }
31493
31507
  ]
31494
31508
  });
31495
- var applicationConsentPrompts = exports_Prompt.all({
31496
- codeOfConductAccepted: exports_Prompt.confirm({
31497
- message: "Do you accept the code of conduct?"
31498
- }),
31499
- privacyPolicyAccepted: exports_Prompt.confirm({
31500
- message: "Do you accept the privacy policy?"
31501
- }),
31502
- mediaConsent: exports_Prompt.confirm({
31503
- message: "Do you consent to appearing in event media?"
31504
- })
31509
+ var publicDocumentUrl = (baseUrl, path4) => `${baseUrl.replace(/\/$/, "")}${path4}`;
31510
+ var requiredAgreement = exports_Effect.fn("requiredAgreement")(function* (name, url2) {
31511
+ const accepted = yield* exports_Prompt.run(exports_Prompt.confirm({
31512
+ message: `Do you accept the ${name}? Read it at ${url2}`
31513
+ }));
31514
+ if (accepted)
31515
+ return true;
31516
+ const nextStep = yield* exports_Prompt.run(exports_Prompt.select({
31517
+ message: `You must accept the ${name} to register. What would you like to do?`,
31518
+ choices: [
31519
+ {
31520
+ title: "I accept and want to continue",
31521
+ value: "accept"
31522
+ },
31523
+ { title: "Cancel registration", value: "cancel" }
31524
+ ]
31525
+ }));
31526
+ if (nextStep === "accept")
31527
+ return true;
31528
+ return yield* cliError("REGISTRATION_CANCELLED", "Registration cancelled. Your answers were not submitted.");
31505
31529
  });
31506
- var interactiveApplication = exports_Effect.gen(function* () {
31530
+ var interactiveApplication = (publicBaseUrl) => exports_Effect.gen(function* () {
31507
31531
  const details = yield* exports_Prompt.run(applicationDetailsPrompts);
31508
31532
  const teamPreference = yield* exports_Prompt.run(teamPreferencePrompt);
31509
31533
  let teamName;
31510
31534
  if (teamPreference === "have_team") {
31511
31535
  teamName = yield* exports_Prompt.run(requiredText("Team name"));
31512
31536
  }
31513
- const consents = yield* exports_Prompt.run(applicationConsentPrompts);
31514
- return { ...details, teamPreference, teamName, ...consents };
31537
+ const codeOfConductAccepted = yield* requiredAgreement("Terms and Code of Conduct", publicDocumentUrl(publicBaseUrl, "/terms"));
31538
+ const privacyPolicyAccepted = yield* requiredAgreement("Privacy Policy", publicDocumentUrl(publicBaseUrl, "/privacy"));
31539
+ const mediaConsent = yield* exports_Prompt.run(exports_Prompt.confirm({
31540
+ message: "Do you consent to appearing in event media? (optional)"
31541
+ }));
31542
+ return {
31543
+ ...details,
31544
+ teamPreference,
31545
+ teamName,
31546
+ codeOfConductAccepted,
31547
+ privacyPolicyAccepted,
31548
+ mediaConsent
31549
+ };
31515
31550
  }).pipe(exports_Effect.map((input) => {
31516
31551
  const normalized = withoutEmptyStrings(input);
31517
31552
  if (input.graduationYear !== "") {
31518
31553
  normalized.graduationYear = Number(input.graduationYear);
31519
31554
  }
31555
+ if (input.githubUrl !== "") {
31556
+ normalized.githubUrl = `github.com/${input.githubUrl}`;
31557
+ }
31558
+ if (input.linkedInUrl !== "") {
31559
+ normalized.linkedInUrl = `linkedin.com/in/${input.linkedInUrl}`;
31560
+ }
31520
31561
  return normalized;
31521
31562
  }));
31522
31563
  var shirtSizePrompt = (participationMode) => {
@@ -31546,9 +31587,13 @@ var inputOrInteractive = (path4, interactive) => {
31546
31587
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
31547
31588
  return exports_Effect.fail(cliError("INPUT_REQUIRED", "Non-interactive use requires --input <file>, or --input - for stdin"));
31548
31589
  }
31549
- return interactive.pipe(exports_Effect.mapError(() => cliError("PROMPT_CANCELLED", "Interactive input was cancelled")));
31590
+ return interactive.pipe(exports_Effect.mapError((error2) => {
31591
+ if (error2 instanceof CliError2)
31592
+ return error2;
31593
+ return cliError("PROMPT_CANCELLED", "Interactive input was cancelled");
31594
+ }));
31550
31595
  };
31551
- var applicationInput = (path4) => inputOrInteractive(path4, interactiveApplication).pipe(exports_Effect.flatMap((input) => decode2(ApplicationInput, input)), exports_Effect.flatMap((input) => validateSemantics(input, applicationSemanticRequirements(input))));
31596
+ var applicationInput = (path4, publicBaseUrl) => inputOrInteractive(path4, interactiveApplication(publicBaseUrl)).pipe(exports_Effect.flatMap((input) => decode2(ApplicationInput, input)), exports_Effect.flatMap((input) => validateSemantics(input, applicationSemanticRequirements(input))));
31552
31597
  var acceptedDetailsInput = (path4, participationMode) => inputOrInteractive(path4, interactiveAcceptedDetails(participationMode)).pipe(exports_Effect.flatMap((input) => decode2(AcceptedDetailsInput, input)), exports_Effect.flatMap((input) => validateSemantics(input, acceptedDetailsSemanticRequirements(input, participationMode))));
31553
31598
 
31554
31599
  // src/output.ts
@@ -31653,7 +31698,7 @@ var registerCommand = exports_Command.make("register", { input: inputFlag }, exp
31653
31698
  const options = yield* root;
31654
31699
  const operation = exports_Effect.gen(function* () {
31655
31700
  const token = exports_Option.getOrUndefined(options.token);
31656
- const body = yield* applicationInput(exports_Option.getOrUndefined(input));
31701
+ const body = yield* applicationInput(exports_Option.getOrUndefined(input), options.apiUrl);
31657
31702
  return yield* register({ apiUrl: options.apiUrl, token }, body);
31658
31703
  });
31659
31704
  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.8",
3
+ "version": "0.1.9",
4
4
  "description": "Command-line client for the Chofex Hackathon",
5
5
  "type": "module",
6
6
  "bin": {