@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,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);
|
package/lib/esm/template-sync.js
DELETED
|
@@ -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
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,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,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,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
|
-
`;
|
package/src/formatting/index.ts
DELETED
|
@@ -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
|
-
}
|