forked from forcedotcom/salesforcedx-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyticsTemplateGenerator.ts
More file actions
106 lines (102 loc) · 3.11 KB
/
Copy pathanalyticsTemplateGenerator.ts
File metadata and controls
106 lines (102 loc) · 3.11 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
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
/*
* Copyright (c) 2019, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as path from 'path';
import { nls } from '../i18n';
import { CreateUtil } from '../utils';
import { AnalyticsTemplateOptions } from '../utils/types';
import { BaseGenerator } from './baseGenerator';
export default class AnalyticsTemplateGenerator extends BaseGenerator<AnalyticsTemplateOptions> {
public validateOptions(): void {
CreateUtil.checkInputs(this.options.templatename);
const fileparts = path.resolve(this.outputdir).split(path.sep);
if (!fileparts.includes('waveTemplates')) {
throw new Error(nls.localize('MissingWaveTemplatesDir'));
}
}
public async generate(): Promise<void> {
const { templatename } = this.options;
this.sourceRootWithPartialPath(path.join('analytics', 'waveTemplates'));
await this.render(
this.templatePath(
path.join(
'DefaultAnalyticsTemplate',
'dashboards',
'basicDashboard.json'
)
),
this.destinationPath(
path.join(
this.outputdir,
templatename,
'dashboards',
templatename + 'Dashboard.json'
)
),
{ templateName: templatename }
);
await this.render(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'app-to-template-rules.json')
),
this.destinationPath(
path.join(this.outputdir, templatename, 'app-to-template-rules.json')
),
{}
);
await this.render(
this.templatePath(path.join('DefaultAnalyticsTemplate', 'folder.json')),
this.destinationPath(
path.join(this.outputdir, templatename, 'folder.json')
),
{ templateName: templatename }
);
await this.render(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'releaseNotes.html')
),
this.destinationPath(
path.join(this.outputdir, templatename, 'releaseNotes.html')
),
{}
);
await this.render(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'template-info.json')
),
this.destinationPath(
path.join(this.outputdir, templatename, 'template-info.json')
),
{
templateName: templatename,
sourceApiVersion: this.apiversion,
}
);
await this.render(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'template-to-app-rules.json')
),
this.destinationPath(
path.join(this.outputdir, templatename, 'template-to-app-rules.json')
),
{}
);
await this.render(
this.templatePath(path.join('DefaultAnalyticsTemplate', 'ui.json')),
this.destinationPath(path.join(this.outputdir, templatename, 'ui.json')),
{}
);
await this.render(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'variables.json')
),
this.destinationPath(
path.join(this.outputdir, templatename, 'variables.json')
),
{}
);
}
}