Skip to content

Commit ffaee0b

Browse files
committed
Support Bun
[GitHub #83]
1 parent aed5256 commit ffaee0b

File tree

3 files changed

+106
-29
lines changed

3 files changed

+106
-29
lines changed

src/chsrc-main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "recipe/lang/Node.js/pnpm.c"
4040
#include "recipe/lang/Node.js/Yarn.c"
4141
#include "recipe/lang/Node.js/Node.js.c"
42+
#include "recipe/lang/Node.js/Bun.c"
4243
#include "recipe/lang/Node.js/nvm.c"
4344

4445
#include "recipe/lang/Perl.c"

src/recipe/lang/Node.js/Bun.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/** ------------------------------------------------------------
2+
* SPDX-License-Identifier: GPL-3.0-or-later
3+
* -------------------------------------------------------------
4+
* File Authors : Aoran Zeng <[email protected]>
5+
* Contributors : Nul None <[email protected]>
6+
* Created On : <2024-09-29>
7+
* Last Modified : <2024-09-29>
8+
* ------------------------------------------------------------*/
9+
10+
/**
11+
* chsrc get bun
12+
*/
13+
void
14+
pl_nodejs_bun_getsrc (char *option)
15+
{
16+
chsrc_view_file ("~/.bun/bunfig.toml");
17+
}
18+
19+
20+
/**
21+
* @consult https://bun.sh/guides/install/custom-registry
22+
* @consult https://github.com/RubyMetric/chsrc/issues/83
23+
*
24+
* chsrc set bun
25+
*/
26+
void
27+
pl_nodejs_bun_setsrc (char *option)
28+
{
29+
char *chsrc_type = xy_streql (option, ChsrcTypeReset) ? ChsrcTypeReset : ChsrcTypeManual;
30+
chsrc_yield_source (pl_nodejs);
31+
32+
char *file = xy_strjoin(3, "[install]\n"
33+
"registry = \"", source.url, "\"");
34+
35+
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_uniform_path ("~/.bun/bunfig.toml"), " 文件中:"));
36+
puts (file);
37+
38+
chsrc_conclude (&source, chsrc_type);
39+
}
40+
41+
42+
/**
43+
* chsrc reset bun
44+
*/
45+
void
46+
pl_nodejs_bun_resetsrc (char *option)
47+
{
48+
pl_nodejs_bun_setsrc (ChsrcTypeReset);
49+
}
50+
51+
52+
/**
53+
* chsrc ls bun
54+
*/
55+
FeatInfo
56+
pl_nodejs_bun_feat (char *option)
57+
{
58+
FeatInfo fi = {0};
59+
60+
fi.can_get = true;
61+
fi.can_reset = true;
62+
63+
fi.stcan_locally = CanFully;
64+
fi.locally = NULL;
65+
fi.can_english = true;
66+
fi.can_user_define = true;
67+
68+
fi.note = NULL;
69+
return fi;
70+
}
71+
72+
// def_target_gsrf(pl_nodejs_bun);
73+
TargetInfo pl_nodejs_bun_target = {def_target_inner_gsrf(pl_nodejs_bun),def_target_sourcesn(pl_nodejs)};

src/recipe/menu.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,48 @@
55
* Contributors : Nil Null <[email protected]>
66
* Created On : <2023-09-01>
77
* Major Revision : 1
8-
* Last Modified : <2024-09-23>
8+
* Last Modified : <2024-09-29>
99
* ------------------------------------------------------------*/
1010

