@git.zone/tsdisk 1.1.0
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/.smartconfig.json +41 -0
- package/cli.js +4 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/index.d.ts +3 -0
- package/dist_ts/index.js +4 -0
- package/dist_ts/tsdisk.cli.d.ts +29 -0
- package/dist_ts/tsdisk.cli.js +1423 -0
- package/dist_ts/tsdisk.plugins.d.ts +6 -0
- package/dist_ts/tsdisk.plugins.js +8 -0
- package/dist_ts/tsdisk.toolcaches.d.ts +22 -0
- package/dist_ts/tsdisk.toolcaches.js +106 -0
- package/license.md +21 -0
- package/package.json +32 -0
- package/readme.md +100 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/index.ts +8 -0
- package/ts/tsdisk.cli.ts +1719 -0
- package/ts/tsdisk.plugins.ts +15 -0
- package/ts/tsdisk.toolcaches.ts +143 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// node native
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { createReadStream, type ReadStream } from 'node:fs';
|
|
4
|
+
import * as fs from 'node:fs/promises';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import { createInterface } from 'node:readline/promises';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
createInterface,
|
|
10
|
+
createReadStream,
|
|
11
|
+
fs,
|
|
12
|
+
path,
|
|
13
|
+
spawn,
|
|
14
|
+
type ReadStream,
|
|
15
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
|
|
3
|
+
export const toolCacheMarkerFile = '.gitzone-tool-cache.json';
|
|
4
|
+
|
|
5
|
+
export type TToolCacheRisk = 'safe-marked' | 'safe-heuristic' | 'review' | 'report-only';
|
|
6
|
+
|
|
7
|
+
export interface IToolCacheMarker {
|
|
8
|
+
owner: string;
|
|
9
|
+
kind: string;
|
|
10
|
+
safeToPrune: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
schemaVersion: 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IToolCacheClassification {
|
|
16
|
+
ownerGuess: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
risk: TToolCacheRisk;
|
|
19
|
+
suggestedCleanupCommand: string;
|
|
20
|
+
marker?: IToolCacheMarker;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IToolCacheFinding extends IToolCacheClassification {
|
|
24
|
+
path: string;
|
|
25
|
+
bytes?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function parseToolCacheMarker(rawArg: string): IToolCacheMarker | undefined {
|
|
29
|
+
try {
|
|
30
|
+
const marker = JSON.parse(rawArg) as Partial<IToolCacheMarker>;
|
|
31
|
+
if (
|
|
32
|
+
typeof marker.owner === 'string' &&
|
|
33
|
+
typeof marker.kind === 'string' &&
|
|
34
|
+
marker.safeToPrune === true &&
|
|
35
|
+
typeof marker.createdAt === 'string' &&
|
|
36
|
+
marker.schemaVersion === 1
|
|
37
|
+
) {
|
|
38
|
+
return marker as IToolCacheMarker;
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function quotePath(pathArg: string): string {
|
|
48
|
+
return `"${pathArg.replace(/(["\\$`])/g, '\\$1')}"`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function normalizedPath(pathArg: string): string {
|
|
52
|
+
return path.resolve(pathArg).replace(/\\/g, '/');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function workspaceRootFor(pathArg: string): string {
|
|
56
|
+
const normalized = normalizedPath(pathArg);
|
|
57
|
+
const nogitIndex = normalized.indexOf('/.nogit/');
|
|
58
|
+
if (nogitIndex > 0) {
|
|
59
|
+
return normalized.slice(0, nogitIndex);
|
|
60
|
+
}
|
|
61
|
+
const rustTargetIndex = normalized.indexOf('/rust/target');
|
|
62
|
+
if (rustTargetIndex > 0) {
|
|
63
|
+
return normalized.slice(0, rustTargetIndex);
|
|
64
|
+
}
|
|
65
|
+
const tsRustTargetIndex = normalized.indexOf('/ts_rust/target');
|
|
66
|
+
if (tsRustTargetIndex > 0) {
|
|
67
|
+
return normalized.slice(0, tsRustTargetIndex);
|
|
68
|
+
}
|
|
69
|
+
const distIndex = normalized.indexOf('/dist/binaries/');
|
|
70
|
+
if (distIndex > 0) {
|
|
71
|
+
return normalized.slice(0, distIndex);
|
|
72
|
+
}
|
|
73
|
+
return path.dirname(pathArg);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function classifyToolCachePath(pathArg: string, markerArg?: IToolCacheMarker): IToolCacheClassification | undefined {
|
|
77
|
+
const normalized = normalizedPath(pathArg);
|
|
78
|
+
if (markerArg) {
|
|
79
|
+
return {
|
|
80
|
+
ownerGuess: markerArg.owner,
|
|
81
|
+
kind: markerArg.kind,
|
|
82
|
+
risk: markerArg.safeToPrune ? 'safe-marked' : 'review',
|
|
83
|
+
suggestedCleanupCommand: `rm -rf ${quotePath(pathArg)}`,
|
|
84
|
+
marker: markerArg,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (/\/dist\/binaries\/\.[^/]+\/[^/]+\/\.deno_compile_node_modules$/.test(normalized)) {
|
|
89
|
+
return {
|
|
90
|
+
ownerGuess: '@git.zone/tsdeno',
|
|
91
|
+
kind: 'deno-self-extracting-staging',
|
|
92
|
+
risk: 'report-only',
|
|
93
|
+
suggestedCleanupCommand: `report-only: verify ownership before removing ${quotePath(path.dirname(pathArg))}`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (/\/\.nogit\/release-binaries\/\.[^/]+\/[^/]+\/\.deno_compile_node_modules$/.test(normalized)) {
|
|
98
|
+
return {
|
|
99
|
+
ownerGuess: '@git.zone/tsdeno',
|
|
100
|
+
kind: 'deno-self-extracting-release-staging',
|
|
101
|
+
risk: 'report-only',
|
|
102
|
+
suggestedCleanupCommand: `report-only: verify ownership before removing ${quotePath(path.dirname(pathArg))}`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (normalized.endsWith('/.nogit/tsbundle-temp')) {
|
|
107
|
+
return {
|
|
108
|
+
ownerGuess: '@git.zone/tsbundle',
|
|
109
|
+
kind: 'bundle-temp-workspace',
|
|
110
|
+
risk: 'report-only',
|
|
111
|
+
suggestedCleanupCommand: `report-only: verify ownership before removing ${quotePath(pathArg)}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (normalized.endsWith('/.nogit/docker-registry') || normalized.includes('/.nogit/docker-registry/')) {
|
|
116
|
+
return {
|
|
117
|
+
ownerGuess: '@git.zone/tsdocker',
|
|
118
|
+
kind: 'docker-registry-cache',
|
|
119
|
+
risk: 'report-only',
|
|
120
|
+
suggestedCleanupCommand: `report-only: run tsdocker prune dry-run from ${quotePath(workspaceRootFor(pathArg))} and verify markers before removal`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (normalized.endsWith('/rust/target') || normalized.endsWith('/ts_rust/target')) {
|
|
125
|
+
return {
|
|
126
|
+
ownerGuess: '@git.zone/tsrust/cargo',
|
|
127
|
+
kind: 'rust-target-cache',
|
|
128
|
+
risk: 'report-only',
|
|
129
|
+
suggestedCleanupCommand: `report-only: run tsrust prune dry-run from ${quotePath(workspaceRootFor(pathArg))} and verify managed markers before removal`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (normalized.endsWith('/.nogit/tsrust-target')) {
|
|
134
|
+
return {
|
|
135
|
+
ownerGuess: '@git.zone/tsrust',
|
|
136
|
+
kind: 'rust-target-cache',
|
|
137
|
+
risk: 'report-only',
|
|
138
|
+
suggestedCleanupCommand: `report-only: run tsrust prune dry-run from ${quotePath(workspaceRootFor(pathArg))} and verify managed markers before removal`,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|