-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: import sibling packages without building #43
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe recent changes enhance the modularity and organization of a gardening and order book application. Key updates include streamlined TypeScript configurations, a new entry point for the order book module, and the introduction of utility functions for blockchain interactions. These adjustments simplify import paths, improve error handling, and consolidate functionalities, ensuring a clearer structure for developers while enabling better integration of components. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ViteConfig
participant TypeScript
participant GardenJS
User->>ViteConfig: Initiate build
ViteConfig->>TypeScript: Compile files
TypeScript->>GardenJS: Resolve imports
GardenJS-->>TypeScript: Return compiled output
ViteConfig-->>User: Provide build artifacts
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (14)
- packages/core/index.ts (1 hunks)
- packages/core/package.json (1 hunks)
- packages/core/src/garden.ts (3 hunks)
- packages/core/src/utils.ts (1 hunks)
- packages/core/tsconfig.json (1 hunks)
- packages/core/tsconfig.lib.json (1 hunks)
- packages/core/tsconfig.spec.json (1 hunks)
- packages/core/vite.config.ts (2 hunks)
- packages/orderbook/index.ts (1 hunks)
- packages/orderbook/package.json (1 hunks)
- packages/orderbook/tsconfig.json (1 hunks)
- packages/orderbook/tsconfig.lib.json (1 hunks)
- packages/orderbook/vite.config.ts (2 hunks)
- tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (4)
- packages/core/package.json
- packages/orderbook/package.json
- packages/orderbook/tsconfig.json
- packages/orderbook/tsconfig.lib.json
Additional comments not posted (26)
packages/core/index.ts (1)
1-3
: Ensure the correctness of export paths.Verify that the paths
./src/garden
,./src/swapper
, and./src/catalogActions
are correct and that the exported entitiesGardenJS
,SwapperActions
,SwapperRole
, andcatalogWalletActions
exist in these modules.Verification successful
Export paths and entities verified successfully.
The paths and entities exported in
packages/core/index.ts
are correct and exist in their respective source files:
GardenJS
is defined inpackages/core/src/garden.ts
.SwapperActions
andSwapperRole
are defined inpackages/core/src/swapper.ts
.catalogWalletActions
is defined inpackages/core/src/catalogActions.ts
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the exported entities in the specified modules. # Test: Check if the modules and exported entities exist. rg --type ts 'export\s+\{[^}]*\b(GardenJS|SwapperActions|SwapperRole|catalogWalletActions)\b[^}]*\}' src/garden.ts src/swapper.ts src/catalogActions.tsLength of output: 324
Script:
#!/bin/bash # Description: Search for the export statements of the entities across the entire codebase. # Search for the export statement of GardenJS rg --type ts 'export\s+\{[^}]*\bGardenJS\b[^}]*\}' -A 5 # Search for the export statement of SwapperActions rg --type ts 'export\s+\{[^}]*\bSwapperActions\b[^}]*\}' -A 5 # Search for the export statement of SwapperRole rg --type ts 'export\s+\{[^}]*\bSwapperRole\b[^}]*\}' -A 5 # Search for the export statement of catalogWalletActions rg --type ts 'export\s+\{[^}]*\bcatalogWalletActions\b[^}]*\}' -A 5Length of output: 904
Script:
#!/bin/bash # Description: Verify the existence of the entities in their respective source files. # Search for the definition of GardenJS in the garden module rg --type ts 'GardenJS' packages/core/src/garden.ts # Search for the definition of SwapperActions in the swapper module rg --type ts 'SwapperActions' packages/core/src/swapper.ts # Search for the definition of SwapperRole in the swapper module rg --type ts 'SwapperRole' packages/core/src/swapper.ts # Search for the definition of catalogWalletActions in the catalogActions module rg --type ts 'catalogWalletActions' packages/core/src/catalogActions.tsLength of output: 1913
packages/core/tsconfig.spec.json (1)
9-10
: Ensure the correctness of theinclude
paths.Verify that the paths
src/**/*.ts
andindex.ts
are correctly included and necessary for the testing setup.Verification successful
The
include
paths intsconfig.spec.json
are correct and necessary for the testing setup.
- The
src/**/*.ts
path correctly includes TypeScript files in thesrc/
directory and its subdirectories.- The
index.ts
file exists in the root directory of thepackages/core
package, confirming its necessity.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the included paths for the testing setup. # Test: Check if the paths exist and are necessary for the testing setup. fd --type f --extension ts src/ | grep -E 'src/.*\.ts|index\.ts'Length of output: 66
Script:
#!/bin/bash # Description: Verify the existence of the included paths for the testing setup. # Check if there are any TypeScript files in the src directory and its subdirectories echo "Checking for TypeScript files in src directory..." fd --type f --extension ts src/ # Check if index.ts exists in the root directory echo "Checking for index.ts in the root directory..." fd --type f --extension ts index.tsLength of output: 406
packages/core/tsconfig.lib.json (2)
8-8
: Ensure the correctness of theinclude
paths.Verify that the paths
src/**/*.ts
andindex.ts
are correctly included and necessary for the library setup.Verification successful
The
include
paths intsconfig.lib.json
are correctly specified and necessary for the library setup. The pathssrc/**/*.ts
andindex.ts
exist within the repository and are valid.
src/**/*.ts
: There are TypeScript files in thesrc
directories.index.ts
: The file exists in multiple locations, includingpackages/core/index.ts
, which is relevant for thepackages/core
directory.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the included paths for the library setup. # Test: Check if the paths exist and are necessary for the library setup. fd --type f --extension ts src/ | grep -E 'src/.*\.ts|index\.ts'Length of output: 66
Script:
#!/bin/bash # Description: Verify the existence of the included paths for the library setup. # Check if there are any TypeScript files in the src directory and its subdirectories fd --type f --extension ts src/ # Check if index.ts exists in the root directory fd --type f --extension ts index.tsLength of output: 194
10-14
: Ensure the correctness of theexclude
paths.Verify that the paths
jest.config.ts
,src/**/*.spec.ts
,src/**/*.test.ts
, andsrc/lib/testUtils.ts
are correctly excluded and unnecessary for the library setup.Verification successful
The
exclude
paths are correct and do not include any unnecessary files for the library setup.
- The paths
jest.config.ts
,src/**/*.spec.ts
,src/**/*.test.ts
, andsrc/lib/testUtils.ts
are correctly excluded.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the excluded paths for the library setup. # Test: Check if the paths exist and are unnecessary for the library setup. fd --type f --extension ts | grep -E 'jest\.config\.ts|src/.*\.spec\.ts|src/.*\.test\.ts|src/lib/testUtils\.ts'Length of output: 390
Script:
#!/bin/bash # Check if jest.config.ts exists fd --type f --name 'jest.config.ts' # Check if any .test.ts files exist fd --type f --extension ts | grep -E 'src/.*\.test\.ts' # Check if src/lib/testUtils.ts exists fd --type f --name 'testUtils.ts' | grep -E 'src/lib/testUtils\.ts'Length of output: 663
Script:
#!/bin/bash # Check if jest.config.ts exists fd --type f 'jest.config.ts' # Check if any .test.ts files exist fd --type f --extension ts | grep -E 'src/.*\.test\.ts' # Check if src/lib/testUtils.ts exists fd --type f 'src/lib/testUtils.ts'Length of output: 121
tsconfig.json (2)
8-8
: LGTM! ThebaseUrl
property addition enhances module resolution.The
baseUrl
property is correctly set to"."
, improving the flexibility of imports throughout the project.
10-10
: LGTM! Thepaths
modification improves module organization.The change to scoped package names (
@gardenfi/*
) enhances the clarity and organization of module imports.packages/orderbook/index.ts (1)
1-12
: LGTM! The export statements are well-organized.The file follows best practices for module exports, enhancing the modularity and usability of the
orderbook
package.packages/core/tsconfig.json (1)
Line range hint
1-16
:
Verify the impact of removinginclude
andexclude
properties.The removal of these properties may lead to a broader set of files being compiled. Ensure that this change does not negatively impact the build process.
packages/orderbook/vite.config.ts (3)
16-16
: LGTM! ThetsconfigPath
property improves TypeScript integration.Specifying the
tsconfigPath
helps in generating declaration files with the correct TypeScript settings.
20-22
: LGTM! Preserving symbolic links can improve module resolution behavior.Setting
preserveSymlinks
to true ensures that symbolic links are preserved when resolving modules, which can be important in certain development environments.
36-36
: LGTM! The entry point modification simplifies the project structure.Changing the
lib.entry
point from'src/index.ts'
to'index.ts'
simplifies the project structure and entry point reference.packages/core/src/utils.ts (2)
6-38
: LGTM! The function is well-structured and handles async operations correctly.The function performs operations to compute a secret based on blockchain interactions and includes necessary error handling and conditional logic.
41-47
: LGTM! The function correctly identifies Bitcoin chains.The function is straightforward and performs the intended checks correctly.
packages/core/vite.config.ts (5)
10-10
: LGTM! The cache directory update aligns with the new project structure.Updating the
cacheDir
to../node_modules/.vite/core
reflects the new project structure and organization.
16-21
: LGTM! ThetsconfigPath
property improves TypeScript integration.Specifying the
tsconfigPath
helps in generating declaration files with the correct TypeScript settings.
25-27
: LGTM! Preserving symbolic links can improve module resolution behavior.Setting
preserveSymlinks
to true ensures that symbolic links are preserved when resolving modules, which can be important in certain development environments.
29-33
: LGTM! The alias improves test organization and import paths.Adding an alias for
@gardenfi/orderbook
facilitates easier imports and improves test organization.
44-44
: LGTM! The entry point modification simplifies the project structure.Changing the
lib.entry
point fromsrc/index.ts
toindex.ts
simplifies the project structure and entry point reference.packages/core/src/garden.ts (8)
Line range hint
19-23
:
Constructor implementation looks good.The constructor correctly initializes
orderbook
andwallets
.
Line range hint
25-27
:
subscribeOrders
method implementation looks good.The method correctly subscribes to order updates.
Line range hint
29-31
:
unsubscribeOrders
method implementation looks good.The method correctly unsubscribes from order updates.
91-92
: Simplified error handling for Bitcoin wallet.The type check for
AbstractBitcoinWallet
has been removed, and the method now only verifies the existence ofbitcoinWallet
.
Line range hint
134-136
:
getSwap
method implementation looks good.The method correctly returns a
Swapper
instance.
Line range hint
139-143
:
calculateReceiveAmt
method implementation looks good.The method correctly calculates the receive amount.
Line range hint
145-151
:
getBitcoinWallet
method implementation looks good.The method correctly returns a Bitcoin wallet.
Line range hint
154-157
:
validateChain
function implementation looks good.The function correctly validates the chain.
if (!followerWallet) throw new Error(`No ${fromChain} wallet found`); | ||
if (!initiatorWallet) throw new Error(`No ${toChain} wallet found`); |
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.
Improve error messages for clarity.
The error messages should specify the chain for which the wallet is missing.
- if (!followerWallet) throw new Error(`No ${fromChain} wallet found`);
- if (!initiatorWallet) throw new Error(`No ${toChain} wallet found`);
+ if (!followerWallet) throw new Error(`No wallet found for chain: ${fromChain}`);
+ if (!initiatorWallet) throw new Error(`No wallet found for chain: ${toChain}`);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (!followerWallet) throw new Error(`No ${fromChain} wallet found`); | |
if (!initiatorWallet) throw new Error(`No ${toChain} wallet found`); | |
if (!followerWallet) throw new Error(`No wallet found for chain: ${fromChain}`); | |
if (!initiatorWallet) throw new Error(`No wallet found for chain: ${toChain}`); |
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Documentation