@mxpicture/build-api 0.2.56 → 0.2.58

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 (159) 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 -2
  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 +33 -0
  26. package/dist/common/common.json.d.ts.map +1 -1
  27. package/dist/common/common.json.js +45 -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/ExportExtractor.d.ts +44 -0
  54. package/dist/pkg/ExportExtractor.d.ts.map +1 -0
  55. package/dist/pkg/ExportExtractor.js +180 -0
  56. package/dist/pkg/ExportExtractor.js.map +1 -0
  57. package/dist/pkg/Pkg.d.ts +69 -0
  58. package/dist/pkg/Pkg.d.ts.map +1 -1
  59. package/dist/pkg/Pkg.js +69 -0
  60. package/dist/pkg/Pkg.js.map +1 -1
  61. package/dist/pkg/SyncPkgVersion.d.ts +35 -0
  62. package/dist/pkg/SyncPkgVersion.d.ts.map +1 -1
  63. package/dist/pkg/SyncPkgVersion.js +35 -0
  64. package/dist/pkg/SyncPkgVersion.js.map +1 -1
  65. package/dist/pkg/UpdatePackages.d.ts +36 -0
  66. package/dist/pkg/UpdatePackages.d.ts.map +1 -1
  67. package/dist/pkg/UpdatePackages.js +36 -0
  68. package/dist/pkg/UpdatePackages.js.map +1 -1
  69. package/dist/pkg/index.d.ts +1 -0
  70. package/dist/pkg/index.d.ts.map +1 -1
  71. package/dist/pkg/index.js +1 -0
  72. package/dist/pkg/index.js.map +1 -1
  73. package/dist/pkg/pkg.common.d.ts +73 -0
  74. package/dist/pkg/pkg.common.d.ts.map +1 -1
  75. package/dist/pkg/pkg.common.js +73 -0
  76. package/dist/pkg/pkg.common.js.map +1 -1
  77. package/dist/pkg/pkg.fs.d.ts +53 -0
  78. package/dist/pkg/pkg.fs.d.ts.map +1 -1
  79. package/dist/pkg/pkg.fs.js +57 -5
  80. package/dist/pkg/pkg.fs.js.map +1 -1
  81. package/dist/types/index.d.ts +1 -0
  82. package/dist/types/index.d.ts.map +1 -1
  83. package/dist/types/index.js +1 -0
  84. package/dist/types/index.js.map +1 -1
  85. package/dist/types/types.barrel.d.ts +28 -0
  86. package/dist/types/types.barrel.d.ts.map +1 -1
  87. package/dist/types/types.barrel.js.map +1 -1
  88. package/dist/types/types.changelog.d.ts +28 -0
  89. package/dist/types/types.changelog.d.ts.map +1 -1
  90. package/dist/types/types.changelog.js +9 -0
  91. package/dist/types/types.changelog.js.map +1 -1
  92. package/dist/types/types.cleanup.d.ts +19 -0
  93. package/dist/types/types.cleanup.d.ts.map +1 -1
  94. package/dist/types/types.cleanup.js.map +1 -1
  95. package/dist/types/types.code.d.ts +36 -0
  96. package/dist/types/types.code.d.ts.map +1 -1
  97. package/dist/types/types.code.js.map +1 -1
  98. package/dist/types/types.deps.d.ts +27 -0
  99. package/dist/types/types.deps.d.ts.map +1 -1
  100. package/dist/types/types.deps.js +10 -0
  101. package/dist/types/types.deps.js.map +1 -1
  102. package/dist/types/types.documents.d.ts +9 -0
  103. package/dist/types/types.documents.d.ts.map +1 -1
  104. package/dist/types/types.documents.js.map +1 -1
  105. package/dist/types/types.exports.d.ts +42 -0
  106. package/dist/types/types.exports.d.ts.map +1 -0
  107. package/dist/types/types.exports.js +2 -0
  108. package/dist/types/types.exports.js.map +1 -0
  109. package/dist/types/types.git.d.ts +25 -0
  110. package/dist/types/types.git.d.ts.map +1 -1
  111. package/dist/types/types.git.js.map +1 -1
  112. package/dist/types/types.npm.d.ts +7 -0
  113. package/dist/types/types.npm.d.ts.map +1 -1
  114. package/dist/types/types.npm.js.map +1 -1
  115. package/dist/types/types.os.d.ts +8 -0
  116. package/dist/types/types.os.d.ts.map +1 -1
  117. package/dist/types/types.os.js.map +1 -1
  118. package/dist/types/types.package.d.ts +48 -0
  119. package/dist/types/types.package.d.ts.map +1 -1
  120. package/dist/types/types.package.js.map +1 -1
  121. package/dist/types/types.run.d.ts +4 -0
  122. package/dist/types/types.run.d.ts.map +1 -1
  123. package/dist/types/types.run.js.map +1 -1
  124. package/dist/types/types.vscode.d.ts +46 -0
  125. package/dist/types/types.vscode.d.ts.map +1 -1
  126. package/dist/types/types.vscode.js.map +1 -1
  127. package/dist/types/types.workspace.d.ts +18 -0
  128. package/dist/types/types.workspace.d.ts.map +1 -1
  129. package/dist/types/types.workspace.js +6 -0
  130. package/dist/types/types.workspace.js.map +1 -1
  131. package/dist/vscode/vscode.config.d.ts +18 -0
  132. package/dist/vscode/vscode.config.d.ts.map +1 -1
  133. package/dist/vscode/vscode.config.js +18 -0
  134. package/dist/vscode/vscode.config.js.map +1 -1
  135. package/dist/vscode/vscode.profiles.d.ts +37 -0
  136. package/dist/vscode/vscode.profiles.d.ts.map +1 -1
  137. package/dist/vscode/vscode.profiles.js +37 -0
  138. package/dist/vscode/vscode.profiles.js.map +1 -1
  139. package/dist/vscode/vscode.settings.d.ts +26 -1
  140. package/dist/vscode/vscode.settings.d.ts.map +1 -1
  141. package/dist/vscode/vscode.settings.js +28 -3
  142. package/dist/vscode/vscode.settings.js.map +1 -1
  143. package/dist/vscode/vscode.storage.d.ts +21 -1
  144. package/dist/vscode/vscode.storage.d.ts.map +1 -1
  145. package/dist/vscode/vscode.storage.js +23 -3
  146. package/dist/vscode/vscode.storage.js.map +1 -1
  147. package/dist/vscode/vscode.workspace.d.ts +17 -0
  148. package/dist/vscode/vscode.workspace.d.ts.map +1 -1
  149. package/dist/vscode/vscode.workspace.js +19 -2
  150. package/dist/vscode/vscode.workspace.js.map +1 -1
  151. package/dist/workspace/Workspace.d.ts +85 -0
  152. package/dist/workspace/Workspace.d.ts.map +1 -1
  153. package/dist/workspace/Workspace.js +85 -0
  154. package/dist/workspace/Workspace.js.map +1 -1
  155. package/dist/workspace/workspace.common.d.ts +42 -1
  156. package/dist/workspace/workspace.common.d.ts.map +1 -1
  157. package/dist/workspace/workspace.common.js +42 -1
  158. package/dist/workspace/workspace.common.js.map +1 -1
  159. package/package.json +3 -1
