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:
|
||||
push:
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
updatehost:
|
||||
host:
|
||||
if: github.repository == 'LNReader/lnreader-sources'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Update plugins host
|
||||
- name: Host plugins
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
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'
|
||||
$exists=$(git show-ref refs/heads/$dist)
|
||||
|
||||
echo $current
|
||||
echo $exists
|
||||
|
||||
if ($exists){
|
||||
git checkout $dist
|
||||
}else{
|
||||
## Make a new one
|
||||
git checkout -b $dist
|
||||
git branch -D $dist
|
||||
}
|
||||
|
||||
git checkout --orphan $dist
|
||||
|
||||
if(-Not $?){
|
||||
# If checkout failed
|
||||
echo "=========="
|
||||
@@ -19,14 +15,14 @@ if(-Not $?){
|
||||
exit 1
|
||||
}
|
||||
|
||||
git merge $current --strategy-option theirs
|
||||
|
||||
git reset
|
||||
rm -r -fo .js
|
||||
npm run clearMultisrc
|
||||
npm run generate
|
||||
npm run json
|
||||
git add .
|
||||
git add -f .dist .js/plugins
|
||||
git commit -m "Update plugins host"
|
||||
git add -f icons .dist .js/plugins
|
||||
git commit -m "Host plugins"
|
||||
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`
|
||||
|
||||
if [ -n "$exists" ]; then
|
||||
git checkout $dist
|
||||
else
|
||||
git checkout -b $dist
|
||||
git branch -D $dist
|
||||
fi
|
||||
|
||||
git checkout --orphan $dist
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
# If checkout failed
|
||||
echo "=========="
|
||||
@@ -15,15 +15,14 @@ if [ $? -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git merge $current --strategy-option theirs
|
||||
|
||||
npm run clearMulti
|
||||
git reset
|
||||
rm -rf .js
|
||||
npm run clearMultisrc
|
||||
npm run generate
|
||||
npm run json
|
||||
git add .
|
||||
git add -f .dist .js/plugins
|
||||
git commit -m "Update plugins host"
|
||||
git add -f icons .dist .js/plugins
|
||||
git commit -m "Host plugins"
|
||||
git push -f origin $dist
|
||||
|
||||
git checkout $current
|
||||
git checkout -f $current
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ app.post("/popularNovels/", async (req, res) => {
|
||||
filters,
|
||||
});
|
||||
res.json(novels);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
} catch (err: unknown) {
|
||||
res.json({ error: String(err) });
|
||||
}
|
||||
});
|
||||
app.post("/searchNovels/", async (req, res) => {
|
||||
@@ -84,8 +84,8 @@ app.post("/searchNovels/", async (req, res) => {
|
||||
req.body["searchTerm"]
|
||||
);
|
||||
res.json(novels);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
} catch (err: unknown) {
|
||||
res.json({ error: String(err) });
|
||||
}
|
||||
});
|
||||
app.post("/parseNovelAndChapters/", async (req, res) => {
|
||||
@@ -95,8 +95,8 @@ app.post("/parseNovelAndChapters/", async (req, res) => {
|
||||
req.body["novelUrl"]
|
||||
);
|
||||
res.json(sourceNovel);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
} catch (err: unknown) {
|
||||
res.json({ error: String(err) });
|
||||
}
|
||||
});
|
||||
app.post("/parseChapter/", async (req, res) => {
|
||||
@@ -106,8 +106,8 @@ app.post("/parseChapter/", async (req, res) => {
|
||||
req.body["chapterUrl"]
|
||||
);
|
||||
res.send(chapterText);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
} catch (err: unknown) {
|
||||
res.json({ error: String(err) });
|
||||
}
|
||||
});
|
||||
app.post("/fetchImage/", async (req, res) => {
|
||||
@@ -117,8 +117,8 @@ app.post("/fetchImage/", async (req, res) => {
|
||||
req.body["url"]
|
||||
);
|
||||
res.send(base64);
|
||||
} catch (err) {
|
||||
res.json({ error: err });
|
||||
} catch (err: unknown) {
|
||||
res.json({ error: String(err) });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
"test": "exit 0",
|
||||
"json": "tsc && node ./.js/scripts/json_plugins.js",
|
||||
"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",
|
||||
"host-linux": "chmod +x ./host.sh && ./host.sh",
|
||||
"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")
|
||||
.toString()
|
||||
.replace(/[\s\n]/g, "");
|
||||
const CURRENT_BRANCH = execSync("git rev-parse --abbrev-ref HEAD")
|
||||
.toString()
|
||||
.replace(/[\s\n]/g, "");
|
||||
const USERNAME = REMOTE.split("/")[3].trim();
|
||||
const REPO = REMOTE.split("/")[4]
|
||||
.trim()
|
||||
.replace(/\.git$/, "");
|
||||
let CURRENT_BRANCH = 'dist';
|
||||
try {
|
||||
CURRENT_BRANCH = execSync("git rev-parse --abbrev-ref HEAD")
|
||||
.toString()
|
||||
.replace(/[\s\n]/g, "");
|
||||
}catch {
|
||||
//
|
||||
}
|
||||
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 ICON_LINK = `${USER_CONTENT_LINK}/icons`;
|
||||
|
||||
Reference in New Issue
Block a user