forked from forcedotcom/salesforcedx-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyticsTemplateGenerator.ts
110 lines (106 loc) · 3.2 KB
/
analyticsTemplateGenerator.ts
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
/*
* 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 { SfdxGenerator } from './sfdxGenerator';
export default class AnalyticsTemplateGenerator extends SfdxGenerator<
AnalyticsTemplateOptions
> {
constructor(args: string | string[], options: AnalyticsTemplateOptions) {
super(args, options);
this.sourceRootWithPartialPath(path.join('analytics', 'waveTemplates'));
}
public validateOptions() {
CreateUtil.checkInputs(this.options.templatename);
const fileparts = path.resolve(this.options.outputdir).split(path.sep);
if (!fileparts.includes('waveTemplates')) {
throw new Error(nls.localize('MissingWaveTemplatesDir'));
}
}
public writing() {
const { outputdir, templatename, apiversion } = this.options;
// tslint:disable-next-line:no-unused-expression
this.fs.copyTpl(
this.templatePath(
path.join(
'DefaultAnalyticsTemplate',
'dashboards',
'basicDashboard.json'
)
),
this.destinationPath(
path.join(
outputdir,
templatename,
'dashboards',
templatename + 'Dashboard.json'
)
),
{ templateName: templatename }
);
this.fs.copyTpl(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'app-to-template-rules.json')
),
this.destinationPath(
path.join(outputdir, templatename, 'app-to-template-rules.json')
),
{}
);
this.fs.copyTpl(
this.templatePath(path.join('DefaultAnalyticsTemplate', 'folder.json')),
this.destinationPath(path.join(outputdir, templatename, 'folder.json')),
{ templateName: templatename }
);
this.fs.copyTpl(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'releaseNotes.html')
),
this.destinationPath(
path.join(outputdir, templatename, 'releaseNotes.html')
),
{}
);
this.fs.copyTpl(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'template-info.json')
),
this.destinationPath(
path.join(outputdir, templatename, 'template-info.json')
),
{
templateName: templatename,
sourceApiVersion: apiversion
}
);
this.fs.copyTpl(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'template-to-app-rules.json')
),
this.destinationPath(
path.join(outputdir, templatename, 'template-to-app-rules.json')
),
{}
);
this.fs.copyTpl(
this.templatePath(path.join('DefaultAnalyticsTemplate', 'ui.json')),
this.destinationPath(path.join(outputdir, templatename, 'ui.json')),
{}
);
this.fs.copyTpl(
this.templatePath(
path.join('DefaultAnalyticsTemplate', 'variables.json')
),
this.destinationPath(
path.join(outputdir, templatename, 'variables.json')
),
{}
);
}
}