@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 CHANGED
@@ -1,5 +1,9 @@
1
- import { exec, execFile } from "child_process";
2
- export { execSync, execFileSync } from "child_process";
3
- export declare const execAsync: typeof exec.__promisify__;
4
- export declare const execFileAsync: typeof execFile.__promisify__;
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
- import { execSync, execFileSync } from "child_process";
3
+
4
+ //#region src/exec.ts
4
5
  const execAsync = promisify(exec);
5
6
  const execFileAsync = promisify(execFile);
6
- export {
7
- execAsync,
8
- execFileAsync,
9
- execFileSync,
10
- execSync
11
- };
7
+
8
+ //#endregion
9
+ export { execAsync, execFileAsync, execFileSync, execSync };
10
+ //# sourceMappingURL=exec.js.map
@@ -1,11 +1,11 @@
1
+ //#region src/findRoot.d.ts
1
2
  /**
2
- * Find the root path of the repository containing the given directory.
3
- *
4
- * @returns null if not found or the path of the repository root as a string
5
- */
6
- export declare function findRoot(
7
- /**
8
- * The directory path of anything in a version-controlled repository
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
- return repositoryExec(directory, "git", [
4
- "rev-parse",
5
- "--quiet",
6
- "--show-toplevel"
7
- ]);
5
+ return repositoryExec(directory, "git", [
6
+ "rev-parse",
7
+ "--quiet",
8
+ "--show-toplevel"
9
+ ]);
8
10
  }
9
11
  async function findSaplingRoot(directory) {
10
- return repositoryExec(directory, "sl", ["--quiet", "root"]);
12
+ return repositoryExec(directory, "sl", ["--quiet", "root"]);
11
13
  }
12
14
  async function findMercurialRoot(directory) {
13
- return repositoryExec(directory, "hg", ["--quiet", "root"]);
15
+ return repositoryExec(directory, "hg", ["--quiet", "root"]);
14
16
  }
15
17
  async function findSubversionRoot(directory) {
16
- return repositoryExec(directory, "svn", ["info", "--show-item", "wc-root"]);
18
+ return repositoryExec(directory, "svn", [
19
+ "info",
20
+ "--show-item",
21
+ "wc-root"
22
+ ]);
17
23
  }
18
24
  const findMethods = [
19
- findGitRoot,
20
- // most used and fastest check
21
- findSubversionRoot,
22
- // next highest market share
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
- for (const method of findMethods) {
30
- try {
31
- const result = await method(directory);
32
- if (result != null && result !== "") {
33
- return result;
34
- }
35
- } catch (e) {
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
- export {
44
- findRoot
45
- };
44
+
45
+ //#endregion
46
+ export { findRoot };
47
+ //# sourceMappingURL=findRoot.js.map
@@ -1,11 +1,11 @@
1
+ //#region src/findRootSync.d.ts
1
2
  /**
2
- * Find the root path of the repository containing the given directory.
3
- *
4
- * @returns null if not found or the path of the repository root as a string
5
- */
6
- export declare function findRootSync(
7
- /**
8
- * The directory path of anything in a version-controlled repository
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
@@ -1,45 +1,47 @@
1
1
  import { repositoryExecSync } from "./repositoryCommand.js";
2
+
3
+ //#region src/findRootSync.ts
2
4
  function findGitRoot(cwd) {
3
- return repositoryExecSync(cwd, "git", [
4
- "rev-parse",
5
- "--quiet",
6
- "--show-toplevel"
7
- ]);
5
+ return repositoryExecSync(cwd, "git", [
6
+ "rev-parse",
7
+ "--quiet",
8
+ "--show-toplevel"
9
+ ]);
8
10
  }
9
11
  function findSaplingRoot(cwd) {
10
- return repositoryExecSync(cwd, "sl", ["--quiet", "root"]);
12
+ return repositoryExecSync(cwd, "sl", ["--quiet", "root"]);
11
13
  }
12
14
  function findMercurialRoot(cwd) {
13
- return repositoryExecSync(cwd, "hg", ["--quiet", "root"]);
15
+ return repositoryExecSync(cwd, "hg", ["--quiet", "root"]);
14
16
  }
15
17
  function findSubversionRoot(cwd) {
16
- return repositoryExecSync(cwd, "svn", ["info", "--show-item", "wc-root"]);
18
+ return repositoryExecSync(cwd, "svn", [
19
+ "info",
20
+ "--show-item",
21
+ "wc-root"
22
+ ]);
17
23
  }
18
24
  const findMethods = [
19
- findGitRoot,
20
- // most used and fastest check
21
- findSubversionRoot,
22
- // next highest market share
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
- for (const method of findMethods) {
30
- try {
31
- const result = method(directory);
32
- if (result != null && result !== "") {
33
- return result;
34
- }
35
- } catch (e) {
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
- export {
44
- findRootSync
45
- };
44
+
45
+ //#endregion
46
+ export { findRootSync };
47
+ //# sourceMappingURL=findRootSync.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./findRoot.js";
2
- export * from "./findRootSync.js";
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { findRoot } from "./findRoot.js";
2
+ import { findRootSync } from "./findRootSync.js";
3
+ export { findRoot, findRootSync };
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
- export * from "./findRoot.js";
2
- export * from "./findRootSync.js";
1
+ import { findRoot } from "./findRoot.js";
2
+ import { findRootSync } from "./findRootSync.js";
3
+
4
+ export { findRoot, findRootSync };
@@ -1,6 +1,9 @@
1
+ //#region src/repositoryCommand.d.ts
1
2
  type RepositoryCommand = "git" | "hg" | "sl" | "svn" | "svnadmin" | "svnrdump";
2
- export declare function repositoryExec(cwd: string, command: RepositoryCommand, args: readonly string[]): Promise<string>;
3
- export declare function repositoryExecSync(cwd: string, command: RepositoryCommand, args: readonly string[]): string;
4
- export declare const createExecForDirectory: (cwd: string) => ((command: RepositoryCommand, args: readonly string[]) => Promise<string>);
5
- export {};
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
- git: {
4
- // non-interactive
5
- GIT_TERMINAL_PROMPT: "0",
6
- // don't use global config
7
- GIT_CONFIG_GLOBAL: "/dev/null",
8
- GIT_CONFIG_SYSTEM: "/dev/null",
9
- // user config
10
- GIT_COMMITTER_NAME: "alan",
11
- GIT_COMMITTER_EMAIL: "alan@example.com",
12
- GIT_AUTHOR_NAME: "alan",
13
- GIT_AUTHOR_EMAIL: "alan@example.com"
14
- },
15
- hg: {
16
- // don't use global config
17
- HGRCPATH: "/dev/null",
18
- // don't use global config
19
- HGUSER: "alan",
20
- EMAIL: "alan@example.com"
21
- },
22
- sl: {
23
- // don't use global config
24
- HGRCPATH: "/dev/null",
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
- return execFileAsync(command, args, {
35
- cwd,
36
- encoding: "utf8",
37
- env: {
38
- ...process.env,
39
- ...environment[command]
40
- }
41
- }).then(({ stdout, stderr }) => {
42
- return stderr ? Promise.reject(new Error(stderr.trim())) : stdout.trim();
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
- const result = execFileSync(command, args, {
47
- cwd,
48
- encoding: "utf8",
49
- env: {
50
- ...process.env,
51
- ...environment[command]
52
- }
53
- }).trim();
54
- return result;
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
- export {
58
- createExecForDirectory,
59
- repositoryExec,
60
- repositoryExecSync
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
- export declare const repositoryTypes: readonly ["git", "mercurial", "sapling", "subversion"];
2
- export type RepositoryType = (typeof repositoryTypes)[number];
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
- "git",
3
- "mercurial",
4
- "sapling",
5
- "subversion"
3
+ "git",
4
+ "mercurial",
5
+ "sapling",
6
+ "subversion"
6
7
  ];
7
- export {
8
- repositoryTypes
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": "1.0.0",
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.1",
40
- "@vitest/expect": "^3.1.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.4",
49
- "vitest": "^3.1.1",
50
- "@altano/testing": "0.0.0",
51
- "@altano/tsconfig": "0.0.0",
52
- "@altano/build-config": "0.0.0"
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": "tsup --config build-config/tsup.config.node.ts",
59
- "build:types": "tsc --project tsconfig.declarations.json",
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",