From 20b637f4782fb1a08e1ebb52dd1a2d9514653a4e Mon Sep 17 00:00:00 2001 From: Damir Shamanaev Date: Wed, 14 Feb 2024 17:06:03 +0300 Subject: [PATCH] [CLI] Better manifest, more comments, more love (#16191) ## Description Move.toml now features hints on which fields to use and how. ## Test Plan Simple feature, only adds comments. Grammar tested with ChatGPT. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] 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 - Move.toml is now more dev-friendly offering hints and usage examples --- .../packages/sui-framework/Move.toml | 3 - .../move/crates/move-cli/src/base/new.rs | 51 ++++++++++++++-- .../tests/build_tests/simple_new/args.exp | 60 +++++++++++++++++++ 3 files changed, 105 insertions(+), 9 deletions(-) diff --git a/crates/sui-framework/packages/sui-framework/Move.toml b/crates/sui-framework/packages/sui-framework/Move.toml index 14d5d417190c5..ae454754c4636 100644 --- a/crates/sui-framework/packages/sui-framework/Move.toml +++ b/crates/sui-framework/packages/sui-framework/Move.toml @@ -4,10 +4,7 @@ version = "0.0.1" published-at = "0x2" [dependencies] -# Using a local dep for the Move stdlib instead of a git dep to avoid the overhead of fetching the git dep in -# CI. The local dep is an unmodified version of the upstream stdlib MoveStdlib = { local = "../move-stdlib" } -#MoveStdlib = { git = "https://github.com/diem/diem.git", subdir="language/move-stdlib", rev = "346301f33b3489bb4e486ae6c0aa5e030223b492" } [addresses] sui = "0x2" diff --git a/external-crates/move/crates/move-cli/src/base/new.rs b/external-crates/move/crates/move-cli/src/base/new.rs index 1904d8c976cb8..2e0b966a40abb 100644 --- a/external-crates/move/crates/move-cli/src/base/new.rs +++ b/external-crates/move/crates/move-cli/src/base/new.rs @@ -58,11 +58,15 @@ impl New { create_dir_all(path.join(SourcePackageLayout::Sources.path()))?; let mut w = std::fs::File::create(path.join(SourcePackageLayout::Manifest.path()))?; writeln!( - &mut w, - "[package] -name = \"{name}\" + w, + r#"[package] +name = "{name}" + +# edition = "2024.alpha" # To use the Move 2024 edition, currently in alpha +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] -[dependencies]" +[dependencies]"# )?; for (dep_name, dep_val) in deps { writeln!(w, "{dep_name} = {dep_val}")?; @@ -70,15 +74,50 @@ name = \"{name}\" writeln!( w, - " -[addresses]" + r#" +# For remote import, use the `{{ git = "...", subdir = "...", rev = "..." }}`. +# Revision can be a branch, a tag, and a commit hash. +# MyRemotePackage = {{ git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }} + +# For local dependencies use `local = path`. Path is relative to the package root +# Local = {{ local = "../path/to" }} + +# To resolve a version conflict and force a specific version for dependency +# override use `override = true` +# Override = {{ local = "../conflicting/version", override = true }} + +[addresses]"# )?; + + // write named addresses for (addr_name, addr_val) in addrs { writeln!(w, "{addr_name} = \"{addr_val}\"")?; } + + writeln!( + w, + r#" +# Named addresses will be accessible in Move as `@name`. They're also exported: +# for example, `std = "0x1"` is exported by the Standard Library. +# alice = "0xA11CE" + +[dev-dependencies] +# The dev-dependencies section allows overriding dependencies for `--test` and +# `--dev` modes. You can introduce test-only dependencies here. +# Local = {{ local = "../path/to/dev-build" }} + +[dev-addresses] +# The dev-addresses section allows overwriting named addresses for the `--test` +# and `--dev` modes. +# alice = "0xB0B" +"# + )?; + + // custom addition in the end if !custom.is_empty() { writeln!(w, "{}", custom)?; } + Ok(()) } } diff --git a/external-crates/move/crates/move-cli/tests/build_tests/simple_new/args.exp b/external-crates/move/crates/move-cli/tests/build_tests/simple_new/args.exp index 9dc4eb72e1ac9..6cf0550b4501e 100644 --- a/external-crates/move/crates/move-cli/tests/build_tests/simple_new/args.exp +++ b/external-crates/move/crates/move-cli/tests/build_tests/simple_new/args.exp @@ -3,14 +3,74 @@ External Command `cat P1/Move.toml`: [package] name = "P1" +# edition = "2024.alpha" # To use the Move 2024 edition, currently in alpha +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + [dependencies] +# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. +# Revision can be a branch, a tag, and a commit hash. +# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" } + +# For local dependencies use `local = path`. Path is relative to the package root +# Local = { local = "../path/to" } + +# To resolve a version conflict and force a specific version for dependency +# override use `override = true` +# Override = { local = "../conflicting/version", override = true } + [addresses] + +# Named addresses will be accessible in Move as `@name`. They're also exported: +# for example, `std = "0x1"` is exported by the Standard Library. +# alice = "0xA11CE" + +[dev-dependencies] +# The dev-dependencies section allows overriding dependencies for `--test` and +# `--dev` modes. You can introduce test-only dependencies here. +# Local = { local = "../path/to/dev-build" } + +[dev-addresses] +# The dev-addresses section allows overwriting named addresses for the `--test` +# and `--dev` modes. +# alice = "0xB0B" + Command `new P2 -p other_dir`: External Command `cat other_dir/Move.toml`: [package] name = "P2" +# edition = "2024.alpha" # To use the Move 2024 edition, currently in alpha +# license = "" # e.g., "MIT", "GPL", "Apache 2.0" +# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"] + [dependencies] +# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`. +# Revision can be a branch, a tag, and a commit hash. +# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" } + +# For local dependencies use `local = path`. Path is relative to the package root +# Local = { local = "../path/to" } + +# To resolve a version conflict and force a specific version for dependency +# override use `override = true` +# Override = { local = "../conflicting/version", override = true } + [addresses] + +# Named addresses will be accessible in Move as `@name`. They're also exported: +# for example, `std = "0x1"` is exported by the Standard Library. +# alice = "0xA11CE" + +[dev-dependencies] +# The dev-dependencies section allows overriding dependencies for `--test` and +# `--dev` modes. You can introduce test-only dependencies here. +# Local = { local = "../path/to/dev-build" } + +[dev-addresses] +# The dev-addresses section allows overwriting named addresses for the `--test` +# and `--dev` modes. +# alice = "0xB0B" +