Skip to content

Commit 4273088

Browse files
morealclaude
andcommitted
Add mise check task for workspace: protocol validation
The pnpm workspace: protocol requires a version specifier (*, ^, or ~). Using "workspace:" without a specifier is invalid but pnpm doesn't report a clear error, which can cause issues with tools like moonrepo. This adds a check:manifest:workspace-protocol task that detects invalid patterns and fails the CI check if found. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent e4f8233 commit 4273088

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

mise.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ depends = [
4646
"check:types",
4747
"check:md",
4848
"check-versions",
49+
"check:manifest:workspace-protocol",
4950
]
5051

5152
[tasks."check:fmt"]
@@ -75,6 +76,42 @@ else
7576
fi
7677
'''
7778

79+
[tasks."check:manifest:workspace-protocol"]
80+
description = "Check for invalid workspace: specifiers without version (*, ^, ~)"
81+
run = '''
82+
found=0
83+
for file in $(find . -name 'package.json' -not -path '*/node_modules/*'); do
84+
invalid=$(jq -r '
85+
[
86+
(.dependencies // {}),
87+
(.devDependencies // {}),
88+
(.peerDependencies // {}),
89+
(.optionalDependencies // {})
90+
]
91+
| add
92+
| to_entries[]
93+
| select(.value == "workspace:")
94+
| " \(.key)"
95+
' "$file" 2>/dev/null)
96+
if [ -n "$invalid" ]; then
97+
if [ "$found" -eq 0 ]; then
98+
echo "Error: Found invalid workspace: specifiers (missing *, ^, or ~):"
99+
echo ""
100+
fi
101+
echo "$file:"
102+
echo "$invalid"
103+
found=1
104+
fi
105+
done
106+
107+
if [ "$found" -eq 1 ]; then
108+
echo ""
109+
echo "Valid formats: workspace:*, workspace:^, workspace:~"
110+
exit 1
111+
fi
112+
echo "All workspace: specifiers are valid"
113+
'''
114+
78115
[tasks.fmt]
79116
description = "Format the codebase"
80117
run = "deno fmt && hongdown --write"

0 commit comments

Comments
 (0)