@hanseltime/template-repo-sync 2.3.0 → 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 (295) hide show
  1. package/CHANGELOG.md +37 -46
  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 -204
  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 -204
  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 -602
  230. package/src/template-sync.ts +0 -304
  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 -14
  237. package/test-fixtures/downstream/plugins/fail-validate-plugin.js +0 -14
  238. package/test-fixtures/downstream/src/index.js +0 -2
  239. package/test-fixtures/downstream/src/index.ts +0 -1
  240. package/test-fixtures/downstream/src/templated.js +0 -2
  241. package/test-fixtures/downstream/src/templated.ts +0 -1
  242. package/test-fixtures/downstream/templatesync.json +0 -16
  243. package/test-fixtures/downstream/templatesync.local.json +0 -10
  244. package/test-fixtures/dummy-plugin.js +0 -8
  245. package/test-fixtures/glob-test/folder1/something.js +0 -1
  246. package/test-fixtures/glob-test/folder1/something.ts +0 -0
  247. package/test-fixtures/glob-test/toplevel.js +0 -0
  248. package/test-fixtures/glob-test/toplevel.txt +0 -0
  249. package/test-fixtures/template/custom-bin/something.txt +0 -1
  250. package/test-fixtures/template/dummy-fail-plugin.js +0 -8
  251. package/test-fixtures/template/package.json +0 -17
  252. package/test-fixtures/template/src/index.js +0 -2
  253. package/test-fixtures/template/src/index.ts +0 -1
  254. package/test-fixtures/template/src/templated.js +0 -2
  255. package/test-fixtures/template/src/templated.ts +0 -1
  256. package/test-fixtures/template/templatesync.json +0 -16
  257. package/test-fixtures/testGitRepo/README.md +0 -17
  258. package/test-fixtures/testGitRepo/gitDir/COMMIT_EDITMSG +0 -14
  259. package/test-fixtures/testGitRepo/gitDir/HEAD +0 -1
  260. package/test-fixtures/testGitRepo/gitDir/config +0 -7
  261. package/test-fixtures/testGitRepo/gitDir/description +0 -1
  262. package/test-fixtures/testGitRepo/gitDir/hooks/applypatch-msg.sample +0 -15
  263. package/test-fixtures/testGitRepo/gitDir/hooks/commit-msg.sample +0 -24
  264. package/test-fixtures/testGitRepo/gitDir/hooks/fsmonitor-watchman.sample +0 -174
  265. package/test-fixtures/testGitRepo/gitDir/hooks/post-update.sample +0 -8
  266. package/test-fixtures/testGitRepo/gitDir/hooks/pre-applypatch.sample +0 -14
  267. package/test-fixtures/testGitRepo/gitDir/hooks/pre-commit.sample +0 -49
  268. package/test-fixtures/testGitRepo/gitDir/hooks/pre-merge-commit.sample +0 -13
  269. package/test-fixtures/testGitRepo/gitDir/hooks/pre-push.sample +0 -53
  270. package/test-fixtures/testGitRepo/gitDir/hooks/pre-rebase.sample +0 -169
  271. package/test-fixtures/testGitRepo/gitDir/hooks/pre-receive.sample +0 -24
  272. package/test-fixtures/testGitRepo/gitDir/hooks/prepare-commit-msg.sample +0 -42
  273. package/test-fixtures/testGitRepo/gitDir/hooks/push-to-checkout.sample +0 -78
  274. package/test-fixtures/testGitRepo/gitDir/hooks/sendemail-validate.sample +0 -77
  275. package/test-fixtures/testGitRepo/gitDir/hooks/update.sample +0 -128
  276. package/test-fixtures/testGitRepo/gitDir/index +0 -0
  277. package/test-fixtures/testGitRepo/gitDir/info/exclude +0 -6
  278. package/test-fixtures/testGitRepo/gitDir/logs/HEAD +0 -5
  279. package/test-fixtures/testGitRepo/gitDir/logs/refs/heads/master +0 -2
  280. package/test-fixtures/testGitRepo/gitDir/logs/refs/heads/test-branch +0 -2
  281. package/test-fixtures/testGitRepo/gitDir/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
  282. package/test-fixtures/testGitRepo/gitDir/objects/6e/187bee8d02f39d0a1be8331dd8fe6a00c9b613 +0 -0
  283. package/test-fixtures/testGitRepo/gitDir/objects/73/185f1f3f5a6345e087d9f46dc4af77cc59449f +0 -2
  284. package/test-fixtures/testGitRepo/gitDir/objects/90/e7ea1089f939840e9649fd617584c1ad117159 +0 -3
  285. package/test-fixtures/testGitRepo/gitDir/objects/ba/99a452b9097047e9bfa8d5a08b3e452fcb364a +0 -0
  286. package/test-fixtures/testGitRepo/gitDir/objects/c5/8d400177cd5180b8566f82a127fafc5bf394b7 +0 -0
  287. package/test-fixtures/testGitRepo/gitDir/objects/e2/e668265db019249a7e8296d85f79000e3d71cf +0 -0
  288. package/test-fixtures/testGitRepo/gitDir/objects/e4/243e430c1ab69f3e344249f5b1859e90abc883 +0 -1
  289. package/test-fixtures/testGitRepo/gitDir/objects/ec/6c1cb72312605282ac61858cf1eaf1ea9f1d02 +0 -0
  290. package/test-fixtures/testGitRepo/gitDir/objects/fc/89cecc4ac0b5b075bd7d0ce9e09b2f50598b82 +0 -0
  291. package/test-fixtures/testGitRepo/gitDir/refs/heads/master +0 -1
  292. package/test-fixtures/testGitRepo/gitDir/refs/heads/test-branch +0 -1
  293. package/tsconfig.cjs.json +0 -12
  294. package/tsconfig.esm.json +0 -10
  295. package/tsconfig.json +0 -22
