Skip to content

Commit

Permalink
chore(canary): Avoid workspace:* in published package.json files (r…
Browse files Browse the repository at this point in the history
…edwoodjs#10532)

**Problem**
It appears leaving these `workspace:*` values in for peer dependencies
can result in:
```
➤ YN0001: │ TypeError: Cannot read properties of null (reading 'set')
```
This was happening to me today. We can simply replace these with the
canary version we are publishing.

We already avoid `workspace:*` in our stable releases.

**Changes**
Updates the existing shell script to also replace all occurrences of
`workspace:*` with the canary version.
  • Loading branch information
Josh-Walker-GM committed May 1, 2024
1 parent 50ad4f4 commit 0288d53
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/scripts/publish_canary.sh
Expand Up @@ -40,6 +40,8 @@ echo 'n' \
| awk -F. '{ $NF = $NF + 1 } 1' OFS=. \
> canary_version

# Update create-redwood-app templates to use canary packages

sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version)\"/" \
packages/create-redwood-app/templates/js/package.json > tmpfile \
&& mv tmpfile packages/create-redwood-app/templates/js/package.json
Expand All @@ -60,6 +62,37 @@ sed "s/\"@redwoodjs\/\(.*\)\": \".*\"/\"@redwoodjs\/\1\": \"$(cat canary_version
packages/create-redwood-app/templates/ts/web/package.json > tmpfile \
&& mv tmpfile packages/create-redwood-app/templates/ts/web/package.json

# Update all packages to replace any "workspace:*" with this canary version

framework_dir="$(cd "$(dirname "$0")" && pwd)/../.."
ws="$(yarn workspaces list --json)"

IFS=$'\n'
for line in $ws; do
location=$(
echo "$line" |
jq -r '.location'
)

relative_pkg_json_path="$location/package.json"

if [[ $location == "." ]]; then
printf "Skipping:\t%s\n" "$relative_pkg_json_path"
continue
fi

pkg_json_path="$framework_dir/$relative_pkg_json_path"
if [ ! -f "$pkg_json_path" ]; then
printf "ERROR:\nNo package.json found at%s\n" "$relative_pkg_json_path"
exit 1
fi

printf "Processing:\t%s\n" "$relative_pkg_json_path"
sed "s/workspace:\*/$(cat canary_version)/g" "$pkg_json_path" > tmpfile \
&& mv tmpfile "$pkg_json_path"
done

# Commit the changes
git config user.name "GitHub Actions"
git config user.email "<>"

Expand Down

0 comments on commit 0288d53

Please sign in to comment.