Minimum the host branch (#751)
* minimum dist branch * force command * clear multisrc by npm script * refactor: action name * fix: handle plugin error * fix: handle plugin error
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: Update Plugins
|
name: Host Plugins
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -6,7 +6,7 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
updatehost:
|
host:
|
||||||
if: github.repository == 'LNReader/lnreader-sources'
|
if: github.repository == 'LNReader/lnreader-sources'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -19,7 +19,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|
||||||
- name: Update plugins host
|
- name: Host plugins
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
@@ -2,16 +2,12 @@ $current=$(git rev-parse --abbrev-ref HEAD)
|
|||||||
$dist='dist'
|
$dist='dist'
|
||||||
$exists=$(git show-ref refs/heads/$dist)
|
$exists=$(git show-ref refs/heads/$dist)
|
||||||
|
|
||||||
echo $current
|
|
||||||
echo $exists
|
|
||||||
|
|
||||||
if ($exists){
|
if ($exists){
|
||||||
git checkout $dist
|
git branch -D $dist
|
||||||
}else{
|
|
||||||
## Make a new one
|
|
||||||
git checkout -b $dist
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
git checkout --orphan $dist
|
||||||
|
|
||||||
if(-Not $?){
|
if(-Not $?){
|
||||||
# If checkout failed
|
# If checkout failed
|
||||||
echo "=========="
|
echo "=========="
|
||||||
@@ -19,14 +15,14 @@ if(-Not $?){
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
git merge $current --strategy-option theirs
|
git reset
|
||||||
|
rm -r -fo .js
|
||||||
|
npm run clearMultisrc
|
||||||
npm run generate
|
npm run generate
|
||||||
npm run json
|
npm run json
|
||||||
git add .
|
git add -f icons .dist .js/plugins
|
||||||
git add -f .dist .js/plugins
|
git commit -m "Host plugins"
|
||||||
git commit -m "Update plugins host"
|
|
||||||
git push -f origin $dist
|
git push -f origin $dist
|
||||||
|
|
||||||
git checkout $current
|
git checkout -f $current
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ dist=dist
|
|||||||
exists=`git show-ref refs/heads/$dist`
|
exists=`git show-ref refs/heads/$dist`
|
||||||
|
|
||||||
if [ -n "$exists" ]; then
|
if [ -n "$exists" ]; then
|
||||||
git checkout $dist
|
git branch -D $dist
|
||||||
else
|
|
||||||
git checkout -b $dist
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
git checkout --orphan $dist
|
||||||
|
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
# If checkout failed
|
# If checkout failed
|
||||||
echo "=========="
|
echo "=========="
|
||||||
@@ -15,15 +15,14 @@ if [ $? -eq 1 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git merge $current --strategy-option theirs
|
git reset
|
||||||
|
rm -rf .js
|
||||||
npm run clearMulti
|
npm run clearMultisrc
|
||||||
npm run generate
|
npm run generate
|
||||||
npm run json
|
npm run json
|
||||||
git add .
|
git add -f icons .dist .js/plugins
|
||||||
git add -f .dist .js/plugins
|
git commit -m "Host plugins"
|
||||||
git commit -m "Update plugins host"
|
|
||||||
git push -f origin $dist
|
git push -f origin $dist
|
||||||
|
|
||||||
git checkout $current
|
git checkout -f $current
|
||||||
|
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ app.post("/popularNovels/", async (req, res) => {
|
|||||||
filters,
|
filters,
|
||||||
});
|
});
|
||||||
res.json(novels);
|
res.json(novels);
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
res.json({ error: err });
|
res.json({ error: String(err) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.post("/searchNovels/", async (req, res) => {
|
app.post("/searchNovels/", async (req, res) => {
|
||||||
@@ -84,8 +84,8 @@ app.post("/searchNovels/", async (req, res) => {
|
|||||||
req.body["searchTerm"]
|
req.body["searchTerm"]
|
||||||
);
|
);
|
||||||
res.json(novels);
|
res.json(novels);
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
res.json({ error: err });
|
res.json({ error: String(err) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.post("/parseNovelAndChapters/", async (req, res) => {
|
app.post("/parseNovelAndChapters/", async (req, res) => {
|
||||||
@@ -95,8 +95,8 @@ app.post("/parseNovelAndChapters/", async (req, res) => {
|
|||||||
req.body["novelUrl"]
|
req.body["novelUrl"]
|
||||||
);
|
);
|
||||||
res.json(sourceNovel);
|
res.json(sourceNovel);
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
res.json({ error: err });
|
res.json({ error: String(err) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.post("/parseChapter/", async (req, res) => {
|
app.post("/parseChapter/", async (req, res) => {
|
||||||
@@ -106,8 +106,8 @@ app.post("/parseChapter/", async (req, res) => {
|
|||||||
req.body["chapterUrl"]
|
req.body["chapterUrl"]
|
||||||
);
|
);
|
||||||
res.send(chapterText);
|
res.send(chapterText);
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
res.json({ error: err });
|
res.json({ error: String(err) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.post("/fetchImage/", async (req, res) => {
|
app.post("/fetchImage/", async (req, res) => {
|
||||||
@@ -117,8 +117,8 @@ app.post("/fetchImage/", async (req, res) => {
|
|||||||
req.body["url"]
|
req.body["url"]
|
||||||
);
|
);
|
||||||
res.send(base64);
|
res.send(base64);
|
||||||
} catch (err) {
|
} catch (err: unknown) {
|
||||||
res.json({ error: err });
|
res.json({ error: String(err) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
"test": "exit 0",
|
"test": "exit 0",
|
||||||
"json": "tsc && node ./.js/scripts/json_plugins.js",
|
"json": "tsc && node ./.js/scripts/json_plugins.js",
|
||||||
"generate": "ts-node ./scripts/multisrc/generate.ts",
|
"generate": "ts-node ./scripts/multisrc/generate.ts",
|
||||||
"clearMulti": "ts-node ./scripts/clearMultisrc.ts",
|
"clearMultisrc": "find . -type f -wholename \"*plugins*\\[*\\]*.[t,j]s\" -delete",
|
||||||
"less": "npx less ./test_web/static/css/index.less ./test_web/static/css/index.css",
|
"less": "npx less ./test_web/static/css/index.less ./test_web/static/css/index.css",
|
||||||
"host-linux": "chmod +x ./host.sh && ./host.sh",
|
"host-linux": "chmod +x ./host.sh && ./host.sh",
|
||||||
"host-windows": "powershell ./host.ps1"
|
"host-windows": "powershell ./host.ps1"
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import * as path from 'path'
|
|
||||||
import * as fs from 'fs'
|
|
||||||
|
|
||||||
for (let pluginDir of ['plugins', path.join('.js', 'plugins')]){
|
|
||||||
if(fs.existsSync(pluginDir)){
|
|
||||||
fs.readdirSync(pluginDir).forEach(lang => {
|
|
||||||
const langDir = path.join(pluginDir, lang);
|
|
||||||
fs.readdirSync(langDir).forEach(plugin => {
|
|
||||||
if(plugin.includes("[") && plugin.includes("]")){
|
|
||||||
fs.unlinkSync(path.join(langDir, plugin));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+12
-7
@@ -11,13 +11,18 @@ const { execSync } = require("child_process");
|
|||||||
const REMOTE = execSync("git remote get-url origin")
|
const REMOTE = execSync("git remote get-url origin")
|
||||||
.toString()
|
.toString()
|
||||||
.replace(/[\s\n]/g, "");
|
.replace(/[\s\n]/g, "");
|
||||||
const CURRENT_BRANCH = execSync("git rev-parse --abbrev-ref HEAD")
|
let CURRENT_BRANCH = 'dist';
|
||||||
.toString()
|
try {
|
||||||
.replace(/[\s\n]/g, "");
|
CURRENT_BRANCH = execSync("git rev-parse --abbrev-ref HEAD")
|
||||||
const USERNAME = REMOTE.split("/")[3].trim();
|
.toString()
|
||||||
const REPO = REMOTE.split("/")[4]
|
.replace(/[\s\n]/g, "");
|
||||||
.trim()
|
}catch {
|
||||||
.replace(/\.git$/, "");
|
//
|
||||||
|
}
|
||||||
|
const matched = REMOTE.match(/github\.com[:/](.+?)\/(.+?)\.git/);
|
||||||
|
if(!matched) throw Error("Cant parse git url");
|
||||||
|
const USERNAME = matched[1];
|
||||||
|
const REPO = matched[2];
|
||||||
const USER_CONTENT_LINK = `https://raw.githubusercontent.com/${USERNAME}/${REPO}/${CURRENT_BRANCH}`;
|
const USER_CONTENT_LINK = `https://raw.githubusercontent.com/${USERNAME}/${REPO}/${CURRENT_BRANCH}`;
|
||||||
|
|
||||||
const ICON_LINK = `${USER_CONTENT_LINK}/icons`;
|
const ICON_LINK = `${USER_CONTENT_LINK}/icons`;
|
||||||
|
|||||||
Reference in New Issue
Block a user