Skip to content

Commit 45cbe9a

Browse files
committed
Fix publishing script
1 parent 4aa0cc5 commit 45cbe9a

File tree

3 files changed

+82
-18
lines changed

3 files changed

+82
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ You can write this:
7474

7575
### Interactive demo & docs
7676

77-
Check out the [live demo](https://brandonscript.github.io/mui-flexy/) for interactive examples of all `mui-flexy`'s features:
77+
Check out the <a href="https://brandonscript.github.io/mui-flexy/" target="_blank" rel="noopener noreferrer">live demo</a> for interactive examples of all <code>mui-flexy</code>'s features:
7878

7979
[![mui-flexy](https://user-images.githubusercontent.com/1480253/186974043-d75cd310-c60b-4835-ba80-e72cbab167c3.gif)](https://brandonscript.github.io/mui-flexy/)
8080

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"lint": "prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown && eslint --config eslint.config.js --ext .ts,.tsx packages/*/src",
3636
"precommit": "./.husky/pre-commit",
3737
"publish": "./scripts/publish.sh",
38+
"publish:dry-run": "./scripts/publish.sh --dry-run",
3839
"test": "yarn test:unit && yarn test:e2e",
3940
"test:e2e": "playwright test",
4041
"test:e2e:clean": "PLAYWRIGHT_FORCE_CLEAN=1 playwright test",

scripts/publish.sh

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,63 @@
11
#!/bin/bash
22
# This script builds and publishes all packages in the workspace
33

4-
# cd to git root
5-
git_root=$(git rev-parse --show-toplevel)
6-
cd "$git_root" || exit 1
4+
# Parse command line arguments
5+
DRY_RUN=false
6+
7+
show_help() {
8+
cat << EOF
9+
Usage: $0 [OPTIONS]
10+
11+
Builds and publishes all packages in the workspace.
12+
13+
OPTIONS:
14+
--dry-run, -n Build packages and show what would be published without actually publishing
15+
--help, -h Show this help message
16+
17+
EXAMPLES:
18+
$0 # Build and publish all packages
19+
$0 --dry-run # Build packages and show what would be published
20+
$0 -n # Same as --dry-run
21+
EOF
22+
}
23+
24+
while [[ $# -gt 0 ]]; do
25+
case $1 in
26+
--dry-run|-n)
27+
DRY_RUN=true
28+
shift
29+
;;
30+
--help|-h)
31+
show_help
32+
exit 0
33+
;;
34+
*)
35+
echo "Unknown option: $1"
36+
show_help
37+
exit 1
38+
;;
39+
esac
40+
done
741

842
# Colors for output
943
RED='\033[0;31m'
1044
GREEN='\033[0;32m'
1145
YELLOW='\033[1;33m'
46+
PURPLE='\033[0;35m'
1247
NC='\033[0m' # No Color
1348

49+
# cd to git root
50+
git_root=$(git rev-parse --show-toplevel)
51+
cd "$git_root" || exit 1
52+
53+
1454
get_package_dirs() {
15-
# Get all package directories that contain package.json files
16-
find packages -name "package.json" -exec dirname {} \; | sort
55+
# Get specific package directories (core, v5, v6, v7)
56+
for dir in packages/core packages/v5 packages/v6 packages/v7; do
57+
if [[ -f "$dir/package.json" ]]; then
58+
echo "$dir"
59+
fi
60+
done | sort
1761
}
1862

1963
get_package_info() {
@@ -77,15 +121,22 @@ publish_package() {
77121
}
78122

79123
main() {
80-
echo -e "${YELLOW}🚀 Starting package publishing process...${NC}"
124+
echo -e "${YELLOW}Starting package publishing process...${NC}"
81125
echo ""
82126

127+
# print dry run status
128+
if [[ "$DRY_RUN" == "true" ]]; then
129+
echo -e "${PURPLE}*** Dry-run mode, no packages will be published${NC}"
130+
echo ""
131+
fi
132+
83133
# Check authentication
84134
check_npm_auth
85135
echo ""
86136

87-
# Build all packages
88-
build_all
137+
echo -e "${YELLOW}Building all packages...${NC}"
138+
# Build all packages (quietly)
139+
build_all > /dev/null 2>&1
89140
echo ""
90141

91142
# Get all packages to publish
@@ -119,7 +170,11 @@ main() {
119170
fi
120171

121172
echo ""
122-
echo -e "${YELLOW}Publishing ${#publishable_packages[@]} packages...${NC}"
173+
if [[ "$DRY_RUN" == "true" ]]; then
174+
echo -e "${PURPLE}[DRY-RUN] Publishing ${#publishable_packages[@]} packages...${NC}"
175+
else
176+
echo -e "${YELLOW}Publishing ${#publishable_packages[@]} packages...${NC}"
177+
fi
123178
echo ""
124179

125180
# Publish each package
@@ -129,21 +184,29 @@ main() {
129184
for package_info in "${publishable_packages[@]}"; do
130185
IFS='|' read -r package_dir name version <<<"$package_info"
131186

132-
if publish_package "$package_dir" "$name" "$version"; then
187+
if [[ "$DRY_RUN" == "true" ]]; then
188+
echo -e "${PURPLE}[DRY-RUN] Would publish $name@$version${NC}"
133189
((published_count++))
134190
else
135-
((failed_count++))
191+
if publish_package "$package_dir" "$name" "$version"; then
192+
((published_count++))
193+
else
194+
((failed_count++))
195+
fi
136196
fi
137197
done
138198

139199
echo ""
140-
echo -e "${GREEN}📊 Publishing Summary:${NC}"
141-
echo " ✅ Successfully published: $published_count"
142-
if [[ $failed_count -gt 0 ]]; then
143-
echo " ❌ Failed: $failed_count"
144-
exit 1
200+
echo -e "${YELLOW}Done:${NC}"
201+
if [[ "$DRY_RUN" == "true" ]]; then
202+
echo -e "${PURPLE}[DRY-RUN] No packages were actually published${NC}"
145203
else
146-
echo -e "${GREEN}🎉 All packages published successfully!${NC}"
204+
if [[ $failed_count -gt 0 ]]; then
205+
echo -e "${RED}✗ Failed: $failed_count${NC}"
206+
exit 1
207+
else
208+
echo -e "${GREEN}✓ Successfully published: $published_count${NC}"
209+
fi
147210
fi
148211
}
149212

0 commit comments

Comments
 (0)