@git.zone/cli 2.23.0 → 2.25.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.
Files changed (38) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/gitzone.cli.js +11 -2
  3. package/dist_ts/mod_services/classes.dockercontainer.d.ts +81 -0
  4. package/dist_ts/mod_services/classes.dockercontainer.js +205 -10
  5. package/dist_ts/mod_services/classes.globalregistry.d.ts +10 -0
  6. package/dist_ts/mod_services/classes.globalregistry.js +23 -1
  7. package/dist_ts/mod_services/classes.serviceconfiguration.d.ts +52 -1
  8. package/dist_ts/mod_services/classes.serviceconfiguration.js +116 -20
  9. package/dist_ts/mod_services/classes.servicedatamarker.d.ts +93 -0
  10. package/dist_ts/mod_services/classes.servicedatamarker.js +166 -0
  11. package/dist_ts/mod_services/classes.servicemanager.d.ts +91 -5
  12. package/dist_ts/mod_services/classes.servicemanager.js +274 -64
  13. package/dist_ts/mod_services/classes.serviceoptions.d.ts +58 -0
  14. package/dist_ts/mod_services/classes.serviceoptions.js +93 -0
  15. package/dist_ts/mod_services/classes.servicepruner.d.ts +102 -0
  16. package/dist_ts/mod_services/classes.servicepruner.js +410 -0
  17. package/dist_ts/mod_services/helpers.d.ts +15 -0
  18. package/dist_ts/mod_services/helpers.js +57 -1
  19. package/dist_ts/mod_services/index.js +307 -53
  20. package/dist_ts/mod_tools/classes.packagemanager.d.ts +13 -0
  21. package/dist_ts/mod_tools/classes.packagemanager.js +42 -1
  22. package/dist_ts/mod_tools/index.js +4 -1
  23. package/package.json +3 -2
  24. package/readme.hints.md +105 -0
  25. package/readme.md +123 -5
  26. package/ts/00_commitinfo_data.ts +1 -1
  27. package/ts/gitzone.cli.ts +10 -0
  28. package/ts/mod_services/classes.dockercontainer.ts +244 -13
  29. package/ts/mod_services/classes.globalregistry.ts +27 -0
  30. package/ts/mod_services/classes.serviceconfiguration.ts +148 -27
  31. package/ts/mod_services/classes.servicedatamarker.ts +228 -0
  32. package/ts/mod_services/classes.servicemanager.ts +394 -72
  33. package/ts/mod_services/classes.serviceoptions.ts +135 -0
  34. package/ts/mod_services/classes.servicepruner.ts +532 -0
  35. package/ts/mod_services/helpers.ts +60 -0
  36. package/ts/mod_services/index.ts +437 -58
  37. package/ts/mod_tools/classes.packagemanager.ts +54 -0
  38. package/ts/mod_tools/index.ts +5 -0
@@ -90,6 +90,66 @@ export const formatBytes = (bytes: number): string => {
90
90
  return `${size.toFixed(2)} ${units[unitIndex]}`;
91
91
  };
92
92
 
93
+ /**
94
+ * True when either path contains the other, or they are the same path.
95
+ *
96
+ * Used to decide whether a deletion candidate collides with a directory a
97
+ * running container has mounted. Containment in *either* direction counts: a
98
+ * parent mount protects its children, and a child mount protects its parent.
99
+ */
100
+ export const pathsOverlap = (firstPathArg: string, secondPathArg: string): boolean => {
101
+ const firstPath = plugins.path.resolve(firstPathArg);
102
+ const secondPath = plugins.path.resolve(secondPathArg);
103
+ const contains = (containerPath: string, candidatePath: string): boolean => {
104
+ const relative = plugins.path.relative(containerPath, candidatePath);
105
+ if (relative === '') {
106
+ return true;
107
+ }
108
+ return !!relative && !relative.startsWith('..') && !plugins.path.isAbsolute(relative);
109
+ };
110
+ return contains(firstPath, secondPath) || contains(secondPath, firstPath);
111
+ };
112
+
113
+ /**
114
+ * Total size in bytes of a directory tree.
115
+ *
116
+ * Symlinks are counted by their own size and never followed, so a symlink
117
+ * inside a data directory can neither inflate the report nor walk out of it.
118
+ */
119
+ export const getDirectorySize = async (
120
+ directoryPathArg: string,
121
+ maxDepthArg: number = 64,
122
+ ): Promise<number> => {
123
+ let total = 0;
124
+ const walk = async (currentPath: string, depth: number): Promise<void> => {
125
+ // Bind mounts inside a data directory are user-controlled and can form a
126
+ // cycle; a depth cap keeps this from recursing until it exhausts memory.
127
+ if (depth > maxDepthArg) {
128
+ return;
129
+ }
130
+ const entries = await plugins.fs
131
+ .readdir(currentPath, { withFileTypes: true })
132
+ .catch(() => []);
133
+ for (const entry of entries) {
134
+ const entryPath = plugins.path.join(currentPath, entry.name);
135
+ // isDirectory() here is lstat-based, so symlinks are counted by their own
136
+ // size and never followed.
137
+ if (entry.isDirectory()) {
138
+ await walk(entryPath, depth + 1);
139
+ continue;
140
+ }
141
+ try {
142
+ const stats = await plugins.fs.lstat(entryPath);
143
+ total += stats.size;
144
+ } catch {
145
+ // entry disappeared between readdir and lstat; ignore
146
+ }
147
+ }
148
+ };
149
+ await walk(plugins.path.resolve(directoryPathArg), 0);
150
+ return total;
151
+ };
152
+
93
153
  /**
94
154
  * Get the local network IP address
95
155
  */