@@ -1,8 +1,17 @@
1
1
  import { simpleGit } from "simple-git";
2
2
  const __entries = [];
3
3
  /**
4
- * Creates a SimpleGit instance and verifies the cwd is a repo
5
- * and the commit ref is valid.
4
+ * Returns a verified {@link SimpleGit} instance for the given repository root.
5
+ *
6
+ * @remarks
7
+ * Instances are cached by `rootDir` and `commitRef` pair. On the first call
8
+ * for a given pair the function verifies that `rootDir` is a git repository
9
+ * and, when supplied, that `commitRef` resolves to a valid object.
10
+ *
11
+ * @param rootDir - Absolute path to the repository working directory.
12
+ * @param commitRef - Optional git ref (SHA, tag, branch) to validate.
13
+ * @returns A {@link SimpleGit} instance bound to `rootDir`.
14
+ * @throws If `rootDir` is not a git repository or `commitRef` is invalid.
6
15
  */
7
16
  export const verifiedGit = async (rootDir, commitRef) => {
8
17
  let found = __entries.find((entry) => entry.rootDir === rootDir && entry.commitRef === commitRef);
@@ -25,14 +34,52 @@ const verifyGit = async (git, rootDir, commitRef) => {
25
34
  }
26
35
  return { git, rootDir, commitRef };
27
36
  };
37
+ /**
38
+ * Retrieves the most recent tag in the repository.
39
+ *
40
+ * @param rootDir - Absolute path to the repository working directory.
41
+ * @returns The name of the latest tag, or `null` if no tags exist.
42
+ */
28
43
  export const lastTag = async (rootDir) => (await (await verifiedGit(rootDir)).tags()).latest ?? null;
44
+ /**
45
+ * Retrieves all tags in the repository.
46
+ *
47
+ * @param rootDir - Absolute path to the repository working directory.
48
+ * @returns An array of tag names.
49
+ */
29
50
  export const tags = async (rootDir) => (await (await verifiedGit(rootDir)).tags()).all;
51
+ /**
52
+ * Retrieves the hash of the most recent commit on the current branch.
53
+ *
54
+ * @param rootDir - Absolute path to the repository working directory.
55
+ * @returns The SHA hash of the latest commit, or `null` if the log is empty.
56
+ */
30
57
  export const lastCommitHash = async (rootDir) => (await (await verifiedGit(rootDir)).log()).latest?.hash ?? null;
58
+ /**
59
+ * Retrieves the full commit log as an array of {@link GitCommitHash} objects.
60
+ *
61
+ * @param rootDir - Absolute path to the repository working directory.
62
+ * @returns An array of commit hashes with dates and optional diff data.
63
+ */
31
64
  export const commitHashs = async (rootDir) => (await (await verifiedGit(rootDir)).log()).all.map((a) => ({
32
65
  date: a.date,
33
66
  hash: a.hash,
34
67
  diff: a.diff,
35
68
  }));
