@narumitw/pi-starship 0.45.0 → 0.49.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.
@@ -1,13 +1,7 @@
1
1
  import type { ModuleName } from "../modules/catalog.js";
2
2
  import { reachableModuleRequirements } from "../modules/render.js";
3
3
  import type { WorkspaceSnapshot } from "../modules/types.js";
4
- import { collectCloud } from "./cloud.js";
5
- import { collectDeployment } from "./deployment.js";
6
- import { collectDevelopment } from "./development.js";
7
- import { collectExecution } from "./execution.js";
8
4
  import { createFileSystem } from "./helpers.js";
9
- import { collectLanguages } from "./languages.js";
10
- import { collectPackage } from "./package.js";
11
5
  import {
12
6
  type CollectorContext,
13
7
  type MutableModuleSnapshot,
@@ -16,9 +10,6 @@ import {
16
10
  type WorkspaceRefreshInput,
17
11
  } from "./types.js";
18
12
 
19
- export { parseTerraformVersion } from "./deployment.js";
20
- export { parseDirenvStatus, parseMiseHealth } from "./development.js";
21
- export { parseRuntimeVersion } from "./languages.js";
22
13
  export type { WorkspaceExec, WorkspaceExecResult, WorkspaceRefreshInput } from "./types.js";
23
14
 
24
15
  export async function collectWorkspaceSnapshot(
@@ -45,16 +36,17 @@ export async function collectWorkspaceSnapshot(
45
36
  },
46
37
  };
47
38
  const modules: MutableModuleSnapshot = {};
48
- const packageValues = await collectPackage(context);
49
- if (input.signal?.aborted) return freezeSnapshot({});
50
- if (packageValues) modules.package = packageValues;
51
- for (const collector of [
52
- collectLanguages,
53
- collectDevelopment,
54
- collectDeployment,
55
- collectCloud,
56
- collectExecution,
57
- ]) {
39
+ if (requirements.has("package")) {
40
+ const { collectPackage } = await import("./package.js");
41
+ if (input.signal?.aborted) return freezeSnapshot({});
42
+ const packageValues = await collectPackage(context);
43
+ if (input.signal?.aborted) return freezeSnapshot({});
44
+ if (packageValues) modules.package = packageValues;
45
+ }
46
+ for (const descriptor of COLLECTOR_GROUPS) {
47
+ if (!descriptor.modules.some((name) => requirements.has(name))) continue;
48
+ if (input.signal?.aborted) return freezeSnapshot({});
49
+ const collector = await descriptor.load();
58
50
  if (input.signal?.aborted) return freezeSnapshot({});
59
51
  mergeModules(modules, await collector(context));
60
52
  }
@@ -74,6 +66,34 @@ function hasWorkspaceRequirement(
74
66
  return [...requirements.keys()].some((name) => !BUILT_IN_ONLY_MODULES.has(name));
75
67
  }
76
68
 
69
+ type WorkspaceCollector = (context: CollectorContext) => Promise<MutableModuleSnapshot>;
70
+
71
+ const COLLECTOR_GROUPS: readonly {
72
+ modules: readonly ModuleName[];
73
+ load(): Promise<WorkspaceCollector>;
74
+ }[] = [
75
+ {
76
+ modules: ["nodejs", "python", "rust", "golang", "bun", "deno"],
77
+ load: async () => (await import("./languages.js")).collectLanguages,
78
+ },
79
+ {
80
+ modules: ["mise", "direnv", "pixi", "conda", "nix_shell", "guix_shell"],
81
+ load: async () => (await import("./development.js")).collectDevelopment,
82
+ },
83
+ {
84
+ modules: ["docker_context", "kubernetes", "terraform"],
85
+ load: async () => (await import("./deployment.js")).collectDeployment,
86
+ },
87
+ {
88
+ modules: ["aws", "gcloud", "azure", "openstack"],
89
+ load: async () => (await import("./cloud.js")).collectCloud,
90
+ },
91
+ {
92
+ modules: ["container", "hostname", "os", "username"],
93
+ load: async () => (await import("./execution.js")).collectExecution,
94
+ },
95
+ ];
96
+
77
97
  const BUILT_IN_ONLY_MODULES = new Set<ModuleName>([
78
98
  "brand",
79
99
  "provider",