-
-
Notifications
You must be signed in to change notification settings - Fork 238
fix: prevent adding non-existent packages #1208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,11 @@ import { fileURLToPath } from 'node:url' | |
| import { resolve } from 'node:path' | ||
| import { createGenerator } from 'unocss' | ||
| import { presetRtl } from '../uno-preset-rtl.ts' | ||
| import { presetA11y } from '../uno-preset-a11y.ts' | ||
| import { COLORS } from './utils.ts' | ||
| import { presetWind4 } from 'unocss' | ||
|
|
||
| const argvFiles = process.argv.slice(2) | ||
| const APP_DIRECTORY = fileURLToPath(new URL('../app', import.meta.url)) | ||
|
|
||
| async function checkFile(path: Dirent): Promise<string | undefined> { | ||
|
|
@@ -33,6 +35,17 @@ async function checkFile(path: Dirent): Promise<string | undefined> { | |
| `${COLORS.red} ❌ [RTL] ${filename}:${idx}${ruleIdx > -1 ? `:${ruleIdx + 1}` : ''} - ${warning}${COLORS.reset}`, | ||
| ) | ||
| }), | ||
| presetA11y((warning, rule) => { | ||
| let entry = warnings.get(idx) | ||
| if (!entry) { | ||
| entry = [] | ||
| warnings.set(idx, entry) | ||
| } | ||
| const ruleIdx = line.indexOf(rule) | ||
| entry.push( | ||
| `${COLORS.red} ❌ [A11y] ${filename}:${idx}${ruleIdx > -1 ? `:${ruleIdx + 1}` : ''} - ${warning}${COLORS.reset}`, | ||
| ) | ||
| }), | ||
| ], | ||
| }) | ||
| const lines = file.split('\n') | ||
|
|
@@ -46,7 +59,10 @@ async function checkFile(path: Dirent): Promise<string | undefined> { | |
| } | ||
|
|
||
| async function check(): Promise<void> { | ||
| const dir = glob('**/*.vue', { withFileTypes: true, cwd: APP_DIRECTORY }) | ||
| const dir = glob(argvFiles.length > 0 ? argvFiles : '**/*.vue', { | ||
| withFileTypes: true, | ||
| cwd: APP_DIRECTORY, | ||
| }) | ||
|
Comment on lines
+62
to
+65
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Examine the full unocss-checker.ts to understand argument handling
echo "=== Full unocss-checker.ts content ==="
cat scripts/unocss-checker.ts
echo -e "\n=== Checking for APP_DIRECTORY definition ==="
rg "APP_DIRECTORY" scripts/ --type ts -B2 -A2Repository: npmx-dev/npmx.dev Length of output: 3519 🏁 Script executed: #!/bin/bash
# Check lint-staged configuration and how the script is invoked
echo "=== lint-staged config in package.json ==="
cat package.json | grep -A10 "lint-staged"
echo -e "\n=== Scripts section in package.json ==="
cat package.json | grep -A20 '"scripts"'
echo -e "\n=== Check how lint:css is defined ==="
grep -r "lint:css" package.jsonRepository: npmx-dev/npmx.dev Length of output: 1916 Fix the file path handling in unocss-checker.ts when invoked via lint-staged. When lint-staged runs Either strip the |
||
| let hasErrors = false | ||
| for await (const file of dir) { | ||
| const result = await checkFile(file) | ||
|
|
@@ -61,7 +77,7 @@ async function check(): Promise<void> { | |
| process.exit(1) | ||
| } else { | ||
| // oxlint-disable-next-line no-console -- success logging | ||
| console.log(`${COLORS.green}✅ CSS RTL check passed!${COLORS.reset}`) | ||
| console.log(`${COLORS.green}✅ CSS check passed!${COLORS.reset}`) | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid misleading “not found” on network failures.
checkPackageExistsreturnsfalsefor any fetch error, so the “not found” message will also show on registry/network issues and thecatchbranch will effectively never run. Consider returning a richer status from the util, or make the message neutral.💡 Possible message adjustment
📝 Committable suggestion