@@ -1,69 +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.loadPlugin = void 0;
27
- const plugins_1 = require("./plugins");
28
- const fs_1 = require("fs");
29
- const path_1 = require("path");
30
- /**
31
- * Loads the plugin associated with the merge config
32
- * @param mergeConfig
33
- * @param forExt
34
- * @param configDir
35
- * @returns
36
- */
37
- async function loadPlugin(mergeConfig, configDir) {
38
- if (mergeConfig.plugin.startsWith("_")) {
39
- const defaultHandler = Object.values(plugins_1.defaultExtensionMap).find((el) => el.builtinName === mergeConfig.plugin);
40
- if (!defaultHandler) {
41
- throw new Error(`No builtin merge function supplied for ${mergeConfig.plugin}. Cannot have merge config without custom plugin supplied.`);
42
- }
43
- return defaultHandler;
44
- }
45
- let handler;
46
- // First check if this is a local .js file
47
- const localPath = (0, path_1.resolve)(configDir, mergeConfig.plugin);
48
- const importPath = (0, fs_1.existsSync)(localPath) ? localPath : mergeConfig.plugin;
49
- try {
50
- // Sad workaround for testing since dynamic import segfaults
51
- if (process.env.JEST_WORKER_ID !== undefined) {
52
- // eslint-disable-next-line @typescript-eslint/no-var-requires
53
- handler = require(importPath);
54
- }
55
- else {
56
- handler = (await Promise.resolve(`${importPath}`).then(s => __importStar(require(s))));
57
- }
58
- if (!handler.merge) {
59
- handler = handler
60
- .default;
61
- }
62
- }
63
- catch (err) {
64
- console.error(err);
65
- throw err;
66
- }
67
- return handler;
68
- }
69
- exports.loadPlugin = loadPlugin;
package/lib/cjs/match.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAllFilesInDir = exports.invertMatchPatterns = void 0;
4
- const fs_1 = require("fs");
5
- const micromatch_1 = require("micromatch");
6
- const path_1 = require("path");
7
- function invertMatchPatterns(patterns) {
8
- return patterns.map((pattern) => {
9
- if (pattern.startsWith("!")) {
10
- return pattern.slice(1);
11
- }
12
- return `!${pattern}`;
13
- });
14
- }
15
- exports.invertMatchPatterns = invertMatchPatterns;
16
- /**
17
- * Gets all the files in the directory recursively while avoiding any micromatch patterns
18
- * that would match for ignoring
19
- *
20
- * @param dir
21
- * @param ignorePatterns
22
- * @returns
23
- */
24
- function getAllFilesInDir(dir, ignorePatterns) {
25
- return recurseDirsForFiles(dir, ignorePatterns);
26
- }
27
- exports.getAllFilesInDir = getAllFilesInDir;
28
- function recurseDirsForFiles(dirpath, ignorePatterns, relativeRoot = "") {
29
- return (0, fs_1.readdirSync)(dirpath, {
30
- withFileTypes: true,
31
- }).reduce((files, f) => {
32
- const relPath = (0, path_1.join)(relativeRoot, f.name);
33
- if ((0, micromatch_1.some)(relPath, ignorePatterns)) {
34
- return files;
35
- }
36
- // Ensure we aren't ignoring these folders explicitly
37
- if (f.isDirectory()) {
38
- files.push(...recurseDirsForFiles((0, path_1.join)(dirpath, f.name), ignorePatterns, relPath));
39
- }
40
- else {
41
- files.push(relPath);
42
- }
43
- return files;
44
- }, []);
45
- }
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeFile = void 0;
4
- const micromatch_1 = require("micromatch");
5
- const path_1 = require("path");
6
- const fs_1 = require("fs");
7
- const promises_1 = require("fs/promises");
8
- const load_plugin_1 = require("./load-plugin");
9
- const diff_1 = require("diff");
10
- const fs_extra_1 = require("fs-extra");
11
- /**
12
- * Applies the merge to a file according to the context information.
13
- *
14
- * Returns true if merged and false if skipped
15
- * @param relPath
16
- * @param context
17
- * @returns
18
- */
19
- async function mergeFile(relPath, context) {
20
- const { localTemplateSyncConfig, templateSyncConfig, tempCloneDir, cwd } = context;
21
- if ((0, micromatch_1.some)(relPath, localTemplateSyncConfig.ignore)) {
22
- return {
23
- ignoredDueToLocal: true,
24
- };
25
- }
26
- const ext = (0, path_1.extname)(relPath);
27
- const filePath = (0, path_1.join)(cwd, relPath);
28
- const templatePath = (0, path_1.join)(tempCloneDir, relPath);
29
- // Unless there's a need, we remove files that were deleted and don't pass them to plugins yet
30
- if (context.fileOperation === "deleted") {
31
- if ((0, fs_1.existsSync)(filePath)) {
32
- await (0, promises_1.rm)(filePath);
33
- }
34
- return {
35
- ignoredDueToLocal: false,
36
- localChanges: [],
37
- };
38
- }
39
- const mergeConfig = templateSyncConfig.merge?.find((mergeConfig) => (0, micromatch_1.isMatch)(relPath, mergeConfig.glob));
40
- const localMergeConfig = localTemplateSyncConfig.merge?.find((mergeConfig) => (0, micromatch_1.isMatch)(relPath, mergeConfig.glob));
41
- const mergeHandler = mergeConfig
42
- ? await (0, load_plugin_1.loadPlugin)(mergeConfig, tempCloneDir)
43
- : undefined;
44
- const localMergeHandler = localMergeConfig
45
- ? await (0, load_plugin_1.loadPlugin)(localMergeConfig, cwd)
46
- : undefined;
47
- // Either write the merge or write the file
48
- let fileContents;
49
- const localChanges = [];
50
- if ((0, fs_1.existsSync)(filePath) && (mergeHandler || localMergeHandler)) {
51
- const originalCurrentFile = (await (0, promises_1.readFile)(filePath)).toString();
52
- if (mergeHandler) {
53
- fileContents = await safeMerge(mergeHandler, mergeConfig?.plugin ?? `default for ${ext}`, originalCurrentFile, (await (0, promises_1.readFile)(templatePath)).toString(), {
54
- relFilePath: relPath,
55
- mergeArguments: mergeConfig?.options ?? {},
56
- isLocalOptions: false,
57
- });
58
- }
59
- else {
60
- // Apply overwrite if we didn't set up merge
61
- fileContents = (await (0, promises_1.readFile)(templatePath)).toString();
62
- }
63
- // We apply the localMerge Config to the fileContent output by the template merge
64
- if (localMergeHandler) {
65
- const localContents = await safeMerge(localMergeHandler, localMergeConfig?.plugin ?? `default for ${ext}`, originalCurrentFile, fileContents, {
66
- relFilePath: relPath,
67
- mergeArguments: localMergeConfig?.options ?? {},
68
- isLocalOptions: true,
69
- });
70
- localChanges.push(...(0, diff_1.diffLines)(fileContents, localContents));
71
- fileContents = localContents;
72
- }
73
- }
74
- else {
75
- // Just perform simple overwrite
76
- fileContents = (await (0, promises_1.readFile)(templatePath)).toString();
77
- }
78
- await (0, fs_extra_1.outputFile)(filePath, fileContents);
79
- return {
80
- ignoredDueToLocal: false,
81
- localChanges,
82
- };
83
- }
84
- exports.mergeFile = mergeFile;
85
- /**
86
- * Simple helper function to ensure that we don't let bad plugins corrupt the call flow
87
- * @param plugin
88
- */
89
- async function safeMerge(plugin, pluginPath, current, fromTemplate, context) {
90
- const ret = await plugin.merge(current, fromTemplate, context);
91
- if (typeof ret !== "string") {
92
- throw new Error(`Plugin ${pluginPath} did not return string for merge function! This is not allowed!`);
93
- }
94
- if (!ret) {
95
- throw new Error(`Plugin ${pluginPath} should not make a merge be an empty string!`);
96
- }
97
- return ret;
98
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultExtensionMap = void 0;
4
- const json_merge_1 = require("./json-merge");
5
- exports.defaultExtensionMap = {
6
- ".json": {
7
- merge: json_merge_1.merge,
8
- validate: json_merge_1.validate,
9
- builtinName: "_json",
10
- },
11
- };
@@ -1,208 +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
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.merge = exports.validate = void 0;
30
- const lodash_merge_1 = __importDefault(require("lodash.merge"));
31
- const jsonpath_1 = __importDefault(require("jsonpath"));
32
- const infer_json_indent_1 = require("../formatting/infer-json-indent");
33
- const commentJSON = __importStar(require("comment-json"));
34
- function stringOptionError(value) {
35
- if (value === "overwrite" ||
36
- value === "merge-template" ||
37
- value === "merge-current") {
38
- return;
39
- }
40
- return `${value} must be one of type overwrite, merge-template, or merge-current`;
41
- }
42
- function validate(options) {
43
- const errors = [];
44
- // check for flat options
45
- if (typeof options === "string") {
46
- const errMsg = stringOptionError(options);
47
- if (errMsg) {
48
- errors.push(errMsg);
49
- }
50
- return errors;
51
- }
52
- else {
53
- if (typeof options !== "object") {
54
- errors.push(`Options must be an object and not ${typeof options}`);
55
- return errors;
56
- }
57
- if (Array.isArray(options)) {
58
- errors.push(`Options must be an object and not Array`);
59
- return errors;
60
- }
61
- if (options === null) {
62
- errors.push("Options cannot be null");
63
- return errors;
64
- }
65
- }
66
- const optionsCast = options;
67
- const optionKeys = Object.keys(optionsCast);
68
- optionKeys.forEach((k) => {
69
- if (k === "paths") {
70
- optionsCast.paths.forEach((pathObj) => {
71
- const [jsonPath, options] = pathObj;
72
- if (jsonPath.startsWith("$.")) {
73
- try {
74
- jsonpath_1.default.parse(jsonPath);
75
- }
76
- catch (err) {
77
- errors.push(`Invalid jsonpath key: ${err}`);
78
- return;
79
- }
80
- const errMsg = stringOptionError(options);
81
- if (errMsg) {
82
- errors.push(`jsonpath ${jsonPath}: ${errMsg}`);
83
- }
84
- }
85
- else {
86
- errors.push(`Unrecognized jsonpath syntax: ${jsonPath}`);
87
- }
88
- });
89
- }
90
- else {
91
- if (k === "ignoreNewProperties" || k === "missingIsDelete") {
92
- return;
93
- }
94
- errors.push(`Unrecognized key: ${k}`);
95
- }
96
- });
97
- return errors;
98
- }
99
- exports.validate = validate;
100
- async function merge(current, fromTemplateRepo, context) {
101
- if (context.mergeArguments === "overwrite") {
102
- return fromTemplateRepo;
103
- }
104
- const currentJson = commentJSON.parse(current);
105
- const fromTemplateJson = commentJSON.parse(fromTemplateRepo);
106
- if (context.mergeArguments === "merge-current") {
107
- // Performs Lodash Merge with current as the override
108
- return commentJSON.stringify((0, lodash_merge_1.default)(fromTemplateJson, currentJson), null, (0, infer_json_indent_1.inferJSONIndent)(current));
109
- }
110
- if (context.mergeArguments === "merge-template") {
111
- // Performs Lodash Merge with current as the override
112
- return commentJSON.stringify((0, lodash_merge_1.default)(currentJson, fromTemplateJson), null, (0, infer_json_indent_1.inferJSONIndent)(current));
113
- }
114
- const { missingIsDelete, ignoreNewProperties, paths } = context.mergeArguments;
115
- const returnJson = commentJSON.parse(current);
116
- paths.forEach((p) => {
117
- const [jPath, overrideType] = p;
118
- const fromTemplatePaths = new Map();
119
- if (overrideType === "merge-template") {
120
- // We want to make sure there aren't extra paths from the template that didn't get added
121
- jsonpath_1.default.nodes(fromTemplateJson, jPath).forEach((n) => {
122
- fromTemplatePaths.set(jsonpath_1.default.stringify(n.path), n.path);
123
- });
124
- }
125
- jsonpath_1.default.nodes(currentJson, jPath).forEach(({ path, value }) => {
126
- // This solves for wildcard operators
127
- const fullPath = jsonpath_1.default.stringify(path);
128
- // track the paths in the template we've walked
129
- fromTemplatePaths.delete(fullPath);
130
- jsonpath_1.default.apply(returnJson, fullPath, () => {
131
- const templateValue = jsonpath_1.default.value(fromTemplateJson, fullPath);
132
- if (overrideType === "merge-template") {
133
- if (templateValue === undefined) {
134
- if (missingIsDelete) {
135
- return templateValue;
136
- }
137
- }
138
- else {
139
- return applyValueMerge(value, templateValue);
140
- }
141
- }
142
- else if (overrideType === "merge-current") {
143
- return applyValueMerge(templateValue, value);
144
- }
145
- else if (overrideType === "overwrite") {
146
- if (templateValue !== undefined || missingIsDelete) {
147
- return templateValue;
148
- }
149
- }
150
- else {
151
- throw new Error(`Unexpected JsonPath merge value ${overrideType}`);
152
- }
153
- return value;
154
- });
155
- });
156
- if (!ignoreNewProperties) {
157
- for (const fromTemplatePath of fromTemplatePaths.values()) {
158
- applyPerPath(fromTemplatePath, returnJson, fromTemplateJson);
159
- }
160
- }
161
- });
162
- if (!ignoreNewProperties) {
163
- Object.keys(fromTemplateJson).forEach((key) => {
164
- if (!returnJson[key]) {
165
- returnJson[key] = fromTemplateJson[key];
166
- }
167
- });
168
- }
169
- return commentJSON.stringify(returnJson, null, (0, infer_json_indent_1.inferJSONIndent)(current));
170
- }
171
- exports.merge = merge;
172
- /**
173
- * A merge from a template to template perspective is either melding objects
174
- * or completely overwriting primitive types
175
- */
176
- function applyValueMerge(base, toMerge) {
177
- if (typeof base === "object" && typeof toMerge === "object") {
178
- return (0, lodash_merge_1.default)(base, toMerge);
179
- }
180
- else {
181
- return toMerge;
182
- }
183
- }
184
- /**
185
- * Given a nodePath on the "map" tree, this will go to the first missing element
186
- * and copy that node onto the object
187
- *
188
- * @param nodePath
189
- * @param onto
190
- * @param map
191
- * @param forIdx
192
- */
193
- function applyPerPath(nodePath,
194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
- onto,
196
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
- map, forIdx = 0) {
198
- if (nodePath[forIdx] === "$") {
199
- applyPerPath(nodePath, onto, map, forIdx + 1);
200
- return;
201
- }
202
- const selector = nodePath[forIdx];
203
- if (onto[selector]) {
204
- applyPerPath(nodePath, onto[selector], map[selector], forIdx + 1);
205
- return;
206
- }
207
- onto[selector] = map[selector];
208
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gitCurrentRef = void 0;
4
- const child_process_1 = require("child_process");
5
- async function gitCurrentRef(options) {
6
- return (0, child_process_1.execSync)(`git rev-parse HEAD`, {
7
- cwd: options.rootDir,
8
- })
9
- .toString()
10
- .trim();
11
- }
12
- exports.gitCurrentRef = gitCurrentRef;
@@ -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,204 +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
- const load_plugin_1 = require("./load-plugin");
39
- exports.TEMPLATE_SYNC_CONFIG = "templatesync";
40
- exports.TEMPLATE_SYNC_LOCAL_CONFIG = "templatesync.local";
41
- async function templateSync(options) {
42
- const cloneDriver = options.cloneDriver ?? git_clone_1.gitClone;
43
- const diffDriver = options.diffDriver ?? diff_drivers_1.gitDiff;
44
- const currentRefDriver = options.currentRefDriver ?? ref_drivers_1.gitCurrentRef;
45
- const checkoutDriver = options.checkoutDriver ?? checkout_drivers_1.gitCheckout;
46
- const cloneReturn = await cloneDriver(options.tmpCloneDir, options.repoUrl);
47
- const { dir: tempCloneDir, remoteName } = typeof cloneReturn === "string"
48
- ? {
49
- dir: cloneReturn,
50
- remoteName: "origin", // Default to this
51
- }
52
- : cloneReturn;
53
- if (options.branch) {
54
- await checkoutDriver({
55
- tmpDir: tempCloneDir,
56
- remoteName,
57
- branch: options.branch,
58
- });
59
- }
60
- // Get the clone Config
61
- const cloneConfigPath = (0, path_1.join)(tempCloneDir, `${exports.TEMPLATE_SYNC_CONFIG}.json`);
62
- const templateSyncConfig = (0, fs_1.existsSync)(cloneConfigPath)
63
- ? commentJSON.parse((0, fs_1.readFileSync)(cloneConfigPath).toString())
64
- : { ignore: [] };
65
- const localConfigFile = `${exports.TEMPLATE_SYNC_LOCAL_CONFIG}.json`;
66
- const localConfigPath = (0, path_1.join)(options.repoDir, localConfigFile);
67
- const localTemplateSyncConfig = (0, fs_1.existsSync)(localConfigPath)
68
- ? commentJSON.parse((0, fs_1.readFileSync)(localConfigPath).toString())
69
- : { ignore: [] };
70
- let filesToSync;
71
- const ref = await currentRefDriver({
72
- rootDir: tempCloneDir,
73
- });
74
- if (localTemplateSyncConfig.afterRef) {
75
- if (ref === localTemplateSyncConfig.afterRef) {
76
- // short circuit if the refs match
77
- return {
78
- localSkipFiles: [],
79
- localFileChanges: {},
80
- modifiedFiles: {
81
- added: [],
82
- modified: [],
83
- deleted: [],
84
- total: 0,
85
- },
86
- };
87
- }
88
- filesToSync = await diffDriver(tempCloneDir, localTemplateSyncConfig.afterRef);
89
- }
90
- else {
91
- filesToSync = {
92
- added: (0, match_1.getAllFilesInDir)(tempCloneDir, [
93
- ...templateSyncConfig.ignore,
94
- ".git/**",
95
- ]),
96
- deleted: [],
97
- modified: [],
98
- };
99
- }
100
- // Pre-load plugins and make sure the sync file is respected
101
- // Synchronous since grpc servers take a second
102
- const localValidateErrors = {};
103
- const validateErrors = {};
104
- for (const config of localTemplateSyncConfig.merge ?? []) {
105
- const plugin = await (0, load_plugin_1.loadPlugin)(config, options.repoDir);
106
- const errors = plugin.validate(config.options ?? {});
107
- if (errors && errors.length > 0) {
108
- localValidateErrors[config.plugin] = errors;
109
- }
110
- }
111
- for (const config of templateSyncConfig.merge ?? []) {
112
- const plugin = await (0, load_plugin_1.loadPlugin)(config, tempCloneDir);
113
- const errors = plugin.validate(config.options ?? {});
114
- if (errors && errors.length > 0) {
115
- validateErrors[config.plugin] = errors;
116
- }
117
- }
118
- let errorStr = "";
119
- if (Object.keys(validateErrors).length > 0) {
120
- errorStr = `${errorStr}templatesync.json plugin option errors:\n`;
121
- for (const plugin in validateErrors) {
122
- errorStr = `${errorStr}\tPlugin (${plugin}):\n`;
123
- validateErrors[plugin].forEach((err) => {
124
- errorStr = `${errorStr}\t\t${err}\n`;
125
- });
126
- }
127
- }
128
- if (Object.keys(localValidateErrors).length > 0) {
129
- errorStr = `${errorStr}templatesync.local.json plugin option errors:\n`;
130
- for (const plugin in localValidateErrors) {
131
- errorStr = `${errorStr}\tPlugin (${plugin}):\n`;
132
- localValidateErrors[plugin].forEach((err) => {
133
- errorStr = `${errorStr}\t\t${err}\n`;
134
- });
135
- }
136
- }
137
- if (errorStr !== "") {
138
- throw Error(errorStr);
139
- }
140
- // Apply ignore filters
141
- filesToSync.added = filesToSync.added.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
142
- filesToSync.modified = filesToSync.modified.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
143
- filesToSync.deleted = filesToSync.deleted.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
144
- const localSkipFiles = new Set();
145
- const localFileChanges = {};
146
- const fileSyncFactory = (op) => {
147
- return async (f) => {
148
- const result = await (0, merge_file_1.mergeFile)(f, {
149
- localTemplateSyncConfig,
150
- templateSyncConfig,
151
- tempCloneDir,
152
- cwd: options.repoDir,
153
- fileOperation: op,
154
- });
155
- if (result.ignoredDueToLocal) {
156
- localSkipFiles.add(f);
157
- }
158
- else if (result?.localChanges && result.localChanges.length > 0) {
159
- localFileChanges[f] = result.localChanges;
160
- }
161
- };
162
- };
163
- // Added and modified have the same setup for now
164
- await Promise.all(filesToSync.added.map(fileSyncFactory("added")));
165
- await Promise.all(filesToSync.modified.map(fileSyncFactory("modified")));
166
- await Promise.all(filesToSync.deleted.map(fileSyncFactory("deleted")));
167
- // Report the files that changed in general
168
- const actualAdded = filesToSync.added.filter((f) => !localSkipFiles.has(f));
169
- const actualModified = filesToSync.modified.filter((f) => !localSkipFiles.has(f));
170
- const actualDeleted = filesToSync.deleted.filter((f) => !localSkipFiles.has(f));
171
- const modifiedFiles = {
172
- added: actualAdded,
173
- modified: actualModified,
174
- deleted: actualDeleted,
175
- };
176
- // apply after ref
177
- if (options.updateAfterRef) {
178
- const ref = await currentRefDriver({
179
- rootDir: tempCloneDir,
180
- });
181
- if ((0, fs_1.existsSync)(localConfigPath)) {
182
- const configStr = (0, fs_1.readFileSync)(localConfigPath).toString();
183
- const config = commentJSON.parse(configStr);
184
- config.afterRef = ref;
185
- (0, fs_1.writeFileSync)(localConfigPath, commentJSON.stringify(config, null, (0, formatting_1.inferJSONIndent)(configStr)));
186
- modifiedFiles.modified.push(localConfigFile);
187
- }
188
- else {
189
- (0, fs_1.writeFileSync)(localConfigPath, commentJSON.stringify({ afterRef: ref }, null, 4));
190
- modifiedFiles.added.push(localConfigFile);
191
- }
192
- }
193
- return {
194
- localSkipFiles: Array.from(localSkipFiles),
195
- localFileChanges,
196
- modifiedFiles: {
197
- ...modifiedFiles,
198
- total: modifiedFiles.added.length +
199
- modifiedFiles.deleted.length +
200
- modifiedFiles.modified.length,
201
- },
202
- };
203
- }
204
- 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;