1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
extern crate os_info;
pub fn bom_data_yaml_template() -> String {
let nl = &get_newline();
let mut contents = String::from("# Bill of Materials Data for {{name}}");
contents.push_str(nl);
contents.push_str("parts:");
contents.push_str(nl);
contents.push_str(" component_1:");
contents.push_str(nl);
contents.push_str(" options:");
contents.push_str(nl);
contents.push_str(" - specific_component_variation");
contents.push_str(nl);
contents.push_str(" default_option: 0");
contents.push_str(nl);
contents.push_str(" quantity: 1");
contents.push_str(nl);
contents.push_str(" quantity_units: part");
contents.push_str(nl);
contents.push_str(" name: Sample Component");
contents.push_str(nl);
contents.push_str(" notes: ''");
contents.push_str(nl);
contents.push_str(nl);
contents.push_str("order:");
contents.push_str(nl);
contents.push_str(" -component_1");
contents.push_str(nl);
contents
}
pub fn gitignore_template() -> String {
let nl = &get_newline();
let mut contents = String::from("# Dependency directories");
contents.push_str(nl);
contents.push_str("node_modules/");
contents.push_str(nl);
contents.push_str(nl);
contents.push_str("# Distribution directory");
contents.push_str(nl);
contents.push_str("dist/");
contents.push_str(nl);
contents
}
pub fn package_json_template() -> String {
let nl = &get_newline();
let mut contents = String::from("{");
contents.push_str(nl);
contents.push_str(" \"name\": \"{{name}}\",");
contents.push_str(nl);
contents.push_str(" \"version\": \"1.0.0\",");
contents.push_str(nl);
contents.push_str(" \"description\": \"Sliderule DOF component.\",");
contents.push_str(nl);
contents.push_str(" \"license\": \"{{license}}\",");
contents.push_str(nl);
contents.push_str(" \"dependencies\": {");
contents.push_str(nl);
contents.push_str(" }");
contents.push_str(nl);
contents.push_str("}");
contents.push_str(nl);
contents
}
pub fn readme_template() -> String {
let nl = &get_newline();
let mut contents = String::from("# {{name}}");
contents.push_str(nl);
contents.push_str("New Sliderule component.");
contents.push_str(nl);
contents.push_str(nl);
contents.push_str("---");
contents.push_str(nl);
contents.push_str("Developed in [Sliderule](http://sliderule.io) an implementation of the [Distributed OSHW Framework](http://dof.sliderule.io).");
contents.push_str(nl);
contents
}
pub fn sr_file_template() -> String {
let nl = &get_newline();
let mut contents = String::from("source_license: {{source_license}},");
contents.push_str(nl);
contents.push_str("documentation_license: {{doc_license}}");
contents.push_str(nl);
contents
}
fn get_newline() -> String {
let info = os_info::get();
if info.os_type() == os_info::Type::Windows {
String::from("\r\n")
} else {
String::from("\n")
}
}