workspace-tools 0.38.4 → 0.38.6

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.
Files changed (73) hide show
  1. package/lib/getPackageInfo.d.ts +13 -0
  2. package/lib/getPackageInfo.js +52 -0
  3. package/lib/getPackageInfo.js.map +1 -0
  4. package/lib/getPackageInfos.d.ts +14 -0
  5. package/lib/getPackageInfos.js +17 -20
  6. package/lib/getPackageInfos.js.map +1 -1
  7. package/lib/getPackagePaths.d.ts +2 -2
  8. package/lib/getPackagePaths.js +2 -2
  9. package/lib/git/gitUtilities.d.ts +132 -3
  10. package/lib/git/gitUtilities.js +141 -4
  11. package/lib/git/gitUtilities.js.map +1 -1
  12. package/lib/graph/createDependencyMap.d.ts +1 -1
  13. package/lib/graph/createDependencyMap.js.map +1 -1
  14. package/lib/graph/getPackageDependencies.d.ts +10 -1
  15. package/lib/graph/getPackageDependencies.js +17 -5
  16. package/lib/graph/getPackageDependencies.js.map +1 -1
  17. package/lib/index.d.ts +17 -14
  18. package/lib/index.js +40 -15
  19. package/lib/index.js.map +1 -1
  20. package/lib/lockfile/parseBerryLock.d.ts +3 -0
  21. package/lib/lockfile/parseBerryLock.js +3 -0
  22. package/lib/lockfile/parseBerryLock.js.map +1 -1
  23. package/lib/lockfile/types.d.ts +3 -0
  24. package/lib/paths.d.ts +3 -0
  25. package/lib/paths.js +4 -1
  26. package/lib/paths.js.map +1 -1
  27. package/lib/tsdoc-metadata.json +1 -1
  28. package/lib/types/Catalogs.d.ts +30 -0
  29. package/lib/types/Catalogs.js +3 -0
  30. package/lib/types/Catalogs.js.map +1 -0
  31. package/lib/types/PackageInfo.d.ts +19 -1
  32. package/lib/types/WorkspaceInfo.d.ts +15 -6
  33. package/lib/workspaces/catalogs.d.ts +33 -0
  34. package/lib/workspaces/catalogs.js +66 -0
  35. package/lib/workspaces/catalogs.js.map +1 -0
  36. package/lib/workspaces/findWorkspacePath.d.ts +5 -5
  37. package/lib/workspaces/findWorkspacePath.js +3 -3
  38. package/lib/workspaces/findWorkspacePath.js.map +1 -1
  39. package/lib/workspaces/getWorkspacePackageInfo.d.ts +12 -9
  40. package/lib/workspaces/getWorkspacePackageInfo.js +14 -16
  41. package/lib/workspaces/getWorkspacePackageInfo.js.map +1 -1
  42. package/lib/workspaces/getWorkspaceRoot.d.ts +18 -2
  43. package/lib/workspaces/getWorkspaceRoot.js +23 -4
  44. package/lib/workspaces/getWorkspaceRoot.js.map +1 -1
  45. package/lib/workspaces/getWorkspaces.d.ts +11 -14
  46. package/lib/workspaces/getWorkspaces.js +8 -11
  47. package/lib/workspaces/getWorkspaces.js.map +1 -1
  48. package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +16 -9
  49. package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
  50. package/lib/workspaces/implementations/index.d.ts +2 -2
  51. package/lib/workspaces/implementations/index.js.map +1 -1
  52. package/lib/workspaces/implementations/lerna.d.ts +8 -8
  53. package/lib/workspaces/implementations/lerna.js +5 -5
  54. package/lib/workspaces/implementations/lerna.js.map +1 -1
  55. package/lib/workspaces/implementations/npm.d.ts +9 -9
  56. package/lib/workspaces/implementations/npm.js +6 -6
  57. package/lib/workspaces/implementations/npm.js.map +1 -1
  58. package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +21 -10
  59. package/lib/workspaces/implementations/packageJsonWorkspaces.js +34 -23
  60. package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +1 -1
  61. package/lib/workspaces/implementations/pnpm.d.ts +17 -9
  62. package/lib/workspaces/implementations/pnpm.js +37 -11
  63. package/lib/workspaces/implementations/pnpm.js.map +1 -1
  64. package/lib/workspaces/implementations/rush.d.ts +8 -8
  65. package/lib/workspaces/implementations/rush.js +5 -5
  66. package/lib/workspaces/implementations/rush.js.map +1 -1
  67. package/lib/workspaces/implementations/yarn.d.ts +18 -10
  68. package/lib/workspaces/implementations/yarn.js +51 -10
  69. package/lib/workspaces/implementations/yarn.js.map +1 -1
  70. package/lib/workspaces/listOfWorkspacePackageNames.d.ts +5 -2
  71. package/lib/workspaces/listOfWorkspacePackageNames.js +3 -0
  72. package/lib/workspaces/listOfWorkspacePackageNames.js.map +1 -1
  73. package/package.json +2 -3
