forked from forcedotcom/salesforcedx-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightningInterfaceGenerator.ts
More file actions
53 lines (48 loc) · 1.64 KB
/
Copy pathlightningInterfaceGenerator.ts
File metadata and controls
53 lines (48 loc) · 1.64 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
/*
* 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 { LightningInterfaceOptions } from '../utils/types';
import { BaseGenerator } from './baseGenerator';
export default class LightningInterfaceGenerator extends BaseGenerator<LightningInterfaceOptions> {
public validateOptions(): void {
CreateUtil.checkInputs(this.options.interfacename);
CreateUtil.checkInputs(this.options.template);
const fileparts = path.resolve(this.outputdir).split(path.sep);
if (!this.options.internal && !fileparts.includes('aura')) {
throw new Error(nls.localize('MissingAuraDir'));
}
}
public async generate(): Promise<void> {
const { template, interfacename, internal } = this.options;
this.sourceRootWithPartialPath('lightninginterface');
if (!internal) {
await this.render(
this.templatePath('_auradefinitionbundle.intf-meta.xml'),
this.destinationPath(
path.join(
this.outputdir,
interfacename,
`${interfacename}.intf-meta.xml`
)
),
{
apiVersion: this.apiversion,
description: nls.localize('LightningInterfaceBundle'),
}
);
}
await this.render(
this.templatePath(`${template}.intf`),
this.destinationPath(
path.join(this.outputdir, interfacename, `${interfacename}.intf`)
),
{}
);
}
}