foldkit-plus 0.17.0 → 0.19.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/README.md +241 -28
- package/dist/cli.mjs +10930 -35
- package/dist/cli.mjs.map +1 -1
- package/dist/docs.d.mts +89 -0
- package/dist/docs.d.mts.map +1 -0
- package/dist/docs.mjs +290 -0
- package/dist/docs.mjs.map +1 -0
- package/dist/project.d.mts +45 -0
- package/dist/project.d.mts.map +1 -0
- package/dist/project.mjs +221 -0
- package/dist/project.mjs.map +1 -0
- package/dist/remote/filter.d.mts +1 -0
- package/dist/remote/filter.mjs +2 -0
- package/dist/remote/live.d.mts +1 -0
- package/dist/remote/live.mjs +2 -0
- package/dist/remote/outbox.d.mts +1 -0
- package/dist/remote/outbox.mjs +2 -0
- package/dist/remote/overlay.d.mts +1 -0
- package/dist/remote/overlay.mjs +2 -0
- package/dist/remote/persistence.d.mts +1 -0
- package/dist/remote/persistence.mjs +2 -0
- package/dist/remote/testing.d.mts +1 -0
- package/dist/remote/testing.mjs +2 -0
- package/dist/remote/why.d.mts +1 -0
- package/dist/remote/why.mjs +2 -0
- package/dist/setup.d.mts +45 -7
- package/dist/setup.d.mts.map +1 -1
- package/dist/setup.mjs +168 -25
- package/dist/setup.mjs.map +1 -1
- package/dist/testing/peer.d.mts +8 -0
- package/dist/testing/peer.d.mts.map +1 -0
- package/dist/testing/peer.mjs +19 -0
- package/dist/testing/peer.mjs.map +1 -0
- package/dist/testing/playwright.d.mts +84 -0
- package/dist/testing/playwright.d.mts.map +1 -0
- package/dist/testing/playwright.mjs +327 -0
- package/dist/testing/playwright.mjs.map +1 -0
- package/dist/testing/workers.d.mts +177 -0
- package/dist/testing/workers.d.mts.map +1 -0
- package/dist/testing/workers.mjs +593 -0
- package/dist/testing/workers.mjs.map +1 -0
- package/package.json +126 -59
package/dist/project.mjs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { declarationsIn } from "./docs.mjs";
|
|
2
|
+
import { effectPackages } from "./setup.mjs";
|
|
3
|
+
import { Option, Schema } from "effect";
|
|
4
|
+
import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
|
|
5
|
+
import { homedir } from "node:os";
|
|
6
|
+
import { dirname, join, relative, sep } from "node:path";
|
|
7
|
+
// src/project.ts
|
|
8
|
+
/**
|
|
9
|
+
* What the CLI reads from the disk: the project in a folder, its package
|
|
10
|
+
* manager, and this package's own manifest.
|
|
11
|
+
*/
|
|
12
|
+
const Versions = Schema.Record(Schema.String, Schema.String);
|
|
13
|
+
const Manifest = Schema.Struct({
|
|
14
|
+
name: Schema.optional(Schema.String),
|
|
15
|
+
version: Schema.optional(Schema.String),
|
|
16
|
+
dependencies: Schema.optional(Versions),
|
|
17
|
+
devDependencies: Schema.optional(Versions),
|
|
18
|
+
peerDependencies: Schema.optional(Versions),
|
|
19
|
+
setup: Schema.optional(Schema.Struct({
|
|
20
|
+
effect: Schema.String,
|
|
21
|
+
foldkit: Schema.String
|
|
22
|
+
}))
|
|
23
|
+
});
|
|
24
|
+
const readManifest = (path) => Schema.decodeUnknownSync(Manifest)(JSON.parse(readFileSync(path, "utf8")));
|
|
25
|
+
/**
|
|
26
|
+
* A project's folder and those above it, up to its repository's root and no
|
|
27
|
+
* further, and never into the home folder: a file left there says nothing
|
|
28
|
+
* about this project. A folder that is no project has none.
|
|
29
|
+
*/
|
|
30
|
+
const projectFolders = (folder) => {
|
|
31
|
+
const folders = [];
|
|
32
|
+
const project = existsSync(join(folder, "package.json"));
|
|
33
|
+
for (let at = folder; project && at !== homedir(); at = dirname(at)) {
|
|
34
|
+
folders.push(at);
|
|
35
|
+
if (existsSync(join(at, ".git")) || dirname(at) === at) break;
|
|
36
|
+
}
|
|
37
|
+
return folders;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Where pnpm reads `folder`'s `overrides` and `peerDependencyRules`: the
|
|
41
|
+
* workspace root, the nearest folder at or above it with a
|
|
42
|
+
* `pnpm-workspace.yaml`, since pnpm ignores them in a member's `package.json`.
|
|
43
|
+
* There, the root `package.json`'s `pnpm` field if it already has one, else
|
|
44
|
+
* the YAML; with no workspace, the project's own `package.json`.
|
|
45
|
+
*/
|
|
46
|
+
const pnpmSettingsIn = (folder) => {
|
|
47
|
+
const root = projectFolders(folder).find((at) => existsSync(join(at, "pnpm-workspace.yaml")));
|
|
48
|
+
if (root === void 0) return {
|
|
49
|
+
folder: ".",
|
|
50
|
+
file: "package.json"
|
|
51
|
+
};
|
|
52
|
+
const manifest = join(root, "package.json");
|
|
53
|
+
const field = existsSync(manifest) && Object.hasOwn(JSON.parse(readFileSync(manifest, "utf8")), "pnpm");
|
|
54
|
+
return {
|
|
55
|
+
folder: relative(folder, root).split(sep).join("/") || ".",
|
|
56
|
+
file: field ? "package.json" : "pnpm-workspace.yaml"
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const NpmLock = Schema.Struct({ packages: Schema.Record(Schema.String, Schema.Struct({ version: Schema.optional(Schema.String) })) });
|
|
60
|
+
/**
|
|
61
|
+
* The versions of Effect's packages in the nearest npm lockfile, keyed by
|
|
62
|
+
* install path (`node_modules/@foldkit/vite-plugin/node_modules/effect`). One
|
|
63
|
+
* npm cannot read holds none.
|
|
64
|
+
*/
|
|
65
|
+
const lockedEffect = (folder) => {
|
|
66
|
+
const lock = projectFolders(folder).map((at) => join(at, "package-lock.json")).find(existsSync);
|
|
67
|
+
if (lock === void 0) return [];
|
|
68
|
+
return Option.match(Schema.decodeUnknownOption(Schema.fromJsonString(NpmLock))(readFileSync(lock, "utf8")), {
|
|
69
|
+
onNone: () => [],
|
|
70
|
+
onSome: ({ packages }) => Object.entries(packages).flatMap(([path, entry]) => entry.version !== void 0 && effectPackages.some((name) => path.endsWith(`node_modules/${name}`)) ? [entry.version] : [])
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
/** The project in `folder`, if it is one. */
|
|
74
|
+
const projectIn = (folder) => {
|
|
75
|
+
const path = join(folder, "package.json");
|
|
76
|
+
if (!existsSync(path)) return Option.none();
|
|
77
|
+
const manifest = readManifest(path);
|
|
78
|
+
return Option.some({
|
|
79
|
+
name: manifest.name ?? "this project",
|
|
80
|
+
versions: {
|
|
81
|
+
...manifest.peerDependencies,
|
|
82
|
+
...manifest.devDependencies,
|
|
83
|
+
...manifest.dependencies
|
|
84
|
+
},
|
|
85
|
+
gitattributes: projectFolders(folder).some((at) => existsSync(join(at, ".gitattributes"))),
|
|
86
|
+
pnpmSettings: pnpmSettingsIn(folder),
|
|
87
|
+
locked: lockedEffect(folder)
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The project's package manager by its lockfile, here or in a project folder
|
|
92
|
+
* above (a workspace keeps one at its root), else the one running this.
|
|
93
|
+
*/
|
|
94
|
+
const managerIn = (folder) => {
|
|
95
|
+
const locks = [
|
|
96
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
97
|
+
["bun.lock", "bun"],
|
|
98
|
+
["bun.lockb", "bun"],
|
|
99
|
+
["yarn.lock", "yarn"],
|
|
100
|
+
["package-lock.json", "npm"]
|
|
101
|
+
];
|
|
102
|
+
for (const at of projectFolders(folder)) {
|
|
103
|
+
const locked = locks.find(([file]) => existsSync(join(at, file)));
|
|
104
|
+
if (locked !== void 0) return locked[1];
|
|
105
|
+
}
|
|
106
|
+
const agent = process.env["npm_config_user_agent"] ?? "";
|
|
107
|
+
return locks.map(([, manager]) => manager).find((manager) => agent.startsWith(`${manager}/`)) ?? "npm";
|
|
108
|
+
};
|
|
109
|
+
/** A failure the reader can act on, printed as its message alone. */
|
|
110
|
+
var Refusal = class extends Error {};
|
|
111
|
+
/** The Foldkit Plus packages a manifest names: its own `foldkit-*` dependencies and peers. */
|
|
112
|
+
const familyOf = (manifest) => Object.keys({
|
|
113
|
+
...manifest.dependencies,
|
|
114
|
+
...manifest.peerDependencies
|
|
115
|
+
}).filter((name) => name.startsWith("foldkit-"));
|
|
116
|
+
/**
|
|
117
|
+
* Where an `import` from `base` finds `name`: the nearest `node_modules` above
|
|
118
|
+
* it that holds the package, with links resolved, so a package's own
|
|
119
|
+
* dependencies are found beside it in pnpm's store. ESM reads neither
|
|
120
|
+
* `NODE_PATH` nor the global folders, which `require.resolve.paths` adds.
|
|
121
|
+
*/
|
|
122
|
+
const installedFrom = (base, name) => {
|
|
123
|
+
for (let at = base;; at = dirname(at)) {
|
|
124
|
+
const candidate = join(at, "node_modules", name);
|
|
125
|
+
if (existsSync(join(candidate, "package.json"))) return Option.some(realpathSync(candidate));
|
|
126
|
+
if (dirname(at) === at) return Option.none();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/** The `foldkit-plus` skill nearest the project: in a dot-folder's `skills/` here, above, or at home. */
|
|
130
|
+
const skillIn = (folder) => {
|
|
131
|
+
for (const at of [...projectFolders(folder), homedir()]) {
|
|
132
|
+
const skill = (existsSync(at) ? readdirSync(at, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.startsWith(".")) : []).map((entry) => join(at, entry.name, "skills", "foldkit-plus")).find((dir) => existsSync(join(dir, "SKILL.md")));
|
|
133
|
+
if (skill !== void 0) return Option.some(skill);
|
|
134
|
+
}
|
|
135
|
+
return Option.none();
|
|
136
|
+
};
|
|
137
|
+
const declarationFiles = (dir) => existsSync(dir) ? readdirSync(dir, { withFileTypes: true }).flatMap((entry) => entry.isDirectory() ? declarationFiles(join(dir, entry.name)) : /\.d\.m?ts$/.test(entry.name) ? [join(dir, entry.name)] : []) : [];
|
|
138
|
+
const topicOf = (name) => name.replace(/^foldkit-/, "");
|
|
139
|
+
/**
|
|
140
|
+
* The documents of what is installed in `folder`: the README of each Foldkit
|
|
141
|
+
* Plus package Node would load there, and the skill's files if it is
|
|
142
|
+
* installed. `family` is the packages this CLI knows of; an installed
|
|
143
|
+
* `foldkit-plus` adds those it knows. Refuses a folder with no project, a
|
|
144
|
+
* package the project names but has not installed, and a project with none.
|
|
145
|
+
*/
|
|
146
|
+
const libraryIn = (folder, family) => {
|
|
147
|
+
const project = projectIn(folder);
|
|
148
|
+
if (Option.isNone(project)) throw new Refusal(`There is no package.json in ${folder}: run this in the application's folder.`);
|
|
149
|
+
const plus = installedFrom(folder, "foldkit-plus");
|
|
150
|
+
const names = /* @__PURE__ */ new Set([
|
|
151
|
+
"foldkit-plus",
|
|
152
|
+
...family,
|
|
153
|
+
...Option.match(plus, {
|
|
154
|
+
onNone: () => [],
|
|
155
|
+
onSome: (dir) => familyOf(readManifest(join(dir, "package.json")))
|
|
156
|
+
})
|
|
157
|
+
]);
|
|
158
|
+
const installed = [];
|
|
159
|
+
for (const name of [...names].sort()) {
|
|
160
|
+
const named = project.value.versions[name] !== void 0;
|
|
161
|
+
const fromProject = () => installedFrom(folder, name);
|
|
162
|
+
const dir = named ? fromProject() : Option.orElse(Option.flatMap(plus, (at) => installedFrom(at, name)), fromProject);
|
|
163
|
+
Option.match(dir, {
|
|
164
|
+
onNone: () => {
|
|
165
|
+
if (named) throw new Refusal(`package.json names ${name}, but it is not installed in ${folder}: run the install first.`);
|
|
166
|
+
},
|
|
167
|
+
onSome: (at) => {
|
|
168
|
+
const version = readManifest(join(at, "package.json")).version ?? "unversioned";
|
|
169
|
+
installed.push({
|
|
170
|
+
name,
|
|
171
|
+
version,
|
|
172
|
+
dir: at
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (installed.length === 0) throw new Refusal(`No Foldkit Plus package is installed in ${folder}. \`npx foldkit-plus setup\` says how to install one.`);
|
|
178
|
+
const skill = Option.match(skillIn(folder), {
|
|
179
|
+
onNone: () => [],
|
|
180
|
+
onSome: (dir) => {
|
|
181
|
+
const front = readFileSync(join(dir, "SKILL.md"), "utf8");
|
|
182
|
+
const version = /^\s+version:\s*['"]?([^'"\s]+)/m.exec(front)?.[1] ?? "unversioned";
|
|
183
|
+
const references = join(dir, "references");
|
|
184
|
+
return [join(dir, "SKILL.md"), ...existsSync(references) ? readdirSync(references).filter((file) => file.endsWith(".md")).sort().map((file) => join(references, file)) : []].map((path) => ({
|
|
185
|
+
topic: path.endsWith("SKILL.md") ? "skill" : relative(references, path).slice(0, -3),
|
|
186
|
+
label: `foldkit-plus skill ${version} ${relative(dir, path).split(sep).join("/")}`,
|
|
187
|
+
path,
|
|
188
|
+
text: readFileSync(path, "utf8")
|
|
189
|
+
}));
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
const readmes = installed.flatMap((each) => {
|
|
193
|
+
const path = join(each.dir, "README.md");
|
|
194
|
+
return existsSync(path) ? [{
|
|
195
|
+
topic: topicOf(each.name),
|
|
196
|
+
label: `${each.name}@${each.version} README.md`,
|
|
197
|
+
path,
|
|
198
|
+
text: readFileSync(path, "utf8")
|
|
199
|
+
}] : [];
|
|
200
|
+
});
|
|
201
|
+
return {
|
|
202
|
+
docs: [...skill, ...readmes],
|
|
203
|
+
declarations: (symbol) => {
|
|
204
|
+
const seen = /* @__PURE__ */ new Set();
|
|
205
|
+
return installed.filter((each) => each.name !== "foldkit-plus").flatMap((each) => declarationFiles(join(each.dir, "dist")).flatMap((path) => declarationsIn({
|
|
206
|
+
topic: topicOf(each.name),
|
|
207
|
+
origin: `${each.name}@${each.version}`,
|
|
208
|
+
path,
|
|
209
|
+
text: readFileSync(path, "utf8")
|
|
210
|
+
}, symbol))).filter((found) => {
|
|
211
|
+
const key = [...found.comment, ...found.signature].join("\n");
|
|
212
|
+
if (seen.has(key)) return false;
|
|
213
|
+
seen.add(key);
|
|
214
|
+
return true;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
export { Refusal, familyOf, libraryIn, managerIn, projectIn, readManifest };
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=project.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.mjs","names":[],"sources":["../src/project.ts"],"sourcesContent":["/**\n * What the CLI reads from the disk: the project in a folder, its package\n * manager, and this package's own manifest.\n */\nimport { Option, Schema } from 'effect'\nimport { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { dirname, join, relative, sep } from 'node:path'\n\nimport { declarationsIn, type Declaration, type Doc } from './docs.js'\nimport { effectPackages, type Manager, type PnpmSettings, type Project } from './setup.js'\n\nconst Versions = Schema.Record(Schema.String, Schema.String)\nconst Manifest = Schema.Struct({\n name: Schema.optional(Schema.String),\n version: Schema.optional(Schema.String),\n dependencies: Schema.optional(Versions),\n devDependencies: Schema.optional(Versions),\n peerDependencies: Schema.optional(Versions),\n setup: Schema.optional(Schema.Struct({ effect: Schema.String, foldkit: Schema.String })),\n})\nexport const readManifest = (path: string) =>\n Schema.decodeUnknownSync(Manifest)(JSON.parse(readFileSync(path, 'utf8')))\n\n/**\n * A project's folder and those above it, up to its repository's root and no\n * further, and never into the home folder: a file left there says nothing\n * about this project. A folder that is no project has none.\n */\nconst projectFolders = (folder: string): ReadonlyArray<string> => {\n const folders: Array<string> = []\n const project = existsSync(join(folder, 'package.json'))\n for (let at = folder; project && at !== homedir(); at = dirname(at)) {\n folders.push(at)\n if (existsSync(join(at, '.git')) || dirname(at) === at) break\n }\n return folders\n}\n\n/**\n * Where pnpm reads `folder`'s `overrides` and `peerDependencyRules`: the\n * workspace root, the nearest folder at or above it with a\n * `pnpm-workspace.yaml`, since pnpm ignores them in a member's `package.json`.\n * There, the root `package.json`'s `pnpm` field if it already has one, else\n * the YAML; with no workspace, the project's own `package.json`.\n */\nconst pnpmSettingsIn = (folder: string): PnpmSettings => {\n const root = projectFolders(folder).find(at => existsSync(join(at, 'pnpm-workspace.yaml')))\n if (root === undefined) return { folder: '.', file: 'package.json' }\n const manifest = join(root, 'package.json')\n const field =\n existsSync(manifest) &&\n Object.hasOwn(JSON.parse(readFileSync(manifest, 'utf8')) as object, 'pnpm')\n return {\n folder: relative(folder, root).split(sep).join('/') || '.',\n file: field ? 'package.json' : 'pnpm-workspace.yaml',\n }\n}\n\nconst NpmLock = Schema.Struct({\n packages: Schema.Record(\n Schema.String,\n Schema.Struct({ version: Schema.optional(Schema.String) }),\n ),\n})\n\n/**\n * The versions of Effect's packages in the nearest npm lockfile, keyed by\n * install path (`node_modules/@foldkit/vite-plugin/node_modules/effect`). One\n * npm cannot read holds none.\n */\nconst lockedEffect = (folder: string): ReadonlyArray<string> => {\n const lock = projectFolders(folder)\n .map(at => join(at, 'package-lock.json'))\n .find(existsSync)\n if (lock === undefined) return []\n return Option.match(\n Schema.decodeUnknownOption(Schema.fromJsonString(NpmLock))(readFileSync(lock, 'utf8')),\n {\n onNone: () => [],\n onSome: ({ packages }) =>\n Object.entries(packages).flatMap(([path, entry]) =>\n entry.version !== undefined &&\n effectPackages.some(name => path.endsWith(`node_modules/${name}`))\n ? [entry.version]\n : [],\n ),\n },\n )\n}\n\n/** The project in `folder`, if it is one. */\nexport const projectIn = (folder: string): Option.Option<Project> => {\n const path = join(folder, 'package.json')\n if (!existsSync(path)) return Option.none()\n const manifest = readManifest(path)\n return Option.some({\n name: manifest.name ?? 'this project',\n versions: {\n ...manifest.peerDependencies,\n ...manifest.devDependencies,\n ...manifest.dependencies,\n },\n gitattributes: projectFolders(folder).some(at => existsSync(join(at, '.gitattributes'))),\n pnpmSettings: pnpmSettingsIn(folder),\n locked: lockedEffect(folder),\n })\n}\n\n/**\n * The project's package manager by its lockfile, here or in a project folder\n * above (a workspace keeps one at its root), else the one running this.\n */\nexport const managerIn = (folder: string): Manager => {\n const locks: ReadonlyArray<readonly [string, Manager]> = [\n ['pnpm-lock.yaml', 'pnpm'],\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n ]\n for (const at of projectFolders(folder)) {\n const locked = locks.find(([file]) => existsSync(join(at, file)))\n if (locked !== undefined) return locked[1]\n }\n const agent = process.env['npm_config_user_agent'] ?? ''\n return (\n locks.map(([, manager]) => manager).find(manager => agent.startsWith(`${manager}/`)) ?? 'npm'\n )\n}\n\n/** A failure the reader can act on, printed as its message alone. */\nexport class Refusal extends Error {}\n\n/** The Foldkit Plus packages a manifest names: its own `foldkit-*` dependencies and peers. */\nexport const familyOf = (manifest: ReturnType<typeof readManifest>): ReadonlyArray<string> =>\n Object.keys({ ...manifest.dependencies, ...manifest.peerDependencies }).filter(name =>\n name.startsWith('foldkit-'),\n )\n\n/**\n * Where an `import` from `base` finds `name`: the nearest `node_modules` above\n * it that holds the package, with links resolved, so a package's own\n * dependencies are found beside it in pnpm's store. ESM reads neither\n * `NODE_PATH` nor the global folders, which `require.resolve.paths` adds.\n */\nconst installedFrom = (base: string, name: string): Option.Option<string> => {\n for (let at = base; ; at = dirname(at)) {\n const candidate = join(at, 'node_modules', name)\n if (existsSync(join(candidate, 'package.json'))) return Option.some(realpathSync(candidate))\n if (dirname(at) === at) return Option.none()\n }\n}\n\ninterface Installed {\n readonly name: string\n readonly version: string\n readonly dir: string\n}\n\n/** The `foldkit-plus` skill nearest the project: in a dot-folder's `skills/` here, above, or at home. */\nconst skillIn = (folder: string): Option.Option<string> => {\n for (const at of [...projectFolders(folder), homedir()]) {\n const holders = existsSync(at)\n ? readdirSync(at, { withFileTypes: true }).filter(\n entry => entry.isDirectory() && entry.name.startsWith('.'),\n )\n : []\n const skill = holders\n .map(entry => join(at, entry.name, 'skills', 'foldkit-plus'))\n .find(dir => existsSync(join(dir, 'SKILL.md')))\n if (skill !== undefined) return Option.some(skill)\n }\n return Option.none()\n}\n\nconst declarationFiles = (dir: string): ReadonlyArray<string> =>\n existsSync(dir)\n ? readdirSync(dir, { withFileTypes: true }).flatMap(entry =>\n entry.isDirectory()\n ? declarationFiles(join(dir, entry.name))\n : /\\.d\\.m?ts$/.test(entry.name)\n ? [join(dir, entry.name)]\n : [],\n )\n : []\n\nconst topicOf = (name: string) => name.replace(/^foldkit-/, '')\n\n/** What `docs` reads for a project: its documents, and a way to look a symbol up in its types. */\nexport interface Library {\n readonly docs: ReadonlyArray<Doc>\n readonly declarations: (symbol: string) => ReadonlyArray<Declaration>\n}\n\n/**\n * The documents of what is installed in `folder`: the README of each Foldkit\n * Plus package Node would load there, and the skill's files if it is\n * installed. `family` is the packages this CLI knows of; an installed\n * `foldkit-plus` adds those it knows. Refuses a folder with no project, a\n * package the project names but has not installed, and a project with none.\n */\nexport const libraryIn = (folder: string, family: ReadonlyArray<string>): Library => {\n const project = projectIn(folder)\n if (Option.isNone(project))\n throw new Refusal(\n `There is no package.json in ${folder}: run this in the application's folder.`,\n )\n const plus = installedFrom(folder, 'foldkit-plus')\n const names = new Set([\n 'foldkit-plus',\n ...family,\n ...Option.match(plus, {\n onNone: () => [],\n onSome: dir => familyOf(readManifest(join(dir, 'package.json'))),\n }),\n ])\n const installed: Array<Installed> = []\n for (const name of [...names].sort()) {\n // What the project names is what its own imports load; the rest is what\n // `foldkit-plus` loads, which a copy in a folder above must not stand for.\n const named = project.value.versions[name] !== undefined\n const fromProject = () => installedFrom(folder, name)\n const dir = named\n ? fromProject()\n : Option.orElse(\n Option.flatMap(plus, at => installedFrom(at, name)),\n fromProject,\n )\n Option.match(dir, {\n onNone: () => {\n if (named)\n throw new Refusal(\n `package.json names ${name}, but it is not installed in ${folder}: run the install first.`,\n )\n },\n onSome: at => {\n const version = readManifest(join(at, 'package.json')).version ?? 'unversioned'\n installed.push({ name, version, dir: at })\n },\n })\n }\n if (installed.length === 0)\n throw new Refusal(\n `No Foldkit Plus package is installed in ${folder}. \\`npx foldkit-plus setup\\` says how to install one.`,\n )\n const skill = Option.match(skillIn(folder), {\n onNone: () => [],\n onSome: dir => {\n const front = readFileSync(join(dir, 'SKILL.md'), 'utf8')\n const version = /^\\s+version:\\s*['\"]?([^'\"\\s]+)/m.exec(front)?.[1] ?? 'unversioned'\n const references = join(dir, 'references')\n const files = [\n join(dir, 'SKILL.md'),\n ...(existsSync(references)\n ? readdirSync(references)\n .filter(file => file.endsWith('.md'))\n .sort()\n .map(file => join(references, file))\n : []),\n ]\n return files.map(path => ({\n topic: path.endsWith('SKILL.md') ? 'skill' : relative(references, path).slice(0, -3),\n label: `foldkit-plus skill ${version} ${relative(dir, path).split(sep).join('/')}`,\n path,\n text: readFileSync(path, 'utf8'),\n }))\n },\n })\n const readmes = installed.flatMap(each => {\n const path = join(each.dir, 'README.md')\n return existsSync(path)\n ? [\n {\n topic: topicOf(each.name),\n label: `${each.name}@${each.version} README.md`,\n path,\n text: readFileSync(path, 'utf8'),\n },\n ]\n : []\n })\n return {\n docs: [...skill, ...readmes],\n // Read only for a symbol; `foldkit-plus`'s own types re-export the others'.\n declarations: symbol => {\n const seen = new Set<string>()\n return installed\n .filter(each => each.name !== 'foldkit-plus')\n .flatMap(each =>\n declarationFiles(join(each.dir, 'dist')).flatMap(path =>\n declarationsIn(\n {\n topic: topicOf(each.name),\n origin: `${each.name}@${each.version}`,\n path,\n text: readFileSync(path, 'utf8'),\n },\n symbol,\n ),\n ),\n )\n .filter(found => {\n const key = [...found.comment, ...found.signature].join('\\n')\n if (seen.has(key)) return false\n seen.add(key)\n return true\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,WAAW,OAAO,OAAO,OAAO,QAAQ,OAAO,MAAM;AAC3D,MAAM,WAAW,OAAO,OAAO;CAC7B,MAAM,OAAO,SAAS,OAAO,MAAM;CACnC,SAAS,OAAO,SAAS,OAAO,MAAM;CACtC,cAAc,OAAO,SAAS,QAAQ;CACtC,iBAAiB,OAAO,SAAS,QAAQ;CACzC,kBAAkB,OAAO,SAAS,QAAQ;CAC1C,OAAO,OAAO,SAAS,OAAO,OAAO;EAAE,QAAQ,OAAO;EAAQ,SAAS,OAAO;CAAO,CAAC,CAAC;AACzF,CAAC;AACD,MAAa,gBAAgB,SAC3B,OAAO,kBAAkB,QAAQ,CAAC,CAAC,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC,CAAC;;;;;;AAO3E,MAAM,kBAAkB,WAA0C;CAChE,MAAM,UAAyB,CAAC;C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|
1
|
+
export * from "foldkit-remote/filter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "foldkit-remote/live";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "foldkit-remote/outbox";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "foldkit-remote/overlay";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "foldkit-remote/persistence";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "foldkit-remote/testing";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "foldkit-remote/why";
|
package/dist/setup.d.mts
CHANGED
|
@@ -5,8 +5,22 @@ export interface Project {
|
|
|
5
5
|
readonly name: string;
|
|
6
6
|
/** Each named library's version range, from any dependency field. */
|
|
7
7
|
readonly versions: Readonly<Record<string, string>>;
|
|
8
|
+
/** Whether a `.gitattributes` applies here: in the project's folder or one above it in its repository. */
|
|
9
|
+
readonly gitattributes: boolean;
|
|
10
|
+
/** Where pnpm reads this project's settings, which a workspace keeps at its root. */
|
|
11
|
+
readonly pnpmSettings: PnpmSettings;
|
|
12
|
+
/** The versions of Effect's packages (`effectPackages`) its npm lockfile holds, nested copies included. */
|
|
13
|
+
readonly locked: ReadonlyArray<string>;
|
|
8
14
|
}
|
|
9
|
-
/**
|
|
15
|
+
/** A file pnpm reads settings from, in `folder` relative to the project (`.`, `../..`). */
|
|
16
|
+
export interface PnpmSettings {
|
|
17
|
+
readonly folder: string;
|
|
18
|
+
readonly file: 'package.json' | 'pnpm-workspace.yaml';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The versions this release is built and tested against, from its own
|
|
22
|
+
* manifest: the workspace's Foldkit and Effect.
|
|
23
|
+
*/
|
|
10
24
|
export interface Versions {
|
|
11
25
|
readonly plus: string;
|
|
12
26
|
readonly effect: string;
|
|
@@ -19,10 +33,11 @@ export interface SetupInput {
|
|
|
19
33
|
}
|
|
20
34
|
/**
|
|
21
35
|
* The `create-foldkit-app` release whose templates pin the Foldkit this
|
|
22
|
-
* release needs (0.
|
|
23
|
-
*
|
|
36
|
+
* release needs (0.41.0 installs `foldkit`, `@foldkit/ui` and `@foldkit/devtools`
|
|
37
|
+
* 0.170.0, `@foldkit/vite-plugin` 0.29.0 and `effect` 4.1.0). A release that
|
|
38
|
+
* moves the `foldkit` peer moves this with it.
|
|
24
39
|
*/
|
|
25
|
-
export declare const SCAFFOLDER = "create-foldkit-app@0.
|
|
40
|
+
export declare const SCAFFOLDER = "create-foldkit-app@0.41.0";
|
|
26
41
|
/** What each job needs, where to import it from, and where it is explained. */
|
|
27
42
|
export declare const jobs: ReadonlyArray<{
|
|
28
43
|
readonly job: string;
|
|
@@ -31,14 +46,37 @@ export declare const jobs: ReadonlyArray<{
|
|
|
31
46
|
}>;
|
|
32
47
|
/**
|
|
33
48
|
* The packages `foldkit-plus` does not install, since each needs a library of
|
|
34
|
-
* its own, and that library
|
|
49
|
+
* its own, and that library at the range the adapter peers on: a manager
|
|
50
|
+
* given a bare name installs the `latest` tag, which for `@yielded/auth` is a
|
|
51
|
+
* beta older than the one `foldkit-auth` names. `test/generated.test.ts`
|
|
52
|
+
* holds this to the manifests.
|
|
35
53
|
*/
|
|
36
54
|
export declare const adapters: ReadonlyArray<{
|
|
37
55
|
readonly name: string;
|
|
38
56
|
readonly libraries: ReadonlyArray<string>;
|
|
39
57
|
readonly when: string;
|
|
40
58
|
}>;
|
|
41
|
-
/**
|
|
42
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The Effect packages an application meets that something names at a version
|
|
61
|
+
* of its own: Foldkit's peers and its Vite plugin's dependencies name one
|
|
62
|
+
* minor (`~4.1.0`), and each `@effect/*` package peers on an `effect` at least
|
|
63
|
+
* its own version. Setup holds all of them at the Effect this release is
|
|
64
|
+
* tested on, as `pnpm-workspace.yaml` does here (`test/generated.test.ts`
|
|
65
|
+
* keeps the two lists together).
|
|
66
|
+
*/
|
|
67
|
+
export declare const effectPackages: ReadonlyArray<string>;
|
|
68
|
+
/**
|
|
69
|
+
* The Effect release setup pins: the one this release is tested on, or a later
|
|
70
|
+
* patch of the same minor that the project's lockfile already holds. npm keeps
|
|
71
|
+
* a locked package that an override contradicts rather than move it down, so
|
|
72
|
+
* pinning 4.1.0 left the 4.1.1 that `@foldkit/vite-plugin`'s `~4.1.0` had
|
|
73
|
+
* locked under it, which `npm ls` calls invalid.
|
|
74
|
+
*/
|
|
75
|
+
export declare const effectRelease: (tested: string, locked: ReadonlyArray<string>) => string;
|
|
76
|
+
/**
|
|
77
|
+
* The command that adds `packages` with `manager`, at exactly the versions
|
|
78
|
+
* named when `exact`. A range a shell would read (`^`, `>`, a space) is quoted.
|
|
79
|
+
*/
|
|
80
|
+
export declare const addCommand: (manager: Manager, packages: ReadonlyArray<string>, exact?: boolean) => string;
|
|
43
81
|
export declare const setupGuide: ({ project, manager, versions }: SetupInput) => string;
|
|
44
82
|
//# sourceMappingURL=setup.d.mts.map
|
package/dist/setup.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.mts","names":[],"sources":["../src/setup.ts"],"mappings":";YAOY;;iBAGK;WACN;;WAEA,UAAU,SAAS;;;
|
|
1
|
+
{"version":3,"file":"setup.d.mts","names":[],"sources":["../src/setup.ts"],"mappings":";YAOY;;iBAGK;WACN;;WAEA,UAAU,SAAS;;WAEnB;;WAEA,cAAc;;WAEd,QAAQ;;;iBAIF;WACN;WACA;;;;;;iBAOM;WACN;WACA;WACA;;iBAGM;WACN,SAAS,OAAO,OAAO;WACvB,SAAS;WACT,UAAU;;;;;;;;qBAYR;;qBAMA,MAAM;WACR;WACA,SAAS;WACT;;;;;;;;;qBA+GE,UAAU;WACZ;WACA,WAAW;WACX;;;;;;;;;;qBAoDE,gBAAgB;;;;;;;;qBAkBhB,gBAAa,gBAAkB,QAAU;;;;;qBAqFzC,aAAU,SACZ,SAAO,UACN,uBAAqB;qBA8BpB,eAAU,SAAA,SAAA,YAAoC"}
|