@tapjs/processinfo 1.0.0 → 1.0.1
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/index.d.ts +55 -0
- package/lib/process-info-node.cjs +14 -6
- package/package.json +4 -3
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import {
|
|
3
|
+
spawn,
|
|
4
|
+
spawnSync,
|
|
5
|
+
exec,
|
|
6
|
+
execSync,
|
|
7
|
+
execFile,
|
|
8
|
+
execFileSync,
|
|
9
|
+
} from 'node:child_process'
|
|
10
|
+
|
|
11
|
+
declare interface ProcessInfoOptions {
|
|
12
|
+
dir?: string
|
|
13
|
+
exclude?: RegExp
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare class ProcessInfoNode {
|
|
17
|
+
public parent: ProcessInfoNode | null
|
|
18
|
+
public children: ProcessInfoNode[] | null
|
|
19
|
+
public files: string[] | null
|
|
20
|
+
public externalID: string | null
|
|
21
|
+
link(db: ProcessInfo): void
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class ProcessInfo {
|
|
25
|
+
public dir: string
|
|
26
|
+
public exclude: RegExp
|
|
27
|
+
public roots: Set<ProcessInfoNode>
|
|
28
|
+
public files: Map<string, Set<ProcessInfoNode>>
|
|
29
|
+
public uuids: Map<string, ProcessInfoNode>
|
|
30
|
+
public externalIDs: Map<string, ProcessInfoNode>
|
|
31
|
+
|
|
32
|
+
private pendingRoot: Map<string, ProcessInfoNode>
|
|
33
|
+
private pendingParent: Map<string, ProcessInfoNode>
|
|
34
|
+
|
|
35
|
+
constructor(options: ProcessInfoOptions)
|
|
36
|
+
|
|
37
|
+
save(): Promise<void>
|
|
38
|
+
saveSync(): void
|
|
39
|
+
erase(): Promise<void>
|
|
40
|
+
eraseSync(): void
|
|
41
|
+
|
|
42
|
+
load(): Promise<ProcessInfo>
|
|
43
|
+
loadSync(): ProcessInfo
|
|
44
|
+
|
|
45
|
+
static get Node(): typeof ProcessInfoNode
|
|
46
|
+
static get ProcessInfo(): typeof ProcessInfo
|
|
47
|
+
static get spawn(): typeof spawn
|
|
48
|
+
static get spawnSync(): typeof spawnSync
|
|
49
|
+
static get exec(): typeof exec
|
|
50
|
+
static get execSync(): typeof execSync
|
|
51
|
+
static get execFile(): typeof execFile
|
|
52
|
+
static get execFileSync(): typeof execFileSync
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export = ProcessInfo
|
|
@@ -3,16 +3,24 @@ class ProcessInfoNode {
|
|
|
3
3
|
this.parent = null
|
|
4
4
|
this.children = null
|
|
5
5
|
this.files = null
|
|
6
|
+
this.externalID = null
|
|
6
7
|
Object.assign(this, data)
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
toJSON() {
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
return Object.fromEntries(
|
|
12
|
+
Object.entries(this)
|
|
13
|
+
.filter(([_, val]) => val !== null && val !== undefined)
|
|
14
|
+
.map(([key, val]) =>
|
|
15
|
+
key === 'root'
|
|
16
|
+
? [key, val.uuid]
|
|
17
|
+
: key === 'parent'
|
|
18
|
+
? [key, val.uuid]
|
|
19
|
+
: key === 'children'
|
|
20
|
+
? [key, [...val].map(c => c.uuid)]
|
|
21
|
+
: [key, val]
|
|
22
|
+
)
|
|
23
|
+
)
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
link(db) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapjs/processinfo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"main": "lib/index.cjs",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -44,9 +44,10 @@
|
|
|
44
44
|
"license": "ISC",
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@npmcli/promise-spawn": "^2.0.1",
|
|
47
|
+
"@types/node": "^18.11.9",
|
|
48
|
+
"diff": "^5.0.0",
|
|
47
49
|
"eslint-config-prettier": "^8.5.0",
|
|
48
|
-
"prettier": "^2.6.2"
|
|
49
|
-
"diff": "^5.0.0"
|
|
50
|
+
"prettier": "^2.6.2"
|
|
50
51
|
},
|
|
51
52
|
"repository": "https://github.com/tapjs/processinfo"
|
|
52
53
|
}
|