-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathtab.ts
156 lines (148 loc) · 4.38 KB
/
tab.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import { flags, SfdxCommand } from '@salesforce/command';
import chalk from 'chalk';
import { writeJSONasXML } from '@mshanemc/plugin-helpers/dist/JSONXMLtools';
import { removeTrailingSlash } from '../../../shared/flagParsing';
import fs = require('fs-extra');
export default class ObjectTab extends SfdxCommand {
public static description = 'create a tab from a custom object, and you have to pick an icon';
public static examples = [
`sfdx shane:object:tab -o SomeObject__c -i 86
// create a tab for the object using icon #86 from https://lightningdesignsystem.com/icons/#custom
`
];
protected static flagsConfig = {
object: flags.string({ char: 'o', required: true, description: 'object api name' }),
icon: flags.integer({
char: 'i',
required: true,
min: 1,
max: 100,
description: 'icon number from https://lightningdesignsystem.com/icons/#custom but only up to 100'
}),
target: flags.directory({
char: 't',
default: 'force-app/main/default',
description: "where to create the folder (if it doesn't exist already) and file...defaults to force-app/main/default",
parse: input => removeTrailingSlash(input)
})
};
protected static requiresProject = true;
public async run(): Promise<any> {
// make sure the tabs directory exists
await fs.ensureDir(`${this.flags.target}/tabs`);
await writeJSONasXML({
path: `${this.flags.target}/tabs/${this.flags.object}.tab-meta.xml`,
type: 'CustomTab',
json: {
'@': {
xmlns: 'http://soap.sforce.com/2006/04/metadata'
},
customObject: true,
motif: tabDefs.find(tab => tab.includes(`Custom${this.flags.icon}:`))
}
});
this.ux.log(chalk.green('Tab created locally.'));
}
}
const tabDefs = [
'Custom20: Airplane',
'Custom25: Alarm clock',
'Custom51: Apple',
'Custom52: Balls',
'Custom16: Bank',
'Custom53: Bell',
'Custom50: Big top',
'Custom54: Boat',
'Custom55: Books',
'Custom56: Bottle',
'Custom13: Box',
'Custom37: Bridge',
'Custom24: Building',
'Custom57: Building Block',
'Custom58: Caduceus',
'Custom38: Camera',
'Custom59: Can',
'Custom31: Car',
'Custom61: Castle',
'Custom49: CD/DVD',
'Custom28: Cell phone',
'Custom62: Chalkboard',
'Custom47: Knight',
'Custom63: Chip',
'Custom12: Circle',
'Custom64: Compass',
'Custom21: Computer',
'Custom40: Credit card',
'Custom99: TV CRT',
'Custom65: Cup',
'Custom33: Desk',
'Custom8: Diamond',
'Custom66: Dice',
'Custom32: Factory',
'Custom2: Fan',
'Custom26: Flag',
'Custom18: Form',
'Custom67: Gears',
'Custom68: Globe',
'Custom69: Guitar',
'Custom44: Hammer',
'Custom14: Hands',
'Custom70: Handsaw',
'Custom71: Headset',
'Custom1: Heart',
'Custom72: Helicopter',
'Custom4: Hexagon ',
'Custom73: Highway Sign',
'Custom74: Hot Air Balloon',
'Custom34: Insect',
'Custom75: IP Phone',
'Custom43: Jewel',
'Custom76: Keys',
'Custom27: Laptop',
'Custom5: Leaf',
'Custom9: Lightning',
'Custom77: Locked',
'Custom23: Envelope',
'Custom78: Map',
'Custom79: Measuring Tape',
'Custom35: Microphone',
'Custom10: Moon',
'Custom80: Motorcycle',
'Custom81: Musical Note',
'Custom29: PDA',
'Custom83: Pencil',
'Custom15: People',
'Custom22: Telephone',
'Custom46: Stamp',
'Custom84: Presenter',
'Custom30: Radar dish',
'Custom85: Real Estate Sign',
'Custom86: Red Cross',
'Custom17: Sack',
'Custom87: Safe',
'Custom88: Sailboat',
'Custom89: Saxophone',
'Custom90: Scales',
'Custom91: Shield',
'Custom92: Ship',
'Custom93: Shopping Cart',
'Custom7: Square',
'Custom41: Cash',
'Custom11: Star',
'Custom94: Stethoscope',
'Custom95: Stopwatch',
'Custom96: Street Sign',
'Custom3: Sun',
'Custom39: Telescope',
'Custom97: Thermometer',
'Custom45: Ticket',
'Custom36: Train',
'Custom42: Treasure chest',
'Custom6: Triangle',
'Custom48: Trophy',
'Custom98: Truck',
'Custom100: TV Widescreen',
'Custom60: Umbrella',
'Custom82: Whistle',
'Custom19: Wrench'
];