@stag-build/phonebook 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +283 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +82 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +33 -0
- package/dist/commands/doctor.js +690 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.js +415 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.js +21 -0
- package/dist/config.js.map +1 -0
- package/dist/engines/android.d.ts +70 -0
- package/dist/engines/android.js +265 -0
- package/dist/engines/android.js.map +1 -0
- package/dist/engines/git.d.ts +4 -0
- package/dist/engines/git.js +13 -0
- package/dist/engines/git.js.map +1 -0
- package/dist/engines/ios.d.ts +55 -0
- package/dist/engines/ios.js +195 -0
- package/dist/engines/ios.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.js +69 -0
- package/dist/errors.js.map +1 -0
- package/dist/gradle/catalog.d.ts +110 -0
- package/dist/gradle/catalog.js +413 -0
- package/dist/gradle/catalog.js.map +1 -0
- package/dist/ios/snapshotTestClass.d.ts +59 -0
- package/dist/ios/snapshotTestClass.js +195 -0
- package/dist/ios/snapshotTestClass.js.map +1 -0
- package/dist/manifest.d.ts +32 -0
- package/dist/manifest.js +23 -0
- package/dist/manifest.js.map +1 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +226 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/naming.d.ts +18 -0
- package/dist/naming.js +34 -0
- package/dist/naming.js.map +1 -0
- package/dist/scan/android.d.ts +7 -0
- package/dist/scan/android.js +222 -0
- package/dist/scan/android.js.map +1 -0
- package/dist/scan/hints.d.ts +25 -0
- package/dist/scan/hints.js +338 -0
- package/dist/scan/hints.js.map +1 -0
- package/dist/scan/ios.d.ts +7 -0
- package/dist/scan/ios.js +201 -0
- package/dist/scan/ios.js.map +1 -0
- package/dist/scan/types.d.ts +52 -0
- package/dist/scan/types.js +7 -0
- package/dist/scan/types.js.map +1 -0
- package/dist/site/build.d.ts +17 -0
- package/dist/site/build.js +0 -0
- package/dist/site/build.js.map +1 -0
- package/dist/versions.d.ts +71 -0
- package/dist/versions.js +334 -0
- package/dist/versions.js.map +1 -0
- package/package.json +54 -0
package/dist/scan/ios.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { join, relative } from 'node:path';
|
|
3
|
+
import { previewHints } from './hints.js';
|
|
4
|
+
/**
|
|
5
|
+
* Regex-based heuristic scanner for SwiftUI `View` structs and `#Preview`
|
|
6
|
+
* macros (plus legacy `PreviewProvider` structs). Walks the project tree and
|
|
7
|
+
* matches previews to components by file + name heuristics.
|
|
8
|
+
*/
|
|
9
|
+
export async function scanIos(projectDir) {
|
|
10
|
+
const components = [];
|
|
11
|
+
const orphanPreviews = [];
|
|
12
|
+
const files = await walkSwiftFiles(projectDir);
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
const relFile = relative(projectDir, file);
|
|
15
|
+
const content = await readFile(file, 'utf8');
|
|
16
|
+
const fileComponents = findViewStructs(content, relFile);
|
|
17
|
+
const filePreviews = findPreviews(content, relFile);
|
|
18
|
+
for (const comp of fileComponents)
|
|
19
|
+
components.push(comp);
|
|
20
|
+
matchPreviewsToComponents(filePreviews, fileComponents, orphanPreviews);
|
|
21
|
+
}
|
|
22
|
+
components.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
23
|
+
orphanPreviews.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line);
|
|
24
|
+
return {
|
|
25
|
+
platform: 'ios',
|
|
26
|
+
components,
|
|
27
|
+
orphanPreviews,
|
|
28
|
+
stats: computeStats(components, orphanPreviews),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function findViewStructs(content, relFile) {
|
|
32
|
+
const results = [];
|
|
33
|
+
const regex = /(?:struct|final class)\s+([A-Z]\w*)\s*:\s*[^{]*\bView\b/g;
|
|
34
|
+
let match;
|
|
35
|
+
while ((match = regex.exec(content)) !== null) {
|
|
36
|
+
results.push({
|
|
37
|
+
name: match[1],
|
|
38
|
+
file: relFile,
|
|
39
|
+
line: lineNumberAt(content, match.index),
|
|
40
|
+
previews: [],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
function findPreviews(content, relFile) {
|
|
46
|
+
const results = [];
|
|
47
|
+
// #Preview("Name", traits: ...) { ... }
|
|
48
|
+
const previewRegex = /#Preview\s*(\(([^)]*)\))?/g;
|
|
49
|
+
let match;
|
|
50
|
+
while ((match = previewRegex.exec(content)) !== null) {
|
|
51
|
+
const argsText = match[2] ?? '';
|
|
52
|
+
const nameMatch = argsText.match(/"([^"]*)"/);
|
|
53
|
+
const displayName = nameMatch ? nameMatch[1] : undefined;
|
|
54
|
+
const line = lineNumberAt(content, match.index);
|
|
55
|
+
const dark = isDarkPreview(content, match.index, displayName);
|
|
56
|
+
const annotationText = extractAnnotationText(content, match.index);
|
|
57
|
+
const functionName = displayName ?? 'unnamed';
|
|
58
|
+
const hints = previewHints({
|
|
59
|
+
platform: 'ios',
|
|
60
|
+
functionName,
|
|
61
|
+
displayName,
|
|
62
|
+
annotationText,
|
|
63
|
+
});
|
|
64
|
+
results.push({
|
|
65
|
+
name: functionName,
|
|
66
|
+
...(displayName !== undefined ? { displayName } : {}),
|
|
67
|
+
file: relFile,
|
|
68
|
+
line,
|
|
69
|
+
dark,
|
|
70
|
+
annotationText,
|
|
71
|
+
...(hints.length > 0 ? { hints } : {}),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Legacy: struct X_Previews: PreviewProvider
|
|
75
|
+
const legacyRegex = /struct\s+(\w+)_Previews\s*:\s*PreviewProvider/g;
|
|
76
|
+
while ((match = legacyRegex.exec(content)) !== null) {
|
|
77
|
+
results.push({
|
|
78
|
+
name: `${match[1]}_Previews`,
|
|
79
|
+
file: relFile,
|
|
80
|
+
line: lineNumberAt(content, match.index),
|
|
81
|
+
dark: false,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
/** True when the ~10 lines following a #Preview declaration set a dark color scheme. */
|
|
87
|
+
function isDarkPreview(content, matchIndex, displayName) {
|
|
88
|
+
if (displayName && displayName.endsWith('Dark'))
|
|
89
|
+
return true;
|
|
90
|
+
const rest = content.slice(matchIndex);
|
|
91
|
+
const restLines = rest.split('\n');
|
|
92
|
+
// Stop at the next #Preview / preview-provider struct so we don't bleed into it.
|
|
93
|
+
const boundary = restLines.findIndex((l, i) => i > 0 && (/#Preview\b/.test(l) || /:\s*PreviewProvider\b/.test(l)));
|
|
94
|
+
const window = boundary === -1 ? restLines.slice(0, 11) : restLines.slice(0, Math.min(11, boundary));
|
|
95
|
+
return /\.preferredColorScheme\(\s*\.dark\s*\)/.test(window.join('\n'));
|
|
96
|
+
}
|
|
97
|
+
/** The #Preview(...) line plus the following lines of its body, up to the next
|
|
98
|
+
* #Preview/PreviewProvider or ~15 lines, whichever comes first. */
|
|
99
|
+
function extractAnnotationText(content, matchIndex) {
|
|
100
|
+
const rest = content.slice(matchIndex);
|
|
101
|
+
const restLines = rest.split('\n');
|
|
102
|
+
const boundary = restLines.findIndex((l, i) => i > 0 && (/#Preview\b/.test(l) || /:\s*PreviewProvider\b/.test(l)));
|
|
103
|
+
const cap = 15;
|
|
104
|
+
const limit = boundary === -1 ? cap : Math.min(cap, boundary);
|
|
105
|
+
return restLines.slice(0, limit).join('\n');
|
|
106
|
+
}
|
|
107
|
+
function lineNumberAt(content, index) {
|
|
108
|
+
let line = 1;
|
|
109
|
+
for (let i = 0; i < index; i++) {
|
|
110
|
+
if (content[i] === '\n')
|
|
111
|
+
line++;
|
|
112
|
+
}
|
|
113
|
+
return line;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Matches previews to components within the same file:
|
|
117
|
+
* 1. A "Component/State" display name matches a component by name
|
|
118
|
+
* (case/space-insensitive).
|
|
119
|
+
* 2. A legacy `X_Previews` preview matches component `X` directly.
|
|
120
|
+
* 3. Otherwise: the single component in the file if there is exactly one,
|
|
121
|
+
* else the nearest component declared above the preview, else orphan.
|
|
122
|
+
*/
|
|
123
|
+
function matchPreviewsToComponents(previews, components, orphanPreviews) {
|
|
124
|
+
for (const preview of previews) {
|
|
125
|
+
let target;
|
|
126
|
+
const legacyMatch = preview.name.match(/^(\w+)_Previews$/);
|
|
127
|
+
if (legacyMatch) {
|
|
128
|
+
target = components.find((c) => c.name === legacyMatch[1]);
|
|
129
|
+
}
|
|
130
|
+
if (!target && preview.displayName?.includes('/')) {
|
|
131
|
+
const componentPart = preview.displayName.slice(0, preview.displayName.indexOf('/'));
|
|
132
|
+
target = components.find((c) => normalize(c.name) === normalize(componentPart));
|
|
133
|
+
}
|
|
134
|
+
if (!target) {
|
|
135
|
+
if (components.length === 1) {
|
|
136
|
+
target = components[0];
|
|
137
|
+
}
|
|
138
|
+
else if (components.length > 1) {
|
|
139
|
+
// Nearest component declared above the preview.
|
|
140
|
+
const above = components.filter((c) => c.line <= preview.line);
|
|
141
|
+
if (above.length > 0) {
|
|
142
|
+
target = above.reduce((a, b) => (b.line > a.line ? b : a));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (target) {
|
|
147
|
+
target.previews.push(preview);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
orphanPreviews.push(preview);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function normalize(name) {
|
|
155
|
+
return name.replace(/\s+/g, '').toLowerCase();
|
|
156
|
+
}
|
|
157
|
+
function computeStats(components, orphanPreviews) {
|
|
158
|
+
const withPreview = components.filter((c) => c.previews.length > 0).length;
|
|
159
|
+
const withDarkPreview = components.filter((c) => c.previews.some((p) => p.dark)).length;
|
|
160
|
+
const totalPreviews = components.reduce((sum, c) => sum + c.previews.length, 0) + orphanPreviews.length;
|
|
161
|
+
const allPreviews = [...components.flatMap((c) => c.previews), ...orphanPreviews];
|
|
162
|
+
const hintCount = allPreviews.reduce((sum, p) => sum + (p.hints?.length ?? 0), 0);
|
|
163
|
+
// Unlike Android's @Preview (which annotates the composable itself), #Preview is
|
|
164
|
+
// always a separate top-level block, so a SwiftUI View struct can't be its own
|
|
165
|
+
// preview. No self-preview pattern exists here.
|
|
166
|
+
return {
|
|
167
|
+
components: components.length,
|
|
168
|
+
withPreview,
|
|
169
|
+
withDarkPreview,
|
|
170
|
+
totalPreviews,
|
|
171
|
+
hintCount,
|
|
172
|
+
selfPreviewed: 0,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const SKIP_DIRS = new Set(['build', '.build', 'DerivedData', 'Pods']);
|
|
176
|
+
async function walkSwiftFiles(dir) {
|
|
177
|
+
const results = [];
|
|
178
|
+
let entries;
|
|
179
|
+
try {
|
|
180
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return results;
|
|
184
|
+
}
|
|
185
|
+
for (const entry of entries) {
|
|
186
|
+
if (entry.isDirectory()) {
|
|
187
|
+
if (SKIP_DIRS.has(entry.name))
|
|
188
|
+
continue;
|
|
189
|
+
if (entry.name.endsWith('.xcodeproj'))
|
|
190
|
+
continue;
|
|
191
|
+
if (entry.name.includes('Test'))
|
|
192
|
+
continue;
|
|
193
|
+
results.push(...(await walkSwiftFiles(join(dir, entry.name))));
|
|
194
|
+
}
|
|
195
|
+
else if (entry.isFile() && entry.name.endsWith('.swift')) {
|
|
196
|
+
results.push(join(dir, entry.name));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return results;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=ios.js.map
|
|
@@ -0,0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AAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;gBAAE,SAAS;YACxC,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAAE,SAAS;YAChD,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAAE,SAAS;YAC1C,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage scanning: heuristic, regex-based discovery of UI components and the
|
|
3
|
+
* previews that cover them. Used by the MCP `analyze_coverage` tool so an agent
|
|
4
|
+
* can find components with missing previews/states and add them as code.
|
|
5
|
+
*/
|
|
6
|
+
import type { PreviewHint } from './hints.js';
|
|
7
|
+
export type { PreviewHint };
|
|
8
|
+
export interface ScannedPreview {
|
|
9
|
+
/** Preview function name (Android) or #Preview display name / "unnamed" (iOS) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Display name from @Preview(name=...) / #Preview("...") when present */
|
|
12
|
+
displayName?: string;
|
|
13
|
+
file: string;
|
|
14
|
+
line: number;
|
|
15
|
+
/** True when the preview declares a dark configuration (uiMode NIGHT / .dark) */
|
|
16
|
+
dark: boolean;
|
|
17
|
+
/** Raw annotation/macro text as written in source (Android: @Preview(...) annotations
|
|
18
|
+
* joined; iOS: the #Preview(...) line plus the following lines of its body, capped). */
|
|
19
|
+
annotationText?: string;
|
|
20
|
+
/** Text of the preview function's body (from the opening brace, capped to ~20 lines).
|
|
21
|
+
* Lets hints inspect what the composable actually does, e.g. a fixed-size Modifier
|
|
22
|
+
* that can't substitute for an annotation-level canvas size. */
|
|
23
|
+
bodyText?: string;
|
|
24
|
+
/** Configuration hints: cases where the preview's name implies a trait its
|
|
25
|
+
* annotation doesn't declare. See src/scan/hints.ts. */
|
|
26
|
+
hints?: PreviewHint[];
|
|
27
|
+
}
|
|
28
|
+
export interface ScannedComponent {
|
|
29
|
+
/** Composable function name (Android) or View struct name (iOS) */
|
|
30
|
+
name: string;
|
|
31
|
+
file: string;
|
|
32
|
+
line: number;
|
|
33
|
+
/** Previews matched to this component (same file + name-prefix heuristic) */
|
|
34
|
+
previews: ScannedPreview[];
|
|
35
|
+
}
|
|
36
|
+
export interface CoverageReport {
|
|
37
|
+
platform: 'android' | 'ios';
|
|
38
|
+
components: ScannedComponent[];
|
|
39
|
+
/** Previews that could not be matched to any discovered component */
|
|
40
|
+
orphanPreviews: ScannedPreview[];
|
|
41
|
+
/** Totals for a quick summary */
|
|
42
|
+
stats: {
|
|
43
|
+
components: number;
|
|
44
|
+
withPreview: number;
|
|
45
|
+
withDarkPreview: number;
|
|
46
|
+
totalPreviews: number;
|
|
47
|
+
hintCount: number;
|
|
48
|
+
/** Components whose only preview is themselves (the @Preview-on-the-composable
|
|
49
|
+
* pattern for screen-level composables with default parameters). */
|
|
50
|
+
selfPreviewed: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage scanning: heuristic, regex-based discovery of UI components and the
|
|
3
|
+
* previews that cover them. Used by the MCP `analyze_coverage` tool so an agent
|
|
4
|
+
* can find components with missing previews/states and add them as code.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/scan/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a static, self-contained gallery site from a phonebook bundle.
|
|
3
|
+
*
|
|
4
|
+
* Reads `<bundleDir>/manifest.json` and writes `<outDir>/index.html`.
|
|
5
|
+
*
|
|
6
|
+
* By default (or when `options.inPlace` is set), the site is written directly
|
|
7
|
+
* into the bundle directory, reusing the images already there under
|
|
8
|
+
* `images/` — nothing is copied. Pass `options.inPlace: false` (which is
|
|
9
|
+
* implied automatically whenever `outDir` differs from `bundleDir`) to copy
|
|
10
|
+
* `<bundleDir>/images` into `<outDir>/images` instead, producing a standalone
|
|
11
|
+
* site directory independent of the bundle.
|
|
12
|
+
*
|
|
13
|
+
* Returns the number of screenshot entries in the manifest.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildSite(bundleDir: string, outDir: string, options?: {
|
|
16
|
+
inPlace?: boolean;
|
|
17
|
+
}): Promise<number>;
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/site/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAqC,MAAM,gBAAgB,CAAC;AAErF,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO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,CAAC,CAAC;IAEnD,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC1C,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,MAAM,GAAG,yBAAyB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1C,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAE1D,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export interface KotlinVersion {
|
|
2
|
+
major: number;
|
|
3
|
+
minor: number;
|
|
4
|
+
patch: number;
|
|
5
|
+
}
|
|
6
|
+
/** Parses a "X.Y[.Z]" version string. */
|
|
7
|
+
export declare function parseKotlinVersion(s: string): KotlinVersion | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Detects the project's Kotlin (compiler) version by searching, in order:
|
|
10
|
+
* gradle/libs.versions.toml, root build.gradle.kts/build.gradle, and
|
|
11
|
+
* settings.gradle.kts/settings.gradle (pluginManagement plugins block).
|
|
12
|
+
* Returns the first hit, with `source` set to the file it came from
|
|
13
|
+
* (relative to `projectDir`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectKotlinVersion(projectDir: string): Promise<{
|
|
16
|
+
version: KotlinVersion;
|
|
17
|
+
source: string;
|
|
18
|
+
} | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a Kotlin compiler `K.M.*` can read metadata written by a compiler
|
|
21
|
+
* whose binary metadata version is `(a, b[, c])`: (a, b) <= (K, M+1).
|
|
22
|
+
* Special case: metadata (1, 9, 9999) means "pinned to language version 1.9"
|
|
23
|
+
* and is readable by any compiler >= 1.9.
|
|
24
|
+
*/
|
|
25
|
+
export declare function canRead(compiler: {
|
|
26
|
+
major: number;
|
|
27
|
+
minor: number;
|
|
28
|
+
}, metadata: [number, number, number?]): boolean;
|
|
29
|
+
/** Finds and decompresses a single zip entry whose name satisfies `matches`. */
|
|
30
|
+
export declare function readZipEntry(buf: Buffer, matches: (name: string) => boolean): Buffer | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Fetches an artifact's real Kotlin metadata version straight from its
|
|
33
|
+
* bytecode (not its POM, which can lie): tries the .aar first (containing
|
|
34
|
+
* classes.jar), falling back to a plain .jar on 404.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fetchKotlinMetadataVersion(group: string, artifact: string, version: string): Promise<[number, number, number] | undefined>;
|
|
37
|
+
/** Lists released (non-alpha/rc) versions of a Maven artifact, oldest first. */
|
|
38
|
+
export declare function listMavenVersions(group: string, artifact: string): Promise<string[]>;
|
|
39
|
+
interface FallbackRange {
|
|
40
|
+
/** Inclusive [low, high] version range this metadata applies to. */
|
|
41
|
+
range: [string, string];
|
|
42
|
+
metadata: [number, number, number];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Known Kotlin-metadata ranges, probed empirically on 2026-08-22 by fetching
|
|
46
|
+
* each artifact's real bytecode (its POM understates Kotlin requirements).
|
|
47
|
+
* Used to skip network probes in resolveMaxCompatible, and as a last resort
|
|
48
|
+
* when the network is unavailable.
|
|
49
|
+
*/
|
|
50
|
+
export declare const FALLBACK: Record<string, FallbackRange[]>;
|
|
51
|
+
/** Looks up an artifact version's Kotlin metadata in the FALLBACK table, if known. */
|
|
52
|
+
export declare function lookupFallbackMetadata(group: string, artifact: string, version: string): [number, number, number] | undefined;
|
|
53
|
+
export interface ResolveResult {
|
|
54
|
+
/** Highest version compatible with the detected Kotlin compiler, if any. */
|
|
55
|
+
best?: string;
|
|
56
|
+
/** Newest released version, regardless of compatibility. */
|
|
57
|
+
latest?: string;
|
|
58
|
+
/** Minimum Kotlin compiler ("major.minor") the `latest` version needs. */
|
|
59
|
+
latestNeedsKotlin?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Finds the newest version of `group:artifact` compatible with `kotlin`, by
|
|
63
|
+
* walking released versions from newest to oldest (capped at 15 network
|
|
64
|
+
* probes) checking real Kotlin metadata, seeded by FALLBACK to skip probing
|
|
65
|
+
* known ranges.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveMaxCompatible(group: string, artifact: string, kotlin: {
|
|
68
|
+
major: number;
|
|
69
|
+
minor: number;
|
|
70
|
+
}): Promise<ResolveResult>;
|
|
71
|
+
export {};
|