@itentialopensource/adapter-azure_devops 0.1.1 → 0.1.2

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 (260) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +169 -0
  4. package/CHANGELOG.md +9 -2
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +88 -74
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +221 -571
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +11 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +11999 -57
  14. package/adapterBase.js +1007 -253
  15. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/README.md +59 -0
  16. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/specificCallScript.js +97 -0
  17. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/update.js +532 -0
  18. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/adapter.js +11651 -0
  19. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/action.json +43 -0
  20. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/mockdatafiles/mockdata.json +20817 -0
  21. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/AnnotatedTags/schema.json +125 -0
  22. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/action.json +43 -0
  23. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/mockdatafiles/mockdata.json +20817 -0
  24. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Blobs/schema.json +125 -0
  25. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/action.json +64 -0
  26. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/mockdatafiles/mockdata.json +20817 -0
  27. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/CherryPicks/schema.json +125 -0
  28. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/action.json +85 -0
  29. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/mockdatafiles/mockdata.json +20817 -0
  30. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Commits/schema.json +125 -0
  31. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/action.json +23 -0
  32. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/mockdatafiles/mockdata.json +20817 -0
  33. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Diffs/schema.json +125 -0
  34. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/action.json +85 -0
  35. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/mockdatafiles/mockdata.json +20817 -0
  36. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Forks/schema.json +125 -0
  37. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/action.json +84 -0
  38. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/mockdatafiles/mockdata.json +20817 -0
  39. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/ImportRequests/schema.json +125 -0
  40. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/action.json +43 -0
  41. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/mockdatafiles/mockdata.json +20817 -0
  42. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Items/schema.json +125 -0
  43. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/action.json +23 -0
  44. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/mockdatafiles/mockdata.json +20817 -0
  45. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/MergeBases/schema.json +125 -0
  46. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/action.json +43 -0
  47. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/mockdatafiles/mockdata.json +20817 -0
  48. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Merges/schema.json +125 -0
  49. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/action.json +23 -0
  50. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/mockdatafiles/mockdata.json +20817 -0
  51. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PolicyConfigurations/schema.json +125 -0
  52. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/action.json +84 -0
  53. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/mockdatafiles/mockdata.json +20817 -0
  54. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestAttachments/schema.json +125 -0
  55. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/action.json +63 -0
  56. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/mockdatafiles/mockdata.json +20817 -0
  57. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommentLikes/schema.json +125 -0
  58. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/action.json +44 -0
  59. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/mockdatafiles/mockdata.json +20817 -0
  60. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestCommits/schema.json +125 -0
  61. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/action.json +23 -0
  62. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/mockdatafiles/mockdata.json +20817 -0
  63. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationChanges/schema.json +125 -0
  64. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/action.json +104 -0
  65. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/mockdatafiles/mockdata.json +20817 -0
  66. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterationStatuses/schema.json +125 -0
  67. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/action.json +44 -0
  68. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/mockdatafiles/mockdata.json +20817 -0
  69. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestIterations/schema.json +125 -0
  70. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/action.json +84 -0
  71. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/mockdatafiles/mockdata.json +20817 -0
  72. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestLabels/schema.json +125 -0
  73. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/action.json +43 -0
  74. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/mockdatafiles/mockdata.json +20817 -0
  75. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestProperties/schema.json +125 -0
  76. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/action.json +22 -0
  77. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/mockdatafiles/mockdata.json +20817 -0
  78. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestQuery/schema.json +125 -0
  79. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/action.json +164 -0
  80. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/mockdatafiles/mockdata.json +20817 -0
  81. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestReviewers/schema.json +125 -0
  82. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/action.json +22 -0
  83. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/mockdatafiles/mockdata.json +20817 -0
  84. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestShare/schema.json +125 -0
  85. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/action.json +104 -0
  86. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/mockdatafiles/mockdata.json +20817 -0
  87. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestStatuses/schema.json +125 -0
  88. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/action.json +104 -0
  89. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/mockdatafiles/mockdata.json +20817 -0
  90. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreadComments/schema.json +125 -0
  91. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/action.json +84 -0
  92. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/mockdatafiles/mockdata.json +20817 -0
  93. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestThreads/schema.json +125 -0
  94. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/action.json +23 -0
  95. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/mockdatafiles/mockdata.json +20817 -0
  96. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequestWorkItems/schema.json +125 -0
  97. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/action.json +126 -0
  98. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/mockdatafiles/mockdata.json +20817 -0
  99. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/PullRequests/schema.json +125 -0
  100. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/action.json +64 -0
  101. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/mockdatafiles/mockdata.json +20817 -0
  102. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Pushes/schema.json +125 -0
  103. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/action.json +63 -0
  104. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/mockdatafiles/mockdata.json +20817 -0
  105. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Refs/schema.json +125 -0
  106. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/action.json +84 -0
  107. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/mockdatafiles/mockdata.json +20817 -0
  108. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/RefsFavorites/schema.json +125 -0
  109. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/action.json +186 -0
  110. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/mockdatafiles/mockdata.json +20817 -0
  111. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Repositories/schema.json +125 -0
  112. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/action.json +64 -0
  113. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/mockdatafiles/mockdata.json +20817 -0
  114. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Reverts/schema.json +125 -0
  115. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/action.json +23 -0
  116. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/mockdatafiles/mockdata.json +20817 -0
  117. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Stats/schema.json +125 -0
  118. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/action.json +43 -0
  119. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/mockdatafiles/mockdata.json +20817 -0
  120. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Statuses/schema.json +125 -0
  121. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/action.json +23 -0
  122. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/mockdatafiles/mockdata.json +20817 -0
  123. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Suggestions/schema.json +125 -0
  124. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/action.json +23 -0
  125. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/mockdatafiles/mockdata.json +20817 -0
  126. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/entities/Trees/schema.json +125 -0
  127. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/methods.json +74975 -0
  128. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/pronghorn.json +11730 -0
  129. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/test/integration/adapterTestIntegration.js +5493 -0
  130. package/adapter_modifications/archive/UPD-2022-04-29T13:05:13.710Z/updateFiles/components/test/unit/adapterTestUnit.js +10889 -0
  131. package/entities/.generic/action.json +105 -0
  132. package/entities/.generic/schema.json +6 -1
  133. package/entities/AnnotatedTags/action.json +45 -0
  134. package/entities/AnnotatedTags/schema.json +20 -0
  135. package/entities/Blobs/action.json +45 -0
  136. package/entities/Blobs/schema.json +20 -0
  137. package/entities/CherryPicks/action.json +66 -0
  138. package/entities/CherryPicks/schema.json +21 -0
  139. package/entities/Commits/action.json +87 -0
  140. package/entities/Commits/mockdatafiles/commitsGetCommitsBatch-default.json +707 -0
  141. package/entities/Commits/mockdatafiles/commitsGetPushCommits-default.json +336 -0
  142. package/entities/Commits/schema.json +22 -0
  143. package/entities/Diffs/action.json +25 -0
  144. package/entities/Diffs/schema.json +19 -0
  145. package/entities/Forks/action.json +87 -0
  146. package/entities/Forks/mockdatafiles/forksGetForkSyncRequests-default.json +200 -0
  147. package/entities/Forks/mockdatafiles/forksList-default.json +102 -0
  148. package/entities/Forks/schema.json +22 -0
  149. package/entities/ImportRequests/action.json +86 -0
  150. package/entities/ImportRequests/mockdatafiles/importRequestsQuery-default.json +91 -0
  151. package/entities/ImportRequests/schema.json +22 -0
  152. package/entities/Items/action.json +45 -0
  153. package/entities/Items/mockdatafiles/itemsGetItemsBatch-default.json +5 -0
  154. package/entities/Items/mockdatafiles/itemsList-default.json +40 -0
  155. package/entities/Items/schema.json +20 -0
  156. package/entities/MergeBases/action.json +25 -0
  157. package/entities/MergeBases/mockdatafiles/mergeBasesList-default.json +580 -0
  158. package/entities/MergeBases/schema.json +19 -0
  159. package/entities/Merges/action.json +45 -0
  160. package/entities/Merges/schema.json +20 -0
  161. package/entities/PolicyConfigurations/action.json +25 -0
  162. package/entities/PolicyConfigurations/mockdatafiles/policyConfigurationsGet-default.json +20 -0
  163. package/entities/PolicyConfigurations/schema.json +19 -0
  164. package/entities/PullRequestAttachments/action.json +86 -0
  165. package/entities/PullRequestAttachments/mockdatafiles/pullRequestAttachmentsList-default.json +159 -0
  166. package/entities/PullRequestAttachments/schema.json +22 -0
  167. package/entities/PullRequestCommentLikes/action.json +65 -0
  168. package/entities/PullRequestCommentLikes/mockdatafiles/pullRequestCommentLikesList-default.json +10 -0
  169. package/entities/PullRequestCommentLikes/schema.json +21 -0
  170. package/entities/PullRequestCommits/action.json +46 -0
  171. package/entities/PullRequestCommits/mockdatafiles/pullRequestCommitsGetPullRequestCommits-default.json +818 -0
  172. package/entities/PullRequestCommits/mockdatafiles/pullRequestCommitsGetPullRequestIterationCommits-default.json +813 -0
  173. package/entities/PullRequestCommits/schema.json +20 -0
  174. package/entities/PullRequestIterationChanges/action.json +25 -0
  175. package/entities/PullRequestIterationChanges/schema.json +19 -0
  176. package/entities/PullRequestIterationStatuses/action.json +106 -0
  177. package/entities/PullRequestIterationStatuses/mockdatafiles/pullRequestIterationStatusesList-default.json +71 -0
  178. package/entities/PullRequestIterationStatuses/schema.json +23 -0
  179. package/entities/PullRequestIterations/action.json +46 -0
  180. package/entities/PullRequestIterations/mockdatafiles/pullRequestIterationsList-default.json +2403 -0
  181. package/entities/PullRequestIterations/schema.json +20 -0
  182. package/entities/PullRequestLabels/action.json +86 -0
  183. package/entities/PullRequestLabels/mockdatafiles/pullRequestLabelsList-default.json +20 -0
  184. package/entities/PullRequestLabels/schema.json +22 -0
  185. package/entities/PullRequestProperties/action.json +45 -0
  186. package/entities/PullRequestProperties/schema.json +20 -0
  187. package/entities/PullRequestQuery/action.json +24 -0
  188. package/entities/PullRequestQuery/schema.json +19 -0
  189. package/entities/PullRequestReviewers/action.json +166 -0
  190. package/entities/PullRequestReviewers/mockdatafiles/pullRequestReviewersCreatePullRequestReviewers-default.json +10 -0
  191. package/entities/PullRequestReviewers/mockdatafiles/pullRequestReviewersList-default.json +10 -0
  192. package/entities/PullRequestReviewers/schema.json +26 -0
  193. package/entities/PullRequestShare/action.json +24 -0
  194. package/entities/PullRequestShare/schema.json +19 -0
  195. package/entities/PullRequestStatuses/action.json +106 -0
  196. package/entities/PullRequestStatuses/mockdatafiles/pullRequestStatusesList-default.json +48 -0
  197. package/entities/PullRequestStatuses/schema.json +23 -0
  198. package/entities/PullRequestThreadComments/action.json +106 -0
  199. package/entities/PullRequestThreadComments/mockdatafiles/pullRequestThreadCommentsList-default.json +215 -0
  200. package/entities/PullRequestThreadComments/schema.json +23 -0
  201. package/entities/PullRequestThreads/action.json +86 -0
  202. package/entities/PullRequestThreads/mockdatafiles/pullRequestThreadsList-default.json +395 -0
  203. package/entities/PullRequestThreads/schema.json +22 -0
  204. package/entities/PullRequestWorkItems/action.json +25 -0
  205. package/entities/PullRequestWorkItems/mockdatafiles/pullRequestWorkItemsList-default.json +18 -0
  206. package/entities/PullRequestWorkItems/schema.json +19 -0
  207. package/entities/PullRequests/action.json +128 -0
  208. package/entities/PullRequests/mockdatafiles/pullRequestsGetPullRequests-default.json +6555 -0
  209. package/entities/PullRequests/mockdatafiles/pullRequestsGetPullRequestsByProject-default.json +5929 -0
  210. package/entities/PullRequests/schema.json +24 -0
  211. package/entities/Pushes/action.json +66 -0
  212. package/entities/Pushes/mockdatafiles/pushesList-default.json +34 -0
  213. package/entities/Pushes/schema.json +21 -0
  214. package/entities/Refs/action.json +65 -0
  215. package/entities/Refs/mockdatafiles/refsList-default.json +500 -0
  216. package/entities/Refs/mockdatafiles/refsUpdateRefs-default.json +13 -0
  217. package/entities/Refs/schema.json +21 -0
  218. package/entities/RefsFavorites/action.json +86 -0
  219. package/entities/RefsFavorites/mockdatafiles/refsFavoritesList-default.json +35 -0
  220. package/entities/RefsFavorites/schema.json +22 -0
  221. package/entities/Repositories/action.json +188 -0
  222. package/entities/Repositories/mockdatafiles/repositoriesGetDeletedRepositories-default.json +54 -0
  223. package/entities/Repositories/mockdatafiles/repositoriesGetRecycleBinRepositories-default.json +28 -0
  224. package/entities/Repositories/mockdatafiles/repositoriesList-default.json +123 -0
  225. package/entities/Repositories/schema.json +27 -0
  226. package/entities/Reverts/action.json +66 -0
  227. package/entities/Reverts/schema.json +21 -0
  228. package/entities/Stats/action.json +25 -0
  229. package/entities/Stats/mockdatafiles/statsList-default.json +195 -0
  230. package/entities/Stats/schema.json +19 -0
  231. package/entities/Statuses/action.json +45 -0
  232. package/entities/Statuses/mockdatafiles/statusesList-default.json +94 -0
  233. package/entities/Statuses/schema.json +20 -0
  234. package/entities/Suggestions/action.json +25 -0
  235. package/entities/Suggestions/mockdatafiles/suggestionsList-default.json +14 -0
  236. package/entities/Suggestions/schema.json +19 -0
  237. package/entities/Trees/action.json +25 -0
  238. package/entities/Trees/schema.json +19 -0
  239. package/error.json +6 -0
  240. package/package.json +5 -3
  241. package/previousVersion.zip +0 -0
  242. package/pronghorn.json +49635 -378
  243. package/propertiesDecorators.json +14 -0
  244. package/propertiesSchema.json +421 -0
  245. package/refs?service=git-upload-pack +0 -0
  246. package/report/adapterInfo.json +10 -0
  247. package/report/updateReport1653439219306.json +120 -0
  248. package/sampleProperties.json +90 -1
  249. package/test/integration/adapterTestBasicGet.js +1 -1
  250. package/test/integration/adapterTestIntegration.js +4869 -105
  251. package/test/unit/adapterBaseTestUnit.js +30 -25
  252. package/test/unit/adapterTestUnit.js +11057 -159
  253. package/utils/adapterInfo.js +206 -0
  254. package/utils/entitiesToDB.js +12 -57
  255. package/utils/patches2bundledDeps.js +90 -0
  256. package/utils/pre-commit.sh +3 -0
  257. package/utils/tbScript.js +35 -20
  258. package/utils/tbUtils.js +59 -35
  259. package/utils/testRunner.js +16 -16
  260. package/versions.json +135 -0
