@bragduck/cli 2.16.0 → 2.16.3

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.
@@ -4738,10 +4738,32 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS) {
4738
4738
  const adapter = AdapterFactory.getAdapter(sourceType);
4739
4739
  const repoSpinner = createStepSpinner(2, TOTAL_STEPS, "Validating repository");
4740
4740
  repoSpinner.start();
4741
- await adapter.validate();
4742
- const repoInfo = await adapter.getRepositoryInfo();
4743
- succeedStepSpinner(repoSpinner, 2, TOTAL_STEPS, `Repository: ${theme.value(repoInfo.fullName)}`);
4744
- logger.log("");
4741
+ const VALIDATION_TIMEOUT = 3e4;
4742
+ let repoInfo;
4743
+ try {
4744
+ repoInfo = await Promise.race([
4745
+ (async () => {
4746
+ await adapter.validate();
4747
+ return await adapter.getRepositoryInfo();
4748
+ })(),
4749
+ new Promise((_, reject) => {
4750
+ setTimeout(
4751
+ () => reject(new Error("Validation timeout after 30 seconds")),
4752
+ VALIDATION_TIMEOUT
4753
+ );
4754
+ })
4755
+ ]);
4756
+ succeedStepSpinner(
4757
+ repoSpinner,
4758
+ 2,
4759
+ TOTAL_STEPS,
4760
+ `Repository: ${theme.value(repoInfo.fullName)}`
4761
+ );
4762
+ logger.log("");
4763
+ } catch (error) {
4764
+ failStepSpinner(repoSpinner, 2, TOTAL_STEPS, "Validation failed");
4765
+ throw error;
4766
+ }
4745
4767
  let days = options.days;
4746
4768
  if (!days && options.today) {
4747
4769
  days = 1;
@@ -4868,12 +4890,12 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS) {
4868
4890
  logger.log(formatRefinedCommitsTable(refinedBrags, newCommits));
4869
4891
  logger.log("");
4870
4892
  acceptedBrags = await promptReviewBrags(refinedBrags, newCommits);
4871
- if (acceptedBrags.length === 0) {
4872
- logger.log("");
4873
- logger.info(theme.secondary("No brags selected for creation. Sync cancelled."));
4874
- logger.log("");
4875
- return { created: 0, skipped: duplicates.length };
4876
- }
4893
+ }
4894
+ if (acceptedBrags.length === 0) {
4895
+ logger.log("");
4896
+ logger.info(theme.secondary("No brags selected for creation. Sync cancelled."));
4897
+ logger.log("");
4898
+ return { created: 0, skipped: duplicates.length };
4877
4899
  }
4878
4900
  logger.log("");
4879
4901
  let selectedOrgId = null;
@@ -4918,14 +4940,32 @@ async function syncSingleService(sourceType, options, TOTAL_STEPS) {
4918
4940
  };
4919
4941
  })
4920
4942
  };
4921
- const createResponse = await apiService.createBrags(createRequest);
4922
- succeedStepSpinner(
4923
- createSpinner2,
4924
- 5,
4925
- TOTAL_STEPS,
4926
- `Created ${theme.count(createResponse.created)} brag${createResponse.created > 1 ? "s" : ""}`
4927
- );
4928
- logger.log("");
4943
+ const CREATE_TIMEOUT = 6e4;
4944
+ logger.debug(`Sending ${acceptedBrags.length} brags to API for creation...`);
4945
+ let createResponse;
4946
+ try {
4947
+ createResponse = await Promise.race([
4948
+ apiService.createBrags(createRequest),
4949
+ new Promise((_, reject) => {
4950
+ setTimeout(
4951
+ () => reject(new Error("Create brags timeout after 60 seconds")),
4952
+ CREATE_TIMEOUT
4953
+ );
4954
+ })
4955
+ ]);
4956
+ logger.debug(`API response: ${createResponse.created} brags created`);
4957
+ succeedStepSpinner(
4958
+ createSpinner2,
4959
+ 5,
4960
+ TOTAL_STEPS,
4961
+ `Created ${theme.count(createResponse.created)} brag${createResponse.created > 1 ? "s" : ""}`
4962
+ );
4963
+ logger.log("");
4964
+ } catch (error) {
4965
+ failStepSpinner(createSpinner2, 5, TOTAL_STEPS, "Failed to create brags");
4966
+ logger.log("");
4967
+ throw error;
4968
+ }
4929
4969
  return { created: createResponse.created, skipped: duplicates.length };
4930
4970
  }
4931
4971
  async function syncAllAuthenticatedServices(options) {
@@ -5094,6 +5134,18 @@ async function syncCommand(options = {}) {
5094
5134
  const result = await syncSingleService(sourceType, options, TOTAL_STEPS);
5095
5135
  if (result.created > 0) {
5096
5136
  logger.log(boxen6(formatSuccessMessage(result.created), boxStyles.success));
5137
+ } else if (result.skipped > 0) {
5138
+ logger.log("");
5139
+ logger.info(
5140
+ theme.secondary(
5141
+ `No new brags created. ${result.skipped} item${result.skipped > 1 ? "s were" : " was"} skipped (already exists in Bragduck).`
5142
+ )
5143
+ );
5144
+ logger.log("");
5145
+ } else {
5146
+ logger.log("");
5147
+ logger.info(theme.secondary("No brags created."));
5148
+ logger.log("");
5097
5149
  }
5098
5150
  }
5099
5151
  } catch (error) {