@@ -0,0 +1,13 @@
1
+ import type { PackageInfo } from "./types/PackageInfo";
2
+ /**
3
+ * Read package.json from the given path if it exists.
4
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
5
+ * @returns The package info, or undefined if it doesn't exist or can't be read
6
+ */
7
+ export declare function getPackageInfo(cwd: string): PackageInfo | undefined;
8
+ /**
9
+ * Read package.json from the given path if it exists.
10
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
11
+ * @returns The package info, or undefined if it doesn't exist or can't be read
12
+ */
13
+ export declare function getPackageInfoAsync(cwd: string): Promise<PackageInfo | undefined>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPackageInfoAsync = exports.getPackageInfo = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const infoFromPackageJson_1 = require("./infoFromPackageJson");
11
+ const logging_1 = require("./logging");
12
+ /**
13
+ * Read package.json from the given path if it exists.
14
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
15
+ * @returns The package info, or undefined if it doesn't exist or can't be read
16
+ */
17
+ function getPackageInfo(cwd) {
18
+ const packageJsonPath = path_1.default.join(cwd, "package.json");
19
+ try {
20
+ if (!fs_1.default.existsSync(packageJsonPath)) {
21
+ (0, logging_1.logVerboseWarning)(`File does not exist: ${packageJsonPath}`);
22
+ return undefined;
23
+ }
24
+ const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
25
+ return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
26
+ }
27
+ catch (e) {
28
+ (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath}: ${e?.message || e}`);
29
+ }
30
+ }
31
+ exports.getPackageInfo = getPackageInfo;
32
+ /**
33
+ * Read package.json from the given path if it exists.
34
+ * Logs a warning if it doesn't exist, or there's an error reading or parsing it.
35
+ * @returns The package info, or undefined if it doesn't exist or can't be read
36
+ */
37
+ async function getPackageInfoAsync(cwd) {
38
+ const packageJsonPath = path_1.default.join(cwd, "package.json");
39
+ try {
40
+ if (!fs_1.default.existsSync(packageJsonPath)) {
41
+ (0, logging_1.logVerboseWarning)(`File does not exist: ${packageJsonPath}`);
42
+ return undefined;
43
+ }
44
+ const packageJson = JSON.parse(await promises_1.default.readFile(packageJsonPath, "utf-8"));
45
+ return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
46
+ }
47
+ catch (e) {
48
+ (0, logging_1.logVerboseWarning)(`Error reading or parsing ${packageJsonPath}: ${e?.message || e}`);
49
+ }
50
+ }
51
+ exports.getPackageInfoAsync = getPackageInfoAsync;
52
+ //# sourceMappingURL=getPackageInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPackageInfo.js","sourceRoot":"","sources":["../src/getPackageInfo.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,2DAAqC;AACrC,gDAAwB;AAExB,+DAA4D;AAC5D,uCAA8C;AAE9C;;;;GAIG;AACH,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI;QACF,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;YACnC,IAAA,2BAAiB,EAAC,wBAAwB,eAAe,EAAE,CAAC,CAAC;YAC7D,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,OAAO,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,KAAM,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;KACjG;AACH,CAAC;AAbD,wCAaC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CAAC,GAAW;IACnD,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI;QACF,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;YACnC,IAAA,2BAAiB,EAAC,wBAAwB,eAAe,EAAE,CAAC,CAAC;YAC7D,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAU,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;QACpF,OAAO,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;KAC1D;IAAC,OAAO,CAAC,EAAE;QACV,IAAA,2BAAiB,EAAC,4BAA4B,eAAe,KAAM,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;KACjG;AACH,CAAC;AAbD,kDAaC"}
@@ -1,3 +1,17 @@
1
1
  import { PackageInfos } from "./types/PackageInfo";
2
+ /**
3
+ * Read all the package.json files in a monorepo. Only works for monorepos which
4
+ * use a supported workspace manager.
5
+ * @param cwd Start looking for the workspace manager config from here
6
+ */
2
7
  export declare function getPackageInfos(cwd: string): PackageInfos;
8
+ /**
9
+ * Read all the package.json files in a monorepo. Only works for monorepos which
10
+ * use a supported workspace manager.
11
+ *
12
+ * NOTE: As of writing, this will start promises to read all package.json files in parallel,
13
+ * without direct concurrency control.
14
+ *
15
+ * @param cwd Start looking for the workspace manager config from here
16
+ */
3
17
  export declare function getPackageInfosAsync(cwd: string): Promise<PackageInfos>;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getPackageInfosAsync = exports.getPackageInfos = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const infoFromPackageJson_1 = require("./infoFromPackageJson");
10
4
  const getWorkspaces_1 = require("./workspaces/getWorkspaces");
5
+ const getPackageInfo_1 = require("./getPackageInfo");
6
+ /**
7
+ * Read all the package.json files in a monorepo. Only works for monorepos which
8
+ * use a supported workspace manager.
9
+ * @param cwd Start looking for the workspace manager config from here
10
+ */
11
11
  function getPackageInfos(cwd) {
12
12
  const packageInfos = {};
13
13
  const workspacePackages = (0, getWorkspaces_1.getWorkspaces)(cwd);
@@ -17,7 +17,7 @@ function getPackageInfos(cwd) {
17
17
  }
18
18
  }
19
19
  else {
20
- const rootInfo = tryReadRootPackageJson(cwd);
20
+ const rootInfo = (0, getPackageInfo_1.getPackageInfo)(cwd);
21
21
  if (rootInfo) {
22
22
  packageInfos[rootInfo.name] = rootInfo;
23
23
  }
@@ -25,6 +25,15 @@ function getPackageInfos(cwd) {
25
25
  return packageInfos;
26
26
  }
27
27
  exports.getPackageInfos = getPackageInfos;
28
+ /**
29
+ * Read all the package.json files in a monorepo. Only works for monorepos which
30
+ * use a supported workspace manager.
31
+ *
32
+ * NOTE: As of writing, this will start promises to read all package.json files in parallel,
33
+ * without direct concurrency control.
34
+ *
35
+ * @param cwd Start looking for the workspace manager config from here
36
+ */
28
37
  async function getPackageInfosAsync(cwd) {
29
38
  const packageInfos = {};
30
39
  const workspacePackages = await (0, getWorkspaces_1.getWorkspacesAsync)(cwd);
@@ -34,7 +43,7 @@ async function getPackageInfosAsync(cwd) {
34
43
  }
35
44
  }
36
45
  else {
37
- const rootInfo = tryReadRootPackageJson(cwd);
46
+ const rootInfo = (0, getPackageInfo_1.getPackageInfo)(cwd);
38
47
  if (rootInfo) {
39
48
  packageInfos[rootInfo.name] = rootInfo;
40
49
  }
@@ -42,16 +51,4 @@ async function getPackageInfosAsync(cwd) {
42
51
  return packageInfos;
43
52
  }
44
53
  exports.getPackageInfosAsync = getPackageInfosAsync;
45
- function tryReadRootPackageJson(cwd) {
46
- const packageJsonPath = path_1.default.join(cwd, "package.json");
47
- if (fs_1.default.existsSync(packageJsonPath)) {
48
- try {
49
- const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, "utf-8"));
50
- return (0, infoFromPackageJson_1.infoFromPackageJson)(packageJson, packageJsonPath);
51
- }
52
- catch (e) {
53
- throw new Error(`Invalid package.json file detected ${packageJsonPath}: ${e?.message || e}`);
54
- }
55
- }
56
- }
57
54
  //# sourceMappingURL=getPackageInfos.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../src/getPackageInfos.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,+DAA4D;AAC5D,8DAA+E;AAE/E,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,MAAM,iBAAiB,GAAG,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,iBAAiB,CAAC,MAAM,EAAE;QAC5B,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;YACnC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;SAC1C;KACF;SAAM;QACL,MAAM,QAAQ,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,QAAQ,EAAE;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;SACxC;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAhBD,0CAgBC;AAEM,KAAK,UAAU,oBAAoB,CAAC,GAAW;IACpD,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,MAAM,iBAAiB,GAAG,MAAM,IAAA,kCAAkB,EAAC,GAAG,CAAC,CAAC;IAExD,IAAI,iBAAiB,CAAC,MAAM,EAAE;QAC5B,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;YACnC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;SAC1C;KACF;SAAM;QACL,MAAM,QAAQ,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,QAAQ,EAAE;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;SACxC;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAhBD,oDAgBC;AAED,SAAS,sBAAsB,CAAC,GAAW;IACzC,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACvD,IAAI,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QAClC,IAAI;YACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;YAC1E,OAAO,IAAA,yCAAmB,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;SAC1D;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,sCAAsC,eAAe,KAAM,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;SACzG;KACF;AACH,CAAC"}
1
+ {"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../src/getPackageInfos.ts"],"names":[],"mappings":";;;AACA,8DAA+E;AAC/E,qDAAkD;AAElD;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,MAAM,iBAAiB,GAAG,IAAA,6BAAa,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,iBAAiB,CAAC,MAAM,EAAE;QAC5B,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;YACnC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;SAC1C;KACF;SAAM;QACL,MAAM,QAAQ,GAAG,IAAA,+BAAc,EAAC,GAAG,CAAC,CAAC;QACrC,IAAI,QAAQ,EAAE;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;SACxC;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAhBD,0CAgBC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,oBAAoB,CAAC,GAAW;IACpD,MAAM,YAAY,GAAiB,EAAE,CAAC;IACtC,MAAM,iBAAiB,GAAG,MAAM,IAAA,kCAAkB,EAAC,GAAG,CAAC,CAAC;IAExD,IAAI,iBAAiB,CAAC,MAAM,EAAE;QAC5B,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;YACnC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;SAC1C;KACF;SAAM;QACL,MAAM,QAAQ,GAAG,IAAA,+BAAc,EAAC,GAAG,CAAC,CAAC;QACrC,IAAI,QAAQ,EAAE;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;SACxC;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAhBD,oDAgBC"}
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Given package folder globs (such as those from package.json `workspaces`) and a workspace root
3
- * directory, get paths to actual package folders.
3
+ * directory, get absolute paths to actual package folders.
4
4
  */
5
5
  export declare function getPackagePaths(root: string, packageGlobs: string[]): string[];
6
6
  /**
7
7
  * Given package folder globs (such as those from package.json `workspaces`) and a workspace root
8
- * directory, get paths to actual package folders.
8
+ * directory, get absolute paths to actual package folders.
9
9
  */
10
10
  export declare function getPackagePathsAsync(root: string, packageGlobs: string[]): Promise<string[]>;
@@ -15,7 +15,7 @@ const globOptions = {
15
15
  };
16
16
  /**
17
17
  * Given package folder globs (such as those from package.json `workspaces`) and a workspace root
18
- * directory, get paths to actual package folders.
18
+ * directory, get absolute paths to actual package folders.
19
19
  */
20
20
  function getPackagePaths(root, packageGlobs) {
21
21
  if ((0, isCachingEnabled_1.isCachingEnabled)() && packagePathsCache[root]) {
@@ -29,7 +29,7 @@ function getPackagePaths(root, packageGlobs) {
29
29
  exports.getPackagePaths = getPackagePaths;
30
30
  /**
31
31
  * Given package folder globs (such as those from package.json `workspaces`) and a workspace root
32
- * directory, get paths to actual package folders.
32
+ * directory, get absolute paths to actual package folders.
33
33
  */
34
34
  async function getPackagePathsAsync(root, packageGlobs) {
35
35
  if ((0, isCachingEnabled_1.isCachingEnabled)() && packagePathsCache[root]) {
@@ -1,41 +1,170 @@
1
+ /**
2
+ * Get a list of files with untracked changes.
3
+ * Throws an error on failure.
4
+ *
5
+ * @returns An array of file paths with untracked changes
6
+ */
1
7
  export declare function getUntrackedChanges(cwd: string): string[];
8
+ /**
9
+ * Fetch from the given remote.
10
+ * Throws an error on failure.
11
+ */
2
12
  export declare function fetchRemote(remote: string, cwd: string): void;
13
+ /**
14
+ * Fetch from the given remote and branch.
15
+ * Throws an error on failure.
16
+ */
3
17
  export declare function fetchRemoteBranch(remote: string, remoteBranch: string, cwd: string): void;
4
18
  /**
5
- * Gets all the changes that have not been staged yet
6
- * @param cwd
19
+ * Gets file paths with changes that have not been staged yet.
20
+ * Throws an error on failure.
21
+ *
22
+ * @returns An array of relative file paths with unstaged changes
7
23
  */
8
24
  export declare function getUnstagedChanges(cwd: string): string[];
25
+ /**
26
+ * Gets file paths with changes between the current branch and the given branch.
27
+ * Throws an error on failure.
28
+ *
29
+ * @returns An array of relative file paths that have changed
30
+ */
9
31
  export declare function getChanges(branch: string, cwd: string): string[];
10
32
  /**
11
- * Gets all the changes between the branch and the merge-base
33
+ * Gets file paths with changes between the branch and the merge-base.
34
+ *
35
+ * @returns An array of relative file paths that have changed
12
36
  */
13
37
  export declare function getBranchChanges(branch: string, cwd: string): string[];
38
+ /**
39
+ * Gets file paths with changes between two git references (commits, branches, tags).
40
+ * Throws an error on failure.
41
+ *
42
+ * @param fromRef - The starting reference
43
+ * @param toRef - The ending reference
44
+ * @param options - Additional git diff options
45
+ * @param pattern - Optional file pattern to filter results
46
+ * @param cwd - The working directory
47
+ * @returns An array of file paths that have changed
48
+ */
14
49
  export declare function getChangesBetweenRefs(fromRef: string, toRef: string, options: string[], pattern: string, cwd: string): string[];
50
+ /**
51
+ * Gets all files with staged changes (files added to the index).
52
+ * Throws an error on failure.
53
+ *
54
+ * @returns An array of relative file paths that have been staged
55
+ */
15
56
  export declare function getStagedChanges(cwd: string): string[];
57
+ /**
58
+ * Gets recent commit messages between the specified branch and HEAD.
59
+ * Returns an empty array if the operation fails.
60
+ *
61
+ * @returns An array of commit message strings
62
+ */
16
63
  export declare function getRecentCommitMessages(branch: string, cwd: string): string[];
64
+ /**
65
+ * Gets the user email from the git config.
66
+ * @returns The email string if found, null otherwise
67
+ */
17
68
  export declare function getUserEmail(cwd: string): string | null;
69
+ /**
70
+ * Gets the current branch name.
71
+ * @returns The branch name if successful, null otherwise
72
+ */
18
73
  export declare function getBranchName(cwd: string): string | null;
74
+ /**
75
+ * Gets the full reference path for a given branch.
76
+ * @param branch - The short branch name (e.g., `branch-name`)
77
+ * @returns The full branch reference (e.g., `refs/heads/branch-name`) if found, null otherwise
78
+ */
19
79
  export declare function getFullBranchRef(branch: string, cwd: string): string | null;
80
+ /**
81
+ * Gets the short branch name from a full branch reference.
82
+ * Note this may not work properly for the current branch.
83
+ * @param fullBranchRef - The full branch reference (e.g., `refs/heads/branch-name`)
84
+ * @returns The short branch name if successful, null otherwise
85
+ */
20
86
  export declare function getShortBranchName(fullBranchRef: string, cwd: string): string | null;
87
+ /**
88
+ * Gets the current commit hash (SHA).
89
+ * @returns The hash if successful, null otherwise
90
+ */
21
91
  export declare function getCurrentHash(cwd: string): string | null;
22
92
  /**
23
93
  * Get the commit hash in which the file was first added.
94
+ * @returns The commit hash if found, undefined otherwise
24
95
  */
25
96
  export declare function getFileAddedHash(filename: string, cwd: string): string | undefined;
97
+ /**
98
+ * Initializes a git repository in the specified directory.
99
+ * Optionally sets user email and username if not already configured.
100
+ * Throws an error if required email or username is not provided and not already configured.
101
+ *
102
+ * @param cwd - The directory to initialize the git repository in
103
+ * @param email - Optional email to set in git config
104
+ * @param username - Optional username to set in git config
105
+ */
26
106
  export declare function init(cwd: string, email?: string, username?: string): void;
107
+ /**
108
+ * Stages files matching the given patterns.
109
+ */
27
110
  export declare function stage(patterns: string[], cwd: string): void;
111
+ /**
112
+ * Creates a commit with the given message and optional git commit options.
113
+ * Throws an error on failure.
114
+ *
115
+ * @param message - The commit message
116
+ * @param cwd - The working directory
117
+ * @param options - Additional git commit options
118
+ */
28
119
  export declare function commit(message: string, cwd: string, options?: string[]): void;
120
+ /**
121
+ * Stages files matching the given patterns and creates a commit with the specified message.
122
+ * Convenience function that combines `stage()` and `commit()`.
123
+ * Throws an error on commit failure.
124
+ *
125
+ * @param patterns - File patterns to stage
126
+ * @param message - The commit message
127
+ * @param cwd - The working directory
128
+ * @param commitOptions - Additional git commit options
129
+ */
29
130
  export declare function stageAndCommit(patterns: string[], message: string, cwd: string, commitOptions?: string[]): void;
131
+ /**
132
+ * Reverts all local changes (both staged and unstaged) by stashing them and then dropping the stash.
133
+ * @returns True if the revert was successful, false otherwise
134
+ */
30
135
  export declare function revertLocalChanges(cwd: string): boolean;
136
+ /**
137
+ * Attempts to determine the parent branch of the current branch using `git show-branch`.
138
+ *
139
+ * @returns The parent branch name if found, null otherwise
140
+ */
31
141
  export declare function getParentBranch(cwd: string): string | null;
142
+ /**
143
+ * Gets the remote tracking branch for the specified branch.
144
+ *
145
+ * @returns The remote branch name (e.g., `origin/main`) if found, null otherwise
146
+ */
32
147
  export declare function getRemoteBranch(branch: string, cwd: string): string | null;
148
+ /**
149
+ * Parses a remote branch string (e.g., `origin/main`) into its components.
150
+ *
151
+ * @param branch - The remote branch string to parse (e.g., `origin/main`)
152
+ */
33
153
  export declare function parseRemoteBranch(branch: string): {
154
+ /** Remote name, e.g. `origin` */
34
155
  remote: string;
156
+ /** Remote branch name, e.g. `main` */
35
157
  remoteBranch: string;
36
158
  };
37
159
  /**
38
160
  * Gets the default branch based on `git config init.defaultBranch`, falling back to `master`.
39
161
  */
40
162
  export declare function getDefaultBranch(cwd: string): string;
163
+ /**
164
+ * Lists all tracked files matching the given patterns.
165
+ *
166
+ * @param patterns - File patterns to match (passed to git ls-files)
167
+ * @param cwd - The working directory
168
+ * @returns An array of file paths, or an empty array if no files are found
169
+ */
41
170
  export declare function listAllTrackedFiles(patterns: string[], cwd: string): string[];