@hanseltime/template-repo-sync 2.2.1 → 2.4.0-alpha.0

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 (293) hide show
  1. package/CHANGELOG.md +43 -45
  2. package/dist/cjs/checkout-drivers/git-checkout.js +37 -0
  3. package/dist/cjs/checkout-drivers/git-checkout.spec.js +60 -0
  4. package/dist/cjs/checkout-drivers/index.js +21 -0
  5. package/dist/cjs/checkout-drivers/types.js +11 -0
  6. package/dist/cjs/clone-drivers/git-clone.js +25 -0
  7. package/dist/cjs/clone-drivers/index.js +21 -0
  8. package/dist/cjs/clone-drivers/types.js +8 -0
  9. package/dist/cjs/diff-drivers/git-diff.js +30 -0
  10. package/dist/cjs/diff-drivers/git-diff.spec.js +138 -0
  11. package/dist/cjs/diff-drivers/index.js +21 -0
  12. package/dist/cjs/diff-drivers/types.js +6 -0
  13. package/dist/cjs/formatting/index.js +21 -0
  14. package/dist/cjs/formatting/infer-json-indent.js +26 -0
  15. package/dist/cjs/formatting/infer-json-indent.spec.js +50 -0
  16. package/dist/cjs/formatting/sync-results-to-md.js +62 -0
  17. package/dist/cjs/formatting/sync-results-to-md.spec.js +45 -0
  18. package/dist/cjs/index.js +22 -0
  19. package/dist/cjs/load-plugin.js +44 -0
  20. package/dist/cjs/match.js +51 -0
  21. package/dist/cjs/match.spec.js +75 -0
  22. package/dist/cjs/merge-file.js +91 -0
  23. package/dist/cjs/merge-file.spec.js +508 -0
  24. package/dist/cjs/plugins/index.js +20 -0
  25. package/dist/cjs/plugins/json-merge.js +228 -0
  26. package/dist/cjs/plugins/json-merge.spec.js +514 -0
  27. package/dist/cjs/ref-drivers/git-current-ref.js +18 -0
  28. package/dist/cjs/ref-drivers/git-current-ref.spec.js +15 -0
  29. package/dist/cjs/ref-drivers/index.js +20 -0
  30. package/dist/cjs/ref-drivers/types.js +11 -0
  31. package/dist/cjs/template-sync.js +236 -0
  32. package/dist/cjs/template-sync.spec.js +521 -0
  33. package/dist/cjs/test-utils/index.js +26 -0
  34. package/dist/cjs/types.js +12 -0
  35. package/dist/esm/checkout-drivers/git-checkout.mjs +27 -0
  36. package/dist/esm/checkout-drivers/git-checkout.spec.mjs +56 -0
  37. package/dist/esm/checkout-drivers/index.mjs +4 -0
  38. package/dist/esm/checkout-drivers/types.mjs +8 -0
  39. package/dist/esm/clone-drivers/git-clone.mjs +15 -0
  40. package/dist/esm/clone-drivers/index.mjs +4 -0
  41. package/dist/esm/clone-drivers/types.mjs +8 -0
  42. package/dist/esm/diff-drivers/git-diff.mjs +26 -0
  43. package/dist/esm/diff-drivers/git-diff.spec.mjs +93 -0
  44. package/dist/esm/diff-drivers/index.mjs +4 -0
  45. package/dist/esm/diff-drivers/types.mjs +6 -0
  46. package/dist/esm/formatting/index.mjs +4 -0
  47. package/dist/esm/formatting/infer-json-indent.mjs +16 -0
  48. package/dist/esm/formatting/infer-json-indent.spec.mjs +46 -0
  49. package/dist/esm/formatting/sync-results-to-md.mjs +52 -0
  50. package/dist/esm/formatting/sync-results-to-md.spec.mjs +41 -0
  51. package/dist/esm/index.mjs +5 -0
  52. package/dist/esm/load-plugin.mjs +40 -0
  53. package/dist/esm/match.mjs +40 -0
  54. package/dist/esm/match.spec.mjs +71 -0
  55. package/dist/esm/merge-file.mjs +88 -0
  56. package/dist/esm/merge-file.spec.mjs +504 -0
  57. package/dist/esm/plugins/index.mjs +10 -0
  58. package/dist/esm/plugins/json-merge.mjs +164 -0
  59. package/dist/esm/plugins/json-merge.spec.mjs +469 -0
  60. package/dist/esm/ref-drivers/git-current-ref.mjs +8 -0
  61. package/dist/esm/ref-drivers/git-current-ref.spec.mjs +11 -0
  62. package/dist/esm/ref-drivers/index.mjs +3 -0
  63. package/dist/esm/ref-drivers/types.mjs +8 -0
  64. package/dist/esm/template-sync.mjs +174 -0
  65. package/dist/esm/template-sync.spec.mjs +517 -0
  66. package/dist/esm/test-utils/index.mjs +10 -0
  67. package/dist/esm/types.mjs +9 -0
  68. package/{lib/cjs → dist/types}/checkout-drivers/git-checkout.d.ts +1 -0
  69. package/dist/types/checkout-drivers/git-checkout.d.ts.map +1 -0
  70. package/dist/types/checkout-drivers/git-checkout.spec.d.ts +2 -0
  71. package/dist/types/checkout-drivers/git-checkout.spec.d.ts.map +1 -0
  72. package/{lib/cjs → dist/types}/checkout-drivers/index.d.ts +1 -0
  73. package/dist/types/checkout-drivers/index.d.ts.map +1 -0
  74. package/{lib/cjs → dist/types}/checkout-drivers/types.d.ts +1 -0
  75. package/dist/types/checkout-drivers/types.d.ts.map +1 -0
  76. package/{lib/cjs → dist/types}/clone-drivers/git-clone.d.ts +2 -1
  77. package/dist/types/clone-drivers/git-clone.d.ts.map +1 -0
  78. package/{lib/cjs → dist/types}/clone-drivers/index.d.ts +2 -1
  79. package/dist/types/clone-drivers/index.d.ts.map +1 -0
  80. package/{lib/cjs → dist/types}/clone-drivers/types.d.ts +1 -0
  81. package/dist/types/clone-drivers/types.d.ts.map +1 -0
  82. package/{lib/cjs → dist/types}/diff-drivers/git-diff.d.ts +1 -0
  83. package/dist/types/diff-drivers/git-diff.d.ts.map +1 -0
  84. package/dist/types/diff-drivers/git-diff.spec.d.ts +2 -0
  85. package/dist/types/diff-drivers/git-diff.spec.d.ts.map +1 -0
  86. package/{lib/cjs → dist/types}/diff-drivers/index.d.ts +2 -1
  87. package/dist/types/diff-drivers/index.d.ts.map +1 -0
  88. package/{lib/cjs → dist/types}/diff-drivers/types.d.ts +1 -0
  89. package/dist/types/diff-drivers/types.d.ts.map +1 -0
  90. package/{lib/cjs → dist/types}/formatting/index.d.ts +2 -1
  91. package/dist/types/formatting/index.d.ts.map +1 -0
  92. package/{lib/cjs → dist/types}/formatting/infer-json-indent.d.ts +1 -0
  93. package/dist/types/formatting/infer-json-indent.d.ts.map +1 -0
  94. package/dist/types/formatting/infer-json-indent.spec.d.ts +2 -0
  95. package/dist/types/formatting/infer-json-indent.spec.d.ts.map +1 -0
  96. package/dist/types/formatting/sync-results-to-md.d.ts +3 -0
  97. package/dist/types/formatting/sync-results-to-md.d.ts.map +1 -0
  98. package/dist/types/formatting/sync-results-to-md.spec.d.ts +2 -0
  99. package/dist/types/formatting/sync-results-to-md.spec.d.ts.map +1 -0
  100. package/{lib/cjs → dist/types}/index.d.ts +3 -2
  101. package/dist/types/index.d.ts.map +1 -0
  102. package/{lib/cjs → dist/types}/load-plugin.d.ts +2 -1
  103. package/dist/types/load-plugin.d.ts.map +1 -0
  104. package/{lib/cjs → dist/types}/match.d.ts +1 -0
  105. package/dist/types/match.d.ts.map +1 -0
  106. package/dist/types/match.spec.d.ts +2 -0
  107. package/dist/types/match.spec.d.ts.map +1 -0
  108. package/{lib/cjs → dist/types}/merge-file.d.ts +3 -2
  109. package/dist/types/merge-file.d.ts.map +1 -0
  110. package/dist/types/merge-file.spec.d.ts +2 -0
  111. package/dist/types/merge-file.spec.d.ts.map +1 -0
  112. package/{lib/cjs → dist/types}/plugins/index.d.ts +2 -1
  113. package/dist/types/plugins/index.d.ts.map +1 -0
  114. package/{lib/cjs → dist/types}/plugins/json-merge.d.ts +2 -1
  115. package/dist/types/plugins/json-merge.d.ts.map +1 -0
  116. package/dist/types/plugins/json-merge.spec.d.ts +2 -0
  117. package/dist/types/plugins/json-merge.spec.d.ts.map +1 -0
  118. package/{lib/cjs → dist/types}/ref-drivers/git-current-ref.d.ts +1 -0
  119. package/dist/types/ref-drivers/git-current-ref.d.ts.map +1 -0
  120. package/dist/types/ref-drivers/git-current-ref.spec.d.ts +2 -0
  121. package/dist/types/ref-drivers/git-current-ref.spec.d.ts.map +1 -0
  122. package/{lib/cjs → dist/types}/ref-drivers/index.d.ts +1 -0
  123. package/dist/types/ref-drivers/index.d.ts.map +1 -0
  124. package/{lib/cjs → dist/types}/ref-drivers/types.d.ts +1 -0
  125. package/dist/types/ref-drivers/types.d.ts.map +1 -0
  126. package/{lib/cjs → dist/types}/template-sync.d.ts +6 -5
  127. package/dist/types/template-sync.d.ts.map +1 -0
  128. package/dist/types/template-sync.spec.d.ts +2 -0
  129. package/dist/types/template-sync.spec.d.ts.map +1 -0
  130. package/{lib/cjs → dist/types}/test-utils/index.d.ts +1 -0
  131. package/dist/types/test-utils/index.d.ts.map +1 -0
  132. package/{lib/cjs → dist/types}/types.d.ts +1 -0
  133. package/dist/types/types.d.ts.map +1 -0
  134. package/package.json +26 -23
  135. package/.eslintrc.js +0 -10
  136. package/.github/CODEOWNERS +0 -6
  137. package/.github/workflows/pr-checks.yaml +0 -12
  138. package/.github/workflows/release.yaml +0 -47
  139. package/.github/workflows/test-flow.yaml +0 -63
  140. package/.husky/commit-msg +0 -4
  141. package/.prettierignore +0 -1
  142. package/.prettierrc +0 -1
  143. package/action.yml +0 -13
  144. package/commitlint.config.js +0 -3
  145. package/docs/merge-plugins/CURRENT_PLUGINS.md +0 -168
  146. package/docs/merge-plugins/PLUGIN_DEVELOPMENT.md +0 -122
  147. package/docs/merge-plugins/README.md +0 -75
  148. package/jest.config.js +0 -19
  149. package/lib/cjs/checkout-drivers/git-checkout.js +0 -29
  150. package/lib/cjs/checkout-drivers/index.js +0 -18
  151. package/lib/cjs/checkout-drivers/types.js +0 -2
  152. package/lib/cjs/clone-drivers/git-clone.js +0 -17
  153. package/lib/cjs/clone-drivers/index.js +0 -18
  154. package/lib/cjs/clone-drivers/types.js +0 -2
  155. package/lib/cjs/diff-drivers/git-diff.js +0 -41
  156. package/lib/cjs/diff-drivers/index.js +0 -18
  157. package/lib/cjs/diff-drivers/types.js +0 -2
  158. package/lib/cjs/formatting/index.js +0 -18
  159. package/lib/cjs/formatting/infer-json-indent.js +0 -18
  160. package/lib/cjs/formatting/sync-results-to-md.d.ts +0 -2
  161. package/lib/cjs/formatting/sync-results-to-md.js +0 -57
  162. package/lib/cjs/index.js +0 -19
  163. package/lib/cjs/load-plugin.js +0 -69
  164. package/lib/cjs/match.js +0 -45
  165. package/lib/cjs/merge-file.js +0 -98
  166. package/lib/cjs/plugins/index.js +0 -11
  167. package/lib/cjs/plugins/json-merge.js +0 -208
  168. package/lib/cjs/ref-drivers/git-current-ref.js +0 -12
  169. package/lib/cjs/ref-drivers/index.js +0 -17
  170. package/lib/cjs/ref-drivers/types.js +0 -2
  171. package/lib/cjs/template-sync.js +0 -163
  172. package/lib/cjs/test-utils/index.js +0 -10
  173. package/lib/cjs/types.js +0 -2
  174. package/lib/esm/checkout-drivers/git-checkout.js +0 -29
  175. package/lib/esm/checkout-drivers/index.js +0 -18
  176. package/lib/esm/checkout-drivers/types.js +0 -2
  177. package/lib/esm/clone-drivers/git-clone.js +0 -17
  178. package/lib/esm/clone-drivers/index.js +0 -18
  179. package/lib/esm/clone-drivers/types.js +0 -2
  180. package/lib/esm/diff-drivers/git-diff.js +0 -41
  181. package/lib/esm/diff-drivers/index.js +0 -18
  182. package/lib/esm/diff-drivers/types.js +0 -2
  183. package/lib/esm/formatting/index.js +0 -18
  184. package/lib/esm/formatting/infer-json-indent.js +0 -18
  185. package/lib/esm/formatting/sync-results-to-md.js +0 -57
  186. package/lib/esm/index.js +0 -19
  187. package/lib/esm/load-plugin.js +0 -46
  188. package/lib/esm/match.js +0 -45
  189. package/lib/esm/merge-file.js +0 -98
  190. package/lib/esm/plugins/index.js +0 -11
  191. package/lib/esm/plugins/json-merge.js +0 -208
  192. package/lib/esm/ref-drivers/git-current-ref.js +0 -12
  193. package/lib/esm/ref-drivers/index.js +0 -17
  194. package/lib/esm/ref-drivers/types.js +0 -2
  195. package/lib/esm/template-sync.js +0 -163
  196. package/lib/esm/test-utils/index.js +0 -10
  197. package/lib/esm/types.js +0 -2
  198. package/release.config.js +0 -40
  199. package/src/checkout-drivers/git-checkout.spec.ts +0 -69
  200. package/src/checkout-drivers/git-checkout.ts +0 -38
  201. package/src/checkout-drivers/index.ts +0 -2
  202. package/src/checkout-drivers/types.ts +0 -14
  203. package/src/clone-drivers/git-clone.ts +0 -20
  204. package/src/clone-drivers/index.ts +0 -2
  205. package/src/clone-drivers/types.ts +0 -20
  206. package/src/diff-drivers/git-diff.spec.ts +0 -73
  207. package/src/diff-drivers/git-diff.ts +0 -39
  208. package/src/diff-drivers/index.ts +0 -2
  209. package/src/diff-drivers/types.ts +0 -14
  210. package/src/formatting/__snapshots__/sync-results-to-md.spec.ts.snap +0 -39
  211. package/src/formatting/index.ts +0 -2
  212. package/src/formatting/infer-json-indent.spec.ts +0 -49
  213. package/src/formatting/infer-json-indent.ts +0 -16
  214. package/src/formatting/sync-results-to-md.spec.ts +0 -31
  215. package/src/formatting/sync-results-to-md.ts +0 -63
  216. package/src/index.ts +0 -3
  217. package/src/load-plugin.ts +0 -51
  218. package/src/match.spec.ts +0 -68
  219. package/src/match.ts +0 -52
  220. package/src/merge-file.spec.ts +0 -506
  221. package/src/merge-file.ts +0 -154
  222. package/src/plugins/index.ts +0 -12
  223. package/src/plugins/json-merge.spec.ts +0 -436
  224. package/src/plugins/json-merge.ts +0 -215
  225. package/src/ref-drivers/git-current-ref.spec.ts +0 -12
  226. package/src/ref-drivers/git-current-ref.ts +0 -9
  227. package/src/ref-drivers/index.ts +0 -1
  228. package/src/ref-drivers/types.ts +0 -10
  229. package/src/template-sync.spec.ts +0 -509
  230. package/src/template-sync.ts +0 -256
  231. package/src/test-utils/index.ts +0 -13
  232. package/src/types.ts +0 -129
  233. package/templatesync.local.json +0 -15
  234. package/test-fixtures/downstream/README.md +0 -3
  235. package/test-fixtures/downstream/package.json +0 -18
  236. package/test-fixtures/downstream/plugins/custom-plugin.js +0 -11
  237. package/test-fixtures/downstream/src/index.js +0 -2
  238. package/test-fixtures/downstream/src/index.ts +0 -1
  239. package/test-fixtures/downstream/src/templated.js +0 -2
  240. package/test-fixtures/downstream/src/templated.ts +0 -1
  241. package/test-fixtures/downstream/templatesync.json +0 -16
  242. package/test-fixtures/downstream/templatesync.local.json +0 -10
  243. package/test-fixtures/dummy-plugin.js +0 -8
  244. package/test-fixtures/glob-test/folder1/something.js +0 -1
  245. package/test-fixtures/glob-test/folder1/something.ts +0 -0
  246. package/test-fixtures/glob-test/toplevel.js +0 -0
  247. package/test-fixtures/glob-test/toplevel.txt +0 -0
  248. package/test-fixtures/template/custom-bin/something.txt +0 -1
  249. package/test-fixtures/template/package.json +0 -17
  250. package/test-fixtures/template/src/index.js +0 -2
  251. package/test-fixtures/template/src/index.ts +0 -1
  252. package/test-fixtures/template/src/templated.js +0 -2
  253. package/test-fixtures/template/src/templated.ts +0 -1
  254. package/test-fixtures/template/templatesync.json +0 -16
  255. package/test-fixtures/testGitRepo/README.md +0 -17
  256. package/test-fixtures/testGitRepo/gitDir/COMMIT_EDITMSG +0 -14
  257. package/test-fixtures/testGitRepo/gitDir/HEAD +0 -1
  258. package/test-fixtures/testGitRepo/gitDir/config +0 -7
  259. package/test-fixtures/testGitRepo/gitDir/description +0 -1
  260. package/test-fixtures/testGitRepo/gitDir/hooks/applypatch-msg.sample +0 -15
  261. package/test-fixtures/testGitRepo/gitDir/hooks/commit-msg.sample +0 -24
  262. package/test-fixtures/testGitRepo/gitDir/hooks/fsmonitor-watchman.sample +0 -174
  263. package/test-fixtures/testGitRepo/gitDir/hooks/post-update.sample +0 -8
  264. package/test-fixtures/testGitRepo/gitDir/hooks/pre-applypatch.sample +0 -14
  265. package/test-fixtures/testGitRepo/gitDir/hooks/pre-commit.sample +0 -49
  266. package/test-fixtures/testGitRepo/gitDir/hooks/pre-merge-commit.sample +0 -13
  267. package/test-fixtures/testGitRepo/gitDir/hooks/pre-push.sample +0 -53
  268. package/test-fixtures/testGitRepo/gitDir/hooks/pre-rebase.sample +0 -169
  269. package/test-fixtures/testGitRepo/gitDir/hooks/pre-receive.sample +0 -24
  270. package/test-fixtures/testGitRepo/gitDir/hooks/prepare-commit-msg.sample +0 -42
  271. package/test-fixtures/testGitRepo/gitDir/hooks/push-to-checkout.sample +0 -78
  272. package/test-fixtures/testGitRepo/gitDir/hooks/sendemail-validate.sample +0 -77
  273. package/test-fixtures/testGitRepo/gitDir/hooks/update.sample +0 -128
  274. package/test-fixtures/testGitRepo/gitDir/index +0 -0
  275. package/test-fixtures/testGitRepo/gitDir/info/exclude +0 -6
  276. package/test-fixtures/testGitRepo/gitDir/logs/HEAD +0 -5
  277. package/test-fixtures/testGitRepo/gitDir/logs/refs/heads/master +0 -2
  278. package/test-fixtures/testGitRepo/gitDir/logs/refs/heads/test-branch +0 -2
  279. package/test-fixtures/testGitRepo/gitDir/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  280. package/test-fixtures/testGitRepo/gitDir/objects/6e/187bee8d02f39d0a1be8331dd8fe6a00c9b613 +0 -0
  281. package/test-fixtures/testGitRepo/gitDir/objects/73/185f1f3f5a6345e087d9f46dc4af77cc59449f +0 -2
  282. package/test-fixtures/testGitRepo/gitDir/objects/90/e7ea1089f939840e9649fd617584c1ad117159 +0 -3
  283. package/test-fixtures/testGitRepo/gitDir/objects/ba/99a452b9097047e9bfa8d5a08b3e452fcb364a +0 -0
  284. package/test-fixtures/testGitRepo/gitDir/objects/c5/8d400177cd5180b8566f82a127fafc5bf394b7 +0 -0
  285. package/test-fixtures/testGitRepo/gitDir/objects/e2/e668265db019249a7e8296d85f79000e3d71cf +0 -0
  286. package/test-fixtures/testGitRepo/gitDir/objects/e4/243e430c1ab69f3e344249f5b1859e90abc883 +0 -1
  287. package/test-fixtures/testGitRepo/gitDir/objects/ec/6c1cb72312605282ac61858cf1eaf1ea9f1d02 +0 -0
  288. package/test-fixtures/testGitRepo/gitDir/objects/fc/89cecc4ac0b5b075bd7d0ce9e09b2f50598b82 +0 -0
  289. package/test-fixtures/testGitRepo/gitDir/refs/heads/master +0 -1
  290. package/test-fixtures/testGitRepo/gitDir/refs/heads/test-branch +0 -1
  291. package/tsconfig.cjs.json +0 -12
  292. package/tsconfig.esm.json +0 -10
  293. package/tsconfig.json +0 -22
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./git-current-ref"), exports);
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,163 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.templateSync = exports.TEMPLATE_SYNC_LOCAL_CONFIG = exports.TEMPLATE_SYNC_CONFIG = void 0;
27
- const path_1 = require("path");
28
- const fs_1 = require("fs");
29
- const match_1 = require("./match");
30
- const merge_file_1 = require("./merge-file");
31
- const git_clone_1 = require("./clone-drivers/git-clone");
32
- const diff_drivers_1 = require("./diff-drivers");
33
- const ref_drivers_1 = require("./ref-drivers");
34
- const formatting_1 = require("./formatting");
35
- const commentJSON = __importStar(require("comment-json"));
36
- const checkout_drivers_1 = require("./checkout-drivers");
37
- const micromatch_1 = require("micromatch");
38
- exports.TEMPLATE_SYNC_CONFIG = "templatesync";
39
- exports.TEMPLATE_SYNC_LOCAL_CONFIG = "templatesync.local";
40
- async function templateSync(options) {
41
- const cloneDriver = options.cloneDriver ?? git_clone_1.gitClone;
42
- const diffDriver = options.diffDriver ?? diff_drivers_1.gitDiff;
43
- const currentRefDriver = options.currentRefDriver ?? ref_drivers_1.gitCurrentRef;
44
- const checkoutDriver = options.checkoutDriver ?? checkout_drivers_1.gitCheckout;
45
- const cloneReturn = await cloneDriver(options.tmpCloneDir, options.repoUrl);
46
- const { dir: tempCloneDir, remoteName } = typeof cloneReturn === "string"
47
- ? {
48
- dir: cloneReturn,
49
- remoteName: "origin", // Default to this
50
- }
51
- : cloneReturn;
52
- if (options.branch) {
53
- await checkoutDriver({
54
- tmpDir: tempCloneDir,
55
- remoteName,
56
- branch: options.branch,
57
- });
58
- }
59
- // Get the clone Config
60
- const cloneConfigPath = (0, path_1.join)(tempCloneDir, `${exports.TEMPLATE_SYNC_CONFIG}.json`);
61
- const templateSyncConfig = (0, fs_1.existsSync)(cloneConfigPath)
62
- ? commentJSON.parse((0, fs_1.readFileSync)(cloneConfigPath).toString())
63
- : { ignore: [] };
64
- const localConfigFile = `${exports.TEMPLATE_SYNC_LOCAL_CONFIG}.json`;
65
- const localConfigPath = (0, path_1.join)(options.repoDir, localConfigFile);
66
- const localTemplateSyncConfig = (0, fs_1.existsSync)(localConfigPath)
67
- ? commentJSON.parse((0, fs_1.readFileSync)(localConfigPath).toString())
68
- : { ignore: [] };
69
- let filesToSync;
70
- const ref = await currentRefDriver({
71
- rootDir: tempCloneDir,
72
- });
73
- if (localTemplateSyncConfig.afterRef) {
74
- if (ref === localTemplateSyncConfig.afterRef) {
75
- // short circuit if the refs match
76
- return {
77
- localSkipFiles: [],
78
- localFileChanges: {},
79
- modifiedFiles: {
80
- added: [],
81
- modified: [],
82
- deleted: [],
83
- total: 0,
84
- },
85
- };
86
- }
87
- filesToSync = await diffDriver(tempCloneDir, localTemplateSyncConfig.afterRef);
88
- }
89
- else {
90
- filesToSync = {
91
- added: (0, match_1.getAllFilesInDir)(tempCloneDir, [
92
- ...templateSyncConfig.ignore,
93
- ".git/**",
94
- ]),
95
- deleted: [],
96
- modified: [],
97
- };
98
- }
99
- // Apply ignore filters
100
- filesToSync.added = filesToSync.added.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
101
- filesToSync.modified = filesToSync.modified.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
102
- filesToSync.deleted = filesToSync.deleted.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
103
- const localSkipFiles = new Set();
104
- const localFileChanges = {};
105
- const fileSyncFactory = (op) => {
106
- return async (f) => {
107
- const result = await (0, merge_file_1.mergeFile)(f, {
108
- localTemplateSyncConfig,
109
- templateSyncConfig,
110
- tempCloneDir,
111
- cwd: options.repoDir,
112
- fileOperation: op,
113
- });
114
- if (result.ignoredDueToLocal) {
115
- localSkipFiles.add(f);
116
- }
117
- else if (result?.localChanges && result.localChanges.length > 0) {
118
- localFileChanges[f] = result.localChanges;
119
- }
120
- };
121
- };
122
- // Added and modified have the same setup for now
123
- await Promise.all(filesToSync.added.map(fileSyncFactory("added")));
124
- await Promise.all(filesToSync.modified.map(fileSyncFactory("modified")));
125
- await Promise.all(filesToSync.deleted.map(fileSyncFactory("deleted")));
126
- // Report the files that changed in general
127
- const actualAdded = filesToSync.added.filter((f) => !localSkipFiles.has(f));
128
- const actualModified = filesToSync.modified.filter((f) => !localSkipFiles.has(f));
129
- const actualDeleted = filesToSync.deleted.filter((f) => !localSkipFiles.has(f));
130
- const modifiedFiles = {
131
- added: actualAdded,
132
- modified: actualModified,
133
- deleted: actualDeleted,
134
- };
135
- // apply after ref
136
- if (options.updateAfterRef) {
137
- const ref = await currentRefDriver({
138
- rootDir: tempCloneDir,
139
- });
140
- if ((0, fs_1.existsSync)(localConfigPath)) {
141
- const configStr = (0, fs_1.readFileSync)(localConfigPath).toString();
142
- const config = commentJSON.parse(configStr);
143
- config.afterRef = ref;
144
- (0, fs_1.writeFileSync)(localConfigPath, commentJSON.stringify(config, null, (0, formatting_1.inferJSONIndent)(configStr)));
145
- modifiedFiles.modified.push(localConfigFile);
146
- }
147
- else {
148
- (0, fs_1.writeFileSync)(localConfigPath, commentJSON.stringify({ afterRef: ref }, null, 4));
149
- modifiedFiles.added.push(localConfigFile);
150
- }
151
- }
152
- return {
153
- localSkipFiles: Array.from(localSkipFiles),
154
- localFileChanges,
155
- modifiedFiles: {
156
- ...modifiedFiles,
157
- total: modifiedFiles.added.length +
158
- modifiedFiles.deleted.length +
159
- modifiedFiles.modified.length,
160
- },
161
- };
162
- }
163
- exports.templateSync = templateSync;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tempDir = exports.TEST_FIXTURES_DIR = void 0;
4
- const path_1 = require("path");
5
- const os_1 = require("os");
6
- exports.TEST_FIXTURES_DIR = (0, path_1.resolve)(__dirname, "..", "..", "test-fixtures");
7
- function tempDir() {
8
- return process.env.RUNNER_TEMP ?? (0, os_1.tmpdir)();
9
- }
10
- exports.tempDir = tempDir;
package/lib/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/release.config.js DELETED
@@ -1,40 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const { readFileSync } = require("fs");
3
- const { join } = require("path");
4
-
5
- const packageJson = JSON.parse(
6
- readFileSync(join(__dirname, "package.json")).toString(),
7
- );
8
-
9
- // Abbreviate for Git Commit readability
10
- const fullName = packageJson.name;
11
- const scopeLimiterIdx = fullName.lastIndexOf("/");
12
- const abbreviatedName = fullName.substring(
13
- scopeLimiterIdx >= 0 ? scopeLimiterIdx + 1 : 0,
14
- );
15
-
16
- module.exports = {
17
- branches: ["main", { name: "alpha", prerelease: true }],
18
- plugins: [
19
- "@semantic-release/commit-analyzer",
20
- "@semantic-release/release-notes-generator",
21
- "@semantic-release/changelog",
22
- [
23
- "@semantic-release/npm",
24
- {
25
- npmPublish: false, // We just use this to increment the versions since semantic-release doesn't handle OIDC well
26
- // Call the publish comand in the CI/CD
27
- },
28
- ],
29
- [
30
- "@semantic-release/git",
31
- {
32
- assets: ["CHANGELOG.md", "package.json"],
33
- message: `docs(release): ${abbreviatedName} $\{nextRelease.version} [skip ci]\n\n$\{nextRelease.notes}`,
34
- },
35
- ],
36
- // This creates a release on github - you can decide if you want to mirror the files in package.json
37
- "@semantic-release/github",
38
- ],
39
- ci: true,
40
- };
@@ -1,69 +0,0 @@
1
- import { join, resolve } from "path";
2
- import { TEST_FIXTURES_DIR, tempDir } from "../test-utils";
3
- import { copy, mkdtemp, moveSync } from "fs-extra";
4
- import { execSync } from "child_process";
5
- import { gitCheckout } from "./git-checkout";
6
- import { readFileSync } from "fs";
7
-
8
- const gitRemoteDir = resolve(TEST_FIXTURES_DIR, "testGitRepo");
9
-
10
- describe("gitCheckout", () => {
11
- let tmpRemoteDir: string;
12
- let tmpRepoDir: string;
13
- beforeEach(async () => {
14
- const baseTmpDir = await mkdtemp(tempDir());
15
- // Make the remote dir
16
- tmpRemoteDir = join(baseTmpDir, "remote");
17
- await copy(gitRemoteDir, tmpRemoteDir);
18
- // rehydrate the git repo
19
- moveSync(join(tmpRemoteDir, "gitDir"), join(tmpRemoteDir, ".git"));
20
-
21
- // Perform the clone we expect
22
- execSync(`git clone ${tmpRemoteDir} testGitRepo`, {
23
- cwd: baseTmpDir,
24
- });
25
- tmpRepoDir = join(baseTmpDir, "testGitRepo");
26
- });
27
- it("checks out the appropriate branch", async () => {
28
- await gitCheckout({
29
- tmpDir: tmpRepoDir,
30
- remoteName: "origin",
31
- branch: "test-branch", // We set this in the gitDir
32
- });
33
-
34
- expect(readFileSync(join(tmpRepoDir, "README.md")).toString()).toContain(
35
- "# This is the test-branch",
36
- );
37
- });
38
- it("throws an error if the branch is not found", async () => {
39
- await expect(
40
- async () =>
41
- await gitCheckout({
42
- tmpDir: tmpRepoDir,
43
- remoteName: "origin",
44
- branch: "test-branch-not-there", // This is not set in gitDir
45
- }),
46
- ).rejects.toThrow();
47
- });
48
- it("throws an error if the origin is not found", async () => {
49
- await expect(
50
- async () =>
51
- await gitCheckout({
52
- tmpDir: tmpRepoDir,
53
- remoteName: "originNA",
54
- branch: "test-branch", // This is not set in gitDir
55
- }),
56
- ).rejects.toThrow();
57
- });
58
- it("does not throw if the branch was the default", async () => {
59
- await gitCheckout({
60
- tmpDir: tmpRepoDir,
61
- remoteName: "origin",
62
- branch: "master", // We set this in the gitDir
63
- });
64
-
65
- expect(readFileSync(join(tmpRepoDir, "README.md")).toString()).toContain(
66
- "# This is the master branch",
67
- );
68
- });
69
- });
@@ -1,38 +0,0 @@
1
- import { execSync } from "child_process";
2
-
3
- export async function gitCheckout(options: {
4
- /** The directory where we cloned to */
5
- tmpDir: string;
6
- /** The name of the remote that git checks out against */
7
- remoteName: string;
8
- /** The branch to checkout against */
9
- branch: string;
10
- }): Promise<boolean> {
11
- const { branch, remoteName, tmpDir } = options;
12
-
13
- const remoteInfo = execSync(`git remote show ${remoteName}`, {
14
- cwd: tmpDir,
15
- env: process.env,
16
- }).toString();
17
- const defaultMatch = /HEAD branch:\s*([a-zA-Z0-9_-]+)/.exec(remoteInfo);
18
- if (!defaultMatch || !defaultMatch[1]) {
19
- throw new Error(
20
- `Could not determine default branch of cloned repo.\nAttempted to find in remote info:\n${remoteInfo} `,
21
- );
22
- }
23
-
24
- const defaultBranch = defaultMatch[1];
25
- // Skip this if the default branch is already pulled
26
- if (defaultBranch !== branch) {
27
- execSync(`git fetch ${remoteName} ${branch}`, {
28
- cwd: tmpDir,
29
- env: process.env,
30
- });
31
- execSync(`git checkout -b ${branch} --track ${remoteName}/${branch}`, {
32
- cwd: tmpDir,
33
- env: process.env,
34
- });
35
- }
36
-
37
- return true;
38
- }
@@ -1,2 +0,0 @@
1
- export * from "./git-checkout";
2
- export * from "./types";
@@ -1,14 +0,0 @@
1
- /**
2
- * A function that will checkout a given "branch" after the repo has been
3
- * "cloned" by a clone drvier.
4
- *
5
- * @returns true if the checkout succeeded
6
- */
7
- export type TemplateCheckoutDriverFn = (options: {
8
- /** The directory where we cloned to */
9
- tmpDir: string;
10
- /** The name of the remote that git checks out against */
11
- remoteName: string;
12
- /** The branch to checkout against */
13
- branch: string;
14
- }) => Promise<boolean>;
@@ -1,20 +0,0 @@
1
- import { execSync } from "child_process";
2
- import { resolve } from "path";
3
- import { CloneReturn } from "./types";
4
-
5
- const CLONE_DIR = "cloned_repo";
6
-
7
- export async function gitClone(
8
- tmpDir: string,
9
- repoUrl: string,
10
- ): Promise<CloneReturn> {
11
- execSync(`git clone ${repoUrl} ${CLONE_DIR}`, {
12
- cwd: tmpDir,
13
- env: process.env,
14
- });
15
-
16
- return {
17
- dir: resolve(tmpDir, CLONE_DIR),
18
- remoteName: "origin",
19
- };
20
- }
@@ -1,2 +0,0 @@
1
- export * from "./types";
2
- export * from "./git-clone";
@@ -1,20 +0,0 @@
1
- /**
2
- * @deprecated - return the remote name in the CloneReturn
3
- */
4
- type CloneDir = string;
5
-
6
- export interface CloneReturn {
7
- /** The directory where the clone occurred - absolute path to avoid working dir issues */
8
- dir: string;
9
- /** The name of the remote for the particular technology that you used - passed to checkout drivers */
10
- remoteName: string;
11
- }
12
-
13
- /**
14
- * A function that clones the template repo into the provided tmpDir
15
- * and then returns the relative path within that directory to the template root
16
- */
17
- export type TemplateCloneDriverFn = (
18
- tmpDir: string,
19
- repoUrl: string,
20
- ) => Promise<CloneReturn | CloneDir>;
@@ -1,73 +0,0 @@
1
- import { execSync } from "child_process";
2
- import * as fs from "fs";
3
- import * as path from "path";
4
- import { gitDiff } from "./git-diff";
5
-
6
- describe("gitDiff", () => {
7
- let tempDir: string;
8
-
9
- beforeEach(() => {
10
- tempDir = fs.mkdtempSync("gitdiff-test");
11
- // Initialize a git repo
12
- execSync("git init", { cwd: tempDir });
13
- fs.writeFileSync(path.join(tempDir, "file1.txt"), "hello");
14
- fs.writeFileSync(path.join(tempDir, "second.txt"), "second");
15
- fs.writeFileSync(path.join(tempDir, "third.txt"), "third");
16
- execSync("git add . && git commit -m 'initial'", { cwd: tempDir });
17
- });
18
-
19
- afterEach(() => {
20
- fs.rmSync(tempDir, { recursive: true, force: true });
21
- });
22
-
23
- it("handles a rename as a delete and an add", async () => {
24
- const firstCommit = execSync("git rev-parse HEAD", { cwd: tempDir })
25
- .toString()
26
- .trim();
27
-
28
- // Perform a rename
29
- execSync("git mv file1.txt file2.txt", { cwd: tempDir });
30
- execSync("git commit -m 'rename'", { cwd: tempDir });
31
-
32
- const result = await gitDiff(tempDir, firstCommit);
33
-
34
- // Because of --no-renames:
35
- expect(result).toEqual({
36
- deleted: ["file1.txt"],
37
- added: ["file2.txt"],
38
- modified: [],
39
- });
40
- });
41
- it("handles a added, deleted, and modified appropriately across multiple commits", async () => {
42
- const firstCommit = execSync("git rev-parse HEAD", { cwd: tempDir })
43
- .toString()
44
- .trim();
45
-
46
- // Perform a rename
47
- execSync("git mv file1.txt file2.txt", { cwd: tempDir });
48
- execSync("git commit -m 'rename'", { cwd: tempDir });
49
-
50
- // Perform adds
51
- fs.writeFileSync(path.join(tempDir, "another.txt"), "another file");
52
- execSync("git add . && git commit -m 'adding another file'", {
53
- cwd: tempDir,
54
- });
55
-
56
- // Perform a modify
57
- fs.writeFileSync(path.join(tempDir, "third.txt"), "third+");
58
- execSync("git add . && git commit -m 'modifying third'", { cwd: tempDir });
59
-
60
- // Perform a delete
61
- fs.rmSync(path.join(tempDir, "second.txt"));
62
- execSync("git add . && git commit -m 'deleting second'", { cwd: tempDir });
63
-
64
- const result = await gitDiff(tempDir, firstCommit);
65
-
66
- // Because of --no-renames:
67
- expect(result).toEqual({
68
- deleted: expect.arrayContaining(["file1.txt", "second.txt"]),
69
- added: expect.arrayContaining(["file2.txt", "another.txt"]),
70
- modified: ["third.txt"],
71
- });
72
- });
73
- });
@@ -1,39 +0,0 @@
1
- import { execSync } from "child_process";
2
-
3
- /**
4
- * For a given directory with a git configuration, this will return the modified, added, and
5
- * deleted files since the last afterRef
6
- * @param gitDir The git directory folder
7
- * @param afterRef The git ref to look for diffs after
8
- * @returns
9
- */
10
- export async function gitDiff(gitDir: string, afterRef: string) {
11
- const baseCommand = `git diff ${afterRef}.. --no-renames --name-only`;
12
- const modifiedFiles = execSync(`${baseCommand} --diff-filter=M`, {
13
- cwd: gitDir,
14
- })
15
- .toString()
16
- .trim()
17
- .split("\n")
18
- .filter((s) => s !== "");
19
- const addedFiles = execSync(`${baseCommand} --diff-filter=A`, {
20
- cwd: gitDir,
21
- })
22
- .toString()
23
- .trim()
24
- .split("\n")
25
- .filter((s) => s !== "");
26
- const deletedFiles = execSync(`${baseCommand} --diff-filter=D`, {
27
- cwd: gitDir,
28
- })
29
- .toString()
30
- .trim()
31
- .split("\n")
32
- .filter((s) => s !== "");
33
-
34
- return {
35
- modified: modifiedFiles,
36
- added: addedFiles,
37
- deleted: deletedFiles,
38
- };
39
- }
@@ -1,2 +0,0 @@
1
- export * from "./types";
2
- export * from "./git-diff";
@@ -1,14 +0,0 @@
1
- export interface DiffResult {
2
- modified: string[];
3
- added: string[];
4
- deleted: string[];
5
- }
6
-
7
- /**
8
- * A function that operates within the gitDir, and returns the list of file paths
9
- * since the last sha
10
- */
11
- export type TemplateDiffDriverFn = (
12
- gitDir: string,
13
- afterRef: string,
14
- ) => Promise<DiffResult>;
@@ -1,39 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`syncResultsToMd snapshots 1`] = `
4
- "# templatesync.local
5
-
6
- ## Stopped the following files from syncing:
7
-
8
- * src/file1.ts
9
-
10
-
11
- ## Changed the following files from what they would have synced:
12
-
13
- package.json
14
- \`\`\`diff
15
-
16
- +my thing
17
-
18
- -your thang
19
-
20
- \`\`\`
21
-
22
- ## Files Modified (6)
23
-
24
- Added:
25
-
26
- - src/something.ts
27
- - new_settings.toml
28
-
29
- Modified:
30
-
31
- - something.txt
32
- - .env
33
-
34
- Deleted:
35
-
36
- - TODO.md
37
- - throwaway.ts
38
- "
39
- `;
@@ -1,2 +0,0 @@
1
- export * from "./sync-results-to-md";
2
- export * from "./infer-json-indent";
@@ -1,49 +0,0 @@
1
- import { inferJSONIndent } from "./infer-json-indent";
2
-
3
- const withNewLine = `{
4
-
5
- "whoa": true,
6
- "thing": here,
7
- "something": {
8
- "nested": false
9
- }
10
- }`;
11
-
12
- const fourSpaces = `{
13
- "whoa": true,
14
- "thing": here,
15
- "something": {
16
- "nested": false
17
- }
18
- }`;
19
-
20
- const tabSpaces = `{
21
- "whoa": true,
22
- "thing": here,
23
- "something": {
24
- "nested": false
25
- }
26
- }`;
27
-
28
- const twoSpaces = `{
29
- "whoa": true,
30
- "thing": here,
31
- "something": {
32
- "nested": false
33
- }
34
- }`;
35
-
36
- describe("inferJSONIndent", () => {
37
- it("returns spaces when the first indent is spaces with a new line", () => {
38
- expect(inferJSONIndent(withNewLine)).toBe(" ");
39
- });
40
- it("returns spaces when the first indent is spaces", () => {
41
- expect(inferJSONIndent(fourSpaces)).toBe(" ");
42
- });
43
- it("returns spaces when the first indent is spaces", () => {
44
- expect(inferJSONIndent(twoSpaces)).toBe(" ");
45
- });
46
- it("returns tabs when the first indent is a tab", () => {
47
- expect(inferJSONIndent(tabSpaces)).toBe("\t");
48
- });
49
- });
@@ -1,16 +0,0 @@
1
- const spacingRegex = /[{[]\n?(?<spacing>\s+)["tf\d]/;
2
- export function inferJSONIndent(rawJSON: string) {
3
- const match = spacingRegex.exec(rawJSON);
4
- if (!match?.groups?.spacing) {
5
- // eslint-disable-next-line no-console
6
- console.warn(
7
- `Could not find json indentation for json string: ${rawJSON.slice(40)} ... \nDefaulting to 4 spaces`,
8
- );
9
- // Four spaces
10
- return " ";
11
- }
12
- const spacing = match.groups.spacing;
13
- // Handle the case where there were multiple newlines before a value
14
- const lastNewLine = spacing.lastIndexOf("\n");
15
- return match?.groups.spacing.slice(lastNewLine >= 0 ? lastNewLine + 1 : 0);
16
- }