@getmonoceros/workbench 1.21.0 → 1.21.2

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/dist/bin.js CHANGED
@@ -5649,6 +5649,15 @@ async function findContainerIds(filters, exec = spawnDocker) {
5649
5649
  }
5650
5650
  return [...ids];
5651
5651
  }
5652
+ async function isWorkspaceRunning(root, exec = spawnDocker) {
5653
+ const result = await exec([
5654
+ "ps",
5655
+ "-q",
5656
+ "--filter",
5657
+ `label=devcontainer.local_folder=${root}`
5658
+ ]);
5659
+ return result.exitCode === 0 && result.stdout.trim().length > 0;
5660
+ }
5652
5661
  async function cleanupDockerObjects(opts) {
5653
5662
  const exec = opts.exec ?? spawnDocker;
5654
5663
  const tag = opts.logTag ?? "cleanup";
@@ -6690,7 +6699,7 @@ var CLI_VERSION;
6690
6699
  var init_version = __esm({
6691
6700
  "src/version.ts"() {
6692
6701
  "use strict";
6693
- CLI_VERSION = true ? "1.21.0" : "dev";
6702
+ CLI_VERSION = true ? "1.21.2" : "dev";
6694
6703
  }
6695
6704
  });
6696
6705
 
@@ -7321,9 +7330,12 @@ function generateComposedYml(name, composed, lookupManifest, repoUrls = [], port
7321
7330
  lines.push("schemaVersion: 1");
7322
7331
  lines.push(`name: ${name}`);
7323
7332
  lines.push(
7324
- "# Pinned runtime image version. Reused on every apply; change it with"
7333
+ "# Pinned runtime base image, reused on every apply (never auto-bumped)."
7325
7334
  );
7326
- lines.push("# `monoceros upgrade <name> [version]`.");
7335
+ lines.push(
7336
+ "# `monoceros upgrade <name>` refreshes the tooling and moves this to the"
7337
+ );
7338
+ lines.push("# latest runtime when a newer one exists.");
7327
7339
  lines.push(`runtimeVersion: ${DEFAULT_RUNTIME_VERSION}`);
7328
7340
  lines.push("");
7329
7341
  if (composed.languages.length > 0) {
@@ -7424,9 +7436,12 @@ function generateDocumentedYml(name, catalog, lookupManifest, repoUrls = [], por
7424
7436
  lines.push("schemaVersion: 1");
7425
7437
  lines.push(`name: ${name}`);
7426
7438
  lines.push(
7427
- "# Pinned runtime image version. Reused on every apply; change it with"
7439
+ "# Pinned runtime base image, reused on every apply (never auto-bumped)."
7428
7440
  );
7429
- lines.push("# `monoceros upgrade <name> [version]`.");
7441
+ lines.push(
7442
+ "# `monoceros upgrade <name>` refreshes the tooling and moves this to the"
7443
+ );
7444
+ lines.push("# latest runtime when a newer one exists.");
7430
7445
  lines.push(`runtimeVersion: ${DEFAULT_RUNTIME_VERSION}`);
7431
7446
  lines.push("");
7432
7447
  if (byCategory.language.length > 0) {
@@ -10039,20 +10054,36 @@ async function runUpgrade(opts) {
10039
10054
  `No such config: ${containerConfigPath(opts.name, home)}. Run \`monoceros init <template> ${opts.name}\` first.`
10040
10055
  );
10041
10056
  }
10042
- const targets = opts.name ? [opts.name] : await listContainerNames2(home);
10043
10057
  const apply = opts.applyRunner ?? runApply;
10058
+ const exec = opts.dockerExec ?? spawnDocker;
10044
10059
  const now = opts.now ?? /* @__PURE__ */ new Date();
10060
+ let targets;
10061
+ const skipped = [];
10062
+ if (opts.name) {
10063
+ targets = [opts.name];
10064
+ } else {
10065
+ targets = [];
10066
+ for (const name of await listContainerNames2(home)) {
10067
+ if (await isWorkspaceRunning(containerDir(name, home), exec)) {
10068
+ targets.push(name);
10069
+ } else {
10070
+ skipped.push(name);
10071
+ }
10072
+ }
10073
+ }
10045
10074
  const pruneAndStamp = async () => {
10046
10075
  const result = await pruneStaleImages({
10047
10076
  home,
10048
10077
  currentContainerNames: new Set(await listContainerNames2(home)),
10049
- ...opts.dockerExec ? { exec: opts.dockerExec } : {}
10078
+ exec
10050
10079
  });
10051
10080
  await markUpgraded(now.toISOString(), home);
10052
10081
  return result;
10053
10082
  };
10054
10083
  if (targets.length === 0) {
10055
- logger.info("No containers to upgrade.");
10084
+ logger.info(
10085
+ opts.name ? "Nothing to upgrade." : skipped.length > 0 ? `No running containers to refresh (${skipped.length} not running: ${skipped.join(", ")}). Start one, or refresh it with \`monoceros upgrade <name>\`.` : "No running containers to refresh."
10086
+ );
10056
10087
  await pruneAndStamp();
10057
10088
  return 0;
10058
10089
  }
@@ -10094,11 +10125,12 @@ async function runUpgrade(opts) {
10094
10125
  if (worstExit === 0) {
10095
10126
  const prune = await pruneAndStamp();
10096
10127
  logger.success(
10097
- `Upgraded ${opts.name ? `'${opts.name}'` : `${targets.length} container${targets.length === 1 ? "" : "s"}`}
10128
+ `Upgraded ${opts.name ? `'${opts.name}'` : `${targets.length} running container${targets.length === 1 ? "" : "s"}`}
10098
10129
  tools rebuilt \u2014 latest pulled
10099
10130
  base ${pinVersion} ${bumped > 0 ? `(${bumped} bumped)` : "(already latest)"}
10100
10131
  pruned ${formatPruneLine(prune)}
10101
- recorded ${now.toISOString().slice(0, 16).replace("T", " ")} UTC`
10132
+ ` + (skipped.length > 0 ? ` skipped ${skipped.length} not running (${skipped.join(", ")})
10133
+ ` : "") + ` recorded ${now.toISOString().slice(0, 16).replace("T", " ")} UTC`
10102
10134
  );
10103
10135
  }
10104
10136
  return worstExit;
@@ -10127,6 +10159,7 @@ var init_upgrade = __esm({
10127
10159
  init_paths();
10128
10160
  init_machine_state();
10129
10161
  init_catalog();
10162
+ init_compose();
10130
10163
  init_proxy();
10131
10164
  init_prune();
10132
10165
  init_apply();