@mxpicture/build-api 0.2.55 → 0.2.57

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 (143) hide show
  1. package/dist/barrel/Barrel.d.ts +66 -0
  2. package/dist/barrel/Barrel.d.ts.map +1 -1
  3. package/dist/barrel/Barrel.js +66 -3
  4. package/dist/barrel/Barrel.js.map +1 -1
  5. package/dist/cleanup/Cleanup.d.ts +70 -0
  6. package/dist/cleanup/Cleanup.d.ts.map +1 -1
  7. package/dist/cleanup/Cleanup.js +70 -0
  8. package/dist/cleanup/Cleanup.js.map +1 -1
  9. package/dist/code/code.common.d.ts +37 -4
  10. package/dist/code/code.common.d.ts.map +1 -1
  11. package/dist/code/code.common.js +37 -4
  12. package/dist/code/code.common.js.map +1 -1
  13. package/dist/code/code.exports.d.ts +25 -0
  14. package/dist/code/code.exports.d.ts.map +1 -1
  15. package/dist/code/code.exports.js +25 -1
  16. package/dist/code/code.exports.js.map +1 -1
  17. package/dist/code/code.format.d.ts +23 -0
  18. package/dist/code/code.format.d.ts.map +1 -1
  19. package/dist/code/code.format.js +23 -0
  20. package/dist/code/code.format.js.map +1 -1
  21. package/dist/common/common.fs.d.ts +22 -0
  22. package/dist/common/common.fs.d.ts.map +1 -1
  23. package/dist/common/common.fs.js +22 -0
  24. package/dist/common/common.fs.js.map +1 -1
  25. package/dist/common/common.json.d.ts +27 -0
  26. package/dist/common/common.json.d.ts.map +1 -1
  27. package/dist/common/common.json.js +27 -0
  28. package/dist/common/common.json.js.map +1 -1
  29. package/dist/deps/FixWorkspaceDeps.d.ts +132 -0
  30. package/dist/deps/FixWorkspaceDeps.d.ts.map +1 -1
  31. package/dist/deps/FixWorkspaceDeps.js +120 -2
  32. package/dist/deps/FixWorkspaceDeps.js.map +1 -1
  33. package/dist/git/GitChanges.d.ts +60 -13
  34. package/dist/git/GitChanges.d.ts.map +1 -1
  35. package/dist/git/GitChanges.js +60 -13
  36. package/dist/git/GitChanges.js.map +1 -1
  37. package/dist/git/git.util.d.ts +58 -3
  38. package/dist/git/git.util.d.ts.map +1 -1
  39. package/dist/git/git.util.js +58 -3
  40. package/dist/git/git.util.js.map +1 -1
  41. package/dist/logger/Logger.d.ts +74 -0
  42. package/dist/logger/Logger.d.ts.map +1 -1
  43. package/dist/logger/Logger.js +49 -0
  44. package/dist/logger/Logger.js.map +1 -1
  45. package/dist/npmPublish/NpmPublisher.d.ts +36 -0
  46. package/dist/npmPublish/NpmPublisher.d.ts.map +1 -1
  47. package/dist/npmPublish/NpmPublisher.js +36 -0
  48. package/dist/npmPublish/NpmPublisher.js.map +1 -1
  49. package/dist/osInfo/osInfo.common.d.ts +45 -1
  50. package/dist/osInfo/osInfo.common.d.ts.map +1 -1
  51. package/dist/osInfo/osInfo.common.js +45 -1
  52. package/dist/osInfo/osInfo.common.js.map +1 -1
  53. package/dist/pkg/Pkg.d.ts +69 -0
  54. package/dist/pkg/Pkg.d.ts.map +1 -1
  55. package/dist/pkg/Pkg.js +69 -0
  56. package/dist/pkg/Pkg.js.map +1 -1
  57. package/dist/pkg/SyncPkgVersion.d.ts +35 -0
  58. package/dist/pkg/SyncPkgVersion.d.ts.map +1 -1
  59. package/dist/pkg/SyncPkgVersion.js +35 -0
  60. package/dist/pkg/SyncPkgVersion.js.map +1 -1
  61. package/dist/pkg/UpdatePackages.d.ts +36 -0
  62. package/dist/pkg/UpdatePackages.d.ts.map +1 -1
  63. package/dist/pkg/UpdatePackages.js +36 -0
  64. package/dist/pkg/UpdatePackages.js.map +1 -1
  65. package/dist/pkg/pkg.common.d.ts +73 -0
  66. package/dist/pkg/pkg.common.d.ts.map +1 -1
  67. package/dist/pkg/pkg.common.js +73 -0
  68. package/dist/pkg/pkg.common.js.map +1 -1
  69. package/dist/pkg/pkg.fs.d.ts +53 -0
  70. package/dist/pkg/pkg.fs.d.ts.map +1 -1
  71. package/dist/pkg/pkg.fs.js +53 -0
  72. package/dist/pkg/pkg.fs.js.map +1 -1
  73. package/dist/types/types.barrel.d.ts +28 -0
  74. package/dist/types/types.barrel.d.ts.map +1 -1
  75. package/dist/types/types.barrel.js.map +1 -1
  76. package/dist/types/types.changelog.d.ts +28 -0
  77. package/dist/types/types.changelog.d.ts.map +1 -1
  78. package/dist/types/types.changelog.js +9 -0
  79. package/dist/types/types.changelog.js.map +1 -1
  80. package/dist/types/types.cleanup.d.ts +19 -0
  81. package/dist/types/types.cleanup.d.ts.map +1 -1
  82. package/dist/types/types.cleanup.js.map +1 -1
  83. package/dist/types/types.code.d.ts +36 -0
  84. package/dist/types/types.code.d.ts.map +1 -1
  85. package/dist/types/types.code.js.map +1 -1
  86. package/dist/types/types.deps.d.ts +27 -0
  87. package/dist/types/types.deps.d.ts.map +1 -1
  88. package/dist/types/types.deps.js +10 -0
  89. package/dist/types/types.deps.js.map +1 -1
  90. package/dist/types/types.documents.d.ts +9 -0
  91. package/dist/types/types.documents.d.ts.map +1 -1
  92. package/dist/types/types.documents.js.map +1 -1
  93. package/dist/types/types.git.d.ts +25 -0
  94. package/dist/types/types.git.d.ts.map +1 -1
  95. package/dist/types/types.git.js.map +1 -1
  96. package/dist/types/types.npm.d.ts +7 -0
  97. package/dist/types/types.npm.d.ts.map +1 -1
  98. package/dist/types/types.npm.js.map +1 -1
  99. package/dist/types/types.os.d.ts +8 -0
  100. package/dist/types/types.os.d.ts.map +1 -1
  101. package/dist/types/types.os.js.map +1 -1
  102. package/dist/types/types.package.d.ts +48 -0
  103. package/dist/types/types.package.d.ts.map +1 -1
  104. package/dist/types/types.package.js.map +1 -1
  105. package/dist/types/types.run.d.ts +4 -0
  106. package/dist/types/types.run.d.ts.map +1 -1
  107. package/dist/types/types.run.js.map +1 -1
  108. package/dist/types/types.vscode.d.ts +46 -0
  109. package/dist/types/types.vscode.d.ts.map +1 -1
  110. package/dist/types/types.vscode.js.map +1 -1
  111. package/dist/types/types.workspace.d.ts +18 -0
  112. package/dist/types/types.workspace.d.ts.map +1 -1
  113. package/dist/types/types.workspace.js +6 -0
  114. package/dist/types/types.workspace.js.map +1 -1
  115. package/dist/vscode/vscode.config.d.ts +18 -0
  116. package/dist/vscode/vscode.config.d.ts.map +1 -1
  117. package/dist/vscode/vscode.config.js +18 -0
  118. package/dist/vscode/vscode.config.js.map +1 -1
  119. package/dist/vscode/vscode.profiles.d.ts +37 -0
  120. package/dist/vscode/vscode.profiles.d.ts.map +1 -1
  121. package/dist/vscode/vscode.profiles.js +37 -0
  122. package/dist/vscode/vscode.profiles.js.map +1 -1
  123. package/dist/vscode/vscode.settings.d.ts +26 -1
  124. package/dist/vscode/vscode.settings.d.ts.map +1 -1
  125. package/dist/vscode/vscode.settings.js +26 -1
  126. package/dist/vscode/vscode.settings.js.map +1 -1
  127. package/dist/vscode/vscode.storage.d.ts +21 -1
  128. package/dist/vscode/vscode.storage.d.ts.map +1 -1
  129. package/dist/vscode/vscode.storage.js +21 -1
  130. package/dist/vscode/vscode.storage.js.map +1 -1
  131. package/dist/vscode/vscode.workspace.d.ts +17 -0
  132. package/dist/vscode/vscode.workspace.d.ts.map +1 -1
  133. package/dist/vscode/vscode.workspace.js +17 -0
  134. package/dist/vscode/vscode.workspace.js.map +1 -1
  135. package/dist/workspace/Workspace.d.ts +85 -0
  136. package/dist/workspace/Workspace.d.ts.map +1 -1
  137. package/dist/workspace/Workspace.js +85 -0
  138. package/dist/workspace/Workspace.js.map +1 -1
  139. package/dist/workspace/workspace.common.d.ts +42 -1
  140. package/dist/workspace/workspace.common.d.ts.map +1 -1
  141. package/dist/workspace/workspace.common.js +42 -1
  142. package/dist/workspace/workspace.common.js.map +1 -1
  143. package/package.json +1 -1
