@crombolo/backoffice-host 0.30.3 → 0.33.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/backoffice-host",
3
- "version": "0.30.3",
3
+ "version": "0.33.0",
4
4
  "description": "Serves the Umbraco backoffice SPA: shell HTML, import map and package manifests.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@crombolo/core": "0.30.3",
34
+ "@crombolo/core": "0.33.0",
35
35
  "@crombolo/backoffice-dist": "18.2.0"
36
36
  }
37
37
  }
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo App Preview",
4
4
  "id": "Crombolo.AppPreview",
5
- "version": "0.30.3",
5
+ "version": "0.33.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Localizations",
4
4
  "id": "Crombolo.Localizations",
5
- "version": "0.30.3",
5
+ "version": "0.33.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Search & sharing",
4
4
  "id": "Crombolo.Seo",
5
- "version": "0.30.3",
5
+ "version": "0.33.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo Sign-in Dialog",
4
4
  "id": "Crombolo.SignInDialog",
5
- "version": "0.30.3",
5
+ "version": "0.33.0",
6
6
  "allowPublicAccess": true,
7
7
  "extensions": [
8
8
  {
@@ -2,7 +2,7 @@
2
2
  "$schema": "../../backoffice-dist/dist/umbraco-package-schema.json",
3
3
  "name": "Crombolo",
4
4
  "id": "Crombolo.Core",
5
- "version": "0.30.3",
5
+ "version": "0.33.0",
6
6
  "allowPublicAccess": false,
7
7
  "extensions": [
8
8
  {
@@ -7,7 +7,7 @@
7
7
  * bundle is.
8
8
  */
9
9
  import { existsSync, readFileSync, statSync } from 'node:fs'
10
- import { dirname, isAbsolute, join, normalize, sep } from 'node:path'
10
+ import { dirname, join, normalize } from 'node:path'
11
11
  import type { PackageManifestImportmap } from './manifests.ts'
12
12
 
13
13
  /** The package a bundle declares its peer range on. */
@@ -20,7 +20,7 @@ export const CORE_PACKAGE = '@crombolo/crombolo'
20
20
  */
21
21
  export const BUNDLE_ID = /^[a-z][a-z0-9-]{1,38}$/
22
22
 
23
- /** The `content` payload: always `bundle.json` inside the named directory. */
23
+ /** The payload's manifest, at the package root (story 193). */
24
24
  export const PAYLOAD_MANIFEST = 'bundle.json'
25
25
 
26
26
  /** An exported binding name: what a site imports to wire the server half. */
@@ -35,8 +35,8 @@ export interface CromboloField {
35
35
  /** The backoffice half: Umbraco extension manifests. */
36
36
  extensions?: unknown[]
37
37
  importmap?: PackageManifestImportmap
38
- /** A directory inside the package holding a `bundle.json` payload. */
39
- content?: string
38
+ /** The package carries content: `bundle.json` at its root, and what it lists beside it. */
39
+ content?: true
40
40
  /** The factory the package exports for the server half. Never imported by core. */
41
41
  server?: string
42
42
  /**
@@ -57,7 +57,7 @@ export interface BundlePackage {
57
57
  peerRange: string
58
58
  private: boolean
59
59
  field: CromboloField
60
- /** Absolute path of the payload directory, when the bundle carries content. */
60
+ /** The package's directory, when it carries content: the payload is the package. */
61
61
  contentDir: string | undefined
62
62
  carries: { extensions: boolean; content: boolean; server: boolean }
63
63
  }
@@ -92,14 +92,6 @@ export function declaresBundle(json: PackageJson | undefined): boolean {
92
92
  return Boolean(json?.crombolo) && json?.name !== CORE_PACKAGE
93
93
  }
94
94
 
95
- /** A relative path that stays inside the package. */
96
- function insidePackage(directory: string, relative: string): string | undefined {
97
- if (relative === '' || isAbsolute(relative) || relative.includes('\0')) return undefined
98
- const root = directory.endsWith(sep) ? directory : `${directory}${sep}`
99
- const target = normalize(join(directory, relative))
100
- return target === normalize(directory) || target.startsWith(root) ? target : undefined
101
- }
102
-
103
95
  /**
104
96
  * Every reason a package's manifest is not a bundle, reported together.
105
97
  *
@@ -134,14 +126,10 @@ export function validateBundlePackage(json: PackageJson, directory?: string): st
134
126
  if (f.server !== undefined && (typeof f.server !== 'string' || !EXPORT_NAME.test(f.server)))
135
127
  problems.push('"crombolo.server" must name the factory the package exports')
136
128
  if (f.content !== undefined) {
137
- if (typeof f.content !== 'string') problems.push('"crombolo.content" must be a directory')
138
- else if (directory) {
139
- const target = insidePackage(directory, f.content)
140
- if (!target) problems.push(`"crombolo.content" (${f.content}) is outside the package`)
141
- else if (!existsSync(join(target, PAYLOAD_MANIFEST)))
142
- problems.push(`"crombolo.content" (${f.content}) holds no ${PAYLOAD_MANIFEST}`)
143
- } else if (isAbsolute(f.content) || f.content.split(/[\\/]/).includes('..'))
144
- problems.push(`"crombolo.content" (${f.content}) is outside the package`)
129
+ if (f.content !== true)
130
+ problems.push(`"crombolo.content" is true: ${PAYLOAD_MANIFEST} sits at the package root`)
131
+ else if (directory && !existsSync(join(directory, PAYLOAD_MANIFEST)))
132
+ problems.push(`it declares content, and holds no ${PAYLOAD_MANIFEST} at its root`)
145
133
  }
146
134
 
147
135
  const hasExtensions = Array.isArray(f.extensions) && f.extensions.length > 0
@@ -182,7 +170,7 @@ export function readBundlePackage(directory: string): {
182
170
  peerRange: pkg.peerDependencies?.[CORE_PACKAGE] as string,
183
171
  private: pkg.private === true,
184
172
  field,
185
- contentDir: field.content ? insidePackage(directory, field.content) : undefined,
173
+ contentDir: field.content === true ? directory : undefined,
186
174
  carries: {
187
175
  extensions: Array.isArray(field.extensions) && field.extensions.length > 0,
188
176
  content: field.content !== undefined,
@@ -244,8 +232,13 @@ export interface DiscoveredBundles {
244
232
  export function discoverBundles(siteDir: string): DiscoveredBundles {
245
233
  const json = readPackageJson(join(siteDir, 'package.json'))
246
234
  const found: DiscoveredBundles = { bundles: [], problems: [] }
247
- if (!json?.dependencies) return found
248
- for (const name of Object.keys(json.dependencies).sort()) {
235
+ // A peer is declared too: a site whose host provides `@crombolo/*` lists
236
+ // them there (story 192).
237
+ const names = new Set([
238
+ ...Object.keys(json?.dependencies ?? {}),
239
+ ...Object.keys(json?.peerDependencies ?? {}),
240
+ ])
241
+ for (const name of [...names].sort()) {
249
242
  const directory = resolvePackageDir(siteDir, name)
250
243
  if (!directory) continue
251
244
  const read = readBundlePackage(directory)