Skip to content

Commit

Permalink
Brightened main final summaries in CLIs ↞ [auto-sync from `adamlui/js…
Browse files Browse the repository at this point in the history
…-utils`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 4, 2024
1 parent 4a0ccf7 commit cdb3e93
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion node.js/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ else if (process.argv.some(arg => reArgs.infoCmds.version.test(arg))) {
if (minifyData?.length > 0) {
printIfNotQuiet(`\n${bg}Minification complete!${nc}`);
printIfNotQuiet(
`${minifyData.length} file${ minifyData.length > 1 ? 's' : '' } minified.`);
`${bw + minifyData.length} file${ minifyData.length > 1 ? 's' : '' } minified.${nc}`);
} else printIfNotQuiet(`${by}No unminified JavaScript files processed.${nc}`);
if (failedPaths.length > 0) {
printIfNotQuiet(`\n${br}`
Expand Down
40 changes: 27 additions & 13 deletions node.js/utils/bump.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/bash

# This script automates: build minified JS >>> bump versions in manifests + READMEs
# >>> commit changes to Git >>> push changes to GitHub >>> publish to npm (optional)
# This script automates:
# >>> bump versions in manifests + READMEs >>> commit bumps to Git
# >>> build minified JS to dist/ >>> update jsDelivr URL in cli.min.js >>> commit build to Git
# >>> push changes to GitHub >>> publish to npm (optional)

# Init UI colors
nc="\033[0m" # no color
bg="\033[1;92m" # bright green
br="\033[1;91m" # bright red
by="\033[1;33m" # bright yellow
bg="\033[1;92m" # bright green
bw="\033[1;97m" # bright white

# Validate version arg
VERSION_TYPES=("major" "minor" "patch")
Expand All @@ -24,15 +28,12 @@ case $1 in # edit SUBVERS based on version type
esac
NEW_VERSION=$(printf "%s.%s.%s" "${SUBVERS[@]}")

# Build minified JS for dist/
bash utils/build.sh

# Bump version in package.json + package-lock.json
echo -e "\nBumping versions in package manifests..."
echo -e "${by}Bumping versions in package manifests...${bw}"
npm version --no-git-tag-version "$NEW_VERSION"

# Bump versions in READMEs
echo -e "\nBumping versions in READMEs..."
echo -e "${by}\nBumping versions in READMEs...${bw}"
PACKAGE_NAME=$(node -pe "require('./package.json').name" | sed -e 's/^@[a-zA-Z0-9-]*\///' -e 's/^@//')
sed_actions=(
# Latest Build shield link
Expand All @@ -47,21 +48,34 @@ sed_actions=(
find . -name 'README.md' "${sed_actions[@]}"
echo "v$NEW_VERSION"

# Commit to Git
echo -e "\nCommitting changes...\n"
# Commit bumps to Git
echo -e "${by}\nCommitting bumps to Git...\n${nc}"
find . -name "README.md" -exec git add {} +
git add package*.json
git commit -n -m "Bumped $PACKAGE_NAME versions to $NEW_VERSION"

# Build minified JS to dist/
echo -e "${by}\nBuilding minified JS...\n${nc}"
bash utils/build.sh

# Update jsDelivr URL for global messages w/ commit hash
echo -e "${by}\nUpdating jsDelivr URL for global messages w/ commit hash...${nc}"
BUMP_HASH=$(git rev-parse HEAD)
if sed -i -E "s|(cdn\.jsdelivr\.net\/gh\/[^/]+\/[^@/]+)[^/]*|\1@$BUMP_HASH|" dist/cli.min.js
then echo -e "${bw}$BUMP_HASH${nc}" ; fi

# Commit build to Git
echo -e "${by}\nCommitting build to Git...\n${nc}"
git add ./dist/*.js
git commit -n -m "Built $PACKAGE_NAME v$NEW_VERSION"

# Push to GiHub
echo -e "\nPushing to GitHub...\n"
# Push changes to GiHub
echo -e "${by}\nPushing to GitHub...\n${nc}"
git push

# Publish to NPM
if [[ "$*" == *"--publish"* ]] ; then
echo -e "\nPublishing to npm...\n"
echo -e "${by}\nPublishing to npm...\n${nc}"
npm publish ; fi

# Print final summary
Expand Down

0 comments on commit cdb3e93

Please sign in to comment.