-
Notifications
You must be signed in to change notification settings - Fork 58
/
ides.js
215 lines (202 loc) · 6.96 KB
/
ides.js
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
const path = require('path');
const utils = require('../utils');
module.exports = {
getAndroidStudioInfo: () => {
let androidStudioVersion = Promise.resolve('N/A');
if (utils.isMacOS) {
const paths = [
path.join('/', 'Applications', 'Android Studio.app', 'Contents', 'Info.plist'),
path.join(process.env.HOME, 'Applications', 'Android Studio.app', 'Contents', 'Info.plist'),
path.join(
'/',
'Applications',
'JetBrains Toolbox',
'Android Studio.app',
'Contents',
'Info.plist'
),
path.join(
process.env.HOME,
'Applications',
'JetBrains Toolbox',
'Android Studio.app',
'Contents',
'Info.plist'
),
];
androidStudioVersion = Promise.all(
paths.map(p => {
return utils.fileExists(p).then(exists => {
if (!exists) {
return null;
}
const command = utils.generatePlistBuddyCommand(p.replace(/ /g, '\\ '), [
'CFBundleShortVersionString',
'CFBundleVersion',
]);
return utils.run(command).then(version => {
return version.split('\n').join(' ');
});
});
})
).then(versions => {
return versions.find(version => version !== null) || utils.NotFound;
});
} else if (utils.isLinux) {
androidStudioVersion = Promise.all([
utils
.run('cat /opt/android-studio/bin/studio.sh | grep "$Home/.AndroidStudio" | head -1')
.then(utils.findVersion),
utils.run('cat /opt/android-studio/build.txt'),
]).then(tasks => {
const linuxVersion = tasks[0];
const linuxBuildNumber = tasks[1];
return `${linuxVersion} ${linuxBuildNumber}`.trim() || utils.NotFound;
});
} else if (utils.isWindows) {
androidStudioVersion = Promise.all([
utils
.run(
'wmic datafile where name="C:\\\\Program Files\\\\Android\\\\Android Studio\\\\bin\\\\studio.exe" get Version'
)
.then(version => version.replace(/(\r\n|\n|\r)/gm, '')),
utils
.run('type "C:\\\\Program Files\\\\Android\\\\Android Studio\\\\build.txt"')
.then(version => version.replace(/(\r\n|\n|\r)/gm, '')),
]).then(tasks => {
const windowsVersion = tasks[0];
const windowsBuildNumber = tasks[1];
return `${windowsVersion} ${windowsBuildNumber}`.trim() || utils.NotFound;
});
}
return androidStudioVersion.then(v => utils.determineFound('Android Studio', v));
},
getAtomInfo: () => {
utils.log('trace', 'getAtomInfo');
return Promise.all([
utils.getDarwinApplicationVersion(utils.ideBundleIdentifiers.Atom),
'N/A',
]).then(v => utils.determineFound('Atom', v[0], v[1]));
},
getEmacsInfo: () => {
utils.log('trace', 'getEmacsInfo');
if (utils.isMacOS || utils.isLinux) {
return Promise.all([
utils.run('emacs --version').then(utils.findVersion),
utils.run('which emacs'),
]).then(v => utils.determineFound('Emacs', v[0], v[1]));
}
return Promise.resolve(['Emacs', 'N/A']);
},
getIntelliJInfo: () => {
utils.log('trace', 'getIntelliJInfo');
return utils
.getDarwinApplicationVersion(utils.ideBundleIdentifiers.IntelliJ)
.then(v => utils.determineFound('IntelliJ', v));
},
getNanoInfo: () => {
utils.log('trace', 'getNanoInfo');
if (utils.isLinux) {
return Promise.all([
utils.run('nano --version').then(utils.findVersion),
utils.run('which nano'),
]).then(v => utils.determineFound('Nano', v[0], v[1]));
}
return Promise.resolve(['Nano', 'N/A']);
},
getNvimInfo: () => {
utils.log('trace', 'getNvimInfo');
if (utils.isMacOS || utils.isLinux) {
return Promise.all([
utils.run('nvim --version').then(utils.findVersion),
utils.run('which nvim'),
]).then(v => utils.determineFound('Nvim', v[0], v[1]));
}
return Promise.resolve(['Vim', 'N/A']);
},
getPhpStormInfo: () => {
utils.log('trace', 'getPhpStormInfo');
return utils
.getDarwinApplicationVersion(utils.ideBundleIdentifiers.PhpStorm)
.then(v => utils.determineFound('PhpStorm', v));
},
getSublimeTextInfo: () => {
utils.log('trace', 'getSublimeTextInfo');
return Promise.all([
utils.run('subl --version').then(version => utils.findVersion(version, /\d+/)),
utils.which('subl'),
])
.then(v => {
if (v[0] === '' && utils.isMacOS) {
utils.log('trace', 'getSublimeTextInfo using plist');
return Promise.all([
utils.getDarwinApplicationVersion(utils.ideBundleIdentifiers['Sublime Text']),
'N/A',
]);
}
return v;
})
.then(v => utils.determineFound('Sublime Text', v[0], v[1]));
},
getVimInfo: () => {
utils.log('trace', 'getVimInfo');
if (utils.isMacOS || utils.isLinux) {
return Promise.all([
utils.run('vim --version').then(utils.findVersion),
utils.run('which vim'),
]).then(v => utils.determineFound('Vim', v[0], v[1]));
}
return Promise.resolve(['Vim', 'N/A']);
},
getVSCodeInfo: () => {
utils.log('trace', 'getVSCodeInfo');
return Promise.all([
utils.run('code --version').then(utils.findVersion),
utils.which('code'),
]).then(v => utils.determineFound('VSCode', v[0], v[1]));
},
getVisualStudioInfo: () => {
utils.log('trace', 'getVisualStudioInfo');
if (utils.isWindows) {
return utils
.run(
`"${process.env['ProgramFiles(x86)']}/Microsoft Visual Studio/Installer/vswhere.exe" -format json -prerelease`
)
.then(jsonText => {
const instances = JSON.parse(jsonText).map(vsInstance => {
return {
Version: vsInstance.installationVersion,
DisplayName: vsInstance.displayName,
};
});
return utils.determineFound(
'Visual Studio',
instances.map(v => `${v.Version} (${v.DisplayName})`)
);
})
.catch(() => {
return Promise.resolve(['Visual Studio', utils.NotFound]);
});
}
return Promise.resolve(['Visual Studio', utils.NA]);
},
getWebStormInfo: () => {
utils.log('trace', 'getWebStormInfo');
return utils
.getDarwinApplicationVersion(utils.ideBundleIdentifiers.WebStorm)
.then(v => utils.determineFound('WebStorm', v));
},
getXcodeInfo: () => {
utils.log('trace', 'getXcodeInfo');
if (utils.isMacOS) {
return Promise.all([
utils
.which('xcodebuild')
.then(xcodePath => utils.run(xcodePath + ' -version'))
.then(version => `${utils.findVersion(version)}/${version.split('Build version ')[1]}`),
utils.which('xcodebuild'),
]).then(v => utils.determineFound('Xcode', v[0], v[1]));
}
return Promise.resolve(['Xcode', 'N/A']);
},
};