forked from forcedotcom/salesforcedx-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightningAppGenerator.ts
More file actions
90 lines (86 loc) · 2.75 KB
/
Copy pathlightningAppGenerator.ts
File metadata and controls
90 lines (86 loc) · 2.75 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
/*
* 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 { LightningAppOptions } from '../utils/types';
import { BaseGenerator } from './baseGenerator';
export default class LightningAppGenerator extends BaseGenerator<LightningAppOptions> {
public validateOptions(): void {
CreateUtil.checkInputs(this.options.appname);
CreateUtil.checkInputs(this.options.template);
const fileparts = path.resolve(this.outputdir).split(path.sep);
if (!fileparts.includes('aura') && !this.options.internal) {
throw new Error(nls.localize('MissingAuraDir'));
}
}
public async generate(): Promise<void> {
const { template, appname, internal } = this.options;
this.sourceRootWithPartialPath('lightningapp');
if (!internal) {
await this.render(
this.templatePath('_auradefinitionbundle.app-meta.xml'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}.app-meta.xml`)
),
{
apiVersion: this.apiversion,
description: nls.localize('LightningAppBundle'),
}
);
}
await this.render(
this.templatePath(`${template}.app`),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}.app`)
),
{}
),
await this.render(
this.templatePath('DefaultLightningAuradoc.auradoc'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}.auradoc`)
),
{}
),
await this.render(
this.templatePath('DefaultLightningController.js'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}Controller.js`)
),
{}
),
await this.render(
this.templatePath('DefaultLightningCss.css'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}.css`)
),
{}
),
await this.render(
this.templatePath('DefaultLightningHelper.js'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}Helper.js`)
),
{}
),
await this.render(
this.templatePath('DefaultLightningRenderer.js'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}Renderer.js`)
),
{}
),
await this.render(
this.templatePath('DefaultLightningSVG.svg'),
this.destinationPath(
path.join(this.outputdir, appname, `${appname}.svg`)
),
{}
);
}
}