Skip to content

Commit

Permalink
Merge pull request #882 from YumNumm/chore/pub-workspace-melos
Browse files Browse the repository at this point in the history
[chore] パッケージ作成スクリプト実行時に `pubspec.yaml`の`workspace`を自動で追加
  • Loading branch information
YumNumm authored Jan 17, 2025
2 parents 550cd8f + 2168224 commit 126ef63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ workspace:
- packages/kyoshin_observation_point_types
- packages/lat_lng
- packages/notification_setting_types
# <ADD_PACKAGE_HERE>

dependencies:
melos: ^7.0.0-dev.2
Expand Down
14 changes: 14 additions & 0 deletions scripts/add-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ for f in $(find packages/$PACKAGE_NAME -type f -name "*_base*"); do
mv "$f" "${f/_base/$PACKAGE_NAME}"
done

# Add the new package to workspace in pubspec.yaml before the comment line
info "Adding package to workspace in pubspec.yaml..."
python3 -c "
import sys
with open('pubspec.yaml', 'r') as f:
lines = f.readlines()
for i, line in enumerate(lines):
if '<ADD_PACKAGE_HERE>' in line:
lines.insert(i, ' - packages/$PACKAGE_NAME\n')
break
with open('pubspec.yaml', 'w') as f:
f.writelines(lines)
"

info "Executing bootstrap script for $PACKAGE_NAME ... Please wait..."

melos bootstrap &>/dev/null
Expand Down

0 comments on commit 126ef63

Please sign in to comment.