-
Notifications
You must be signed in to change notification settings - Fork 2
Unread chats tab #136
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
Unread chats tab #136
Changes from all commits
9ea1175
ec1984c
48ad490
4d65d55
3ec83ea
2f217a0
0b56a57
cac1fa5
34f6ca9
a8eb26b
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 | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||||||||||||||||||||||||||||||||||||
| const fs = require('fs') | ||||||||||||||||||||||||||||||||||||||||||||
| const path = require('path') | ||||||||||||||||||||||||||||||||||||||||||||
| const YAML = require('yaml') | ||||||||||||||||||||||||||||||||||||||||||||
| const { execSync } = require('child_process') | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const scriptDir = path.resolve(__dirname) | ||||||||||||||||||||||||||||||||||||||||||||
| const rootDir = path.resolve(scriptDir, '..') | ||||||||||||||||||||||||||||||||||||||||||||
| const workspaceConfigPath = path.join(rootDir, 'pnpm-workspace.yaml') | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const loadWorkspaceCatalogs = () => { | ||||||||||||||||||||||||||||||||||||||||||||
| const workspaceContent = fs.readFileSync(workspaceConfigPath, 'utf8') | ||||||||||||||||||||||||||||||||||||||||||||
| const workspaceConfig = YAML.parse(workspaceContent) | ||||||||||||||||||||||||||||||||||||||||||||
| const rootCatalog = workspaceConfig.catalog || {} | ||||||||||||||||||||||||||||||||||||||||||||
| const catalogs = workspaceConfig.catalogs || {} | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| return { rootCatalog, catalogs } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const getCatalogNameForDependency = (dependency, catalogs) => { | ||||||||||||||||||||||||||||||||||||||||||||
| for (const [catalogName, catalogDeps] of Object.entries(catalogs)) { | ||||||||||||||||||||||||||||||||||||||||||||
| if (catalogDeps[dependency]) { | ||||||||||||||||||||||||||||||||||||||||||||
| return catalogName | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| return null | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const replaceVersionsWithCatalogs = (packageJsonPath, rootCatalog, catalogs) => { | ||||||||||||||||||||||||||||||||||||||||||||
| const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8') | ||||||||||||||||||||||||||||||||||||||||||||
| const packageJson = JSON.parse(packageJsonContent) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| ;['dependencies', 'devDependencies', 'peerDependencies', 'resolutions'].forEach( | ||||||||||||||||||||||||||||||||||||||||||||
| (dependencyType) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (packageJson[dependencyType]) { | ||||||||||||||||||||||||||||||||||||||||||||
| Object.keys(packageJson[dependencyType]).forEach((dependency) => { | ||||||||||||||||||||||||||||||||||||||||||||
| const version = packageJson[dependencyType][dependency] | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if (!version.startsWith('catalog:')) { | ||||||||||||||||||||||||||||||||||||||||||||
| let catalogVersion = null | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if (rootCatalog[dependency]) { | ||||||||||||||||||||||||||||||||||||||||||||
| catalogVersion = 'catalog:' | ||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||
| const catalogName = getCatalogNameForDependency(dependency, catalogs) | ||||||||||||||||||||||||||||||||||||||||||||
| if (catalogName) { | ||||||||||||||||||||||||||||||||||||||||||||
| catalogVersion = `catalog:${catalogName}` | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if (catalogVersion) { | ||||||||||||||||||||||||||||||||||||||||||||
| packageJson[dependencyType][dependency] = catalogVersion | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n') | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const updatePackagesDependencies = (selectedPackages) => { | ||||||||||||||||||||||||||||||||||||||||||||
| const { rootCatalog, catalogs } = loadWorkspaceCatalogs() | ||||||||||||||||||||||||||||||||||||||||||||
| const packagesPath = path.join(rootDir, 'packages') | ||||||||||||||||||||||||||||||||||||||||||||
| const packageFolders = fs.readdirSync(packagesPath) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const foldersToProcess = | ||||||||||||||||||||||||||||||||||||||||||||
| selectedPackages.length > 0 | ||||||||||||||||||||||||||||||||||||||||||||
| ? packageFolders.filter((folder) => selectedPackages.includes(folder)) | ||||||||||||||||||||||||||||||||||||||||||||
| : packageFolders | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+65
to
+70
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. 🛠️ Refactor suggestion Add error handling when reading the packages directory The script assumes that the Apply this diff to include error handling and directory checks: const packagesPath = path.join(rootDir, 'packages')
-let packageFolders = fs.readdirSync(packagesPath)
+let packageFolders
+try {
+ packageFolders = fs.readdirSync(packagesPath)
+} catch (err) {
+ console.error('Failed to read packages directory:', err)
+ process.exit(1)
+}
const foldersToProcess =
selectedPackages.length > 0
? packageFolders.filter((folder) => selectedPackages.includes(folder))
: packageFolders.filter((folder) => {
+ const folderPath = path.join(packagesPath, folder)
+ return fs.lstatSync(folderPath).isDirectory()
})📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| foldersToProcess.forEach((folder) => { | ||||||||||||||||||||||||||||||||||||||||||||
| const packageJsonPath = path.join(packagesPath, folder, 'package.json') | ||||||||||||||||||||||||||||||||||||||||||||
| if (fs.existsSync(packageJsonPath)) { | ||||||||||||||||||||||||||||||||||||||||||||
| replaceVersionsWithCatalogs(packageJsonPath, rootCatalog, catalogs) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const selectedPackages = process.argv.slice(2) | ||||||||||||||||||||||||||||||||||||||||||||
| updatePackagesDependencies(selectedPackages) | ||||||||||||||||||||||||||||||||||||||||||||
| console.log( | ||||||||||||||||||||||||||||||||||||||||||||
| 'Dependencies have been replaced with catalog references successfully. Be sure to double-check the changes made. 😉', | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| console.log('Regenerating pnpm-lock.yaml...') | ||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||
| execSync('pnpm install --lockfile-only', { stdio: 'inherit', cwd: rootDir }) | ||||||||||||||||||||||||||||||||||||||||||||
| console.log('pnpm-lock.yaml has been successfully regenerated.') | ||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||
| console.error('An error occurred while regenerating pnpm-lock.yaml:', error) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+87
to
+92
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. 🛠️ Refactor suggestion Exit the script if regenerating pnpm-lock.yaml fails When Apply this diff to exit upon failure: } catch (error) {
console.error('An error occurred while regenerating pnpm-lock.yaml:', error)
+ process.exit(1)
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| console.log( | ||||||||||||||||||||||||||||||||||||||||||||
| 'The catalog references are now set. Remember to ensure these changes are appropriate before committing.', | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,9 @@ const path = require('path') | |
| const YAML = require('yaml') | ||
| const { execSync } = require('child_process') | ||
|
|
||
| const workspaceConfigPath = path.resolve(__dirname, 'pnpm-workspace.yaml') | ||
| const scriptDir = path.resolve(__dirname) | ||
| const rootDir = path.resolve(scriptDir, '..') | ||
| const workspaceConfigPath = path.join(rootDir, 'pnpm-workspace.yaml') | ||
|
|
||
| const loadWorkspaceCatalogs = () => { | ||
| const workspaceContent = fs.readFileSync(workspaceConfigPath, 'utf8') | ||
|
|
@@ -18,34 +20,37 @@ const replaceCatalogDependencies = (packageJsonPath, rootCatalog, catalogs) => { | |
| const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8') | ||
| const packageJson = JSON.parse(packageJsonContent) | ||
|
|
||
| ;['dependencies', 'devDependencies', 'peerDependencies', 'resolutions'].forEach((depType) => { | ||
| if (packageJson[depType]) { | ||
| Object.keys(packageJson[depType]).forEach((dep) => { | ||
| const version = packageJson[depType][dep] | ||
| if (version.startsWith('catalog:')) { | ||
| const catalogName = version.split(':')[1] | ||
| ;['dependencies', 'devDependencies', 'peerDependencies', 'resolutions'].forEach( | ||
| (dependencyType) => { | ||
| if (packageJson[dependencyType]) { | ||
| Object.keys(packageJson[dependencyType]).forEach((dependency) => { | ||
| const version = packageJson[dependencyType][dependency] | ||
| if (version.startsWith('catalog:')) { | ||
| const catalogName = version.split(':')[1] | ||
|
|
||
| let resolvedVersion = | ||
| rootCatalog[dep] || (catalogs[catalogName] && catalogs[catalogName][dep]) | ||
| let resolvedVersion = | ||
| rootCatalog[dependency] || | ||
| (catalogs[catalogName] && catalogs[catalogName][dependency]) | ||
|
|
||
| if (resolvedVersion) { | ||
| packageJson[depType][dep] = resolvedVersion | ||
| } else { | ||
| console.warn( | ||
| `Could not find a matching version for ${dep} in catalog "${catalogName}" or root catalog.`, | ||
| ) | ||
| if (resolvedVersion) { | ||
| packageJson[dependencyType][dependency] = resolvedVersion | ||
| } else { | ||
| console.warn( | ||
| `Could not find a matching version for ${dependency} in catalog "${catalogName}" or root catalog.`, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
| }, | ||
| ) | ||
|
Comment on lines
+23
to
+46
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. 🛠️ Refactor suggestion Several improvements could enhance code quality and maintainability.
Consider these improvements: +const DEPENDENCY_TYPES = ['dependencies', 'devDependencies', 'peerDependencies', 'resolutions'];
+
const replaceCatalogDependencies = (packageJsonPath, rootCatalog, catalogs) => {
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf8')
const packageJson = JSON.parse(packageJsonContent)
- ;['dependencies', 'devDependencies', 'peerDependencies', 'resolutions'].forEach(
+ DEPENDENCY_TYPES.forEach(
(dependencyType) => {
if (packageJson[dependencyType]) {
Object.keys(packageJson[dependencyType]).forEach((dependency) => {
const version = packageJson[dependencyType][dependency]
if (version.startsWith('catalog:')) {
const catalogName = version.split(':')[1]
- let resolvedVersion =
- rootCatalog[dependency] ||
- (catalogs[catalogName] && catalogs[catalogName][dependency])
+ let resolvedVersion = rootCatalog[dependency] ?? catalogs[catalogName]?.[dependency]
if (resolvedVersion) {
packageJson[dependencyType][dependency] = resolvedVersion
} else {
console.warn(
- `Could not find a matching version for ${dependency} in catalog "${catalogName}" or root catalog.`,
+ `Could not find a matching version for ${dependency} in catalog "${catalogName}" or root catalog.\n` +
+ `Please ensure the package is listed in either:\n` +
+ `- Root catalog in pnpm-workspace.yaml\n` +
+ `- "${catalogName}" catalog in pnpm-workspace.yaml`
)
}
🧰 Tools🪛 Biome (1.9.4)[error] 33-33: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain) |
||
|
|
||
| fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n') | ||
| } | ||
|
|
||
| const updatePackagesDependencies = (selectedPackages) => { | ||
| const { rootCatalog, catalogs } = loadWorkspaceCatalogs() | ||
| const packagesPath = path.resolve(__dirname, 'packages') | ||
| const packagesPath = path.join(rootDir, 'packages') | ||
| const packageFolders = fs.readdirSync(packagesPath) | ||
|
|
||
| const foldersToProcess = | ||
|
|
@@ -69,7 +74,7 @@ console.log( | |
|
|
||
| console.log('Regenerating pnpm-lock.yaml...') | ||
| try { | ||
| execSync('pnpm install --lockfile-only', { stdio: 'inherit' }) | ||
| execSync('pnpm install --lockfile-only', { stdio: 'inherit', cwd: rootDir }) | ||
| console.log('pnpm-lock.yaml has been successfully regenerated.') | ||
| } catch (error) { | ||
| console.error('An error occurred while regenerating pnpm-lock.yaml:', error) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,19 @@ | ||||||
| # @baseapp-frontend/components | ||||||
|
|
||||||
| ## 0.0.20 | ||||||
|
|
||||||
| ### Patch Changes | ||||||
|
|
||||||
| - Add Active Tab functionality to the `messages` module. | ||||||
| - Several tweaks on the messages modules in general. | ||||||
| - Adapt `ChatRoomListItem` so it uses a fragment. | ||||||
|
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. 🛠️ Refactor suggestion Document component rename in changelog According to the AI summary, -Adapt `ChatRoomListItem` so it uses a fragment.
+Adapt `ChatRoomListItem` so it uses a fragment (renamed from `ChatRoomCard` to `ChatRoomItem`).📝 Committable suggestion
Suggested change
|
||||||
| - Add `ViewportHeightContainer` component and make sure `MainCointainer` uses variables from the navigation's constants. | ||||||
| - Updated dependencies | ||||||
| - @baseapp-frontend/authentication@4.0.2 | ||||||
| - @baseapp-frontend/design-system@0.0.21 | ||||||
| - @baseapp-frontend/graphql@1.1.12 | ||||||
| - @baseapp-frontend/utils@3.0.4 | ||||||
|
|
||||||
| ## 0.0.19 | ||||||
|
|
||||||
| ### Patch Changes | ||||||
|
|
||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
🛠️ Refactor suggestion
Add error handling when reading the workspace configuration file
The function
loadWorkspaceCatalogsdoes not handle errors when reading or parsing thepnpm-workspace.yamlfile. If the file is missing or malformed, the script will throw an unhandled exception. Consider adding error handling to improve the script's robustness.Apply this diff to include error handling:
const loadWorkspaceCatalogs = () => { - const workspaceContent = fs.readFileSync(workspaceConfigPath, 'utf8') - const workspaceConfig = YAML.parse(workspaceContent) + let workspaceContent + try { + workspaceContent = fs.readFileSync(workspaceConfigPath, 'utf8') + } catch (err) { + console.error('Failed to read pnpm-workspace.yaml:', err) + process.exit(1) + } + + let workspaceConfig + try { + workspaceConfig = YAML.parse(workspaceContent) + } catch (err) { + console.error('Failed to parse pnpm-workspace.yaml:', err) + process.exit(1) + } + const rootCatalog = workspaceConfig.catalog || {} const catalogs = workspaceConfig.catalogs || {} return { rootCatalog, catalogs } }📝 Committable suggestion