@crombolo/transfer 0.33.0 → 0.34.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 +14 -0
- package/package.json +4 -4
- package/src/load.ts +9 -0
- package/src/model.ts +10 -13
- package/src/write.ts +1 -15
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @crombolo/transfer
|
|
2
|
+
|
|
3
|
+
**Internal to crombolo.** This package is published because
|
|
4
|
+
[`@crombolo/crombolo`](https://www.npmjs.com/package/@crombolo/crombolo)
|
|
5
|
+
depends on it, and its exports can change in any release, a patch included.
|
|
6
|
+
|
|
7
|
+
Import from `@crombolo/crombolo` instead:
|
|
8
|
+
|
|
9
|
+
- `@crombolo/crombolo` for a site: its config, its boot and its views.
|
|
10
|
+
- `@crombolo/crombolo/bundle` for a server bundle's author.
|
|
11
|
+
- `@crombolo/crombolo/host` for whoever runs sites.
|
|
12
|
+
|
|
13
|
+
Those three entry points carry the compatibility promise in
|
|
14
|
+
[`docs/api.md`](https://github.com/kineco-au/crombolo-cms/blob/main/docs/api.md).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/transfer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Content transfer for crombolo: bundles of content moved between environments.",
|
|
3
|
+
"version": "0.34.0",
|
|
4
|
+
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Content transfer for crombolo: bundles of content moved between environments.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
7
7
|
"homepage": "https://github.com/kineco-au/crombolo-cms#readme",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@crombolo/core": "0.
|
|
32
|
-
"@crombolo/data": "0.
|
|
31
|
+
"@crombolo/core": "0.34.0",
|
|
32
|
+
"@crombolo/data": "0.34.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/load.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type BundleValue,
|
|
24
24
|
type BundleVariant,
|
|
25
25
|
type ContentSet,
|
|
26
|
+
OLDEST_BUNDLE_FORMAT_VERSION,
|
|
26
27
|
} from './model.ts'
|
|
27
28
|
import { type BundlePeople, openPeople, type PeopleBlock, parsePeopleBlock } from './people.ts'
|
|
28
29
|
import { openBytes, parseSealParameters, unlock } from './seal.ts'
|
|
@@ -237,6 +238,10 @@ function parseManifest(text: string, problems: BundleProblem[]): BundleManifest
|
|
|
237
238
|
})
|
|
238
239
|
return undefined
|
|
239
240
|
}
|
|
241
|
+
if (formatVersion < OLDEST_BUNDLE_FORMAT_VERSION) {
|
|
242
|
+
problems.push({ file: MANIFEST_FILE, message: OLD_LAYOUT })
|
|
243
|
+
return undefined
|
|
244
|
+
}
|
|
240
245
|
const provenance = isRecord(raw.provenance) ? raw.provenance : {}
|
|
241
246
|
const selector = isRecord(raw.selector) ? raw.selector : {}
|
|
242
247
|
const dependencies = isRecord(raw.dependencies) ? raw.dependencies : {}
|
|
@@ -348,6 +353,10 @@ function parseCarries(raw: Record<string, unknown>): Partial<Record<BundleSectio
|
|
|
348
353
|
return out
|
|
349
354
|
}
|
|
350
355
|
|
|
356
|
+
/** Why a bundle in the layout before format 4 is refused, and what to do about it. */
|
|
357
|
+
export const OLD_LAYOUT =
|
|
358
|
+
'this bundle was written before crombolo 0.33.1, in a layout no longer read; rebuild it with the command that made it (bundle build, content export, export, or a created package download)'
|
|
359
|
+
|
|
351
360
|
/** Reads a bundle directory. `set` is undefined when it cannot be trusted at all. */
|
|
352
361
|
export function loadBundle(dir: string): LoadedBundle {
|
|
353
362
|
const problems: BundleProblem[] = []
|
package/src/model.ts
CHANGED
|
@@ -11,22 +11,19 @@
|
|
|
11
11
|
import type { BundlePeople, PeopleBlock } from './people.ts'
|
|
12
12
|
import type { SealParameters } from './seal.ts'
|
|
13
13
|
|
|
14
|
-
/** Bumped when a change to the shapes below stops an older reader understanding a bundle. */
|
|
15
|
-
export const BUNDLE_FORMAT_VERSION = 3
|
|
16
|
-
|
|
17
|
-
/** What a bundle with sections and nothing sealed writes: version 2 readers still read it. */
|
|
18
|
-
export const SECTIONS_FORMAT_VERSION = 2
|
|
19
|
-
|
|
20
14
|
/**
|
|
21
|
-
*
|
|
15
|
+
* Bumped when a change to the shapes below stops an older reader understanding
|
|
16
|
+
* a bundle. Every bundle is written at this version.
|
|
22
17
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* rather than failing an integrity check it cannot explain.
|
|
18
|
+
* 4 (0.33.1): `bundle.json` at the package root, with what it carries beside
|
|
19
|
+
* it, and a site's code as a section (stories 192, 193). Versions 1–3 kept the
|
|
20
|
+
* payload in `content/`, and are refused rather than read (no older layout is
|
|
21
|
+
* kept up), with a message saying to rebuild them.
|
|
28
22
|
*/
|
|
29
|
-
export const
|
|
23
|
+
export const BUNDLE_FORMAT_VERSION = 4
|
|
24
|
+
|
|
25
|
+
/** The oldest version this reader reads: the first with the payload at the package root. */
|
|
26
|
+
export const OLDEST_BUNDLE_FORMAT_VERSION = 4
|
|
30
27
|
|
|
31
28
|
/**
|
|
32
29
|
* The sections a bundle can carry beyond its content, and the directory each
|
package/src/write.ts
CHANGED
|
@@ -20,9 +20,7 @@ import {
|
|
|
20
20
|
type BundleSection,
|
|
21
21
|
type BundleValue,
|
|
22
22
|
type BundleVariant,
|
|
23
|
-
CONTENT_ONLY_FORMAT_VERSION,
|
|
24
23
|
type ContentSet,
|
|
25
|
-
SECTIONS_FORMAT_VERSION,
|
|
26
24
|
} from './model.ts'
|
|
27
25
|
import { type BundlePeople, sealPeople } from './people.ts'
|
|
28
26
|
import { type Seal, sealBytes } from './seal.ts'
|
|
@@ -367,21 +365,9 @@ function planBundle(
|
|
|
367
365
|
}
|
|
368
366
|
|
|
369
367
|
const people = options.people && seal ? sealPeople(options.people, seal) : undefined
|
|
370
|
-
// Rules a node carries beyond its content: an older reader would drop them,
|
|
371
|
-
// and a protected page it dropped would be public.
|
|
372
|
-
const nodeExtras = source.some(
|
|
373
|
-
(n) => n.access || (n.schedule?.length ?? 0) > 0 || (n.redirects?.length ?? 0) > 0,
|
|
374
|
-
)
|
|
375
368
|
const manifest: BundleManifest = {
|
|
376
369
|
...set.manifest,
|
|
377
|
-
|
|
378
|
-
// need 2, and anything sealed or a node's rules need 3.
|
|
379
|
-
formatVersion:
|
|
380
|
-
people || sealing || nodeExtras
|
|
381
|
-
? BUNDLE_FORMAT_VERSION
|
|
382
|
-
: extra.length > 0
|
|
383
|
-
? SECTIONS_FORMAT_VERSION
|
|
384
|
-
: CONTENT_ONLY_FORMAT_VERSION,
|
|
370
|
+
formatVersion: BUNDLE_FORMAT_VERSION,
|
|
385
371
|
// Without values nothing names a media file, so none is expected either.
|
|
386
372
|
blobs: (content === 'omitted' ? [] : set.manifest.blobs).map((blob) => {
|
|
387
373
|
const size = carriedSizes.get(blob.key)
|