diff --git a/src/recipe/lang/Node.js/pnpm.c b/src/recipe/lang/Node.js/pnpm.c new file mode 100644 index 0000000..c89cbdb --- /dev/null +++ b/src/recipe/lang/Node.js/pnpm.c @@ -0,0 +1,90 @@ +/** ------------------------------------------------------------ + * SPDX-License-Identifier: GPL-3.0-or-later + * ------------------------------------------------------------- + * File Authors : Aoran Zeng + * Contributors : Nul None + * Created On : <2024-09-10> + * Major Revision : 1 + * Last Modified : <2024-09-10> + * ------------------------------------------------------------*/ + +/** + * @update 2024-04-08 + */ +static SourceInfo +pl_nodejs_pnpm_sources[] = { + {&Upstream, "https://registry.npmjs.org/"}, // @note 根据 pnpm 官网,有最后的斜线 + {&NpmMirror, "https://registry.npmmirror.com"}, + {&Huawei, "https://mirrors.huaweicloud.com/repository/npm/"}, + {&Zju, "https://mirrors.zju.edu.cn/npm"} +}; +def_sources_n(pl_nodejs_pnpm); + + +/** + * chsrc get pnpm + */ +void +pl_nodejs_pnpm_getsrc (char *option) +{ + chsrc_run ("pnpm config get registry", RunOpt_Default); +} + + +/** + * @consult https://pnpm.io/feature-comparison + * @consult https://pnpm.io/cli/config + * + * chsrc set pnpm + */ +void +pl_nodejs_pnpm_setsrc (char *option) +{ + chsrc_yield_source_and_confirm (pl_nodejs_pnpm); + + char *cmd = NULL; + + if (CliOpt_Locally) + cmd = xy_2strjoin ("pnpm config --location project set registry ", source.url); + else + cmd = xy_2strjoin ("pnpm config -g set registry ", source.url); + + chsrc_run (cmd, RunOpt_Default); + + chsrc_conclude (&source, ChsrcTypeAuto); +} + + +/** + * chsrc reset pnpm + */ +void +pl_nodejs_pnpm_resetsrc (char *option) +{ + pl_nodejs_pnpm_setsrc (ChsrcTypeReset); +} + + +/** + * chsrc ls pnpm + */ +FeatInfo +pl_nodejs_pnpm_feat (char *option) +{ + FeatInfo fi = {0}; + + fi.can_get = true; + fi.can_reset = true; + + fi.stcan_locally = CanFully; + fi.locally = NULL; + fi.can_english = true; + fi.can_user_define = true; + + fi.note = NULL; + return fi; +} + + +// 下列情形多选1 +def_target_gsrf(pl_nodejs_pnpm); diff --git a/src/recipe/menu.c b/src/recipe/menu.c index aee9205..576fb70 100644 --- a/src/recipe/menu.c +++ b/src/recipe/menu.c @@ -1,10 +1,11 @@ /** ------------------------------------------------------------ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- - * File Authors : Aoran Zeng - * Contributors : Nil Null - * Created On : <2023-09-01> - * Last Modified : <2024-08-16> + * File Authors : Aoran Zeng + * Contributors : Nil Null + * Created On : <2023-09-01> + * Major Revision : 1 + * Last Modified : <2024-09-10> * ------------------------------------------------------------*/ /* Begin Target Matrix */ @@ -12,7 +13,8 @@ static const char *pl_ruby [] = {"gem", "ruby", "rubygem", "rb", "rubygems", "bundler", NULL, t(&pl_ruby_target)}, *pl_python[] = {"pip", "python", "pypi", "py", "poetry", "pdm", NULL, t(&pl_python_target)}, -*pl_nodejs[] = {"npm", "node", "nodejs", "js", "yarn", "pnpm", NULL, t(&pl_nodejs_target)}, +*pl_nodejs[] = {"npm", "node", "nodejs", "js", "yarn", NULL, t(&pl_nodejs_target)}, +*pl_nodejs_pnpm[] = {"pnpm", NULL, t(&pl_nodejs_pnpm_target)}, *pl_perl [] = {"perl", "cpan", NULL, t(&pl_perl_target)}, *pl_php [] = {"php", "composer", NULL, t(&pl_php_target)}, *pl_lua [] = {"lua", "luarocks", NULL, t(&pl_lua_target)}, @@ -28,7 +30,9 @@ static const char *pl_julia [] = {"julia", NULL, t(&pl_julia_target)}, **pl_packagers[] = { - pl_ruby, pl_python, pl_nodejs, pl_perl, pl_php, pl_lua, + pl_ruby, pl_python, + pl_nodejs, pl_nodejs_pnpm, + pl_perl, pl_php, pl_lua, pl_rust, pl_go, /*pl_nuget,*/ pl_java, pl_clojure, pl_dart, pl_haskell, pl_ocaml, pl_r, pl_julia