@crombolo/backoffice-host 0.31.0 → 0.33.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/package.json +2 -2
- package/plugin/app-preview/umbraco-package.json +1 -1
- package/plugin/localizations/umbraco-package.json +1 -1
- package/plugin/seo/umbraco-package.json +1 -1
- package/plugin/sign-in/umbraco-package.json +1 -1
- package/plugin/umbraco-package.json +1 -1
- package/src/bundle-package.ts +21 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1",
|
|
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.
|
|
34
|
+
"@crombolo/core": "0.33.1",
|
|
35
35
|
"@crombolo/backoffice-dist": "18.2.0"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/bundle-package.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* bundle is.
|
|
8
8
|
*/
|
|
9
9
|
import { existsSync, readFileSync, statSync } from 'node:fs'
|
|
10
|
-
import { dirname,
|
|
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
|
|
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
|
-
/**
|
|
39
|
-
content?:
|
|
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
|
-
/**
|
|
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,14 @@ 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
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
problems.push(`
|
|
129
|
+
if (typeof f.content === 'string')
|
|
130
|
+
problems.push(
|
|
131
|
+
'it was written before crombolo 0.33.1, with its content in a folder, a layout no longer read; rebuild it with the command that made it',
|
|
132
|
+
)
|
|
133
|
+
else if (f.content !== true)
|
|
134
|
+
problems.push(`"crombolo.content" is true: ${PAYLOAD_MANIFEST} sits at the package root`)
|
|
135
|
+
else if (directory && !existsSync(join(directory, PAYLOAD_MANIFEST)))
|
|
136
|
+
problems.push(`it declares content, and holds no ${PAYLOAD_MANIFEST} at its root`)
|
|
145
137
|
}
|
|
146
138
|
|
|
147
139
|
const hasExtensions = Array.isArray(f.extensions) && f.extensions.length > 0
|
|
@@ -182,7 +174,7 @@ export function readBundlePackage(directory: string): {
|
|
|
182
174
|
peerRange: pkg.peerDependencies?.[CORE_PACKAGE] as string,
|
|
183
175
|
private: pkg.private === true,
|
|
184
176
|
field,
|
|
185
|
-
contentDir: field.content ?
|
|
177
|
+
contentDir: field.content === true ? directory : undefined,
|
|
186
178
|
carries: {
|
|
187
179
|
extensions: Array.isArray(field.extensions) && field.extensions.length > 0,
|
|
188
180
|
content: field.content !== undefined,
|
|
@@ -244,8 +236,13 @@ export interface DiscoveredBundles {
|
|
|
244
236
|
export function discoverBundles(siteDir: string): DiscoveredBundles {
|
|
245
237
|
const json = readPackageJson(join(siteDir, 'package.json'))
|
|
246
238
|
const found: DiscoveredBundles = { bundles: [], problems: [] }
|
|
247
|
-
|
|
248
|
-
|
|
239
|
+
// A peer is declared too: a site whose host provides `@crombolo/*` lists
|
|
240
|
+
// them there (story 192).
|
|
241
|
+
const names = new Set([
|
|
242
|
+
...Object.keys(json?.dependencies ?? {}),
|
|
243
|
+
...Object.keys(json?.peerDependencies ?? {}),
|
|
244
|
+
])
|
|
245
|
+
for (const name of [...names].sort()) {
|
|
249
246
|
const directory = resolvePackageDir(siteDir, name)
|
|
250
247
|
if (!directory) continue
|
|
251
248
|
const read = readBundlePackage(directory)
|