-
Notifications
You must be signed in to change notification settings - Fork 27
/
start.ts
44 lines (33 loc) · 1.33 KB
/
start.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
import { SfdxCommand } from '@salesforce/command';
import { Messages } from '@salesforce/core';
import { AnyJson } from '@salesforce/ts-types';
import { post } from 'request-promise';
// Initialize Messages with the current plugin directory
Messages.importMessagesDirectory(__dirname);
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
// or any library that is using the messages framework can also be loaded this way.
const messages = Messages.loadMessages('sfdx-waw-plugin', 'waw');
export default class ApexLogGet extends SfdxCommand {
public static description = messages.getMessage('codeclean.check.description');
public static examples = [];
protected static requiresUsername = true;
public async run(): Promise<AnyJson> {
// Make sure we have a valid access token
await this.org.refreshAuth();
const startApi = 'https://sfcodeclean.herokuapp.com/api/job/';
const data = {
accessToken: this.org.getConnection().accessToken,
instanceUrl: this.org.getConnection().instanceUrl
};
this.logger.debug('using connection information: ', data);
const options = {
uri: startApi,
method: 'POST',
json: data
};
// Is this the body or request?
const body = await post(options);
this.ux.styledJSON(body);
return { body };
}
}