@@ -1,6 +1,43 @@
1
1
  import { VSCodeProfile } from "../types/types.vscode.js";
2
+ /**
3
+ * Returns all VS Code user-data profiles.
4
+ *
5
+ * @remarks
6
+ * Each profile is resolved from the persisted {@link storage} and enriched
7
+ * with the absolute path to its `settings.json` via {@link profileSettingsPath}.
8
+ *
9
+ * @returns An array of {@link VSCodeProfile} objects for every configured profile.
10
+ */
2
11
  export declare const profiles: () => VSCodeProfile[];
12
+ /**
13
+ * Resolves the active VS Code profile for a given workspace directory.
14
+ *
15
+ * @remarks
16
+ * The workspace root is located via {@link findWorkspaceRoot}, then matched
17
+ * against the profile-to-workspace associations stored in VS Code's
18
+ * `storage.json`. Throws if no matching profile is found.
19
+ *
20
+ * @param dir - The directory to resolve the workspace from. Defaults to the
21
+ * current working directory.
22
+ * @returns A promise that resolves to the active {@link VSCodeProfile}.
23
+ * @throws If no active profile is associated with the resolved workspace.
24
+ */
3
25
  export declare const activeProfile: (dir?: string) => Promise<VSCodeProfile>;
26
+ /**
27
+ * Builds the absolute path to a profile's `settings.json` file.
28
+ *
29
+ * @param profile - The unique location identifier of the profile.
30
+ * @returns The absolute path to `settings.json` inside the profile's directory.
31
+ */
4
32
  export declare const profileSettingsPath: (profile: string) => string;
33
+ /**
34
+ * Returns the absolute path to the default (global) `settings.json` file.
35
+ *
36
+ * @remarks
37
+ * This is the settings file used when no named profile is active.
38
+ *
39
+ * @returns The absolute path to the default `settings.json` in the VS Code
40
+ * `User` directory.
41
+ */
5
42
  export declare const defaultSettingsPath: () => string;
6
43
  //# sourceMappingURL=vscode.profiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.profiles.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.profiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,eAAO,MAAM,QAAQ,QAAO,aAAa,EAOtC,CAAC;AAEJ,eAAO,MAAM,aAAa,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,aAAa,CAkBvE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,MACQ,CAAC;AAE/D,eAAO,MAAM,mBAAmB,QAAO,MACE,CAAC"}
1
+ {"version":3,"file":"vscode.profiles.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.profiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,QAAO,aAAa,EAOtC,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,aAAa,CAkBvE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,MACQ,CAAC;AAE/D;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,QAAO,MACE,CAAC"}
@@ -3,11 +3,33 @@ import { storage } from "./vscode.storage.js";
3
3
  import { configUserPath } from "./vscode.config.js";
4
4
  import { findWorkspaceRoot } from "../workspace/workspace.common.js";
5
5
  import { cwd } from "node:process";
6
+ /**
7
+ * Returns all VS Code user-data profiles.
8
+ *
9
+ * @remarks
10
+ * Each profile is resolved from the persisted {@link storage} and enriched
11
+ * with the absolute path to its `settings.json` via {@link profileSettingsPath}.
12
+ *
13
+ * @returns An array of {@link VSCodeProfile} objects for every configured profile.
14
+ */
6
15
  export const profiles = () => storage().userDataProfiles.map((prof) => ({
7
16
  name: prof.name,
8
17
  location: prof.location,
9
18
  settingsPath: profileSettingsPath(prof.location),
10
19
  }));
