fix: refactor migration types to drop glob dependency#886
Conversation
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis pull request removes the "glob" package and its TypeScript type definitions from dependencies. The migration type generation script is updated to replace glob-based file discovery with direct filesystem directory reading. The updated script reads the migrations/tenant directory, filters for SQL files, sorts by numeric prefix, and generates DBMigration keys conditionally as bare identifiers or quoted strings based on whether filenames are valid JavaScript identifiers. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/scripts/migrations-types.ts`:
- Around line 36-37: The generated key string can be invalid if migration.file
contains quotes or escape characters; update the code that computes key (using
isIdentifier and migration.file in migrations-types.ts) to produce a safely
escaped quoted key when the file is not an identifier (e.g., replace the raw
`'${migration.file}'` interpolation with a proper escaping method such as
JSON.stringify(migration.file) or an equivalent escape routine) so key becomes
either the identifier or a correctly escaped string literal before returning `
${key}: ${migration.index},`.
ℹ️ Review info
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
package.jsonsrc/scripts/migrations-types.ts
💤 Files with no reviewable changes (1)
- package.json
What kind of change does this PR introduce?
Refactor
What is the current behavior?
Using glob to generate tenant migration types.
What is the new behavior?
Use fs to generate the same file and drop the dependency.
Additional context
Update template to be compatible with lint so that lint formatting doesn't interfere (
npm run lint:fix)