diff --git a/src/chsrc-main.c b/src/chsrc-main.c index a64fb29..b9c71e7 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -13,13 +13,13 @@ * | Terrasse * | * Created On : <2023-08-28> - * Last Modified : <2024-09-14> + * Last Modified : <2024-09-23> * * chsrc: Change Source —— 全平台通用命令行换源工具 * ------------------------------------------------------------*/ -#define Chsrc_Version "0.1.9.Beta1" -#define Chsrc_Release_Date "2024/09/14" +#define Chsrc_Version "0.1.9.Beta1Dev2" +#define Chsrc_Release_Date "2024/09/23" #define Chsrc_Banner_Version "v" Chsrc_Version "-" Chsrc_Release_Date #define Chsrc_Maintain_URL "https://github.com/RubyMetric/chsrc" #define Chsrc_Maintain_URL2 "https://gitee.com/RubyMetric/chsrc" @@ -39,6 +39,7 @@ #include "recipe/lang/Node.js/pnpm.c" #include "recipe/lang/Node.js/Yarn.c" #include "recipe/lang/Node.js/Node.js.c" +#include "recipe/lang/Node.js/nvm.c" #include "recipe/lang/Perl.c" #include "recipe/lang/PHP.c" diff --git a/src/recipe/lang/Node.js/nvm.c b/src/recipe/lang/Node.js/nvm.c new file mode 100644 index 0000000..5a8d101 --- /dev/null +++ b/src/recipe/lang/Node.js/nvm.c @@ -0,0 +1,82 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nul None + * Created On : <2024-09-23> + * Last Modified : <2024-09-23> + * ------------------------------------------------------------*/ + +/** + * chsrc get nvm + */ +void +pl_nodejs_nvm_getsrc (char *option) +{ + char *cmd = "echo NVM_NODEJS_ORG_MIRROR"; + system (cmd); +} + + +/** + * @consult https://github.com/nvm-sh/nvm?tab=readme-ov-file#use-a-mirror-of-node-binaries + * @consult https://mirrors.tuna.tsinghua.edu.cn/help/nodejs-release/ + * @issue https://github.com/RubyMetric/chsrc/issues/81 + * + * chsrc set nvm + * + * @note nvm does not support Fish + */ +void +pl_nodejs_nvm_setsrc (char *option) +{ + chsrc_yield_source_and_confirm (pl_nodejs_binary_release); + + char *env = xy_2strjoin ("export NVM_NODEJS_ORG_MIRROR=", source.url); + + char *zshrc = "~/.zshrc"; + char *bashrc = "~/.bashrc"; + + chsrc_append_to_file (env, bashrc); + + if (xy_file_exist (zshrc)) + chsrc_append_to_file (env, zshrc); + + chsrc_conclude (&source, ChsrcTypeAuto); +} + + +/** + * chsrc reset nvm + */ +void +pl_nodejs_nvm_resetsrc (char *option) +{ + // pl_nodejs_nvm_setsrc (ChsrcTypeReset); + chsrc_error ("暂不支持对 nvm 重置"); + exit (Exit_Unsupported); +} + + +/** + * chsrc ls nvm + */ +FeatInfo +pl_nodejs_nvm_feat (char *option) +{ + FeatInfo fi = {0}; + + fi.can_get = true; + fi.can_reset = false; + + fi.stcan_locally = CanNot; + fi.locally = ""; + fi.can_english = false; + fi.can_user_define = true; + + fi.note = NULL; + return fi; +} + +// def_target_gsrf(pl_nodejs_nvm); +TargetInfo pl_nodejs_nvm_target = {def_target_inner_gsrf(pl_nodejs_nvm),def_target_sourcesn(pl_nodejs_binary_release)}; diff --git a/src/recipe/lang/Ruby.c b/src/recipe/lang/Ruby.c index ace2d9b..065bf64 100644 --- a/src/recipe/lang/Ruby.c +++ b/src/recipe/lang/Ruby.c @@ -12,9 +12,9 @@ RubyChina = {"rubychina", "RubyChina", "Ruby China 社区", "https://ge "https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem"}; // 9.9 MB /** - * @time 2024-09-04 同步 - * @sync https://github.com/RubyMetric/chsrc/discussions/62 + * @update 2024-09-04 * @sync https://github.com/RubyMetric/chsrc/wiki/Ruby-MirrorSite + * @sync https://github.com/RubyMetric/chsrc/discussions/62 * * @note 曾经的问题 https://ruby-china.org/topics/43331 */ diff --git a/src/recipe/menu.c b/src/recipe/menu.c index 534f0cc..b811748 100644 --- a/src/recipe/menu.c +++ b/src/recipe/menu.c @@ -5,7 +5,7 @@ * Contributors : Nil Null * Created On : <2023-09-01> * Major Revision : 1 - * Last Modified : <2024-09-14> + * Last Modified : <2024-09-23> * ------------------------------------------------------------*/ /* Begin Target Matrix */ @@ -21,6 +21,7 @@ static const char *pl_nodejs_npm[] = {"npm", NULL, t(&pl_nodejs_npm_target)}, *pl_nodejs_yarn[] = {"yarn", NULL, t(&pl_nodejs_yarn_target)}, *pl_nodejs_pnpm[] = {"pnpm", NULL, t(&pl_nodejs_pnpm_target)}, +*pl_nodejs_nvm[] = {"nvm", NULL, t(&pl_nodejs_nvm_target)}, *pl_perl [] = {"perl", "cpan", NULL, t(&pl_perl_target)}, *pl_php [] = {"php", "composer", NULL, t(&pl_php_target)}, @@ -43,6 +44,7 @@ static const char pl_ruby, pl_python, pl_python_pip, pl_python_poetry, pl_python_pdm, pl_nodejs, pl_nodejs_npm, pl_nodejs_pnpm, pl_nodejs_yarn, + pl_nodejs_nvm, pl_perl, pl_php, pl_lua, pl_rust, pl_go,