-
Notifications
You must be signed in to change notification settings - Fork 1
feat(mbe,ebe)!: migrate to beta packages and deprecate bitgo package #81
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,98 @@ | ||
| export {}; | ||
|
|
||
| const { writeFileSync, mkdirSync, existsSync } = require('fs'); | ||
| const path = require('path'); | ||
| const https = require('https'); | ||
|
|
||
| /** | ||
| * Script purpose: Automatically update @bitgo-beta/ package versions in package.json | ||
| * - Reads package.json in current directory | ||
| * - Bumps @bitgo-beta/ packages to latest version | ||
| * - Overwrites package.json with updated versions | ||
| */ | ||
|
|
||
| type BitGoBetaPackageName = `@bitgo-beta/${string}`; | ||
|
|
||
| function dependencyIsBitGoBetaPackage(dependency: string): dependency is BitGoBetaPackageName { | ||
| return dependency.startsWith('@bitgo-beta/'); | ||
| } | ||
|
|
||
| type Tag = { | ||
| beta?: string; | ||
| latest?: string; | ||
| }; | ||
|
|
||
| type DistTags = { | ||
| tags: Tag; | ||
| }; | ||
|
|
||
| const packageJsonPath = path.resolve(process.cwd(), 'package.json'); | ||
| const packageJson = require(packageJsonPath); | ||
| const packageNames: BitGoBetaPackageName[] = Object.keys(packageJson.dependencies).filter( | ||
| dependencyIsBitGoBetaPackage, | ||
| ); | ||
|
|
||
| /** | ||
| * Fetches distribution tags for a given package from npm registry | ||
| */ | ||
| const getDistTags = async (packageName: BitGoBetaPackageName): Promise<DistTags> => { | ||
| return new Promise((resolve) => { | ||
| https.get( | ||
| `https://registry.npmjs.org/-/package/${packageName}/dist-tags`, | ||
| (res: { on: (arg0: string, arg1: (d: any) => void) => void }) => { | ||
| let data = ''; | ||
| res.on('data', (d) => { | ||
| data += d; | ||
| }); | ||
| res.on('end', () => { | ||
| const tags = JSON.parse(data) as Tag; | ||
| resolve({ tags }); | ||
| }); | ||
| }, | ||
| ); | ||
| }); | ||
| }; | ||
|
|
||
| /** | ||
| * Updates package version to latest in package.json | ||
| */ | ||
| const bumpVersion = async (packageName: BitGoBetaPackageName) => { | ||
| const { tags } = await getDistTags(packageName); | ||
|
|
||
| // Prefer beta tag if available, otherwise use latest | ||
| const next = tags['beta'] || tags['latest']; | ||
|
|
||
| if (next) { | ||
| packageJson.dependencies[packageName] = next; | ||
| console.log(`Upgrading ${packageName} to ${packageJson.dependencies[packageName]}...`); | ||
|
|
||
| // Update resolutions if the package is in resolutions | ||
| if (packageJson.resolutions && packageJson.resolutions[packageName]) { | ||
| packageJson.resolutions[packageName] = next; | ||
| console.log(`Updating resolution for ${packageName} to ${next}...`); | ||
| } | ||
| } else { | ||
| console.log(`No suitable version found for ${packageName}, keeping current version`); | ||
| } | ||
|
|
||
| return; | ||
| }; | ||
|
|
||
| const bumpVersions = async () => { | ||
| const bumpPromises = packageNames.map(bumpVersion); | ||
| await Promise.all(bumpPromises); | ||
|
|
||
| const targetDir = path.join(process.cwd()); | ||
|
|
||
| // Ensure scripts directory exists | ||
| const scriptsDir = path.join(targetDir, 'scripts'); | ||
| if (!existsSync(scriptsDir)) { | ||
| mkdirSync(scriptsDir, { recursive: true }); | ||
| } | ||
|
|
||
| writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2) + '\n'); | ||
|
|
||
| console.log(`Successfully bumped ${packageJson.name} dependencies`); | ||
| }; | ||
|
|
||
| void bumpVersions(); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This import uses '@bitgo/public-types' instead of the beta equivalent. Consider updating to '@bitgo-beta/public-types' if available to maintain consistency with the migration.