@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
@@ -35,6 +35,11 @@ export interface ILegacyCleanupResult {
35
35
  globalDir: string;
36
36
  deleted: boolean;
37
37
  reason?: string;
38
+ /**
39
+ * Managed packages removed from a legacy root that itself had to be kept.
40
+ * Each entry is `name@version` of an inert copy that nothing resolves to.
41
+ */
42
+ stalePackagesRemoved?: string[];
38
43
  }
39
44
 
40
45
  export interface IShimSyncResult {
@@ -179,9 +184,18 @@ export class PackageManagerUtil {
179
184
  }
180
185
 
181
186
  if (!legacyRoot.safeToDelete) {
187
+ // The root must stay, but the managed copies inside it are inert: the
188
+ // current global root already provides those packages and no shim
189
+ // resolves here. Leaving them behind makes the directory look like the
190
+ // installed version, which misleads anyone inspecting it.
191
+ const stalePackagesRemoved = await this.removeStaleManagedPackages(
192
+ legacyRoot,
193
+ currentPackageNames,
194
+ );
182
195
  cleanupResults.push({
183
196
  globalDir: legacyRoot.globalDir,
184
197
  deleted: false,
198
+ stalePackagesRemoved,
185
199
  reason:
186
200
  legacyRoot.unmanagedPackageNames.length > 0
187
201
  ? `kept because it also contains ${legacyRoot.unmanagedPackageNames.join(", ")}`
@@ -231,6 +245,46 @@ export class PackageManagerUtil {
231
245
  return cleanupResults;
232
246
  }
233
247
 
248
+ /**
249
+ * Remove managed package copies from a legacy global root that has to be kept.
250
+ *
251
+ * Only removes a package when the active global root already provides it and
252
+ * no command shim points into this legacy root, so nothing that currently
253
+ * resolves can be affected. Fails closed: any doubt leaves the copy in place.
254
+ */
255
+ private async removeStaleManagedPackages(
256
+ legacyRootArg: ILegacyGlobalRootInfo,
257
+ currentPackageNamesArg: Set<string>,
258
+ ): Promise<string[]> {
259
+ const shimReferences = await this.getShimReferences(legacyRootArg.globalDir);
260
+ if (shimReferences === null || shimReferences.length > 0) {
261
+ // PNPM_HOME unknown, or something still resolves here.
262
+ return [];
263
+ }
264
+
265
+ const removed: string[] = [];
266
+ for (const packageInfo of legacyRootArg.packages) {
267
+ if (!packageInfo.packagePath) {
268
+ continue;
269
+ }
270
+ if (!currentPackageNamesArg.has(packageInfo.name)) {
271
+ // Not provided by the active root — removing it would lose the package.
272
+ continue;
273
+ }
274
+ try {
275
+ await plugins.fs.rm(packageInfo.packagePath, {
276
+ recursive: true,
277
+ force: true,
278
+ });
279
+ removed.push(`${packageInfo.name}@${packageInfo.version}`);
280
+ } catch {
281
+ // Leave it rather than half-removing it.
282
+ }
283
+ }
284
+
285
+ return removed;
286
+ }
287
+
234
288
  public async syncCurrentGlobalShims(): Promise<IShimSyncResult[]> {
235
289
  const pnpmShimDirs = await this.getPnpmShimDirs();
236
290
  if (!pnpmShimDirs) {
@@ -485,6 +485,11 @@ async function cleanupLegacyInstalls(
485
485
  console.log(
486
486
  ` ${cleanupResult.globalDir} kept (${cleanupResult.reason || "unknown reason"})`,
487
487
  );
488
+ for (const stalePackage of cleanupResult.stalePackagesRemoved || []) {
489
+ console.log(
490
+ ` removed stale inert copy ${stalePackage} (the active global root provides it)`,
491
+ );
492
+ }
488
493
  }
489
494
  }
490
495
  console.log("");