Skip to content

Commit

Permalink
Merge pull request #1941 from multiversx/upgrade-ruplacer
Browse files Browse the repository at this point in the history
ruplacer - upgrade
  • Loading branch information
BiancaIalangi authored Feb 6, 2025
2 parents 93a7f71 + 81c9ae9 commit c489427
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions chain/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ sha3 = "0.10.6"
itertools = "0.14.0"
hex-literal = "=0.4.1"
bitflags = "=2.8.0"
colored = "2.2"
rand = { version= "0.8.5", optional = true }
colored = "2.2" # TODO: doesn't support >v2.2 (can't build on nightly)
rand = { version = "0.8.5", optional = true }
rand_seeder = "0.3.0"
ed25519-dalek = "2.1.0"

Expand Down
2 changes: 1 addition & 1 deletion framework/meta-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rustc_version = "0.4"
toml = { version = "0.8.6", features = ["preserve_order"] }
colored = "2.2"
colored = "2.2" # TODO: doesn't support >v2.2 (can't build on nightly)
lazy_static = "1.4.0"
convert_case = "0.7.1"
hex = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion framework/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ toml = { version = "0.8.6", features = ["preserve_order"] }
colored = "2.2"
convert_case = "0.7.1"
semver = "1.0.20"
ruplacer = { version = "0.8.1", default-features = false }
ruplacer = { version = "0.10.0", default-features = false }
reqwest = { version = "0.12", features = ["blocking", "json"] }
zip = { version = "2.1", features = ["deflate"], default-features = false }
copy_dir = "0.1.2"
Expand Down
46 changes: 23 additions & 23 deletions framework/meta/src/cmd/template/template_adjuster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ impl TemplateAdjuster {
&self.target.contract_dir(),
"*rs",
&[
Query::substring(old_trait, &new_trait),
Query::substring(&old_package, &new_package),
Query::substring(&old_proxy_mod, &new_proxy_mod),
Query::simple(old_trait, &new_trait),
Query::simple(&old_package, &new_package),
Query::simple(&old_proxy_mod, &new_proxy_mod),
][..],
);

replace_in_files(
&self.target.contract_dir(),
"*sc-config.toml",
&[Query::substring(&old_proxy_mod, &new_proxy_mod)][..],
&[Query::simple(&old_proxy_mod, &new_proxy_mod)][..],
);
}

