workspace-tools 0.19.0 → 0.19.3
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/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +22 -0
- package/docs/assets/icons.css +1043 -0
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/docs/assets/main.js +52 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1414 -0
- package/docs/assets/widgets.png +0 -0
- package/docs/assets/widgets@2x.png +0 -0
- package/docs/index.html +42 -0
- package/docs/interfaces/NpmLockFile.html +1 -0
- package/docs/interfaces/NpmSymlinkInfo.html +1 -0
- package/docs/interfaces/NpmWorkspacesInfo.html +1 -0
- package/docs/interfaces/PackageInfo.html +1 -0
- package/docs/interfaces/PackageInfos.html +1 -0
- package/docs/interfaces/PnpmLockFile.html +1 -0
- package/docs/modules.html +70 -0
- package/lib/git.d.ts +7 -10
- package/lib/git.js +13 -23
- package/package.json +6 -2
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);
|
|
@@ -85,7 +75,7 @@ function getUntrackedChanges(cwd) {
|
|
|
85
75
|
if (changes.length == 0) {
|
|
86
76
|
return [];
|
|
87
77
|
}
|
|
88
|
-
const lines = changes.split(
|
|
78
|
+
const lines = changes.split(/[\r\n]+/).filter((line) => line) || [];
|
|
89
79
|
const untracked = [];
|
|
90
80
|
for (let i = 0; i < lines.length; i++) {
|
|
91
81
|
const line = lines[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-tools",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"types": "lib/index.d.ts",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsc",
|
|
13
|
+
"build:docs": "typedoc src/index.ts",
|
|
14
|
+
"release:docs": "typedoc src/index.ts && gh-pages -d docs",
|
|
13
15
|
"change": "beachball change",
|
|
14
16
|
"checkchange": "beachball check",
|
|
15
17
|
"release": "beachball publish -y",
|
|
@@ -38,6 +40,8 @@
|
|
|
38
40
|
"jest": "^25.0.0",
|
|
39
41
|
"tmp": "^0.2.1",
|
|
40
42
|
"ts-jest": "^25.5.1",
|
|
41
|
-
"
|
|
43
|
+
"typedoc": "^0.22.15",
|
|
44
|
+
"typescript": "^4.5.4",
|
|
45
|
+
"gh-pages": "^3.2.3"
|
|
42
46
|
}
|
|
43
47
|
}
|