Skip to content
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: anchor migrations #227

Merged
merged 4 commits into from
Nov 21, 2024
Merged

fix: anchor migrations #227

merged 4 commits into from
Nov 21, 2024

Conversation

jsonDoge
Copy link
Collaborator

@jsonDoge jsonDoge commented Nov 15, 2024

Current anchor 0.30.1 doesn't have optional package manager and is hardcoded to use yarn. And to run a migration it simply runs: yarn run ts-node ... {migration stuff} in the cwd.

So when calling a migration from root route, due to package.json existance in anchor folder, it expected a node_modules to exist and call ts-node from there. But due to nx and monorepo structure, it's placed in root. Furthermore nx ignores nested package.json - so simply removing them (anchor/package.json and anchor/package-lock.json) fixes the problem.

After the fix when anchor-migrate is run anchor will place "packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" in root package.json. This is for now ignored and not committed because our current manager is npm and anchor is planning to add support in the next version.

New commands:
npm run anchor-migrate-localnet
npm run anchor-migrate-devnet

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
darklake ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 10:53am

@vitorpy
Copy link
Collaborator

vitorpy commented Nov 15, 2024

Man, Vercel seems very finnicky with this monorepo layout. Minor changes seem to upset it. On the other hand, I think the IDL json file should be shared between the rust code and the web code (it being out of date is a problem), so I kinda like the monorepo idea.

@jsonDoge
Copy link
Collaborator Author

jsonDoge commented Nov 19, 2024

@nx/rollup packages some ts functions from anchor and was using package.json. Would be annoying to keep track of two
package.jsons. It was using package.json for the entry points (and likely dependencies), but since they match the rollup defaults, root package.json without entry points is fine.

Tested preview deployment, works.

P.S. migrations still don't work, but now the problem is in the migration scripts themselves as anchor is now able to call the deploy.ts

@jsonDoge jsonDoge requested a review from vitorpy November 19, 2024 13:11
@vitorpy
Copy link
Collaborator

vitorpy commented Nov 19, 2024

Oh cool - I'm guessing the scripts running with ts-node need some adaptation to run within anchor migrate.

LGTM.

@jsonDoge jsonDoge merged commit 6a49e65 into develop Nov 21, 2024
6 checks passed
@vitorpy vitorpy deleted the fix/anchor-migrations branch November 21, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants