workspace-tools 0.19.1 → 0.19.4
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/CHANGELOG.json +46 -1
- package/CHANGELOG.md +26 -2
- package/lib/git.d.ts +7 -10
- package/lib/git.js +12 -22
- package/lib/paths.d.ts +15 -3
- package/lib/paths.js +28 -7
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,52 @@
|
|
|
2
2
|
"name": "workspace-tools",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 23 Jun 2022 19:53:00 GMT",
|
|
6
|
+
"tag": "workspace-tools_v0.19.4",
|
|
7
|
+
"version": "0.19.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "elcraig@microsoft.com",
|
|
12
|
+
"package": "workspace-tools",
|
|
13
|
+
"comment": "Add findProjectRoot path helper",
|
|
14
|
+
"commit": "5ad6577811656ad23cf567f0996cf9b70d8c23a0"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Thu, 23 Jun 2022 19:10:04 GMT",
|
|
21
|
+
"tag": "workspace-tools_v0.19.3",
|
|
22
|
+
"version": "0.19.3",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "elcraig@microsoft.com",
|
|
27
|
+
"package": "workspace-tools",
|
|
28
|
+
"comment": "Move typedoc to devDependencies",
|
|
29
|
+
"commit": "8dbb9af66b8e1564734861d23849957b22dbe870"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Thu, 23 Jun 2022 18:52:05 GMT",
|
|
36
|
+
"tag": "workspace-tools_v0.19.2",
|
|
37
|
+
"version": "0.19.2",
|
|
38
|
+
"comments": {
|
|
39
|
+
"patch": [
|
|
40
|
+
{
|
|
41
|
+
"author": "elcraig@microsoft.com",
|
|
42
|
+
"package": "workspace-tools",
|
|
43
|
+
"comment": "Allow full spawnSync options for git methods",
|
|
44
|
+
"commit": "cf0a0d77be58988e411d0349c8a009642770696e"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"date": "Fri, 03 Jun 2022 16:57:07 GMT",
|
|
6
51
|
"tag": "workspace-tools_v0.19.1",
|
|
7
52
|
"version": "0.19.1",
|
|
8
53
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
# Change Log - workspace-tools
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 23 Jun 2022 19:53:00 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 0.19.4
|
|
8
|
+
|
|
9
|
+
Thu, 23 Jun 2022 19:53:00 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Add findProjectRoot path helper (elcraig@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 0.19.3
|
|
16
|
+
|
|
17
|
+
Thu, 23 Jun 2022 19:10:04 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Move typedoc to devDependencies (elcraig@microsoft.com)
|
|
22
|
+
|
|
23
|
+
## 0.19.2
|
|
24
|
+
|
|
25
|
+
Thu, 23 Jun 2022 18:52:05 GMT
|
|
26
|
+
|
|
27
|
+
### Patches
|
|
28
|
+
|
|
29
|
+
- Allow full spawnSync options for git methods (elcraig@microsoft.com)
|
|
30
|
+
|
|
7
31
|
## 0.19.1
|
|
8
32
|
|
|
9
|
-
Fri, 03 Jun 2022 16:57:
|
|
33
|
+
Fri, 03 Jun 2022 16:57:07 GMT
|
|
10
34
|
|
|
11
35
|
### Patches
|
|
12
36
|
|
package/lib/git.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SpawnSyncOptions } from "child_process";
|
|
1
3
|
declare type ProcessOutput = {
|
|
2
4
|
stderr: string;
|
|
3
5
|
stdout: string;
|
|
4
6
|
success: boolean;
|
|
5
7
|
};
|
|
8
|
+
/** Observes the git operations called from `git()` or `gitFailFast()` */
|
|
6
9
|
declare type GitObserver = (args: string[], output: ProcessOutput) => void;
|
|
7
10
|
/**
|
|
8
11
|
* Adds an observer for the git operations, e.g. for testing
|
|
@@ -10,19 +13,13 @@ declare type GitObserver = (args: string[], output: ProcessOutput) => void;
|
|
|
10
13
|
*/
|
|
11
14
|
export declare function addGitObserver(observer: GitObserver): void;
|
|
12
15
|
/**
|
|
13
|
-
* Runs git command - use this for read
|
|
16
|
+
* Runs git command - use this for read-only commands
|
|
14
17
|
*/
|
|
15
|
-
export declare function git(args: string[], options?:
|
|
16
|
-
cwd: string;
|
|
17
|
-
maxBuffer?: number;
|
|
18
|
-
}): ProcessOutput;
|
|
18
|
+
export declare function git(args: string[], options?: SpawnSyncOptions): ProcessOutput;
|
|
19
19
|
/**
|
|
20
|
-
* Runs git command - use this for commands that
|
|
20
|
+
* Runs git command - use this for commands that make changes to the filesystem
|
|
21
21
|
*/
|
|
22
|
-
export declare function gitFailFast(args: string[], options?:
|
|
23
|
-
cwd: string;
|
|
24
|
-
maxBuffer?: number;
|
|
25
|
-
}): void;
|
|
22
|
+
export declare function gitFailFast(args: string[], options?: SpawnSyncOptions): void;
|
|
26
23
|
export declare function getUntrackedChanges(cwd: string): string[];
|
|
27
24
|
export declare function fetchRemote(remote: string, cwd: string): void;
|
|
28
25
|
export declare function fetchRemoteBranch(remote: string, remoteBranch: string, cwd: string): void;
|
package/lib/git.js
CHANGED
|
@@ -16,11 +16,11 @@ function gitError(message, e) {
|
|
|
16
16
|
return new Error(message);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* A maxBuffer override
|
|
20
|
-
* Bumps up the default to 500MB
|
|
21
|
-
* Override this value with
|
|
19
|
+
* A global maxBuffer override for all git operations.
|
|
20
|
+
* Bumps up the default to 500MB instead of 1MB.
|
|
21
|
+
* Override this value with the `GIT_MAX_BUFFER` environment variable.
|
|
22
22
|
*/
|
|
23
|
-
const
|
|
23
|
+
const defaultMaxBuffer = process.env.GIT_MAX_BUFFER ? parseInt(process.env.GIT_MAX_BUFFER) : 500 * 1024 * 1024;
|
|
24
24
|
const observers = [];
|
|
25
25
|
let observing;
|
|
26
26
|
/**
|
|
@@ -32,25 +32,15 @@ function addGitObserver(observer) {
|
|
|
32
32
|
}
|
|
33
33
|
exports.addGitObserver = addGitObserver;
|
|
34
34
|
/**
|
|
35
|
-
* Runs git command - use this for read
|
|
35
|
+
* Runs git command - use this for read-only commands
|
|
36
36
|
*/
|
|
37
37
|
function git(args, options) {
|
|
38
|
-
const results = (0, child_process_1.spawnSync)("git", args, Object.assign({ maxBuffer:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
success: true,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
output = {
|
|
49
|
-
stderr: results.stderr.toString().trimRight(),
|
|
50
|
-
stdout: results.stdout.toString().trimRight(),
|
|
51
|
-
success: false,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
38
|
+
const results = (0, child_process_1.spawnSync)("git", args, Object.assign({ maxBuffer: defaultMaxBuffer }, options));
|
|
39
|
+
const output = {
|
|
40
|
+
stderr: results.stderr.toString().trimRight(),
|
|
41
|
+
stdout: results.stdout.toString().trimRight(),
|
|
42
|
+
success: results.status === 0
|
|
43
|
+
};
|
|
54
44
|
// notify observers, flipping the observing bit to prevent infinite loops
|
|
55
45
|
if (!observing) {
|
|
56
46
|
observing = true;
|
|
@@ -63,7 +53,7 @@ function git(args, options) {
|
|
|
63
53
|
}
|
|
64
54
|
exports.git = git;
|
|
65
55
|
/**
|
|
66
|
-
* Runs git command - use this for commands that
|
|
56
|
+
* Runs git command - use this for commands that make changes to the filesystem
|
|
67
57
|
*/
|
|
68
58
|
function gitFailFast(args, options) {
|
|
69
59
|
const gitResult = git(args, options);
|
package/lib/paths.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Starting from `cwd`, searches up the directory hierarchy for `pathName
|
|
3
|
-
* @param pathName
|
|
4
|
-
* @param cwd
|
|
2
|
+
* Starting from `cwd`, searches up the directory hierarchy for `pathName`.
|
|
5
3
|
*/
|
|
6
4
|
export declare function searchUp(pathName: string, cwd: string): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* Starting from `cwd`, searches up the directory hierarchy for `.git`.
|
|
7
|
+
*/
|
|
7
8
|
export declare function findGitRoot(cwd: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Starting from `cwd`, searches up the directory hierarchy for `package.json`.
|
|
11
|
+
*/
|
|
8
12
|
export declare function findPackageRoot(cwd: string): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Starting from `cwd`, searches up the directory hierarchy for the workspace root,
|
|
15
|
+
* falling back to the git root if no workspace is detected.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findProjectRoot(cwd: string): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Get the folder containing beachball change files.
|
|
20
|
+
*/
|
|
9
21
|
export declare function getChangePath(cwd: string): string | null;
|
|
10
22
|
export declare function isChildOf(child: string, parent: string): boolean;
|
package/lib/paths.js
CHANGED
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isChildOf = exports.getChangePath = exports.findPackageRoot = exports.findGitRoot = exports.searchUp = void 0;
|
|
6
|
+
exports.isChildOf = exports.getChangePath = exports.findProjectRoot = exports.findPackageRoot = exports.findGitRoot = exports.searchUp = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const getWorkspaceRoot_1 = require("./workspaces/getWorkspaceRoot");
|
|
9
10
|
/**
|
|
10
|
-
* Starting from `cwd`, searches up the directory hierarchy for `pathName
|
|
11
|
-
* @param pathName
|
|
12
|
-
* @param cwd
|
|
11
|
+
* Starting from `cwd`, searches up the directory hierarchy for `pathName`.
|
|
13
12
|
*/
|
|
14
13
|
function searchUp(pathName, cwd) {
|
|
15
14
|
const root = path_1.default.parse(cwd).root;
|
|
@@ -27,18 +26,40 @@ function searchUp(pathName, cwd) {
|
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
28
|
exports.searchUp = searchUp;
|
|
29
|
+
/**
|
|
30
|
+
* Starting from `cwd`, searches up the directory hierarchy for `.git`.
|
|
31
|
+
*/
|
|
30
32
|
function findGitRoot(cwd) {
|
|
31
|
-
return searchUp(
|
|
33
|
+
return searchUp(".git", cwd);
|
|
32
34
|
}
|
|
33
35
|
exports.findGitRoot = findGitRoot;
|
|
36
|
+
/**
|
|
37
|
+
* Starting from `cwd`, searches up the directory hierarchy for `package.json`.
|
|
38
|
+
*/
|
|
34
39
|
function findPackageRoot(cwd) {
|
|
35
|
-
return searchUp(
|
|
40
|
+
return searchUp("package.json", cwd);
|
|
36
41
|
}
|
|
37
42
|
exports.findPackageRoot = findPackageRoot;
|
|
43
|
+
/**
|
|
44
|
+
* Starting from `cwd`, searches up the directory hierarchy for the workspace root,
|
|
45
|
+
* falling back to the git root if no workspace is detected.
|
|
46
|
+
*/
|
|
47
|
+
function findProjectRoot(cwd) {
|
|
48
|
+
let workspaceRoot;
|
|
49
|
+
try {
|
|
50
|
+
workspaceRoot = (0, getWorkspaceRoot_1.getWorkspaceRoot)(cwd);
|
|
51
|
+
}
|
|
52
|
+
catch (_a) { }
|
|
53
|
+
return workspaceRoot || findGitRoot(cwd);
|
|
54
|
+
}
|
|
55
|
+
exports.findProjectRoot = findProjectRoot;
|
|
56
|
+
/**
|
|
57
|
+
* Get the folder containing beachball change files.
|
|
58
|
+
*/
|
|
38
59
|
function getChangePath(cwd) {
|
|
39
60
|
const gitRoot = findGitRoot(cwd);
|
|
40
61
|
if (gitRoot) {
|
|
41
|
-
return path_1.default.join(gitRoot,
|
|
62
|
+
return path_1.default.join(gitRoot, "change");
|
|
42
63
|
}
|
|
43
64
|
return null;
|
|
44
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-tools",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
"globby": "^11.0.0",
|
|
26
26
|
"jju": "^1.4.0",
|
|
27
27
|
"multimatch": "^4.0.0",
|
|
28
|
-
"read-yaml-file": "^2.0.0"
|
|
29
|
-
"typedoc": "^0.22.15"
|
|
28
|
+
"read-yaml-file": "^2.0.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@types/git-url-parse": "^9.0.0",
|
|
@@ -41,6 +40,7 @@
|
|
|
41
40
|
"jest": "^25.0.0",
|
|
42
41
|
"tmp": "^0.2.1",
|
|
43
42
|
"ts-jest": "^25.5.1",
|
|
43
|
+
"typedoc": "^0.22.15",
|
|
44
44
|
"typescript": "^4.5.4",
|
|
45
45
|
"gh-pages": "^3.2.3"
|
|
46
46
|
}
|