@@ -0,0 +1,206 @@
1
+ #!/usr/bin/env node
2
+ /* @copyright Itential, LLC 2019 */
3
+ /* eslint global-require:warn */
4
+ /* eslint import/no-dynamic-require:warn */
5
+ /* eslint prefer-destructuring:warn */
6
+
7
+ const fs = require('fs-extra');
8
+ const path = require('path');
9
+
10
+ /**
11
+ * This script will determine the information about the adapter and store
12
+ * it into a file in the adapter.
13
+ */
14
+
15
+ /**
16
+ * get adapter information
17
+ */
18
+ function adapterInfo() {
19
+ // set the base pase of the adapter - tool shoud be one level up in utils
20
+ let adaptdir = __dirname;
21
+ const infoRes = {};
22
+
23
+ if (adaptdir.endsWith('/utils')) {
24
+ adaptdir = adaptdir.substring(0, adaptdir.length - 6);
25
+ }
26
+ const pack = require(`${adaptdir}/package.json`);
27
+ infoRes.version = pack.version;
28
+
29
+ let configCount = 0;
30
+ if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
31
+ const cFile = fs.readFileSync(`${adaptdir}/pronghorn.json`, 'utf8');
32
+ configCount += cFile.split('\n').length;
33
+ } else {
34
+ console.log('Missing - pronghorn.json');
35
+ }
36
+ if (fs.existsSync(`${adaptdir}/propertiesSchema.json`)) {
37
+ const cFile = fs.readFileSync(`${adaptdir}/propertiesSchema.json`, 'utf8');
38
+ configCount += cFile.split('\n').length;
39
+ } else {
40
+ console.log('Missing - propertiesSchema.json');
41
+ }
42
+ if (fs.existsSync(`${adaptdir}/error.json`)) {
43
+ const cFile = fs.readFileSync(`${adaptdir}/error.json`, 'utf8');
44
+ configCount += cFile.split('\n').length;
45
+ } else {
46
+ console.log('Missing - error.json');
47
+ }
48
+ const entitydir = path.join(adaptdir, '/entities');
49
+ if (fs.existsSync(entitydir) && fs.statSync(entitydir).isDirectory()) {
50
+ const entities = fs.readdirSync(entitydir);
51
+ // need to go through each entity in the entities directory
52
+ for (let e = 0; e < entities.length; e += 1) {
53
+ if (fs.statSync(`${entitydir}/${entities[e]}`).isDirectory()) {
54
+ const cfiles = fs.readdirSync(entitydir);
55
+ for (let c = 0; c < cfiles.length; c += 1) {
56
+ if (cfiles[c].endsWith('.json')) {
57
+ const ccFile = fs.readFileSync(`${entitydir}/${entities[e]}/${cfiles[c]}`, 'utf8');
58
+ configCount += ccFile.split('\n').length;
59
+ }
60
+ }
61
+ }
62
+ }
63
+ } else {
64
+ console.log('Could not find the entities directory');
65
+ }
66
+ infoRes.configLines = configCount;
67
+
68
+ let scodeCount = 0;
69
+ if (fs.existsSync(`${adaptdir}/utils/artifactize.js`)) {
70
+ const sFile = fs.readFileSync(`${adaptdir}/utils/artifactize.js`, 'utf8');
71
+ scodeCount += sFile.split('\n').length;
72
+ } else {
73
+ console.log('Missing - utils/artifactize.js');
74
+ }
75
+ if (fs.existsSync(`${adaptdir}/utils/basicGet.js`)) {
76
+ const sFile = fs.readFileSync(`${adaptdir}/utils/basicGet.js`, 'utf8');
77
+ scodeCount += sFile.split('\n').length;
78
+ } else {
79
+ console.log('Missing - utils/basicGet.js');
80
+ }
81
+ if (fs.existsSync(`${adaptdir}/utils/checkMigrate.js`)) {
82
+ const sFile = fs.readFileSync(`${adaptdir}/utils/checkMigrate.js`, 'utf8');
83
+ scodeCount += sFile.split('\n').length;
84
+ } else {
85
+ console.log('Missing - utils/checkMigrate.js');
86
+ }
87
+ if (fs.existsSync(`${adaptdir}/utils/findPath.js`)) {
88
+ const sFile = fs.readFileSync(`${adaptdir}/utils/findPath.js`, 'utf8');
89
+ scodeCount += sFile.split('\n').length;
90
+ } else {
91
+ console.log('Missing - utils/findPath.js');
92
+ }
93
+ if (fs.existsSync(`${adaptdir}/utils/modify.js`)) {
94
+ const sFile = fs.readFileSync(`${adaptdir}/utils/modify.js`, 'utf8');
95
+ scodeCount += sFile.split('\n').length;
96
+ } else {
97
+ console.log('Missing - utils/modify.js');
98
+ }
99
+ if (fs.existsSync(`${adaptdir}/utils/packModificationScript.js`)) {
100
+ const sFile = fs.readFileSync(`${adaptdir}/utils/packModificationScript.js`, 'utf8');
101
+ scodeCount += sFile.split('\n').length;
102
+ } else {
103
+ console.log('Missing - utils/packModificationScript.js');
104
+ }
105
+ if (fs.existsSync(`${adaptdir}/utils/setup.js`)) {
106
+ const sFile = fs.readFileSync(`${adaptdir}/utils/setup.js`, 'utf8');
107
+ scodeCount += sFile.split('\n').length;
108
+ } else {
109
+ console.log('Missing - utils/setup.js');
110
+ }
111
+ if (fs.existsSync(`${adaptdir}/utils/tbScript.js`)) {
112
+ const sFile = fs.readFileSync(`${adaptdir}/utils/tbScript.js`, 'utf8');
113
+ scodeCount += sFile.split('\n').length;
114
+ } else {
115
+ console.log('Missing - utils/tbScript.js');
116
+ }
117
+ if (fs.existsSync(`${adaptdir}/utils/tbUtils.js`)) {
118
+ const sFile = fs.readFileSync(`${adaptdir}/utils/tbUtils.js`, 'utf8');
119
+ scodeCount += sFile.split('\n').length;
120
+ } else {
121
+ console.log('Missing - utils/tbUtils.js');
122
+ }
123
+ if (fs.existsSync(`${adaptdir}/utils/testRunner.js`)) {
124
+ const sFile = fs.readFileSync(`${adaptdir}/utils/testRunner.js`, 'utf8');
125
+ scodeCount += sFile.split('\n').length;
126
+ } else {
127
+ console.log('Missing - utils/testRunner.js');
128
+ }
129
+ if (fs.existsSync(`${adaptdir}/utils/troubleshootingAdapter.js`)) {
130
+ const sFile = fs.readFileSync(`${adaptdir}/utils/troubleshootingAdapter.js`, 'utf8');
131
+ scodeCount += sFile.split('\n').length;
132
+ } else {
133
+ console.log('Missing - utils/troubleshootingAdapter.js');
134
+ }
135
+ infoRes.scriptLines = scodeCount;
136
+
137
+ let codeCount = 0;
138
+ if (fs.existsSync(`${adaptdir}/adapter.js`)) {
139
+ const aFile = fs.readFileSync(`${adaptdir}/adapter.js`, 'utf8');
140
+ codeCount += aFile.split('\n').length;
141
+ } else {
142
+ console.log('Missing - utils/adapter.js');
143
+ }
144
+ if (fs.existsSync(`${adaptdir}/adapterBase.js`)) {
145
+ const aFile = fs.readFileSync(`${adaptdir}/adapterBase.js`, 'utf8');
146
+ codeCount += aFile.split('\n').length;
147
+ } else {
148
+ console.log('Missing - utils/adapterBase.js');
149
+ }
150
+ infoRes.codeLines = codeCount;
151
+
152
+ let tcodeCount = 0;
153
+ let ttestCount = 0;
154
+ if (fs.existsSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`)) {
155
+ const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestBasicGet.js`, 'utf8');
156
+ tcodeCount += tFile.split('\n').length;
157
+ ttestCount += tFile.split('it(\'').length;
158
+ } else {
159
+ console.log('Missing - test/integration/adapterTestBasicGet.js');
160
+ }
161
+ if (fs.existsSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`)) {
162
+ const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestConnectivity.js`, 'utf8');
163
+ tcodeCount += tFile.split('\n').length;
164
+ ttestCount += tFile.split('it(\'').length;
165
+ } else {
166
+ console.log('Missing - test/integration/adapterTestConnectivity.js');
167
+ }
168
+ if (fs.existsSync(`${adaptdir}/test/integration/adapterTestIntegration.js`)) {
169
+ const tFile = fs.readFileSync(`${adaptdir}/test/integration/adapterTestIntegration.js`, 'utf8');
170
+ tcodeCount += tFile.split('\n').length;
171
+ ttestCount += tFile.split('it(\'').length;
172
+ } else {
173
+ console.log('Missing - test/integration/adapterTestIntegration.js');
174
+ }
175
+ if (fs.existsSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`)) {
176
+ const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterBaseTestUnit.js`, 'utf8');
177
+ tcodeCount += tFile.split('\n').length;
178
+ ttestCount += tFile.split('it(\'').length;
179
+ } else {
180
+ console.log('Missing - test/unit/adapterBaseTestUnit.js');
181
+ }
182
+ if (fs.existsSync(`${adaptdir}/test/unit/adapterTestUnit.js`)) {
183
+ const tFile = fs.readFileSync(`${adaptdir}/test/unit/adapterTestUnit.js`, 'utf8');
184
+ tcodeCount += tFile.split('\n').length;
185
+ ttestCount += tFile.split('it(\'').length;
186
+ } else {
187
+ console.log('Missing - test/unit/adapterTestUnit.js');
188
+ }
189
+ infoRes.testLines = tcodeCount;
190
+ infoRes.testCases = ttestCount;
191
+ infoRes.totalCodeLines = scodeCount + codeCount + tcodeCount;
192
+
193
+ if (fs.existsSync(`${adaptdir}/pronghorn.json`)) {
194
+ // Read the entity schema from the file system
195
+ const phFile = path.join(adaptdir, '/pronghorn.json');
196
+ const prong = require(phFile);
197
+ infoRes.wfTasks = prong.methods.length;
198
+ } else {
199
+ console.log('Missing - pronghorn.json');
200
+ }
201
+
202
+ console.log(JSON.stringify(infoRes));
203
+ fs.writeFileSync(`${adaptdir}/report/adapterInfo.json`, JSON.stringify(infoRes, null, 2));
204
+ }
205
+
206
+ adapterInfo();
@@ -14,10 +14,8 @@
14
14
  */
