@lightnet/sveltia-admin 4.0.3 → 4.0.5
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @lightnet/sveltia-admin
|
|
2
2
|
|
|
3
|
+
## 4.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#382](https://github.com/LightNetDev/LightNet/pull/382) [`c6c8f31`](https://github.com/LightNetDev/LightNet/commit/c6c8f31adf464a842739f2b99d858aa0ba5d43e9) Thanks [@smn-cds](https://github.com/smn-cds)! - Update dependencies
|
|
8
|
+
|
|
9
|
+
- [#382](https://github.com/LightNetDev/LightNet/pull/382) [`c6c8f31`](https://github.com/LightNetDev/LightNet/commit/c6c8f31adf464a842739f2b99d858aa0ba5d43e9) Thanks [@smn-cds](https://github.com/smn-cds)! - Add experimental support for Cloudflare-R2 through sveltia admin
|
|
10
|
+
|
|
11
|
+
## 4.0.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#380](https://github.com/LightNetDev/LightNet/pull/380) [`4efb5b5`](https://github.com/LightNetDev/LightNet/commit/4efb5b5bf4fccc1f6314911e1cfb395c0488ff98) Thanks [@smn-cds](https://github.com/smn-cds)! - Update dependencies
|
|
16
|
+
|
|
17
|
+
- [#380](https://github.com/LightNetDev/LightNet/pull/380) [`4efb5b5`](https://github.com/LightNetDev/LightNet/commit/4efb5b5bf4fccc1f6314911e1cfb395c0488ff98) Thanks [@smn-cds](https://github.com/smn-cds)! - Update pnpm settings to make supply chain attacks less likely
|
|
18
|
+
|
|
3
19
|
## 4.0.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Admin UI for LightNet based on Sveltia CMS.",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.5",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"astro": "^6.0.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@sveltia/cms": "0.
|
|
37
|
-
"lightnet": "^4.0.
|
|
36
|
+
"@sveltia/cms": "0.156.1",
|
|
37
|
+
"lightnet": "^4.0.8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@internal/e2e-test-utils": "^0.0.1",
|
|
41
40
|
"@playwright/test": "^1.59.1",
|
|
42
|
-
"astro": "^6.1.
|
|
41
|
+
"astro": "^6.1.8",
|
|
43
42
|
"typescript": "^5.9.3",
|
|
44
|
-
"vitest": "^4.1.4"
|
|
43
|
+
"vitest": "^4.1.4",
|
|
44
|
+
"@internal/e2e-test-utils": "^0.0.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22"
|
|
@@ -5,40 +5,53 @@ const normalizeAdminPath = (path: string) => path.replace(/^\/+|\/+$/g, "")
|
|
|
5
5
|
/**
|
|
6
6
|
* @see https://sveltiacms.app/en/docs/backends/gitlab
|
|
7
7
|
*/
|
|
8
|
-
const gitlabSchema = z
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
.transform((gitlabConfig) => ({
|
|
17
|
-
...gitlabConfig,
|
|
18
|
-
app_id: gitlabConfig.appId,
|
|
19
|
-
auth_type: gitlabConfig.authType,
|
|
20
|
-
}))
|
|
8
|
+
const gitlabSchema = z.object({
|
|
9
|
+
name: z.literal("gitlab"),
|
|
10
|
+
repo: z.string(),
|
|
11
|
+
appId: z.string().optional(),
|
|
12
|
+
branch: z.string().default("main"),
|
|
13
|
+
authType: z.literal("pkce").default("pkce"),
|
|
14
|
+
})
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* @see https://sveltiacms.app/en/docs/backends/github
|
|
24
18
|
*/
|
|
25
|
-
const githubSchema = z
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
.transform((githubConfig) => ({
|
|
33
|
-
...githubConfig,
|
|
34
|
-
base_url: githubConfig.baseUrl,
|
|
35
|
-
}))
|
|
19
|
+
const githubSchema = z.object({
|
|
20
|
+
name: z.literal("github"),
|
|
21
|
+
repo: z.string(),
|
|
22
|
+
baseUrl: z.string().optional(),
|
|
23
|
+
branch: z.string().default("main"),
|
|
24
|
+
})
|
|
36
25
|
|
|
37
26
|
// Internal testing backend used by the Playwright harness.
|
|
38
27
|
const testRepoSchema = z.object({
|
|
39
28
|
name: z.literal("test-repo"),
|
|
40
29
|
})
|
|
41
30
|
|
|
31
|
+
const r2Storage = z.object({
|
|
32
|
+
name: z.literal("cloudflare-r2"),
|
|
33
|
+
/**
|
|
34
|
+
* R2 Access Key ID (64 hex characters). Safe to store in config.
|
|
35
|
+
*/
|
|
36
|
+
accessKeyId: z.string(),
|
|
37
|
+
/**
|
|
38
|
+
* The R2 bucket name.
|
|
39
|
+
*/
|
|
40
|
+
bucket: z.string(),
|
|
41
|
+
/**
|
|
42
|
+
* Your Cloudflare account ID. Used to construct the S3 API endpoint.
|
|
43
|
+
*/
|
|
44
|
+
accountId: z.string(),
|
|
45
|
+
/**
|
|
46
|
+
* Public URL for asset previews and downloads. Required because the R2 S3 API always requires authentication.
|
|
47
|
+
*/
|
|
48
|
+
publicUrl: z.string(),
|
|
49
|
+
/**
|
|
50
|
+
* Path prefix within the bucket, e.g. uploads/.
|
|
51
|
+
*/
|
|
52
|
+
prefix: z.string().optional(),
|
|
53
|
+
})
|
|
54
|
+
|
|
42
55
|
export const adminConfigSchema = z.object({
|
|
43
56
|
/**
|
|
44
57
|
* Path for the admin page.
|
|
@@ -83,7 +96,7 @@ export const adminConfigSchema = z.object({
|
|
|
83
96
|
* `lightnet({ languages })`.
|
|
84
97
|
*
|
|
85
98
|
* @example
|
|
86
|
-
* import languages from "./languages.json"
|
|
99
|
+
* import languages from "./languages.json"
|
|
87
100
|
*
|
|
88
101
|
* export default defineConfig({
|
|
89
102
|
* integrations: [
|
|
@@ -100,6 +113,10 @@ export const adminConfigSchema = z.object({
|
|
|
100
113
|
* migration path.
|
|
101
114
|
*/
|
|
102
115
|
useLanguagesCollection: z.boolean().default(false),
|
|
116
|
+
/**
|
|
117
|
+
* Use Cloudflare r2 for content uploads.
|
|
118
|
+
*/
|
|
119
|
+
fileStorage: r2Storage.optional(),
|
|
103
120
|
})
|
|
104
121
|
.optional(),
|
|
105
122
|
})
|
|
@@ -60,14 +60,7 @@ export const mediaItemCollection: Collection = {
|
|
|
60
60
|
label: "File",
|
|
61
61
|
widget: "file",
|
|
62
62
|
choose_url: false,
|
|
63
|
-
|
|
64
|
-
public_folder: "/files",
|
|
65
|
-
hint: `Maximum file size is ${sveltiaAdminConfig.maxFileSize} MB.`,
|
|
66
|
-
media_library: {
|
|
67
|
-
config: {
|
|
68
|
-
max_file_size: sveltiaAdminConfig.maxFileSize * 1000000,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
63
|
+
...getFileStorage(),
|
|
71
64
|
},
|
|
72
65
|
inlineTranslation({
|
|
73
66
|
name: "label",
|
|
@@ -162,3 +155,31 @@ export const mediaItemCollection: Collection = {
|
|
|
162
155
|
},
|
|
163
156
|
],
|
|
164
157
|
}
|
|
158
|
+
|
|
159
|
+
function getFileStorage() {
|
|
160
|
+
const externalFileStorage = sveltiaAdminConfig.experimental?.fileStorage
|
|
161
|
+
if (!externalFileStorage) {
|
|
162
|
+
return {
|
|
163
|
+
media_folder: projectPath("public/files"),
|
|
164
|
+
public_folder: "/files",
|
|
165
|
+
hint: `Maximum file size is ${sveltiaAdminConfig.maxFileSize} MB.`,
|
|
166
|
+
media_library: {
|
|
167
|
+
config: {
|
|
168
|
+
max_file_size: sveltiaAdminConfig.maxFileSize * 1000000,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
media_libraries: {
|
|
176
|
+
default: false,
|
|
177
|
+
cloudflare_r2: {
|
|
178
|
+
...externalFileStorage,
|
|
179
|
+
access_key_id: externalFileStorage.accessKeyId,
|
|
180
|
+
account_id: externalFileStorage.accountId,
|
|
181
|
+
public_url: externalFileStorage.publicUrl,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CmsConfig } from "@sveltia/cms"
|
|
1
|
+
import type { Backend, CmsConfig } from "@sveltia/cms"
|
|
2
2
|
import { site } from "astro:config/server"
|
|
3
3
|
import sveltiaAdminConfig from "virtual:lightnet/sveltiaAdminConfig"
|
|
4
4
|
|
|
@@ -11,10 +11,7 @@ export function getConfig(
|
|
|
11
11
|
siteUrl = process.env.LIGHTNET_DEV_SITE_URL ?? site,
|
|
12
12
|
): CmsConfig {
|
|
13
13
|
return {
|
|
14
|
-
backend:
|
|
15
|
-
name: "github",
|
|
16
|
-
repo: createLocalRepoPath(),
|
|
17
|
-
},
|
|
14
|
+
backend: getBackend(),
|
|
18
15
|
media_folder: projectPath("src/assets"),
|
|
19
16
|
public_folder: "/src/assets",
|
|
20
17
|
app_title: "LightNet Admin",
|
|
@@ -58,6 +55,33 @@ export function getConfig(
|
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
|
|
58
|
+
function getBackend(): Backend {
|
|
59
|
+
const { backend } = sveltiaAdminConfig
|
|
60
|
+
|
|
61
|
+
if (!backend) {
|
|
62
|
+
return {
|
|
63
|
+
name: "github",
|
|
64
|
+
repo: createLocalRepoPath(),
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (backend.name === "github") {
|
|
69
|
+
return {
|
|
70
|
+
...backend,
|
|
71
|
+
base_url: backend.baseUrl,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (backend.name === "gitlab") {
|
|
76
|
+
return {
|
|
77
|
+
...backend,
|
|
78
|
+
app_id: backend.appId,
|
|
79
|
+
auth_type: backend.authType,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return backend
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
// Sveltia CMS uses repo as unique site identifier for IndexedDB
|
|
62
86
|
// https://github.com/sveltia/sveltia-cms/issues/630
|
|
63
87
|
// Also it expects repo in format <org>/<repo>
|