20
+ /**
21
+ * Resolves the active VS Code profile for a given workspace directory.
22
+ *
23
+ * @remarks
24
+ * The workspace root is located via {@link findWorkspaceRoot}, then matched
25
+ * against the profile-to-workspace associations stored in VS Code's
26
+ * `storage.json`. Throws if no matching profile is found.
27
+ *
28
+ * @param dir - The directory to resolve the workspace from. Defaults to the
29
+ * current working directory.
30
+ * @returns A promise that resolves to the active {@link VSCodeProfile}.
31
+ * @throws If no active profile is associated with the resolved workspace.
32
+ */
11
33
  export const activeProfile = async (dir) => {
12
34
  const foundWS = await findWorkspaceRoot(dir ?? cwd());
13
35
  const storageContent = storage();
@@ -26,6 +48,21 @@ export const activeProfile = async (dir) => {
26
48
  throw new Error("No active profile found");
27
49
  return foundProfile;
28
50
  };
51
+ /**
52
+ * Builds the absolute path to a profile's `settings.json` file.
53
+ *
54
+ * @param profile - The unique location identifier of the profile.
55
+ * @returns The absolute path to `settings.json` inside the profile's directory.
56
+ */
29
57
  export const profileSettingsPath = (profile) => join(configUserPath(), "profiles", profile, "settings.json");
58
+ /**
59
+ * Returns the absolute path to the default (global) `settings.json` file.
60
+ *
61
+ * @remarks
62
+ * This is the settings file used when no named profile is active.
63
+ *
64
+ * @returns The absolute path to the default `settings.json` in the VS Code
65
+ * `User` directory.
66
+ */
30
67
  export const defaultSettingsPath = () => join(configUserPath(), "settings.json");
31
68
  //# sourceMappingURL=vscode.profiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.profiles.js","sourceRoot":"","sources":["../../src/vscode/vscode.profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAoB,EAAE,CAC5C,OAAO,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAC5B,CAAC,IAAI,EAAiB,EAAE,CAAC,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,YAAY,EAAE,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC;CACjD,CAAC,CACH,CAAC;AAEJ,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,GAAY,EAA0B,EAAE;IAC1E,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,OAAO,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,YAAuC,CAAC;IAE5C,wCAAwC;IACxC,KAAK,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CACxC,cAAc,CAAC,mBAAmB,CAAC,UAAU,CAC9C,EAAE,CAAC;QACF,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;YAAE,SAAS;QACxC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC/D,IAAI,YAAY;YAAE,MAAM;IAC1B,CAAC;IAED,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC9D,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE,CAC7D,IAAI,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAC9C,IAAI,CAAC,cAAc,EAAE,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport { VSCodeProfile } from \"../types/types.vscode.js\";\nimport { storage } from \"./vscode.storage.js\";\nimport { configUserPath } from \"./vscode.config.js\";\nimport { findWorkspaceRoot } from \"../workspace/workspace.common.js\";\nimport { cwd } from \"node:process\";\n\nexport const profiles = (): VSCodeProfile[] =>\n storage().userDataProfiles.map(\n (prof): VSCodeProfile => ({\n name: prof.name,\n location: prof.location,\n settingsPath: profileSettingsPath(prof.location),\n }),\n );\n\nexport const activeProfile = async (dir?: string): Promise<VSCodeProfile> => {\n const foundWS = await findWorkspaceRoot(dir ?? cwd());\n const storageContent = storage();\n const profs = profiles();\n let foundProfile: VSCodeProfile | undefined;\n\n // eslint-disable-next-line prefer-const\n for (let [path, profile] of Object.entries(\n storageContent.profileAssociations.workspaces,\n )) {\n path = path.replace(\"file://\", \"\");\n if (foundWS.filePath !== path) continue;\n foundProfile = profs.find((prof) => prof.location === profile);\n if (foundProfile) break;\n }\n\n if (!foundProfile) throw new Error(\"No active profile found\");\n return foundProfile;\n};\n\nexport const profileSettingsPath = (profile: string): string =>\n join(configUserPath(), \"profiles\", profile, \"settings.json\");\n\nexport const defaultSettingsPath = (): string =>\n join(configUserPath(), \"settings.json\");\n"]}
1
+ {"version":3,"file":"vscode.profiles.js","sourceRoot":"","sources":["../../src/vscode/vscode.profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAoB,EAAE,CAC5C,OAAO,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAC5B,CAAC,IAAI,EAAiB,EAAE,CAAC,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC,IAAI;IACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,YAAY,EAAE,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC;CACjD,CAAC,CACH,CAAC;AAEJ;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,GAAY,EAA0B,EAAE;IAC1E,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,OAAO,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,YAAuC,CAAC;IAE5C,wCAAwC;IACxC,KAAK,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CACxC,cAAc,CAAC,mBAAmB,CAAC,UAAU,CAC9C,EAAE,CAAC;QACF,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI;YAAE,SAAS;QACxC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC/D,IAAI,YAAY;YAAE,MAAM;IAC1B,CAAC;IAED,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC9D,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE,CAC7D,IAAI,CAAC,cAAc,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAC9C,IAAI,CAAC,cAAc,EAAE,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { join } from \"node:path\";\nimport { VSCodeProfile } from \"../types/types.vscode.js\";\nimport { storage } from \"./vscode.storage.js\";\nimport { configUserPath } from \"./vscode.config.js\";\nimport { findWorkspaceRoot } from \"../workspace/workspace.common.js\";\nimport { cwd } from \"node:process\";\n\n/**\n * Returns all VS Code user-data profiles.\n *\n * @remarks\n * Each profile is resolved from the persisted {@link storage} and enriched\n * with the absolute path to its `settings.json` via {@link profileSettingsPath}.\n *\n * @returns An array of {@link VSCodeProfile} objects for every configured profile.\n */\nexport const profiles = (): VSCodeProfile[] =>\n storage().userDataProfiles.map(\n (prof): VSCodeProfile => ({\n name: prof.name,\n location: prof.location,\n settingsPath: profileSettingsPath(prof.location),\n }),\n );\n\n/**\n * Resolves the active VS Code profile for a given workspace directory.\n *\n * @remarks\n * The workspace root is located via {@link findWorkspaceRoot}, then matched\n * against the profile-to-workspace associations stored in VS Code's\n * `storage.json`. Throws if no matching profile is found.\n *\n * @param dir - The directory to resolve the workspace from. Defaults to the\n * current working directory.\n * @returns A promise that resolves to the active {@link VSCodeProfile}.\n * @throws If no active profile is associated with the resolved workspace.\n */\nexport const activeProfile = async (dir?: string): Promise<VSCodeProfile> => {\n const foundWS = await findWorkspaceRoot(dir ?? cwd());\n const storageContent = storage();\n const profs = profiles();\n let foundProfile: VSCodeProfile | undefined;\n\n // eslint-disable-next-line prefer-const\n for (let [path, profile] of Object.entries(\n storageContent.profileAssociations.workspaces,\n )) {\n path = path.replace(\"file://\", \"\");\n if (foundWS.filePath !== path) continue;\n foundProfile = profs.find((prof) => prof.location === profile);\n if (foundProfile) break;\n }\n\n if (!foundProfile) throw new Error(\"No active profile found\");\n return foundProfile;\n};\n\n/**\n * Builds the absolute path to a profile's `settings.json` file.\n *\n * @param profile - The unique location identifier of the profile.\n * @returns The absolute path to `settings.json` inside the profile's directory.\n */\nexport const profileSettingsPath = (profile: string): string =>\n join(configUserPath(), \"profiles\", profile, \"settings.json\");\n\n/**\n * Returns the absolute path to the default (global) `settings.json` file.\n *\n * @remarks\n * This is the settings file used when no named profile is active.\n *\n * @returns The absolute path to the default `settings.json` in the VS Code\n * `User` directory.\n */\nexport const defaultSettingsPath = (): string =>\n join(configUserPath(), \"settings.json\");\n"]}
@@ -1,6 +1,31 @@
1
1
  import { VSCodeSettings } from "../types/types.vscode.js";
2
+ /**
3
+ * Reads and returns the VS Code `settings.json` for the active profile.
4
+ *
5
+ * @remarks
6
+ * The result is cached after the first successful read. If no active profile
7
+ * can be resolved, the default (global) settings file is used as a fallback.
8
+ * A shallow copy is returned so that callers cannot mutate the cached object.
9
+ *
10
+ * @param dir - Optional directory used to resolve the active profile's
11
+ * workspace. Defaults to the current working directory.
12
+ * @returns A promise that resolves to a shallow copy of the parsed
13
+ * {@link VSCodeSettings}.
14
+ * @throws If the settings file cannot be read or parsed.
15
+ */
2
16
  export declare const vscodeSettings: (dir?: string) => Promise<VSCodeSettings>;
17
+ /**
18
+ * Extracts the `C_Cpp.clang_format_style` value from the VS Code settings.
19
+ *
20
+ * @param cwd - The working directory used to locate the active profile's settings.
21
+ * @returns A promise that resolves to the clang-format style string.
22
+ * @throws If the `C_Cpp.clang_format_style` key is missing from the settings.
23
+ */
3
24
  export declare const clangFormatStyle: (cwd: string) => Promise<string>;
4
- /** @internal test-only */
25
+ /**
26
+ * Resets the cached settings so they are re-read on the next call.
27
+ *
28
+ * @internal
29
+ */
5
30
  export declare const __resetSettings: () => void;
6
31
  //# sourceMappingURL=vscode.settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.settings.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAO1D,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,cAAc,CAgBzE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CAKlE,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,eAAe,YAE3B,CAAC"}
1
+ {"version":3,"file":"vscode.settings.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAO1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,cAAc,CAgBzE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,MAAM,CAKlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,YAE3B,CAAC"}
@@ -2,6 +2,20 @@ import { activeProfile, defaultSettingsPath } from "./vscode.profiles.js";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import json5 from "json5";
4
4
  let __settings = null;
5
+ /**
6
+ * Reads and returns the VS Code `settings.json` for the active profile.
7
+ *
8
+ * @remarks
9
+ * The result is cached after the first successful read. If no active profile
10
+ * can be resolved, the default (global) settings file is used as a fallback.
11
+ * A shallow copy is returned so that callers cannot mutate the cached object.
12
+ *
13
+ * @param dir - Optional directory used to resolve the active profile's
14
+ * workspace. Defaults to the current working directory.
15
+ * @returns A promise that resolves to a shallow copy of the parsed
16
+ * {@link VSCodeSettings}.
17
+ * @throws If the settings file cannot be read or parsed.
18
+ */
5
19
  export const vscodeSettings = async (dir) => {
6
20
  if (!__settings) {
7
21
  let settingsPath;
@@ -18,13 +32,24 @@ export const vscodeSettings = async (dir) => {
18
32
  }
19
33
  return { ...__settings };
20
34
  };
35
+ /**
36
+ * Extracts the `C_Cpp.clang_format_style` value from the VS Code settings.
37
+ *
38
+ * @param cwd - The working directory used to locate the active profile's settings.
39
+ * @returns A promise that resolves to the clang-format style string.
40
+ * @throws If the `C_Cpp.clang_format_style` key is missing from the settings.
41
+ */
21
42
  export const clangFormatStyle = async (cwd) => {
22
43
  const settings = await vscodeSettings(cwd);
23
44
  if (!("C_Cpp.clang_format_style" in settings))
24
45
  throw new Error("C_Cpp.clang_format_style not found in settings.json");
25
46
  return settings["C_Cpp.clang_format_style"];
26
47
  };
27
- /** @internal test-only */
48
+ /**
49
+ * Resets the cached settings so they are re-read on the next call.
50
+ *
51
+ * @internal
52
+ */
28
53
  export const __resetSettings = () => {
29
54
  __settings = null;
30
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.settings.js","sourceRoot":"","sources":["../../src/vscode/vscode.settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,IAAI,UAAU,GAA0B,IAAI,CAAC;AAE7C,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,GAAY,EAA2B,EAAE;IAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,YAAgC,CAAC;QAErC,IAAI,CAAC;YACH,YAAY,GAAG,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,YAAY,GAAG,mBAAmB,EAAE,CAAC;QACvC,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAClD,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;IACrE,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,CAAC,0BAA0B,IAAI,QAAQ,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,OAAO,QAAQ,CAAC,0BAA0B,CAAW,CAAC;AACxD,CAAC,CAAC;AAEF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import { VSCodeSettings } from \"../types/types.vscode.js\";\nimport { activeProfile, defaultSettingsPath } from \"./vscode.profiles.js\";\nimport { readFile } from \"node:fs/promises\";\nimport json5 from \"json5\";\n\nlet __settings: VSCodeSettings | null = null;\n\nexport const vscodeSettings = async (dir?: string): Promise<VSCodeSettings> => {\n if (!__settings) {\n let settingsPath: string | undefined;\n\n try {\n settingsPath = (await activeProfile(dir)).settingsPath;\n } catch {\n settingsPath = defaultSettingsPath();\n }\n\n const raw = await readFile(settingsPath, \"utf-8\");\n __settings = json5.parse(raw);\n if (!__settings) throw new Error(\"No settings found\");\n }\n\n return { ...__settings };\n};\n\nexport const clangFormatStyle = async (cwd: string): Promise<string> => {\n const settings = await vscodeSettings(cwd);\n if (!(\"C_Cpp.clang_format_style\" in settings))\n throw new Error(\"C_Cpp.clang_format_style not found in settings.json\");\n return settings[\"C_Cpp.clang_format_style\"] as string;\n};\n\n/** @internal test-only */\nexport const __resetSettings = () => {\n __settings = null;\n};\n"]}
1
+ {"version":3,"file":"vscode.settings.js","sourceRoot":"","sources":["../../src/vscode/vscode.settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,IAAI,UAAU,GAA0B,IAAI,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,GAAY,EAA2B,EAAE;IAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,IAAI,YAAgC,CAAC;QAErC,IAAI,CAAC;YACH,YAAY,GAAG,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,YAAY,GAAG,mBAAmB,EAAE,CAAC;QACvC,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAClD,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;IACrE,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,CAAC,0BAA0B,IAAI,QAAQ,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,OAAO,QAAQ,CAAC,0BAA0B,CAAW,CAAC;AACxD,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import { VSCodeSettings } from \"../types/types.vscode.js\";\nimport { activeProfile, defaultSettingsPath } from \"./vscode.profiles.js\";\nimport { readFile } from \"node:fs/promises\";\nimport json5 from \"json5\";\n\nlet __settings: VSCodeSettings | null = null;\n\n/**\n * Reads and returns the VS Code `settings.json` for the active profile.\n *\n * @remarks\n * The result is cached after the first successful read. If no active profile\n * can be resolved, the default (global) settings file is used as a fallback.\n * A shallow copy is returned so that callers cannot mutate the cached object.\n *\n * @param dir - Optional directory used to resolve the active profile's\n * workspace. Defaults to the current working directory.\n * @returns A promise that resolves to a shallow copy of the parsed\n * {@link VSCodeSettings}.\n * @throws If the settings file cannot be read or parsed.\n */\nexport const vscodeSettings = async (dir?: string): Promise<VSCodeSettings> => {\n if (!__settings) {\n let settingsPath: string | undefined;\n\n try {\n settingsPath = (await activeProfile(dir)).settingsPath;\n } catch {\n settingsPath = defaultSettingsPath();\n }\n\n const raw = await readFile(settingsPath, \"utf-8\");\n __settings = json5.parse(raw);\n if (!__settings) throw new Error(\"No settings found\");\n }\n\n return { ...__settings };\n};\n\n/**\n * Extracts the `C_Cpp.clang_format_style` value from the VS Code settings.\n *\n * @param cwd - The working directory used to locate the active profile's settings.\n * @returns A promise that resolves to the clang-format style string.\n * @throws If the `C_Cpp.clang_format_style` key is missing from the settings.\n */\nexport const clangFormatStyle = async (cwd: string): Promise<string> => {\n const settings = await vscodeSettings(cwd);\n if (!(\"C_Cpp.clang_format_style\" in settings))\n throw new Error(\"C_Cpp.clang_format_style not found in settings.json\");\n return settings[\"C_Cpp.clang_format_style\"] as string;\n};\n\n/**\n * Resets the cached settings so they are re-read on the next call.\n *\n * @internal\n */\nexport const __resetSettings = () => {\n __settings = null;\n};\n"]}
@@ -1,6 +1,26 @@
1
1
  import { VSCodeStorage } from "../types/types.vscode.js";
2
+ /**
3
+ * Returns the absolute path to the VS Code `storage.json` file.
4
+ *
5
+ * @returns The path to `storage.json` inside the `globalStorage` directory.
6
+ */
2
7
  export declare const storagePath: () => string;
8
+ /**
9
+ * Reads and returns the parsed VS Code `storage.json`.
10
+ *
11
+ * @remarks
12
+ * The result is cached after the first successful read. Subsequent calls
13
+ * return the cached {@link VSCodeStorage} instance without re-reading
14
+ * the file from disk.
15
+ *
16
+ * @returns The parsed {@link VSCodeStorage} object.
17
+ * @throws If the file cannot be read or parsed.
18
+ */
3
19
  export declare const storage: () => VSCodeStorage;
4
- /** @internal test-only */
20
+ /**
21
+ * Resets the cached storage so it is re-read on the next call.
22
+ *
23
+ * @internal
24
+ */
5
25
  export declare const __resetStorage: () => void;
6
26
  //# sourceMappingURL=vscode.storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.storage.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,eAAO,MAAM,WAAW,QAAO,MAC0B,CAAC;AAG1D,eAAO,MAAM,OAAO,QAAO,aAM1B,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,cAAc,YAE1B,CAAC"}
1
+ {"version":3,"file":"vscode.storage.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,MAC0B,CAAC;AAI1D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,QAAO,aAM1B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAE1B,CAAC"}
@@ -2,8 +2,24 @@ import * as fs from "node:fs";
2
2
  import { join } from "node:path";
3
3
  import json5 from "json5";
4
4
  import { configUserPath } from "./vscode.config.js";
5
+ /**
6
+ * Returns the absolute path to the VS Code `storage.json` file.
7
+ *
8
+ * @returns The path to `storage.json` inside the `globalStorage` directory.
9
+ */
5
10
  export const storagePath = () => join(configUserPath(), "globalStorage", "storage.json");
6
11
  let __storage;
12
+ /**
13
+ * Reads and returns the parsed VS Code `storage.json`.
14
+ *
15
+ * @remarks
16
+ * The result is cached after the first successful read. Subsequent calls
17
+ * return the cached {@link VSCodeStorage} instance without re-reading
18
+ * the file from disk.
19
+ *
20
+ * @returns The parsed {@link VSCodeStorage} object.
21
+ * @throws If the file cannot be read or parsed.
22
+ */
7
23
  export const storage = () => {
8
24
  if (__storage)
9
25
  return __storage;
@@ -13,7 +29,11 @@ export const storage = () => {
13
29
  throw new Error("VS Code storage.json could not be loaded");
14
30
  return __storage;
15
31
  };
16
- /** @internal test-only */
32
+ /**
33
+ * Resets the cached storage so it is re-read on the next call.
34
+ *
35
+ * @internal
36
+ */
17
37
  export const __resetStorage = () => {
18
38
  __storage = undefined;
19
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.storage.js","sourceRoot":"","sources":["../../src/vscode/vscode.storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAW,EAAE,CACtC,IAAI,CAAC,cAAc,EAAE,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;AAE1D,IAAI,SAAoC,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAkB,EAAE;IACzC,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5E,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,SAAS,GAAG,SAAS,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport { join } from \"node:path\";\nimport json5 from \"json5\";\nimport { VSCodeStorage } from \"../types/types.vscode.js\";\nimport { configUserPath } from \"./vscode.config.js\";\n\nexport const storagePath = (): string =>\n join(configUserPath(), \"globalStorage\", \"storage.json\");\n\nlet __storage: VSCodeStorage | undefined;\nexport const storage = (): VSCodeStorage => {\n if (__storage) return __storage;\n const content = fs.readFileSync(storagePath()).toString();\n __storage = json5.parse(content);\n if (!__storage) throw new Error(\"VS Code storage.json could not be loaded\");\n return __storage;\n};\n\n/** @internal test-only */\nexport const __resetStorage = () => {\n __storage = undefined;\n};\n"]}
1
+ {"version":3,"file":"vscode.storage.js","sourceRoot":"","sources":["../../src/vscode/vscode.storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAW,EAAE,CACtC,IAAI,CAAC,cAAc,EAAE,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;AAE1D,IAAI,SAAoC,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,GAAkB,EAAE;IACzC,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC5E,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,SAAS,GAAG,SAAS,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport { join } from \"node:path\";\nimport json5 from \"json5\";\nimport { VSCodeStorage } from \"../types/types.vscode.js\";\nimport { configUserPath } from \"./vscode.config.js\";\n\n/**\n * Returns the absolute path to the VS Code `storage.json` file.\n *\n * @returns The path to `storage.json` inside the `globalStorage` directory.\n */\nexport const storagePath = (): string =>\n join(configUserPath(), \"globalStorage\", \"storage.json\");\n\nlet __storage: VSCodeStorage | undefined;\n\n/**\n * Reads and returns the parsed VS Code `storage.json`.\n *\n * @remarks\n * The result is cached after the first successful read. Subsequent calls\n * return the cached {@link VSCodeStorage} instance without re-reading\n * the file from disk.\n *\n * @returns The parsed {@link VSCodeStorage} object.\n * @throws If the file cannot be read or parsed.\n */\nexport const storage = (): VSCodeStorage => {\n if (__storage) return __storage;\n const content = fs.readFileSync(storagePath()).toString();\n __storage = json5.parse(content);\n if (!__storage) throw new Error(\"VS Code storage.json could not be loaded\");\n return __storage;\n};\n\n/**\n * Resets the cached storage so it is re-read on the next call.\n *\n * @internal\n */\nexport const __resetStorage = () => {\n __storage = undefined;\n};\n"]}
@@ -1,4 +1,21 @@
1
1
  import { VSCodeWorkspace } from "../types/types.vscode.js";
2
+ /**
3
+ * Reads and returns a parsed VS Code `.code-workspace` file.
4
+ *
5
+ * @remarks
6
+ * The result is cached per `workspaceFile` path. A shallow copy is returned
7
+ * so that callers cannot mutate the cached object.
8
+ *
9
+ * @param workspaceFile - Absolute path to the `.code-workspace` file.
10
+ * @returns A promise that resolves to a shallow copy of the parsed
11
+ * {@link VSCodeWorkspace}.
12
+ */
2
13
  export declare const vscodeWorkspace: (workspaceFile: string) => Promise<VSCodeWorkspace>;
14
+ /**
15
+ * Returns the directory that contains the given workspace file.
16
+ *
17
+ * @param workspaceFile - Absolute path to the `.code-workspace` file.
18
+ * @returns The parent directory of the workspace file.
19
+ */
3
20
  export declare const vscodeWorkspaceRoot: (workspaceFile: string) => string;
4
21
  //# sourceMappingURL=vscode.workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.workspace.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAM3D,eAAO,MAAM,eAAe,GAC1B,eAAe,MAAM,KACpB,OAAO,CAAC,eAAe,CASzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,eAAe,MAAM,WACjC,CAAC"}
1
+ {"version":3,"file":"vscode.workspace.d.ts","sourceRoot":"","sources":["../../src/vscode/vscode.workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAM3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,eAAe,MAAM,KACpB,OAAO,CAAC,eAAe,CASzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,eAAe,MAAM,WACjC,CAAC"}
@@ -2,6 +2,17 @@ import { readFile } from "node:fs/promises";
2
2
  import json5 from "json5";
3
3
  import { dirname } from "node:path";
4
4
  const __workspaces = {};
5
+ /**
6
+ * Reads and returns a parsed VS Code `.code-workspace` file.
7
+ *
8
+ * @remarks
9
+ * The result is cached per `workspaceFile` path. A shallow copy is returned
10
+ * so that callers cannot mutate the cached object.
11
+ *
12
+ * @param workspaceFile - Absolute path to the `.code-workspace` file.
13
+ * @returns A promise that resolves to a shallow copy of the parsed
14
+ * {@link VSCodeWorkspace}.
15
+ */
5
16
  export const vscodeWorkspace = async (workspaceFile) => {
6
17
  let found = __workspaces[workspaceFile];
7
18
  if (!found) {
@@ -11,5 +22,11 @@ export const vscodeWorkspace = async (workspaceFile) => {
11
22
  }
12
23
  return { ...found };
13
24
  };
25
+ /**
26
+ * Returns the directory that contains the given workspace file.
27
+ *
28
+ * @param workspaceFile - Absolute path to the `.code-workspace` file.
29
+ * @returns The parent directory of the workspace file.
30
+ */
14
31
  export const vscodeWorkspaceRoot = (workspaceFile) => dirname(workspaceFile);
15
32
  //# sourceMappingURL=vscode.workspace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vscode.workspace.js","sourceRoot":"","sources":["../../src/vscode/vscode.workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,YAAY,GAAoC,EAAE,CAAC;AAEzD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,aAAqB,EACK,EAAE;IAC5B,IAAI,KAAK,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACnD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,YAAY,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;IACtC,CAAC;IAED,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAqB,EAAE,EAAE,CAC3D,OAAO,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { VSCodeWorkspace } from \"../types/types.vscode.js\";\nimport json5 from \"json5\";\nimport { dirname } from \"node:path\";\n\nconst __workspaces: Record<string, VSCodeWorkspace> = {};\n\nexport const vscodeWorkspace = async (\n workspaceFile: string,\n): Promise<VSCodeWorkspace> => {\n let found = __workspaces[workspaceFile];\n if (!found) {\n const raw = await readFile(workspaceFile, \"utf-8\");\n found = json5.parse(raw);\n __workspaces[workspaceFile] = found;\n }\n\n return { ...found };\n};\n\nexport const vscodeWorkspaceRoot = (workspaceFile: string) =>\n dirname(workspaceFile);\n"]}
1
+ {"version":3,"file":"vscode.workspace.js","sourceRoot":"","sources":["../../src/vscode/vscode.workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,YAAY,GAAoC,EAAE,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,aAAqB,EACK,EAAE;IAC5B,IAAI,KAAK,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACnD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,YAAY,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;IACtC,CAAC;IAED,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;AACtB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,aAAqB,EAAE,EAAE,CAC3D,OAAO,CAAC,aAAa,CAAC,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { VSCodeWorkspace } from \"../types/types.vscode.js\";\nimport json5 from \"json5\";\nimport { dirname } from \"node:path\";\n\nconst __workspaces: Record<string, VSCodeWorkspace> = {};\n\n/**\n * Reads and returns a parsed VS Code `.code-workspace` file.\n *\n * @remarks\n * The result is cached per `workspaceFile` path. A shallow copy is returned\n * so that callers cannot mutate the cached object.\n *\n * @param workspaceFile - Absolute path to the `.code-workspace` file.\n * @returns A promise that resolves to a shallow copy of the parsed\n * {@link VSCodeWorkspace}.\n */\nexport const vscodeWorkspace = async (\n workspaceFile: string,\n): Promise<VSCodeWorkspace> => {\n let found = __workspaces[workspaceFile];\n if (!found) {\n const raw = await readFile(workspaceFile, \"utf-8\");\n found = json5.parse(raw);\n __workspaces[workspaceFile] = found;\n }\n\n return { ...found };\n};\n\n/**\n * Returns the directory that contains the given workspace file.\n *\n * @param workspaceFile - Absolute path to the `.code-workspace` file.\n * @returns The parent directory of the workspace file.\n */\nexport const vscodeWorkspaceRoot = (workspaceFile: string) =>\n dirname(workspaceFile);\n"]}
@@ -1,24 +1,109 @@
1
1
  import { PnpmWorkspace } from "../types/types.workspace.js";
2
2
  import { Pkg } from "../pkg/Pkg.js";
3
+ /**
4
+ * Create and register the global {@link Workspace} singleton.
5
+ *
6
+ * @remarks
7
+ * This is the primary entry point for bootstrapping a workspace. It must be
8
+ * called before {@link workspace} can be used. Subsequent calls replace the
9
+ * existing singleton.
10
+ *
11
+ * @param repoRoot - Absolute path to the repository root directory.
12
+ * @returns The newly created {@link Workspace} instance.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const ws = initWorkspace("/path/to/repo");
17
+ * await ws.read();
18
+ * console.log(ws.packages);
19
+ * ```
20
+ */
3
21
  export declare const initWorkspace: (repoRoot: string) => Workspace;
22
+ /**
23
+ * Retrieve the global {@link Workspace} singleton.
24
+ *
25
+ * @remarks
26
+ * Throws if {@link initWorkspace} has not been called first.
27
+ *
28
+ * @returns The current {@link Workspace} instance.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const ws = workspace();
33
+ * console.log(ws.rootPackage.name);
34
+ * ```
35
+ */
4
36
  export declare const workspace: () => Workspace;
5
37
  interface WorkspaceData {
6
38
  pnpmWs: PnpmWorkspace;
7
39
  rootPackage: Pkg;
8
40
  packages: Pkg[];
9
41
  }
42
+ /**
43
+ * Represents a pnpm monorepo workspace rooted at a given directory.
44
+ *
45
+ * @remarks
46
+ * {@link Workspace} is implemented as a singleton managed via the
47
+ * {@link initWorkspace} and {@link workspace} helper functions. It lazily
48
+ * reads the `pnpm-workspace.yaml` and every package's `package.json` on the
49
+ * first call to {@link Workspace.read}, and persists pending changes back to
50
+ * disk with {@link Workspace.write}.
51
+ */
10
52
  export declare class Workspace {
11
53
  readonly repoRoot: string;
12
54
  protected _data: WorkspaceData | null;
55
+ /**
56
+ * Create and register a new singleton instance.
57
+ *
58
+ * @internal
59
+ * @param repoRoot - Absolute path to the repository root directory.
60
+ * @returns The newly created {@link Workspace} instance.
61
+ */
13
62
  static __init(repoRoot: string): Workspace;
63
+ /**
64
+ * Return the current singleton instance.
65
+ *
66
+ * @internal
67
+ * @returns The existing {@link Workspace} instance.
68
+ * @throws {Error} If the singleton has not been initialised via {@link Workspace.__init}.
69
+ */
14
70
  static __get(): Workspace;
15
71
  private constructor();
72
+ /**
73
+ * A deep-cloned copy of the parsed `pnpm-workspace.yaml` configuration.
74
+ *
75
+ * @remarks
76
+ * Returns a clone so that callers cannot mutate the internal state.
77
+ */
16
78
  get pnpmWs(): PnpmWorkspace;
79
+ /**
80
+ * The list of {@link Pkg} instances representing each workspace package.
81
+ */
17
82
  get packages(): Pkg[];
83
+ /**
84
+ * The {@link Pkg} instance for the repository root `package.json`.
85
+ */
18
86
  get rootPackage(): Pkg;
19
87
  protected set data(c: WorkspaceData);
20
88
  protected get data(): WorkspaceData;
89
+ /**
90
+ * Read the workspace configuration and all package manifests from disk.
91
+ *
92
+ * @remarks
93
+ * This method is idempotent — if data has already been loaded it returns
94
+ * immediately without re-reading. It parses `pnpm-workspace.yaml`, then
95
+ * reads every referenced `package.json` in parallel.
96
+ *
97
+ * @returns This {@link Workspace} instance for chaining.
98
+ */
21
99
  read(): Promise<Workspace>;
100
+ /**
101
+ * Persist all modified package manifests back to disk.
102
+ *
103
+ * @remarks
104
+ * No-ops if {@link Workspace.read} has not yet been called. Writes the
105
+ * root package and every workspace package in parallel.
106
+ */
22
107
  write(): Promise<void>;
23
108
  }
24
109
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Workspace.d.ts","sourceRoot":"","sources":["../../src/workspace/Workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,cAA+B,CAAC;AAC9E,eAAO,MAAM,SAAS,iBAA0B,CAAC;AAEjD,UAAU,aAAa;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,GAAG,CAAC;IACjB,QAAQ,EAAE,GAAG,EAAE,CAAC;CACjB;AAED,qBAAa,SAAS;aAagB,QAAQ,EAAE,MAAM;IAZpD,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAQ;WAE/B,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS;WAInC,KAAK,IAAI,SAAS;IAMhC,OAAO;IAEP,IAAW,MAAM,IAAI,aAAa,CAEjC;IAED,IAAW,QAAQ,IAAI,GAAG,EAAE,CAE3B;IAED,IAAW,WAAW,IAAI,GAAG,CAE5B;IAED,SAAS,KAAK,IAAI,CAAC,CAAC,EAAE,aAAa,EAElC;IAED,SAAS,KAAK,IAAI,IAAI,aAAa,CAGlC;IAEY,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC;IAqB1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC"}
1
+ {"version":3,"file":"Workspace.d.ts","sourceRoot":"","sources":["../../src/workspace/Workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,MAAM,cAA+B,CAAC;AAE9E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS,iBAA0B,CAAC;AAEjD,UAAU,aAAa;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,EAAE,GAAG,CAAC;IACjB,QAAQ,EAAE,GAAG,EAAE,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,qBAAa,SAAS;aA2BgB,QAAQ,EAAE,MAAM;IA1BpD,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAQ;IAE7C;;;;;;OAMG;WACW,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS;IAIjD;;;;;;OAMG;WACW,KAAK,IAAI,SAAS;IAMhC,OAAO;IAEP;;;;;OAKG;IACH,IAAW,MAAM,IAAI,aAAa,CAEjC;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,GAAG,EAAE,CAE3B;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,GAAG,CAE5B;IAED,SAAS,KAAK,IAAI,CAAC,CAAC,EAAE,aAAa,EAElC;IAED,SAAS,KAAK,IAAI,IAAI,aAAa,CAGlC;IAED;;;;;;;;;OASG;IACU,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC;IAqBvC;;;;;;OAMG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC"}
@@ -2,14 +2,70 @@ import { readWorkspaceYaml } from "./workspace.common.js";
2
2
  import { Pkg } from "../pkg/Pkg.js";
3
3
  import { jsonClone } from "../common/common.json.js";
4
4
  let __instance = null;
5
+ /**
6
+ * Create and register the global {@link Workspace} singleton.
7
+ *
8
+ * @remarks
9
+ * This is the primary entry point for bootstrapping a workspace. It must be
10
+ * called before {@link workspace} can be used. Subsequent calls replace the
11
+ * existing singleton.
12
+ *
13
+ * @param repoRoot - Absolute path to the repository root directory.
14
+ * @returns The newly created {@link Workspace} instance.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const ws = initWorkspace("/path/to/repo");
19
+ * await ws.read();
20
+ * console.log(ws.packages);
21
+ * ```
22
+ */
5
23
  export const initWorkspace = (repoRoot) => Workspace.__init(repoRoot);
24
+ /**
25
+ * Retrieve the global {@link Workspace} singleton.
26
+ *
27
+ * @remarks
28
+ * Throws if {@link initWorkspace} has not been called first.
29
+ *
30
+ * @returns The current {@link Workspace} instance.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const ws = workspace();
35
+ * console.log(ws.rootPackage.name);
36
+ * ```
37
+ */
6
38
  export const workspace = () => Workspace.__get();
39
+ /**
40
+ * Represents a pnpm monorepo workspace rooted at a given directory.
41
+ *
42
+ * @remarks
43
+ * {@link Workspace} is implemented as a singleton managed via the
44
+ * {@link initWorkspace} and {@link workspace} helper functions. It lazily
45
+ * reads the `pnpm-workspace.yaml` and every package's `package.json` on the
46
+ * first call to {@link Workspace.read}, and persists pending changes back to
47
+ * disk with {@link Workspace.write}.
48
+ */
7
49
  export class Workspace {
8
50
  repoRoot;
9
51
  _data = null;
52
+ /**
53
+ * Create and register a new singleton instance.
54
+ *
55
+ * @internal
56
+ * @param repoRoot - Absolute path to the repository root directory.
57
+ * @returns The newly created {@link Workspace} instance.
58
+ */
10
59
  static __init(repoRoot) {
11
60
  return (__instance = new Workspace(repoRoot));
12
61
  }
62
+ /**
63
+ * Return the current singleton instance.
64
+ *
65
+ * @internal
66
+ * @returns The existing {@link Workspace} instance.
67
+ * @throws {Error} If the singleton has not been initialised via {@link Workspace.__init}.
68
+ */
13
69
  static __get() {
14
70
  if (!__instance)
15
71
  throw new Error("Workspace not initialized. initWorkspace()");
@@ -18,12 +74,24 @@ export class Workspace {
18
74
  constructor(repoRoot) {
19
75
  this.repoRoot = repoRoot;
20
76
  }
77
+ /**
78
+ * A deep-cloned copy of the parsed `pnpm-workspace.yaml` configuration.
79
+ *
80
+ * @remarks
81
+ * Returns a clone so that callers cannot mutate the internal state.
82
+ */
21
83
  get pnpmWs() {
22
84
  return jsonClone(this.data.pnpmWs);
23
85
  }
86
+ /**
87
+ * The list of {@link Pkg} instances representing each workspace package.
88
+ */
24
89
  get packages() {
25
90
  return this.data.packages;
26
91
  }
92
+ /**
93
+ * The {@link Pkg} instance for the repository root `package.json`.
94
+ */
27
95
  get rootPackage() {
28
96
  return this.data.rootPackage;
29
97
  }
@@ -35,6 +103,16 @@ export class Workspace {
35
103
  throw new Error(`Data not loaded. ${this.repoRoot}`);
36
104
  return this._data;
37
105
  }
106
+ /**
107
+ * Read the workspace configuration and all package manifests from disk.
108
+ *
109
+ * @remarks
110
+ * This method is idempotent — if data has already been loaded it returns
111
+ * immediately without re-reading. It parses `pnpm-workspace.yaml`, then
112
+ * reads every referenced `package.json` in parallel.
113
+ *
114
+ * @returns This {@link Workspace} instance for chaining.
115
+ */
38
116
  async read() {
39
117
  if (this._data)
40
118
  return this;
@@ -52,6 +130,13 @@ export class Workspace {
52
130
  };
53
131
  return this;
54
132
  }
133
+ /**
134
+ * Persist all modified package manifests back to disk.
135
+ *
136
+ * @remarks
137
+ * No-ops if {@link Workspace.read} has not yet been called. Writes the
138
+ * root package and every workspace package in parallel.
139
+ */
55
140
  async write() {
56
141
  if (!this._data)
57
142
  return;