@crombolo/transfer 0.60.0 → 0.61.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 +3 -3
- package/src/code.ts +37 -2
- package/src/package.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/transfer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
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",
|
|
@@ -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.61.0",
|
|
32
|
+
"@crombolo/data": "0.61.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/code.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* listed in `bundle.json` and covered by its one hash like every other section.
|
|
5
5
|
* `docs/bundles.md`, "A site's bundle with code".
|
|
6
6
|
*/
|
|
7
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
7
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
8
8
|
import { isAbsolute, join, sep } from 'node:path'
|
|
9
9
|
import { loadBundle } from './load.ts'
|
|
10
10
|
import { BUNDLE_SECTIONS } from './model.ts'
|
|
@@ -42,6 +42,29 @@ export function isNeverCode(path: string): boolean {
|
|
|
42
42
|
)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/** Where installed extensions' roots sit, and the record of them (story 326; `extension-roots.ts`). */
|
|
46
|
+
export const EXTENSION_ROOTS_DIR = 'extensions'
|
|
47
|
+
export const EXTENSION_RECORD = 'crombolo.extensions.json'
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The record and each extension root's `package.json` and `bun.lock`: what a
|
|
51
|
+
* site package always carries once it has them, never a root's `node_modules`.
|
|
52
|
+
*/
|
|
53
|
+
export function extensionRootFiles(siteDir: string): string[] {
|
|
54
|
+
const out: string[] = []
|
|
55
|
+
if (existsSync(join(siteDir, EXTENSION_RECORD))) out.push(EXTENSION_RECORD)
|
|
56
|
+
const dir = join(siteDir, EXTENSION_ROOTS_DIR)
|
|
57
|
+
if (!existsSync(dir)) return out
|
|
58
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
59
|
+
if (!entry.isDirectory()) continue
|
|
60
|
+
for (const file of ['package.json', 'bun.lock']) {
|
|
61
|
+
const path = `${EXTENSION_ROOTS_DIR}/${entry.name}/${file}`
|
|
62
|
+
if (existsSync(join(siteDir, path))) out.push(path)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out
|
|
66
|
+
}
|
|
67
|
+
|
|
45
68
|
/** The site folder a bundle installed from a file is kept in (story 245). */
|
|
46
69
|
export const LOCAL_BUNDLES_DIR = 'bundles'
|
|
47
70
|
|
|
@@ -51,7 +74,8 @@ export const localBundleFileName = (name: string, version: string): string =>
|
|
|
51
74
|
|
|
52
75
|
/** The `bundles/` file a dependency's range names, as `./bundles/x.tgz` or `file:bundles/x.tgz`. */
|
|
53
76
|
export function localBundlePath(range: string | undefined): string | undefined {
|
|
54
|
-
|
|
77
|
+
// From an extension's root, two folders down, it is `file:../../bundles/x.tgz` (story 326).
|
|
78
|
+
const match = /^(?:file:)?(?:\.\/|(?:\.\.\/){2})?bundles\/([^/\\]+\.tgz)$/.exec(range ?? '')
|
|
55
79
|
return match ? `${LOCAL_BUNDLES_DIR}/${match[1]}` : undefined
|
|
56
80
|
}
|
|
57
81
|
|
|
@@ -69,6 +93,15 @@ export function localBundlesNamed(siteDir: string): string[] {
|
|
|
69
93
|
const path = localBundlePath(range)
|
|
70
94
|
if (path) named.add(path)
|
|
71
95
|
}
|
|
96
|
+
for (const root of extensionRootFiles(siteDir).filter((path) => path.endsWith('/package.json'))) {
|
|
97
|
+
const declared = JSON.parse(readFileSync(join(siteDir, root), 'utf8')) as {
|
|
98
|
+
dependencies?: Record<string, string>
|
|
99
|
+
}
|
|
100
|
+
for (const range of Object.values(declared.dependencies ?? {})) {
|
|
101
|
+
const path = localBundlePath(range)
|
|
102
|
+
if (path) named.add(path)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
72
105
|
return [...named].sort()
|
|
73
106
|
}
|
|
74
107
|
|
|
@@ -107,6 +140,8 @@ export function selectCodeFiles(
|
|
|
107
140
|
if (matched === 0) problems.push(`"${pattern}" matches no file the bundle can carry`)
|
|
108
141
|
}
|
|
109
142
|
for (const always of CODE_ALWAYS) if (existsSync(join(siteDir, always))) paths.add(always)
|
|
143
|
+
// Story 326: the record and each extension's root, which a deploy installs from.
|
|
144
|
+
for (const path of extensionRootFiles(siteDir)) paths.add(path)
|
|
110
145
|
// A bundle installed from a file (story 245) goes where its lockfile entry does.
|
|
111
146
|
for (const bundle of localBundlesNamed(siteDir))
|
|
112
147
|
if (existsSync(join(siteDir, bundle))) paths.add(bundle)
|
package/src/package.ts
CHANGED
|
@@ -113,7 +113,7 @@ export function bundlePackageJson(
|
|
|
113
113
|
bundleType: info.bundleType,
|
|
114
114
|
content: true,
|
|
115
115
|
...(info.code
|
|
116
|
-
? { server: info.code.server, schemaVersion:
|
|
116
|
+
? { server: info.code.server, schemaVersion: 6, permissions: { ...info.code.permissions } }
|
|
117
117
|
: {}),
|
|
118
118
|
},
|
|
119
119
|
}
|