diff --git a/src/framework/chef.c b/src/framework/chef.c index 7896c23..7358357 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -44,9 +44,25 @@ chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_z return; target->cap_local = cap; + + if (cap == FullyCan) + { + target->cap_local_explain = xy_strdup (CHINESE ? "完全支持项目级换源" : "Supports project-level source switching"); + return; + } + target->cap_local_explain = xy_strdup (CHINESE ? explain_zh : explain_en); } +chef_forbid_local_mode (Target_t *target) +{ + if (!target) + return; + + target->cap_local = CanNot; + target->cap_local_explain = xy_strdup (CHINESE ? "无法进行项目级换源" : "Unable to perform project-level source switching"); +} + void chef_allow_user_define (Target_t *target) diff --git a/src/recipe/lang/JavaScript/Bun.c b/src/recipe/lang/JavaScript/Bun.c index fc3ac4f..2be90e7 100644 --- a/src/recipe/lang/JavaScript/Bun.c +++ b/src/recipe/lang/JavaScript/Bun.c @@ -50,7 +50,7 @@ void pl_js_bun_setsrc (char *option) { // 用的是 npm Registry 的源 - chsrc_yield_source (pl_js_group); + Source_t source = chsrc_yield_source_and_confirm (pl_js_group_target, option); char *content = RAWSTR_pl_js_bun_config; diff --git a/src/recipe/lang/JavaScript/Yarn.c b/src/recipe/lang/JavaScript/Yarn.c index 13415e7..0c8dab6 100644 --- a/src/recipe/lang/JavaScript/Yarn.c +++ b/src/recipe/lang/JavaScript/Yarn.c @@ -58,9 +58,9 @@ pl_js_yarn_getsrc (char *option) void pl_js_yarn_setsrc (char *option) { - chsrc_yield_source (pl_js_group); + Source_t source = chsrc_yield_source (pl_js_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *cmd = NULL; diff --git a/src/recipe/lang/JavaScript/common.h b/src/recipe/lang/JavaScript/common.h index cce5c28..8df4181 100644 --- a/src/recipe/lang/JavaScript/common.h +++ b/src/recipe/lang/JavaScript/common.h @@ -15,6 +15,7 @@ void pl_js_group_prelude (void) { use_this(pl_js_group); + chef_allow_gsr(pl_js_group); chef_set_created_on (this, "2023-09-09"); chef_set_last_updated (this, "2025-07-11"); @@ -25,10 +26,6 @@ pl_js_group_prelude (void) chef_set_sous_chefs (this, 0); chef_set_contributors (this,0); - chef_allow_get(); - chef_allow_set(); - chef_allow_reset(); - chef_allow_local_mode (this, PartiallyCan, "支持 npm, yarn v2, pnpm, 不支持 yarn v1" "Support npm, yarn v2, pnpm, not yarn v1"); @@ -54,6 +51,7 @@ void pl_js_nodejs_binary_prelude (void) { use_this(pl_js_nodejs_binary); + chef_allow_gsr(pl_js_group); chef_set_created_on (this, "2023-09-09"); chef_set_last_updated (this, "2025-07-11"); @@ -64,10 +62,6 @@ pl_js_nodejs_binary_prelude (void) chef_set_sous_chefs (this, 0); chef_set_contributors (this, 0); - chef_allow_get(); - chef_allow_set(); - chef_allow_reset(); - chef_forbid_local_mode (this); chef_allow_english(this); chef_allow_user_define(this); diff --git a/src/recipe/lang/JavaScript/npm.c b/src/recipe/lang/JavaScript/npm.c index 94eb2c8..dc4d58d 100644 --- a/src/recipe/lang/JavaScript/npm.c +++ b/src/recipe/lang/JavaScript/npm.c @@ -43,9 +43,9 @@ pl_js_npm_getsrc (char *option) void pl_js_npm_setsrc (char *option) { - chsrc_yield_source (pl_js_group); + Source_t source = chsrc_yield_source (pl_js_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *cmd = NULL; diff --git a/src/recipe/lang/JavaScript/pnpm.c b/src/recipe/lang/JavaScript/pnpm.c index 4f4750a..0da46e0 100644 --- a/src/recipe/lang/JavaScript/pnpm.c +++ b/src/recipe/lang/JavaScript/pnpm.c @@ -43,9 +43,9 @@ pl_js_pnpm_getsrc (char *option) void pl_js_pnpm_setsrc (char *option) { - chsrc_yield_source (pl_js_group); + Source_t source = chsrc_yield_source (pl_js_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *cmd = NULL; diff --git a/src/recipe/lang/Python/PDM.c b/src/recipe/lang/Python/PDM.c index f7c088b..f18341a 100644 --- a/src/recipe/lang/Python/PDM.c +++ b/src/recipe/lang/Python/PDM.c @@ -45,9 +45,9 @@ pl_python_pdm_getsrc (char *option) void pl_python_pdm_setsrc (char *option) { - chsrc_yield_source (pl_python_group); + Source_t source = chsrc_yield_source (pl_python_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *cmd = NULL; diff --git a/src/recipe/lang/Python/Poetry.c b/src/recipe/lang/Python/Poetry.c index dffcbb5..5a76257 100644 --- a/src/recipe/lang/Python/Poetry.c +++ b/src/recipe/lang/Python/Poetry.c @@ -41,9 +41,9 @@ pl_python_poetry_getsrc (char *option) void pl_python_poetry_setsrc (char *option) { - chsrc_yield_source (pl_python_group); + Source_t source = chsrc_yield_source (pl_python_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *cmd = NULL; diff --git a/src/recipe/lang/Python/Rye.c b/src/recipe/lang/Python/Rye.c index b702c22..b10e50c 100644 --- a/src/recipe/lang/Python/Rye.c +++ b/src/recipe/lang/Python/Rye.c @@ -57,7 +57,7 @@ void pl_python_rye_setsrc (char *option) { /* 并不在 Python group 中,所以不考虑 target group 情况,仅使用 Python group 提供的源 */ - chsrc_yield_source_and_confirm (pl_python_group); + Source_t source = chsrc_yield_source_and_confirm (pl_python_group_target, option); const char *content = RAWSTR_pl_python_rye_config; diff --git a/src/recipe/lang/Python/common.h b/src/recipe/lang/Python/common.h index bcffaf3..97659d3 100644 --- a/src/recipe/lang/Python/common.h +++ b/src/recipe/lang/Python/common.h @@ -23,6 +23,7 @@ void pl_python_group_prelude (void) { use_this(pl_python_group); + chef_allow_gsr(pl_python_group); chef_set_created_on (this, "2023-09-03"); chef_set_last_updated (this, "2025-07-14"); @@ -35,9 +36,6 @@ pl_python_group_prelude (void) "yongxiang", "1926885268@qq.com", "happy game", "happygame1024@gmail.com"); - chef_allow_get(); - chef_allow_set(); - chef_allow_reset(); chef_allow_local_mode (this, PartiallyCan, "部分包管理器支持项目级换源", "Some package managers support project-level source changing"); chef_allow_english(this); diff --git a/src/recipe/lang/Python/pip.c b/src/recipe/lang/Python/pip.c index 5f68c79..c504b69 100644 --- a/src/recipe/lang/Python/pip.c +++ b/src/recipe/lang/Python/pip.c @@ -55,9 +55,9 @@ pl_python_pip_setsrc (char *option) return; } - chsrc_yield_source (pl_python_group); + Source_t source = chsrc_yield_source (pl_python_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *py_prog_name = NULL; pl_python_get_py_program_name (&py_prog_name); diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index 3128c12..7589ff6 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -21,18 +21,16 @@ pl_python_uv_prelude (void) "ccy", "icuichengyi@gmail.com", "Aoran Zeng", "ccmywish@qq.com"); - chef_allow_local_mode (this, FullyCan, "支持项目级配置", "Supports project-level configuration"); + chef_allow_local_mode (this, FullyCan, NULL, NULL); chef_allow_english(this); chef_allow_user_define(this); - chef_set_note ("uv的配置优先级顺序: $workspaces/uv.toml > $workspaces/pyproject.toml > ~/.config/uv/uv.toml > /etc/uv/uv.toml", - "uv config priority order: $workspaces/uv.toml > $workspaces/pyproject.toml > ~/.config/uv/uv.toml > /etc/uv/uv.toml"); - // 使用 pl_python_group 的源 this->sources = pl_python_group_target.sources; this->sources_n = pl_python_group_target.sources_n; } + /** * chsrc get uv * @@ -113,9 +111,9 @@ pl_python_uv_setsrc (char *option) { chsrc_ensure_program ("uv"); - chsrc_yield_source (pl_python_group); + Source_t source = chsrc_yield_source (pl_python_group_target, option); if (chsrc_in_standalone_mode()) - chsrc_confirm_source(); + chsrc_confirm_source(&source); char *uv_config = pl_python_find_uv_config (true); if (NULL==uv_config)