frontend
This commit is contained in:
1
maxkey-web-frontend/maxkey-web-app/scripts/_ci/README.md
Normal file
1
maxkey-web-frontend/maxkey-web-app/scripts/_ci/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Only for CI, you can delete it
|
||||
17
maxkey-web-frontend/maxkey-web-app/scripts/_ci/delon.sh
Normal file
17
maxkey-web-frontend/maxkey-web-app/scripts/_ci/delon.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# bash ./scripts/_ci/delon.sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)/../..
|
||||
|
||||
echo "Download latest @delon version"
|
||||
rm -rf delon-builds
|
||||
git clone --depth 1 https://github.com/ng-alain/delon-builds.git
|
||||
rm -rf node_modules/@delon
|
||||
rm -rf node_modules/ng-alain
|
||||
rsync -am delon-builds/ node_modules/
|
||||
NG_ALAIN_VERSION=$(node -p "require('./node_modules/ng-alain/package.json').version")
|
||||
rm -rf delon-builds
|
||||
echo "Using ng-alain version: ${NG_ALAIN_VERSION}"
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
GH=false
|
||||
DAY=false
|
||||
for ARG in "$@"; do
|
||||
case "$ARG" in
|
||||
-gh)
|
||||
GH=true
|
||||
;;
|
||||
-day)
|
||||
DAY=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "List:"
|
||||
ls -al
|
||||
|
||||
ROOT_DIR="$(pwd)"
|
||||
DIST_DIR="$(pwd)/dist"
|
||||
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
|
||||
echo "Start build version: ${VERSION}"
|
||||
|
||||
if [[ ${DAY} == true ]]; then
|
||||
echo ""
|
||||
echo "Download day @delon/* libs"
|
||||
echo ""
|
||||
bash ./scripts/_ci/delon.sh
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Generate color less"
|
||||
echo ""
|
||||
npm run color-less
|
||||
|
||||
echo ""
|
||||
echo "Generate theme files"
|
||||
echo ""
|
||||
npm run theme
|
||||
|
||||
echo '===== need mock'
|
||||
cp -f ${ROOT_DIR}/src/environments/environment.ts ${ROOT_DIR}/src/environments/environment.prod.ts
|
||||
sed -i 's/production: false/production: true/g' ${ROOT_DIR}/src/environments/environment.prod.ts
|
||||
sed -i 's/showSettingDrawer = !environment.production;/showSettingDrawer = true;/g' ${ROOT_DIR}/src/app/layout/basic/basic.component.ts
|
||||
|
||||
if [[ ${GH} == true ]]; then
|
||||
echo "Build angular [github gh-pages]"
|
||||
node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build --base-href /ng-alain/
|
||||
else
|
||||
echo "Build angular"
|
||||
node --max_old_space_size=5120 ./node_modules/@angular/cli/bin/ng build
|
||||
fi
|
||||
|
||||
cp -f ${DIST_DIR}/index.html ${DIST_DIR}/404.html
|
||||
|
||||
echo "Finished"
|
||||
@@ -0,0 +1,61 @@
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const REPO = process.env.ACCESS_REPO;
|
||||
const TOKEN = process.env.ACCESS_TOKEN;
|
||||
const PR = process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER;
|
||||
const argv = process.argv;
|
||||
const tag = argv[argv.length - 2];
|
||||
const comment = argv[argv.length - 1];
|
||||
const REPLACE_MARK = `<!-- AZURE_UPDATE_COMMENT_${tag} -->`;
|
||||
|
||||
const wrappedComment = `
|
||||
${REPLACE_MARK}
|
||||
${comment}
|
||||
`.trim();
|
||||
|
||||
async function withGithub(url, json, method) {
|
||||
const res = await fetch(url, {
|
||||
method: method || (json ? 'POST' : 'GET'),
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Basic ${Buffer.from(TOKEN).toString('base64')}`,
|
||||
},
|
||||
body: json ? JSON.stringify(json) : undefined,
|
||||
});
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
(async function run() {
|
||||
if (PR == null) {
|
||||
console.log('未获取到PR,忽略处理')
|
||||
return;
|
||||
}
|
||||
|
||||
const comments = await withGithub(`https://api.github.com/repos/${REPO}/issues/${PR}/comments`);
|
||||
|
||||
// Find my comment
|
||||
const updateComment = comments.find(({ body }) => body.includes(REPLACE_MARK));
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Origin comment:', updateComment);
|
||||
|
||||
// Update
|
||||
let res;
|
||||
if (!updateComment) {
|
||||
res = await withGithub(`https://api.github.com/repos/${REPO}/issues/${PR}/comments`, {
|
||||
body: wrappedComment,
|
||||
});
|
||||
} else {
|
||||
res = await withGithub(
|
||||
`https://api.github.com/repos/${REPO}/issues/comments/${updateComment.id}`,
|
||||
{
|
||||
body: wrappedComment,
|
||||
},
|
||||
'PATCH',
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(res);
|
||||
})();
|
||||
Reference in New Issue
Block a user