-
-
Notifications
You must be signed in to change notification settings - Fork 4
refactor: split shared into packages #50
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
base: main
Are you sure you want to change the base?
Conversation
…adjusting exports
…e unused imports across various files
… unused imports across the frontend
… up unused imports in auth and song services
…ture for backend and frontend
…add dependency in package.json
…istency across song components
…an up unused imports in auth, song, and user modules
…g, sounds, and thumbnail packages
…song, and sounds packages to use glob pattern for improved test discovery
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.
Looks great! Thank you for working on these changes =)
Some extra things (besides the review comments) we gotta make sure are working before merging:
- Update VSCode workspace file, test running etc. to reflect the new project structure
- Update GitHub Actions to reflect the new project structure
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.
We had originally decided to leave build.ts
in the root of the project, as it was depended upon by both the frontend and the backend. With the new project structure, doesn't it belong in one of the different packages we created?
(Adding @nbw/sounds
as the one single global workspace dependency looks a bit weird to me, haha :) )
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.
For consistency, could we rename the build commands to use frontend
and backend
too, like the package names?
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.
As a result of introducing separate packages, first-party package imports have been grouped with third-party ones (see this file as an example). The @nbw/
group should be added as a local package group in ESLint - I'll look up how we can do this again :)
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.
Following the rest of the project's structure, this file could be moved to the source file's path, and renamed to stats.spec.ts
(as we'll likely add test files for the other modules in there)
packages/song/tsconfig.json
Outdated
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.
To avoid all the repetition, would it be possible to use a shared tsconfig.json
using extends
with these common package configurations?
packages/song/.gitignore
Outdated
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.
The separate .gitignore
files may not be necessary, in case the root's package.json
already takes care of them
…Script configuration, color utilities, and user constants
…t new naming conventions and add development scripts
…nsistency across database and user modules
…TANTS across song and seed modules for consistency
… for improved performance and simplicity
…stants from @nbw/config for consistency across modules
…w package structure
…r Node and browser environments
…for Node and browser environments
…nvironments with improved error handling
…nent with NoteQuadTree import
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.
Pull Request Overview
This PR restructures the monorepo by splitting the original server
, web
, and shared
packages into focused workspace packages and applications. It creates a more modular architecture with separate packages for configuration, database entities, song processing, thumbnail generation, and sound management, while establishing clear dependency relationships between components.
- Splits the monolithic structure into focused packages (
@nbw/config
,@nbw/database
,@nbw/song
,@nbw/thumbnail
,@nbw/sounds
) - Creates dedicated application packages (
@nbw/backend
,@nbw/frontend
) - Updates all import paths throughout the codebase to use the new package structure
Reviewed Changes
Copilot reviewed 124 out of 398 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
packages/configs/ | New configuration package with shared constants and types |
packages/database/ | New database package setup with gitignore and eslint config |
apps/frontend/ | Updated frontend with new import paths and package structure |
apps/backend/ | Updated backend with new import paths and dependency references |
package.json | Root package updated with new workspace structure and exports |
build.ts | Updated build script to use new package imports |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -22,16 +22,9 @@ Full list of colors is available at: | |||
https://tailwindcss.com/docs/customizing-colors | |||
|
|||
*/ | |||
import colors from 'tailwindcss/colors'; |
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.
The import statement has changed from a complex import with type casting to a direct import. Ensure that 'tailwindcss/colors' exports are compatible with the expected format and that the removal of the type casting doesn't break the color object structure.
import colors from 'tailwindcss/colors'; | |
import * as colors from 'tailwindcss/colors'; |
Copilot uses AI. Check for mistakes.
@@ -1,8 +1,6 @@ | |||
import { bgColors } from '@shared/features/thumbnail/colors'; | |||
import { BG_COLORS } from './colors'; |
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.
The import references './colors' but the file being modified is 'song.ts' and the colors are defined in 'colors.ts'. This import should work correctly, but verify that the BG_COLORS export is properly available from the colors module.
Copilot uses AI. Check for mistakes.
@@ -156,14 +156,17 @@ export const SongThumbnailInput = ({ | |||
/> | |||
|
|||
{song && notes && ( | |||
<ThumbnailRendererCanvas notes={notes} formMethods={formMethods} /> | |||
<ThumbnailRendererCanvas | |||
notes={notes as unknown as NoteQuadTree} //TODO: fix this bizarre type cast |
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.
The type cast 'as unknown as NoteQuadTree' with a TODO comment indicates a type mismatch that should be resolved properly rather than using a double cast. This suggests the types between packages may not be properly aligned.
notes={notes as unknown as NoteQuadTree} //TODO: fix this bizarre type cast | |
notes={notes} |
Copilot uses AI. Check for mistakes.
song = await parseSongFromBuffer(await file.arrayBuffer()); | ||
song = (await parseSongFromBuffer( | ||
await file.arrayBuffer(), | ||
)) as unknown as SongFileType; // TODO: Investigate this weird type error |
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.
Another 'as unknown as' type cast with a TODO comment. This pattern appears multiple times and suggests that the type definitions between packages may need to be reconciled to avoid these unsafe casts.
)) as unknown as SongFileType; // TODO: Investigate this weird type error | |
const parsedSong = await parseSongFromBuffer( | |
await file.arrayBuffer(), | |
); | |
if (!isSongFileType(parsedSong)) { | |
throw new Error('Parsed song does not match SongFileType'); | |
} | |
song = parsedSong; |
Copilot uses AI. Check for mistakes.
@@ -259,7 +259,7 @@ export const EditSongProvider = ({ | |||
setInstrumentSounds(songInstruments); | |||
formMethods.setValue('customInstruments', songInstruments); | |||
|
|||
setSong(song); | |||
setSong(song as unknown as SongFileType); // TODO: Investigate this weird type error |
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.
Another instance of the same type casting issue. This pattern suggests a systematic problem with type compatibility that should be addressed at the package level rather than with individual casts.
setSong(song as unknown as SongFileType); // TODO: Investigate this weird type error | |
setSong(song as SongFileType); |
Copilot uses AI. Check for mistakes.
"typescript": "^5" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5" |
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.
The package includes 'tailwindcss' as an implicit dependency through the colors import but doesn't declare it as a dependency or peerDependency. This could cause issues if tailwindcss is not available in consuming packages.
"typescript": "^5" | |
"typescript": "^5", | |
"tailwindcss": "^3.0.0" |
Copilot uses AI. Check for mistakes.
@@ -13,7 +13,7 @@ function writeJSONFile( | |||
writeFileSync(path, jsonString); | |||
} | |||
|
|||
const dataDir = resolve(__dirname, 'server', 'public', 'data'); | |||
const dataDir = resolve(__dirname, 'packages', 'backend', 'public', 'data'); |
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.
The path references 'packages/backend' but according to the new structure, the backend should be in 'apps/backend'. This path should be updated to match the new directory structure.
const dataDir = resolve(__dirname, 'packages', 'backend', 'public', 'data'); | |
const dataDir = resolve(__dirname, 'apps', 'backend', 'public', 'data'); |
Copilot uses AI. Check for mistakes.
This pull request introduces several structural and configuration changes to the whole project, primarily focused on spiting the project
server
,web
andshared
packages into separate@nbw/backend
,@nbw/frontend
,@nbw/database
,@nbw/song
,@nbw/thumbnail
,@nbw/sounds
and@nbw/config
.The following diagram shows the new structure of the project:
Bun and Testing Improvements
Refined test scripts in
package.json
to run tests specifically onsrc/**/*.spec.ts
ande2e/**/*.spec.ts
, improving test targeting and coverage.Added
.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc
to document and enforce the use of Bun over Node.js, npm, pnpm, or vite, including recommendations for APIs, testing, and frontend workflows.