@component-compass/cli 0.1.23 → 0.1.25

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 (223) hide show
  1. package/dist/cli.js +103882 -104
  2. package/package.json +21 -25
  3. package/dist/auth/browser.d.ts +0 -13
  4. package/dist/auth/browser.js +0 -21
  5. package/dist/auth/browser.js.map +0 -1
  6. package/dist/auth/client.d.ts +0 -48
  7. package/dist/auth/client.js +0 -89
  8. package/dist/auth/client.js.map +0 -1
  9. package/dist/auth/paths.d.ts +0 -2
  10. package/dist/auth/paths.js +0 -14
  11. package/dist/auth/paths.js.map +0 -1
  12. package/dist/auth/session.d.ts +0 -38
  13. package/dist/auth/session.js +0 -88
  14. package/dist/auth/session.js.map +0 -1
  15. package/dist/auth/store.d.ts +0 -16
  16. package/dist/auth/store.js +0 -37
  17. package/dist/auth/store.js.map +0 -1
  18. package/dist/auth/upload-auth.d.ts +0 -22
  19. package/dist/auth/upload-auth.js +0 -51
  20. package/dist/auth/upload-auth.js.map +0 -1
  21. package/dist/cli/help.d.ts +0 -4
  22. package/dist/cli/help.js +0 -52
  23. package/dist/cli/help.js.map +0 -1
  24. package/dist/cli/parse.d.ts +0 -14
  25. package/dist/cli/parse.js +0 -75
  26. package/dist/cli/parse.js.map +0 -1
  27. package/dist/cli/suggest.d.ts +0 -4
  28. package/dist/cli/suggest.js +0 -38
  29. package/dist/cli/suggest.js.map +0 -1
  30. package/dist/cli.d.ts +0 -2
  31. package/dist/cli.js.map +0 -1
  32. package/dist/commands/auth.d.ts +0 -33
  33. package/dist/commands/auth.js +0 -248
  34. package/dist/commands/auth.js.map +0 -1
  35. package/dist/commands/init.d.ts +0 -11
  36. package/dist/commands/init.js +0 -112
  37. package/dist/commands/init.js.map +0 -1
  38. package/dist/commands/scan.d.ts +0 -33
  39. package/dist/commands/scan.js +0 -691
  40. package/dist/commands/scan.js.map +0 -1
  41. package/dist/composition-rollup.d.ts +0 -23
  42. package/dist/composition-rollup.js +0 -64
  43. package/dist/composition-rollup.js.map +0 -1
  44. package/dist/config/loader.d.ts +0 -6
  45. package/dist/config/loader.js +0 -71
  46. package/dist/config/loader.js.map +0 -1
  47. package/dist/config/schema.d.ts +0 -18
  48. package/dist/config/schema.js +0 -15
  49. package/dist/config/schema.js.map +0 -1
  50. package/dist/dispatcher.d.ts +0 -8
  51. package/dist/dispatcher.js +0 -22
  52. package/dist/dispatcher.js.map +0 -1
  53. package/dist/envelope/git.d.ts +0 -13
  54. package/dist/envelope/git.js +0 -69
  55. package/dist/envelope/git.js.map +0 -1
  56. package/dist/envelope/index.d.ts +0 -1
  57. package/dist/envelope/index.js +0 -12
  58. package/dist/envelope/index.js.map +0 -1
  59. package/dist/envelope/repo-id.d.ts +0 -16
  60. package/dist/envelope/repo-id.js +0 -40
  61. package/dist/envelope/repo-id.js.map +0 -1
  62. package/dist/identity.d.ts +0 -56
  63. package/dist/identity.js +0 -115
  64. package/dist/identity.js.map +0 -1
  65. package/dist/index.d.ts +0 -3
  66. package/dist/index.js +0 -3
  67. package/dist/index.js.map +0 -1
  68. package/dist/local-index/declared-props.d.ts +0 -15
  69. package/dist/local-index/declared-props.js +0 -101
  70. package/dist/local-index/declared-props.js.map +0 -1
  71. package/dist/local-index/detect-react.d.ts +0 -3
  72. package/dist/local-index/detect-react.js +0 -378
  73. package/dist/local-index/detect-react.js.map +0 -1
  74. package/dist/local-index/detect-vue.d.ts +0 -16
  75. package/dist/local-index/detect-vue.js +0 -284
  76. package/dist/local-index/detect-vue.js.map +0 -1
  77. package/dist/local-index/detect-wc.d.ts +0 -8
  78. package/dist/local-index/detect-wc.js +0 -70
  79. package/dist/local-index/detect-wc.js.map +0 -1
  80. package/dist/local-index/index.d.ts +0 -14
  81. package/dist/local-index/index.js +0 -46
  82. package/dist/local-index/index.js.map +0 -1
  83. package/dist/local-index/types.d.ts +0 -2
  84. package/dist/local-index/types.js +0 -2
  85. package/dist/local-index/types.js.map +0 -1
  86. package/dist/manifest/barrel-parser.d.ts +0 -35
  87. package/dist/manifest/barrel-parser.js +0 -76
  88. package/dist/manifest/barrel-parser.js.map +0 -1
  89. package/dist/manifest/lazy-resolver.d.ts +0 -123
  90. package/dist/manifest/lazy-resolver.js +0 -712
  91. package/dist/manifest/lazy-resolver.js.map +0 -1
  92. package/dist/occurrences.d.ts +0 -15
  93. package/dist/occurrences.js +0 -101
  94. package/dist/occurrences.js.map +0 -1
  95. package/dist/parse-by-ext.d.ts +0 -21
  96. package/dist/parse-by-ext.js +0 -53
  97. package/dist/parse-by-ext.js.map +0 -1
  98. package/dist/prompts/adapter.d.ts +0 -43
  99. package/dist/prompts/adapter.js +0 -32
  100. package/dist/prompts/adapter.js.map +0 -1
  101. package/dist/reporter/diagnostic-lines.d.ts +0 -7
  102. package/dist/reporter/diagnostic-lines.js +0 -40
  103. package/dist/reporter/diagnostic-lines.js.map +0 -1
  104. package/dist/reporter/index.d.ts +0 -39
  105. package/dist/reporter/index.js +0 -144
  106. package/dist/reporter/index.js.map +0 -1
  107. package/dist/reporter/json.d.ts +0 -6
  108. package/dist/reporter/json.js +0 -11
  109. package/dist/reporter/json.js.map +0 -1
  110. package/dist/reporter/stdout.d.ts +0 -3
  111. package/dist/reporter/stdout.js +0 -41
  112. package/dist/reporter/stdout.js.map +0 -1
  113. package/dist/rollup.d.ts +0 -26
  114. package/dist/rollup.js +0 -135
  115. package/dist/rollup.js.map +0 -1
  116. package/dist/scan/cem-index.d.ts +0 -38
  117. package/dist/scan/cem-index.js +0 -139
  118. package/dist/scan/cem-index.js.map +0 -1
  119. package/dist/scan/entry-packages.d.ts +0 -42
  120. package/dist/scan/entry-packages.js +0 -87
  121. package/dist/scan/entry-packages.js.map +0 -1
  122. package/dist/scan/framework-root.d.ts +0 -1
  123. package/dist/scan/framework-root.js +0 -22
  124. package/dist/scan/framework-root.js.map +0 -1
  125. package/dist/scan/git-mtime.d.ts +0 -2
  126. package/dist/scan/git-mtime.js +0 -22
  127. package/dist/scan/git-mtime.js.map +0 -1
  128. package/dist/scan/global-components.d.ts +0 -37
  129. package/dist/scan/global-components.js +0 -228
  130. package/dist/scan/global-components.js.map +0 -1
  131. package/dist/scan/meta.d.ts +0 -5
  132. package/dist/scan/meta.js +0 -58
  133. package/dist/scan/meta.js.map +0 -1
  134. package/dist/scan/stamp-version.d.ts +0 -18
  135. package/dist/scan/stamp-version.js +0 -94
  136. package/dist/scan/stamp-version.js.map +0 -1
  137. package/dist/scan/stamp-wraps.d.ts +0 -11
  138. package/dist/scan/stamp-wraps.js +0 -24
  139. package/dist/scan/stamp-wraps.js.map +0 -1
  140. package/dist/scan/wrap-relationships.d.ts +0 -12
  141. package/dist/scan/wrap-relationships.js +0 -38
  142. package/dist/scan/wrap-relationships.js.map +0 -1
  143. package/dist/seeds.d.ts +0 -81
  144. package/dist/seeds.js +0 -258
  145. package/dist/seeds.js.map +0 -1
  146. package/dist/types/brand.d.ts +0 -11
  147. package/dist/types/brand.js +0 -5
  148. package/dist/types/brand.js.map +0 -1
  149. package/dist/types/component-id.d.ts +0 -2
  150. package/dist/types/component-id.js +0 -2
  151. package/dist/types/component-id.js.map +0 -1
  152. package/dist/types.d.ts +0 -13
  153. package/dist/types.js +0 -2
  154. package/dist/types.js.map +0 -1
  155. package/dist/upload.d.ts +0 -18
  156. package/dist/upload.js +0 -34
  157. package/dist/upload.js.map +0 -1
  158. package/dist/util/color.d.ts +0 -24
  159. package/dist/util/color.js +0 -45
  160. package/dist/util/color.js.map +0 -1
  161. package/dist/util/git.d.ts +0 -10
  162. package/dist/util/git.js +0 -95
  163. package/dist/util/git.js.map +0 -1
  164. package/dist/util/interactive.d.ts +0 -17
  165. package/dist/util/interactive.js +0 -19
  166. package/dist/util/interactive.js.map +0 -1
  167. package/dist/util/log.d.ts +0 -9
  168. package/dist/util/log.js +0 -20
  169. package/dist/util/log.js.map +0 -1
  170. package/dist/util/pkg.d.ts +0 -1
  171. package/dist/util/pkg.js +0 -13
  172. package/dist/util/pkg.js.map +0 -1
  173. package/dist/util/pnp-check.d.ts +0 -1
  174. package/dist/util/pnp-check.js +0 -6
  175. package/dist/util/pnp-check.js.map +0 -1
  176. package/dist/util/posix.d.ts +0 -2
  177. package/dist/util/posix.js +0 -15
  178. package/dist/util/posix.js.map +0 -1
  179. package/dist/util/progress.d.ts +0 -21
  180. package/dist/util/progress.js +0 -54
  181. package/dist/util/progress.js.map +0 -1
  182. package/dist/util/version.d.ts +0 -7
  183. package/dist/util/version.js +0 -13
  184. package/dist/util/version.js.map +0 -1
  185. package/dist/walker/bounded-definition-resolver.d.ts +0 -9
  186. package/dist/walker/bounded-definition-resolver.js +0 -125
  187. package/dist/walker/bounded-definition-resolver.js.map +0 -1
  188. package/dist/walker/files.d.ts +0 -7
  189. package/dist/walker/files.js +0 -24
  190. package/dist/walker/files.js.map +0 -1
  191. package/dist/walker/package-alias-layers.d.ts +0 -7
  192. package/dist/walker/package-alias-layers.js +0 -40
  193. package/dist/walker/package-alias-layers.js.map +0 -1
  194. package/dist/walker/resolve-import.d.ts +0 -25
  195. package/dist/walker/resolve-import.js +0 -243
  196. package/dist/walker/resolve-import.js.map +0 -1
  197. package/dist/walker/tsconfig-discovery.d.ts +0 -36
  198. package/dist/walker/tsconfig-discovery.js +0 -52
  199. package/dist/walker/tsconfig-discovery.js.map +0 -1
  200. package/dist/walker/tsconfig-loader.d.ts +0 -35
  201. package/dist/walker/tsconfig-loader.js +0 -138
  202. package/dist/walker/tsconfig-loader.js.map +0 -1
  203. package/dist/walker/workspace-exports.d.ts +0 -3
  204. package/dist/walker/workspace-exports.js +0 -120
  205. package/dist/walker/workspace-exports.js.map +0 -1
  206. package/dist/workspace/build-graph.d.ts +0 -15
  207. package/dist/workspace/build-graph.js +0 -120
  208. package/dist/workspace/build-graph.js.map +0 -1
  209. package/dist/workspace/declared-deps.d.ts +0 -5
  210. package/dist/workspace/declared-deps.js +0 -42
  211. package/dist/workspace/declared-deps.js.map +0 -1
  212. package/dist/workspace/find-owning-package.d.ts +0 -8
  213. package/dist/workspace/find-owning-package.js +0 -69
  214. package/dist/workspace/find-owning-package.js.map +0 -1
  215. package/dist/workspace/find-workspace-root.d.ts +0 -1
  216. package/dist/workspace/find-workspace-root.js +0 -60
  217. package/dist/workspace/find-workspace-root.js.map +0 -1
  218. package/dist/workspace/index.d.ts +0 -4
  219. package/dist/workspace/index.js +0 -4
  220. package/dist/workspace/index.js.map +0 -1
  221. package/dist/workspace/types.d.ts +0 -49
  222. package/dist/workspace/types.js +0 -13
  223. package/dist/workspace/types.js.map +0 -1
@@ -1,243 +0,0 @@
1
- import { realpathSync, statSync } from "node:fs";
2
- import { createRequire } from "node:module";
3
- import { dirname, isAbsolute, resolve as pathResolve } from "node:path";
4
- import { loadTsconfigChain, compileAliasPattern } from "./tsconfig-loader.js";
5
- import { buildWorkspaceExportEntries } from "./workspace-exports.js";
6
- /**
7
- * Module specifier resolver layered on top of Node's module resolution.
8
- *
9
- * Resolution order (first hit wins):
10
- * 1. Config `aliases` (explicit user-supplied alias map).
11
- * 2. The owning workspace package's own tsconfig `paths` layer (when
12
- * `packageAliasLayers` provided and `from` sits inside a member).
13
- * 3. `compilerOptions.paths` from the tsconfig at `tsconfigPath`.
14
- * 4. `package.json#exports` from each workspace package (when `workspaceGraph` provided).
15
- * 5. Node module resolution via `require.resolve`.
16
- *
17
- * Returns the absolute path of the resolved file, or `null` if no layer
18
- * matches.
19
- *
20
- * Resolver instances memoise results by `${dirname(from)}::${spec}`.
21
- * Each uncached call does up to ~25 statSync probes plus require.resolve;
22
- * the walker phase hits the same specifier once per file, and the
23
- * reference-graph engine (via graph.moduleResolver) re-queries the same
24
- * pairs during helper-callers and reference resolution. The key uses
25
- * `dirname(from)` because resolution output depends only on the caller's
26
- * directory: alias/tsconfig targets are resolved against fixed bases, and
27
- * require.resolve's `paths` argument is set from `fromDir` alone.
28
- */
29
- const FILE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".vue"];
30
- /**
31
- * TypeScript ESM spellings. Under `moduleResolution: node16|nodenext`
32
- * a relative specifier names the EMITTED file (`./Leaf.js`) while the source
33
- * on disk is `Leaf.ts`/`Leaf.tsx`. Mirror `tsc`'s mapping — `.js` → `.ts`,
34
- * `.tsx`; `.jsx` → `.tsx` — and probe those twins only after the spelled file
35
- * itself is missing, so a real `.js` on disk still wins.
36
- */
37
- const TS_SOURCE_TWINS = [
38
- [".js", [".ts", ".tsx"]],
39
- [".jsx", [".tsx"]],
40
- ];
41
- function tsSourceSpellings(spec) {
42
- for (const [emitted, sources] of TS_SOURCE_TWINS) {
43
- if (spec.endsWith(emitted)) {
44
- const stem = spec.slice(0, -emitted.length);
45
- return sources.map((ext) => `${stem}${ext}`);
46
- }
47
- }
48
- return [];
49
- }
50
- export function createImportResolver(opts) {
51
- const configEntries = compileAliasMap(opts.aliases, opts.repoRoot);
52
- const tsconfigEntries = loadTsconfigEntries(opts.tsconfigPath, opts.onWarning);
53
- const workspaceExportEntries = opts.workspaceGraph
54
- ? buildWorkspaceExportEntries(opts.workspaceGraph)
55
- : [];
56
- const pkgLayers = opts.packageAliasLayers ?? [];
57
- const fromDirRealCache = new Map();
58
- const ownerEntriesFor = (fromDir) => {
59
- if (pkgLayers.length === 0)
60
- return [];
61
- let real = fromDirRealCache.get(fromDir);
62
- if (real === undefined) {
63
- try {
64
- real = realpathSync(fromDir);
65
- }
66
- catch {
67
- real = fromDir;
68
- }
69
- fromDirRealCache.set(fromDir, real);
70
- }
71
- for (const layer of pkgLayers) {
72
- const withSep = layer.pkgRealPath.endsWith("/") ? layer.pkgRealPath : `${layer.pkgRealPath}/`;
73
- if (real === layer.pkgRealPath || real.startsWith(withSep))
74
- return layer.entries;
75
- }
76
- return [];
77
- };
78
- // Reused for `require.resolve` fallback. Anchoring at <repoRoot>/_ ensures
79
- // Node walks up through <repoRoot>/node_modules and parents.
80
- const requireFromRepo = createRequire(pathResolve(opts.repoRoot, "_"));
81
- const cache = new Map();
82
- return function resolveImport(from, spec) {
83
- // Normalise `from` to absolute — `require.resolve`'s `paths` array
84
- // requires absolute directories. Callers should pass absolute paths:
85
- // resolving a relative `from` against THIS resolver's repoRoot is only
86
- // correct when the caller's anchor happens to coincide with it (the
87
- // reference-graph builder absolutises its graph keys before calling).
88
- const absFrom = isAbsolute(from) ? from : pathResolve(opts.repoRoot, from);
89
- const fromDir = dirname(absFrom);
90
- const cacheKey = `${fromDir}\0${spec}`;
91
- const cached = cache.get(cacheKey);
92
- if (cached !== undefined)
93
- return cached;
94
- const result = resolveUncached(fromDir, spec);
95
- cache.set(cacheKey, result);
96
- return result;
97
- };
98
- function resolveUncached(fromDir, spec) {
99
- for (const layers of [configEntries, ownerEntriesFor(fromDir), tsconfigEntries, workspaceExportEntries]) {
100
- for (const entry of layers) {
101
- const m = entry.pattern.exec(spec);
102
- if (!m)
103
- continue;
104
- const wildcard = m[1] ?? "";
105
- for (const target of entry.targets) {
106
- const expanded = pathResolve(entry.base, target.replace(/\*/g, wildcard));
107
- const hit = tryFileWithExtensions(expanded);
108
- if (hit)
109
- return hit;
110
- }
111
- }
112
- }
113
- // Plain relative/bare resolution via Node. require.resolve doesn't try
114
- // TS/JSX/Vue extensions by default, so probe them on first failure —
115
- // mirrors the alias-branch tryFileWithExtensions behaviour and preserves
116
- // the extensionless-relative-TS-import contract this resolver must honour
117
- // for its consumers.
118
- try {
119
- return requireFromRepo.resolve(spec, { paths: [fromDir, opts.repoRoot] });
120
- }
121
- catch {
122
- // `./Leaf.js` → `./Leaf.tsx` (TypeScript ESM). Before the
123
- // append-an-extension probes: `./Leaf.js.tsx` can never exist.
124
- for (const twin of tsSourceSpellings(spec)) {
125
- try {
126
- return requireFromRepo.resolve(twin, { paths: [fromDir, opts.repoRoot] });
127
- }
128
- catch {
129
- // continue
130
- }
131
- }
132
- for (const ext of FILE_EXTENSIONS) {
133
- try {
134
- return requireFromRepo.resolve(`${spec}${ext}`, { paths: [fromDir, opts.repoRoot] });
135
- }
136
- catch {
137
- // continue
138
- }
139
- }
140
- // Directory-with-index fallback: Node only auto-resolves `index.js`/`.json`/`.node`.
141
- // Consumer codebases use `index.jsx`/`.tsx`/`.vue`/`.ts` too; probe them explicitly so
142
- // `import "./modal"` resolves when `modal/index.jsx` exists. Without this, the structural
143
- // lazy-import detector reports unresolved on a target that does exist on disk.
144
- for (const ext of FILE_EXTENSIONS) {
145
- try {
146
- return requireFromRepo.resolve(`${spec}/index${ext}`, { paths: [fromDir, opts.repoRoot] });
147
- }
148
- catch {
149
- // continue
150
- }
151
- }
152
- // Folder-with-basename: `./avatar` → `./avatar/avatar.{ext}`,
153
- // the Next.js convention. Gated on relative specs because bare-package
154
- // imports have a `main` field and don't use this shape.
155
- if (spec.startsWith(".")) {
156
- const segments = spec.split("/");
157
- const basename = segments[segments.length - 1];
158
- if (basename) {
159
- for (const ext of FILE_EXTENSIONS) {
160
- try {
161
- return requireFromRepo.resolve(`${spec}/${basename}${ext}`, {
162
- paths: [fromDir, opts.repoRoot],
163
- });
164
- }
165
- catch {
166
- // continue
167
- }
168
- }
169
- }
170
- }
171
- return null;
172
- }
173
- }
174
- }
175
- function compileAliasMap(aliases, base) {
176
- if (!aliases)
177
- return [];
178
- const out = [];
179
- for (const [key, targets] of Object.entries(aliases)) {
180
- out.push({ pattern: compileAliasPattern(key), targets, base });
181
- }
182
- return out;
183
- }
184
- function loadTsconfigEntries(tsconfigPath, onWarning) {
185
- if (!tsconfigPath)
186
- return [];
187
- const { entries, warnings } = loadTsconfigChain(tsconfigPath);
188
- if (onWarning)
189
- for (const w of warnings)
190
- onWarning(w);
191
- return entries;
192
- }
193
- /**
194
- * Tries the path as-is, as its TypeScript source twin (`.js` → `.ts`/`.tsx`),
195
- * with each extension, as a directory with `index.{ext}`, and finally as a
196
- * directory with `<basename>.{ext}` (the Next.js folder
197
- * convention also used by some React Native projects: `./avatar` resolves to
198
- * `./avatar/avatar.tsx`). The `isFile` guard rules out false positives — if
199
- * the basename file doesn't exist, we return null.
200
- */
201
- function tryFileWithExtensions(absPath) {
202
- if (!isAbsolute(absPath))
203
- return null;
204
- if (isFile(absPath))
205
- return absPath;
206
- for (const twin of tsSourceSpellings(absPath)) {
207
- if (isFile(twin))
208
- return twin;
209
- }
210
- for (const ext of FILE_EXTENSIONS) {
211
- const withExt = absPath + ext;
212
- if (isFile(withExt))
213
- return withExt;
214
- }
215
- for (const ext of FILE_EXTENSIONS) {
216
- const indexPath = pathResolve(absPath, `index${ext}`);
217
- if (isFile(indexPath))
218
- return indexPath;
219
- }
220
- // Folder-with-basename: `./avatar` → `./avatar/avatar.{ext}`. Node's
221
- // resolver doesn't try this; Next.js layers it on framework-side. Safe to
222
- // probe unconditionally because the file-existence check rejects false
223
- // positives.
224
- const segments = absPath.split(/[\\/]/);
225
- const basename = segments[segments.length - 1];
226
- if (basename) {
227
- for (const ext of FILE_EXTENSIONS) {
228
- const basenamePath = pathResolve(absPath, `${basename}${ext}`);
229
- if (isFile(basenamePath))
230
- return basenamePath;
231
- }
232
- }
233
- return null;
234
- }
235
- function isFile(p) {
236
- try {
237
- return statSync(p).isFile();
238
- }
239
- catch {
240
- return false;
241
- }
242
- }
243
- //# sourceMappingURL=resolve-import.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-import.js","sourceRoot":"","sources":["../../src/walker/resolve-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAmB,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAKrE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MA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,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -1,36 +0,0 @@
1
- export type TsconfigDiscoveryInput = {
2
- /** Directory containing component-compass.config.json. */
3
- configDir: string;
4
- /** Repo root (typically same as configDir, but can differ in nested layouts). */
5
- repoRoot: string;
6
- /**
7
- * Explicit override from cc config. Absolute or relative to configDir.
8
- * Honored unconditionally when present — caller's `createImportResolver`
9
- * returns an empty tsconfig layer if the file is missing/broken, matching
10
- * the same outcome a typo'd path produces.
11
- */
12
- tsconfigPath?: string;
13
- };
14
- /**
15
- * Tsconfig discovery — single source of truth for where the resolver finds
16
- * the consumer's tsconfig. Layered:
17
- *
18
- * 1. Explicit `tsconfigPath` from cc config → use it (absolute or
19
- * configDir-relative).
20
- * 2. `<configDir>/tsconfig.json` if it exists.
21
- * 3. `<configDir>/tsconfig.base.json` if it exists.
22
- * 4. `<repoRoot>/tsconfig.json` if different from configDir and it exists.
23
- * 5. `<repoRoot>/tsconfig.base.json` if different from configDir and it exists.
24
- * 6. null — no tsconfig; tsconfig `paths` layer of `createImportResolver`
25
- * becomes empty.
26
- *
27
- * Discovery returns the leaf path; `loadTsconfigChain` (in tsconfig-loader)
28
- * handles `extends` from there. Deliberately does NOT walk up from configDir
29
- * or repoRoot.
30
- *
31
- * Per-package tsconfigs in monorepos are handled separately by
32
- * `buildPackageAliasLayers` (walker/package-alias-layers.ts), which calls
33
- * this function once per workspace member with configDir = repoRoot = the
34
- * member's own directory.
35
- */
36
- export declare function resolveTsconfigPath(input: TsconfigDiscoveryInput): string | null;
@@ -1,52 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { isAbsolute, resolve, join } from "node:path";
3
- /**
4
- * Tsconfig discovery — single source of truth for where the resolver finds
5
- * the consumer's tsconfig. Layered:
6
- *
7
- * 1. Explicit `tsconfigPath` from cc config → use it (absolute or
8
- * configDir-relative).
9
- * 2. `<configDir>/tsconfig.json` if it exists.
10
- * 3. `<configDir>/tsconfig.base.json` if it exists.
11
- * 4. `<repoRoot>/tsconfig.json` if different from configDir and it exists.
12
- * 5. `<repoRoot>/tsconfig.base.json` if different from configDir and it exists.
13
- * 6. null — no tsconfig; tsconfig `paths` layer of `createImportResolver`
14
- * becomes empty.
15
- *
16
- * Discovery returns the leaf path; `loadTsconfigChain` (in tsconfig-loader)
17
- * handles `extends` from there. Deliberately does NOT walk up from configDir
18
- * or repoRoot.
19
- *
20
- * Per-package tsconfigs in monorepos are handled separately by
21
- * `buildPackageAliasLayers` (walker/package-alias-layers.ts), which calls
22
- * this function once per workspace member with configDir = repoRoot = the
23
- * member's own directory.
24
- */
25
- export function resolveTsconfigPath(input) {
26
- if (input.tsconfigPath) {
27
- return isAbsolute(input.tsconfigPath)
28
- ? input.tsconfigPath
29
- : resolve(input.configDir, input.tsconfigPath);
30
- }
31
- // Probe order at each location: tsconfig.json, then tsconfig.base.json.
32
- // tsconfig.base.json is the de facto monorepo convention (Next.js, Nx,
33
- // Turborepo defaults). When extends chains live in a per-app tsconfig.json
34
- // that points to a root tsconfig.base.json, picking up the .base.json
35
- // directly still resolves the path aliases — the loader treats whatever
36
- // is discovered as the chain's leaf.
37
- const candidates = ["tsconfig.json", "tsconfig.base.json"];
38
- for (const candidate of candidates) {
39
- const configDirCandidate = join(input.configDir, candidate);
40
- if (existsSync(configDirCandidate))
41
- return configDirCandidate;
42
- }
43
- if (input.repoRoot !== input.configDir) {
44
- for (const candidate of candidates) {
45
- const repoRootCandidate = join(input.repoRoot, candidate);
46
- if (existsSync(repoRootCandidate))
47
- return repoRootCandidate;
48
- }
49
- }
50
- return null;
51
- }
52
- //# sourceMappingURL=tsconfig-discovery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsconfig-discovery.js","sourceRoot":"","sources":["../../src/walker/tsconfig-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAgBtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA6B;IAC/D,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;QACvB,OAAO,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC;YACnC,CAAC,CAAC,KAAK,CAAC,YAAY;YACpB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IACnD,CAAC;IACD,wEAAwE;IACxE,uEAAuE;IACvE,2EAA2E;IAC3E,sEAAsE;IACtE,wEAAwE;IACxE,qCAAqC;IACrC,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;IAC3D,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5D,IAAI,UAAU,CAAC,kBAAkB,CAAC;YAAE,OAAO,kBAAkB,CAAC;IAChE,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC1D,IAAI,UAAU,CAAC,iBAAiB,CAAC;gBAAE,OAAO,iBAAiB,CAAC;QAC9D,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,35 +0,0 @@
1
- /** Compiled alias record consumed by `createImportResolver`. */
2
- export type AliasEntry = {
3
- /** Anchored regex matching the specifier; capture group 1 is the wildcard expansion. */
4
- pattern: RegExp;
5
- /** Substitution targets in declaration order. `*` is replaced with the captured wildcard. */
6
- targets: string[];
7
- /** Absolute directory anchoring `targets` (the effective baseUrl of the file that declared `paths`). */
8
- base: string;
9
- };
10
- export type LoadTsconfigChainResult = {
11
- entries: AliasEntry[];
12
- warnings: string[];
13
- };
14
- /**
15
- * Load a tsconfig and its `extends` chain, returning a flat list of alias
16
- * entries ready for `createImportResolver`. Pure: no side effects beyond fs
17
- * reads. Non-fatal failures (missing files, JSONC errors, cycles) are
18
- * appended to `warnings` rather than thrown — callers decide where to emit.
19
- *
20
- * Inheritance semantics match TypeScript:
21
- * - `extends` is string OR array of strings; arrays apply in order, later
22
- * overrides earlier.
23
- * - `compilerOptions.paths`: REPLACE not merge. If the child defines
24
- * `paths`, the child wins entirely; otherwise the parent's flows through.
25
- * - `compilerOptions.baseUrl`: REPLACE. Anchored to the file that defines
26
- * it.
27
- * - Each `AliasEntry.base` pins to the effective baseUrl of the file that
28
- * contributed its `paths` (so the resolver doesn't need to know which
29
- * file produced which entry).
30
- */
31
- export declare function loadTsconfigChain(absPath: string): LoadTsconfigChainResult;
32
- /** Compile a TS-paths-style alias pattern into an anchored RegExp. The single
33
- * `*` wildcard becomes capture group 1, available for substitution into the
34
- * target. Shared between tsconfig-derived and config-derived alias entries. */
35
- export declare function compileAliasPattern(pattern: string): RegExp;
@@ -1,138 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { createRequire } from "node:module";
3
- import { dirname, isAbsolute, resolve as pathResolve } from "node:path";
4
- import { parse as parseJsonc, printParseErrorCode } from "jsonc-parser";
5
- const REGEX_META = /[.+?^${}()|[\]\\]/g;
6
- /**
7
- * Load a tsconfig and its `extends` chain, returning a flat list of alias
8
- * entries ready for `createImportResolver`. Pure: no side effects beyond fs
9
- * reads. Non-fatal failures (missing files, JSONC errors, cycles) are
10
- * appended to `warnings` rather than thrown — callers decide where to emit.
11
- *
12
- * Inheritance semantics match TypeScript:
13
- * - `extends` is string OR array of strings; arrays apply in order, later
14
- * overrides earlier.
15
- * - `compilerOptions.paths`: REPLACE not merge. If the child defines
16
- * `paths`, the child wins entirely; otherwise the parent's flows through.
17
- * - `compilerOptions.baseUrl`: REPLACE. Anchored to the file that defines
18
- * it.
19
- * - Each `AliasEntry.base` pins to the effective baseUrl of the file that
20
- * contributed its `paths` (so the resolver doesn't need to know which
21
- * file produced which entry).
22
- */
23
- export function loadTsconfigChain(absPath) {
24
- const warnings = [];
25
- const seen = new Set();
26
- const merged = loadChainInner(absPath, seen, warnings);
27
- if (!merged || !merged.paths)
28
- return { entries: [], warnings };
29
- const entries = [];
30
- for (const [pattern, targets] of Object.entries(merged.paths)) {
31
- entries.push({
32
- pattern: compileAliasPattern(pattern),
33
- targets,
34
- base: merged.baseDir,
35
- });
36
- }
37
- return { entries, warnings };
38
- }
39
- function loadChainInner(absPath, seen, warnings) {
40
- if (seen.has(absPath)) {
41
- warnings.push(`tsconfig extends cycle at ${absPath}; ignoring this hop`);
42
- return null;
43
- }
44
- seen.add(absPath);
45
- const parsed = readAndParse(absPath, warnings);
46
- if (!parsed)
47
- return null;
48
- // Resolve parents first, then apply this file's overrides on top.
49
- let inherited = null;
50
- if (parsed.extends) {
51
- const parents = Array.isArray(parsed.extends) ? parsed.extends : [parsed.extends];
52
- for (const ext of parents) {
53
- const parentAbs = resolveExtends(absPath, ext, warnings);
54
- if (!parentAbs)
55
- continue;
56
- const parentResult = loadChainInner(parentAbs, seen, warnings);
57
- if (!parentResult)
58
- continue;
59
- inherited = mergeOverride(inherited, parentResult);
60
- }
61
- }
62
- const ownBaseDir = effectiveBaseDir(absPath, parsed);
63
- const own = {
64
- paths: parsed.compilerOptions?.paths,
65
- baseDir: ownBaseDir,
66
- };
67
- return mergeOverride(inherited, own);
68
- }
69
- function readAndParse(absPath, warnings) {
70
- let raw;
71
- try {
72
- raw = readFileSync(absPath, "utf8");
73
- }
74
- catch (err) {
75
- warnings.push(`tsconfig not readable at ${absPath}: ${err.message}`);
76
- return null;
77
- }
78
- const errors = [];
79
- const parsed = parseJsonc(raw, errors, {
80
- allowTrailingComma: true,
81
- disallowComments: false,
82
- });
83
- if (errors.length > 0) {
84
- const messages = errors.map((e) => printParseErrorCode(e.error)).join(", ");
85
- warnings.push(`tsconfig parse errors in ${absPath}: ${messages}`);
86
- if (parsed === undefined)
87
- return null;
88
- }
89
- if (parsed === null || typeof parsed !== "object") {
90
- warnings.push(`tsconfig at ${absPath} did not produce an object`);
91
- return null;
92
- }
93
- return parsed;
94
- }
95
- function resolveExtends(fromAbs, spec, warnings) {
96
- // Relative paths resolve from the importing file's directory. Bare specs
97
- // (e.g. "@tsconfig/node20/tsconfig.json") go through Node module resolution
98
- // anchored at the same location.
99
- const fromDir = dirname(fromAbs);
100
- if (spec.startsWith(".") || isAbsolute(spec)) {
101
- const candidate = isAbsolute(spec) ? spec : pathResolve(fromDir, spec);
102
- // TS conventions: if the path ends without .json, try appending it.
103
- const withExt = candidate.endsWith(".json") ? candidate : `${candidate}.json`;
104
- return withExt;
105
- }
106
- try {
107
- const req = createRequire(fromAbs);
108
- return req.resolve(spec);
109
- }
110
- catch (err) {
111
- warnings.push(`tsconfig extends "${spec}" from ${fromAbs} did not resolve`);
112
- return null;
113
- }
114
- }
115
- function effectiveBaseDir(absPath, parsed) {
116
- const fileDir = dirname(absPath);
117
- const baseUrl = parsed.compilerOptions?.baseUrl;
118
- if (!baseUrl)
119
- return fileDir;
120
- return pathResolve(fileDir, baseUrl);
121
- }
122
- function mergeOverride(parent, child) {
123
- // TS replace semantics: if child has paths, child wins entirely; otherwise
124
- // parent's paths flow through. Each MergedPaths carries the baseDir tied to
125
- // the *paths* it owns.
126
- if (child.paths)
127
- return child;
128
- if (parent?.paths)
129
- return parent;
130
- return child;
131
- }
132
- /** Compile a TS-paths-style alias pattern into an anchored RegExp. The single
133
- * `*` wildcard becomes capture group 1, available for substitution into the
134
- * target. Shared between tsconfig-derived and config-derived alias entries. */
135
- export function compileAliasPattern(pattern) {
136
- return new RegExp(`^${pattern.replace(REGEX_META, "\\$&").replace(/\*/g, "(.*)")}$`);
137
- }
138
- //# sourceMappingURL=tsconfig-loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tsconfig-loader.js","sourceRo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0 @@
1
- import type { AliasEntry } from "./tsconfig-loader.js";
2
- import type { WorkspaceGraph } from "../workspace/types.js";
3
- export declare function buildWorkspaceExportEntries(graph: WorkspaceGraph): AliasEntry[];
@@ -1,120 +0,0 @@
1
- import { compileAliasPattern } from "./tsconfig-loader.js";
2
- // The workspace-member name→source resolution seam. For every member, emit
3
- // resolver entries so any import of the member's name resolves to its source
4
- // on disk — independent of install state (no symlink needed) and winning over
5
- // a version-pinned published copy in node_modules (this layer precedes Node
6
- // resolution). Per member, in precedence order:
7
- //
8
- // 1. Declared `exports` subpaths (existing behaviour):
9
- // - Constant: "./types" -> "./types.ts" matches <pkgName>/types exactly.
10
- // - Pattern: "./icons/<star>" -> "./icons/<star>.tsx".
11
- // Skipped shapes (follow-ups if a real consumer hits them): conditional
12
- // objects, null targets, multi-wildcard targets, non-subpath keys.
13
- // Note: a `null` (deny) subpath is deliberately overridden by the
14
- // wildcard source probe below — this seam attributes usage to source;
15
- // it does not enforce publish-time encapsulation.
16
- // 2. One bare-name entry: <pkgName> -> [exports["."], module, main, ".", "./src"].
17
- // The "." / "./src" directory targets rely on tryFileWithExtensions'
18
- // index probing. Conditional exports["."] contributes its first string
19
- // among import/module/default (one level deep).
20
- // 3. One wildcard fallback: <pkgName>/<star> -> ./<star> (source-tree probe).
21
- //
22
- // Within a package, subpath entries sort by static-prefix length descending so
23
- // more-specific subpaths beat patterns — matches Node's exports specificity
24
- // rule; the bare-name and wildcard entries follow, so declared exports always
25
- // win when their targets exist on disk.
26
- export function buildWorkspaceExportEntries(graph) {
27
- const out = [];
28
- for (const pkg of graph.packages) {
29
- out.push(...subpathExportEntries(pkg));
30
- out.push(bareNameEntry(pkg));
31
- out.push({
32
- pattern: wildcardPattern(pkg.name),
33
- targets: ["./*"],
34
- base: pkg.absolutePath,
35
- });
36
- }
37
- return out;
38
- }
39
- function subpathExportEntries(pkg) {
40
- const exports = pkg.packageJson.exports;
41
- if (exports === null || exports === undefined)
42
- return [];
43
- if (typeof exports !== "object")
44
- return [];
45
- if (Array.isArray(exports))
46
- return [];
47
- const out = [];
48
- const subpaths = Object.entries(exports)
49
- .filter(([key]) => key.startsWith("./") && key !== "./")
50
- .sort(([a], [b]) => staticPrefixLength(b) - staticPrefixLength(a));
51
- for (const [subpath, target] of subpaths) {
52
- if (target === null)
53
- continue;
54
- if (typeof target !== "string")
55
- continue;
56
- if (target.includes("**"))
57
- continue;
58
- if (target.split("*").length > 2)
59
- continue;
60
- // "./icons/*" + "@example/icons" → "@example/icons/icons/*"
61
- const fullPattern = `${pkg.name}${subpath.slice(1)}`;
62
- out.push({
63
- pattern: compileAliasPattern(fullPattern),
64
- targets: [target],
65
- base: pkg.absolutePath,
66
- });
67
- }
68
- return out;
69
- }
70
- function bareNameEntry(pkg) {
71
- const targets = [];
72
- const dot = dotExportTarget(pkg.packageJson.exports);
73
- if (dot !== null)
74
- targets.push(dot);
75
- if (typeof pkg.packageJson.module === "string")
76
- targets.push(pkg.packageJson.module);
77
- if (typeof pkg.packageJson.main === "string")
78
- targets.push(pkg.packageJson.main);
79
- targets.push(".", "./src");
80
- return {
81
- pattern: compileAliasPattern(pkg.name),
82
- targets,
83
- base: pkg.absolutePath,
84
- };
85
- }
86
- // `<pkgName>/*` with `..` path segments rejected, so the source-tree probe
87
- // cannot expand outside the member directory (`@ws/ui/../secret` falls through
88
- // to Node resolution instead). `..` inside a segment name (`a..b`) stays legal.
89
- // Reuses compileAliasPattern for the name's regex escaping; the name itself
90
- // contains no `*`, so the compiled source is the escaped literal.
91
- function wildcardPattern(pkgName) {
92
- const escapedName = compileAliasPattern(pkgName).source.slice(1, -1);
93
- return new RegExp(`^${escapedName}/((?!\\.\\.(?:/|$))(?:(?!/\\.\\.(?:/|$)).)*)$`);
94
- }
95
- // exports["."] as an entry-point target: string form, the bare-string sugar,
96
- // or (one level deep) the first string among import/module/default in a
97
- // conditional object. Anything else → null (bare-name entry falls through to
98
- // module/main/directory probes).
99
- function dotExportTarget(exports) {
100
- if (typeof exports === "string")
101
- return exports;
102
- if (exports === null || typeof exports !== "object" || Array.isArray(exports))
103
- return null;
104
- const dot = exports["."];
105
- if (typeof dot === "string")
106
- return dot;
107
- if (dot !== null && typeof dot === "object" && !Array.isArray(dot)) {
108
- for (const key of ["import", "module", "default"]) {
109
- const value = dot[key];
110
- if (typeof value === "string")
111
- return value;
112
- }
113
- }
114
- return null;
115
- }
116
- function staticPrefixLength(subpath) {
117
- const starIdx = subpath.indexOf("*");
118
- return starIdx === -1 ? subpath.length : starIdx;
119
- }
120
- //# sourceMappingURL=workspace-exports.js.map