This commit is contained in:
MaxKey
2022-04-23 10:08:40 +08:00
parent b6d30a8730
commit ba518828f8
1024 changed files with 142635 additions and 0 deletions

View File

@@ -0,0 +1 @@
# Only for CI, you can delete it

View 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}"

View File

@@ -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"

View File

@@ -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);
})();