-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29f2174
commit 717737c
Showing
4 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import fs from 'fs/promises'; | ||
|
||
const filePath = './package.json'; | ||
const backupFilePath = './package-original.json'; | ||
|
||
async function modifyUiPackageJson() { | ||
try { | ||
// Check if a backup already exists | ||
try { | ||
await fs.access(backupFilePath); | ||
console.log(`Backup file already exists: ${backupFilePath}`); | ||
} catch { | ||
await fs.copyFile(filePath, backupFilePath); | ||
console.log(`Backup created: ${backupFilePath}`); | ||
} | ||
|
||
// Read and parse the package.json file | ||
const data = await fs.readFile(filePath, 'utf-8'); | ||
let packageJson = JSON.parse(data); | ||
|
||
// Modify the @leather.io/ui dependency | ||
packageJson.dependencies['@leather.io/ui'] = 'file:../mono/packages/ui'; | ||
|
||
// Ensure pnpm and pnpm.overrides are initialized | ||
if (!packageJson.pnpm) { | ||
packageJson.pnpm = {}; | ||
} | ||
if (!packageJson.pnpm.overrides) { | ||
packageJson.pnpm.overrides = {}; | ||
} | ||
|
||
// Add the specified overrides | ||
const overrides = { | ||
'@leather.io/rpc': 'file:../mono/packages/rpc', | ||
'@leather.io/constants': 'file:../mono/packages/constants', | ||
'@leather.io/models': 'file:../mono/packages/models', | ||
'@leather.io/tokens': 'file:../mono/packages/tokens', | ||
'@leather.io/utils': 'file:../mono/packages/utils' | ||
}; | ||
|
||
packageJson.pnpm.overrides = { ...packageJson.pnpm.overrides, ...overrides }; | ||
|
||
// Write the modified package.json back to the file | ||
await fs.writeFile(filePath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8'); | ||
console.log(`Successfully updated ${filePath}`); | ||
|
||
} catch (err) { | ||
console.error(`Error: ${err}`); | ||
} | ||
} | ||
|
||
// Execute the function | ||
modifyUiPackageJson(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters