mod.rs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. use crate::VERSION;
  2. use heck::ToSnakeCase;
  3. pub const ANCHOR_VERSION: &str = anchor_cli::VERSION;
  4. pub fn workspace_manifest() -> String {
  5. format!(
  6. include_str!("workspace.toml.template"),
  7. VERSION = VERSION,
  8. ANCHOR_VERSION = ANCHOR_VERSION
  9. )
  10. }
  11. pub fn package_json(jest: bool) -> String {
  12. if jest {
  13. include_str!("jest.package.json.template").to_string()
  14. } else {
  15. include_str!("package.json.template").to_string()
  16. }
  17. }
  18. pub fn ts_package_json(jest: bool) -> String {
  19. if jest {
  20. include_str!("jest.ts.package.json.template").to_string()
  21. } else {
  22. include_str!("ts.package.json.template").to_string()
  23. }
  24. }
  25. pub fn mocha(name: &str) -> String {
  26. format!(include_str!("mocha.js.template"), name)
  27. }
  28. pub fn jest(name: &str) -> String {
  29. format!(include_str!("jest.js.template"), name)
  30. }
  31. pub fn ts_mocha(name: &str) -> String {
  32. format!(include_str!("mocha.ts.template"), name)
  33. }
  34. pub fn cargo_toml(name: &str) -> String {
  35. let snake_case_name = name.to_snake_case();
  36. format!(
  37. include_str!("Cargo.toml.template"),
  38. name = name,
  39. snake_case_name = snake_case_name,
  40. VERSION = VERSION
  41. )
  42. }
  43. /// TODO: Remove serde dependency
  44. pub fn cargo_toml_with_serde(name: &str) -> String {
  45. let snake_case_name = name.to_snake_case();
  46. format!(
  47. include_str!("Cargo.serde.toml.template"),
  48. name = name,
  49. snake_case_name = snake_case_name,
  50. VERSION = VERSION
  51. )
  52. }
  53. pub fn xargo_toml() -> &'static str {
  54. include_str!("Xargo.toml.template")
  55. }
  56. pub fn git_ignore() -> &'static str {
  57. include_str!(".gitignore.template")
  58. }
  59. pub fn prettier_ignore() -> &'static str {
  60. include_str!(".prettierignore.template")
  61. }
  62. pub(crate) fn types_cargo_toml() -> String {
  63. let name = "bolt-types";
  64. let snake_case_name = name.to_snake_case();
  65. format!(
  66. include_str!("types.Cargo.toml.template"),
  67. name = name,
  68. snake_case_name = snake_case_name,
  69. VERSION = VERSION
  70. )
  71. }