mktcms 0.2.3 → 0.2.4
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 +5 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -1
- package/dist/runtime/server/api/admin/md.post.js +9 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,8 +42,13 @@ NUXT_MKTCMS_SMTP_USER="your-smtp-user"
|
|
|
42
42
|
NUXT_MKTCMS_SMTP_PASS="your-smtp-pass"
|
|
43
43
|
NUXT_MKTCMS_MAILER_FROM="your-mailer-from-address"
|
|
44
44
|
NUXT_MKTCMS_MAILER_TO="your-mailer-to-address"
|
|
45
|
+
NUXT_MKTCMS_GIT_USER="your-github-username"
|
|
46
|
+
NUXT_MKTCMS_GIT_REPO="owner/repository.git"
|
|
47
|
+
NUXT_MKTCMS_GIT_TOKEN="your-github-personal-access-token"
|
|
45
48
|
```
|
|
46
49
|
|
|
50
|
+
> **Note:** To generate a GitHub Personal Access Token, go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token. Grant it `repo` scope for full repository access.
|
|
51
|
+
|
|
47
52
|
## Usage
|
|
48
53
|
|
|
49
54
|
```
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -21,7 +21,10 @@ const module$1 = defineNuxtModule({
|
|
|
21
21
|
smtpUser: "",
|
|
22
22
|
smtpPass: "",
|
|
23
23
|
mailerFrom: "",
|
|
24
|
-
mailerTo: ""
|
|
24
|
+
mailerTo: "",
|
|
25
|
+
gitUser: "",
|
|
26
|
+
gitRepo: "",
|
|
27
|
+
gitToken: ""
|
|
25
28
|
}));
|
|
26
29
|
_nuxt.options.runtimeConfig.public.mktcms = defu((_nuxt.options.runtimeConfig.public.mktcms, {
|
|
27
30
|
siteUrl: ""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineEventHandler, getValidatedQuery, readValidatedBody } from "h3";
|
|
3
|
-
import { useStorage } from "nitropack/runtime";
|
|
3
|
+
import { useStorage, useRuntimeConfig } from "nitropack/runtime";
|
|
4
4
|
import { stringify } from "yaml";
|
|
5
5
|
import { simpleGit } from "simple-git";
|
|
6
6
|
const querySchema = z.object({
|
|
@@ -27,13 +27,17 @@ export default defineEventHandler(async (event) => {
|
|
|
27
27
|
const content = buildContent(frontmatter, markdown);
|
|
28
28
|
const storage = useStorage("content");
|
|
29
29
|
await storage.setItem(decodedPath, content);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const { mktcms: { gitToken, gitUser, gitRepo } } = useRuntimeConfig();
|
|
31
|
+
if (!gitToken || !gitUser || !gitRepo) {
|
|
32
|
+
throw new Error("Missing Git auth config: NUXT_MKTCMS_GIT_USER, NUXT_MKTCMS_GIT_REPO, NUXT_MKTCMS_GIT_TOKEN");
|
|
33
|
+
}
|
|
34
|
+
const git = simpleGit();
|
|
35
|
+
git.addConfig("user.name", "Kunde").addConfig("user.email", "admin@mktcode.de");
|
|
33
36
|
try {
|
|
34
37
|
await git.add(".");
|
|
35
38
|
await git.commit(commitMessage || `\xC4nderung durch Kunden`);
|
|
36
|
-
|
|
39
|
+
const authUrl = `https://${encodeURIComponent(gitUser)}:${encodeURIComponent(gitToken)}@github.com/${gitRepo}`;
|
|
40
|
+
await git.push([authUrl]);
|
|
37
41
|
} catch (error) {
|
|
38
42
|
console.error("Git-Fehler:", error);
|
|
39
43
|
}
|