@altano/repository-tools 1.0.1 → 2.0.1
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 +7 -4
- package/dist/exec.js +7 -8
- package/dist/exec.js.map +1 -0
- package/dist/findRoot.d.ts +8 -9
- package/dist/findRoot.js +34 -32
- package/dist/findRoot.js.map +1 -0
- package/dist/findRootSync.d.ts +8 -9
- package/dist/findRootSync.js +34 -32
- package/dist/findRootSync.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -2
- package/dist/repositoryCommand.d.ts +6 -4
- package/dist/repositoryCommand.js +47 -53
- package/dist/repositoryCommand.js.map +1 -0
- package/dist/types.d.ts +5 -2
- package/dist/types.js +9 -7
- package/dist/types.js.map +1 -0
- package/package.json +12 -11
package/dist/exec.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
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
|
+
//#endregion
|
|
7
|
+
export { execAsync, execFileAsync, execFileSync, execSync };
|
|
5
8
|
//# 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/exec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","names":["execAsync: typeof exec.__promisify__","execFileAsync: typeof execFile.__promisify__"],"sources":["../src/exec.ts"],"sourcesContent":["import { exec, execFile } from \"child_process\";\nimport { promisify } from \"node:util\";\n\nexport { execSync, execFileSync } from \"child_process\";\n\nexport const execAsync: typeof exec.__promisify__ = promisify(exec);\nexport const execFileAsync: typeof execFile.__promisify__ = promisify(execFile);\n"],"mappings":";;;;AAKA,MAAaA,YAAuC,UAAU,KAAK;AACnE,MAAaC,gBAA+C,UAAU,SAAS"}
|
package/dist/findRoot.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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
|
+
//#endregion
|
|
9
|
+
export { findRoot };
|
|
11
10
|
//# 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findRoot.js","names":["directory: string","e: unknown"],"sources":["../src/findRoot.ts"],"sourcesContent":["import { repositoryExec } from \"./repositoryCommand.js\";\n\nasync function findGitRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"git\", [\n \"rev-parse\",\n \"--quiet\",\n \"--show-toplevel\",\n ]);\n}\n\nasync function findSaplingRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"sl\", [\"--quiet\", \"root\"]);\n}\n\nasync function findMercurialRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"hg\", [\"--quiet\", \"root\"]);\n}\n\nasync function findSubversionRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"svn\", [\"info\", \"--show-item\", \"wc-root\"]);\n}\n\n// Version control systems to check for. Highest-precedence checks go first.\nconst findMethods = [\n findGitRoot, // most used and fastest check\n findSubversionRoot, // next highest market share\n findSaplingRoot, // much smaller market share, but much faster\n findMercurialRoot, // slow af\n] as const;\n\n/**\n * Find the root path of the repository containing the given directory.\n *\n * @returns null if not found or the path of the repository root as a string\n */\nexport async function findRoot(\n /**\n * The directory path of anything in a version-controlled repository\n */\n directory: string,\n): Promise<string | null> {\n for (const method of findMethods) {\n try {\n const result = await method(directory);\n if (result != null && result !== \"\") {\n return result;\n }\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"ENOTDIR\") {\n // rethrow error when given directory path isn't a directory\n throw new Error(`Given path isn't a directory: ${directory}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AAEA,eAAe,YAAYA,WAAoC;AAC7D,QAAO,eAAe,WAAW,OAAO;EACtC;EACA;EACA;CACD,EAAC;AACH;AAED,eAAe,gBAAgBA,WAAoC;AACjE,QAAO,eAAe,WAAW,MAAM,CAAC,WAAW,MAAO,EAAC;AAC5D;AAED,eAAe,kBAAkBA,WAAoC;AACnE,QAAO,eAAe,WAAW,MAAM,CAAC,WAAW,MAAO,EAAC;AAC5D;AAED,eAAe,mBAAmBA,WAAoC;AACpE,QAAO,eAAe,WAAW,OAAO;EAAC;EAAQ;EAAe;CAAU,EAAC;AAC5E;AAGD,MAAM,cAAc;CAClB;CACA;CACA;CACA;AACD;;;;;;AAOD,eAAsB,SAIpBA,WACwB;AACxB,MAAK,MAAM,UAAU,YACnB,KAAI;EACF,MAAM,SAAS,MAAM,OAAO,UAAU;AACtC,MAAI,UAAU,QAAQ,WAAW,GAC/B,QAAO;CAEV,SAAQC,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,UAElD,OAAM,IAAI,OAAO,gCAAgC,UAAU;CAE9D;AAEH,QAAO;AACR"}
|
package/dist/findRootSync.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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
|
+
//#endregion
|
|
9
|
+
export { findRootSync };
|
|
11
10
|
//# 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findRootSync.js","names":["cwd: string","directory: string","e: unknown"],"sources":["../src/findRootSync.ts"],"sourcesContent":["import { repositoryExecSync } from \"./repositoryCommand.js\";\n\nfunction findGitRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"git\", [\n \"rev-parse\",\n \"--quiet\",\n \"--show-toplevel\",\n ]);\n}\n\nfunction findSaplingRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"sl\", [\"--quiet\", \"root\"]);\n}\n\nfunction findMercurialRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"hg\", [\"--quiet\", \"root\"]);\n}\n\nfunction findSubversionRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"svn\", [\"info\", \"--show-item\", \"wc-root\"]);\n}\n\n// Version control systems to check for. Highest-precedence checks go first.\nconst findMethods = [\n findGitRoot, // most used and fastest check\n findSubversionRoot, // next highest market share\n findSaplingRoot, // much smaller market share, but much faster\n findMercurialRoot, // slow af\n] as const;\n\n/**\n * Find the root path of the repository containing the given directory.\n *\n * @returns null if not found or the path of the repository root as a string\n */\nexport function findRootSync(\n /**\n * The directory path of anything in a version-controlled repository\n */\n directory: string,\n): string | null {\n for (const method of findMethods) {\n try {\n const result = method(directory);\n if (result != null && result !== \"\") {\n return result;\n }\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"ENOTDIR\") {\n // rethrow error when given directory path isn't a directory\n throw new Error(`Given path isn't a directory: ${directory}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AAEA,SAAS,YAAYA,KAAqB;AACxC,QAAO,mBAAmB,KAAK,OAAO;EACpC;EACA;EACA;CACD,EAAC;AACH;AAED,SAAS,gBAAgBA,KAAqB;AAC5C,QAAO,mBAAmB,KAAK,MAAM,CAAC,WAAW,MAAO,EAAC;AAC1D;AAED,SAAS,kBAAkBA,KAAqB;AAC9C,QAAO,mBAAmB,KAAK,MAAM,CAAC,WAAW,MAAO,EAAC;AAC1D;AAED,SAAS,mBAAmBA,KAAqB;AAC/C,QAAO,mBAAmB,KAAK,OAAO;EAAC;EAAQ;EAAe;CAAU,EAAC;AAC1E;AAGD,MAAM,cAAc;CAClB;CACA;CACA;CACA;AACD;;;;;;AAOD,SAAgB,aAIdC,WACe;AACf,MAAK,MAAM,UAAU,YACnB,KAAI;EACF,MAAM,SAAS,OAAO,UAAU;AAChC,MAAI,UAAU,QAAQ,WAAW,GAC/B,QAAO;CAEV,SAAQC,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,UAElD,OAAM,IAAI,OAAO,gCAAgC,UAAU;CAE9D;AAEH,QAAO;AACR"}
|
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,8 @@
|
|
|
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
|
+
//#endregion
|
|
7
|
+
export { createExecForDirectory, repositoryExec, repositoryExecSync };
|
|
6
8
|
//# 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repositoryCommand.js","names":["cwd: string","command: RepositoryCommand","args: readonly string[]"],"sources":["../src/repositoryCommand.ts"],"sourcesContent":["import { execFileAsync, execFileSync } from \"./exec.js\";\nimport {} from \"child_process\";\n\ntype RepositoryCommand = \"git\" | \"hg\" | \"sl\" | \"svn\" | \"svnadmin\" | \"svnrdump\";\n\nconst environment = {\n git: {\n // non-interactive\n GIT_TERMINAL_PROMPT: \"0\",\n // don't use global config\n GIT_CONFIG_GLOBAL: \"/dev/null\",\n GIT_CONFIG_SYSTEM: \"/dev/null\",\n // user config\n GIT_COMMITTER_NAME: \"alan\",\n GIT_COMMITTER_EMAIL: \"alan@example.com\",\n GIT_AUTHOR_NAME: \"alan\",\n GIT_AUTHOR_EMAIL: \"alan@example.com\",\n },\n hg: {\n // don't use global config\n HGRCPATH: \"/dev/null\",\n // don't use global config\n HGUSER: \"alan\",\n EMAIL: \"alan@example.com\",\n },\n sl: {\n // don't use global config\n HGRCPATH: \"/dev/null\",\n // don't use global config\n HGUSER: \"alan\",\n EMAIL: \"alan@example.com\",\n },\n svn: {},\n svnadmin: {},\n svnrdump: {},\n} as const satisfies Record<RepositoryCommand, NodeJS.ProcessEnv>;\n\nexport async function repositoryExec(\n cwd: string,\n command: RepositoryCommand,\n args: readonly string[],\n): Promise<string> {\n // const msg = `Executing command: ${command} ${args.join(\" \")}`;\n // console.time(msg);\n return execFileAsync(command, args, {\n cwd: cwd,\n encoding: \"utf8\",\n env: {\n ...process.env,\n ...environment[command],\n },\n }).then(({ stdout, stderr }) => {\n // console.timeEnd(msg);\n return stderr ? Promise.reject(new Error(stderr.trim())) : stdout.trim();\n });\n}\n\nexport function repositoryExecSync(\n cwd: string,\n command: RepositoryCommand,\n args: readonly string[],\n): string {\n // const msg = `Executing command: ${command} ${args.join(\" \")}`;\n // console.time(msg);\n const result = execFileSync(command, args, {\n cwd: cwd,\n encoding: \"utf8\",\n env: {\n ...process.env,\n ...environment[command],\n },\n }).trim();\n // console.timeEnd(msg);\n return result;\n}\n\nexport const createExecForDirectory = (\n cwd: string,\n): ((command: RepositoryCommand, args: readonly string[]) => Promise<string>) =>\n repositoryExec.bind(null, cwd);\n\n// Not being used.\n// export const createExecSyncForDirectory = (\n// cwd: string,\n// ): ((command: RepositoryCommand, args: readonly string[]) => string) =>\n// repositoryExecSync.bind(null, cwd);\n"],"mappings":";;;AAKA,MAAM,cAAc;CAClB,KAAK;EAEH,qBAAqB;EAErB,mBAAmB;EACnB,mBAAmB;EAEnB,oBAAoB;EACpB,qBAAqB;EACrB,iBAAiB;EACjB,kBAAkB;CACnB;CACD,IAAI;EAEF,UAAU;EAEV,QAAQ;EACR,OAAO;CACR;CACD,IAAI;EAEF,UAAU;EAEV,QAAQ;EACR,OAAO;CACR;CACD,KAAK,CAAE;CACP,UAAU,CAAE;CACZ,UAAU,CAAE;AACb;AAED,eAAsB,eACpBA,KACAC,SACAC,MACiB;AAGjB,QAAO,cAAc,SAAS,MAAM;EAC7B;EACL,UAAU;EACV,KAAK;GACH,GAAG,QAAQ;GACX,GAAG,YAAY;EAChB;CACF,EAAC,CAAC,KAAK,CAAC,EAAE,QAAQ,QAAQ,KAAK;AAE9B,SAAO,SAAS,QAAQ,OAAO,IAAI,MAAM,OAAO,MAAM,EAAE,GAAG,OAAO,MAAM;CACzE,EAAC;AACH;AAED,SAAgB,mBACdF,KACAC,SACAC,MACQ;CAGR,MAAM,SAAS,aAAa,SAAS,MAAM;EACpC;EACL,UAAU;EACV,KAAK;GACH,GAAG,QAAQ;GACX,GAAG,YAAY;EAChB;CACF,EAAC,CAAC,MAAM;AAET,QAAO;AACR;AAED,MAAa,yBAAyB,CACpCF,QAEA,eAAe,KAAK,MAAM,IAAI"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
declare const repositoryTypes: readonly ["git", "mercurial", "sapling", "subversion"];
|
|
3
|
+
type RepositoryType = (typeof repositoryTypes)[number];
|
|
4
|
+
//#endregion
|
|
5
|
+
export { RepositoryType, repositoryTypes };
|
|
3
6
|
//# 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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export const repositoryTypes = [\n \"git\",\n \"mercurial\",\n \"sapling\",\n \"subversion\",\n] as const;\n\nexport type RepositoryType = (typeof repositoryTypes)[number];\n"],"mappings":";AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altano/repository-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Misc tools for dealing with repositories of multiple version control systems (git, svn, etc)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"repository",
|
|
@@ -32,33 +32,34 @@
|
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"files": [
|
|
34
34
|
"dist/**/*.js",
|
|
35
|
+
"dist/**/*.js.map",
|
|
35
36
|
"dist/**/*.d.ts"
|
|
36
37
|
],
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@arethetypeswrong/cli": "^0.17.4",
|
|
39
40
|
"@types/node": "^22.13.10",
|
|
40
|
-
"@vitest/coverage-v8": "^3.1.
|
|
41
|
-
"@vitest/expect": "^3.1.
|
|
41
|
+
"@vitest/coverage-v8": "^3.1.4",
|
|
42
|
+
"@vitest/expect": "^3.1.4",
|
|
42
43
|
"depcheck": "^1.4.7",
|
|
43
44
|
"eslint": "^9.23.0",
|
|
44
45
|
"find-cache-dir": "^5.0.0",
|
|
45
46
|
"memize": "^2.1.0",
|
|
46
47
|
"prettier": "^3.5.3",
|
|
47
48
|
"ts-assert-unreachable": "^0.0.9",
|
|
49
|
+
"tsdown": "^0.12.9",
|
|
48
50
|
"typescript": "^5.8.2",
|
|
49
|
-
"vite": "^6.2.
|
|
50
|
-
"vitest": "^3.1.
|
|
51
|
-
"@altano/build-config": "0.0.
|
|
52
|
-
"@altano/
|
|
53
|
-
"@altano/
|
|
51
|
+
"vite": "^6.2.6",
|
|
52
|
+
"vitest": "^3.1.4",
|
|
53
|
+
"@altano/build-config": "0.0.1",
|
|
54
|
+
"@altano/testing": "0.0.1",
|
|
55
|
+
"@altano/tsconfig": "0.0.1"
|
|
54
56
|
},
|
|
55
57
|
"publishConfig": {
|
|
56
58
|
"access": "public"
|
|
57
59
|
},
|
|
58
60
|
"scripts": {
|
|
59
|
-
"build": "
|
|
60
|
-
"
|
|
61
|
-
"check:exports": "attw --pack . --profile esm-only",
|
|
61
|
+
"build": "tsdown --config ../build-config/tsdown.config.node.ts",
|
|
62
|
+
"check:exports": "attw --pack . --profile esm-only --quiet",
|
|
62
63
|
"check:types:src": "tsc --noEmit",
|
|
63
64
|
"check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
|
|
64
65
|
"check:unused-dependencies": "depcheck",
|