@bygghammar/cms-platform 0.1.0 → 0.1.1

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
@@ -28,9 +28,59 @@ import { registerTranslations } from "@bygghammar/cms-platform/i18n";
28
28
  registerTranslations({ generated: TRANSLATIONS, overrides: TRANSLATION_OVERRIDES });
29
29
  ```
30
30
 
31
- ## Consuming
31
+ Host components must participate in a value the application actually uses.
32
+ Do not rely only on `import "./register-host"` because an optimized build may
33
+ remove that module when the application's `package.json` declares
34
+ `"sideEffects": false`.
32
35
 
33
- Today the package is linked through the Bun workspace (`workspace:*`), so edits
34
- are picked up instantly with no publish step. When the workspace managed npm
35
- registry is enabled, the same source publishes under the `@ws-` scope and sites
36
- switch `workspace:*` for a version range — no code changes.
36
+ ```tsx
37
+ import {
38
+ initializeHostComponents,
39
+ type HostComponents,
40
+ } from "@bygghammar/cms-platform/host";
41
+
42
+ const HOST_COMPONENTS = {
43
+ FocalImage,
44
+ LazyVideo,
45
+ FocusPicker,
46
+ RichTextEditor,
47
+ mediaLibraryQueryOptions,
48
+ useMediaUpload,
49
+ } satisfies Partial<HostComponents>;
50
+
51
+ export const BLOCK_REGISTRY = initializeHostComponents(
52
+ HOST_COMPONENTS,
53
+ () => createBlockRegistry(),
54
+ );
55
+ ```
56
+
57
+ Keep any existing registration module in the consuming application's
58
+ `sideEffects` allowlist as defence in depth until every entry point uses the
59
+ explicit contract. CSS must also remain in that allowlist.
60
+
61
+ ## Publishing
62
+
63
+ This directory is the maintained source for the public npm package. Releases
64
+ use npm Trusted Publishing from GitHub Actions; do not publish from a laptop or
65
+ create an npm token.
66
+
67
+ 1. Merge the reviewed version bump and wait for Checks to pass on `main`.
68
+ 2. Run **Actions → Publish CMS platform → Run workflow** from `main` and enter
69
+ the exact version from this package.
70
+ 3. Verify the new public version before updating consuming CMS lockfiles.
71
+
72
+ Never place an npm token or `.npmrc` in the repository. Consumers install an
73
+ explicit released version such as `@bygghammar/cms-platform@^0.1.1`.
74
+
75
+ ### Release checks and troubleshooting
76
+
77
+ The workflow type-checks the package and runs
78
+ `tests/cms-platform-host-contract.test.tsx` before requesting npm's OIDC
79
+ publishing credential. Keep Vitest's include glob compatible with both
80
+ `*.test.ts` and `*.test.tsx`; otherwise the release stops with “No test files
81
+ found” before npm is contacted.
82
+
83
+ If a release run fails, read its failed step before rerunning it. A failed run
84
+ does not publish a partial package. After a successful run, verify the public
85
+ registry reports the requested version, then update each consuming application
86
+ and its frozen lockfile in a separate pull request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bygghammar/cms-platform",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Shared CMS platform: blocks, block types, i18n core, UI primitives and design-token contract used by every Bygghammar/Voyara site.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -13,6 +13,14 @@
13
13
  "src",
14
14
  "README.md"
15
15
  ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/byggis79/devsba.git",
19
+ "directory": "packages/cms-platform"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
16
24
  "exports": {
17
25
  ".": "./src/index.ts",
18
26
  "./i18n": "./src/i18n/index.ts",
@@ -32,8 +40,10 @@
32
40
  "./blocks/registry": "./src/blocks/registry.tsx"
33
41
  },
34
42
  "peerDependencies": {
43
+ "@tanstack/react-query": ">=5",
35
44
  "lucide-react": ">=0.5.0",
36
45
  "react": ">=19",
37
- "react-dom": ">=19"
46
+ "react-dom": ">=19",
47
+ "sonner": ">=2"
38
48
  }
39
- }
49
+ }
@@ -89,6 +89,22 @@ export function registerHostComponents(components: Partial<HostComponents>): voi
89
89
  hosts = { ...hosts, ...components };
90
90
  }
91
91
 
92
+ /**
93
+ * Register a site's host components as part of constructing a value the site
94
+ * actually exports or renders.
95
+ *
96
+ * Prefer this over a side-effect-only import. Applications whose package
97
+ * metadata declares `sideEffects: false` may otherwise lose their registration
98
+ * module during an optimized build even though development still works.
99
+ */
100
+ export function initializeHostComponents<T>(
101
+ components: Partial<HostComponents>,
102
+ initialize: () => T,
103
+ ): T {
104
+ registerHostComponents(components);
105
+ return initialize();
106
+ }
107
+
92
108
  function missing(name: keyof HostComponents): never {
93
109
  throw new Error(
94
110
  `@bygghammar/cms-platform: host "${name}" is not registered. Call registerHostComponents() during site startup.`,