Skip to content

Commit

Permalink
feat: add switching workspace mode (#6)
Browse files Browse the repository at this point in the history
* Add switching workspace mode

* Update README

* Use pre script

* Update README
  • Loading branch information
ulbqb authored Feb 22, 2024
1 parent 5b6e9e7 commit 92c9276
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ cargo generate \
--destination $PWD/contracts
```

## How To Use (without workspace)

Generate a contract template without workspace.

```
cargo generate \
--git https://github.com/Finschia/cw-workspace.git contracts \
-d workspace=false
```

## Contract Option

- minimal - This is an empty contract. Please refer to [original repository](https://github.com/osmosis-labs/cw-minimal-template/tree/2c05d77b0c8fd0f44cc5c35f971263bc4b8e6419) for more information.
- minimal - This is an empty contract. Please refer to [original repository](https://github.com/osmosis-labs/cw-minimal-template/tree/2c05d77b0c8fd0f44cc5c35f971263bc4b8e6419) for more information.
- cw20 - This is a cw20-base contract. Please refer to [original repository](https://github.com/CosmWasm/cw-plus/tree/v1.1.0/contracts/cw20-base) for more information.
- cw721 - This is a cw721-base contract. Please refer to [original respository](https://github.com/CosmWasm/cw-nfts/tree/v0.16.0/contracts/cw721-base) for more information.
1 change: 1 addition & 0 deletions cargo-generate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ ignore = [
"contracts/cw20",
"contracts/cw721",
"contracts/cargo-generate.toml",
"contracts/pre-script.rhai",
]
3 changes: 3 additions & 0 deletions contracts/cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[template]
sub_templates = ["minimal", "cw20", "cw721"]

[hooks]
pre = ["../pre-script.rhai"]
28 changes: 28 additions & 0 deletions contracts/cw20/Cargo-single.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "{{project-name}}"
version = "0.1.0"
authors = ["{{authors}}"]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = "=1.1.9"
cosmwasm-std = "=1.1.9"
cw-utils = "=1.0.1"
cw2 = "=1.1.0"
cw20 = "=1.1.0"
cw-storage-plus = "=1.1.0"
schemars = "0.8.1"
semver = "1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.23" }

[dev-dependencies]
cw-multi-test = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/cw20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ library = []

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-utils = { workspace = true }
cw2 = { workspace = true }
cw20 = { workspace = true }
cw-storage-plus = { workspace = true }
cosmwasm-std = { workspace = true }
schemars = "0.8.1"
semver = "1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
Expand Down
25 changes: 25 additions & 0 deletions contracts/cw721/Cargo-single.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "{{project-name}}"
authors = ["{{authors}}"]
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = "=1.1.9"
cosmwasm-std = "=1.1.9"
cw-utils = "=1.0.1"
cw2 = "=1.1.0"
cw721 = "=0.16.0"
cw-storage-plus = "=1.1.0"
schemars = "0.8.10"
serde = { version = "1.0.140", default-features = false, features = ["derive"] }
thiserror = "1.0.31"
45 changes: 45 additions & 0 deletions contracts/minimal/Cargo-single.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[package]
authors = ["{{authors}}"]
edition = "2021"
name = "{{project-name}}"
version = "0.1.0"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = "=1.1.9"
cosmwasm-std = "=1.1.9"
cw-storage-plus = "=1.1.0"
cw2 = "=1.1.0"
schemars = "0.8.15"
serde = { version = "1.0.189", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.49" }

[dev-dependencies]
cw-multi-test = { workspace = true }
6 changes: 6 additions & 0 deletions contracts/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if variable::get("workspace") == "false" {
file::delete("Cargo.toml");
file::rename("Cargo-single.toml", "Cargo.toml");
} else {
file::delete("Cargo-single.toml");
}

0 comments on commit 92c9276

Please sign in to comment.