Bump version to v0.1.3

This commit is contained in:
Aoran Zeng 2024-04-18 23:16:50 +08:00
parent 6ff06c41b4
commit 58da758b21

76
chsrc.c
View File

@ -12,7 +12,7 @@
* GPLv3 LICENSE.txt
* ------------------------------------------------------------*/
#define Chsrc_Version "v0.1.2-2023/10/05"
#define Chsrc_Version "v0.1.3-2024/04/18"
#include "chsrc.h"
@ -27,7 +27,8 @@ void
pl_ruby_remove_gem_source (const char *source)
{
char *cmd = NULL;
if (xy_str_start_with(source, "http")){
if (xy_str_start_with (source, "http"))
{
cmd = xy_str_delete_suffix (source, "\n");
cmd = xy_2strjoin ("gem sources -r ", cmd);
chsrc_run (cmd);
@ -43,7 +44,8 @@ pl_ruby_setsrc (char* option)
int index = 0;
char *check_cmd = xy_str_to_quietcmd ("gem -v");
bool exist = query_program_exist (check_cmd, "gem");
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 gem 命令,请检查是否存在");
return;
}
@ -62,7 +64,8 @@ pl_ruby_setsrc (char* option)
check_cmd = xy_str_to_quietcmd ("bundle -v");
exist = query_program_exist (check_cmd, "bundle");
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 bundle 命令,请检查是否存在");
return;
}
@ -89,16 +92,19 @@ pl_python_check_cmd (char** prog)
char *check_cmd = xy_str_to_quietcmd ("python --version");
bool exist = query_program_exist (check_cmd, "python");
if (!exist) {
if (!exist)
{
check_cmd = xy_str_to_quietcmd ("python3 --version");
exist = query_program_exist (check_cmd, "python3");
if (exist) *prog = "python3";
}
else {
else
{
*prog = "python";
}
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 Python 相关命令,请检查是否存在");
exit (1);
}
@ -149,7 +155,8 @@ pl_nodejs_check_cmd (bool* npm_exist, bool* yarn_exist, bool* pnpm_exist)
check_cmd = xy_str_to_quietcmd ("pnpm -v");
*pnpm_exist = query_program_exist (check_cmd, "pnpm");
if (!*npm_exist && !*yarn_exist && !*pnpm_exist) {
if (!*npm_exist && !*yarn_exist && !*pnpm_exist)
{
chsrc_error ("未找到 npm 或 yarn 或 pnpm 命令,请检查是否存在其一");
exit (1);
}
@ -162,13 +169,16 @@ pl_nodejs_getsrc (char* option)
bool npm_exist, yarn_exist, pnpm_exist;
pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
if (npm_exist) {
if (npm_exist)
{
chsrc_run ("npm config get registry");
}
if (yarn_exist) {
if (yarn_exist)
{
chsrc_run ("yarn config get registry");
}
if (pnpm_exist) {
if (pnpm_exist)
{
chsrc_run ("pnpm config get registry");
}
}
@ -187,21 +197,23 @@ pl_nodejs_setsrc (char* option)
SourceInfo source = pl_nodejs_sources[index];
chsrc_say_selection (&source);
char *cmd = NULL;
if (npm_exist)
{
char* cmd = xy_2strjoin("npm config set registry ", source.url);
cmd = xy_2strjoin ("npm config set registry ", source.url);
chsrc_run (cmd);
}
if (yarn_exist)
{
char* cmd = xy_str_to_quietcmd(xy_2strjoin("yarn config set registry ", source.url));
cmd = xy_str_to_quietcmd (xy_2strjoin ("yarn config set registry ", source.url));
chsrc_run (cmd);
}
if (pnpm_exist)
{
char* cmd = xy_str_to_quietcmd(xy_2strjoin("pnpm config set registry ", source.url));
cmd = xy_str_to_quietcmd (xy_2strjoin ("pnpm config set registry ", source.url));
chsrc_run (cmd);
}
@ -216,7 +228,8 @@ pl_perl_check_cmd ()
char *check_cmd = xy_str_to_quietcmd ("perl --version");
bool exist = query_program_exist (check_cmd, "perl");
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 perl 命令,请检查是否存在");
exit (1);
}
@ -261,7 +274,8 @@ pl_php_check_cmd ()
char *check_cmd = xy_str_to_quietcmd ("composer --version");
bool exist = query_program_exist (check_cmd, "composer");
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 composer 命令,请检查是否存在");
exit (1);
}
@ -339,7 +353,8 @@ pl_go_check_cmd ()
char *check_cmd = xy_str_to_quietcmd ("go version");
bool exist = query_program_exist (check_cmd, "go");
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 go 相关命令,请检查是否存在");
exit (1);
}
@ -433,7 +448,8 @@ pl_java_check_cmd (bool* maven_exist, bool* gradle_exist)
check_cmd = xy_str_to_quietcmd ("gradle --version");
*gradle_exist = query_program_exist (check_cmd, "gradle");
if (! *maven_exist && ! *gradle_exist) {
if (! *maven_exist && ! *gradle_exist)
{
chsrc_error ("maven 与 gradle 命令均未找到,请检查是否存在其一");
exit (1);
}
@ -475,7 +491,8 @@ pl_java_setsrc (char* option)
SourceInfo source = pl_java_sources[index];
chsrc_say_selection(&source);
if (maven_exist) {
if (maven_exist)
{
const char *file = xy_strjoin (7,
"<mirror>\n"
" <id>", source.mirror->code, "</id>\n"
@ -490,7 +507,8 @@ pl_java_setsrc (char* option)
puts (file);
}
if (gradle_exist) {
if (gradle_exist)
{
if (maven_exist) puts("");
const char* file = xy_strjoin (3,
"allprojects {\n"
@ -528,10 +546,13 @@ void
pl_dart_getsrc (char *option)
{
char *cmd = NULL;
if (xy_on_windows) {
if (xy_on_windows)
{
cmd = "set PUB_HOSTED_URL & set FLUTTER_STORAGE_BASE_URL";
chsrc_run (cmd);
} else {
}
else
{
cmd = "echo $PUB_HOSTED_URL; echo $FLUTTER_STORAGE_BASE_URL";
chsrc_run (cmd);
}
@ -573,7 +594,6 @@ pl_dart_setsrc (char* option)
chsrc_append_to_file (towrite, xy_win_powershellv5_profile);
}
}
else
{
towrite = xy_strjoin (3, "export PUB_HOSTED_URL=\"", pub, "\"");
@ -638,7 +658,8 @@ pl_ocaml_check_cmd ()
char *check_cmd = xy_str_to_quietcmd("opam --version");
bool exist = query_program_exist (check_cmd, "opam");
if (!exist) {
if (!exist)
{
chsrc_error ("未找到 opam 命令,请检查是否存在");
exit (1);
}
@ -686,9 +707,12 @@ pl_r_getsrc (char* option)
// options()$repos
// options()$BioC_mirror
//
if (xy_on_windows) {
if (xy_on_windows)
{
chsrc_check_file ("~/Documents/.Rprofile");
} else {
}
else
{
chsrc_check_file ("~/.Rprofile");
}
}