@capybara-hq/plugin-tools 0.1.0-rc.0 → 0.1.0-rc.10

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 (51) hide show
  1. package/README.md +26 -19
  2. package/bin/capybara-plugin.mjs +1 -1
  3. package/dist/check/applied-migrations.d.ts +23 -0
  4. package/dist/check/applied-migrations.js +86 -0
  5. package/dist/check/cli.d.ts +2 -1
  6. package/dist/check/cli.js +7 -3
  7. package/dist/check/config-forms.d.ts +13 -0
  8. package/dist/check/config-forms.js +71 -0
  9. package/dist/check/deps.d.ts +4 -2
  10. package/dist/check/deps.js +14 -2
  11. package/dist/check/index.d.ts +4 -1
  12. package/dist/check/index.js +4 -1
  13. package/dist/check/migrations.d.ts +1 -1
  14. package/dist/check/migrations.js +30 -1
  15. package/dist/check/org-override.d.ts +10 -0
  16. package/dist/check/org-override.js +62 -0
  17. package/dist/check/plugin-pack.js +2 -0
  18. package/dist/check/plugin-permissions.d.ts +34 -1
  19. package/dist/check/plugin-permissions.js +66 -6
  20. package/dist/check/plugin-tool-keys.d.ts +13 -0
  21. package/dist/check/plugin-tool-keys.js +38 -0
  22. package/dist/check/release-metadata.d.ts +5 -0
  23. package/dist/check/release-metadata.js +47 -0
  24. package/dist/check/report.d.ts +4 -3
  25. package/dist/check/report.js +13 -3
  26. package/dist/check/run.d.ts +3 -1
  27. package/dist/check/run.js +12 -1
  28. package/dist/check/source.d.ts +7 -0
  29. package/dist/check/source.js +2 -0
  30. package/dist/check/themes.d.ts +19 -0
  31. package/dist/check/themes.js +112 -0
  32. package/dist/check/tool-design.d.ts +1 -1
  33. package/dist/check/tool-design.js +3 -3
  34. package/dist/check/ui-slots.d.ts +7 -0
  35. package/dist/check/ui-slots.js +30 -0
  36. package/dist/cli.js +0 -2
  37. package/dist/marketplace/cli.d.ts +10 -7
  38. package/dist/marketplace/cli.js +20 -10
  39. package/dist/marketplace/marketplace.d.ts +46 -24
  40. package/dist/marketplace/marketplace.js +232 -60
  41. package/dist/pack/cli.d.ts +3 -10
  42. package/dist/pack/cli.js +3 -40
  43. package/dist/pack/config-schemas.d.ts +34 -0
  44. package/dist/pack/config-schemas.js +151 -0
  45. package/dist/pack/index.d.ts +2 -2
  46. package/dist/pack/index.js +2 -2
  47. package/dist/pack/pack.d.ts +8 -2
  48. package/dist/pack/pack.js +154 -38
  49. package/package.json +4 -4
  50. package/dist/pack/bootstrap.d.ts +0 -25
  51. package/dist/pack/bootstrap.js +0 -70
@@ -1,70 +0,0 @@
1
- import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
2
- import { tmpdir } from "node:os";
3
- import { join } from "node:path";
4
- import { bootstrapFileName, parseBootstrapManifest } from "@capybara-hq/plugin-sdk";
5
- import { integrityOf } from "../integrity.js";
6
- import { DEFAULT_NPM_REGISTRY, downloadPinnedNpmPackage } from "./npm.js";
7
- import { packPlugin } from "./pack.js";
8
- /**
9
- * Produces the bootstrap directory the image bakes (package ecosystem spec §7): every entry of the
10
- * bootstrap manifest (`packages/kernel/bootstrap.json`) as `<outDir>/<name>-<version>.tgz`. A
11
- * `source: "workspace"` entry is packed from `<repoRoot>/<path>` with {@link packPlugin}
12
- * (byte-reproducible) and must equal the entry: the plugin name, the version and the pinned sha512,
13
- * otherwise this throws naming the plugin and writes nothing for it (the image build fails rather
14
- * than baking a package `capybara bootstrap` would refuse). A `source: "npm"` entry is downloaded
15
- * from `opts.registry` (default the public npm registry, the kernel's `packages.npmRegistry`
16
- * default; `opts.token` goes to the registry origin only) and written only when its bytes match
17
- * the pinned sha512 and its package.json names the entry's package and version; a tampered,
18
- * mislabelled or oversized (`bootstrap.too_large`) tarball or an unpublished package or version
19
- * throws naming the plugin. So npm entries need the network at
20
- * build time only: init installs from the baked directory and never downloads.
21
- */
22
- export async function packBootstrap(manifestFile, repoRoot, outDir, opts = {}) {
23
- const parsed = parseBootstrapManifest(JSON.parse(await readFile(manifestFile, "utf8")));
24
- if ("errors" in parsed) {
25
- throw new Error(`invalid bootstrap manifest ${manifestFile}: ${parsed.errors.join("; ")}`);
26
- }
27
- await mkdir(outDir, { recursive: true });
28
- const staging = await mkdtemp(join(tmpdir(), "pack-bootstrap-"));
29
- const out = [];
30
- try {
31
- for (const e of parsed.plugins) {
32
- if (e.source === "npm") {
33
- let bytes;
34
- try {
35
- bytes = await downloadPinnedNpmPackage(e, opts.registry ?? DEFAULT_NPM_REGISTRY, {
36
- ...(opts.token !== undefined && { token: opts.token }),
37
- ...(opts.maxBytes !== undefined && { maxBytes: opts.maxBytes }),
38
- });
39
- }
40
- catch (err) {
41
- throw new Error(`${e.name}: ${err instanceof Error ? err.message : String(err)}`, {
42
- cause: err,
43
- });
44
- }
45
- const file = join(outDir, bootstrapFileName(e));
46
- await writeFile(file, bytes);
47
- out.push({ name: e.name, version: e.version, file, integrity: e.integrity });
48
- continue;
49
- }
50
- const r = await packPlugin(join(repoRoot, e.path), staging);
51
- const integrity = integrityOf(new Uint8Array(await readFile(r.file)));
52
- const problems = [
53
- r.manifest.name !== e.name && `${e.path} packs the plugin "${r.manifest.name}"`,
54
- r.manifest.version !== e.version &&
55
- `version is ${e.version} but ${e.path} packs ${r.manifest.version}`,
56
- integrity !== e.integrity && `integrity is ${e.integrity} but ${e.path} packs ${integrity}`,
57
- ].filter((p) => typeof p === "string");
58
- if (problems.length > 0) {
59
- throw new Error(`${e.name}: ${problems.join("; ")}; the bootstrap manifest is stale (pnpm check:bootstrap --write)`);
60
- }
61
- const file = join(outDir, bootstrapFileName(e));
62
- await copyFile(r.file, file);
63
- out.push({ name: e.name, version: e.version, file, integrity });
64
- }
65
- }
66
- finally {
67
- await rm(staging, { recursive: true, force: true });
68
- }
69
- return out;
70
- }