kerfjs 5.0.0-beta.13 → 5.0.0-beta.130
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/CHANGELOG.md +3370 -108
- package/README.md +101 -37
- package/ai/cursorrules +127 -68
- package/ai/manifest.json +36 -7
- package/ai/skill.md +167 -86
- package/ai/ui-skill.md +18 -0
- package/dist/actions.d.ts +1 -1
- package/dist/actions.js +10 -6
- package/dist/actions.js.map +1 -1
- package/dist/array-signal.js +1 -1
- package/dist/async.d.ts +7 -3
- package/dist/async.js +39 -22
- package/dist/async.js.map +1 -1
- package/dist/attach.js +1 -66
- package/dist/attach.js.map +1 -1
- package/dist/{chunk-GY4XV2UV.js → chunk-4TX6YJDM.js} +10 -3
- package/dist/chunk-4TX6YJDM.js.map +1 -0
- package/dist/{chunk-SVATPF5R.js → chunk-5QDM6HPD.js} +637 -277
- package/dist/chunk-5QDM6HPD.js.map +1 -0
- package/dist/{chunk-QIP723L4.js → chunk-5WRGJZV6.js} +3 -2
- package/dist/chunk-5WRGJZV6.js.map +1 -0
- package/dist/chunk-AP2FT33F.js +87 -0
- package/dist/chunk-AP2FT33F.js.map +1 -0
- package/dist/chunk-BTOKH5FA.js +70 -0
- package/dist/chunk-BTOKH5FA.js.map +1 -0
- package/dist/{chunk-ZDCJZCNO.js → chunk-GGADRIQO.js} +168 -97
- package/dist/chunk-GGADRIQO.js.map +1 -0
- package/dist/chunk-KOEGJCIS.js +65 -0
- package/dist/chunk-KOEGJCIS.js.map +1 -0
- package/dist/{chunk-HW7KSM2Y.js → chunk-KUHXPPJ4.js} +1 -1
- package/dist/chunk-KUHXPPJ4.js.map +1 -0
- package/dist/{chunk-UZJ6I4T6.js → chunk-MK42GLPV.js} +1 -1
- package/dist/chunk-MK42GLPV.js.map +1 -0
- package/dist/chunk-N4VHHOCM.js +27 -0
- package/dist/chunk-N4VHHOCM.js.map +1 -0
- package/dist/{chunk-V46JKE44.js → chunk-NRPLVJVR.js} +43 -14
- package/dist/chunk-NRPLVJVR.js.map +1 -0
- package/dist/{chunk-LVH3GC6B.js → chunk-QOAB2ESQ.js} +3 -3
- package/dist/chunk-QOAB2ESQ.js.map +1 -0
- package/dist/{chunk-KZJXHFIB.js → chunk-V322Z7FX.js} +5 -5
- package/dist/chunk-V322Z7FX.js.map +1 -0
- package/dist/{delegate-CL9VTZFb.d.ts → delegate--CrfgYtC.d.ts} +0 -34
- package/dist/dev.d.ts +46 -15
- package/dist/dev.js +185 -40
- package/dist/dev.js.map +1 -1
- package/dist/html.js +20 -8
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +98 -13
- package/dist/index.js +49 -21
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime.d.ts +25 -10
- package/dist/jsx-runtime.js +1 -1
- package/dist/list.d.ts +7 -3
- package/dist/list.js +236 -78
- package/dist/list.js.map +1 -1
- package/dist/overlay.d.ts +287 -142
- package/dist/overlay.js +1039 -369
- package/dist/overlay.js.map +1 -1
- package/dist/remount.js +2 -2
- package/dist/remount.js.map +1 -1
- package/dist/router.d.ts +22 -6
- package/dist/router.js +58 -19
- package/dist/router.js.map +1 -1
- package/dist/scope.d.ts +45 -8
- package/dist/scope.js +69 -30
- package/dist/scope.js.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/timing.d.ts +17 -7
- package/dist/timing.js +8 -3
- package/dist/timing.js.map +1 -1
- package/llms.txt +17 -6
- package/package.json +48 -12
- package/setup/apply.mjs +202 -0
- package/setup/cli.mjs +95 -0
- package/setup/common.mjs +77 -0
- package/setup/detect.mjs +274 -0
- package/setup/index.d.mts +39 -0
- package/setup/index.mjs +1226 -0
- package/setup/jsonc.mjs +201 -0
- package/setup/state.schema.json +57 -0
- package/setup/ui-baseline.mjs +210 -0
- package/dist/chunk-GY4XV2UV.js.map +0 -1
- package/dist/chunk-HW7KSM2Y.js.map +0 -1
- package/dist/chunk-KPXIOG2C.js +0 -54
- package/dist/chunk-KPXIOG2C.js.map +0 -1
- package/dist/chunk-KZJXHFIB.js.map +0 -1
- package/dist/chunk-LVH3GC6B.js.map +0 -1
- package/dist/chunk-QIP723L4.js.map +0 -1
- package/dist/chunk-SVATPF5R.js.map +0 -1
- package/dist/chunk-U6FK33SG.js +0 -20
- package/dist/chunk-U6FK33SG.js.map +0 -1
- package/dist/chunk-UZJ6I4T6.js.map +0 -1
- package/dist/chunk-V46JKE44.js.map +0 -1
- package/dist/chunk-ZDCJZCNO.js.map +0 -1
package/setup/common.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { access, readFile } from 'node:fs/promises';
|
|
3
|
+
import { isAbsolute, relative } from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
|
|
6
|
+
export const exists = async (path) => {
|
|
7
|
+
try {
|
|
8
|
+
await access(path);
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const portable = (root, path) =>
|
|
16
|
+
relative(root, path).replaceAll('\\', '/') || '.';
|
|
17
|
+
export const shellArg = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
18
|
+
export const contained = (root, path) => {
|
|
19
|
+
const offset = relative(root, path);
|
|
20
|
+
return (
|
|
21
|
+
offset === '' ||
|
|
22
|
+
(!offset.startsWith(`..${process.platform === 'win32' ? '\\' : '/'}`) &&
|
|
23
|
+
offset !== '..' &&
|
|
24
|
+
!isAbsolute(offset))
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
export const stableJson = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
28
|
+
export const sha256 = (value) =>
|
|
29
|
+
createHash('sha256').update(value, 'utf8').digest('hex');
|
|
30
|
+
export const redactText = (value) =>
|
|
31
|
+
String(value).replace(
|
|
32
|
+
/([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+(?::[^\s/@]*)?@/gi,
|
|
33
|
+
'$1<redacted>@',
|
|
34
|
+
);
|
|
35
|
+
export const describeValue = (key, value) =>
|
|
36
|
+
/token|secret|password|credential/i.test(key)
|
|
37
|
+
? '<redacted>'
|
|
38
|
+
: redactText(JSON.stringify(value));
|
|
39
|
+
|
|
40
|
+
/** A file's text, or null when it does not exist; other read errors propagate. */
|
|
41
|
+
export async function readText(path) {
|
|
42
|
+
try {
|
|
43
|
+
return await readFile(path, 'utf8');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (error?.code === 'ENOENT') return null;
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parses a file's JSON text (null stays null). Malformed JSON names the file,
|
|
52
|
+
* relative to `root` when given: `<path> is invalid JSON: …`.
|
|
53
|
+
*/
|
|
54
|
+
export function parseJsonFile(source, path, root) {
|
|
55
|
+
if (source === null) return null;
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(source);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`${root ? portable(root, path) : path} is invalid JSON: ${error.message}`,
|
|
61
|
+
{ cause: error },
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A file's parsed JSON, or null when it does not exist. */
|
|
67
|
+
export async function readJson(path, root) {
|
|
68
|
+
return parseJsonFile(await readText(path), path, root);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function dependencies(manifest) {
|
|
72
|
+
return {
|
|
73
|
+
...(manifest.dependencies ?? {}),
|
|
74
|
+
...(manifest.devDependencies ?? {}),
|
|
75
|
+
...(manifest.peerDependencies ?? {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
package/setup/detect.mjs
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { readdir, realpath } from 'node:fs/promises';
|
|
2
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { braceExpand, minimatch } from 'minimatch';
|
|
5
|
+
import { parse as parseYaml } from 'yaml';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
contained,
|
|
9
|
+
dependencies,
|
|
10
|
+
exists,
|
|
11
|
+
portable,
|
|
12
|
+
readJson,
|
|
13
|
+
readText,
|
|
14
|
+
} from './common.mjs';
|
|
15
|
+
|
|
16
|
+
function validatedWorkspacePattern(pattern) {
|
|
17
|
+
if (typeof pattern !== 'string' || pattern !== pattern.trim() || !pattern)
|
|
18
|
+
throw new Error(`Unsafe workspace pattern ${String(pattern)}.`);
|
|
19
|
+
const negated = pattern.startsWith('!');
|
|
20
|
+
const body = negated ? pattern.slice(1) : pattern;
|
|
21
|
+
if (
|
|
22
|
+
!body ||
|
|
23
|
+
body.startsWith('!') ||
|
|
24
|
+
isAbsolute(body) ||
|
|
25
|
+
/^[A-Za-z]:/.test(body) ||
|
|
26
|
+
body.startsWith('//') ||
|
|
27
|
+
body.includes('\\') ||
|
|
28
|
+
body.includes('\0')
|
|
29
|
+
)
|
|
30
|
+
throw new Error(`Unsafe workspace pattern ${pattern}.`);
|
|
31
|
+
let expansions;
|
|
32
|
+
try {
|
|
33
|
+
expansions = braceExpand(body);
|
|
34
|
+
// Compile as well as expand so malformed extglobs/classes fail here.
|
|
35
|
+
minimatch('', body, { nonegate: true });
|
|
36
|
+
} catch {
|
|
37
|
+
throw new Error(`Invalid workspace pattern ${pattern}.`);
|
|
38
|
+
}
|
|
39
|
+
if (
|
|
40
|
+
!expansions.length ||
|
|
41
|
+
expansions.some(
|
|
42
|
+
(expanded) =>
|
|
43
|
+
isAbsolute(expanded) ||
|
|
44
|
+
expanded.split('/').some((segment) => segment === '..'),
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
throw new Error(`Unsafe workspace pattern ${pattern}.`);
|
|
48
|
+
return { body, negated };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function pnpmWorkspacePatterns(root) {
|
|
52
|
+
const source = await readText(resolve(root, 'pnpm-workspace.yaml'));
|
|
53
|
+
if (source === null) return [];
|
|
54
|
+
let document;
|
|
55
|
+
try {
|
|
56
|
+
document = parseYaml(source);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new Error(`pnpm-workspace.yaml is invalid: ${error.message}`, {
|
|
59
|
+
cause: error,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (
|
|
63
|
+
!document ||
|
|
64
|
+
typeof document !== 'object' ||
|
|
65
|
+
!Array.isArray(document.packages) ||
|
|
66
|
+
document.packages.some((pattern) => typeof pattern !== 'string')
|
|
67
|
+
)
|
|
68
|
+
throw new Error(
|
|
69
|
+
'pnpm-workspace.yaml packages must be an array of strings.',
|
|
70
|
+
);
|
|
71
|
+
return [...document.packages];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function workspacePackages(root) {
|
|
75
|
+
const rootManifest = await readJson(resolve(root, 'package.json'), root);
|
|
76
|
+
if (!rootManifest) throw new Error(`${root} has no package.json.`);
|
|
77
|
+
let manifestPatterns = [];
|
|
78
|
+
if (rootManifest.workspaces !== undefined) {
|
|
79
|
+
const declaredPatterns = Array.isArray(rootManifest.workspaces)
|
|
80
|
+
? rootManifest.workspaces
|
|
81
|
+
: rootManifest.workspaces?.packages;
|
|
82
|
+
if (!Array.isArray(declaredPatterns))
|
|
83
|
+
throw new Error(
|
|
84
|
+
'package.json workspaces must be an array or an object with a packages array.',
|
|
85
|
+
);
|
|
86
|
+
manifestPatterns = [...declaredPatterns];
|
|
87
|
+
}
|
|
88
|
+
const patterns = [
|
|
89
|
+
...manifestPatterns,
|
|
90
|
+
...(await pnpmWorkspacePatterns(root)),
|
|
91
|
+
].map(validatedWorkspacePattern);
|
|
92
|
+
const positivePatterns = patterns.filter(({ negated }) => !negated);
|
|
93
|
+
const rootReal = await realpath(root);
|
|
94
|
+
const candidates = new Map();
|
|
95
|
+
const ignored = new Set([
|
|
96
|
+
'.git',
|
|
97
|
+
'.hg',
|
|
98
|
+
'.pnpm-store',
|
|
99
|
+
'.svn',
|
|
100
|
+
'.yarn',
|
|
101
|
+
'node_modules',
|
|
102
|
+
]);
|
|
103
|
+
const visit = async (directory, relativeDirectory = '') => {
|
|
104
|
+
const entries = (await readdir(directory, { withFileTypes: true })).sort(
|
|
105
|
+
(left, right) => left.name.localeCompare(right.name),
|
|
106
|
+
);
|
|
107
|
+
for (const entry of entries) {
|
|
108
|
+
if (ignored.has(entry.name)) continue;
|
|
109
|
+
const childRelative = relativeDirectory
|
|
110
|
+
? `${relativeDirectory}/${entry.name}`
|
|
111
|
+
: entry.name;
|
|
112
|
+
if (
|
|
113
|
+
!positivePatterns.some(({ body }) =>
|
|
114
|
+
minimatch(childRelative, body, { nonegate: true, partial: true }),
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
continue;
|
|
118
|
+
const child = resolve(directory, entry.name);
|
|
119
|
+
if (entry.isSymbolicLink()) {
|
|
120
|
+
const actual = await realpath(child);
|
|
121
|
+
if (!contained(rootReal, actual))
|
|
122
|
+
throw new Error(
|
|
123
|
+
`Workspace package symlink escapes the workspace: ${childRelative}.`,
|
|
124
|
+
);
|
|
125
|
+
const manifest = await readJson(resolve(child, 'package.json'), root);
|
|
126
|
+
if (manifest)
|
|
127
|
+
candidates.set(childRelative, { directory: child, manifest });
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (!entry.isDirectory()) continue;
|
|
131
|
+
const manifest = await readJson(resolve(child, 'package.json'), root);
|
|
132
|
+
if (manifest)
|
|
133
|
+
candidates.set(childRelative, { directory: child, manifest });
|
|
134
|
+
await visit(child, childRelative);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (positivePatterns.length) await visit(root);
|
|
138
|
+
const selected = new Map();
|
|
139
|
+
for (const { body, negated } of patterns)
|
|
140
|
+
for (const [path, candidate] of [...candidates].sort(([left], [right]) =>
|
|
141
|
+
left.localeCompare(right),
|
|
142
|
+
))
|
|
143
|
+
if (minimatch(path, body, { nonegate: true })) {
|
|
144
|
+
if (negated) selected.delete(path);
|
|
145
|
+
else selected.set(path, candidate);
|
|
146
|
+
}
|
|
147
|
+
const packages = [
|
|
148
|
+
{ directory: root, manifest: rootManifest },
|
|
149
|
+
...[...selected]
|
|
150
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
151
|
+
.map(([, candidate]) => candidate),
|
|
152
|
+
];
|
|
153
|
+
const actualDirectories = new Map([[rootReal, '.']]);
|
|
154
|
+
for (const { directory } of packages) {
|
|
155
|
+
if (directory === root) continue;
|
|
156
|
+
const actual = await realpath(directory);
|
|
157
|
+
const previous = actualDirectories.get(actual);
|
|
158
|
+
if (previous)
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Workspace package aliases ${previous} and ${portable(root, directory)} resolve to the same directory.`,
|
|
161
|
+
);
|
|
162
|
+
actualDirectories.set(actual, portable(root, directory));
|
|
163
|
+
}
|
|
164
|
+
return packages;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function declaredMode(manifest) {
|
|
168
|
+
const deps = dependencies(manifest);
|
|
169
|
+
if (deps['@kerfjs/ui']) return 'ui';
|
|
170
|
+
if (deps.kerfjs) return 'core';
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async function sourceMode(directory) {
|
|
175
|
+
const queue = [resolve(directory, 'src')];
|
|
176
|
+
let inspected = 0;
|
|
177
|
+
let core = false;
|
|
178
|
+
while (queue.length && inspected < 200) {
|
|
179
|
+
const current = queue.shift();
|
|
180
|
+
let entries;
|
|
181
|
+
try {
|
|
182
|
+
entries = await readdir(current, { withFileTypes: true });
|
|
183
|
+
} catch {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
for (const entry of entries) {
|
|
187
|
+
const path = resolve(current, entry.name);
|
|
188
|
+
if (entry.isDirectory()) queue.push(path);
|
|
189
|
+
else if (/\.(?:[cm]?[jt]sx?)$/.test(entry.name)) {
|
|
190
|
+
inspected += 1;
|
|
191
|
+
const source = await readText(path);
|
|
192
|
+
if (/['"]@kerfjs\/ui(?:\/[^'"]*)?['"]/.test(source)) return 'ui';
|
|
193
|
+
if (/['"]kerfjs(?:\/[^'"]*)?['"]/.test(source)) core = true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return core ? 'core' : null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function detectMode(candidate) {
|
|
201
|
+
return declaredMode(candidate.manifest) ?? sourceMode(candidate.directory);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export async function selectPackage(root, selector, requestedMode) {
|
|
205
|
+
const packages = await workspacePackages(root);
|
|
206
|
+
if (selector) {
|
|
207
|
+
const direct = resolve(root, selector);
|
|
208
|
+
const pathMatch = packages.find(({ directory }) => directory === direct);
|
|
209
|
+
const nameMatches = packages.filter(
|
|
210
|
+
({ manifest }) => manifest.name === selector,
|
|
211
|
+
);
|
|
212
|
+
if (!pathMatch && nameMatches.length > 1)
|
|
213
|
+
throw new Error(
|
|
214
|
+
`Workspace package name ${selector} is ambiguous (${nameMatches
|
|
215
|
+
.map(({ directory }) => portable(root, directory))
|
|
216
|
+
.join(', ')}); select a relative package path.`,
|
|
217
|
+
);
|
|
218
|
+
const selected = pathMatch ?? nameMatches[0];
|
|
219
|
+
if (!selected)
|
|
220
|
+
throw new Error(`Workspace package ${selector} was not found.`);
|
|
221
|
+
return selected;
|
|
222
|
+
}
|
|
223
|
+
const candidates = [];
|
|
224
|
+
for (const candidate of packages)
|
|
225
|
+
if ((await detectMode(candidate)) || requestedMode)
|
|
226
|
+
candidates.push(candidate);
|
|
227
|
+
if (candidates.length === 1) return candidates[0];
|
|
228
|
+
if (!candidates.length)
|
|
229
|
+
throw new Error('No Kerf package detected; pass --core or --ui.');
|
|
230
|
+
throw new Error(
|
|
231
|
+
`Multiple Kerf packages detected (${candidates
|
|
232
|
+
.map(({ manifest }) => manifest.name ?? '<unnamed>')
|
|
233
|
+
.join(', ')}); pass --package <name|path>.`,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export async function packageManagerInfo(root) {
|
|
238
|
+
const manifest = await readJson(resolve(root, 'package.json'), root);
|
|
239
|
+
const declared = manifest?.packageManager?.match(/^(npm|pnpm|yarn)@(.+)$/);
|
|
240
|
+
if (manifest?.packageManager && !declared)
|
|
241
|
+
throw new Error(
|
|
242
|
+
`Unsupported packageManager ${manifest.packageManager}; expected npm@<version>, pnpm@<version>, or yarn@<numeric-version>.`,
|
|
243
|
+
);
|
|
244
|
+
if (declared) {
|
|
245
|
+
if (declared[1] !== 'yarn')
|
|
246
|
+
return { name: declared[1], version: declared[2] };
|
|
247
|
+
const major = Number(declared[2].match(/^\d+/)?.[0]);
|
|
248
|
+
if (!Number.isInteger(major))
|
|
249
|
+
throw new Error(
|
|
250
|
+
'Cannot distinguish Yarn Classic from Berry; declare a numeric yarn packageManager version.',
|
|
251
|
+
);
|
|
252
|
+
return {
|
|
253
|
+
name: 'yarn',
|
|
254
|
+
version: declared[2],
|
|
255
|
+
variant: major === 1 ? 'classic' : 'berry',
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
if (await exists(resolve(root, 'pnpm-lock.yaml'))) return { name: 'pnpm' };
|
|
259
|
+
const yarnLock = await readText(resolve(root, 'yarn.lock'));
|
|
260
|
+
const berryConfig = await exists(resolve(root, '.yarnrc.yml'));
|
|
261
|
+
const classicConfig = await exists(resolve(root, '.yarnrc'));
|
|
262
|
+
if (yarnLock !== null || berryConfig || classicConfig) {
|
|
263
|
+
const berryLock = /^__metadata:\s*$/m.test(yarnLock ?? '');
|
|
264
|
+
const classicLock = /^# yarn lockfile v1\s*$/m.test(yarnLock ?? '');
|
|
265
|
+
if ((berryConfig || berryLock) && !(classicConfig || classicLock))
|
|
266
|
+
return { name: 'yarn', variant: 'berry' };
|
|
267
|
+
if ((classicConfig || classicLock) && !(berryConfig || berryLock))
|
|
268
|
+
return { name: 'yarn', variant: 'classic' };
|
|
269
|
+
throw new Error(
|
|
270
|
+
'Cannot distinguish Yarn Classic from Berry; declare packageManager as yarn@<version>.',
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
return { name: 'npm' };
|
|
274
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface SetupConflict {
|
|
2
|
+
id: string;
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SetupAction {
|
|
6
|
+
path: string;
|
|
7
|
+
absolutePath: string;
|
|
8
|
+
before: string | null;
|
|
9
|
+
after: string;
|
|
10
|
+
kind: string;
|
|
11
|
+
}
|
|
12
|
+
export interface KerfSetupPlan {
|
|
13
|
+
schemaVersion: 1;
|
|
14
|
+
root: string;
|
|
15
|
+
packageRoot: string;
|
|
16
|
+
packageName: string;
|
|
17
|
+
packageManager: 'npm' | 'pnpm' | 'yarn';
|
|
18
|
+
packageManagerVersion?: string;
|
|
19
|
+
packageManagerVariant?: 'classic' | 'berry';
|
|
20
|
+
mode: 'core' | 'ui';
|
|
21
|
+
setupVersion: string;
|
|
22
|
+
actions: SetupAction[];
|
|
23
|
+
proposalIds: string[];
|
|
24
|
+
conflicts: SetupConflict[];
|
|
25
|
+
generatedPaths: string[];
|
|
26
|
+
}
|
|
27
|
+
export function planKerfSetup(options?: {
|
|
28
|
+
root?: string;
|
|
29
|
+
package?: string;
|
|
30
|
+
mode?: 'core' | 'ui';
|
|
31
|
+
version?: string;
|
|
32
|
+
guidanceSource?: string;
|
|
33
|
+
resolutions?: Record<string, 'keep' | 'kerf' | 'skip'>;
|
|
34
|
+
}): Promise<KerfSetupPlan>;
|
|
35
|
+
export function formatSetupPlan(plan: KerfSetupPlan): string;
|
|
36
|
+
export function applyKerfSetup(
|
|
37
|
+
plan: KerfSetupPlan,
|
|
38
|
+
options?: { install?: boolean; offline?: boolean; runner?: Function },
|
|
39
|
+
): Promise<{ changed: string[] }>;
|