workspace-tools 0.38.3 → 0.38.5
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/lib/getPackageInfos.d.ts +14 -0
- package/lib/getPackageInfos.js +17 -20
- package/lib/getPackageInfos.js.map +1 -1
- package/lib/getPackagePaths.d.ts +2 -2
- package/lib/getPackagePaths.js +2 -2
- package/lib/git/getRepositoryName.js +6 -6
- package/lib/git/getRepositoryName.js.map +1 -1
- package/lib/git/git.d.ts +10 -2
- package/lib/git/git.js +15 -3
- package/lib/git/git.js.map +1 -1
- package/lib/git/gitUtilities.d.ts +132 -3
- package/lib/git/gitUtilities.js +141 -4
- package/lib/git/gitUtilities.js.map +1 -1
- package/lib/graph/createDependencyMap.d.ts +1 -1
- package/lib/graph/createDependencyMap.js.map +1 -1
- package/lib/graph/getPackageDependencies.d.ts +10 -1
- package/lib/graph/getPackageDependencies.js +17 -5
- package/lib/graph/getPackageDependencies.js.map +1 -1
- package/lib/index.d.ts +17 -14
- package/lib/index.js +40 -15
- package/lib/index.js.map +1 -1
- package/lib/lockfile/parseBerryLock.d.ts +3 -0
- package/lib/lockfile/parseBerryLock.js +3 -0
- package/lib/lockfile/parseBerryLock.js.map +1 -1
- package/lib/lockfile/types.d.ts +3 -0
- package/lib/paths.d.ts +3 -0
- package/lib/paths.js +4 -1
- package/lib/paths.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types/Catalogs.d.ts +30 -0
- package/lib/types/Catalogs.js +3 -0
- package/lib/types/Catalogs.js.map +1 -0
- package/lib/types/PackageInfo.d.ts +19 -1
- package/lib/types/WorkspaceInfo.d.ts +15 -6
- package/lib/workspaces/catalogs.d.ts +28 -0
- package/lib/workspaces/catalogs.js +57 -0
- package/lib/workspaces/catalogs.js.map +1 -0
- package/lib/workspaces/findWorkspacePath.d.ts +5 -5
- package/lib/workspaces/findWorkspacePath.js +3 -3
- package/lib/workspaces/findWorkspacePath.js.map +1 -1
- package/lib/workspaces/getWorkspacePackageInfo.d.ts +12 -9
- package/lib/workspaces/getWorkspacePackageInfo.js +14 -16
- package/lib/workspaces/getWorkspacePackageInfo.js.map +1 -1
- package/lib/workspaces/getWorkspaceRoot.d.ts +18 -2
- package/lib/workspaces/getWorkspaceRoot.js +23 -4
- package/lib/workspaces/getWorkspaceRoot.js.map +1 -1
- package/lib/workspaces/getWorkspaces.d.ts +11 -14
- package/lib/workspaces/getWorkspaces.js +8 -11
- package/lib/workspaces/getWorkspaces.js.map +1 -1
- package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +16 -9
- package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
- package/lib/workspaces/implementations/index.d.ts +2 -2
- package/lib/workspaces/implementations/index.js.map +1 -1
- package/lib/workspaces/implementations/lerna.d.ts +8 -8
- package/lib/workspaces/implementations/lerna.js +5 -5
- package/lib/workspaces/implementations/lerna.js.map +1 -1
- package/lib/workspaces/implementations/npm.d.ts +9 -9
- package/lib/workspaces/implementations/npm.js +6 -6
- package/lib/workspaces/implementations/npm.js.map +1 -1
- package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +21 -10
- package/lib/workspaces/implementations/packageJsonWorkspaces.js +34 -23
- package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +1 -1
- package/lib/workspaces/implementations/pnpm.d.ts +17 -9
- package/lib/workspaces/implementations/pnpm.js +37 -11
- package/lib/workspaces/implementations/pnpm.js.map +1 -1
- package/lib/workspaces/implementations/rush.d.ts +8 -8
- package/lib/workspaces/implementations/rush.js +5 -5
- package/lib/workspaces/implementations/rush.js.map +1 -1
- package/lib/workspaces/implementations/yarn.d.ts +18 -10
- package/lib/workspaces/implementations/yarn.js +51 -10
- package/lib/workspaces/implementations/yarn.js.map +1 -1
- package/lib/workspaces/listOfWorkspacePackageNames.d.ts +5 -2
- package/lib/workspaces/listOfWorkspacePackageNames.js +3 -0
- package/lib/workspaces/listOfWorkspacePackageNames.js.map +1 -1
- package/lib/workspaces/readPackageInfo.d.ts +13 -0
- package/lib/workspaces/readPackageInfo.js +52 -0
- package/lib/workspaces/readPackageInfo.js.map +1 -0
- package/package.json +3 -4
package/lib/getPackageInfos.d.ts
CHANGED
|
@@ -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>;
|
package/lib/getPackageInfos.js
CHANGED
|
@@ -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 readPackageInfo_1 = require("./workspaces/readPackageInfo");
|
|
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 =
|
|
20
|
+
const rootInfo = (0, readPackageInfo_1.readPackageInfo)(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 =
|
|
46
|
+
const rootInfo = (0, readPackageInfo_1.readPackageInfo)(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":"
|
|
1
|
+
{"version":3,"file":"getPackageInfos.js","sourceRoot":"","sources":["../src/getPackageInfos.ts"],"names":[],"mappings":";;;AACA,8DAA+E;AAC/E,kEAA+D;AAE/D;;;;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,iCAAe,EAAC,GAAG,CAAC,CAAC;QACtC,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,iCAAe,EAAC,GAAG,CAAC,CAAC;QACtC,IAAI,QAAQ,EAAE;YACZ,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;SACxC;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAhBD,oDAgBC"}
|
package/lib/getPackagePaths.d.ts
CHANGED
|
@@ -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[]>;
|
package/lib/getPackagePaths.js
CHANGED
|
@@ -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]) {
|
|
@@ -26,11 +26,11 @@ function getRepositoryName(url) {
|
|
|
26
26
|
// https://dev.azure.com/foo/bar/_git/_optimized/some-repo
|
|
27
27
|
// https://user@dev.azure.com/foo/bar/_git/some-repo
|
|
28
28
|
// git@ssh.dev.azure.com:v3/foo/bar/some-repo
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
if (!isVSO &&
|
|
29
|
+
const parsedUrl = (0, git_url_parse_1.default)(url.replace("/_optimized/", "/").replace("/DefaultCollection/", "/"));
|
|
30
|
+
// `host` is set in `parse-url` but not documented... https://github.com/IonicaBizau/parse-url/blob/c830d48647f33c054745a916cf7c4c58722f4b25/src/index.js#L28
|
|
31
|
+
const host = parsedUrl.host || "";
|
|
32
|
+
const isVSO = host.endsWith(".visualstudio.com");
|
|
33
|
+
if (!isVSO && host !== "dev.azure.com" && host !== "ssh.dev.azure.com") {
|
|
34
34
|
return parsedUrl.full_name;
|
|
35
35
|
}
|
|
36
36
|
// As of writing, ADO and VSO SSH URLs are parsed completely wrong
|
|
@@ -43,7 +43,7 @@ function getRepositoryName(url) {
|
|
|
43
43
|
let organization = parsedUrl.organization;
|
|
44
44
|
if (!organization && isVSO) {
|
|
45
45
|
// organization is missing or wrong for VSO
|
|
46
|
-
organization =
|
|
46
|
+
organization = host.match(/([^.@]+)\.visualstudio\.com$/)?.[1];
|
|
47
47
|
}
|
|
48
48
|
return `${organization}/${parsedUrl.owner}/${parsedUrl.name}`;
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/git/getRepositoryName.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AAExC;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI;QACF,4FAA4F;QAC5F,sFAAsF;QACtF,kDAAkD;QAClD,oEAAoE;QACpE,+EAA+E;QAC/E,+EAA+E;QAC/E,mDAAmD;QACnD,+CAA+C;QAC/C,0DAA0D;QAC1D,oDAAoD;QACpD,6CAA6C;QAC7C,
|
|
1
|
+
{"version":3,"file":"getRepositoryName.js","sourceRoot":"","sources":["../../src/git/getRepositoryName.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AAExC;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI;QACF,4FAA4F;QAC5F,sFAAsF;QACtF,kDAAkD;QAClD,oEAAoE;QACpE,+EAA+E;QAC/E,+EAA+E;QAC/E,mDAAmD;QACnD,+CAA+C;QAC/C,0DAA0D;QAC1D,oDAAoD;QACpD,6CAA6C;QAC7C,MAAM,SAAS,GAAG,IAAA,uBAAW,EAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC,CAAC;QAEpG,6JAA6J;QAC7J,MAAM,IAAI,GAAY,SAAiB,CAAC,IAAI,IAAI,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,IAAI,IAAI,KAAK,eAAe,IAAI,IAAI,KAAK,mBAAmB,EAAE;YACtE,OAAO,SAAS,CAAC,SAAS,CAAC;SAC5B;QAED,kEAAkE;QAClE,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,KAAK,CACxC,yEAAyE,CAC1E,CAAC;QACF,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;SAC1D;QAED,oFAAoF;QACpF,8CAA8C;QAC9C,IAAI,YAAY,GAAuB,SAAS,CAAC,YAAY,CAAC;QAC9D,IAAI,CAAC,YAAY,IAAI,KAAK,EAAE;YAC1B,2CAA2C;YAC3C,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAChE;QACD,OAAO,GAAG,YAAY,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;KAC/D;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAzCD,8CAyCC"}
|
package/lib/git/git.d.ts
CHANGED
|
@@ -22,11 +22,19 @@ export declare function addGitObserver(observer: GitObserver): () => void;
|
|
|
22
22
|
/** Clear all git observers */
|
|
23
23
|
export declare function clearGitObservers(): void;
|
|
24
24
|
/**
|
|
25
|
-
* Runs git command - use this for read-only commands
|
|
25
|
+
* Runs git command - use this for read-only commands.
|
|
26
|
+
* `gitFailFast` is recommended for commands that make changes to the filesystem.
|
|
27
|
+
*
|
|
28
|
+
* The caller is responsible for validating the input.
|
|
29
|
+
* `shell` will always be set to false.
|
|
26
30
|
*/
|
|
27
31
|
export declare function git(args: string[], options?: SpawnSyncOptions): GitProcessOutput;
|
|
28
32
|
/**
|
|
29
|
-
* Runs git command
|
|
33
|
+
* Runs git command and throws an error if it fails.
|
|
34
|
+
* Use this for commands that make changes to the filesystem.
|
|
35
|
+
*
|
|
36
|
+
* The caller is responsible for validating the input.
|
|
37
|
+
* `shell` will always be set to false.
|
|
30
38
|
*/
|
|
31
39
|
export declare function gitFailFast(args: string[], options?: SpawnSyncOptions & {
|
|
32
40
|
noExitCode?: boolean;
|
package/lib/git/git.js
CHANGED
|
@@ -48,11 +48,19 @@ function removeGitObserver(observer) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Runs git command - use this for read-only commands
|
|
51
|
+
* Runs git command - use this for read-only commands.
|
|
52
|
+
* `gitFailFast` is recommended for commands that make changes to the filesystem.
|
|
53
|
+
*
|
|
54
|
+
* The caller is responsible for validating the input.
|
|
55
|
+
* `shell` will always be set to false.
|
|
52
56
|
*/
|
|
53
57
|
function git(args, options) {
|
|
54
58
|
isDebug && console.log(`git ${args.join(" ")}`);
|
|
55
|
-
|
|
59
|
+
if (args.some((arg) => arg.startsWith("--upload-pack"))) {
|
|
60
|
+
// This is a security issue and not needed for any expected usage of this library.
|
|
61
|
+
throw new GitError("git command contains --upload-pack, which is not allowed: " + args.join(" "));
|
|
62
|
+
}
|
|
63
|
+
const results = (0, child_process_1.spawnSync)("git", args, { maxBuffer: defaultMaxBuffer, ...options, shell: false });
|
|
56
64
|
const output = {
|
|
57
65
|
...results,
|
|
58
66
|
// these may be undefined if stdio: inherit is set
|
|
@@ -77,7 +85,11 @@ function git(args, options) {
|
|
|
77
85
|
}
|
|
78
86
|
exports.git = git;
|
|
79
87
|
/**
|
|
80
|
-
* Runs git command
|
|
88
|
+
* Runs git command and throws an error if it fails.
|
|
89
|
+
* Use this for commands that make changes to the filesystem.
|
|
90
|
+
*
|
|
91
|
+
* The caller is responsible for validating the input.
|
|
92
|
+
* `shell` will always be set to false.
|
|
81
93
|
*/
|
|
82
94
|
function gitFailFast(args, options) {
|
|
83
95
|
const gitResult = git(args, options);
|
package/lib/git/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git/git.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,qBAAqB;AACrB,EAAE;;;AAGF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AC,SAAS,EAAE;QACd,SAAS,GAAG,IAAI,CAAC;QACjB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SACxB;QACD,SAAS,GAAG,KAAK,CAAC;KACnB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,kBAiCC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,IAAc,EAAE,OAAqD;IAC/F,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;QACtB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;YACxB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;SACtB;QAED,MAAM,IAAI,QAAQ,CAAC,4CAA4C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;MAC3E,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE;MACtC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;KAC7C;AACH,CAAC;AAXD,kCAWC"}
|
|
@@ -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
|
|
6
|
-
*
|
|
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
|
|
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[];
|