diff --git a/src/recipe/lang/Haskell.c b/src/recipe/lang/Haskell.c index fa3558a..bc13f5a 100644 --- a/src/recipe/lang/Haskell.c +++ b/src/recipe/lang/Haskell.c @@ -4,7 +4,7 @@ * File Authors : Aoran Zeng * Contributors : Nil Null * Created On : <2023-09-10> - * Last Modified : <2025-07-16> + * Last Modified : <2025-07-21> * ------------------------------------------------------------*/ #include "rawstr4c.h" @@ -33,9 +33,13 @@ pl_haskell_setsrc (char *option) { chsrc_yield_source_and_confirm (pl_haskell); - char *file = xy_strjoin (3, "repository mirror\n" - " url: ", source.url, - "\n secure: True"); + char *file = R"( +repository mirror + url: @url@ + secure: True +)"; + + file = xy_str_gsub (file, "@url@", source.url); char *config = NULL; if (xy_on_windows) @@ -48,7 +52,7 @@ pl_haskell_setsrc (char *option) } chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:")); - println (file); br(); + println (file); config = xy_normalize_path ("~/.stack/config.yaml"); file = xy_str_gsub (RAWSTR_pl_haskell_stackage_yaml, "@url@", source.url); diff --git a/src/recipe/lang/Node.js/Bun.c b/src/recipe/lang/Node.js/Bun.c index 38f43e8..cd112ae 100644 --- a/src/recipe/lang/Node.js/Bun.c +++ b/src/recipe/lang/Node.js/Bun.c @@ -4,7 +4,7 @@ * File Authors : Aoran Zeng * Contributors : Lontten * Created On : <2024-09-29> - * Last Modified : <2025-07-11> + * Last Modified : <2025-07-21> * ------------------------------------------------------------*/ /** @@ -30,8 +30,13 @@ pl_nodejs_bun_setsrc (char *option) // 用的是 npm Registry 的源 chsrc_yield_source (pl_nodejs_group); - char *file = xy_strjoin(3, "[install]\n" - "registry = \"", source.url, "\""); + char *file = +R"( +[install] +registry = "@url@" +)"; + + file = xy_str_gsub (file, "@url@", source.url); if (chsrc_in_local_mode()) { diff --git a/src/recipe/lang/Node.js/Node.js.c b/src/recipe/lang/Node.js/Node.js.c index ba10f87..5291071 100644 --- a/src/recipe/lang/Node.js/Node.js.c +++ b/src/recipe/lang/Node.js/Node.js.c @@ -19,7 +19,7 @@ pl_nodejs_check_cmd (bool *npm_exist, bool *yarn_exist, bool *pnpm_exist) if (!*npm_exist && !*yarn_exist && !*pnpm_exist) { char *msg = ENGLISH ? "No npm, yarn or pnpm command found, check if at least one is present" - : "未找到 npm 或 yarn 或 pnpm 命令,请检查是否存在其一"; + : "未找到 npm 或 yarn 或 pnpm 命令,请检查是否存在其一"; chsrc_error (msg); exit (Exit_UserCause); } diff --git a/src/recipe/lang/Python/Rye.c b/src/recipe/lang/Python/Rye.c index 850c370..f794303 100644 --- a/src/recipe/lang/Python/Rye.c +++ b/src/recipe/lang/Python/Rye.c @@ -4,7 +4,7 @@ * File Authors : Aoran Zeng * Contributors : Nul None * Created On : <2024-12-06> - * Last Modified : <2025-07-11> + * Last Modified : <2025-07-21> * * 由于Rye已经有后继uv了,所以我们不把该管理器纳入Python group中 * ------------------------------------------------------------*/ @@ -41,10 +41,15 @@ pl_python_rye_setsrc (char *option) /* 并不在 Python group 中,所以不考虑 target group 情况 */ chsrc_yield_source_and_confirm (pl_python_group); - const char *file = xy_strjoin (7, - "[[sources]]\n", - "name = \"", source.mirror->abbr, "\"\n", - "url = \"", source.url, "\""); + const char *file = +R"( +[[sources]] +name = "@1@" +url = "@2@" +)"; + + file = xy_str_gsub (file, "@1@", source.mirror->abbr); + file = xy_str_gsub (file, "@2@", source.url); char *rye_config = pl_python_find_rye_config (); chsrc_note2 (xy_strjoin (3, "请在配置文件 ", rye_config, " 中添加:")); diff --git a/src/recipe/lang/Rust/Cargo.c b/src/recipe/lang/Rust/Cargo.c index 1bc88eb..a6d6513 100644 --- a/src/recipe/lang/Rust/Cargo.c +++ b/src/recipe/lang/Rust/Cargo.c @@ -84,15 +84,19 @@ pl_rust_cargo_setsrc (char *option) { chsrc_yield_source_and_confirm (pl_rust_cargo); - const char* file = xy_strjoin (3, - "[source.crates-io]\n" - "replace-with = 'mirror'\n\n" + const char *file = +R"toml( +[source.crates-io] +replace-with = 'mirror' - "[source.mirror]\n" - "registry = \"sparse+", source.url, "\""); +[source.mirror] +registry = "sparse+@url@" +)toml"; + + file = xy_str_gsub (file, "@url@", source.url); chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:")); - p(file); + println (file); chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source);