-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathurl.ts
33 lines (26 loc) · 1.12 KB
/
url.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
import { flags, SfdxCommand } from '@salesforce/command';
import { getExternalApps } from '../../../shared/community';
export default class CommunityUrl extends SfdxCommand {
public static description = 'get me the login for a community from an org';
public static examples = ['sfdx shane:communities:url --prefix dealers'];
protected static flagsConfig = {
prefix: flags.string({ char: 'p', required: false, description: 'community prefix (thing after the slash in the url)' })
};
protected static requiresUsername = true;
public async run(): Promise<any> {
const conn = this.org.getConnection();
const extApps = await getExternalApps(conn);
let output;
if (this.flags.prefix) {
if (extApps.communities[this.flags.prefix]) {
output = `https://${extApps.domain}/${this.flags.prefix}`;
} else {
throw new Error(`There is no community with prefix ${this.flags.prefix}`);
}
} else {
output = `https://${extApps.domain}`;
}
this.ux.log(output);
return output;
}
}