15
15
 
16
16
  const fs = require('fs');
17
- const { MongoClient } = require('mongodb');
18
17
  const path = require('path');
19
- // const { argv } = require('process');
20
- // const { string } = require('yargs');
18
+ const utils = require('./tbUtils');
21
19
 
22
20
  // get the pronghorn database information
23
21
  const getPronghornProps = async (iapDir) => {
@@ -99,7 +97,7 @@ const optionsHandler = (options) => {
99
97
  /**
100
98
  * Function used to put the adapter configuration into the provided database
101
99
  */
102
- const moveEntitiesToDB = (targetPath, options) => {
100
+ const moveEntitiesToDB = async (targetPath, options) => {
103
101
  // set local variables
104
102
  let myOpts = options;
105
103
  let myPath = targetPath;
@@ -120,25 +118,7 @@ const moveEntitiesToDB = (targetPath, options) => {
120
118
  }
121
119
 
122
120
  // get the pronghorn database properties
123
- optionsHandler(options).then((currentProps) => {
124
- let mongoUrl;
125
- let dbName;
126
-
127
- // find the mongo properties so we can connect
128
- if (currentProps.mongoProps) {
129
- mongoUrl = currentProps.mongoProps.url;
130
- dbName = currentProps.mongoProps.db;
131
- } else if (currentProps.mongo) {
132
- if (currentProps.mongo.url) {
133
- mongoUrl = currentProps.mongo.url;
134
- } else {
135
- mongoUrl = `mongodb://${currentProps.mongo.host}:${currentProps.mongo.port}`;
136
- }
137
- dbName = currentProps.mongo.database;
138
- } else {
139
- throw new Error('Mongo properties are not specified in adapter preferences!');
140
- }
141
-
121
+ return optionsHandler(options).then(async (currentProps) => {
142
122
  // Check valid filepath provided
143
123
  if (!myPath) {
144
124
  // if no path use the current directory without the utils
@@ -184,41 +164,16 @@ const moveEntitiesToDB = (targetPath, options) => {
184
164
  });
185
165
 
186
166
  // Upload documents to db collection
187
- MongoClient.connect(mongoUrl, (err, db) => {
188
- if (err) {
189
- log.error(JSON.stringify(err));
190
- throw err;
191
- }
192
-
193
- // get the proper collection
194
- const collection = db.db(dbName).collection(myOpts.targetCollection);
195
- // insert the documents into the collection
196
- collection.insertMany(docs, { checkKeys: false }, (error, res) => {
197
- if (error) {
198
- log.error(JSON.stringify(error));
199
- throw error;
200
- }
201
- // log the insertion, close the database and return
202
- log.debug(`Inserted ${docs.length} documents to ${dbName}.${myOpts.targetCollection} with response ${JSON.stringify(res)}`);
203
- db.close();
204
- return res;
205
- });
206
- });
167
+ const iapDir = utils.getIAPHome();
168
+ const db = await utils.connect(iapDir, currentProps).catch((err) => { console.error(err); throw err; });
169
+ if (!db) {
170
+ console.error('Error occured when connectiong to database', currentProps);
171
+ throw new Error('Database not found');
172
+ }
173
+ const collection = db.collection(myOpts.targetCollection);
174
+ const res = await collection.insertMany(docs, { checkKeys: false }).catch((err) => { console.error(err); throw err; });
175
+ return res;
207
176
  });
208
177
  };
209
178
 
210
- // const args = process.argv.slice(2);
211
-
212
- // throw new SyntaxError(args[0]);
213
-
214
- // if (args.length === 0) {
215
- // console.error('ERROR: target path not specified!');
216
- // } else if (args[0] === 'help') {
217
- // log.trace('node ./entitiesToDB <target path> <options object: {iapDir: string, pronghornProps: string, targetCollection: string}>');
218
- // } else if (args.length === 1) {
219
- // console.error('ERROR: IAP directory not specified');
220
- // } else {
221
- // moveEntitiesToDB(args[0], args[1]);
222
- // }
223
-
224
179
  module.exports = { moveEntitiesToDB };
@@ -0,0 +1,90 @@
1
+ const fs = require('fs');
2
+ const semverSatisfies = require('semver/functions/satisfies');
3
+ const packageJson = require('../package.json');
4
+
5
+ try {
6
+ // pattern supplied by semver.org via https://regex101.com/r/vkijKf/1/ but removed gm from end to only match a single semver
7
+ // const semverPat = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
8
+ // pattern supplied by semver.org via https://regex101.com/r/Ly7O1x/3/ with following changes
9
+ // removed P's from before capturing group names and
10
+ // removed gm from end to only match a single semver
11
+ // const semverPat = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
12
+
13
+ const patches = (fs.existsSync('./patches')) ? fs.readdirSync('./patches', { withFileTypes: true }) : [];
14
+ if (!patches.length) {
15
+ console.error('\nno patches - nothing to do\n');
16
+ process.exitCode = 1;
17
+ }
18
+
19
+ const dependencies = packageJson.dependencies || {};
20
+ if (!Object.keys(dependencies).length) {
21
+ console.error('\nno dependencies - nothing to do\n');
22
+ process.exitCode = 1;
23
+ }
24
+
25
+ let changed = false;
26
+ console.error('\nprocessing patches');
27
+ const bundledDependencies = packageJson.bundledDependencies || packageJson.bundleDependencies || [];
28
+
29
+ patches.forEach((patch) => {
30
+ if (!patch.isFile()) {
31
+ console.error(`${patch.name} skipped, is not a regular file`);
32
+ return;
33
+ }
34
+ if (!patch.name.endsWith('.patch')) {
35
+ console.error(`${patch.name} skipped, does not end with .patch`);
36
+ return;
37
+ }
38
+ const splits = patch.name.slice(0, -6).split('+');
39
+ if (splits.length > 4) {
40
+ console.error(`${patch.name} skipped, does not follow the naming convention (cannot use '+' other than to separate scope/package/semver and at most once within semver)`);
41
+ return;
42
+ }
43
+ const scope = splits[0][0] === '@' ? splits.shift() : null;
44
+ const packageName = splits.shift();
45
+ const semver = splits.join('+');
46
+ // const { groups } = semver.match(semverPat);
47
+ const file = scope ? `${scope}/${packageName}` : packageName;
48
+ if (dependencies[file] && semverSatisfies(semver, dependencies[file])) {
49
+ if (!bundledDependencies.includes(file)) {
50
+ bundledDependencies.push(file);
51
+ console.error(`added ${file} to bundledDependencies`);
52
+ changed = true;
53
+ } else {
54
+ console.error(`bundledDependencies already has ${file}`);
55
+ }
56
+ } else {
57
+ const depmsg = dependencies[file] ? `version mismatch (${dependencies[file]}) in dependencies` : 'not found in dependencies';
58
+ console.error(`patch ${patch.name} ${depmsg}`);
59
+ }
60
+ });
61
+
62
+ if (!packageJson.bundledDependencies && bundledDependencies.length) {
63
+ delete packageJson.bundleDependencies;
64
+ packageJson.bundledDependencies = bundledDependencies;
65
+ console.error('renaming bundleDependencies to bundledDependencies');
66
+ changed = true;
67
+ }
68
+ if (changed) {
69
+ fs.writeFileSync('./package.json.new', JSON.stringify(packageJson, null, 2));
70
+ console.error('wrote package.json.new');
71
+ fs.renameSync('./package.json', './package.json.old');
72
+ console.error('moved package.json to package.json.old');
73
+ fs.renameSync('./package.json.new', './package.json');
74
+ console.error('moved package.json.new to package.json');
75
+ } else {
76
+ console.error('no changes\n');
77
+ process.exitCode = 1;
78
+ }
79
+ } catch (e) {
80
+ if (e) {
81
+ // caught error, exit with status 2 to signify abject failure
82
+ console.error(`\ncaught exception - ${e}\n`);
83
+ process.exitCode = 2;
84
+ } else {
85
+ // caught false, exit with status 1 to signify nothing done
86
+ process.exitCode = 1;
87
+ }
88
+ } finally {
89
+ console.error('done\n');
90
+ }
@@ -17,6 +17,9 @@ printf "%b" "Running pre-commit hooks...\\n"
17
17
  # verify testing script is stubbed and no credentials
18
18
  node utils/testRunner.js -r
19
19
 
20
+ # update the adapter information file
21
+ node utils/adapterInfo.js
22
+
20
23
  # security audit on the code
21
24
  npm audit --registry=https://registry.npmjs.org --audit-level=moderate
22
25
 
package/utils/tbScript.js CHANGED
@@ -1,4 +1,4 @@
1
- /* eslint no-console: warn */
1
+ /* eslint-disable no-console */
2
2
  /* eslint import/no-unresolved: warn */
3
3
  /* eslint global-require: warn */
4
4
 
@@ -7,7 +7,6 @@
7
7
  /* eslint import/no-extraneous-dependencies: warn */
8
8
  /* eslint import/no-dynamic-require: warn */
9
9
 
10
- const path = require('path');
11
10
  const program = require('commander');
12
11
  const rls = require('readline-sync');
13
12
  const utils = require('./tbUtils');
@@ -19,32 +18,39 @@ const { addAuthInfo } = require('./addAuth');
19
18
 
20
19
  const { troubleshoot, offline } = require('./troubleshootingAdapter');
21
20
 
22
- const main = async (command) => {
23
- const dirname = utils.getDirname();
24
- const iapDir = path.join(dirname, '../../../../');
25
- if (!utils.withinIAP(iapDir)) {
26
- if (command === 'install') {
27
- console.log('Not currently in IAP directory - installation not possible');
28
- process.exit(0);
29
- } else if (command === 'connectivity') {
21
+ const executeInStandaloneMode = async (command) => {
22
+ console.info('\n> Executing the script outside of IAP installation directory');
23
+ console.info('> Using sampleProperties.json configuration');
24
+ switch (command) {
25
+ case 'install': {
26
+ console.error('Not currently in IAP directory - installation not possible');
27
+ break;
28
+ }
29
+ case 'connectivity': {
30
30
  const { host } = sampleProperties.properties;
31
31
  console.log(`perform networking diagnositics to ${host}`);
32
- await utils.runConnectivity(host);
33
- process.exit(0);
34
- } else if (command === 'healthcheck') {
32
+ utils.runConnectivity(host);
33
+ break;
34
+ }
35
+ case 'healthcheck': {
35
36
  const a = basicGet.getAdapterInstance({ properties: sampleProperties });
36
37
  await utils.healthCheck(a);
37
- process.exit(0);
38
- } else if (command === 'basicget') {
39
- await utils.runBasicGet();
40
- process.exit(0);
38
+ break;
41
39
  }
42
- if (rls.keyInYN('Troubleshooting without IAP?')) {
43
- await offline();
40
+ case 'basicget': {
41
+ utils.runBasicGet();
42
+ break;
43
+ }
44
+ default: {
45
+ if (rls.keyInYN('Troubleshooting without IAP?')) {
46
+ await offline();
47
+ }
44
48
  }
45
- process.exit(0);
46
49
  }
50
+ process.exit(0);
51
+ };
47
52
 
53
+ const executeUnderIAPInstallationDirectory = async (command) => {
48
54
  if (command === undefined) {
49
55
  await troubleshoot({}, true, true);
50
56
  } else if (command === 'install') {
@@ -79,6 +85,7 @@ const main = async (command) => {
79
85
  process.exit(0);
80
86
  }
81
87
  } else {
88
+ const dirname = utils.getCurrentExecutionPath();
82
89
  utils.verifyInstallationDir(dirname, name);
83
90
  utils.runTest();
84
91
  if (rls.keyInYN(`Do you want to install ${name} to IAP?`)) {
@@ -123,6 +130,14 @@ const main = async (command) => {
123
130
  }
124
131
  };
125
132
 
133
+ const main = async (command) => {
134
+ if (!utils.areWeUnderIAPinstallationDirectory()) {
135
+ executeInStandaloneMode(command); // configuration from sampleproperties.json
136
+ } else {
137
+ executeUnderIAPInstallationDirectory(command); // configuration from $IAP_HOME/properties.json
138
+ }
139
+ };
140
+
126
141
  program
127
142
  .command('connectivity')
128
143
  .alias('c')
package/utils/tbUtils.js CHANGED
@@ -3,6 +3,7 @@
3
3
  /* eslint import/no-extraneous-dependencies: warn */
4
4
  /* eslint global-require: warn */
5
5
  /* eslint import/no-dynamic-require: warn */
6
+ /* eslint-disable no-console */
6
7
 
7
8
  const path = require('path');
8
9
  const fs = require('fs-extra');
@@ -100,8 +101,8 @@ module.exports = {
100
101
  *
101
102
  * @function decryptProperties
102
103
  */
103
- decryptProperties: (props, dirname, discovery) => {
104
- const propertyEncryptionClassPath = path.join(dirname, '../../../@itential/pronghorn-core/core/PropertyEncryption.js');
104
+ decryptProperties: (props, iapDir, discovery) => {
105
+ const propertyEncryptionClassPath = path.join(iapDir, 'node_modules/@itential/pronghorn-core/core/PropertyEncryption.js');
105
106
  const isEncrypted = props.pathProps.encrypted;
106
107
  const PropertyEncryption = discovery.require(propertyEncryptionClassPath, isEncrypted);
107
108
  const propertyEncryption = new PropertyEncryption({
@@ -177,12 +178,12 @@ module.exports = {
177
178
  verifyInstallationDir: (dirname, name) => {
178
179
  const pathArray = dirname.split(path.sep);
179
180
  const expectedPath = `node_modules/${name}`;
180
- const currentPath = pathArray.slice(pathArray.length - 4, pathArray.length - 1).join('/');
181
+ const currentPath = pathArray.slice(pathArray.length - 3, pathArray.length).join('/');
181
182
  if (currentPath.trim() !== expectedPath.trim()) {
182
- throw new Error(`adapter should be installed under ${expectedPath}`);
183
+ throw new Error(`adapter should be installed under ${expectedPath} but is installed under ${currentPath}`);
183
184
  }
184
185
 
185
- const serverFile = path.join(dirname, '../../../..', 'server.js');
186
+ const serverFile = path.join(dirname, '../../../', 'server.js');
186
187
  if (!fs.existsSync(serverFile)) {
187
188
  throw new Error(`adapter should be installed under IAP/${expectedPath}`);
188
189
  }
@@ -305,9 +306,9 @@ module.exports = {
305
306
  * @param {Object} sampleProperties - './sampleProperties.json' in adapter dir
306
307
  */
307
308
  createAdapter: function createAdapter(pronghornProps, profileItem, sampleProperties, adapterPronghorn) {
308
- const dirname = this.getDirname();
309
- const packagePath = `${dirname.split('node_modules')[0]}package.json`;
310
- const info = JSON.parse(fs.readFileSync(packagePath));
309
+ const iapDir = this.getIAPHome();
310
+ const packageFile = path.join(iapDir, 'package.json');
311
+ const info = JSON.parse(fs.readFileSync(packageFile));
311
312
  const version = parseInt(info.version.split('.')[0], 10);
312
313
 
313
314
  let adapter = {};
@@ -345,17 +346,17 @@ module.exports = {
345
346
  console.log('Decrypting properties...');
346
347
  const { Discovery } = require(path.join(iapDir, 'node_modules/@itential/itential-utils'));
347
348
  const discovery = new Discovery();
348
- const pronghornProps = this.decryptProperties(rawProps, this.getDirname(), discovery);
349
+ const pronghornProps = this.decryptProperties(rawProps, iapDir, discovery);
349
350
  console.log('Found properties.\n');
350
351
  return pronghornProps;
351
352
  },
352
353
 
353
354
  // get database connection and existing adapter config
354
355
  getAdapterConfig: async function getAdapterConfig() {
355
- const iapDir = path.join(this.getDirname(), '../../../../');
356
+ const iapDir = this.getIAPHome();
356
357
  const pronghornProps = this.getPronghornProps(iapDir);
357
358
  console.log('Connecting to Database...');
358
- const database = await this.connect(pronghornProps);
359
+ const database = await this.connect(iapDir, pronghornProps);
359
360
  console.log('Connection established.');
360
361
  const { name } = require(path.join(__dirname, '..', 'package.json'));
361
362
  const serviceItem = await database.collection(this.SERVICE_CONFIGS_COLLECTION).findOne(
@@ -399,33 +400,42 @@ module.exports = {
399
400
  },
400
401
 
401
402
  /**
402
- * @summary Check whether adapter is located within IAP node_modules
403
- * by loading properties.json. If not, return false.
404
- * @function withinIAP
405
- * @param {String} iapDir root directory of IAP
403
+ * @summary Obtain the IAP installation directory depending on how adapter is used:
404
+ * by IAP, or by npm run CLI interface
405
+ * @returns IAP installation directory or null if adapter running without IAP
406
+ * @function getIAPHome
406
407
  */
407
- withinIAP: (iapDir) => {
408
- try {
409
- const rawProps = require(path.join(iapDir, 'properties.json'));
410
- return rawProps;
411
- } catch (error) {
412
- return false;
408
+ getIAPHome: function getIAPHome() {
409
+ let IAPHomePath = null;
410
+ // check if adapter started via IAP, use path injected by core
411
+ if (process.env.iap_home) IAPHomePath = process.env.iap_home;
412
+ // check if adapter started via CLI `npm run <command>` so we have to be located under
413
+ // <IAP_HOME>/node_modules/@itentialopensource/<adapter_name>/ directory
414
+ const currentExecutionPath = this.getCurrentExecutionPath();
415
+ if (currentExecutionPath.indexOf('/node_modules') >= 0) {
416
+ [IAPHomePath] = currentExecutionPath.split('/node_modules');
413
417
  }
418
+ return IAPHomePath;
414
419
  },
415
420
 
416
421
  /**
417
- * @summary Used to determine the proper dirname to return in case adapter reference is
418
- * symlinked withink IAP
419
- * @returns the symlinked path (using pwd command) of the adapter in case properties.json
420
- * is not found in the original path
421
- * @function getDirname
422
+ * @summary get current execution path without resolving symbolic links,
423
+ * use `pwd` command wihout '-P' option (resolving symlinks) https://linux.die.net/man/1/pwd
424
+ * @returns
425
+ * @function getCurrentExecutionPAth
422
426
  */
423
- getDirname: function getDirname() {
424
- if (this.withinIAP(path.join(__dirname, '../../../../'))) {
425
- return __dirname;
426
- }
427
+ getCurrentExecutionPath: function getCurrentExecutionPAth() {
427
428
  const { stdout } = this.systemSync('pwd', true);
428
- return path.join(stdout, 'utils');
429
+ return stdout.trim();
430
+ },
431
+
432
+ /**
433
+ * @summary checks if command executed from <IAP_HOME>/node_modules/@itentialopensource/<adapter_name>/ location
434
+ * @returns true if command executed under <IAP_HOME>/node_modules/@itentialopensource/<adapter_name>/ path
435
+ * @function areWeUnderIAPinstallationDirectory
436
+ */
437
+ areWeUnderIAPinstallationDirectory: function areWeUnderIAPinstallationDirectory() {
438
+ return path.join(this.getCurrentExecutionPath(), '../../..') === this.getIAPHome();
429
439
  },
430
440
 
431
441
  /**
@@ -434,10 +444,24 @@ module.exports = {
434
444
  * @function connect
435
445
  * @param {Object} properties - pronghornProps
436
446
  */
437
- connect: async function connect(properties) {
438
- // Connect to Mongo
439
- const { MongoDBConnection } = require(path.join(this.getDirname(), '../../../', '@itential/database'));
440
- const connection = new MongoDBConnection(properties.mongoProps);
447
+ connect: async function connect(iapDir, properties) {
448
+ let dbConnectionProperties = {};
449
+ if (properties.mongoProps) {
450
+ dbConnectionProperties = properties.mongoProps;
451
+ } else if (properties.mongo) {
452
+ if (properties.mongo.url) {
453
+ dbConnectionProperties.url = properties.mongo.url;
454
+ } else {
455
+ dbConnectionProperties.url = `mongodb://${properties.mongo.host}:${properties.mongo.port}`;
456
+ }
457
+ dbConnectionProperties.db = properties.mongo.database;
458
+ }
459
+ if (!dbConnectionProperties.url || !dbConnectionProperties.db) {
460
+ throw new Error('Mongo properties are not specified in IAP configuration!');
461
+ }
462
+
463
+ const { MongoDBConnection } = require(path.join(iapDir, 'node_modules/@itential/database'));
464
+ const connection = new MongoDBConnection(dbConnectionProperties);
441
465
  const database = await connection.connect(true);
442
466
  return database;
443
467
  }