1111
/* Begin Target Matrix */
1212
#define t(a) (const char*)(a)
1313
static const char
1414
*pl_ruby [] = {"gem", "ruby", "rb", "rubygem", "rubygems", "bundler", NULL, t(&pl_ruby_target)},
15-
*pl_python[] = {"python", "pypi", "py", NULL, t(&pl_python_target)},
16-
*pl_python_pip[] = {"pip", NULL, t(&pl_python_pip_target)},
17-
*pl_python_poetry[] = {"poetry", NULL, t(&pl_python_poetry_target)},
18-
*pl_python_pdm[] = {"pdm", NULL, t(&pl_python_pdm_target)},
19-
20-
*pl_nodejs[] = {"node", "nodejs", NULL, t(&pl_nodejs_target)},
21-
*pl_nodejs_npm[] = {"npm", NULL, t(&pl_nodejs_npm_target)},
22-
*pl_nodejs_yarn[] = {"yarn", NULL, t(&pl_nodejs_yarn_target)},
23-
*pl_nodejs_pnpm[] = {"pnpm", NULL, t(&pl_nodejs_pnpm_target)},
24-
*pl_nodejs_nvm[] = {"nvm", NULL, t(&pl_nodejs_nvm_target)},
25-
26-
*pl_perl [] = {"perl", "cpan", NULL, t(&pl_perl_target)},
27-
*pl_php [] = {"php", "composer", NULL, t(&pl_php_target)},
28-
*pl_lua [] = {"lua", "luarocks", NULL, t(&pl_lua_target)},
29-
*pl_go [] = {"go", "golang", "goproxy", NULL, t(&pl_go_target)} ,
30-
*pl_rust [] = {"rust", "cargo", "crate", "crates", NULL, t(&pl_rust_target)},
31-
*pl_java [] = {"java", "maven", "mvn", "gradle", NULL, t(&pl_java_target)},
32-
*pl_clojure[]= {"clojure","clojars","cloj", "lein", "leiningen", NULL, t(&pl_clojure_target)},
33-
34-
*pl_dart [] = {"dart", "pub", NULL, t(&pl_dart_target)},
35-
*pl_dart_flutter [] = {"flutter",NULL, t(&pl_dart_flutter_target)},
36-
37-
*pl_nuget[] = {"nuget", "net", ".net", "dotnet", NULL, t(&pl_nuget_target)},
38-
*pl_haskell[]= {"haskell", "cabal", "stack", "hackage", NULL, t(&pl_haskell_target)},
39-
*pl_ocaml[] = {"ocaml", "opam", NULL, t(&pl_ocaml_target)},
40-
*pl_r [] = {"cran", "r", NULL, t(&pl_r_target)},
41-
*pl_julia [] = {"julia", NULL, t(&pl_julia_target)},
15+
16+
*pl_python[] = {"python", "pypi", "py", NULL, t(&pl_python_target)},
17+
*pl_python_pip[] = {"pip", NULL, t(&pl_python_pip_target)},
18+
*pl_python_poetry[] = {"poetry", NULL, t(&pl_python_poetry_target)},
19+
*pl_python_pdm[] = {"pdm", NULL, t(&pl_python_pdm_target)},
20+
21+
*pl_nodejs[] = {"node", "nodejs", NULL, t(&pl_nodejs_target)},
22+
*pl_nodejs_bun[] = {"bun", NULL, t(&pl_nodejs_bun_target)},
23+
*pl_nodejs_npm[] = {"npm", NULL, t(&pl_nodejs_npm_target)},
24+
*pl_nodejs_yarn[] = {"yarn", NULL, t(&pl_nodejs_yarn_target)},
25+
*pl_nodejs_pnpm[] = {"pnpm", NULL, t(&pl_nodejs_pnpm_target)},
26+
*pl_nodejs_nvm[] = {"nvm", NULL, t(&pl_nodejs_nvm_target)},
27+
28+
*pl_perl [] = {"perl", "cpan", NULL, t(&pl_perl_target)},
29+
*pl_php [] = {"php", "composer", NULL, t(&pl_php_target)},
30+
*pl_lua [] = {"lua", "luarocks", NULL, t(&pl_lua_target)},
31+
*pl_go [] = {"go", "golang", "goproxy", NULL, t(&pl_go_target)} ,
32+
*pl_rust [] = {"rust", "cargo", "crate", "crates", NULL, t(&pl_rust_target)},
33+
*pl_java [] = {"java", "maven", "mvn", "gradle", NULL, t(&pl_java_target)},
34+
*pl_clojure[]= {"clojure","clojars","cloj", "lein", NULL, t(&pl_clojure_target)},
35+
36+
*pl_dart [] = {"dart", "pub", NULL, t(&pl_dart_target)},
37+
*pl_dart_flutter [] = {"flutter", NULL, t(&pl_dart_flutter_target)},
38+
39+
*pl_nuget[] = {"nuget", "net", ".net", "dotnet", NULL, t(&pl_nuget_target)},
40+
*pl_haskell[]= {"haskell", "cabal", "stack", "hackage", NULL, t(&pl_haskell_target)},
41+
*pl_ocaml[] = {"ocaml", "opam", NULL, t(&pl_ocaml_target)},
42+
*pl_r [] = {"cran", "r", NULL, t(&pl_r_target)},
43+
*pl_julia [] = {"julia", NULL, t(&pl_julia_target)},
4244
**pl_packagers[] =
4345
{
4446
pl_ruby,
4547
pl_python, pl_python_pip, pl_python_poetry, pl_python_pdm,
46-
pl_nodejs, pl_nodejs_npm, pl_nodejs_pnpm, pl_nodejs_yarn,
48+
pl_nodejs, pl_nodejs_bun,
49+
pl_nodejs_npm, pl_nodejs_pnpm, pl_nodejs_yarn,
4750
pl_nodejs_nvm,
4851
pl_perl, pl_php,
4952
pl_lua,

0 commit comments

Comments
 (0)