Expand All @@ -139,11 +139,11 @@ impl TemplateAdjuster {
&self.target.contract_dir(),
"*Cargo.toml",
&[
Query::substring(
Query::simple(
&package_name_expr(&self.metadata.name),
&package_name_expr(&self.target.new_name),
),
Query::substring(&old_path, &new_path),
Query::simple(&old_path, &new_path),
][..],
);
}
Expand All @@ -156,10 +156,10 @@ impl TemplateAdjuster {
&self.target.contract_dir(),
"*Cargo.toml",
&[
Query::substring(&package_name_expr(&old_meta), &package_name_expr(&new_meta)),
Query::substring(
&dependecy_decl_expr(&self.metadata.name),
&dependecy_decl_expr(&self.target.new_name),
Query::simple(&package_name_expr(&old_meta), &package_name_expr(&new_meta)),
Query::simple(
&dependency_decl_expr(&self.metadata.name),
&dependency_decl_expr(&self.target.new_name),
),
][..],
);
Expand All @@ -173,10 +173,10 @@ impl TemplateAdjuster {
&self.target.contract_dir(),
"*Cargo.toml",
&[
Query::substring(&package_name_expr(&old_wasm), &package_name_expr(&new_wasm)),
Query::substring(
&dependecy_decl_expr(&self.metadata.name),
&dependecy_decl_expr(&self.target.new_name),
Query::simple(&package_name_expr(&old_wasm), &package_name_expr(&new_wasm)),
Query::simple(
&dependency_decl_expr(&self.metadata.name),
&dependency_decl_expr(&self.target.new_name),
),
][..],
);
Expand All @@ -188,16 +188,16 @@ impl TemplateAdjuster {

let mut queries = Vec::<Query>::new();
for (old, new) in self.metadata.rename_pairs.iter() {
queries.push(Query::substring(old, new))
queries.push(Query::simple(old, new))
}

let new_path = as_path(&self.target.new_name);
let old_path = as_path(&self.metadata.name);
queries.push(Query::substring(&old_path, &new_path));
queries.push(Query::simple(&old_path, &new_path));

let new_scenarios = scenario_path(&new_name);
let old_scenarios = scenario_path(&old_name);
queries.push(Query::substring(&old_scenarios, &new_scenarios));
queries.push(Query::simple(&old_scenarios, &new_scenarios));

let old_wasm = wasm_file_name(&self.metadata.name);
let new_wasm = wasm_file_name(&self.target.new_name);
Expand All @@ -208,8 +208,8 @@ impl TemplateAdjuster {
self.rename_in_scenarios(&old_wasm, &new_wasm);
self.rename_in_scenarios(&old_mxsc, &new_mxsc);

queries.push(Query::substring(&old_wasm, &new_wasm));
queries.push(Query::substring(&old_mxsc, &new_mxsc));
queries.push(Query::simple(&old_wasm, &new_wasm));
queries.push(Query::simple(&old_mxsc, &new_mxsc));

replace_in_files(
&self.target.contract_dir().join(TEST_DIRECTORY),
Expand All @@ -222,21 +222,21 @@ impl TemplateAdjuster {
replace_in_files(
&self.target.contract_dir(),
"*.scen.json",
&[Query::substring(old, new)][..],
&[Query::simple(old, new)][..],
);

replace_in_files(
&self.target.contract_dir(),
"*.steps.json",
&[Query::substring(old, new)][..],
&[Query::simple(old, new)][..],
);
}

fn rename_in_interactor(&self) {
let old_mxsc = mxsc_file_name(&self.metadata.name);
let new_mxsc = mxsc_file_name(&self.target.new_name);

let queries = vec![Query::substring(&old_mxsc, &new_mxsc)];
let queries = vec![Query::simple(&old_mxsc, &new_mxsc)];

replace_in_files(
&self.target.contract_dir().join(INTERACT_DIRECTORY),
Expand Down Expand Up @@ -279,7 +279,7 @@ fn as_path(name: &str) -> String {
fn package_name_expr(template: &str) -> String {
format!("name = \"{template}\"")
}
fn dependecy_decl_expr(template: &str) -> String {
fn dependency_decl_expr(template: &str) -> String {
format!("dependencies.{template}")
}

Expand Down
2 changes: 1 addition & 1 deletion framework/meta/src/cmd/upgrade/upgrade_0_31.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ fn v_0_31_replace_in_files(sc_crate_path: &Path) {
replace_in_files(
sc_crate_path,
"*rs",
&[Query::substring("#[var_args]", "")][..],
&[Query::simple("#[var_args]", "")][..],
);
}
4 changes: 2 additions & 2 deletions framework/meta/src/cmd/upgrade/upgrade_0_32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::folder_structure::RelevantDirectory;
use ruplacer::Query;
use std::path::Path;

/// Migrate `0.30` to `0.31.0`, including the version bump.
/// Migrate `0.31` to `0.32.0`, including the version bump.
pub fn upgrade_to_32_0(dir: &RelevantDirectory) {
v_0_32_replace_in_files(dir.path.as_ref());

Expand All @@ -15,7 +15,7 @@ fn v_0_32_replace_in_files(sc_crate_path: &Path) {
replace_in_files(
sc_crate_path,
"*rs",
&[Query::substring(
&[Query::simple(
"TokenIdentifier::egld()",
"EgldOrEsdtTokenIdentifier::egld()",
)][..],
Expand Down
32 changes: 16 additions & 16 deletions framework/meta/src/cmd/upgrade/upgrade_0_39.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,38 +84,38 @@ fn v_0_39_replace_in_files(sc_crate_path: &Path) {
sc_crate_path,
"*Cargo.toml",
&[
Query::substring("elrond-wasm-debug", "multiversx-sc-scenario"),
Query::substring("elrond-wasm-modules", "multiversx-sc-modules"),
Query::substring("elrond-wasm-node", "multiversx-sc-wasm-adapter"),
Query::substring("elrond-wasm", "multiversx-sc"),
Query::simple("elrond-wasm-debug", "multiversx-sc-scenario"),
Query::simple("elrond-wasm-modules", "multiversx-sc-modules"),
Query::simple("elrond-wasm-node", "multiversx-sc-wasm-adapter"),
Query::simple("elrond-wasm", "multiversx-sc"),
][..],
);

replace_in_files(
sc_crate_path,
"*rs",
&[
Query::substring("elrond_codec", "codec"),
Query::substring(
Query::simple("elrond_codec", "codec"),
Query::simple(
"elrond_wasm_debug::meta::perform",
"multiversx_sc_meta::cli_main",
),
Query::substring(
Query::simple(
"elrond_wasm_debug::mandos_go",
"multiversx_sc_scenario::run_go",
),
Query::substring(
Query::simple(
"elrond_wasm_debug::mandos_rs",
"multiversx_sc_scenario::run_rs",
),
Query::substring("elrond_wasm_debug", "multiversx_sc_scenario"),
Query::substring("elrond_wasm_modules", "multiversx_sc_modules"),
Query::substring("elrond_wasm_node", "multiversx_sc_wasm_adapter"),
Query::substring("elrond_wasm", "multiversx_sc"),
Query::substring("BlockchainMock", "ScenarioWorld"),
Query::substring("testing_framework", "whitebox"),
Query::substring("tx_mock", "whitebox"),
Query::substring("register_contract_builder", "register_contract"),
Query::simple("elrond_wasm_debug", "multiversx_sc_scenario"),
Query::simple("elrond_wasm_modules", "multiversx_sc_modules"),
Query::simple("elrond_wasm_node", "multiversx_sc_wasm_adapter"),
Query::simple("elrond_wasm", "multiversx_sc"),
Query::simple("BlockchainMock", "ScenarioWorld"),
Query::simple("testing_framework", "whitebox"),
Query::simple("tx_mock", "whitebox"),
Query::simple("register_contract_builder", "register_contract"),
][..],
);
}
2 changes: 1 addition & 1 deletion framework/meta/src/cmd/upgrade/upgrade_0_51.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn v_0_51_replace_in_files(sc_crate_path: &Path) {
replace_in_files(
sc_crate_path,
"*rs",
&[Query::substring(
&[Query::simple(
"multiversx_sc_meta",
"multiversx_sc_meta_lib",
)][..],
Expand Down
2 changes: 1 addition & 1 deletion framework/scenario/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ serde = "1.0"
serde_json = "1.0"
pathdiff = "0.2.1"
itertools = "0.14.0"
colored = "2.2"
colored = "2.2" # TODO: doesn't support >v2.2 (can't build on nightly)
unwrap-infallible = "0.1.5"

[features]
Expand Down

0 comments on commit c489427

Please sign in to comment.