forked from forcedotcom/salesforcedx-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apexClassGenerator.ts
38 lines (35 loc) · 1.25 KB
/
apexClassGenerator.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
/*
* 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 { CreateUtil } from '../utils';
import { ApexClassOptions } from '../utils/types';
import { SfdxGenerator } from './sfdxGenerator';
export default class ApexClassGenerator extends SfdxGenerator<ApexClassOptions> {
constructor(args: string | string[], options: ApexClassOptions) {
super(args, options);
this.sourceRootWithPartialPath('apexclass');
}
public validateOptions(): void {
CreateUtil.checkInputs(this.options.template);
CreateUtil.checkInputs(this.options.classname);
}
public writing(): void {
const { template, classname } = this.options;
this.fs.copyTpl(
this.templatePath(`${template}.cls`),
this.destinationPath(path.join(this.outputdir, `${classname}.cls`)),
{ apiName: classname }
),
this.fs.copyTpl(
this.templatePath('_class.cls-meta.xml'),
this.destinationPath(
path.join(this.outputdir, `${classname}.cls-meta.xml`)
),
{ apiName: classname, apiVersion: this.apiversion }
);
}
}