sui icon indicating copy to clipboard operation
sui copied to clipboard

[cli/move-new] verify if the package name is valid and replace hyphens with underscores

Open stefan-mysten opened this issue 2 years ago • 4 comments
trafficstars

Description

This PR adds a check for the sui move new command to ensure that the package name is valid (matches this regex: [A-Za-z][A-Za-z0-9-_]*), and it replaces hyphens with underscores in the address field of the Move.toml file.

Test Plan

Added several tests both in move-cli and in sui-move crates.

$ sui move new test_!
Invalid package naming: a valid package name must start with a letter and can contain only letters, hyphens (-), or underscores (_).

If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • [ ] protocol change
  • [x] user-visible impact
  • [ ] breaking change for a client SDKs
  • [ ] breaking change for FNs (FN binary must upgrade)
  • [ ] breaking change for validators or node operators (must upgrade binaries)
  • [ ] breaking change for on-chain data layout
  • [ ] necessitate either a data wipe or data migration

Release notes

Added a check to ensure that pacakge name is valid for the sui move new command (must match this regex: [A-Za-z][A-Za-z0-9-_]*). Additionally, all hyphens are replaced with underscore in the address' field of the Move.toml file.

stefan-mysten avatar Oct 25 '23 21:10 stefan-mysten

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

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2023 1:31am
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2023 1:31am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2023 1:31am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Dec 27, 2023 1:31am
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Dec 27, 2023 1:31am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Dec 27, 2023 1:31am

vercel[bot] avatar Oct 25 '23 21:10 vercel[bot]

I think we we still need to update the regex with digits. And we will need a new CLI test for this before landing. Otherwise looks good!

@tnowacki Fixed the regex issue and added tests.

stefan-mysten avatar Oct 31 '23 00:10 stefan-mysten

@stefan-mysten is attempting to deploy a commit to the Sui Foundation Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 03 '23 00:11 vercel[bot]

Locally, all tests pass. On the CI, many of them fail :| Not sure how to debug this, yet.

stefan-mysten avatar Nov 07 '23 05:11 stefan-mysten