@cardanvil/frame-kit 0.3.1 → 0.4.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 CHANGED
@@ -74,6 +74,25 @@ reports everything; under GitHub Actions they become inline annotations.
74
74
 
75
75
  Exit codes: `0` clean, `1` one or more frames failed, `2` used wrongly.
76
76
 
77
+ ### Frames you do not want to ship
78
+
79
+ A descriptor can opt its frame out of every build:
80
+
81
+ ```json
82
+ {
83
+ "id": "com.example.example",
84
+ "private": true,
85
+ "author": { "name": "Your Name" },
86
+ "license": "CC-BY-4.0"
87
+ }
88
+ ```
89
+
90
+ `validate` still loads and checks it; `build` reports it as skipped and packs
91
+ nothing, so it never reaches a bundle, the index, or a release. That is the
92
+ combination a worked example needs — a reference frame stays in the repository
93
+ and stays correct, without an `id` that is permanent identity ending up in
94
+ somebody's release by accident.
95
+
77
96
  ### `--watch`
78
97
 
79
98
  `build --watch` builds once, then rebuilds only the frames whose files changed,
@@ -25,6 +25,8 @@ export interface BuiltFrame {
25
25
  }
26
26
  export interface BuildResult {
27
27
  frames: BuiltFrame[];
28
+ /** Frames marked `private` in their descriptor. Checked, then left alone. */
29
+ skipped: LoadedFrame[];
28
30
  /** Written to `<out>/frame-index.json` unless nothing built. */
29
31
  index?: FrameIndex;
30
32
  }
package/dist/cli/build.js CHANGED
@@ -5,6 +5,7 @@ import { DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, } from "../schema/frame.js
5
5
  import { loadFrames } from "./api.js";
6
6
  import { copyFileAtomic, writeFileAtomic } from "./atomic.js";
7
7
  import { describeBytes, writeBundle } from "./bundle.js";
8
+ import { relativePosix } from "./discover.js";
8
9
  import { PackagingError } from "./errors.js";
9
10
  import { FRAME_INDEX_FILENAME, buildIndex, downloadBase, } from "./frameIndex.js";
10
11
  import { hashFile, mapWithConcurrency } from "./hash.js";
@@ -29,17 +30,33 @@ existingServer) {
29
30
  `optionally with a pre-release suffix.`);
30
31
  }
31
32
  const loaded = await loadFrames(options, reporter, existingServer);
33
+ // Validated above like any other frame, then dropped: `private` says this
34
+ // one exists to be read, not shipped.
35
+ const skipped = loaded.filter((frame) => frame.discovered.meta.private);
36
+ const shippable = loaded.filter((frame) => !frame.discovered.meta.private);
37
+ for (const frame of skipped) {
38
+ // Silence would look like a broken build to whoever asked for this frame
39
+ // by name. Frames merely swept up by a whole-repository build say nothing.
40
+ if (options.only?.includes(frame.discovered.slug)) {
41
+ reporter.warn({
42
+ frame: frame.discovered.slug,
43
+ file: relativePosix(path.resolve(options.root), frame.discovered.metaFile),
44
+ message: `is private, so it was not built. Remove "private" from its ` +
45
+ `frame.meta.json to ship it.`,
46
+ });
47
+ }
48
+ }
32
49
  const outDir = path.resolve(options.outDir);
33
50
  await mkdir(outDir, { recursive: true });
34
51
  const built = [];
35
- for (const frame of loaded) {
52
+ for (const frame of shippable) {
36
53
  const result = await buildOne(frame, outDir, options, reporter);
37
54
  if (result) {
38
55
  built.push(result);
39
56
  }
40
57
  }
41
58
  if (built.length === 0) {
42
- return { frames: built };
59
+ return { frames: built, skipped };
43
60
  }
44
61
  const index = buildIndex({
45
62
  version: options.version,
@@ -50,7 +67,7 @@ existingServer) {
50
67
  frames: built.map((frame) => frame.entry),
51
68
  });
52
69
  await writeFileAtomic(path.join(outDir, FRAME_INDEX_FILENAME), stableStringify(index));
53
- return { frames: built, index };
70
+ return { frames: built, skipped, index };
54
71
  }
55
72
  async function buildOne(loaded, outDir, options, reporter) {
56
73
  const slug = loaded.discovered.slug;
package/dist/cli/main.js CHANGED
@@ -35,7 +35,8 @@ build only:
35
35
  in the index
36
36
  --watch rebuild a frame whenever its source changes
37
37
 
38
- A frame is any directory containing a frame.meta.json.
38
+ A frame is any directory containing a frame.meta.json. One with "private": true
39
+ is checked by validate but never built.
39
40
  `;
40
41
  /** 0 clean · 1 one or more frames failed · 2 the command was used wrongly. */
41
42
  const EXIT = { ok: 0, failed: 1, usage: 2 };
@@ -119,7 +120,7 @@ async function runBuild(root, only, values) {
119
120
  return EXIT.ok;
120
121
  }
121
122
  const reporter = new Reporter();
122
- const { frames: built } = await buildFrames({
123
+ const { frames: built, skipped } = await buildFrames({
123
124
  root,
124
125
  only,
125
126
  outDir: values.out,
@@ -140,6 +141,11 @@ async function runBuild(root, only, values) {
140
141
  bundle: frame.bundleName,
141
142
  bytes: frame.bytes,
142
143
  })),
144
+ skipped: skipped.map((frame) => ({
145
+ id: frame.discovered.meta.id,
146
+ slug: frame.discovered.slug,
147
+ reason: "private",
148
+ })),
143
149
  problems: reporter.problems,
144
150
  }, null, 2));
145
151
  }
@@ -148,6 +154,9 @@ async function runBuild(root, only, values) {
148
154
  for (const frame of built) {
149
155
  console.log(`${frame.bundleName} ${describeBytes(frame.bytes)}`);
150
156
  }
157
+ for (const frame of skipped) {
158
+ console.log(`${frame.discovered.slug} skipped (private)`);
159
+ }
151
160
  summarise(reporter, built.length);
152
161
  }
153
162
  return reporter.ok ? EXIT.ok : EXIT.failed;
package/dist/cli/watch.js CHANGED
@@ -156,6 +156,9 @@ export async function slugsFor(root, changed, only) {
156
156
  if (!owner) {
157
157
  return undefined; // outside every frame — something shared changed
158
158
  }
159
+ if (owner.meta.private) {
160
+ continue; // a build would skip it anyway; do not announce a rebuild
161
+ }
159
162
  if (wanted.size === 0 || wanted.has(owner.slug)) {
160
163
  slugs.add(owner.slug);
161
164
  }
@@ -14,6 +14,7 @@ export declare const FrameMetaSchema: z.ZodObject<{
14
14
  slug: z.ZodOptional<z.ZodString>;
15
15
  entry: z.ZodDefault<z.ZodString>;
16
16
  export: z.ZodDefault<z.ZodString>;
17
+ private: z.ZodDefault<z.ZodBoolean>;
17
18
  author: z.ZodObject<{
18
19
  name: z.ZodString;
19
20
  url: z.ZodOptional<z.ZodURL>;
@@ -33,6 +33,18 @@ export const FrameMetaSchema = z.object({
33
33
  entry: z.string().default("./index.ts"),
34
34
  /** Named export to read from `entry`. */
35
35
  export: z.string().default("default"),
36
+ /**
37
+ * Keeps the frame out of every build: it is never packaged, never indexed
38
+ * and never released. `validate` still loads and checks it, so a frame
39
+ * nobody ships cannot quietly rot.
40
+ *
41
+ * The author template's `example` frame is the case this exists for. It has
42
+ * to stay in the repository because `new-frame` copies it, but an id is
43
+ * permanent identity — publishing it would put the same
44
+ * `com.example.example` in every release by every author who forgot to
45
+ * delete it.
46
+ */
47
+ private: z.boolean().default(false),
36
48
  author: z.object({
37
49
  name: z.string().min(1),
38
50
  url: z.url().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardanvil/frame-kit",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "The contract Card Anvil frames are authored against: schemas, types, authoring helpers, and the distributable manifest format.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,6 +40,10 @@
40
40
  "minLength": 1,
41
41
  "type": "string"
42
42
  },
43
+ "private": {
44
+ "default": false,
45
+ "type": "boolean"
46
+ },
43
47
  "slug": {
44
48
  "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
45
49
  "type": "string"