-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample_template.dart
More file actions
62 lines (55 loc) · 1.49 KB
/
sample_template.dart
File metadata and controls
62 lines (55 loc) · 1.49 KB
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
import '../workspace.dart';
/// Builds a String of valid YAML for an inline sample block.
///
/// This generates a sample entry that can be appended to an existing
/// task.yaml file under the `samples.inline:` key.
String sampleTemplate({
required String id,
required String difficulty,
WorkspaceType? workspaceType,
TemplatePackage? templatePackage,
String? workspaceValue,
}) {
final workspaceSection = _buildSampleWorkspaceSection(
workspaceType,
templatePackage: templatePackage,
workspaceValue: workspaceValue,
);
return '''
- id: $id
difficulty: $difficulty
tags: []$workspaceSection
input: |
# Write prompt here
target: |
# Write target here
''';
}
/// Builds workspace/tests lines for an inline sample block.
///
/// Only needed if the sample overrides the task-level workspace.
String _buildSampleWorkspaceSection(
WorkspaceType? workspaceType, {
TemplatePackage? templatePackage,
String? workspaceValue,
}) {
return switch (workspaceType) {
WorkspaceType.git =>
'''
workspace:
git: ${workspaceValue ?? '<GIT_REPOSITORY_URL>'}''',
WorkspaceType.path =>
'''
workspace:
path: ${workspaceValue ?? '<RELATIVE_PATH>'}''',
WorkspaceType.template =>
'''
workspace:
template: ${templatePackage?.yamlValue ?? '<flutter_app OR jaspr_app OR dart_package>'}''',
WorkspaceType.create =>
'''
workspace:
path: ./project''',
_ => '',
};
}