@proteinjs/reflection-build 1.1.1 → 1.2.1

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 (303) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/src/codegen/writeGeneratedIndex.js +9 -0
  3. package/dist/src/codegen/writeGeneratedIndex.js.map +1 -1
  4. package/dist/test/examples/source-repository/a/generated/index.js +1 -1
  5. package/dist/test/examples/source-repository/a/generated/index.js.map +1 -1
  6. package/dist/test/examples/source-repository/b/generated/index.js +1 -1
  7. package/dist/test/examples/source-repository/b/generated/index.js.map +1 -1
  8. package/package.json +4 -5
  9. package/src/codegen/writeGeneratedIndex.ts +12 -0
  10. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js +9 -0
  11. package/test/examples/source-repository/a/dist/codegen/writeGeneratedIndex.js.map +1 -1
  12. package/test/examples/source-repository/a/dist/generated/index.js +1 -1
  13. package/test/examples/source-repository/a/dist/generated/index.js.map +1 -1
  14. package/test/examples/source-repository/a/generated/index.ts +33 -38
  15. package/test/examples/source-repository/a/node_modules/.package-lock.json +59 -6
  16. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/.eslintrc.js +20 -0
  17. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/.prettierignore +4 -0
  18. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/.prettierrc +8 -0
  19. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/CHANGELOG.md +58 -0
  20. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/index.d.ts +5 -0
  21. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/index.js +18 -0
  22. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/index.js.map +1 -0
  23. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/FlattenedSourceGraph.d.ts +19 -0
  24. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/FlattenedSourceGraph.js +555 -0
  25. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/FlattenedSourceGraph.js.map +1 -0
  26. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/Loadable.d.ts +3 -0
  27. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/Loadable.js +5 -0
  28. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/Loadable.js.map +1 -0
  29. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/SourceRepository.d.ts +45 -0
  30. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/SourceRepository.js +176 -0
  31. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/SourceRepository.js.map +1 -0
  32. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/SourceRepositoryFilter.d.ts +11 -0
  33. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/SourceRepositoryFilter.js +9 -0
  34. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/SourceRepositoryFilter.js.map +1 -0
  35. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/sourceGraphTypes.d.ts +13 -0
  36. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/sourceGraphTypes.js +19 -0
  37. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/sourceGraphTypes.js.map +1 -0
  38. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/types.d.ts +221 -0
  39. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/types.js +234 -0
  40. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/dist/src/types.js.map +1 -0
  41. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/index.ts +5 -0
  42. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/jest.config.js +9 -0
  43. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/package.json +42 -0
  44. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/src/FlattenedSourceGraph.ts +702 -0
  45. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/src/Loadable.ts +2 -0
  46. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/src/SourceRepository.ts +250 -0
  47. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/src/SourceRepositoryFilter.ts +15 -0
  48. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/src/sourceGraphTypes.ts +14 -0
  49. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/src/types.ts +236 -0
  50. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/tsconfig.json +19 -0
  51. package/test/examples/source-repository/a/node_modules/@proteinjs/reflection/types/@dagrejs/graphlib.d.ts +1 -0
  52. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/CHANGELOG.md +13 -0
  53. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.d.ts +23 -0
  54. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.js +67 -0
  55. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/Fs.js.map +1 -1
  56. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/GitUtil.d.ts +297 -10
  57. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/GitUtil.js +349 -112
  58. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/GitUtil.js.map +1 -1
  59. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/cmd.d.ts +10 -1
  60. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/cmd.js +91 -48
  61. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/dist/src/cmd.js.map +1 -1
  62. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/package.json +2 -2
  63. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/Fs.ts +75 -0
  64. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/GitUtil.ts +248 -110
  65. package/test/examples/source-repository/a/node_modules/@proteinjs/util-node/src/cmd.ts +84 -59
  66. package/test/examples/source-repository/a/node_modules/bindings/LICENSE.md +22 -0
  67. package/test/examples/source-repository/a/node_modules/bindings/README.md +98 -0
  68. package/test/examples/source-repository/a/node_modules/bindings/bindings.js +221 -0
  69. package/test/examples/source-repository/a/node_modules/bindings/package.json +28 -0
  70. package/test/examples/source-repository/a/node_modules/file-uri-to-path/.travis.yml +30 -0
  71. package/test/examples/source-repository/a/node_modules/file-uri-to-path/History.md +21 -0
  72. package/test/examples/source-repository/a/node_modules/file-uri-to-path/LICENSE +20 -0
  73. package/test/examples/source-repository/a/node_modules/file-uri-to-path/README.md +74 -0
  74. package/test/examples/source-repository/a/node_modules/file-uri-to-path/index.d.ts +2 -0
  75. package/test/examples/source-repository/a/node_modules/file-uri-to-path/index.js +66 -0
  76. package/test/examples/source-repository/a/node_modules/file-uri-to-path/package.json +32 -0
  77. package/test/examples/source-repository/a/node_modules/file-uri-to-path/test/test.js +24 -0
  78. package/test/examples/source-repository/a/node_modules/file-uri-to-path/test/tests.json +13 -0
  79. package/test/examples/source-repository/a/node_modules/fsevents/LICENSE +22 -0
  80. package/test/examples/source-repository/a/node_modules/fsevents/README.md +89 -0
  81. package/test/examples/source-repository/a/node_modules/fsevents/fsevents.d.ts +46 -0
  82. package/test/examples/source-repository/a/node_modules/fsevents/fsevents.js +83 -0
  83. package/test/examples/source-repository/a/node_modules/fsevents/fsevents.node +0 -0
  84. package/test/examples/source-repository/a/node_modules/fsevents/package.json +62 -0
  85. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/.travis.yml +103 -0
  86. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/ISSUE_TEMPLATE.md +8 -0
  87. package/{LICENSE → test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/LICENSE} +6 -5
  88. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/Readme.md +78 -0
  89. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/binding.gyp +21 -0
  90. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/.target.mk +53 -0
  91. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/Makefile +352 -0
  92. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/Release/.deps/Release/.node.d +1 -0
  93. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/Release/.deps/Release/obj.target/fse/fsevents.o.d.raw +75 -0
  94. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/Release/.node +0 -0
  95. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/binding.Makefile +6 -0
  96. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/fse.target.mk +188 -0
  97. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/build/gyp-mac-tool +772 -0
  98. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/fsevents.cc +88 -0
  99. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/fsevents.js +106 -0
  100. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/install.js +13 -0
  101. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/package.json +34 -0
  102. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/src/async.cc +43 -0
  103. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/src/constants.cc +110 -0
  104. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/src/methods.cc +44 -0
  105. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/src/storage.cc +27 -0
  106. package/test/examples/source-repository/a/node_modules/glob-watcher/node_modules/fsevents/src/thread.cc +71 -0
  107. package/test/examples/source-repository/a/node_modules/nan/CHANGELOG.md +557 -0
  108. package/test/examples/source-repository/a/node_modules/nan/CMakeLists.txt +138 -0
  109. package/test/examples/source-repository/a/node_modules/nan/LICENSE.md +9 -0
  110. package/test/examples/source-repository/a/node_modules/nan/README.md +456 -0
  111. package/test/examples/source-repository/a/node_modules/nan/doc/asyncworker.md +146 -0
  112. package/test/examples/source-repository/a/node_modules/nan/doc/buffers.md +54 -0
  113. package/test/examples/source-repository/a/node_modules/nan/doc/callback.md +76 -0
  114. package/test/examples/source-repository/a/node_modules/nan/doc/converters.md +41 -0
  115. package/test/examples/source-repository/a/node_modules/nan/doc/errors.md +226 -0
  116. package/test/examples/source-repository/a/node_modules/nan/doc/json.md +62 -0
  117. package/test/examples/source-repository/a/node_modules/nan/doc/maybe_types.md +583 -0
  118. package/test/examples/source-repository/a/node_modules/nan/doc/methods.md +672 -0
  119. package/test/examples/source-repository/a/node_modules/nan/doc/new.md +147 -0
  120. package/test/examples/source-repository/a/node_modules/nan/doc/node_misc.md +123 -0
  121. package/test/examples/source-repository/a/node_modules/nan/doc/object_wrappers.md +263 -0
  122. package/test/examples/source-repository/a/node_modules/nan/doc/persistent.md +296 -0
  123. package/test/examples/source-repository/a/node_modules/nan/doc/scopes.md +73 -0
  124. package/test/examples/source-repository/a/node_modules/nan/doc/script.md +58 -0
  125. package/test/examples/source-repository/a/node_modules/nan/doc/string_bytes.md +62 -0
  126. package/test/examples/source-repository/a/node_modules/nan/doc/v8_internals.md +199 -0
  127. package/test/examples/source-repository/a/node_modules/nan/doc/v8_misc.md +85 -0
  128. package/test/examples/source-repository/a/node_modules/nan/include_dirs.js +1 -0
  129. package/test/examples/source-repository/a/node_modules/nan/nan.h +2958 -0
  130. package/test/examples/source-repository/a/node_modules/nan/nan_callbacks.h +92 -0
  131. package/test/examples/source-repository/a/node_modules/nan/nan_callbacks_12_inl.h +520 -0
  132. package/test/examples/source-repository/a/node_modules/nan/nan_callbacks_pre_12_inl.h +520 -0
  133. package/test/examples/source-repository/a/node_modules/nan/nan_converters.h +72 -0
  134. package/test/examples/source-repository/a/node_modules/nan/nan_converters_43_inl.h +68 -0
  135. package/test/examples/source-repository/a/node_modules/nan/nan_converters_pre_43_inl.h +42 -0
  136. package/test/examples/source-repository/a/node_modules/nan/nan_define_own_property_helper.h +29 -0
  137. package/test/examples/source-repository/a/node_modules/nan/nan_implementation_12_inl.h +430 -0
  138. package/test/examples/source-repository/a/node_modules/nan/nan_implementation_pre_12_inl.h +263 -0
  139. package/test/examples/source-repository/a/node_modules/nan/nan_json.h +166 -0
  140. package/test/examples/source-repository/a/node_modules/nan/nan_maybe_43_inl.h +356 -0
  141. package/test/examples/source-repository/a/node_modules/nan/nan_maybe_pre_43_inl.h +268 -0
  142. package/test/examples/source-repository/a/node_modules/nan/nan_new.h +340 -0
  143. package/test/examples/source-repository/a/node_modules/nan/nan_object_wrap.h +156 -0
  144. package/test/examples/source-repository/a/node_modules/nan/nan_persistent_12_inl.h +132 -0
  145. package/test/examples/source-repository/a/node_modules/nan/nan_persistent_pre_12_inl.h +242 -0
  146. package/test/examples/source-repository/a/node_modules/nan/nan_private.h +73 -0
  147. package/test/examples/source-repository/a/node_modules/nan/nan_scriptorigin.h +76 -0
  148. package/test/examples/source-repository/a/node_modules/nan/nan_string_bytes.h +305 -0
  149. package/test/examples/source-repository/a/node_modules/nan/nan_typedarray_contents.h +96 -0
  150. package/test/examples/source-repository/a/node_modules/nan/nan_weak.h +437 -0
  151. package/test/examples/source-repository/a/node_modules/nan/package.json +38 -0
  152. package/test/examples/source-repository/a/node_modules/nan/tools/1to2.js +412 -0
  153. package/test/examples/source-repository/a/node_modules/nan/tools/README.md +14 -0
  154. package/test/examples/source-repository/a/node_modules/nan/tools/package.json +19 -0
  155. package/test/examples/source-repository/a/package-lock.json +8 -8
  156. package/test/examples/source-repository/a/package.json +3 -3
  157. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js +9 -0
  158. package/test/examples/source-repository/b/dist/codegen/writeGeneratedIndex.js.map +1 -1
  159. package/test/examples/source-repository/b/dist/generated/index.js +1 -1
  160. package/test/examples/source-repository/b/dist/generated/index.js.map +1 -1
  161. package/test/examples/source-repository/b/generated/index.ts +11 -10
  162. package/test/examples/source-repository/b/node_modules/.package-lock.json +57 -4
  163. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/.eslintrc.js +20 -0
  164. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/.prettierignore +4 -0
  165. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/.prettierrc +8 -0
  166. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/CHANGELOG.md +58 -0
  167. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/index.d.ts +5 -0
  168. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/index.js +18 -0
  169. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/index.js.map +1 -0
  170. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/FlattenedSourceGraph.d.ts +19 -0
  171. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/FlattenedSourceGraph.js +555 -0
  172. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/FlattenedSourceGraph.js.map +1 -0
  173. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/Loadable.d.ts +3 -0
  174. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/Loadable.js +5 -0
  175. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/Loadable.js.map +1 -0
  176. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/SourceRepository.d.ts +45 -0
  177. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/SourceRepository.js +176 -0
  178. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/SourceRepository.js.map +1 -0
  179. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/SourceRepositoryFilter.d.ts +11 -0
  180. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/SourceRepositoryFilter.js +9 -0
  181. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/SourceRepositoryFilter.js.map +1 -0
  182. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/sourceGraphTypes.d.ts +13 -0
  183. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/sourceGraphTypes.js +19 -0
  184. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/sourceGraphTypes.js.map +1 -0
  185. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/types.d.ts +221 -0
  186. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/types.js +234 -0
  187. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/dist/src/types.js.map +1 -0
  188. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/index.ts +5 -0
  189. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/jest.config.js +9 -0
  190. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/package.json +42 -0
  191. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/src/FlattenedSourceGraph.ts +702 -0
  192. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/src/Loadable.ts +2 -0
  193. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/src/SourceRepository.ts +250 -0
  194. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/src/SourceRepositoryFilter.ts +15 -0
  195. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/src/sourceGraphTypes.ts +14 -0
  196. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/src/types.ts +236 -0
  197. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/tsconfig.json +19 -0
  198. package/test/examples/source-repository/b/node_modules/@proteinjs/reflection/types/@dagrejs/graphlib.d.ts +1 -0
  199. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/CHANGELOG.md +13 -0
  200. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.d.ts +23 -0
  201. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.js +67 -0
  202. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/Fs.js.map +1 -1
  203. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/GitUtil.d.ts +297 -10
  204. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/GitUtil.js +349 -112
  205. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/GitUtil.js.map +1 -1
  206. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/cmd.d.ts +10 -1
  207. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/cmd.js +91 -48
  208. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/dist/src/cmd.js.map +1 -1
  209. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/package.json +2 -2
  210. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/Fs.ts +75 -0
  211. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/GitUtil.ts +248 -110
  212. package/test/examples/source-repository/b/node_modules/@proteinjs/util-node/src/cmd.ts +84 -59
  213. package/test/examples/source-repository/b/node_modules/bindings/LICENSE.md +22 -0
  214. package/test/examples/source-repository/b/node_modules/bindings/README.md +98 -0
  215. package/test/examples/source-repository/b/node_modules/bindings/bindings.js +221 -0
  216. package/test/examples/source-repository/b/node_modules/bindings/package.json +28 -0
  217. package/test/examples/source-repository/b/node_modules/file-uri-to-path/.travis.yml +30 -0
  218. package/test/examples/source-repository/b/node_modules/file-uri-to-path/History.md +21 -0
  219. package/test/examples/source-repository/b/node_modules/file-uri-to-path/LICENSE +20 -0
  220. package/test/examples/source-repository/b/node_modules/file-uri-to-path/README.md +74 -0
  221. package/test/examples/source-repository/b/node_modules/file-uri-to-path/index.d.ts +2 -0
  222. package/test/examples/source-repository/b/node_modules/file-uri-to-path/index.js +66 -0
  223. package/test/examples/source-repository/b/node_modules/file-uri-to-path/package.json +32 -0
  224. package/test/examples/source-repository/b/node_modules/file-uri-to-path/test/test.js +24 -0
  225. package/test/examples/source-repository/b/node_modules/file-uri-to-path/test/tests.json +13 -0
  226. package/test/examples/source-repository/b/node_modules/fsevents/LICENSE +22 -0
  227. package/test/examples/source-repository/b/node_modules/fsevents/README.md +89 -0
  228. package/test/examples/source-repository/b/node_modules/fsevents/fsevents.d.ts +46 -0
  229. package/test/examples/source-repository/b/node_modules/fsevents/fsevents.js +83 -0
  230. package/test/examples/source-repository/b/node_modules/fsevents/fsevents.node +0 -0
  231. package/test/examples/source-repository/b/node_modules/fsevents/package.json +62 -0
  232. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/.travis.yml +103 -0
  233. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/ISSUE_TEMPLATE.md +8 -0
  234. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/LICENSE +22 -0
  235. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/Readme.md +78 -0
  236. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/binding.gyp +21 -0
  237. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/.target.mk +53 -0
  238. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/Makefile +352 -0
  239. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/Release/.deps/Release/.node.d +1 -0
  240. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/Release/.deps/Release/obj.target/fse/fsevents.o.d.raw +75 -0
  241. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/Release/.node +0 -0
  242. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/binding.Makefile +6 -0
  243. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/fse.target.mk +188 -0
  244. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/build/gyp-mac-tool +772 -0
  245. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/fsevents.cc +88 -0
  246. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/fsevents.js +106 -0
  247. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/install.js +13 -0
  248. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/package.json +34 -0
  249. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/src/async.cc +43 -0
  250. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/src/constants.cc +110 -0
  251. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/src/methods.cc +44 -0
  252. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/src/storage.cc +27 -0
  253. package/test/examples/source-repository/b/node_modules/glob-watcher/node_modules/fsevents/src/thread.cc +71 -0
  254. package/test/examples/source-repository/b/node_modules/nan/CHANGELOG.md +557 -0
  255. package/test/examples/source-repository/b/node_modules/nan/CMakeLists.txt +138 -0
  256. package/test/examples/source-repository/b/node_modules/nan/LICENSE.md +9 -0
  257. package/test/examples/source-repository/b/node_modules/nan/README.md +456 -0
  258. package/test/examples/source-repository/b/node_modules/nan/doc/asyncworker.md +146 -0
  259. package/test/examples/source-repository/b/node_modules/nan/doc/buffers.md +54 -0
  260. package/test/examples/source-repository/b/node_modules/nan/doc/callback.md +76 -0
  261. package/test/examples/source-repository/b/node_modules/nan/doc/converters.md +41 -0
  262. package/test/examples/source-repository/b/node_modules/nan/doc/errors.md +226 -0
  263. package/test/examples/source-repository/b/node_modules/nan/doc/json.md +62 -0
  264. package/test/examples/source-repository/b/node_modules/nan/doc/maybe_types.md +583 -0
  265. package/test/examples/source-repository/b/node_modules/nan/doc/methods.md +672 -0
  266. package/test/examples/source-repository/b/node_modules/nan/doc/new.md +147 -0
  267. package/test/examples/source-repository/b/node_modules/nan/doc/node_misc.md +123 -0
  268. package/test/examples/source-repository/b/node_modules/nan/doc/object_wrappers.md +263 -0
  269. package/test/examples/source-repository/b/node_modules/nan/doc/persistent.md +296 -0
  270. package/test/examples/source-repository/b/node_modules/nan/doc/scopes.md +73 -0
  271. package/test/examples/source-repository/b/node_modules/nan/doc/script.md +58 -0
  272. package/test/examples/source-repository/b/node_modules/nan/doc/string_bytes.md +62 -0
  273. package/test/examples/source-repository/b/node_modules/nan/doc/v8_internals.md +199 -0
  274. package/test/examples/source-repository/b/node_modules/nan/doc/v8_misc.md +85 -0
  275. package/test/examples/source-repository/b/node_modules/nan/include_dirs.js +1 -0
  276. package/test/examples/source-repository/b/node_modules/nan/nan.h +2958 -0
  277. package/test/examples/source-repository/b/node_modules/nan/nan_callbacks.h +92 -0
  278. package/test/examples/source-repository/b/node_modules/nan/nan_callbacks_12_inl.h +520 -0
  279. package/test/examples/source-repository/b/node_modules/nan/nan_callbacks_pre_12_inl.h +520 -0
  280. package/test/examples/source-repository/b/node_modules/nan/nan_converters.h +72 -0
  281. package/test/examples/source-repository/b/node_modules/nan/nan_converters_43_inl.h +68 -0
  282. package/test/examples/source-repository/b/node_modules/nan/nan_converters_pre_43_inl.h +42 -0
  283. package/test/examples/source-repository/b/node_modules/nan/nan_define_own_property_helper.h +29 -0
  284. package/test/examples/source-repository/b/node_modules/nan/nan_implementation_12_inl.h +430 -0
  285. package/test/examples/source-repository/b/node_modules/nan/nan_implementation_pre_12_inl.h +263 -0
  286. package/test/examples/source-repository/b/node_modules/nan/nan_json.h +166 -0
  287. package/test/examples/source-repository/b/node_modules/nan/nan_maybe_43_inl.h +356 -0
  288. package/test/examples/source-repository/b/node_modules/nan/nan_maybe_pre_43_inl.h +268 -0
  289. package/test/examples/source-repository/b/node_modules/nan/nan_new.h +340 -0
  290. package/test/examples/source-repository/b/node_modules/nan/nan_object_wrap.h +156 -0
  291. package/test/examples/source-repository/b/node_modules/nan/nan_persistent_12_inl.h +132 -0
  292. package/test/examples/source-repository/b/node_modules/nan/nan_persistent_pre_12_inl.h +242 -0
  293. package/test/examples/source-repository/b/node_modules/nan/nan_private.h +73 -0
  294. package/test/examples/source-repository/b/node_modules/nan/nan_scriptorigin.h +76 -0
  295. package/test/examples/source-repository/b/node_modules/nan/nan_string_bytes.h +305 -0
  296. package/test/examples/source-repository/b/node_modules/nan/nan_typedarray_contents.h +96 -0
  297. package/test/examples/source-repository/b/node_modules/nan/nan_weak.h +437 -0
  298. package/test/examples/source-repository/b/node_modules/nan/package.json +38 -0
  299. package/test/examples/source-repository/b/node_modules/nan/tools/1to2.js +412 -0
  300. package/test/examples/source-repository/b/node_modules/nan/tools/README.md +14 -0
  301. package/test/examples/source-repository/b/node_modules/nan/tools/package.json +19 -0
  302. package/test/examples/source-repository/b/package-lock.json +6 -6
  303. package/test/examples/source-repository/b/package.json +3 -3
