@altano/repository-tools 1.0.0 → 2.0.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/dist/exec.d.ts +8 -4
- package/dist/exec.js +7 -8
- package/dist/findRoot.d.ts +9 -9
- package/dist/findRoot.js +34 -32
- package/dist/findRootSync.d.ts +9 -9
- package/dist/findRootSync.js +34 -32
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -2
- package/dist/repositoryCommand.d.ts +7 -4
- package/dist/repositoryCommand.js +47 -53
- package/dist/types.d.ts +6 -2
- package/dist/types.js +9 -7
- package/package.json +12 -11
package/dist/exec.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { exec, execFile } from "child_process";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { exec, execFile, execFileSync, execSync } from "child_process";
|
|
2
|
+
|
|
3
|
+
//#region src/exec.d.ts
|
|
4
|
+
declare const execAsync: typeof exec.__promisify__;
|
|
5
|
+
declare const execFileAsync: typeof execFile.__promisify__;
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { execAsync, execFileAsync, execFileSync, execSync };
|
|
5
9
|
//# sourceMappingURL=exec.d.ts.map
|
package/dist/exec.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { exec, execFile } from "child_process";
|
|
1
|
+
import { exec, execFile, execFileSync, execSync } from "child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
//#region src/exec.ts
|
|
4
5
|
const execAsync = promisify(exec);
|
|
5
6
|
const execFileAsync = promisify(execFile);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
execSync
|
|
11
|
-
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { execAsync, execFileAsync, execFileSync, execSync };
|
|
10
|
+
//# sourceMappingURL=exec.js.map
|
package/dist/findRoot.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
//#region src/findRoot.d.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
directory: string): Promise<string | null>;
|
|
3
|
+
* Find the root path of the repository containing the given directory.
|
|
4
|
+
*
|
|
5
|
+
* @returns null if not found or the path of the repository root as a string
|
|
6
|
+
*/
|
|
7
|
+
declare function findRoot(directory: string): Promise<string | null>;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { findRoot };
|
|
11
11
|
//# sourceMappingURL=findRoot.d.ts.map
|
package/dist/findRoot.js
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
1
|
import { repositoryExec } from "./repositoryCommand.js";
|
|
2
|
+
|
|
3
|
+
//#region src/findRoot.ts
|
|
2
4
|
async function findGitRoot(directory) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
return repositoryExec(directory, "git", [
|
|
6
|
+
"rev-parse",
|
|
7
|
+
"--quiet",
|
|
8
|
+
"--show-toplevel"
|
|
9
|
+
]);
|
|
8
10
|
}
|
|
9
11
|
async function findSaplingRoot(directory) {
|
|
10
|
-
|
|
12
|
+
return repositoryExec(directory, "sl", ["--quiet", "root"]);
|
|
11
13
|
}
|
|
12
14
|
async function findMercurialRoot(directory) {
|
|
13
|
-
|
|
15
|
+
return repositoryExec(directory, "hg", ["--quiet", "root"]);
|
|
14
16
|
}
|
|
15
17
|
async function findSubversionRoot(directory) {
|
|
16
|
-
|
|
18
|
+
return repositoryExec(directory, "svn", [
|
|
19
|
+
"info",
|
|
20
|
+
"--show-item",
|
|
21
|
+
"wc-root"
|
|
22
|
+
]);
|
|
17
23
|
}
|
|
18
24
|
const findMethods = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
findSaplingRoot,
|
|
24
|
-
// much smaller market share, but much faster
|
|
25
|
-
findMercurialRoot
|
|
26
|
-
// slow af
|
|
25
|
+
findGitRoot,
|
|
26
|
+
findSubversionRoot,
|
|
27
|
+
findSaplingRoot,
|
|
28
|
+
findMercurialRoot
|
|
27
29
|
];
|
|
30
|
+
/**
|
|
31
|
+
* Find the root path of the repository containing the given directory.
|
|
32
|
+
*
|
|
33
|
+
* @returns null if not found or the path of the repository root as a string
|
|
34
|
+
*/
|
|
28
35
|
async function findRoot(directory) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (e instanceof Error && "code" in e && e.code === "ENOTDIR") {
|
|
37
|
-
throw new Error(`Given path isn't a directory: ${directory}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
36
|
+
for (const method of findMethods) try {
|
|
37
|
+
const result = await method(directory);
|
|
38
|
+
if (result != null && result !== "") return result;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (e instanceof Error && "code" in e && e.code === "ENOTDIR") throw new Error(`Given path isn't a directory: ${directory}`);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { findRoot };
|
|
47
|
+
//# sourceMappingURL=findRoot.js.map
|
package/dist/findRootSync.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
//#region src/findRootSync.d.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
directory: string): string | null;
|
|
3
|
+
* Find the root path of the repository containing the given directory.
|
|
4
|
+
*
|
|
5
|
+
* @returns null if not found or the path of the repository root as a string
|
|
6
|
+
*/
|
|
7
|
+
declare function findRootSync(directory: string): string | null;
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { findRootSync };
|
|
11
11
|
//# sourceMappingURL=findRootSync.d.ts.map
|
package/dist/findRootSync.js
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
1
|
import { repositoryExecSync } from "./repositoryCommand.js";
|
|
2
|
+
|
|
3
|
+
//#region src/findRootSync.ts
|
|
2
4
|
function findGitRoot(cwd) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
return repositoryExecSync(cwd, "git", [
|
|
6
|
+
"rev-parse",
|
|
7
|
+
"--quiet",
|
|
8
|
+
"--show-toplevel"
|
|
9
|
+
]);
|
|
8
10
|
}
|
|
9
11
|
function findSaplingRoot(cwd) {
|
|
10
|
-
|
|
12
|
+
return repositoryExecSync(cwd, "sl", ["--quiet", "root"]);
|
|
11
13
|
}
|
|
12
14
|
function findMercurialRoot(cwd) {
|
|
13
|
-
|
|
15
|
+
return repositoryExecSync(cwd, "hg", ["--quiet", "root"]);
|
|
14
16
|
}
|
|
15
17
|
function findSubversionRoot(cwd) {
|
|
16
|
-
|
|
18
|
+
return repositoryExecSync(cwd, "svn", [
|
|
19
|
+
"info",
|
|
20
|
+
"--show-item",
|
|
21
|
+
"wc-root"
|
|
22
|
+
]);
|
|
17
23
|
}
|
|
18
24
|
const findMethods = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
findSaplingRoot,
|
|
24
|
-
// much smaller market share, but much faster
|
|
25
|
-
findMercurialRoot
|
|
26
|
-
// slow af
|
|
25
|
+
findGitRoot,
|
|
26
|
+
findSubversionRoot,
|
|
27
|
+
findSaplingRoot,
|
|
28
|
+
findMercurialRoot
|
|
27
29
|
];
|
|
30
|
+
/**
|
|
31
|
+
* Find the root path of the repository containing the given directory.
|
|
32
|
+
*
|
|
33
|
+
* @returns null if not found or the path of the repository root as a string
|
|
34
|
+
*/
|
|
28
35
|
function findRootSync(directory) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (e instanceof Error && "code" in e && e.code === "ENOTDIR") {
|
|
37
|
-
throw new Error(`Given path isn't a directory: ${directory}`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return null;
|
|
36
|
+
for (const method of findMethods) try {
|
|
37
|
+
const result = method(directory);
|
|
38
|
+
if (result != null && result !== "") return result;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (e instanceof Error && "code" in e && e.code === "ENOTDIR") throw new Error(`Given path isn't a directory: ${directory}`);
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { findRootSync };
|
|
47
|
+
//# sourceMappingURL=findRootSync.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { findRoot } from "./findRoot.js";
|
|
2
|
+
import { findRootSync } from "./findRootSync.js";
|
|
3
|
+
export { findRoot, findRootSync };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
//#region src/repositoryCommand.d.ts
|
|
1
2
|
type RepositoryCommand = "git" | "hg" | "sl" | "svn" | "svnadmin" | "svnrdump";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
declare function repositoryExec(cwd: string, command: RepositoryCommand, args: readonly string[]): Promise<string>;
|
|
4
|
+
declare function repositoryExecSync(cwd: string, command: RepositoryCommand, args: readonly string[]): string;
|
|
5
|
+
declare const createExecForDirectory: (cwd: string) => ((command: RepositoryCommand, args: readonly string[]) => Promise<string>);
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { createExecForDirectory, repositoryExec, repositoryExecSync };
|
|
6
9
|
//# sourceMappingURL=repositoryCommand.d.ts.map
|
|
@@ -1,61 +1,55 @@
|
|
|
1
1
|
import { execFileAsync, execFileSync } from "./exec.js";
|
|
2
|
+
|
|
3
|
+
//#region src/repositoryCommand.ts
|
|
2
4
|
const environment = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// don't use global config
|
|
26
|
-
HGUSER: "alan",
|
|
27
|
-
EMAIL: "alan@example.com"
|
|
28
|
-
},
|
|
29
|
-
svn: {},
|
|
30
|
-
svnadmin: {},
|
|
31
|
-
svnrdump: {}
|
|
5
|
+
git: {
|
|
6
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
7
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
8
|
+
GIT_CONFIG_SYSTEM: "/dev/null",
|
|
9
|
+
GIT_COMMITTER_NAME: "alan",
|
|
10
|
+
GIT_COMMITTER_EMAIL: "alan@example.com",
|
|
11
|
+
GIT_AUTHOR_NAME: "alan",
|
|
12
|
+
GIT_AUTHOR_EMAIL: "alan@example.com"
|
|
13
|
+
},
|
|
14
|
+
hg: {
|
|
15
|
+
HGRCPATH: "/dev/null",
|
|
16
|
+
HGUSER: "alan",
|
|
17
|
+
EMAIL: "alan@example.com"
|
|
18
|
+
},
|
|
19
|
+
sl: {
|
|
20
|
+
HGRCPATH: "/dev/null",
|
|
21
|
+
HGUSER: "alan",
|
|
22
|
+
EMAIL: "alan@example.com"
|
|
23
|
+
},
|
|
24
|
+
svn: {},
|
|
25
|
+
svnadmin: {},
|
|
26
|
+
svnrdump: {}
|
|
32
27
|
};
|
|
33
28
|
async function repositoryExec(cwd, command, args) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
return execFileAsync(command, args, {
|
|
30
|
+
cwd,
|
|
31
|
+
encoding: "utf8",
|
|
32
|
+
env: {
|
|
33
|
+
...process.env,
|
|
34
|
+
...environment[command]
|
|
35
|
+
}
|
|
36
|
+
}).then(({ stdout, stderr }) => {
|
|
37
|
+
return stderr ? Promise.reject(new Error(stderr.trim())) : stdout.trim();
|
|
38
|
+
});
|
|
44
39
|
}
|
|
45
40
|
function repositoryExecSync(cwd, command, args) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
const result = execFileSync(command, args, {
|
|
42
|
+
cwd,
|
|
43
|
+
encoding: "utf8",
|
|
44
|
+
env: {
|
|
45
|
+
...process.env,
|
|
46
|
+
...environment[command]
|
|
47
|
+
}
|
|
48
|
+
}).trim();
|
|
49
|
+
return result;
|
|
55
50
|
}
|
|
56
51
|
const createExecForDirectory = (cwd) => repositoryExec.bind(null, cwd);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createExecForDirectory, repositoryExec, repositoryExecSync };
|
|
55
|
+
//# sourceMappingURL=repositoryCommand.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
declare const repositoryTypes: readonly ["git", "mercurial", "sapling", "subversion"];
|
|
3
|
+
type RepositoryType = (typeof repositoryTypes)[number];
|
|
4
|
+
|
|
5
|
+
//#endregion
|
|
6
|
+
export { RepositoryType, repositoryTypes };
|
|
3
7
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
1
2
|
const repositoryTypes = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"git",
|
|
4
|
+
"mercurial",
|
|
5
|
+
"sapling",
|
|
6
|
+
"subversion"
|
|
6
7
|
];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { repositoryTypes };
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altano/repository-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Misc tools for dealing with repositories of multiple version control systems (git, svn, etc)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"repository",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"main": "./dist/index.js",
|
|
31
31
|
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
32
33
|
"files": [
|
|
33
34
|
"dist/**/*.js",
|
|
34
35
|
"dist/**/*.d.ts"
|
|
@@ -36,28 +37,28 @@
|
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@arethetypeswrong/cli": "^0.17.4",
|
|
38
39
|
"@types/node": "^22.13.10",
|
|
39
|
-
"@vitest/coverage-v8": "^3.1.
|
|
40
|
-
"@vitest/expect": "^3.1.
|
|
40
|
+
"@vitest/coverage-v8": "^3.1.4",
|
|
41
|
+
"@vitest/expect": "^3.1.4",
|
|
41
42
|
"depcheck": "^1.4.7",
|
|
42
43
|
"eslint": "^9.23.0",
|
|
43
44
|
"find-cache-dir": "^5.0.0",
|
|
44
45
|
"memize": "^2.1.0",
|
|
45
46
|
"prettier": "^3.5.3",
|
|
46
47
|
"ts-assert-unreachable": "^0.0.9",
|
|
48
|
+
"tsdown": "^0.12.3",
|
|
47
49
|
"typescript": "^5.8.2",
|
|
48
|
-
"vite": "^6.2.
|
|
49
|
-
"vitest": "^3.1.
|
|
50
|
-
"@altano/
|
|
51
|
-
"@altano/
|
|
52
|
-
"@altano/
|
|
50
|
+
"vite": "^6.2.6",
|
|
51
|
+
"vitest": "^3.1.4",
|
|
52
|
+
"@altano/build-config": "0.0.1",
|
|
53
|
+
"@altano/testing": "0.0.1",
|
|
54
|
+
"@altano/tsconfig": "0.0.1"
|
|
53
55
|
},
|
|
54
56
|
"publishConfig": {
|
|
55
57
|
"access": "public"
|
|
56
58
|
},
|
|
57
59
|
"scripts": {
|
|
58
|
-
"build": "
|
|
59
|
-
"
|
|
60
|
-
"check:exports": "attw --pack . --profile esm-only",
|
|
60
|
+
"build": "tsdown --config ../build-config/tsdown.config.node.ts",
|
|
61
|
+
"check:exports": "attw --pack . --profile esm-only --quiet",
|
|
61
62
|
"check:types:src": "tsc --noEmit",
|
|
62
63
|
"check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
|
|
63
64
|
"check:unused-dependencies": "depcheck",
|