Repository navigation
feat: vibed cli for valdiating the deepnote files - #109
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the 📝 WalkthroughWalkthroughThis PR refactors the CLI structure by transitioning from a standalone validation script to an integrated command-based architecture. The validate logic previously in Sequence DiagramsequenceDiagram
participant User
participant bin as bin.ts
participant cli as cli.ts
participant yaml as YAML Parser
User->>bin: npm run validate .
bin->>bin: Parse command: validate
bin->>cli: validate({ path: ".", cwd: process.cwd() })
cli->>cli: findDeepnoteFiles(path)
loop For each .deepnote file
cli->>yaml: parseYaml(fileContent)
yaml-->>cli: parsed content
cli->>cli: validateSingleFile(parsed)
cli->>User: Print validation result
end
cli->>User: Exit with code 0/1
Possibly related PRs
Suggested reviewers
Pre-merge checks❌ Failed checks (1 inconclusive)
✅ Passed checks (1 passed)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## val-deepnotefiles #109 +/- ##
=====================================================
- Coverage 95.24% 86.53% -8.72%
=====================================================
Files 25 25
Lines 715 787 +72
Branches 210 225 +15
=====================================================
Hits 681 681
- Misses 34 106 +72 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
package.json (1)
1-61: Update lockfile to match package.json changes.The pipeline is failing because the lockfile is out of sync with package.json. Run
pnpm installto update it.#!/bin/bash # Update the lockfile pnpm install
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (6)
package.json(2 hunks)packages/convert/package.json(1 hunks)packages/convert/src/bin.ts(1 hunks)packages/convert/src/cli.ts(2 hunks)packages/convert/tsdown.config.ts(1 hunks)validate-deepnote-files.ts(0 hunks)
💤 Files with no reviewable changes (1)
- validate-deepnote-files.ts
🧰 Additional context used
📓 Path-based instructions (3)
packages/*/src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards
Files:
packages/convert/src/bin.tspackages/convert/src/cli.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)
Files:
packages/convert/src/bin.tspackages/convert/tsdown.config.tspackages/convert/src/cli.ts
packages/*/src/**/*
📄 CodeRabbit inference engine (CLAUDE.md)
Place source code under packages/*/src/
Files:
packages/convert/src/bin.tspackages/convert/src/cli.ts
🧬 Code graph analysis (2)
packages/convert/src/bin.ts (1)
packages/convert/src/cli.ts (2)
convert(16-111)validate(170-254)
packages/convert/src/cli.ts (1)
packages/blocks/src/deserialize-file/parse-yaml.ts (1)
parseYaml(3-12)
🪛 GitHub Actions: CI
package.json
[error] 1-1: Lockfile out of date: specifiers in the lockfile don't match package.json. Run 'pnpm install' without --frozen-lockfile to update.
packages/convert/package.json
[error] 1-1: Lockfile out of date: specifiers in the lockfile don't match package.json. Run 'pnpm install' without --frozen-lockfile to update.
🔇 Additional comments (9)
packages/convert/package.json (1)
31-33: LGTM!Centralizing tsdown configuration in
tsdown.config.tsimproves maintainability.packages/convert/tsdown.config.ts (1)
1-8: LGTM!Configuration correctly defines both library and CLI entry points with appropriate ES module output.
packages/convert/src/bin.ts (3)
10-39: LGTM!Convert command correctly maps CLI arguments to the convert function.
40-58: LGTM!Validate command correctly maps CLI arguments to the validate function.
63-69: LGTM!Test guard and error handling are appropriate for a CLI entry point.
packages/convert/src/cli.ts (4)
113-116: LGTM!Interface follows the same pattern as ConvertOptions.
121-140: LGTM!Recursive file discovery with appropriate filtering of node_modules and hidden directories.
145-168: LGTM with one caveat.Validation logic is sound with proper error handling and user-friendly messages. Just ensure the parseYaml import is updated per the earlier comment.
227-253: LGTM!Single file validation with clear success/error feedback and appropriate exit codes.
| "test:coverage": "vitest run --coverage", | ||
| "typecheck": "tsc --noEmit -p tsconfig.json && pnpm -r exec tsc --noEmit", | ||
| "validate:deepnote-files": "tsx validate-deepnote-files.ts" | ||
| "validate:deepnote-files": "node packages/convert/dist/bin.js validate ." |
There was a problem hiding this comment.
🧩 Analysis chain
Verify build order for validation script.
The script now depends on packages/convert/dist/bin.js being built. Ensure the convert package is built before this script runs (e.g., via pnpm build or a prepare hook).
Run the following to verify the build produces the expected binary:
🏁 Script executed:
#!/bin/bash
# Verify that bin.js is produced by the build
cd packages/convert
pnpm run build
# Check if bin.js exists and is executable
if [ -f "dist/bin.js" ]; then
echo "✓ dist/bin.js exists"
head -1 dist/bin.js
else
echo "✗ dist/bin.js not found"
exit 1
fiLength of output: 242
---
🏁 Script executed:
```shell
#!/bin/bash
# Check root package.json for build/prepare scripts
cat package.json | grep -A 20 '"scripts"'
# Check if bin.ts exists and implements validate command
if [ -f "packages/convert/src/bin.ts" ]; then
echo -e "\n--- bin.ts found ---"
grep -n "validate" packages/convert/src/bin.ts | head -10
fi
# Verify validate-deepnote-files.ts was removed
if [ -f "packages/convert/src/validate-deepnote-files.ts" ]; then
echo -e "\n--- validate-deepnote-files.ts still exists ---"
else
echo -e "\n--- validate-deepnote-files.ts removed ---"
fi
Length of output: 1272
Build dependency not enforced for validation script.
The validate:deepnote-files script depends on packages/convert/dist/bin.js existing, but the prepare hook only runs Husky—it doesn't build. Running this script immediately after pnpm install will fail.
Either:
- Add
pnpm buildto the prepare hook or add a postinstall script - Revert to using
tsxto run the source file directly - Document that
pnpm buildmust run first
🤖 Prompt for AI Agents
In package.json around line 29, the "validate:deepnote-files" script points to
packages/convert/dist/bin.js which may not exist after install because the
prepare hook only runs Husky; update to ensure the built file exists by either
adding "pnpm build" to the prepare hook (or adding a postinstall script that
runs the build), or change the validate script to run the source with tsx (e.g.,
point at the TS source) so it doesn't require prior build; apply one of these
fixes and keep package scripts consistent with the chosen approach.
| import { deepnoteFileSchema } from '@deepnote/blocks' | ||
| import chalk from 'chalk' | ||
| import ora from 'ora' | ||
| import { parse as parseYaml } from 'yaml' |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Use existing parseYaml helper from @deepnote/blocks.
The blocks package already exports a parseYaml helper with better error messages. Import it instead of using yaml's parse directly.
-import { parse as parseYaml } from 'yaml'
+import { deepnoteFileSchema, parseYaml } from '@deepnote/blocks'Then update line 149:
- const parsed = parseYaml(content)
+ const parsed = parseYaml(content)Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/convert/src/cli.ts around line 6 (and affecting line 149), replace
the direct import from 'yaml' with the parseYaml helper exported by
@deepnote/blocks; remove "import { parse as parseYaml } from 'yaml'" and instead
import parseYaml from '@deepnote/blocks', then update the usage at line 149 to
call that helper so you get the blocks package's richer error messages and
handling.
| for (const file of deepnoteFiles) { | ||
| const relativePath = basename(file) | ||
| const result = await validateSingleFile(file) | ||
| results.push({ file: relativePath, ...result }) |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider showing relative paths instead of just filenames.
Using basename() shows only the filename. If multiple .deepnote files exist with the same name in different directories, users won't be able to distinguish them.
+import { relative } from 'node:path'
...
- const relativePath = basename(file)
+ const relativePath = relative(absolutePath, file)Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/convert/src/cli.ts around lines 191 to 194, the code uses
basename(file) which only shows the filename and can collide for same-named
.deepnote files in different directories; replace basename(file) with a relative
path (for example path.relative(process.cwd(), file) or path.relative(inputRoot,
file) depending on the CLI input root) so the pushed results use a
disambiguating relative path, and ensure you import/require path if not already
present.
Summary by CodeRabbit
New Features
Refactor
Chores