mod.rs 1.9 KB

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