@tinyrack/devsync 1.0.0 → 1.1.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/README.md +39 -1
- package/package.json +8 -5
- package/src/cli/commands/doctor.ts +20 -0
- package/src/cli/commands/index.ts +6 -0
- package/src/cli/commands/list.ts +17 -0
- package/src/cli/commands/status.ts +18 -0
- package/src/cli/sync-output.test.ts +173 -0
- package/src/cli/sync-output.ts +71 -0
- package/src/config/sync.test.ts +609 -0
- package/src/lib/string.test.ts +13 -0
- package/src/lib/validation.test.ts +32 -0
- package/src/services/config-file.test.ts +161 -0
- package/src/services/crypto.test.ts +132 -0
- package/src/services/doctor.ts +142 -0
- package/src/services/filesystem.test.ts +171 -0
- package/src/services/git.test.ts +83 -0
- package/src/services/init.test.ts +109 -0
- package/src/services/list.ts +63 -0
- package/src/services/local-materialization.ts +1 -1
- package/src/services/paths.test.ts +74 -0
- package/src/services/pull.ts +87 -18
- package/src/services/push.ts +65 -18
- package/src/services/status.ts +57 -0
- package/src/services/sync.dry-run.test.ts +179 -0
- package/src/services/sync.runtime.test.ts +756 -0
- package/src/services/sync.service.test.ts +1169 -0
- package/src/test/helpers/sync-fixture.ts +47 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
|
|
7
|
+
import { generateIdentity, identityToRecipient } from "age-encryption";
|
|
8
|
+
|
|
9
|
+
const execFileAsync = promisify(execFile);
|
|
10
|
+
|
|
11
|
+
export const createTemporaryDirectory = async (prefix: string) => {
|
|
12
|
+
return await mkdtemp(join(tmpdir(), prefix));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const createAgeKeyPair = async () => {
|
|
16
|
+
const identity = await generateIdentity();
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
identity,
|
|
20
|
+
recipient: await identityToRecipient(identity),
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const writeIdentityFile = async (
|
|
25
|
+
xdgConfigHome: string,
|
|
26
|
+
identity: string,
|
|
27
|
+
) => {
|
|
28
|
+
const identityFile = join(xdgConfigHome, "devsync", "age", "keys.txt");
|
|
29
|
+
|
|
30
|
+
await mkdir(dirname(identityFile), { recursive: true });
|
|
31
|
+
await writeFile(identityFile, `${identity}\n`);
|
|
32
|
+
|
|
33
|
+
return identityFile;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const runGit = async (args: readonly string[], cwd?: string) => {
|
|
37
|
+
return await execFileAsync("git", [...args], {
|
|
38
|
+
cwd,
|
|
39
|
+
encoding: "utf8",
|
|
40
|
+
maxBuffer: 10_000_000,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const writeJsonFile = async (path: string, value: unknown) => {
|
|
45
|
+
await mkdir(dirname(path), { recursive: true });
|
|
46
|
+
await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
47
|
+
};
|