This commit is contained in:
parent
e7227844c7
commit
3ced32a4d0
19 changed files with 63 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ const NPM = `${NODE_BIN}/npm`;
|
|||
const BLOGS_ROOT = "/Users/neeldhara/forgejo/blogs";
|
||||
const ALLBLOGS_REPO = `${BLOGS_ROOT}/allblogs`;
|
||||
const MICRO_REPO = `${BLOGS_ROOT}/micro`;
|
||||
const HOME_REPO = `${BLOGS_ROOT}/home`;
|
||||
|
||||
const DEFAULT_TARGETS = [
|
||||
{
|
||||
|
|
@ -557,14 +558,41 @@ module.exports = class BlogFamilySyncPlugin extends Plugin {
|
|||
|
||||
this.updateStatusBar(`Blog sync: pushing ${target.label}...`);
|
||||
const output = await this.runShellCommand(publishCommand, repoFolder);
|
||||
|
||||
let homeOutput = "";
|
||||
if (path.resolve(target.repoFolder) === path.resolve(ALLBLOGS_REPO)) {
|
||||
homeOutput = await this.publishHomeIndex();
|
||||
}
|
||||
|
||||
this.updateStatusBar("Blog sync: published");
|
||||
new Notice(
|
||||
output.includes("No staged changes")
|
||||
? `No ${target.label} changes to publish.`
|
||||
: `${target.label} changes pushed.`,
|
||||
[
|
||||
output.includes("No staged changes")
|
||||
? `No ${target.label} changes to publish.`
|
||||
: `${target.label} changes pushed.`,
|
||||
homeOutput
|
||||
? homeOutput.includes("No homepage index changes")
|
||||
? "Homepage index unchanged."
|
||||
: "Homepage index pushed."
|
||||
: "",
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" "),
|
||||
);
|
||||
}
|
||||
|
||||
async publishHomeIndex() {
|
||||
this.updateStatusBar("Blog sync: refreshing homepage index...");
|
||||
const command = [
|
||||
`${shellQuote(NPM)} run refresh:index`,
|
||||
"git add content/blog-index.json",
|
||||
'if git diff --cached --quiet; then echo "No homepage index changes to publish."; else git commit -m "Refresh homepage blog index"; fi',
|
||||
"git push",
|
||||
].join(" && ");
|
||||
|
||||
return await this.runShellCommand(command, HOME_REPO);
|
||||
}
|
||||
|
||||
async ensureDevServer(target) {
|
||||
const baseUrl = normalizeBaseUrl(target.devServerUrl);
|
||||
if (await urlResponds(baseUrl)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue