Support nvm-sh

[GitHub #81]
This commit is contained in:
Aoran Zeng 2024-09-23 23:43:44 +08:00
parent 9332b5a4e3
commit 63c036ccd4
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
4 changed files with 91 additions and 6 deletions

View File

@ -13,13 +13,13 @@
* | Terrasse <terrasse@qq.com>
* |
* 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"

View File

@ -0,0 +1,82 @@
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nul None <nul@none.org>
* 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)};

View File

@ -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
*/

View File

@ -5,7 +5,7 @@
* Contributors : Nil Null <nil@null.org>
* 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,