@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.
- package/CHANGELOG.md +43 -45
- package/dist/cjs/checkout-drivers/git-checkout.js +37 -0
- package/dist/cjs/checkout-drivers/git-checkout.spec.js +60 -0
- package/dist/cjs/checkout-drivers/index.js +21 -0
- package/dist/cjs/checkout-drivers/types.js +11 -0
- package/dist/cjs/clone-drivers/git-clone.js +25 -0
- package/dist/cjs/clone-drivers/index.js +21 -0
- package/dist/cjs/clone-drivers/types.js +8 -0
- package/dist/cjs/diff-drivers/git-diff.js +30 -0
- package/dist/cjs/diff-drivers/git-diff.spec.js +138 -0
- package/dist/cjs/diff-drivers/index.js +21 -0
- package/dist/cjs/diff-drivers/types.js +6 -0
- package/dist/cjs/formatting/index.js +21 -0
- package/dist/cjs/formatting/infer-json-indent.js +26 -0
- package/dist/cjs/formatting/infer-json-indent.spec.js +50 -0
- package/dist/cjs/formatting/sync-results-to-md.js +62 -0
- package/dist/cjs/formatting/sync-results-to-md.spec.js +45 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/load-plugin.js +44 -0
- package/dist/cjs/match.js +51 -0
- package/dist/cjs/match.spec.js +75 -0
- package/dist/cjs/merge-file.js +91 -0
- package/dist/cjs/merge-file.spec.js +508 -0
- package/dist/cjs/plugins/index.js +20 -0
- package/dist/cjs/plugins/json-merge.js +228 -0
- package/dist/cjs/plugins/json-merge.spec.js +514 -0
- package/dist/cjs/ref-drivers/git-current-ref.js +18 -0
- package/dist/cjs/ref-drivers/git-current-ref.spec.js +15 -0
- package/dist/cjs/ref-drivers/index.js +20 -0
- package/dist/cjs/ref-drivers/types.js +11 -0
- package/dist/cjs/template-sync.js +236 -0
- package/dist/cjs/template-sync.spec.js +521 -0
- package/dist/cjs/test-utils/index.js +26 -0
- package/dist/cjs/types.js +12 -0
- package/dist/esm/checkout-drivers/git-checkout.mjs +27 -0
- package/dist/esm/checkout-drivers/git-checkout.spec.mjs +56 -0
- package/dist/esm/checkout-drivers/index.mjs +4 -0
- package/dist/esm/checkout-drivers/types.mjs +8 -0
- package/dist/esm/clone-drivers/git-clone.mjs +15 -0
- package/dist/esm/clone-drivers/index.mjs +4 -0
- package/dist/esm/clone-drivers/types.mjs +8 -0
- package/dist/esm/diff-drivers/git-diff.mjs +26 -0
- package/dist/esm/diff-drivers/git-diff.spec.mjs +93 -0
- package/dist/esm/diff-drivers/index.mjs +4 -0
- package/dist/esm/diff-drivers/types.mjs +6 -0
- package/dist/esm/formatting/index.mjs +4 -0
- package/dist/esm/formatting/infer-json-indent.mjs +16 -0
- package/dist/esm/formatting/infer-json-indent.spec.mjs +46 -0
- package/dist/esm/formatting/sync-results-to-md.mjs +52 -0
- package/dist/esm/formatting/sync-results-to-md.spec.mjs +41 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/load-plugin.mjs +40 -0
- package/dist/esm/match.mjs +40 -0
- package/dist/esm/match.spec.mjs +71 -0
- package/dist/esm/merge-file.mjs +88 -0
- package/dist/esm/merge-file.spec.mjs +504 -0
- package/dist/esm/plugins/index.mjs +10 -0
- package/dist/esm/plugins/json-merge.mjs +164 -0
- package/dist/esm/plugins/json-merge.spec.mjs +469 -0
- package/dist/esm/ref-drivers/git-current-ref.mjs +8 -0
- package/dist/esm/ref-drivers/git-current-ref.spec.mjs +11 -0
- package/dist/esm/ref-drivers/index.mjs +3 -0
- package/dist/esm/ref-drivers/types.mjs +8 -0
- package/dist/esm/template-sync.mjs +174 -0
- package/dist/esm/template-sync.spec.mjs +517 -0
- package/dist/esm/test-utils/index.mjs +10 -0
- package/dist/esm/types.mjs +9 -0
- package/{lib/cjs → dist/types}/checkout-drivers/git-checkout.d.ts +1 -0
- package/dist/types/checkout-drivers/git-checkout.d.ts.map +1 -0
- package/dist/types/checkout-drivers/git-checkout.spec.d.ts +2 -0
- package/dist/types/checkout-drivers/git-checkout.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/checkout-drivers/index.d.ts +1 -0
- package/dist/types/checkout-drivers/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/checkout-drivers/types.d.ts +1 -0
- package/dist/types/checkout-drivers/types.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/clone-drivers/git-clone.d.ts +2 -1
- package/dist/types/clone-drivers/git-clone.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/clone-drivers/index.d.ts +2 -1
- package/dist/types/clone-drivers/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/clone-drivers/types.d.ts +1 -0
- package/dist/types/clone-drivers/types.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/diff-drivers/git-diff.d.ts +1 -0
- package/dist/types/diff-drivers/git-diff.d.ts.map +1 -0
- package/dist/types/diff-drivers/git-diff.spec.d.ts +2 -0
- package/dist/types/diff-drivers/git-diff.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/diff-drivers/index.d.ts +2 -1
- package/dist/types/diff-drivers/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/diff-drivers/types.d.ts +1 -0
- package/dist/types/diff-drivers/types.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/formatting/index.d.ts +2 -1
- package/dist/types/formatting/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/formatting/infer-json-indent.d.ts +1 -0
- package/dist/types/formatting/infer-json-indent.d.ts.map +1 -0
- package/dist/types/formatting/infer-json-indent.spec.d.ts +2 -0
- package/dist/types/formatting/infer-json-indent.spec.d.ts.map +1 -0
- package/dist/types/formatting/sync-results-to-md.d.ts +3 -0
- package/dist/types/formatting/sync-results-to-md.d.ts.map +1 -0
- package/dist/types/formatting/sync-results-to-md.spec.d.ts +2 -0
- package/dist/types/formatting/sync-results-to-md.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/load-plugin.d.ts +2 -1
- package/dist/types/load-plugin.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/match.d.ts +1 -0
- package/dist/types/match.d.ts.map +1 -0
- package/dist/types/match.spec.d.ts +2 -0
- package/dist/types/match.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/merge-file.d.ts +3 -2
- package/dist/types/merge-file.d.ts.map +1 -0
- package/dist/types/merge-file.spec.d.ts +2 -0
- package/dist/types/merge-file.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/plugins/index.d.ts +2 -1
- package/dist/types/plugins/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/plugins/json-merge.d.ts +2 -1
- package/dist/types/plugins/json-merge.d.ts.map +1 -0
- package/dist/types/plugins/json-merge.spec.d.ts +2 -0
- package/dist/types/plugins/json-merge.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/ref-drivers/git-current-ref.d.ts +1 -0
- package/dist/types/ref-drivers/git-current-ref.d.ts.map +1 -0
- package/dist/types/ref-drivers/git-current-ref.spec.d.ts +2 -0
- package/dist/types/ref-drivers/git-current-ref.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/ref-drivers/index.d.ts +1 -0
- package/dist/types/ref-drivers/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/ref-drivers/types.d.ts +1 -0
- package/dist/types/ref-drivers/types.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/template-sync.d.ts +6 -5
- package/dist/types/template-sync.d.ts.map +1 -0
- package/dist/types/template-sync.spec.d.ts +2 -0
- package/dist/types/template-sync.spec.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/test-utils/index.d.ts +1 -0
- package/dist/types/test-utils/index.d.ts.map +1 -0
- package/{lib/cjs → dist/types}/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +26 -23
- package/.eslintrc.js +0 -10
- package/.github/CODEOWNERS +0 -6
- package/.github/workflows/pr-checks.yaml +0 -12
- package/.github/workflows/release.yaml +0 -47
- package/.github/workflows/test-flow.yaml +0 -63
- package/.husky/commit-msg +0 -4
- package/.prettierignore +0 -1
- package/.prettierrc +0 -1
- package/action.yml +0 -13
- package/commitlint.config.js +0 -3
- package/docs/merge-plugins/CURRENT_PLUGINS.md +0 -168
- package/docs/merge-plugins/PLUGIN_DEVELOPMENT.md +0 -122
- package/docs/merge-plugins/README.md +0 -75
- package/jest.config.js +0 -19
- package/lib/cjs/checkout-drivers/git-checkout.js +0 -29
- package/lib/cjs/checkout-drivers/index.js +0 -18
- package/lib/cjs/checkout-drivers/types.js +0 -2
- package/lib/cjs/clone-drivers/git-clone.js +0 -17
- package/lib/cjs/clone-drivers/index.js +0 -18
- package/lib/cjs/clone-drivers/types.js +0 -2
- package/lib/cjs/diff-drivers/git-diff.js +0 -41
- package/lib/cjs/diff-drivers/index.js +0 -18
- package/lib/cjs/diff-drivers/types.js +0 -2
- package/lib/cjs/formatting/index.js +0 -18
- package/lib/cjs/formatting/infer-json-indent.js +0 -18
- package/lib/cjs/formatting/sync-results-to-md.d.ts +0 -2
- package/lib/cjs/formatting/sync-results-to-md.js +0 -57
- package/lib/cjs/index.js +0 -19
- package/lib/cjs/load-plugin.js +0 -69
- package/lib/cjs/match.js +0 -45
- package/lib/cjs/merge-file.js +0 -98
- package/lib/cjs/plugins/index.js +0 -11
- package/lib/cjs/plugins/json-merge.js +0 -208
- package/lib/cjs/ref-drivers/git-current-ref.js +0 -12
- package/lib/cjs/ref-drivers/index.js +0 -17
- package/lib/cjs/ref-drivers/types.js +0 -2
- package/lib/cjs/template-sync.js +0 -163
- package/lib/cjs/test-utils/index.js +0 -10
- package/lib/cjs/types.js +0 -2
- package/lib/esm/checkout-drivers/git-checkout.js +0 -29
- package/lib/esm/checkout-drivers/index.js +0 -18
- package/lib/esm/checkout-drivers/types.js +0 -2
- package/lib/esm/clone-drivers/git-clone.js +0 -17
- package/lib/esm/clone-drivers/index.js +0 -18
- package/lib/esm/clone-drivers/types.js +0 -2
- package/lib/esm/diff-drivers/git-diff.js +0 -41
- package/lib/esm/diff-drivers/index.js +0 -18
- package/lib/esm/diff-drivers/types.js +0 -2
- package/lib/esm/formatting/index.js +0 -18
- package/lib/esm/formatting/infer-json-indent.js +0 -18
- package/lib/esm/formatting/sync-results-to-md.js +0 -57
- package/lib/esm/index.js +0 -19
- package/lib/esm/load-plugin.js +0 -46
- package/lib/esm/match.js +0 -45
- package/lib/esm/merge-file.js +0 -98
- package/lib/esm/plugins/index.js +0 -11
- package/lib/esm/plugins/json-merge.js +0 -208
- package/lib/esm/ref-drivers/git-current-ref.js +0 -12
- package/lib/esm/ref-drivers/index.js +0 -17
- package/lib/esm/ref-drivers/types.js +0 -2
- package/lib/esm/template-sync.js +0 -163
- package/lib/esm/test-utils/index.js +0 -10
- package/lib/esm/types.js +0 -2
- package/release.config.js +0 -40
- package/src/checkout-drivers/git-checkout.spec.ts +0 -69
- package/src/checkout-drivers/git-checkout.ts +0 -38
- package/src/checkout-drivers/index.ts +0 -2
- package/src/checkout-drivers/types.ts +0 -14
- package/src/clone-drivers/git-clone.ts +0 -20
- package/src/clone-drivers/index.ts +0 -2
- package/src/clone-drivers/types.ts +0 -20
- package/src/diff-drivers/git-diff.spec.ts +0 -73
- package/src/diff-drivers/git-diff.ts +0 -39
- package/src/diff-drivers/index.ts +0 -2
- package/src/diff-drivers/types.ts +0 -14
- package/src/formatting/__snapshots__/sync-results-to-md.spec.ts.snap +0 -39
- package/src/formatting/index.ts +0 -2
- package/src/formatting/infer-json-indent.spec.ts +0 -49
- package/src/formatting/infer-json-indent.ts +0 -16
- package/src/formatting/sync-results-to-md.spec.ts +0 -31
- package/src/formatting/sync-results-to-md.ts +0 -63
- package/src/index.ts +0 -3
- package/src/load-plugin.ts +0 -51
- package/src/match.spec.ts +0 -68
- package/src/match.ts +0 -52
- package/src/merge-file.spec.ts +0 -506
- package/src/merge-file.ts +0 -154
- package/src/plugins/index.ts +0 -12
- package/src/plugins/json-merge.spec.ts +0 -436
- package/src/plugins/json-merge.ts +0 -215
- package/src/ref-drivers/git-current-ref.spec.ts +0 -12
- package/src/ref-drivers/git-current-ref.ts +0 -9
- package/src/ref-drivers/index.ts +0 -1
- package/src/ref-drivers/types.ts +0 -10
- package/src/template-sync.spec.ts +0 -509
- package/src/template-sync.ts +0 -256
- package/src/test-utils/index.ts +0 -13
- package/src/types.ts +0 -129
- package/templatesync.local.json +0 -15
- package/test-fixtures/downstream/README.md +0 -3
- package/test-fixtures/downstream/package.json +0 -18
- package/test-fixtures/downstream/plugins/custom-plugin.js +0 -11
- package/test-fixtures/downstream/src/index.js +0 -2
- package/test-fixtures/downstream/src/index.ts +0 -1
- package/test-fixtures/downstream/src/templated.js +0 -2
- package/test-fixtures/downstream/src/templated.ts +0 -1
- package/test-fixtures/downstream/templatesync.json +0 -16
- package/test-fixtures/downstream/templatesync.local.json +0 -10
- package/test-fixtures/dummy-plugin.js +0 -8
- package/test-fixtures/glob-test/folder1/something.js +0 -1
- package/test-fixtures/glob-test/folder1/something.ts +0 -0
- package/test-fixtures/glob-test/toplevel.js +0 -0
- package/test-fixtures/glob-test/toplevel.txt +0 -0
- package/test-fixtures/template/custom-bin/something.txt +0 -1
- package/test-fixtures/template/package.json +0 -17
- package/test-fixtures/template/src/index.js +0 -2
- package/test-fixtures/template/src/index.ts +0 -1
- package/test-fixtures/template/src/templated.js +0 -2
- package/test-fixtures/template/src/templated.ts +0 -1
- package/test-fixtures/template/templatesync.json +0 -16
- package/test-fixtures/testGitRepo/README.md +0 -17
- package/test-fixtures/testGitRepo/gitDir/COMMIT_EDITMSG +0 -14
- package/test-fixtures/testGitRepo/gitDir/HEAD +0 -1
- package/test-fixtures/testGitRepo/gitDir/config +0 -7
- package/test-fixtures/testGitRepo/gitDir/description +0 -1
- package/test-fixtures/testGitRepo/gitDir/hooks/applypatch-msg.sample +0 -15
- package/test-fixtures/testGitRepo/gitDir/hooks/commit-msg.sample +0 -24
- package/test-fixtures/testGitRepo/gitDir/hooks/fsmonitor-watchman.sample +0 -174
- package/test-fixtures/testGitRepo/gitDir/hooks/post-update.sample +0 -8
- package/test-fixtures/testGitRepo/gitDir/hooks/pre-applypatch.sample +0 -14
- package/test-fixtures/testGitRepo/gitDir/hooks/pre-commit.sample +0 -49
- package/test-fixtures/testGitRepo/gitDir/hooks/pre-merge-commit.sample +0 -13
- package/test-fixtures/testGitRepo/gitDir/hooks/pre-push.sample +0 -53
- package/test-fixtures/testGitRepo/gitDir/hooks/pre-rebase.sample +0 -169
- package/test-fixtures/testGitRepo/gitDir/hooks/pre-receive.sample +0 -24
- package/test-fixtures/testGitRepo/gitDir/hooks/prepare-commit-msg.sample +0 -42
- package/test-fixtures/testGitRepo/gitDir/hooks/push-to-checkout.sample +0 -78
- package/test-fixtures/testGitRepo/gitDir/hooks/sendemail-validate.sample +0 -77
- package/test-fixtures/testGitRepo/gitDir/hooks/update.sample +0 -128
- package/test-fixtures/testGitRepo/gitDir/index +0 -0
- package/test-fixtures/testGitRepo/gitDir/info/exclude +0 -6
- package/test-fixtures/testGitRepo/gitDir/logs/HEAD +0 -5
- package/test-fixtures/testGitRepo/gitDir/logs/refs/heads/master +0 -2
- package/test-fixtures/testGitRepo/gitDir/logs/refs/heads/test-branch +0 -2
- package/test-fixtures/testGitRepo/gitDir/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- package/test-fixtures/testGitRepo/gitDir/objects/6e/187bee8d02f39d0a1be8331dd8fe6a00c9b613 +0 -0
- package/test-fixtures/testGitRepo/gitDir/objects/73/185f1f3f5a6345e087d9f46dc4af77cc59449f +0 -2
- package/test-fixtures/testGitRepo/gitDir/objects/90/e7ea1089f939840e9649fd617584c1ad117159 +0 -3
- package/test-fixtures/testGitRepo/gitDir/objects/ba/99a452b9097047e9bfa8d5a08b3e452fcb364a +0 -0
- package/test-fixtures/testGitRepo/gitDir/objects/c5/8d400177cd5180b8566f82a127fafc5bf394b7 +0 -0
- package/test-fixtures/testGitRepo/gitDir/objects/e2/e668265db019249a7e8296d85f79000e3d71cf +0 -0
- package/test-fixtures/testGitRepo/gitDir/objects/e4/243e430c1ab69f3e344249f5b1859e90abc883 +0 -1
- package/test-fixtures/testGitRepo/gitDir/objects/ec/6c1cb72312605282ac61858cf1eaf1ea9f1d02 +0 -0
- package/test-fixtures/testGitRepo/gitDir/objects/fc/89cecc4ac0b5b075bd7d0ce9e09b2f50598b82 +0 -0
- package/test-fixtures/testGitRepo/gitDir/refs/heads/master +0 -1
- package/test-fixtures/testGitRepo/gitDir/refs/heads/test-branch +0 -1
- package/tsconfig.cjs.json +0 -12
- package/tsconfig.esm.json +0 -10
- package/tsconfig.json +0 -22
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# Current Merge Plugins
|
|
2
|
-
|
|
3
|
-
This document lists all merge plugins that are provided as defaults for certain file extensions.
|
|
4
|
-
These should be found in the [plugins folder](src/plugins)
|
|
5
|
-
|
|
6
|
-
- [Current Merge Plugins](#current-merge-plugins)
|
|
7
|
-
- [Json Merge Plugin](#json-merge-plugin)
|
|
8
|
-
- [Configuration Options:](#configuration-options)
|
|
9
|
-
- [Simple merge spec](#simple-merge-spec)
|
|
10
|
-
- [JsonPath config](#jsonpath-config)
|
|
11
|
-
- [Example](#example)
|
|
12
|
-
- [About Comments](#about-comments)
|
|
13
|
-
|
|
14
|
-
<!-- Created with Markdown All In One VsCode Extension -->
|
|
15
|
-
|
|
16
|
-
## Json Merge Plugin
|
|
17
|
-
|
|
18
|
-
The json merge plugin allows you to configure jsonpath based merges on any .json file.
|
|
19
|
-
|
|
20
|
-
Plugin Field Name: `_json`
|
|
21
|
-
|
|
22
|
-
## Configuration Options:
|
|
23
|
-
|
|
24
|
-
### Simple merge spec
|
|
25
|
-
|
|
26
|
-
At it's simplest, you can take advantage of lodash merge behavior by just specifying one of:
|
|
27
|
-
|
|
28
|
-
- overwrite - the template completely overwrites the file
|
|
29
|
-
- merge-template - keys are merged together with the template overwriting any matching keys on local file
|
|
30
|
-
- merge-current - keys are merged together with the local file keeping any keys that match in the template
|
|
31
|
-
|
|
32
|
-
Example config:
|
|
33
|
-
|
|
34
|
-
```json
|
|
35
|
-
{
|
|
36
|
-
"merge": {
|
|
37
|
-
".json": {
|
|
38
|
-
"rules": [
|
|
39
|
-
{
|
|
40
|
-
"glob": "metadata.json",
|
|
41
|
-
"options": "merge-template"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"glob": "template-lock.json",
|
|
45
|
-
"options": "overwrite"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"glob": "package.json",
|
|
49
|
-
"options": "merge-current"
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### JsonPath config
|
|
58
|
-
|
|
59
|
-
If you would like further control over what merges within a .json file, you can actually specify, via way of jsonpath operators,
|
|
60
|
-
the level of merge per field.
|
|
61
|
-
|
|
62
|
-
A few rules:
|
|
63
|
-
|
|
64
|
-
- Once you have provided jsonpath options, only the json path options (or new fields if the option is enabled) will be merged
|
|
65
|
-
- jsonpaths are run from first to last. This means you can layer merges.
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
interface Options {
|
|
69
|
-
/**
|
|
70
|
-
* If set to true, this means we won't add new properties from the template
|
|
71
|
-
*/
|
|
72
|
-
ignoreNewProperties?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* If set to true, overwrite will apply undefined values as deleted for the jsonpaths
|
|
75
|
-
* or for values that are supposed to be merged on top of other values
|
|
76
|
-
*/
|
|
77
|
-
missingIsDelete?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Note, if multiple json paths match a rule, we pick the first one in the list that matches
|
|
80
|
-
*/
|
|
81
|
-
paths: /**
|
|
82
|
-
* We only override jsonpaths. Anything not specified is kept the same.
|
|
83
|
-
*/
|
|
84
|
-
[jsonPath: `$.${string}`, options: BaseJsonMergeOptions][];
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
#### Example
|
|
89
|
-
|
|
90
|
-
```json
|
|
91
|
-
{
|
|
92
|
-
"merge": {
|
|
93
|
-
".json": {
|
|
94
|
-
"rules": [
|
|
95
|
-
{
|
|
96
|
-
"glob": "metadata.json",
|
|
97
|
-
"options": {
|
|
98
|
-
"ignoreNewProperties": false,
|
|
99
|
-
"missingIsDelete:": true,
|
|
100
|
-
"paths": [
|
|
101
|
-
["$.path", "template-merge"] // if we delete path in the template, it will delete the path
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"glob": "template-lock.json",
|
|
107
|
-
"options": "overwrite"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"glob": "package.json",
|
|
111
|
-
"options": {
|
|
112
|
-
"ignoreNewProperties": false,
|
|
113
|
-
"paths": [
|
|
114
|
-
["$.scripts.*", "template-merge"],
|
|
115
|
-
["$.scripts.specific-script", "template-currrent"] // We end up keeping the current template
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### About Comments
|
|
126
|
-
|
|
127
|
-
There are numerous json files that support comments now; tsconfig.json is a prime example of this. In order to support this,
|
|
128
|
-
this library makes use of comment-json for parsing and stringifying. This means that, minimally, you will not run into errors
|
|
129
|
-
when merging commented json files (and that you can comment on your templatesync config files).
|
|
130
|
-
|
|
131
|
-
One thing to note however, is that only include comments from the template if they are inside of an object that is being merged.
|
|
132
|
-
This is because this plugin has not yet defined a good configuration for merging comments. If you run into a pertinent need for this,
|
|
133
|
-
please feel free to open an issue and potentially contribute a fix in a PR.
|
|
134
|
-
|
|
135
|
-
Example of comment merging:
|
|
136
|
-
|
|
137
|
-
```json
|
|
138
|
-
// In template
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
// I have a comment here
|
|
142
|
-
"newField": 44,
|
|
143
|
-
"overridingField": {
|
|
144
|
-
// Comment in here
|
|
145
|
-
"value": "v",
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// In the extending repo
|
|
150
|
-
{
|
|
151
|
-
// My custom comment
|
|
152
|
-
"newField": 88,
|
|
153
|
-
"overridingField": 66
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// After merging with template-merge
|
|
157
|
-
{
|
|
158
|
-
// My custom comment
|
|
159
|
-
"newField": 44,
|
|
160
|
-
"overridingField": {
|
|
161
|
-
// Comment in here
|
|
162
|
-
"value": "v",
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
From the above example, you can see that we specifically keep as many of the comments as possible from the extending repo
|
|
168
|
-
and only the comment that was fully nested inside new value that we were adding was kept.
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# Plugin Development
|
|
2
|
-
|
|
3
|
-
- [Plugin Development](#plugin-development)
|
|
4
|
-
- [Example: hello \<world\>](#example-hello-world)
|
|
5
|
-
- [Example one: local file](#example-one-local-file)
|
|
6
|
-
- [Example two: npm package](#example-two-npm-package)
|
|
7
|
-
|
|
8
|
-
The templatesync.json and templatesync.local.config files make use of a `"merge"` property where you can
|
|
9
|
-
customize the baseline behavior of ignore or overwrite from template.
|
|
10
|
-
|
|
11
|
-
This library provides a set of typescript types for you to create additional plugins.
|
|
12
|
-
|
|
13
|
-
At the core of it, you need to have a file or npm package that exposes the interface:
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
export interface MergePlugin<PluginOptions> {
|
|
17
|
-
/**
|
|
18
|
-
* This method will be called when a file from the template and it's analog in the downstream repo
|
|
19
|
-
* have some differences. The plugin must perform the merge and return the appropriate file contents
|
|
20
|
-
* as a string
|
|
21
|
-
*
|
|
22
|
-
* TODO: we may create a V2 plugin that could deal with large files and not pass around strings in memory,
|
|
23
|
-
* but for now, this is the current implementation
|
|
24
|
-
*
|
|
25
|
-
* @param current - The downstream repo's current file contents
|
|
26
|
-
* @param fromTemplateRepo - the current
|
|
27
|
-
* @param context - an object defining the context around the file and the specific options
|
|
28
|
-
*/
|
|
29
|
-
merge(
|
|
30
|
-
current: string,
|
|
31
|
-
fromTemplateRepo: string,
|
|
32
|
-
context: MergeContext<PluginOptions>,
|
|
33
|
-
): Promise<string>;
|
|
34
|
-
/**
|
|
35
|
-
* Given an options object for the merge, this validates the options object and returns error messages if there is anything wrong.
|
|
36
|
-
* @param options any json value that the user provided - must be validated against the expected options
|
|
37
|
-
*/
|
|
38
|
-
validate(options: unknown): string[] | undefined;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Example: hello \<world>
|
|
43
|
-
|
|
44
|
-
So let's say that we want to have a plugin that will take every file assigned to it, and just write hello {world} instead.
|
|
45
|
-
(Not much of a merge, but so it goes)
|
|
46
|
-
|
|
47
|
-
We will define and export an options object, validate function, and merge function
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
// src/hello-plugin.ts
|
|
51
|
-
import { MergePlugin, MergeContext } from '@hanseltime/template-repo-sync'
|
|
52
|
-
|
|
53
|
-
export interface HelloOptions: {
|
|
54
|
-
/** the name of the world we're greeting */
|
|
55
|
-
world: string
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const validate: MergePlugin<HelloOptions>['validate'] = (options: unknown) => {
|
|
59
|
-
const errors: string[] = [];
|
|
60
|
-
// In our case, we have decided you HAVE to use an object
|
|
61
|
-
if (typeof options !== 'object') {
|
|
62
|
-
errors.push('must provide an object');
|
|
63
|
-
return errors;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// make sure there aren't extra keys
|
|
67
|
-
const { world, ...rest } = options;
|
|
68
|
-
const unknownKeys = Object.keys(rest);
|
|
69
|
-
if (unknownKeys.length > 0 ) {
|
|
70
|
-
errors.push(`Unexpected options keys: ${unknownKeys.join(' ')}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!world) {
|
|
74
|
-
errors.push(`Must provide a valid world value`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return errors
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const merge: MergePlugin<HelloOptions>['merge'] = async (current, fromTemplateRepo, options: HelloOptions) => {
|
|
81
|
-
// Note, we don't use the current with this simple plugin, but we would use the first 2 args normally
|
|
82
|
-
return `Hello ${options.world}`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
With all of that set up, as long as we have the package available to the pacakge manager running our script, we can use it:
|
|
88
|
-
|
|
89
|
-
### Example one: local file
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
{
|
|
93
|
-
"merge": [
|
|
94
|
-
{
|
|
95
|
-
"glob": "**/*.txt",
|
|
96
|
-
"plugin": "dist/hello-plugin.js",
|
|
97
|
-
"options": {
|
|
98
|
-
"world": "chad"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Example two: npm package
|
|
106
|
-
|
|
107
|
-
Let's assume that you published this as an npm package to @myscope/hello-merge. Once you have install the pacakge to the project, you can
|
|
108
|
-
simply reference the package (assuming that it exposes the required functions as it's index file).
|
|
109
|
-
|
|
110
|
-
```json
|
|
111
|
-
{
|
|
112
|
-
"merge": [
|
|
113
|
-
{
|
|
114
|
-
"glob": "**/*.txt",
|
|
115
|
-
"plugin": "@myscope/hello-merge",
|
|
116
|
-
"options": {
|
|
117
|
-
"world": "chad"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
```
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# Merge Plugins
|
|
2
|
-
|
|
3
|
-
The templatesync.json and templatesync.local.config files make use of a `"merge"` property where you can
|
|
4
|
-
customize the baseline behavior of just ignoring or overwriting from the template.
|
|
5
|
-
|
|
6
|
-
# Example Use Case
|
|
7
|
-
|
|
8
|
-
One example of this behavior is around an npm package.json. If you were making a template for a particular
|
|
9
|
-
set of boilerplate for an npm package, you would probably provide an example package.json like:
|
|
10
|
-
|
|
11
|
-
```json
|
|
12
|
-
{
|
|
13
|
-
"name": "<fill in your package name",
|
|
14
|
-
"description": "<fill in your package description",
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsc",
|
|
18
|
-
"publish": "our-artifact-script"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"typescript": "^5.0.0",
|
|
22
|
-
"our-artifact-package": "^1.0.0"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
In this scenario, we expect the template user to declare their own `name` and `description`, and add their own
|
|
28
|
-
`scripts` and `devDependencies`. However, we are hoping to make sure that the publish method and and its
|
|
29
|
-
our-artifact-package are kept up-to-date on syncs. Because of this, we would make use of the built-in json merge
|
|
30
|
-
plugin `_json` that is provided with this library:
|
|
31
|
-
|
|
32
|
-
```json
|
|
33
|
-
{
|
|
34
|
-
"merge": [
|
|
35
|
-
{
|
|
36
|
-
"glob": "package.json",
|
|
37
|
-
"plugin": "_json",
|
|
38
|
-
"options": {
|
|
39
|
-
"paths": [
|
|
40
|
-
["$.scripts.publish", "merge-template"], // Any changes to publish are so critical that we want them to sync
|
|
41
|
-
["$.devDependencies", "merge-template"] // Always ensure dev dependency versions for our scripts are updated
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
As a repo maintainer, we can be sure that when people sync from our repo in its current state, the publish script
|
|
50
|
-
and devDependency should be synced from package.json, without anything else!
|
|
51
|
-
|
|
52
|
-
## What if the repo extender is annoyed?
|
|
53
|
-
|
|
54
|
-
If the repo extender already made the decision to update the publish method for a good reason, they may find it
|
|
55
|
-
tedious to constantly get their publish script overwritten and then have to undo it. Due to the local
|
|
56
|
-
config file, they can specify their own merge configuration for the package.json.
|
|
57
|
-
|
|
58
|
-
```json
|
|
59
|
-
{
|
|
60
|
-
"merge": [
|
|
61
|
-
{
|
|
62
|
-
"glob": "package.json",
|
|
63
|
-
"plugin": "_json",
|
|
64
|
-
"paths": [
|
|
65
|
-
["$.devDependencies", "merge-template"] // Always ensure dev dependency versions for our scripts are updated
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
This configuration will now override the template repo's merge and only allow devDependencies to be updated. We report
|
|
73
|
-
this override as part of the output of the sync call, and for things like our
|
|
74
|
-
[github action](https://github.com/HanseltimeIndustries/template-repo-sync-action), we format that output into the PR
|
|
75
|
-
that is opened up when performing a sync.
|
package/jest.config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: "ts-jest",
|
|
3
|
-
testEnvironment: "node",
|
|
4
|
-
roots: ["<rootDir>/src"],
|
|
5
|
-
transform: {
|
|
6
|
-
"\\.tsx?$": "ts-jest",
|
|
7
|
-
"\\.jsx?$": "babel-jest",
|
|
8
|
-
},
|
|
9
|
-
collectCoverage: true,
|
|
10
|
-
collectCoverageFrom: ["./src/**"],
|
|
11
|
-
coverageThreshold: {
|
|
12
|
-
global: {
|
|
13
|
-
branches: 77,
|
|
14
|
-
functions: 80,
|
|
15
|
-
// Lines can get skewed by bucket files
|
|
16
|
-
statements: 80,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitCheckout = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
async function gitCheckout(options) {
|
|
6
|
-
const { branch, remoteName, tmpDir } = options;
|
|
7
|
-
const remoteInfo = (0, child_process_1.execSync)(`git remote show ${remoteName}`, {
|
|
8
|
-
cwd: tmpDir,
|
|
9
|
-
env: process.env,
|
|
10
|
-
}).toString();
|
|
11
|
-
const defaultMatch = /HEAD branch:\s*([a-zA-Z0-9_-]+)/.exec(remoteInfo);
|
|
12
|
-
if (!defaultMatch || !defaultMatch[1]) {
|
|
13
|
-
throw new Error(`Could not determine default branch of cloned repo.\nAttempted to find in remote info:\n${remoteInfo} `);
|
|
14
|
-
}
|
|
15
|
-
const defaultBranch = defaultMatch[1];
|
|
16
|
-
// Skip this if the default branch is already pulled
|
|
17
|
-
if (defaultBranch !== branch) {
|
|
18
|
-
(0, child_process_1.execSync)(`git fetch ${remoteName} ${branch}`, {
|
|
19
|
-
cwd: tmpDir,
|
|
20
|
-
env: process.env,
|
|
21
|
-
});
|
|
22
|
-
(0, child_process_1.execSync)(`git checkout -b ${branch} --track ${remoteName}/${branch}`, {
|
|
23
|
-
cwd: tmpDir,
|
|
24
|
-
env: process.env,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
exports.gitCheckout = gitCheckout;
|
|
@@ -1,18 +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-checkout"), exports);
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitClone = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const CLONE_DIR = "cloned_repo";
|
|
7
|
-
async function gitClone(tmpDir, repoUrl) {
|
|
8
|
-
(0, child_process_1.execSync)(`git clone ${repoUrl} ${CLONE_DIR}`, {
|
|
9
|
-
cwd: tmpDir,
|
|
10
|
-
env: process.env,
|
|
11
|
-
});
|
|
12
|
-
return {
|
|
13
|
-
dir: (0, path_1.resolve)(tmpDir, CLONE_DIR),
|
|
14
|
-
remoteName: "origin",
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
exports.gitClone = gitClone;
|
|
@@ -1,18 +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("./types"), exports);
|
|
18
|
-
__exportStar(require("./git-clone"), exports);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitDiff = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
|
-
/**
|
|
6
|
-
* For a given directory with a git configuration, this will return the modified, added, and
|
|
7
|
-
* deleted files since the last afterRef
|
|
8
|
-
* @param gitDir The git directory folder
|
|
9
|
-
* @param afterRef The git ref to look for diffs after
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
async function gitDiff(gitDir, afterRef) {
|
|
13
|
-
const baseCommand = `git diff ${afterRef}.. --no-renames --name-only`;
|
|
14
|
-
const modifiedFiles = (0, child_process_1.execSync)(`${baseCommand} --diff-filter=M`, {
|
|
15
|
-
cwd: gitDir,
|
|
16
|
-
})
|
|
17
|
-
.toString()
|
|
18
|
-
.trim()
|
|
19
|
-
.split("\n")
|
|
20
|
-
.filter((s) => s !== "");
|
|
21
|
-
const addedFiles = (0, child_process_1.execSync)(`${baseCommand} --diff-filter=A`, {
|
|
22
|
-
cwd: gitDir,
|
|
23
|
-
})
|
|
24
|
-
.toString()
|
|
25
|
-
.trim()
|
|
26
|
-
.split("\n")
|
|
27
|
-
.filter((s) => s !== "");
|
|
28
|
-
const deletedFiles = (0, child_process_1.execSync)(`${baseCommand} --diff-filter=D`, {
|
|
29
|
-
cwd: gitDir,
|
|
30
|
-
})
|
|
31
|
-
.toString()
|
|
32
|
-
.trim()
|
|
33
|
-
.split("\n")
|
|
34
|
-
.filter((s) => s !== "");
|
|
35
|
-
return {
|
|
36
|
-
modified: modifiedFiles,
|
|
37
|
-
added: addedFiles,
|
|
38
|
-
deleted: deletedFiles,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
exports.gitDiff = gitDiff;
|
|
@@ -1,18 +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("./types"), exports);
|
|
18
|
-
__exportStar(require("./git-diff"), exports);
|
|
@@ -1,18 +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("./sync-results-to-md"), exports);
|
|
18
|
-
__exportStar(require("./infer-json-indent"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inferJSONIndent = void 0;
|
|
4
|
-
const spacingRegex = /[{[]\n?(?<spacing>\s+)["tf\d]/;
|
|
5
|
-
function inferJSONIndent(rawJSON) {
|
|
6
|
-
const match = spacingRegex.exec(rawJSON);
|
|
7
|
-
if (!match?.groups?.spacing) {
|
|
8
|
-
// eslint-disable-next-line no-console
|
|
9
|
-
console.warn(`Could not find json indentation for json string: ${rawJSON.slice(40)} ... \nDefaulting to 4 spaces`);
|
|
10
|
-
// Four spaces
|
|
11
|
-
return " ";
|
|
12
|
-
}
|
|
13
|
-
const spacing = match.groups.spacing;
|
|
14
|
-
// Handle the case where there were multiple newlines before a value
|
|
15
|
-
const lastNewLine = spacing.lastIndexOf("\n");
|
|
16
|
-
return match?.groups.spacing.slice(lastNewLine >= 0 ? lastNewLine + 1 : 0);
|
|
17
|
-
}
|
|
18
|
-
exports.inferJSONIndent = inferJSONIndent;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.syncResultsToMd = void 0;
|
|
4
|
-
const template_sync_1 = require("../template-sync");
|
|
5
|
-
function syncResultsToMd(result) {
|
|
6
|
-
return `# ${template_sync_1.TEMPLATE_SYNC_LOCAL_CONFIG}
|
|
7
|
-
|
|
8
|
-
## Stopped the following files from syncing:
|
|
9
|
-
|
|
10
|
-
${result.localSkipFiles.reduce((s, file) => {
|
|
11
|
-
return `${s}* ${file}\n`;
|
|
12
|
-
}, "")}
|
|
13
|
-
|
|
14
|
-
## Changed the following files from what they would have synced:
|
|
15
|
-
|
|
16
|
-
${Object.keys(result.localFileChanges).reduce((s, file) => {
|
|
17
|
-
return `${s}${file}
|
|
18
|
-
\`\`\`diff
|
|
19
|
-
${result.localFileChanges[file].reduce((diffS, change) => {
|
|
20
|
-
return `${diffS}\n${makeChangeIntoDiffLines(change)}`;
|
|
21
|
-
}, "")}
|
|
22
|
-
\`\`\``;
|
|
23
|
-
}, "")}
|
|
24
|
-
|
|
25
|
-
## Files Modified (${result.modifiedFiles.total})
|
|
26
|
-
|
|
27
|
-
Added:
|
|
28
|
-
${result.modifiedFiles.added.reduce((s, f) => {
|
|
29
|
-
return `${s}\n- ${f}`;
|
|
30
|
-
}, "")}
|
|
31
|
-
|
|
32
|
-
Modified:
|
|
33
|
-
${result.modifiedFiles.modified.reduce((s, f) => {
|
|
34
|
-
return `${s}\n- ${f}`;
|
|
35
|
-
}, "")}
|
|
36
|
-
|
|
37
|
-
Deleted:
|
|
38
|
-
${result.modifiedFiles.deleted.reduce((s, f) => {
|
|
39
|
-
return `${s}\n- ${f}`;
|
|
40
|
-
}, "")}
|
|
41
|
-
`;
|
|
42
|
-
}
|
|
43
|
-
exports.syncResultsToMd = syncResultsToMd;
|
|
44
|
-
function makeChangeIntoDiffLines(change, nonchangeMax = 3) {
|
|
45
|
-
const operator = change.added ? "+" : change.removed ? "-" : "";
|
|
46
|
-
if (!operator &&
|
|
47
|
-
nonchangeMax > 0 &&
|
|
48
|
-
change.count &&
|
|
49
|
-
change.count > nonchangeMax) {
|
|
50
|
-
const lines = change.value.split("\n");
|
|
51
|
-
const partial = lines.slice(lines.length - nonchangeMax);
|
|
52
|
-
return `...\n${partial.join("\n")}\n`;
|
|
53
|
-
}
|
|
54
|
-
return change.value.split("\n").reduce((s, line) => {
|
|
55
|
-
return `${s}${operator}${line}\n`;
|
|
56
|
-
}, "");
|
|
57
|
-
}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,19 +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("./types"), exports);
|
|
18
|
-
__exportStar(require("./template-sync"), exports);
|
|
19
|
-
__exportStar(require("./formatting"), exports);
|