タグとバージョンの扱いを変更・改行コードLFの強制・その他調整
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
{
|
{
|
||||||
"name": "Alpine",
|
"name": "Alpine",
|
||||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
"image": "mcr.microsoft.com/devcontainers/base:alpine"
|
"image": "mcr.microsoft.com/devcontainers/base:alpine-3.20",
|
||||||
|
|
||||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
// "features": {},
|
//"features": { }
|
||||||
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
// "forwardPorts": [],
|
// "forwardPorts": [],
|
||||||
@@ -19,4 +19,4 @@
|
|||||||
|
|
||||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
// "remoteUser": "root"
|
// "remoteUser": "root"
|
||||||
}
|
}
|
||||||
|
|||||||
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
*.json text eol=lf
|
||||||
|
*.sh text eol=lf
|
||||||
|
*.yml text eol=lf
|
||||||
|
*.md text eol=lf
|
||||||
|
*.git* text eol=lf
|
||||||
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for more information:
|
||||||
|
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
# https://containers.dev/guide/dependabot
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "devcontainers"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"python.analysis.typeCheckingMode": "basic"
|
||||||
|
}
|
||||||
122
package.sh
122
package.sh
@@ -1,4 +1,4 @@
|
|||||||
apk add curl git git-lfs icu-data-full jq npm uuidgen > /dev/null
|
apk add curl git git-lfs icu-data-full jq npm uuidgen sed >/dev/null
|
||||||
git config --global http.sslVerify false
|
git config --global http.sslVerify false
|
||||||
git config --global advice.detachedHead false
|
git config --global advice.detachedHead false
|
||||||
|
|
||||||
@@ -6,20 +6,23 @@ Repo_Process() {
|
|||||||
# Prepare Variables
|
# Prepare Variables
|
||||||
local UUID=$(uuidgen)
|
local UUID=$(uuidgen)
|
||||||
local WORK_ROOT=$1
|
local WORK_ROOT=$1
|
||||||
local ITEM=$2
|
local REPO_SETTING=$2
|
||||||
local ADDRBASE=$(echo $ITEM | jq -r '.addr')
|
local ADDR=$(echo $REPO_SETTING | jq -r '.addr')
|
||||||
local DIR=$(echo $ITEM | jq -r '.dir')
|
local DIR=$(echo $REPO_SETTING | jq -r '.dir')
|
||||||
local NAME=$(echo $ITEM | jq -r '.name')
|
local TAG_REGEX=$(echo $REPO_SETTING | jq -r '.tagRegex')
|
||||||
local DISP=$(echo $ITEM | jq -r '.displayName')
|
local IGNORE_REPO=$(echo $REPO_SETTING | jq -r '.ignore')
|
||||||
local DESC=$(echo $ITEM | jq -r '.description')
|
|
||||||
local TAG_REGEX=$(echo $ITEM | jq -r '.tagRegex')
|
|
||||||
local WORK_DIR=$(basename $ADDRBASE | sed 's/\.[^\.]*$//')
|
|
||||||
local GITLABX="oauth2:glpat-$GITLABTOKEN"
|
|
||||||
local ADDR=${ADDRBASE/GITLAB/$GITLABX}
|
|
||||||
|
|
||||||
local PACKAGE_ROOT="$WORK_ROOT/$WORK_DIR-$UUID"
|
local REPO_NAME=$(basename $ADDR | sed 's/\.[^\.]*$//')
|
||||||
local PACKAGE_DIR="$WORK_ROOT/$WORK_DIR-$UUID/$DIR"
|
local AUTHOR_NAME=$(echo "$ADDR" | awk -F[/:] '{print $(NF-1)}')
|
||||||
local PACKAGE_PATH="$PACKAGE_DIR/package.json"
|
local PACKAGE_NAME=$(basename $DIR)
|
||||||
|
|
||||||
|
local PACKAGE_ROOT="$WORK_ROOT/$REPO_NAME-$UUID"
|
||||||
|
local PACKAGE_DIR="$WORK_ROOT/$REPO_NAME-$UUID/$DIR"
|
||||||
|
|
||||||
|
# Check if ignore
|
||||||
|
if [[ "$IGNORE_REPO" == "true" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$TAG_REGEX" == null ]]; then
|
if [[ "$TAG_REGEX" == null ]]; then
|
||||||
local TAG_REGEX="^[0-9]+\.[0-9]+\.[0-9]+$"
|
local TAG_REGEX="^[0-9]+\.[0-9]+\.[0-9]+$"
|
||||||
@@ -31,8 +34,7 @@ Repo_Process() {
|
|||||||
|
|
||||||
# Download latest version
|
# Download latest version
|
||||||
cd $WORK_ROOT
|
cd $WORK_ROOT
|
||||||
echo $ADDR
|
git clone $ADDR $REPO_NAME-$UUID >/dev/null 2>&1
|
||||||
git clone $ADDR $WORK_DIR-$UUID
|
|
||||||
cd $PACKAGE_ROOT
|
cd $PACKAGE_ROOT
|
||||||
|
|
||||||
local TAGS=$(git tag -l --sort authordate)
|
local TAGS=$(git tag -l --sort authordate)
|
||||||
@@ -41,77 +43,63 @@ Repo_Process() {
|
|||||||
for TAG in $TAGS; do
|
for TAG in $TAGS; do
|
||||||
|
|
||||||
# Check if tag is valid
|
# Check if tag is valid
|
||||||
if [[ $TAG =~ $TAG_REGEX ]]; then
|
if [[ ! $TAG =~ $TAG_REGEX ]]; then
|
||||||
echo "$TAG is valid tag."
|
echo "$REPO_NAME:$DIR@$TAG is invalid tag."
|
||||||
else
|
|
||||||
echo "$TAG is not valid tag."
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $WORK_ROOT
|
# Prepare Variables
|
||||||
rm -r $PACKAGE_ROOT
|
local GITHUB_PACKAGE_ADDR="https://raw.githubusercontent.com/${AUTHOR_NAME}/${REPO_NAME}/${TAG}/${DIR}/package.json"
|
||||||
git clone -b $TAG $ADDR $WORK_DIR-$UUID
|
|
||||||
cd $PACKAGE_ROOT
|
|
||||||
git submodule update --init --recursive
|
|
||||||
git lfs pull
|
|
||||||
|
|
||||||
# Check if package.json is exists
|
# 404 Check
|
||||||
if [ ! -e $PACKAGE_PATH ]; then
|
local GITHUB_STAT=$(curl -sL $GITHUB_PACKAGE_ADDR -o /dev/null -w '%{http_code}\n')
|
||||||
echo "$PACKAGE_PATH does not exist."
|
if [[ "$GITHUB_STAT" != "200" ]]; then
|
||||||
|
echo "$REPO_NAME:$DIR@$TAG has invalid path."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $PACKAGE_DIR
|
local PACKAGE_JSON=$(curl -sL $GITHUB_PACKAGE_ADDR)
|
||||||
|
local GITHUB_NAME=$(echo "$PACKAGE_JSON" | jq -r .name)
|
||||||
# Load Package.json
|
local SEM_VERSION=$(echo "$TAG" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
|
||||||
local PACKAGE=$(cat package.json)
|
|
||||||
|
|
||||||
# Change Name
|
|
||||||
if [[ "$NAME" != null ]]; then
|
|
||||||
local PROCESS_NAME='.name|="'$NAME'"'
|
|
||||||
local PACKAGE=$(echo $PACKAGE | jq "$PROCESS_NAME" | jq -c .)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change DisplayName
|
|
||||||
if [[ "$DISP" != null ]]; then
|
|
||||||
local PROCESS_DISP='.displayName|="'$DISP'"'
|
|
||||||
local PACKAGE=$(echo $PACKAGE | jq "$PROCESS_DISP" | jq -c .)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change Description
|
|
||||||
if [[ "$DESC" != null ]]; then
|
|
||||||
local PROCESS_DESC='.description|="'$DESC'"'
|
|
||||||
local PACKAGE=$(echo $PACKAGE | jq "$PROCESS_DESC" | jq -c .)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update package.json
|
|
||||||
rm package.json
|
|
||||||
echo $PACKAGE >package.json
|
|
||||||
|
|
||||||
local PACKAGE_NAME=$(cat $PACKAGE_PATH | jq -r .name)
|
|
||||||
local PACKAGE_VERSION=$(cat $PACKAGE_PATH | jq -r .version)
|
|
||||||
|
|
||||||
# Get Server tag
|
# Get Server tag
|
||||||
local SVR_STAT=$(curl -sL https://$NPM_REGISTRY/$PACKAGE_NAME -o /dev/null -w '%{http_code}\n')
|
local SVR_STAT=$(curl -sL https://$NPM_REGISTRY/$GITHUB_NAME -o /dev/null -w '%{http_code}\n')
|
||||||
local SVR_VERS=""
|
local SVR_VERS=""
|
||||||
if [[ "$SVR_STAT" == "200" ]]; then
|
if [[ "$SVR_STAT" == "200" ]]; then
|
||||||
local SVR_DATA=$(curl -sL https://$NPM_REGISTRY/$PACKAGE_NAME)
|
local SVR_DATA=$(curl -sL https://$NPM_REGISTRY/$GITHUB_NAME)
|
||||||
local SVR_VERS=$(echo $SVR_DATA | jq .versions | jq -s -r '[ .[] | keys ] | flatten | unique | .[]')
|
local SVR_VERS=$(echo $SVR_DATA | jq .versions | jq -s -r '[ .[] | keys ] | flatten | unique | .[]')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check server version
|
# Check server version
|
||||||
local EXIST_ON_SVR="false"
|
local EXIST_ON_SVR="false"
|
||||||
for SVR_VER in $SVR_VERS; do
|
for SVR_VER in $SVR_VERS; do
|
||||||
if [[ "$SVR_VER" == "$PACKAGE_VERSION" ]]; then
|
if [[ "$SVR_VER" == "$SEM_VERSION" ]]; then
|
||||||
local EXIST_ON_SVR="true"
|
local EXIST_ON_SVR="true"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ "$EXIST_ON_SVR" == "true" ]]; then
|
if [[ "$EXIST_ON_SVR" == "true" ]]; then
|
||||||
echo "Package $PACKAGE_NAME@$PACKAGE_VERSION is already exist."
|
echo "$REPO_NAME:$DIR@$TAG is already published."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "Package $PACKAGE_NAME@$PACKAGE_VERSION will be published."
|
|
||||||
|
# Download Repository
|
||||||
|
cd $WORK_ROOT
|
||||||
|
rm -r $PACKAGE_ROOT
|
||||||
|
git clone -b $TAG $ADDR $REPO_NAME-$UUID >/dev/null 2>&1
|
||||||
|
cd $PACKAGE_ROOT
|
||||||
|
git submodule update --init --recursive >/dev/null 2>&1
|
||||||
|
git lfs pull >/dev/null 2>&1
|
||||||
|
|
||||||
|
cd $PACKAGE_DIR
|
||||||
|
|
||||||
|
# Change Version
|
||||||
|
local PROCESS_VER='.version="'$SEM_VERSION'"'
|
||||||
|
local PACKAGE_JSON=$(echo "$PACKAGE_JSON" | jq "$PROCESS_VER" | jq -c .)
|
||||||
|
|
||||||
|
# Update package.json
|
||||||
|
rm package.json
|
||||||
|
echo $PACKAGE_JSON >package.json
|
||||||
|
|
||||||
# Publish Package
|
# Publish Package
|
||||||
local DATA='{"name":"'"$NPM_USER"'", "password":"'"$NPM_PASS"'"}'
|
local DATA='{"name":"'"$NPM_USER"'", "password":"'"$NPM_PASS"'"}'
|
||||||
@@ -119,7 +107,13 @@ Repo_Process() {
|
|||||||
local RETURN=$(curl -sL -H "Accept:application/json" -H "Content-Type:application/json" -X PUT --data "$DATA" --user "$USER" https://$NPM_REGISTRY/-/user/org.couchdb.user:$NPM_USER)
|
local RETURN=$(curl -sL -H "Accept:application/json" -H "Content-Type:application/json" -X PUT --data "$DATA" --user "$USER" https://$NPM_REGISTRY/-/user/org.couchdb.user:$NPM_USER)
|
||||||
local TOKEN=$(echo $RETURN | jq '.token')
|
local TOKEN=$(echo $RETURN | jq '.token')
|
||||||
npm set //$NPM_REGISTRY/:_authToken $TOKEN
|
npm set //$NPM_REGISTRY/:_authToken $TOKEN
|
||||||
npm publish --registry https://$NPM_REGISTRY/
|
npm publish --registry https://$NPM_REGISTRY/ >/dev/null 2>&1
|
||||||
|
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "$REPO_NAME:$DIR@$TAG failed to publish."
|
||||||
|
else
|
||||||
|
echo "$REPO_NAME:$DIR@$TAG published."
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user