@@ -1,93 +1,155 @@
1
1
  import { cmd } from './cmd';
2
+ import type { LogOptions } from './cmd';
3
+
4
+ type LogPassThrough = { log?: LogOptions };
5
+
6
+ const DEFAULT_SILENT_LOG: LogOptions = {
7
+ omitLogs: {
8
+ stdout: { omit: true },
9
+ stderr: { omit: true },
10
+ },
11
+ };
2
12
 
3
13
  export class GitUtil {
4
- static async cloneAppTemplatePackages(directory: string): Promise<void> {
5
- const args = ['clone', 'https://github.com/brentbahry/app-template.git', directory];
6
- let envVars;
7
- if (directory) {
8
- envVars = { cwd: directory };
9
- }
10
- await cmd('git', args, envVars);
14
+ static async cloneAppTemplatePackages(directory: string, opts?: LogPassThrough): Promise<void> {
15
+ const args = ['clone', 'https://github.com/proteinjs/app-template.git', directory];
16
+ const env = directory ? { cwd: directory } : undefined;
17
+ await cmd('git', args, env, opts?.log);
11
18
  }
12
19
 
13
- static async init(directory: string): Promise<void> {
20
+ static async init(directory: string, opts?: LogPassThrough): Promise<void> {
14
21
  const args = ['init'];
15
- let envVars;
16
- if (directory) {
17
- envVars = { cwd: directory };
18
- }
19
- await cmd('git', args, envVars);
22
+ const env = directory ? { cwd: directory } : undefined;
23
+ await cmd('git', args, env, opts?.log);
20
24
  }
21
25
 
22
- static async setRemote(directory: string, remote: string): Promise<void> {
26
+ static async setRemote(directory: string, remote: string, opts?: LogPassThrough): Promise<void> {
23
27
  const args = ['remote', 'set-url', 'origin', remote];
24
- let envVars;
25
- if (directory) {
26
- envVars = { cwd: directory };
27
- }
28
- await cmd('git', args, envVars);
28
+ const env = directory ? { cwd: directory } : undefined;
29
+ await cmd('git', args, env, opts?.log);
29
30
  }
30
31
 
31
- static async addRemote(directory: string, remote: string): Promise<void> {
32
+ static async addRemote(directory: string, remote: string, opts?: LogPassThrough): Promise<void> {
32
33
  const args = ['remote', 'add', 'origin', remote];
33
- let envVars;
34
- if (directory) {
35
- envVars = { cwd: directory };
36
- }
37
- await cmd('git', args, envVars);
34
+ const env = directory ? { cwd: directory } : undefined;
35
+ await cmd('git', args, env, opts?.log);
38
36
  }
39
37
 
40
- static async commit(directory: string, message: string): Promise<void> {
38
+ static async commit(directory: string, message: string, opts?: LogPassThrough): Promise<void> {
41
39
  const args = ['commit', '-m', message];
42
- let envVars;
43
- if (directory) {
44
- envVars = { cwd: directory };
45
- }
46
- await cmd('git', args, envVars);
40
+ const env = directory ? { cwd: directory } : undefined;
41
+ await cmd('git', args, env, opts?.log);
47
42
  }
48
43
 
49
- static async pull(directory: string): Promise<void> {
44
+ static async pull(directory: string, opts?: LogPassThrough): Promise<void> {
50
45
  const args = ['pull'];
51
- let envVars;
52
- if (directory) {
53
- envVars = { cwd: directory };
54
- }
55
- await cmd('git', args, envVars);
46
+ const env = directory ? { cwd: directory } : undefined;
47
+ await cmd('git', args, env, opts?.log);
56
48
  }
57
49
 
58
- static async push(directory: string): Promise<void> {
50
+ static async push(directory: string, opts?: LogPassThrough): Promise<void> {
59
51
  const args = ['push'];
60
- let envVars;
61
- if (directory) {
62
- envVars = { cwd: directory };
63
- }
64
- await cmd('git', args, envVars);
52
+ const env = directory ? { cwd: directory } : undefined;
53
+ await cmd('git', args, env, opts?.log);
65
54
  }
66
55
 
67
- static async status(directory: string): Promise<void> {
56
+ static async status(directory: string, opts?: LogPassThrough): Promise<void> {
68
57
  const args = ['status'];
69
- let envVars;
70
- if (directory) {
71
- envVars = { cwd: directory };
72
- }
73
- await cmd('git', args, envVars);
58
+ const env = directory ? { cwd: directory } : undefined;
59
+ await cmd('git', args, env, opts?.log);
60
+ }
61
+
62
+ static async addAll(directory: string, opts?: LogPassThrough): Promise<void> {
63
+ const args = ['add', '-A'];
64
+ const env = directory ? { cwd: directory } : undefined;
65
+ await cmd('git', args, env, opts?.log);
66
+ }
67
+
68
+ static async sync(directory: string, opts?: LogPassThrough): Promise<void> {
69
+ await GitUtil.pull(directory, opts);
70
+ await GitUtil.push(directory, opts);
71
+ }
72
+
73
+ /** Return the current branch name. */
74
+ static async currentBranch(directory: string, opts?: LogPassThrough): Promise<string> {
75
+ const args = ['rev-parse', '--abbrev-ref', 'HEAD'];
76
+ const env = directory ? { cwd: directory } : undefined;
77
+ const { stdout } = await cmd('git', args, env, opts?.log);
78
+ return String(stdout ?? '').trim();
79
+ }
80
+
81
+ /** Return the current HEAD SHA. */
82
+ static async headSha(directory: string, opts?: LogPassThrough): Promise<string> {
83
+ const args = ['rev-parse', 'HEAD'];
84
+ const env = directory ? { cwd: directory } : undefined;
85
+ const { stdout } = await cmd('git', args, env, opts?.log);
86
+ return String(stdout ?? '').trim();
87
+ }
88
+
89
+ /** Create and switch to a new branch. */
90
+ static async createBranch(directory: string, name: string, opts?: LogPassThrough): Promise<void> {
91
+ const args = ['checkout', '-b', name];
92
+ const env = directory ? { cwd: directory } : undefined;
93
+ await cmd('git', args, env, opts?.log);
74
94
  }
75
95
 
76
- static async addAll(directory: string): Promise<void> {
77
- const args = ['add', '.'];
78
- let envVars;
79
- if (directory) {
80
- envVars = { cwd: directory };
96
+ /** Checkout an existing branch. */
97
+ static async checkout(directory: string, name: string, opts?: LogPassThrough): Promise<void> {
98
+ const args = ['checkout', name];
99
+ const env = directory ? { cwd: directory } : undefined;
100
+ await cmd('git', args, env, opts?.log);
101
+ }
102
+
103
+ /** Return a binary-safe patch between two refs (from..to). Defaults to no logging. */
104
+ static async diffPatch(directory: string, fromRef: string, toRef: string, opts?: LogPassThrough): Promise<string> {
105
+ const args = ['diff', '--binary', `${fromRef}..${toRef}`];
106
+ const env = directory ? { cwd: directory } : undefined;
107
+ const log = opts?.log ?? DEFAULT_SILENT_LOG;
108
+ const { stdout } = await cmd('git', args, env, log);
109
+ return String(stdout ?? '');
110
+ }
111
+
112
+ /**
113
+ * Apply a patch to the working tree (stdin piped). Defaults to no logging.
114
+ * When `staged` is true, applies to the index only; otherwise as unstaged changes.
115
+ * When `reverse` is true, applies the patch in reverse.
116
+ */
117
+ static async applyPatch(
118
+ directory: string,
119
+ patch: string,
120
+ opts: { staged?: boolean; reverse?: boolean; log?: LogOptions } = {}
121
+ ): Promise<void> {
122
+ const args = ['apply', '--whitespace=nowarn'];
123
+ if (opts.reverse) {
124
+ args.push('--reverse');
125
+ }
126
+ if (opts.staged) {
127
+ args.push('--cached');
81
128
  }
82
- await cmd('git', args, envVars);
129
+ args.push('-'); // read patch from stdin
130
+ const env = directory ? { cwd: directory } : undefined;
131
+ const baseLog = opts.log ?? DEFAULT_SILENT_LOG;
132
+ await cmd('git', args, env, { ...baseLog, stdin: patch });
83
133
  }
84
134
 
85
- static async sync(directory: string): Promise<void> {
86
- await GitUtil.pull(directory);
87
- await GitUtil.push(directory);
135
+ static async hasStagedChanges(directory: string, opts?: LogPassThrough): Promise<boolean> {
136
+ // exit 0 => no staged changes; non-zero => there are staged changes
137
+ try {
138
+ await cmd(
139
+ 'git',
140
+ ['diff', '--cached', '--quiet'],
141
+ directory ? { cwd: directory } : {},
142
+ opts?.log ?? DEFAULT_SILENT_LOG
143
+ );
144
+ return false;
145
+ } catch {
146
+ return true;
147
+ }
88
148
  }
89
149
  }
90
150
 
151
+ /* ---------- exported function wrappers (unchanged public API) ---------- */
152
+
91
153
  export const cloneAppTemplatePackagesFunctionName = 'cloneAppTemplatePackages';
92
154
  export const cloneAppTemplatePackagesFunction = {
93
155
  definition: {
@@ -96,10 +158,7 @@ export const cloneAppTemplatePackagesFunction = {
96
158
  parameters: {
97
159
  type: 'object',
98
160
  properties: {
99
- directory: {
100
- type: 'string',
101
- description: 'The directory to clone the packages to',
102
- },
161
+ directory: { type: 'string', description: 'The directory to clone the packages to' },
103
162
  },
104
163
  required: ['directory'],
105
164
  },
@@ -115,10 +174,7 @@ export const initFunction = {
115
174
  parameters: {
116
175
  type: 'object',
117
176
  properties: {
118
- directory: {
119
- type: 'string',
120
- description: 'The directory to initialize the git repository in',
121
- },
177
+ directory: { type: 'string', description: 'The directory to initialize the git repository in' },
122
178
  },
123
179
  required: ['directory'],
124
180
  },
@@ -134,14 +190,8 @@ export const setRemoteFunction = {
134
190
  parameters: {
135
191
  type: 'object',
136
192
  properties: {
137
- directory: {
138
- type: 'string',
139
- description: 'The directory of the git repository',
140
- },
141
- remote: {
142
- type: 'string',
143
- description: 'The remote to set',
144
- },
193
+ directory: { type: 'string', description: 'The directory of the git repository' },
194
+ remote: { type: 'string', description: 'The remote to set' },
145
195
  },
146
196
  required: ['directory', 'remote'],
147
197
  },
@@ -158,14 +208,8 @@ export const addRemoteFunction = {
158
208
  parameters: {
159
209
  type: 'object',
160
210
  properties: {
161
- directory: {
162
- type: 'string',
163
- description: 'The directory of the git repository',
164
- },
165
- remote: {
166
- type: 'string',
167
- description: 'The remote to add',
168
- },
211
+ directory: { type: 'string', description: 'The directory of the git repository' },
212
+ remote: { type: 'string', description: 'The remote to add' },
169
213
  },
170
214
  required: ['directory', 'remote'],
171
215
  },
@@ -182,14 +226,8 @@ export const commitFunction = {
182
226
  parameters: {
183
227
  type: 'object',
184
228
  properties: {
185
- directory: {
186
- type: 'string',
187
- description: 'The directory of the git repository',
188
- },
189
- message: {
190
- type: 'string',
191
- description: 'The commit message',
192
- },
229
+ directory: { type: 'string', description: 'The directory of the git repository' },
230
+ message: { type: 'string', description: 'The commit message' },
193
231
  },
194
232
  required: ['directory', 'message'],
195
233
  },
@@ -206,10 +244,7 @@ export const pullFunction = {
206
244
  parameters: {
207
245
  type: 'object',
208
246
  properties: {
209
- directory: {
210
- type: 'string',
211
- description: 'The directory of the git repository',
212
- },
247
+ directory: { type: 'string', description: 'The directory of the git repository' },
213
248
  },
214
249
  required: ['directory'],
215
250
  },
@@ -225,10 +260,7 @@ export const pushFunction = {
225
260
  parameters: {
226
261
  type: 'object',
227
262
  properties: {
228
- directory: {
229
- type: 'string',
230
- description: 'The directory of the git repository',
231
- },
263
+ directory: { type: 'string', description: 'The directory of the git repository' },
232
264
  },
233
265
  required: ['directory'],
234
266
  },
@@ -244,10 +276,7 @@ export const statusFunction = {
244
276
  parameters: {
245
277
  type: 'object',
246
278
  properties: {
247
- directory: {
248
- type: 'string',
249
- description: 'The directory of the git repository',
250
- },
279
+ directory: { type: 'string', description: 'The directory of the git repository' },
251
280
  },
252
281
  required: ['directory'],
253
282
  },
@@ -263,10 +292,7 @@ export const addAllFunction = {
263
292
  parameters: {
264
293
  type: 'object',
265
294
  properties: {
266
- directory: {
267
- type: 'string',
268
- description: 'The directory of the git repository',
269
- },
295
+ directory: { type: 'string', description: 'The directory of the git repository' },
270
296
  },
271
297
  required: ['directory'],
272
298
  },
@@ -282,10 +308,7 @@ export const syncFunction = {
282
308
  parameters: {
283
309
  type: 'object',
284
310
  properties: {
285
- directory: {
286
- type: 'string',
287
- description: 'The directory of the git repository',
288
- },
311
+ directory: { type: 'string', description: 'The directory of the git repository' },
289
312
  },
290
313
  required: ['directory'],
291
314
  },
@@ -293,6 +316,115 @@ export const syncFunction = {
293
316
  call: async (params: { directory: string }) => await GitUtil.sync(params.directory),
294
317
  };
295
318
 
319
+ export const currentBranchFunctionName = 'gitCurrentBranch';
320
+ export const currentBranchFunction = {
321
+ definition: {
322
+ name: currentBranchFunctionName,
323
+ description: 'Get the current branch name',
324
+ parameters: {
325
+ type: 'object',
326
+ properties: {
327
+ directory: { type: 'string', description: 'Repository directory' },
328
+ },
329
+ required: ['directory'],
330
+ },
331
+ },
332
+ call: async (params: { directory: string }) => await GitUtil.currentBranch(params.directory),
333
+ };
334
+
335
+ export const headShaFunctionName = 'gitHeadSha';
336
+ export const headShaFunction = {
337
+ definition: {
338
+ name: headShaFunctionName,
339
+ description: 'Get the SHA of HEAD',
340
+ parameters: {
341
+ type: 'object',
342
+ properties: {
343
+ directory: { type: 'string', description: 'Repository directory' },
344
+ },
345
+ required: ['directory'],
346
+ },
347
+ },
348
+ call: async (params: { directory: string }) => await GitUtil.headSha(params.directory),
349
+ };
350
+
351
+ export const createBranchFunctionName = 'gitCreateBranch';
352
+ export const createBranchFunction = {
353
+ definition: {
354
+ name: createBranchFunctionName,
355
+ description: 'Create and switch to a new branch',
356
+ parameters: {
357
+ type: 'object',
358
+ properties: {
359
+ directory: { type: 'string', description: 'Repository directory' },
360
+ name: { type: 'string', description: 'Branch name' },
361
+ },
362
+ required: ['directory', 'name'],
363
+ },
364
+ },
365
+ call: async (params: { directory: string; name: string }) =>
366
+ await GitUtil.createBranch(params.directory, params.name),
367
+ };
368
+
369
+ export const checkoutFunctionName = 'gitCheckout';
370
+ export const checkoutFunction = {
371
+ definition: {
372
+ name: checkoutFunctionName,
373
+ description: 'Checkout an existing branch',
374
+ parameters: {
375
+ type: 'object',
376
+ properties: {
377
+ directory: { type: 'string', description: 'Repository directory' },
378
+ name: { type: 'string', description: 'Branch name' },
379
+ },
380
+ required: ['directory', 'name'],
381
+ },
382
+ },
383
+ call: async (params: { directory: string; name: string }) => await GitUtil.checkout(params.directory, params.name),
384
+ };
385
+
386
+ export const diffPatchFunctionName = 'gitDiffPatch';
387
+ export const diffPatchFunction = {
388
+ definition: {
389
+ name: diffPatchFunctionName,
390
+ description: 'Return a binary-safe patch between two refs (from..to)',
391
+ parameters: {
392
+ type: 'object',
393
+ properties: {
394
+ directory: { type: 'string', description: 'Repository directory' },
395
+ from: { type: 'string', description: 'From ref' },
396
+ to: { type: 'string', description: 'To ref' },
397
+ },
398
+ required: ['directory', 'from', 'to'],
399
+ },
400
+ },
401
+ call: async (params: { directory: string; from: string; to: string }) =>
402
+ await GitUtil.diffPatch(params.directory, params.from, params.to),
403
+ };
404
+
405
+ export const applyPatchFunctionName = 'gitApplyPatch';
406
+ export const applyPatchFunction = {
407
+ definition: {
408
+ name: applyPatchFunctionName,
409
+ description: 'Apply a patch to the working tree',
410
+ parameters: {
411
+ type: 'object',
412
+ properties: {
413
+ directory: { type: 'string', description: 'Repository directory' },
414
+ patch: { type: 'string', description: 'Patch content' },
415
+ reverse: { type: 'boolean', description: 'Apply in reverse', default: false },
416
+ staged: { type: 'boolean', description: 'Apply to index/staged only', default: false },
417
+ },
418
+ required: ['directory', 'patch'],
419
+ },
420
+ },
421
+ call: async (params: { directory: string; patch: string; reverse?: boolean; staged?: boolean }) =>
422
+ await GitUtil.applyPatch(params.directory, params.patch, {
423
+ reverse: !!params.reverse,
424
+ staged: !!params.staged,
425
+ }),
426
+ };
427
+
296
428
  export const gitFunctions = [
297
429
  cloneAppTemplatePackagesFunction,
298
430
  initFunction,
@@ -304,4 +436,10 @@ export const gitFunctions = [
304
436
  statusFunction,
305
437
  addAllFunction,
306
438
  syncFunction,
439
+ currentBranchFunction,
440
+ headShaFunction,
441
+ createBranchFunction,
442
+ checkoutFunction,
443
+ diffPatchFunction,
444
+ applyPatchFunction,
307
445
  ];
@@ -1,7 +1,10 @@
1
1
  import * as ChildProcess from 'child_process';
2
2
 
3
3
  export type LogOptions = {
4
+ /** Prefix each printed line with this string (cosmetic only). */
4
5
  logPrefix?: string;
6
+ /** Optional data to write to the child process stdin, then end() it. */
7
+ stdin?: string | Buffer;
5
8
  omitLogs?: {
6
9
  stdout?: {
7
10
  omit?: boolean;
@@ -16,9 +19,15 @@ export type LogOptions = {
16
19
  };
17
20
  };
18
21
 
22
+ export type CmdResult = {
23
+ code: number;
24
+ stdout: string;
25
+ stderr: string;
26
+ };
27
+
19
28
  export async function cmd(
20
29
  command: string,
21
- args?: readonly string[],
30
+ args: readonly string[] = [],
22
31
  options:
23
32
  | ChildProcess.SpawnOptionsWithoutStdio
24
33
  | ChildProcess.SpawnOptionsWithStdioTuple<
@@ -27,72 +36,88 @@ export async function cmd(
27
36
  ChildProcess.StdioPipe | ChildProcess.StdioNull
28
37
  > = {},
29
38
  logOptions?: LogOptions
30
- ) {
31
- const p = ChildProcess.spawn(
32
- command,
33
- args ? args : [],
34
- Object.assign(
35
- {
36
- cwd: process.cwd(),
37
- },
38
- options
39
- )
40
- );
41
- return new Promise((resolve, reject) => {
42
- p.stdout?.on('data', (x: any) => {
43
- if (
44
- logOptions?.omitLogs?.stdout?.omit ||
45
- (logOptions?.omitLogs?.stdout?.shouldOmit && logOptions.omitLogs.stdout.shouldOmit())
46
- ) {
47
- return;
48
- }
39
+ ): Promise<CmdResult> {
40
+ const proc = ChildProcess.spawn(command, [...args], {
41
+ cwd: process.cwd(),
42
+ ...options,
43
+ });
49
44
 
50
- const rawLog = x.toString();
51
- const filteredLog = logOptions?.omitLogs?.stdout?.filter ? logOptions.omitLogs.stdout.filter(rawLog) : rawLog;
52
- if (!filteredLog) {
53
- return;
54
- }
45
+ // Use Uint8Array[] to satisfy Buffer.concat's typings across Node versions.
46
+ const stdoutChunks: Uint8Array[] = [];
47
+ const stderrChunks: Uint8Array[] = [];
55
48
 
56
- process.stdout.write(prefixLog(filteredLog, logOptions?.logPrefix));
57
- });
58
- p.stderr?.on('data', (x) => {
59
- if (
60
- logOptions?.omitLogs?.stderr?.omit ||
61
- (logOptions?.omitLogs?.stderr?.shouldOmit && logOptions.omitLogs.stderr.shouldOmit())
62
- ) {
63
- return;
64
- }
49
+ const omitStdout = () =>
50
+ !!(
51
+ logOptions?.omitLogs?.stdout?.omit ||
52
+ (logOptions?.omitLogs?.stdout?.shouldOmit && logOptions.omitLogs.stdout.shouldOmit())
53
+ );
65
54
 
66
- const rawLog = x.toString();
67
- const filteredLog = logOptions?.omitLogs?.stderr?.filter ? logOptions.omitLogs.stderr.filter(rawLog) : rawLog;
68
- if (!filteredLog) {
69
- return;
70
- }
55
+ const omitStderr = () =>
56
+ !!(
57
+ logOptions?.omitLogs?.stderr?.omit ||
58
+ (logOptions?.omitLogs?.stderr?.shouldOmit && logOptions.omitLogs.stderr.shouldOmit())
59
+ );
71
60
 
72
- process.stderr.write(prefixLog(filteredLog, logOptions?.logPrefix));
73
- });
74
- p.on('error', (error) => {
75
- if (
76
- logOptions?.omitLogs?.stderr?.omit ||
77
- (logOptions?.omitLogs?.stderr?.shouldOmit && logOptions.omitLogs.stderr.shouldOmit())
78
- ) {
79
- return;
80
- }
61
+ // If caller provided stdin data, write it immediately then end().
62
+ if (logOptions?.stdin !== undefined && proc.stdin) {
63
+ proc.stdin.write(logOptions.stdin);
64
+ proc.stdin.end();
65
+ }
81
66
 
82
- const rawLog = error.toString();
83
- const filteredLog = logOptions?.omitLogs?.stderr?.filter ? logOptions.omitLogs.stderr.filter(rawLog) : rawLog;
84
- if (!filteredLog) {
85
- return;
86
- }
67
+ proc.stdout?.on('data', (chunk: Uint8Array) => {
68
+ stdoutChunks.push(chunk);
69
+ if (omitStdout()) {
70
+ return;
71
+ }
72
+ const raw = Buffer.from(chunk).toString();
73
+ const filtered = logOptions?.omitLogs?.stdout?.filter ? logOptions.omitLogs.stdout.filter(raw) : raw;
74
+ if (filtered) {
75
+ process.stdout.write(prefixLog(filtered, logOptions?.logPrefix));
76
+ }
77
+ });
87
78
 
88
- process.stderr.write(prefixLog(filteredLog, logOptions?.logPrefix));
79
+ proc.stderr?.on('data', (chunk: Uint8Array) => {
80
+ stderrChunks.push(chunk);
81
+ if (omitStderr()) {
82
+ return;
83
+ }
84
+ const raw = Buffer.from(chunk).toString();
85
+ const filtered = logOptions?.omitLogs?.stderr?.filter ? logOptions.omitLogs.stderr.filter(raw) : raw;
86
+ if (filtered) {
87
+ process.stderr.write(prefixLog(filtered, logOptions?.logPrefix));
88
+ }
89
+ });
90
+
91
+ return await new Promise<CmdResult>((resolve, reject) => {
92
+ proc.once('error', (err) => {
93
+ const stderr = Buffer.concat(stderrChunks as readonly Uint8Array[]).toString();
94
+ const stdout = Buffer.concat(stdoutChunks as readonly Uint8Array[]).toString();
95
+ const e = new Error(`spawn error for '${command} ${args.join(' ')}': ${String(err)}`) as Error & {
96
+ stdout?: string;
97
+ stderr?: string;
98
+ };
99
+ e.stdout = stdout;
100
+ e.stderr = stderr;
101
+ reject(e);
89
102
  });
90
- p.on('exit', (code) => {
91
- const logCode = `child process '${command} ${args ? args.join(' ') : ''}' exited with code: ${code}`;
92
- if (code === 0) {
93
- resolve(code);
103
+
104
+ // Use 'close' to ensure stdio is flushed
105
+ proc.once('close', (code, signal) => {
106
+ const stdout = Buffer.concat(stdoutChunks as readonly Uint8Array[]).toString();
107
+ const stderr = Buffer.concat(stderrChunks as readonly Uint8Array[]).toString();
108
+ const exitCode = typeof code === 'number' ? code : -1;
109
+
110
+ if (exitCode === 0) {
111
+ resolve({ code: exitCode, stdout, stderr });
94
112
  } else {
95
- reject(logCode);
113
+ const msg = signal
114
+ ? `process '${command} ${args.join(' ')}' terminated by signal: ${signal}`
115
+ : `process '${command} ${args.join(' ')}' exited with code: ${exitCode}`;
116
+ const err = new Error(msg) as Error & { code: number; stdout: string; stderr: string };
117
+ err.code = exitCode;
118
+ err.stdout = stdout;
119
+ err.stderr = stderr;
120
+ reject(err);
96
121
  }
97
122
  });
98
123
  });
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.