mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 05:01:43 +00:00
add jq-nano and build-pkg.sh
Signed-off-by: andy.lee <andy.lee@suse.com>
This commit is contained in:
parent
a6f2301498
commit
83edd23ada
102
scripts/build-pkg.sh
Executable file
102
scripts/build-pkg.sh
Executable file
@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
BASE_DIR="$( cd $SCRIPT_DIR && cd ../.. & pwd)"
|
||||
SHELL_DIR=$BASE_DIR/shell/
|
||||
EXIT_CODE=0
|
||||
FORMATS="umd-min"
|
||||
|
||||
while getopts "df:" opt; do
|
||||
case $opt in
|
||||
d)
|
||||
FORMATS="umd"
|
||||
;;
|
||||
f)
|
||||
FORMATS=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# Use shell folder in node modules when we have @rancher/shell installed as a node module
|
||||
# rather than the use-case of the mono-repo with the shell folder at the top-level
|
||||
if [ ! -d ${SHELL_DIR} ]; then
|
||||
SHELL_DIR=$BASE_DIR/node_modules/@rancher/shell/
|
||||
SHELL_DIR=$(cd -P ${SHELL_DIR} && pwd)
|
||||
fi
|
||||
|
||||
CREATE_TARBALL=${2}
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=$(cd pkg/$1; node -p -e "require('./package.json').version")
|
||||
fi
|
||||
|
||||
NAME=${1}-${VERSION}
|
||||
PKG_DIST=${BASE_DIR}/dist-pkg/${NAME}
|
||||
|
||||
if [ -d "${BASE_DIR}/pkg/${1}" ]; then
|
||||
echo "Building UI Package $1"
|
||||
echo " Package name: ${NAME}"
|
||||
echo " Package version: ${VERSION}"
|
||||
echo " Output formats: ${FORMATS}"
|
||||
echo " Output directory: ${PKG_DIST}"
|
||||
rm -rf ${PKG_DIST}
|
||||
mkdir -p ${PKG_DIST}
|
||||
|
||||
pushd pkg/${1}
|
||||
|
||||
# Check that the .shell link exists and points to the correct place
|
||||
if [ -e ".shell" ]; then
|
||||
LINK=$(readlink .shell)
|
||||
if [ "${LINK}" != "${SHELL_DIR}" ]; then
|
||||
echo ".shell symlink exists but does not point to expected location - please check and fix"
|
||||
popd
|
||||
exit -1
|
||||
fi
|
||||
else
|
||||
ln -s ${SHELL_DIR} .shell
|
||||
fi
|
||||
|
||||
FILE=index.js
|
||||
if [ -f ./index.ts ]; then
|
||||
FILE=index.ts
|
||||
fi
|
||||
|
||||
if [ -n "$COMMIT" ]; then
|
||||
echo ${COMMIT} > ${PKG_DIST}/version
|
||||
fi
|
||||
|
||||
${BASE_DIR}/node_modules/.bin/vue-cli-service build --name ${NAME} --target lib ${FILE} --dest ${PKG_DIST} --formats ${FORMATS} --filename ${NAME}
|
||||
EXIT_CODE=$?
|
||||
cp -f ./package.json ${PKG_DIST}/package.json
|
||||
node ${SCRIPT_DIR}/pkgfile.js ${PKG_DIST}/package.json
|
||||
rm -rf ${PKG_DIST}/*.bak
|
||||
rm .shell
|
||||
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ $EXIT_CODE -ne 0 ]; then
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "${CREATE_TARBALL}" ]; then
|
||||
echo $COMMIT $COMMIT_BRANCH > ${PKG_DIST}/version-commit.txt
|
||||
|
||||
TARBALL=${NAME}.tar.gz
|
||||
|
||||
pushd ${PKG_DIST}
|
||||
|
||||
rm -f ../$TARBALL
|
||||
|
||||
echo "Compressing to ${TARBALL}..."
|
||||
|
||||
tar -czf ../${TARBALL} .
|
||||
|
||||
popd
|
||||
|
||||
fi
|
||||
|
||||
exit $EXIT_CODE
|
||||
@ -20,9 +20,9 @@ echo "COMMIT_BRANCH: ${COMMIT_BRANCH}"
|
||||
echo "VERSION: ${VERSION}"
|
||||
|
||||
if [ -n "$GIT_TAG" ]; then
|
||||
COMMIT=$COMMIT COMMIT_BRANCH=$COMMIT_BRANCH VERSION=$CI_BUILD_TAG ./shell/scripts/build-pkg.sh ${1} "true"
|
||||
COMMIT=$COMMIT COMMIT_BRANCH=$COMMIT_BRANCH VERSION=$CI_BUILD_TAG ./scripts/build-pkg.sh ${1} "true"
|
||||
else
|
||||
COMMIT=$COMMIT COMMIT_BRANCH=$COMMIT_BRANCH VERSION=$VERSION ./shell/scripts/build-pkg.sh ${1} "true"
|
||||
COMMIT=$COMMIT COMMIT_BRANCH=$COMMIT_BRANCH VERSION=$VERSION ./scripts/build-pkg.sh ${1} "true"
|
||||
fi
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
||||
25
scripts/jq-nano
Executable file
25
scripts/jq-nano
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const readline = require('readline');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const file = args.shift();
|
||||
|
||||
let text;
|
||||
|
||||
if ( file === '-' ) {
|
||||
process.stdin.resume();
|
||||
text = fs.readFileSync(0, "utf8");
|
||||
} else {
|
||||
text = fs.readFileSync(file, "utf8");
|
||||
}
|
||||
|
||||
const data = JSON.parse(text);
|
||||
|
||||
let out = data;
|
||||
while ( args.length ) {
|
||||
out = out[args.shift()];
|
||||
}
|
||||
|
||||
console.log(out);
|
||||
Loading…
x
Reference in New Issue
Block a user