69
+ /**
70
+ * Resolves a git reference, falling back to a secondary ref if the primary is invalid.
71
+ *
72
+ * @remarks
73
+ * Attempts to verify `ref` against the repository. If verification fails
74
+ * (e.g. the ref does not exist), `fallback` is verified and returned instead.
75
+ * An error is thrown only when *both* refs are invalid.
76
+ *
77
+ * @param ref - The preferred git reference to validate.
78
+ * @param fallback - A fallback git reference used when `ref` is invalid.
79
+ * @param rootDir - Absolute path to the repository working directory.
80
+ * @returns The verified git reference string (`ref` or `fallback`).
81
+ * @throws If neither `ref` nor `fallback` resolves to a valid git object.
82
+ */
36
83
  export const ensureCommitRef = async (ref, fallback, rootDir) => {
37
84
  try {
38
85
  await verifiedGit(rootDir, ref);
@@ -43,7 +90,15 @@ export const ensureCommitRef = async (ref, fallback, rootDir) => {
43
90
  return fallback;
44
91
  }
45
92
  };
46
- /** @internal test-only */
93
+ /**
94
+ * Resets the internal cache of verified git entries.
95
+ *
96
+ * @remarks
97
+ * This is intended for test cleanup only and should never be called in
98
+ * production code.
99
+ *
100
+ * @internal
101
+ */
47
102
  export const __resetGitEntries = () => {
48
103
  __entries.length = 0;
49
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"git.util.js","sourceRoot":"","sources":["../../src/git/git.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,YAAY,CA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pleGit } from \"simple-git\";\nimport { GitCommitHash } from \"../types/types.git.js\";\n\ninterface GitEntry {\n git: SimpleGit;\n rootDir: string;\n commitRef?: string;\n}\n\nconst __entries: GitEntry[] = [];\n\n/**\n * Creates a SimpleGit instance and verifies the cwd is a repo\n * and the commit ref is valid.\n */\nexport const verifiedGit = async (\n rootDir: string,\n commitRef?: string,\n): Promise<SimpleGit> => {\n let found = __entries.find(\n (entry) => entry.rootDir === rootDir && entry.commitRef === commitRef,\n );\n if (!found) {\n found = await verifyGit(simpleGit(rootDir), rootDir, commitRef);\n __entries.push(found);\n }\n\n return found.git;\n};\n\nconst verifyGit = async (\n git: SimpleGit,\n rootDir: string,\n commitRef?: string,\n): Promise<GitEntry> => {\n if (!(await git.checkIsRepo()))\n throw new Error(`Not a git repository: ${rootDir}`);\n\n if (!commitRef) return { git, rootDir, commitRef };\n\n try {\n await git.revparse([\"--verify\", commitRef]);\n } catch {\n throw new Error(`Invalid git commit reference: \"${commitRef}\"`);\n }\n\n return { git, rootDir, commitRef };\n};\n\nexport const lastTag = async (rootDir: string): Promise<string | null> =>\n (await (await verifiedGit(rootDir)).tags()).latest ?? null;\n\nexport const tags = async (rootDir: string): Promise<string[]> =>\n (await (await verifiedGit(rootDir)).tags()).all;\n\nexport const lastCommitHash = async (rootDir: string): Promise<string | null> =>\n (await (await verifiedGit(rootDir)).log()).latest?.hash ?? null;\n\nexport const commitHashs = async (rootDir: string): Promise<GitCommitHash[]> =>\n (await (await verifiedGit(rootDir)).log()).all.map((a) => ({\n date: a.date,\n hash: a.hash,\n diff: a.diff,\n }));\n\nexport const ensureCommitRef = async (\n ref: string,\n fallback: string,\n rootDir: string,\n): Promise<string> => {\n try {\n await verifiedGit(rootDir, ref);\n return ref;\n } catch {\n await verifiedGit(rootDir, fallback);\n return fallback;\n }\n};\n\n/** @internal test-only */\nexport const __resetGitEntries = () => {\n __entries.length = 0;\n};\n"]}
1
+ {"version":3,"file":"git.util.js","sourceRoot":"","sources":["../../src/git/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;AACH,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import { SimpleGit, simpleGit } from \"simple-git\";\nimport { GitCommitHash } from \"../types/types.git.js\";\n\ninterface GitEntry {\n git: SimpleGit;\n rootDir: string;\n commitRef?: string;\n}\n\nconst __entries: GitEntry[] = [];\n\n/**\n * Returns a verified {@link SimpleGit} instance for the given repository root.\n *\n * @remarks\n * Instances are cached by `rootDir` and `commitRef` pair. On the first call\n * for a given pair the function verifies that `rootDir` is a git repository\n * and, when supplied, that `commitRef` resolves to a valid object.\n *\n * @param rootDir - Absolute path to the repository working directory.\n * @param commitRef - Optional git ref (SHA, tag, branch) to validate.\n * @returns A {@link SimpleGit} instance bound to `rootDir`.\n * @throws If `rootDir` is not a git repository or `commitRef` is invalid.\n */\nexport const verifiedGit = async (\n rootDir: string,\n commitRef?: string,\n): Promise<SimpleGit> => {\n let found = __entries.find(\n (entry) => entry.rootDir === rootDir && entry.commitRef === commitRef,\n );\n if (!found) {\n found = await verifyGit(simpleGit(rootDir), rootDir, commitRef);\n __entries.push(found);\n }\n\n return found.git;\n};\n\nconst verifyGit = async (\n git: SimpleGit,\n rootDir: string,\n commitRef?: string,\n): Promise<GitEntry> => {\n if (!(await git.checkIsRepo()))\n throw new Error(`Not a git repository: ${rootDir}`);\n\n if (!commitRef) return { git, rootDir, commitRef };\n\n try {\n await git.revparse([\"--verify\", commitRef]);\n } catch {\n throw new Error(`Invalid git commit reference: \"${commitRef}\"`);\n }\n\n return { git, rootDir, commitRef };\n};\n\n/**\n * Retrieves the most recent tag in the repository.\n *\n * @param rootDir - Absolute path to the repository working directory.\n * @returns The name of the latest tag, or `null` if no tags exist.\n */\nexport const lastTag = async (rootDir: string): Promise<string | null> =>\n (await (await verifiedGit(rootDir)).tags()).latest ?? null;\n\n/**\n * Retrieves all tags in the repository.\n *\n * @param rootDir - Absolute path to the repository working directory.\n * @returns An array of tag names.\n */\nexport const tags = async (rootDir: string): Promise<string[]> =>\n (await (await verifiedGit(rootDir)).tags()).all;\n\n/**\n * Retrieves the hash of the most recent commit on the current branch.\n *\n * @param rootDir - Absolute path to the repository working directory.\n * @returns The SHA hash of the latest commit, or `null` if the log is empty.\n */\nexport const lastCommitHash = async (rootDir: string): Promise<string | null> =>\n (await (await verifiedGit(rootDir)).log()).latest?.hash ?? null;\n\n/**\n * Retrieves the full commit log as an array of {@link GitCommitHash} objects.\n *\n * @param rootDir - Absolute path to the repository working directory.\n * @returns An array of commit hashes with dates and optional diff data.\n */\nexport const commitHashs = async (rootDir: string): Promise<GitCommitHash[]> =>\n (await (await verifiedGit(rootDir)).log()).all.map((a) => ({\n date: a.date,\n hash: a.hash,\n diff: a.diff,\n }));\n\n/**\n * Resolves a git reference, falling back to a secondary ref if the primary is invalid.\n *\n * @remarks\n * Attempts to verify `ref` against the repository. If verification fails\n * (e.g. the ref does not exist), `fallback` is verified and returned instead.\n * An error is thrown only when *both* refs are invalid.\n *\n * @param ref - The preferred git reference to validate.\n * @param fallback - A fallback git reference used when `ref` is invalid.\n * @param rootDir - Absolute path to the repository working directory.\n * @returns The verified git reference string (`ref` or `fallback`).\n * @throws If neither `ref` nor `fallback` resolves to a valid git object.\n */\nexport const ensureCommitRef = async (\n ref: string,\n fallback: string,\n rootDir: string,\n): Promise<string> => {\n try {\n await verifiedGit(rootDir, ref);\n return ref;\n } catch {\n await verifiedGit(rootDir, fallback);\n return fallback;\n }\n};\n\n/**\n * Resets the internal cache of verified git entries.\n *\n * @remarks\n * This is intended for test cleanup only and should never be called in\n * production code.\n *\n * @internal\n */\nexport const __resetGitEntries = () => {\n __entries.length = 0;\n};\n"]}
@@ -1,14 +1,88 @@
1
+ /**
2
+ * A function that accepts variadic arguments and logs them.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const handler: LoggerHandler = (...data) => console.log(...data);
7
+ * handler("hello", 42);
8
+ * ```
9
+ */
1
10
  export type LoggerHandler = (...data: any[]) => void;
11
+ /**
12
+ * Logger interface providing success, error, and info logging channels.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const myLogger: Logger = {
17
+ * success: console.log,
18
+ * error: console.error,
19
+ * info: console.log,
20
+ * };
21
+ * initLogger(myLogger);
22
+ * ```
23
+ */
2
24
  export interface Logger {
25
+ /** Logs a success message. */
3
26
  success: LoggerHandler;
27
+ /** Logs an error message. */
4
28
  error: LoggerHandler;
29
+ /** Logs an informational message. */
5
30
  info: LoggerHandler;
6
31
  }
32
+ /**
33
+ * Initializes the global logger instance.
34
+ *
35
+ * @param log - The {@link Logger} implementation to use globally.
36
+ * @returns The logger that was set.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * initLogger(consoleLogger);
41
+ * ```
42
+ */
7
43
  export declare const initLogger: (log: Logger) => Logger;
44
+ /**
45
+ * Returns the current global logger, falling back to {@link silentLogger} if none has been initialized.
46
+ *
47
+ * @returns The active {@link Logger} instance.
48
+ */
8
49
  export declare const logger: () => Logger;
50
+ /**
51
+ * Logs a success message through the global logger.
52
+ *
53
+ * @param data - The values to log.
54
+ */
9
55
  export declare const logSuccess: LoggerHandler;
56
+ /**
57
+ * Logs an error message through the global logger.
58
+ *
59
+ * @param data - The values to log.
60
+ */
10
61
  export declare const logError: LoggerHandler;
62
+ /**
63
+ * Logs an informational message through the global logger.
64
+ *
65
+ * @param data - The values to log.
66
+ */
11
67
  export declare const logInfo: LoggerHandler;
68
+ /**
69
+ * A logger that silently discards all messages.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * initLogger(silentLogger);
74
+ * logInfo("this is discarded");
75
+ * ```
76
+ */
12
77
  export declare const silentLogger: Logger;
78
+ /**
79
+ * A logger that writes to the console using {@link console.log} and {@link console.error}.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * initLogger(consoleLogger);
84
+ * logSuccess("build complete");
85
+ * ```
86
+ */
13
87
  export declare const consoleLogger: Logger;
14
88
  //# sourceMappingURL=Logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAErD,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC;CACrB;AAID,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,WAAqB,CAAC;AAC5D,eAAO,MAAM,MAAM,QAAO,MAAkC,CAAC;AAG7D,eAAO,MAAM,UAAU,EAAE,aACE,CAAC;AAG5B,eAAO,MAAM,QAAQ,EAAE,aACE,CAAC;AAG1B,eAAO,MAAM,OAAO,EAAE,aACE,CAAC;AAEzB,eAAO,MAAM,YAAY,EAAE,MAI1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAI3B,CAAC"}
1
+ {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,MAAM;IACrB,8BAA8B;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,6BAA6B;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,qCAAqC;IACrC,IAAI,EAAE,aAAa,CAAC;CACrB;AAID;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,WAAqB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,MAAM,QAAO,MAAkC,CAAC;AAE7D;;;;GAIG;AAEH,eAAO,MAAM,UAAU,EAAE,aACE,CAAC;AAE5B;;;;GAIG;AAEH,eAAO,MAAM,QAAQ,EAAE,aACE,CAAC;AAE1B;;;;GAIG;AAEH,eAAO,MAAM,OAAO,EAAE,aACE,CAAC;AAEzB;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,MAI1B,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,MAI3B,CAAC"}
@@ -1,17 +1,66 @@
1
1
  let __logger = null;
2
+ /**
3
+ * Initializes the global logger instance.
4
+ *
5
+ * @param log - The {@link Logger} implementation to use globally.
6
+ * @returns The logger that was set.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * initLogger(consoleLogger);
11
+ * ```
12
+ */
2
13
  export const initLogger = (log) => (__logger = log);
14
+ /**
15
+ * Returns the current global logger, falling back to {@link silentLogger} if none has been initialized.
16
+ *
17
+ * @returns The active {@link Logger} instance.
18
+ */
3
19
  export const logger = () => __logger ?? silentLogger;
20
+ /**
21
+ * Logs a success message through the global logger.
22
+ *
23
+ * @param data - The values to log.
24
+ */
4
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
26
  export const logSuccess = (...data) => logger().success(...data);
27
+ /**
28
+ * Logs an error message through the global logger.
29
+ *
30
+ * @param data - The values to log.
31
+ */
6
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
33
  export const logError = (...data) => logger().error(...data);
34
+ /**
35
+ * Logs an informational message through the global logger.
36
+ *
37
+ * @param data - The values to log.
38
+ */
8
39
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
40
  export const logInfo = (...data) => logger().info(...data);
41
+ /**
42
+ * A logger that silently discards all messages.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * initLogger(silentLogger);
47
+ * logInfo("this is discarded");
48
+ * ```
49
+ */
10
50
  export const silentLogger = {
11
51
  success: () => { },
12
52
  error: () => { },
13
53
  info: () => { },
14
54
  };
55
+ /**
56
+ * A logger that writes to the console using {@link console.log} and {@link console.error}.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * initLogger(consoleLogger);
61
+ * logSuccess("build complete");
62
+ * ```
63
+ */
15
64
  export const consoleLogger = {
16
65
  success: console.log,
17
66
  error: console.error,
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":"AASA,IAAI,QAAQ,GAAkB,IAAI,CAAC;AAEnC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,QAAQ,IAAI,YAAY,CAAC;AAE7D,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAkB,CAAC,GAAG,IAAW,EAAQ,EAAE,CAChE,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AAE5B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,QAAQ,GAAkB,CAAC,GAAG,IAAW,EAAQ,EAAE,CAC9D,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AAE1B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAkB,CAAC,GAAG,IAAW,EAAQ,EAAE,CAC7D,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAEzB,MAAM,CAAC,MAAM,YAAY,GAAW;IAClC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;IACjB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;CACf,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,OAAO,EAAE,OAAO,CAAC,GAAG;IACpB,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,IAAI,EAAE,OAAO,CAAC,GAAG;CAClB,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoggerHandler = (...data: any[]) => void;\n\nexport interface Logger {\n success: LoggerHandler;\n error: LoggerHandler;\n info: LoggerHandler;\n}\n\nlet __logger: Logger | null = null;\n\nexport const initLogger = (log: Logger) => (__logger = log);\nexport const logger = (): Logger => __logger ?? silentLogger;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const logSuccess: LoggerHandler = (...data: any[]): void =>\n logger().success(...data);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const logError: LoggerHandler = (...data: any[]): void =>\n logger().error(...data);\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const logInfo: LoggerHandler = (...data: any[]): void =>\n logger().info(...data);\n\nexport const silentLogger: Logger = {\n success: () => {},\n error: () => {},\n info: () => {},\n};\n\nexport const consoleLogger: Logger = {\n success: console.log,\n error: console.error,\n info: console.log,\n};\n"]}
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/logger/Logger.ts"],"names":[],"mappings":"AAkCA,IAAI,QAAQ,GAAkB,IAAI,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE,CAAC,QAAQ,IAAI,YAAY,CAAC;AAE7D;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAkB,CAAC,GAAG,IAAW,EAAQ,EAAE,CAChE,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AAE5B;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,QAAQ,GAAkB,CAAC,GAAG,IAAW,EAAQ,EAAE,CAC9D,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;AAE1B;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,OAAO,GAAkB,CAAC,GAAG,IAAW,EAAQ,EAAE,CAC7D,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAEzB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAW;IAClC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;IACjB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;CACf,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAW;IACnC,OAAO,EAAE,OAAO,CAAC,GAAG;IACpB,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,IAAI,EAAE,OAAO,CAAC,GAAG;CAClB,CAAC","sourcesContent":["/**\n * A function that accepts variadic arguments and logs them.\n *\n * @example\n * ```ts\n * const handler: LoggerHandler = (...data) => console.log(...data);\n * handler(\"hello\", 42);\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoggerHandler = (...data: any[]) => void;\n\n/**\n * Logger interface providing success, error, and info logging channels.\n *\n * @example\n * ```ts\n * const myLogger: Logger = {\n * success: console.log,\n * error: console.error,\n * info: console.log,\n * };\n * initLogger(myLogger);\n * ```\n */\nexport interface Logger {\n /** Logs a success message. */\n success: LoggerHandler;\n /** Logs an error message. */\n error: LoggerHandler;\n /** Logs an informational message. */\n info: LoggerHandler;\n}\n\nlet __logger: Logger | null = null;\n\n/**\n * Initializes the global logger instance.\n *\n * @param log - The {@link Logger} implementation to use globally.\n * @returns The logger that was set.\n *\n * @example\n * ```ts\n * initLogger(consoleLogger);\n * ```\n */\nexport const initLogger = (log: Logger) => (__logger = log);\n\n/**\n * Returns the current global logger, falling back to {@link silentLogger} if none has been initialized.\n *\n * @returns The active {@link Logger} instance.\n */\nexport const logger = (): Logger => __logger ?? silentLogger;\n\n/**\n * Logs a success message through the global logger.\n *\n * @param data - The values to log.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const logSuccess: LoggerHandler = (...data: any[]): void =>\n logger().success(...data);\n\n/**\n * Logs an error message through the global logger.\n *\n * @param data - The values to log.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const logError: LoggerHandler = (...data: any[]): void =>\n logger().error(...data);\n\n/**\n * Logs an informational message through the global logger.\n *\n * @param data - The values to log.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const logInfo: LoggerHandler = (...data: any[]): void =>\n logger().info(...data);\n\n/**\n * A logger that silently discards all messages.\n *\n * @example\n * ```ts\n * initLogger(silentLogger);\n * logInfo(\"this is discarded\");\n * ```\n */\nexport const silentLogger: Logger = {\n success: () => {},\n error: () => {},\n info: () => {},\n};\n\n/**\n * A logger that writes to the console using {@link console.log} and {@link console.error}.\n *\n * @example\n * ```ts\n * initLogger(consoleLogger);\n * logSuccess(\"build complete\");\n * ```\n */\nexport const consoleLogger: Logger = {\n success: console.log,\n error: console.error,\n info: console.log,\n};\n"]}
@@ -1,8 +1,44 @@
1
1
  import { NpmPublisherParams } from "../types/types.npm.js";
2
2
  import { Pkg } from "../pkg/Pkg.js";
3
+ /**
4
+ * Publishes all non-private workspace packages to the npm registry.
5
+ *
6
+ * @remarks
7
+ * Initialises the workspace from the given repository root, then delegates
8
+ * to {@link NpmPublisher.run} which publishes every public package in
9
+ * parallel. Already-published versions are automatically skipped.
10
+ *
11
+ * @param params - Publisher parameters containing the repository root path.
12
+ * @returns A promise that resolves when all packages have been processed.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * await runNpmPublisher({ repoRoot: "/path/to/repo" });
17
+ * ```
18
+ */
3
19
  export declare const runNpmPublisher: (params: NpmPublisherParams) => Promise<void>;
20
+ /**
21
+ * Publishes workspace packages to the npm registry.
22
+ *
23
+ * @remarks
24
+ * Reads every package from the current workspace, attempts to publish each
25
+ * non-private package in parallel via `npm publish --access public`, and
26
+ * exits the process with code 1 if any publication fails. Packages whose
27
+ * exact version is already on the registry are silently skipped.
28
+ */
4
29
  export declare class NpmPublisher {
30
+ /** Creates a new {@link NpmPublisher} instance. */
5
31
  constructor();
32
+ /**
33
+ * Publishes all non-private workspace packages.
34
+ *
35
+ * @remarks
36
+ * Each package is published concurrently using `Promise.allSettled`.
37
+ * If one or more packages fail, the errors are logged and the process
38
+ * exits with code 1.
39
+ *
40
+ * @returns A promise that resolves when all publish attempts have settled.
41
+ */
6
42
  run(): Promise<void>;
7
43
  protected runPackage(pkg: Pkg): Promise<void>;
8
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NpmPublisher.d.ts","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC,eAAO,MAAM,eAAe,GAAU,QAAQ,kBAAkB,kBAG/D,CAAC;AAEF,qBAAa,YAAY;;IAGV,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;cAiBjB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAkCpD"}
1
+ {"version":3,"file":"NpmPublisher.d.ts","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,GAAU,QAAQ,kBAAkB,kBAG/D,CAAC;AAEF;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACvB,mDAAmD;;IAGnD;;;;;;;;;OASG;IACU,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;cAiBjB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;CAkCpD"}
@@ -1,12 +1,48 @@
1
1
  import { logError, logInfo, logSuccess } from "../logger/Logger.js";
2
2
  import { execAsync } from "../common/common.fs.js";
3
3
  import { initWorkspace, workspace } from "../workspace/Workspace.js";
4
+ /**
5
+ * Publishes all non-private workspace packages to the npm registry.
6
+ *
7
+ * @remarks
8
+ * Initialises the workspace from the given repository root, then delegates
9
+ * to {@link NpmPublisher.run} which publishes every public package in
10
+ * parallel. Already-published versions are automatically skipped.
11
+ *
12
+ * @param params - Publisher parameters containing the repository root path.
13
+ * @returns A promise that resolves when all packages have been processed.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * await runNpmPublisher({ repoRoot: "/path/to/repo" });
18
+ * ```
19
+ */
4
20
  export const runNpmPublisher = async (params) => {
5
21
  initWorkspace(params.repoRoot);
6
22
  return new NpmPublisher().run();
7
23
  };
24
+ /**
25
+ * Publishes workspace packages to the npm registry.
26
+ *
27
+ * @remarks
28
+ * Reads every package from the current workspace, attempts to publish each
29
+ * non-private package in parallel via `npm publish --access public`, and
30
+ * exits the process with code 1 if any publication fails. Packages whose
31
+ * exact version is already on the registry are silently skipped.
32
+ */
8
33
  export class NpmPublisher {
34
+ /** Creates a new {@link NpmPublisher} instance. */
9
35
  constructor() { }
36
+ /**
37
+ * Publishes all non-private workspace packages.
38
+ *
39
+ * @remarks
40
+ * Each package is published concurrently using `Promise.allSettled`.
41
+ * If one or more packages fail, the errors are logged and the process
42
+ * exits with code 1.
43
+ *
44
+ * @returns A promise that resolves when all publish attempts have settled.
45
+ */
10
46
  async run() {
11
47
  const pkgs = (await workspace().read()).packages;
12
48
  const results = await Promise.allSettled(pkgs.map((d) => this.runPackage(d)));
@@ -1 +1 @@
1
- {"version":3,"file":"NpmPublisher.js","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,C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,SAAS,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,CACrE,CAAC;QAEF,mDAAmD;QACnD,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,YAAY,IAAI,IAAI,OAAO,UAAU,CAAC,CAAC;YAC1E,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;YAEhC,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;gBAC1B,OAAO,CAAC,OAAO,IAAI,IAAI,OAAO,+BAA+B,CAAC,CAAC;gBAC/D,OAAO;YACT,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,yFAAyF;QAC3F,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,6BAA6B,EAAE;gBAC7C,GAAG,EAAE,GAAG,CAAC,OAAO;aACjB,CAAC,CAAC;YACH,UAAU,CACR,KAAK,IAAI,IAAI,OAAO,4BAA4B,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,CAC7E,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,qBAAqB,IAAI,IAAI,OAAO,KAAK,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC;YAC1F,QAAQ,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { logError, logInfo, logSuccess } from \"../logger/Logger.js\";\nimport { execAsync } from \"../common/common.fs.js\";\nimport { NpmPublisherParams } from \"../types/types.npm.js\";\nimport { Pkg } from \"../pkg/Pkg.js\";\nimport { initWorkspace, workspace } from \"../workspace/Workspace.js\";\n\nexport const runNpmPublisher = async (params: NpmPublisherParams) => {\n initWorkspace(params.repoRoot);\n return new NpmPublisher().run();\n};\n\nexport class NpmPublisher {\n public constructor() {}\n\n public async run(): Promise<void> {\n const pkgs = (await workspace().read()).packages;\n\n const results = await Promise.allSettled(\n pkgs.map((d) => this.runPackage(d)),\n );\n\n const failures = results.filter((r) => r.status === \"rejected\");\n if (failures.length > 0) {\n logError(`\\n❌ ${failures.length} package(s) failed to publish:`);\n failures.forEach((failure) => {\n logError(failure.reason);\n });\n process.exit(1);\n }\n }\n\n protected async runPackage(pkg: Pkg): Promise<void> {\n if (pkg.content.private) return;\n const { name, version } = pkg.content;\n\n logInfo(\n `📦 Publishing ${name}@${version} ... (${new Date().toISOString()})`,\n );\n\n // Check if this exact version is already published\n try {\n const { stdout } = await execAsync(`npm view ${name}@${version} version`);\n const published = stdout.trim();\n\n if (published === version) {\n logInfo(`⏭️ ${name}@${version} already published, skipping.`);\n return;\n }\n } catch {\n // npm view exits non-zero if the package/version doesn't exist — means we should publish\n }\n\n try {\n await execAsync(\"npm publish --access public\", {\n cwd: pkg.dirPath,\n });\n logSuccess(\n `✅ ${name}@${version} published successfully (${new Date().toISOString()}).`,\n );\n } catch (err) {\n const errorMessage = `Failed to publish ${name}@${version} (${new Date().toISOString()})`;\n logError(`❌ ${errorMessage}`);\n throw new Error(errorMessage, { cause: err });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"NpmPublisher.js","sourceRoot":"","sources":["../../src/npmPublish/NpmPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,MAA0B,EAAE,EAAE;IAClE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,IAAI,YAAY,EAAE,CAAC,GAAG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U,CAAC,CAAC;YAC1E,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;YAEhC,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;gBAC1B,OAAO,CAAC,OAAO,IAAI,IAAI,OAAO,+BAA+B,CAAC,CAAC;gBAC/D,OAAO;YACT,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,yFAAyF;QAC3F,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,6BAA6B,EAAE;gBAC7C,GAAG,EAAE,GAAG,CAAC,OAAO;aACjB,CAAC,CAAC;YACH,UAAU,CACR,KAAK,IAAI,IAAI,OAAO,4BAA4B,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,CAC7E,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,qBAAqB,IAAI,IAAI,OAAO,KAAK,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC;YAC1F,QAAQ,CAAC,KAAK,YAAY,EAAE,CAAC,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { logError, logInfo, logSuccess } from \"../logger/Logger.js\";\nimport { execAsync } from \"../common/common.fs.js\";\nimport { NpmPublisherParams } from \"../types/types.npm.js\";\nimport { Pkg } from \"../pkg/Pkg.js\";\nimport { initWorkspace, workspace } from \"../workspace/Workspace.js\";\n\n/**\n * Publishes all non-private workspace packages to the npm registry.\n *\n * @remarks\n * Initialises the workspace from the given repository root, then delegates\n * to {@link NpmPublisher.run} which publishes every public package in\n * parallel. Already-published versions are automatically skipped.\n *\n * @param params - Publisher parameters containing the repository root path.\n * @returns A promise that resolves when all packages have been processed.\n *\n * @example\n * ```ts\n * await runNpmPublisher({ repoRoot: \"/path/to/repo\" });\n * ```\n */\nexport const runNpmPublisher = async (params: NpmPublisherParams) => {\n initWorkspace(params.repoRoot);\n return new NpmPublisher().run();\n};\n\n/**\n * Publishes workspace packages to the npm registry.\n *\n * @remarks\n * Reads every package from the current workspace, attempts to publish each\n * non-private package in parallel via `npm publish --access public`, and\n * exits the process with code 1 if any publication fails. Packages whose\n * exact version is already on the registry are silently skipped.\n */\nexport class NpmPublisher {\n /** Creates a new {@link NpmPublisher} instance. */\n public constructor() {}\n\n /**\n * Publishes all non-private workspace packages.\n *\n * @remarks\n * Each package is published concurrently using `Promise.allSettled`.\n * If one or more packages fail, the errors are logged and the process\n * exits with code 1.\n *\n * @returns A promise that resolves when all publish attempts have settled.\n */\n public async run(): Promise<void> {\n const pkgs = (await workspace().read()).packages;\n\n const results = await Promise.allSettled(\n pkgs.map((d) => this.runPackage(d)),\n );\n\n const failures = results.filter((r) => r.status === \"rejected\");\n if (failures.length > 0) {\n logError(`\\n❌ ${failures.length} package(s) failed to publish:`);\n failures.forEach((failure) => {\n logError(failure.reason);\n });\n process.exit(1);\n }\n }\n\n protected async runPackage(pkg: Pkg): Promise<void> {\n if (pkg.content.private) return;\n const { name, version } = pkg.content;\n\n logInfo(\n `📦 Publishing ${name}@${version} ... (${new Date().toISOString()})`,\n );\n\n // Check if this exact version is already published\n try {\n const { stdout } = await execAsync(`npm view ${name}@${version} version`);\n const published = stdout.trim();\n\n if (published === version) {\n logInfo(`⏭️ ${name}@${version} already published, skipping.`);\n return;\n }\n } catch {\n // npm view exits non-zero if the package/version doesn't exist — means we should publish\n }\n\n try {\n await execAsync(\"npm publish --access public\", {\n cwd: pkg.dirPath,\n });\n logSuccess(\n `✅ ${name}@${version} published successfully (${new Date().toISOString()}).`,\n );\n } catch (err) {\n const errorMessage = `Failed to publish ${name}@${version} (${new Date().toISOString()})`;\n logError(`❌ ${errorMessage}`);\n throw new Error(errorMessage, { cause: err });\n }\n }\n}\n"]}
@@ -1,7 +1,51 @@
1
1
  import { OSInfo } from "../types/types.os.js";
2
+ /**
3
+ * Returns the current operating-system information, creating it on first call.
4
+ *
5
+ * @remarks
6
+ * The result is lazily computed and cached for the lifetime of the process.
7
+ * On WSL environments (detected via the kernel release string) the info is
8
+ * sourced from the Windows host; otherwise the native Node.js APIs are used.
9
+ *
10
+ * @returns The cached {@link OSInfo} for the current environment.
11
+ * @throws {Error} If OS information cannot be determined.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const info = osInfo();
16
+ * console.log(info.platform, info.homedir);
17
+ * ```
18
+ */
2
19
  export declare const osInfo: () => OSInfo;
20
+ /**
21
+ * Builds OS information using native Node.js APIs.
22
+ *
23
+ * @remarks
24
+ * Resolves the platform-specific application configuration directory:
25
+ * - **Windows** (`win32`): `%APPDATA%`
26
+ * - **macOS** (`darwin`): `~/Library/Application Support`
27
+ * - **Linux / other**: `~/.config`
28
+ *
29
+ * @returns An {@link OSInfo} object for the current (non-WSL) environment.
30
+ */
3
31
  export declare const defaultInfo: () => OSInfo;
32
+ /**
33
+ * Builds OS information for a Windows Subsystem for Linux (WSL) environment.
34
+ *
35
+ * @remarks
36
+ * Calls `whoami.exe` to determine the Windows username, then constructs
37
+ * paths that point into the Windows file system mounted under `/mnt/c`.
38
+ * The returned {@link OSInfo.isWSL} flag is always `true`.
39
+ *
40
+ * @returns An {@link OSInfo} object reflecting the Windows host environment.
41
+ * @throws {Error} If the Windows username cannot be determined from `whoami.exe`.
42
+ */
4
43
  export declare const wslInfo: () => OSInfo;
5
- /** @internal test-only */
44
+ /**
45
+ * Resets the cached OS information so the next call to {@link osInfo} recomputes it.
46
+ *
47
+ * @internal
48
+ * This function is intended for testing purposes only.
49
+ */
6
50
  export declare const __resetOsInfo: () => void;
7
51
  //# sourceMappingURL=osInfo.common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"osInfo.common.d.ts","sourceRoot":"","sources":["../../src/osInfo/osInfo.common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,eAAO,MAAM,MAAM,QAAO,MAOzB,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,MAmB9B,CAAC;AAEF,eAAO,MAAM,OAAO,QAAO,MAuB1B,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,aAAa,YAEzB,CAAC"}
1
+ {"version":3,"file":"osInfo.common.d.ts","sourceRoot":"","sources":["../../src/osInfo/osInfo.common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,QAAO,MAOzB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,QAAO,MAmB9B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,QAAO,MAuB1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAEzB,CAAC"}
@@ -2,6 +2,23 @@ import { join, sep } from "node:path";
2
2
  import * as os from "node:os";
3
3
  import { execSync } from "node:child_process";
4
4
  let __info = null;
5
+ /**
6
+ * Returns the current operating-system information, creating it on first call.
7
+ *
8
+ * @remarks
9
+ * The result is lazily computed and cached for the lifetime of the process.
10
+ * On WSL environments (detected via the kernel release string) the info is
11
+ * sourced from the Windows host; otherwise the native Node.js APIs are used.
12
+ *
13
+ * @returns The cached {@link OSInfo} for the current environment.
14
+ * @throws {Error} If OS information cannot be determined.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const info = osInfo();
19
+ * console.log(info.platform, info.homedir);
20
+ * ```
21
+ */
5
22
  export const osInfo = () => {
6
23
  if (!__info) {
7
24
  const isWSL = os.release().toLowerCase().includes("microsoft");
@@ -11,6 +28,17 @@ export const osInfo = () => {
11
28
  }
12
29
  return __info;
13
30
  };
31
+ /**
32
+ * Builds OS information using native Node.js APIs.
33
+ *
34
+ * @remarks
35
+ * Resolves the platform-specific application configuration directory:
36
+ * - **Windows** (`win32`): `%APPDATA%`
37
+ * - **macOS** (`darwin`): `~/Library/Application Support`
38
+ * - **Linux / other**: `~/.config`
39
+ *
40
+ * @returns An {@link OSInfo} object for the current (non-WSL) environment.
41
+ */
14
42
  export const defaultInfo = () => {
15
43
  const platform = process.platform;
16
44
  const homedir = os.homedir();
@@ -32,6 +60,17 @@ export const defaultInfo = () => {
32
60
  configDir: join(...configDirParts),
33
61
  };
34
62
  };
63
+ /**
64
+ * Builds OS information for a Windows Subsystem for Linux (WSL) environment.
65
+ *
66
+ * @remarks
67
+ * Calls `whoami.exe` to determine the Windows username, then constructs
68
+ * paths that point into the Windows file system mounted under `/mnt/c`.
69
+ * The returned {@link OSInfo.isWSL} flag is always `true`.
70
+ *
71
+ * @returns An {@link OSInfo} object reflecting the Windows host environment.
72
+ * @throws {Error} If the Windows username cannot be determined from `whoami.exe`.
73
+ */
35
74
  export const wslInfo = () => {
36
75
  const whoamiParts = execSync("whoami.exe").toString().split(sep);
37
76
  if (whoamiParts.length === 0)
@@ -54,7 +93,12 @@ export const wslInfo = () => {
54
93
  isWSL: true,
55
94
  };
56
95
  };
57
- /** @internal test-only */
96
+ /**
97
+ * Resets the cached OS information so the next call to {@link osInfo} recomputes it.
98
+ *
99
+ * @internal
100
+ * This function is intended for testing purposes only.
101
+ */
58
102
  export const __resetOsInfo = () => {
59
103
  __info = null;
60
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"osInfo.common.js","sourceRoot":"","sources":["../../src/osInfo/osInfo.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,IAAI,MAAM,GAAkB,IAAI,CAAC;AAEjC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE;IACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,KAAK,GAAG,EAAE,CAAC,OA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MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAE1D,iEAAiE;IACjE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,IAAI,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,kBAAkB;IAClB,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3C,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxD,MAAM,KAAK,GAAa,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAEtD,OAAO;QACL,QAAQ;QACR,OAAO;QACP,SAAS;QACT,QAAQ;QACR,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { join, sep } from \"node:path\";\nimport { OSInfo } from \"../types/types.os.js\";\nimport * as os from \"node:os\";\nimport { execSync } from \"node:child_process\";\n\nlet __info: OSInfo | null = null;\n\nexport const osInfo = (): OSInfo => {\n if (!__info) {\n const isWSL = os.release().toLowerCase().includes(\"microsoft\");\n __info = isWSL ? wslInfo() : defaultInfo();\n if (!__info) throw new Error(\"Load OS info failed\");\n }\n return __info;\n};\n\nexport const defaultInfo = (): OSInfo => {\n const platform = process.platform;\n const homedir = os.homedir();\n const configDirParts: string[] = [];\n\n if (platform === \"win32\") {\n if (process.env.APPDATA) configDirParts.push(process.env.APPDATA);\n } else if (platform === \"darwin\") {\n configDirParts.push(homedir, \"Library\", \"Application Support\");\n } else {\n configDirParts.push(homedir, \".config\");\n }\n\n return {\n username: os.userInfo().username,\n homedir,\n platform,\n configDir: join(...configDirParts),\n };\n};\n\nexport const wslInfo = (): OSInfo => {\n const whoamiParts = execSync(\"whoami.exe\").toString().split(sep);\n if (whoamiParts.length === 0)\n throw new Error(\"Windows user could not be determined\");\n\n // const winUser = process.env[\"WINUSER\"] || process.env[\"USER\"];\n const platform = process.platform;\n let username = whoamiParts[whoamiParts.length - 1];\n // remove AD group\n const userParts = username.split(\"\\\\\");\n username = userParts[userParts.length - 1];\n username = username.replace(\"\\r\", \"\").replace(\"\\n\", \"\");\n const parts: string[] = [\"/mnt\", \"c\", \"Users\", username];\n const homedir = join(...parts);\n const configDir = join(homedir, \"AppData\", \"Roaming\");\n\n return {\n username,\n homedir,\n configDir,\n platform,\n isWSL: true,\n };\n};\n\n/** @internal test-only */\nexport const __resetOsInfo = () => {\n __info = null;\n};\n"]}
1
+ {"version":3,"file":"osInfo.common.js","sourceRoot":"","sources":["../../src/osInfo/osInfo.common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,IAAI,MAAM,GAAkB,IAAI,CAAC;AAEjC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAW,EAAE;IACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/D,MAAM,GAAG,KAAK,CA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D,iEAAiE;IACjE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,IAAI,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,kBAAkB;IAClB,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC3C,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACxD,MAAM,KAAK,GAAa,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAEtD,OAAO;QACL,QAAQ;QACR,OAAO;QACP,SAAS;QACT,QAAQ;QACR,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { join, sep } from \"node:path\";\nimport { OSInfo } from \"../types/types.os.js\";\nimport * as os from \"node:os\";\nimport { execSync } from \"node:child_process\";\n\nlet __info: OSInfo | null = null;\n\n/**\n * Returns the current operating-system information, creating it on first call.\n *\n * @remarks\n * The result is lazily computed and cached for the lifetime of the process.\n * On WSL environments (detected via the kernel release string) the info is\n * sourced from the Windows host; otherwise the native Node.js APIs are used.\n *\n * @returns The cached {@link OSInfo} for the current environment.\n * @throws {Error} If OS information cannot be determined.\n *\n * @example\n * ```ts\n * const info = osInfo();\n * console.log(info.platform, info.homedir);\n * ```\n */\nexport const osInfo = (): OSInfo => {\n if (!__info) {\n const isWSL = os.release().toLowerCase().includes(\"microsoft\");\n __info = isWSL ? wslInfo() : defaultInfo();\n if (!__info) throw new Error(\"Load OS info failed\");\n }\n return __info;\n};\n\n/**\n * Builds OS information using native Node.js APIs.\n *\n * @remarks\n * Resolves the platform-specific application configuration directory:\n * - **Windows** (`win32`): `%APPDATA%`\n * - **macOS** (`darwin`): `~/Library/Application Support`\n * - **Linux / other**: `~/.config`\n *\n * @returns An {@link OSInfo} object for the current (non-WSL) environment.\n */\nexport const defaultInfo = (): OSInfo => {\n const platform = process.platform;\n const homedir = os.homedir();\n const configDirParts: string[] = [];\n\n if (platform === \"win32\") {\n if (process.env.APPDATA) configDirParts.push(process.env.APPDATA);\n } else if (platform === \"darwin\") {\n configDirParts.push(homedir, \"Library\", \"Application Support\");\n } else {\n configDirParts.push(homedir, \".config\");\n }\n\n return {\n username: os.userInfo().username,\n homedir,\n platform,\n configDir: join(...configDirParts),\n };\n};\n\n/**\n * Builds OS information for a Windows Subsystem for Linux (WSL) environment.\n *\n * @remarks\n * Calls `whoami.exe` to determine the Windows username, then constructs\n * paths that point into the Windows file system mounted under `/mnt/c`.\n * The returned {@link OSInfo.isWSL} flag is always `true`.\n *\n * @returns An {@link OSInfo} object reflecting the Windows host environment.\n * @throws {Error} If the Windows username cannot be determined from `whoami.exe`.\n */\nexport const wslInfo = (): OSInfo => {\n const whoamiParts = execSync(\"whoami.exe\").toString().split(sep);\n if (whoamiParts.length === 0)\n throw new Error(\"Windows user could not be determined\");\n\n // const winUser = process.env[\"WINUSER\"] || process.env[\"USER\"];\n const platform = process.platform;\n let username = whoamiParts[whoamiParts.length - 1];\n // remove AD group\n const userParts = username.split(\"\\\\\");\n username = userParts[userParts.length - 1];\n username = username.replace(\"\\r\", \"\").replace(\"\\n\", \"\");\n const parts: string[] = [\"/mnt\", \"c\", \"Users\", username];\n const homedir = join(...parts);\n const configDir = join(homedir, \"AppData\", \"Roaming\");\n\n return {\n username,\n homedir,\n configDir,\n platform,\n isWSL: true,\n };\n};\n\n/**\n * Resets the cached OS information so the next call to {@link osInfo} recomputes it.\n *\n * @internal\n * This function is intended for testing purposes only.\n */\nexport const __resetOsInfo = () => {\n __info = null;\n};\n"]}
@@ -0,0 +1,44 @@
1
+ import { EntryPoint, ExportExtractorParams, ExportNode, PackageAPI } from "../types/types.exports.js";
2
+ import { PackageJson } from "../types/types.package.js";
3
+ export declare const runExportExtractor: (params: ExportExtractorParams) => Promise<void>;
4
+ export declare class ExportExtractor {
5
+ readonly pkg: string;
6
+ /**
7
+ * Analyze an installed package and produce
8
+ * a structured API representation.
9
+ *
10
+ * @param pkg package name
11
+ */
12
+ constructor(pkg: string);
13
+ /**
14
+ * Analyze an installed package and build its API model.
15
+ */
16
+ run(): Promise<PackageAPI>;
17
+ writeJson(filePath: string, content: PackageAPI): Promise<void>;
18
+ toJson(content: PackageAPI): Promise<string>;
19
+ /**
20
+ * Resolve the root directory of an installed package.
21
+ */
22
+ protected resolvePackageRoot(pkg: string): string;
23
+ /**
24
+ * Resolve entrypoints using the Node exports algorithm.
25
+ */
26
+ protected resolveEntrypoints(pkg: string, pkgJson: PackageJson): EntryPoint[];
27
+ /**
28
+ * Expand wildcard export patterns.
29
+ */
30
+ protected expandWildcardEntrypoints(root: string, entrypoints: EntryPoint[]): Promise<EntryPoint[]>;
31
+ /**
32
+ * Dynamically import a module supporting ESM and CommonJS.
33
+ */
34
+ protected loadModule(id: string): Promise<Record<string, unknown>>;
35
+ /**
36
+ * Extract runtime exports from entrypoints.
37
+ */
38
+ protected inspectRuntimeExports(entrypoints: EntryPoint[]): Promise<ExportNode[]>;
39
+ /**
40
+ * Parse TypeScript declaration files to extract exported types.
41
+ */
42
+ protected parseTypeExports(root: string): Promise<ExportNode[]>;
43
+ }
44
+ //# sourceMappingURL=ExportExtractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportExtractor.d.ts","sourceRoot":"","sources":["../../src/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