@hanseltime/template-repo-sync 2.1.0 → 2.1.2
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 +14 -0
- package/lib/cjs/merge-file.js +6 -6
- package/lib/cjs/template-sync.js +5 -0
- package/lib/esm/merge-file.js +6 -6
- package/lib/esm/template-sync.js +5 -0
- package/package.json +1 -1
- package/src/merge-file.spec.ts +11 -11
- package/src/merge-file.ts +6 -6
- package/src/template-sync.spec.ts +1 -1
- package/src/template-sync.ts +12 -0
- package/test-fixtures/downstream/src/templated.js +1 -1
- package/test-fixtures/downstream/src/templated.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.1.2](https://github.com/HanseltimeIndustries/template-repo-sync/compare/v2.1.1...v2.1.2) (2026-02-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* afterref was skipping template ignores ([270b926](https://github.com/HanseltimeIndustries/template-repo-sync/commit/270b926983ddc7070c2099cfa8fa507d1b527233))
|
|
7
|
+
|
|
8
|
+
## [2.1.1](https://github.com/HanseltimeIndustries/template-repo-sync/compare/v2.1.0...v2.1.1) (2026-02-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* delete was not deleting the right file ([104e3ec](https://github.com/HanseltimeIndustries/template-repo-sync/commit/104e3ec8913c983f1d046bf19b197857e8016ff0))
|
|
14
|
+
|
|
1
15
|
# [2.1.0](https://github.com/HanseltimeIndustries/template-repo-sync/compare/v2.0.4...v2.1.0) (2026-02-08)
|
|
2
16
|
|
|
3
17
|
|
package/lib/cjs/merge-file.js
CHANGED
|
@@ -28,13 +28,13 @@ async function mergeFile(relPath, context) {
|
|
|
28
28
|
const templatePath = (0, path_1.join)(tempCloneDir, relPath);
|
|
29
29
|
// Unless there's a need, we remove files that were deleted and don't pass them to plugins yet
|
|
30
30
|
if (context.fileOperation === "deleted") {
|
|
31
|
-
if ((0, fs_1.existsSync)(
|
|
32
|
-
await (0, promises_1.rm)(
|
|
33
|
-
return {
|
|
34
|
-
ignoredDueToLocal: false,
|
|
35
|
-
localChanges: [],
|
|
36
|
-
};
|
|
31
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
32
|
+
await (0, promises_1.rm)(filePath);
|
|
37
33
|
}
|
|
34
|
+
return {
|
|
35
|
+
ignoredDueToLocal: false,
|
|
36
|
+
localChanges: [],
|
|
37
|
+
};
|
|
38
38
|
}
|
|
39
39
|
const mergeConfig = templateSyncConfig.merge?.find((mergeConfig) => (0, micromatch_1.isMatch)(relPath, mergeConfig.glob));
|
|
40
40
|
const localMergeConfig = localTemplateSyncConfig.merge?.find((mergeConfig) => (0, micromatch_1.isMatch)(relPath, mergeConfig.glob));
|
package/lib/cjs/template-sync.js
CHANGED
|
@@ -34,6 +34,7 @@ const ref_drivers_1 = require("./ref-drivers");
|
|
|
34
34
|
const formatting_1 = require("./formatting");
|
|
35
35
|
const commentJSON = __importStar(require("comment-json"));
|
|
36
36
|
const checkout_drivers_1 = require("./checkout-drivers");
|
|
37
|
+
const micromatch_1 = require("micromatch");
|
|
37
38
|
exports.TEMPLATE_SYNC_CONFIG = "templatesync";
|
|
38
39
|
exports.TEMPLATE_SYNC_LOCAL_CONFIG = "templatesync.local";
|
|
39
40
|
async function templateSync(options) {
|
|
@@ -78,6 +79,10 @@ async function templateSync(options) {
|
|
|
78
79
|
modified: [],
|
|
79
80
|
};
|
|
80
81
|
}
|
|
82
|
+
// Apply ignore filters
|
|
83
|
+
filesToSync.added = filesToSync.added.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
|
|
84
|
+
filesToSync.modified = filesToSync.modified.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
|
|
85
|
+
filesToSync.deleted = filesToSync.deleted.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
|
|
81
86
|
const localSkipFiles = [];
|
|
82
87
|
const localFileChanges = {};
|
|
83
88
|
const fileSyncFactory = (op) => {
|
package/lib/esm/merge-file.js
CHANGED
|
@@ -28,13 +28,13 @@ async function mergeFile(relPath, context) {
|
|
|
28
28
|
const templatePath = (0, path_1.join)(tempCloneDir, relPath);
|
|
29
29
|
// Unless there's a need, we remove files that were deleted and don't pass them to plugins yet
|
|
30
30
|
if (context.fileOperation === "deleted") {
|
|
31
|
-
if ((0, fs_1.existsSync)(
|
|
32
|
-
await (0, promises_1.rm)(
|
|
33
|
-
return {
|
|
34
|
-
ignoredDueToLocal: false,
|
|
35
|
-
localChanges: [],
|
|
36
|
-
};
|
|
31
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
32
|
+
await (0, promises_1.rm)(filePath);
|
|
37
33
|
}
|
|
34
|
+
return {
|
|
35
|
+
ignoredDueToLocal: false,
|
|
36
|
+
localChanges: [],
|
|
37
|
+
};
|
|
38
38
|
}
|
|
39
39
|
const mergeConfig = templateSyncConfig.merge?.find((mergeConfig) => (0, micromatch_1.isMatch)(relPath, mergeConfig.glob));
|
|
40
40
|
const localMergeConfig = localTemplateSyncConfig.merge?.find((mergeConfig) => (0, micromatch_1.isMatch)(relPath, mergeConfig.glob));
|
package/lib/esm/template-sync.js
CHANGED
|
@@ -34,6 +34,7 @@ const ref_drivers_1 = require("./ref-drivers");
|
|
|
34
34
|
const formatting_1 = require("./formatting");
|
|
35
35
|
const commentJSON = __importStar(require("comment-json"));
|
|
36
36
|
const checkout_drivers_1 = require("./checkout-drivers");
|
|
37
|
+
const micromatch_1 = require("micromatch");
|
|
37
38
|
exports.TEMPLATE_SYNC_CONFIG = "templatesync";
|
|
38
39
|
exports.TEMPLATE_SYNC_LOCAL_CONFIG = "templatesync.local";
|
|
39
40
|
async function templateSync(options) {
|
|
@@ -78,6 +79,10 @@ async function templateSync(options) {
|
|
|
78
79
|
modified: [],
|
|
79
80
|
};
|
|
80
81
|
}
|
|
82
|
+
// Apply ignore filters
|
|
83
|
+
filesToSync.added = filesToSync.added.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
|
|
84
|
+
filesToSync.modified = filesToSync.modified.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
|
|
85
|
+
filesToSync.deleted = filesToSync.deleted.filter((f) => !(0, micromatch_1.some)(f, templateSyncConfig.ignore));
|
|
81
86
|
const localSkipFiles = [];
|
|
82
87
|
const localFileChanges = {};
|
|
83
88
|
const fileSyncFactory = (op) => {
|
package/package.json
CHANGED
package/src/merge-file.spec.ts
CHANGED
|
@@ -11,19 +11,19 @@ const testDownstreamDir = resolve(TEST_FIXTURES_DIR, "downstream");
|
|
|
11
11
|
|
|
12
12
|
describe("mergeFile", () => {
|
|
13
13
|
let tmpDir: string;
|
|
14
|
-
let
|
|
14
|
+
let tmpTemplateDir: string;
|
|
15
15
|
beforeEach(async () => {
|
|
16
16
|
tmpDir = await mkdtemp(tempDir());
|
|
17
17
|
copySync(testDownstreamDir, tmpDir);
|
|
18
|
-
|
|
19
|
-
copySync(testTemplateDir,
|
|
18
|
+
tmpTemplateDir = await mkdtemp(tempDir());
|
|
19
|
+
copySync(testTemplateDir, tmpTemplateDir);
|
|
20
20
|
});
|
|
21
21
|
afterEach(async () => {
|
|
22
22
|
await rm(tmpDir, {
|
|
23
23
|
force: true,
|
|
24
24
|
recursive: true,
|
|
25
25
|
});
|
|
26
|
-
await rm(
|
|
26
|
+
await rm(tmpTemplateDir, {
|
|
27
27
|
force: true,
|
|
28
28
|
recursive: true,
|
|
29
29
|
});
|
|
@@ -49,7 +49,7 @@ describe("mergeFile", () => {
|
|
|
49
49
|
expect(
|
|
50
50
|
await mergeFile("package.json", {
|
|
51
51
|
cwd: tmpDir,
|
|
52
|
-
tempCloneDir:
|
|
52
|
+
tempCloneDir: tmpTemplateDir,
|
|
53
53
|
localTemplateSyncConfig: {
|
|
54
54
|
ignore: ["**/package.json"],
|
|
55
55
|
merge: [],
|
|
@@ -70,7 +70,7 @@ describe("mergeFile", () => {
|
|
|
70
70
|
expect(
|
|
71
71
|
await mergeFile("package.json", {
|
|
72
72
|
cwd: tmpDir,
|
|
73
|
-
tempCloneDir:
|
|
73
|
+
tempCloneDir: tmpTemplateDir,
|
|
74
74
|
localTemplateSyncConfig: {
|
|
75
75
|
ignore: [],
|
|
76
76
|
},
|
|
@@ -86,7 +86,7 @@ describe("mergeFile", () => {
|
|
|
86
86
|
|
|
87
87
|
// Ensure we overwrote
|
|
88
88
|
expect(await readFile(join(tmpDir, "package.json"))).toEqual(
|
|
89
|
-
await readFile(join(
|
|
89
|
+
await readFile(join(tmpTemplateDir, "package.json")),
|
|
90
90
|
);
|
|
91
91
|
},
|
|
92
92
|
);
|
|
@@ -94,7 +94,7 @@ describe("mergeFile", () => {
|
|
|
94
94
|
expect(
|
|
95
95
|
await mergeFile("package.json", {
|
|
96
96
|
cwd: tmpDir,
|
|
97
|
-
tempCloneDir:
|
|
97
|
+
tempCloneDir: tmpTemplateDir,
|
|
98
98
|
localTemplateSyncConfig: {
|
|
99
99
|
ignore: [],
|
|
100
100
|
},
|
|
@@ -109,7 +109,7 @@ describe("mergeFile", () => {
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
// Ensure we overwrote
|
|
112
|
-
expect(existsSync(join(
|
|
112
|
+
expect(existsSync(join(tmpDir, "package.json"))).toBeFalsy();
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
// TODO - this could change if there's a use case
|
|
@@ -117,7 +117,7 @@ describe("mergeFile", () => {
|
|
|
117
117
|
expect(
|
|
118
118
|
await mergeFile("package.json", {
|
|
119
119
|
cwd: tmpDir,
|
|
120
|
-
tempCloneDir:
|
|
120
|
+
tempCloneDir: tmpTemplateDir,
|
|
121
121
|
localTemplateSyncConfig: {
|
|
122
122
|
ignore: [],
|
|
123
123
|
merge: [
|
|
@@ -157,7 +157,7 @@ describe("mergeFile", () => {
|
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
// Ensure we overwrote
|
|
160
|
-
expect(existsSync(join(
|
|
160
|
+
expect(existsSync(join(tmpDir, "package.json"))).toBeFalsy();
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
describe.each([["added" as FileOperation], ["modified" as FileOperation]])(
|
package/src/merge-file.ts
CHANGED
|
@@ -54,13 +54,13 @@ export async function mergeFile(
|
|
|
54
54
|
|
|
55
55
|
// Unless there's a need, we remove files that were deleted and don't pass them to plugins yet
|
|
56
56
|
if (context.fileOperation === "deleted") {
|
|
57
|
-
if (existsSync(
|
|
58
|
-
await rm(
|
|
59
|
-
return {
|
|
60
|
-
ignoredDueToLocal: false,
|
|
61
|
-
localChanges: [],
|
|
62
|
-
};
|
|
57
|
+
if (existsSync(filePath)) {
|
|
58
|
+
await rm(filePath);
|
|
63
59
|
}
|
|
60
|
+
return {
|
|
61
|
+
ignoredDueToLocal: false,
|
|
62
|
+
localChanges: [],
|
|
63
|
+
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const mergeConfig = templateSyncConfig.merge?.find((mergeConfig) =>
|
|
@@ -256,7 +256,7 @@ describe("templateSync", () => {
|
|
|
256
256
|
// We will only update the templated.ts
|
|
257
257
|
const mockDiffDriver = jest.fn().mockImplementation(async () => ({
|
|
258
258
|
added: ["src/templated.ts"],
|
|
259
|
-
modified: [],
|
|
259
|
+
modified: ["src/index.ts"], // Add index.ts so we make sure it is still ignored - due to a bug
|
|
260
260
|
deleted: [],
|
|
261
261
|
}));
|
|
262
262
|
const mockCurrentRefDriver = jest
|
package/src/template-sync.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { TemplateRefDriverFn } from "./ref-drivers/types";
|
|
|
12
12
|
import { inferJSONIndent } from "./formatting";
|
|
13
13
|
import * as commentJSON from "comment-json";
|
|
14
14
|
import { TemplateCheckoutDriverFn, gitCheckout } from "./checkout-drivers";
|
|
15
|
+
import { some } from "micromatch";
|
|
15
16
|
|
|
16
17
|
export interface TemplateSyncOptions {
|
|
17
18
|
/**
|
|
@@ -141,6 +142,17 @@ export async function templateSync(
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
// Apply ignore filters
|
|
146
|
+
filesToSync.added = filesToSync.added.filter(
|
|
147
|
+
(f) => !some(f, templateSyncConfig.ignore),
|
|
148
|
+
);
|
|
149
|
+
filesToSync.modified = filesToSync.modified.filter(
|
|
150
|
+
(f) => !some(f, templateSyncConfig.ignore),
|
|
151
|
+
);
|
|
152
|
+
filesToSync.deleted = filesToSync.deleted.filter(
|
|
153
|
+
(f) => !some(f, templateSyncConfig.ignore),
|
|
154
|
+
);
|
|
155
|
+
|
|
144
156
|
const localSkipFiles: string[] = [];
|
|
145
157
|
const localFileChanges: {
|
|
146
158
|
[filePath: string]: Change[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
console.log("this is
|
|
2
|
+
console.log("this is downstream stuff that should not change");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
console.log("this is
|
|
1
|
+
console.log("this is downstream stuff that should not change");
|