|
6 | 6 | (() => { |
7 | 7 |
|
8 | 8 | const DEFAULT_ALS_VERSION = 'nightly'; |
9 | | - const DEFAULT_CLANGD_VERSION = '9.0.0'; |
| 9 | + const DEFAULT_CLANGD_VERSION = 'snapshot_20210124'; |
10 | 10 |
|
11 | 11 | const path = require('path'); |
12 | 12 | const shell = require('shelljs'); |
|
22 | 22 | .option('clangd-version', { |
23 | 23 | alias: 'cv', |
24 | 24 | default: DEFAULT_CLANGD_VERSION, |
25 | | - choices: ['8.0.1', '9.0.0'], |
| 25 | + choices: ['snapshot_20210124'], |
26 | 26 | describe: `The version of 'clangd' to download. Defaults to ${DEFAULT_CLANGD_VERSION}.` |
27 | 27 | }) |
28 | 28 | .option('force-download', { |
|
38 | 38 | const { platform, arch } = process; |
39 | 39 |
|
40 | 40 | const build = path.join(__dirname, '..', 'build'); |
41 | | - const alsTarget = path.join(build, `arduino-language-server${platform === 'win32' ? '.exe' : ''}`); |
| 41 | + const lsExecutablePath = path.join(build, `arduino-language-server${platform === 'win32' ? '.exe' : ''}`); |
42 | 42 |
|
43 | | - let clangdTarget, alsSuffix, clangdSuffix; |
| 43 | + let clangdExecutablePath, lsSuffix, clangdPrefix; |
44 | 44 | switch (platform) { |
45 | 45 | case 'darwin': |
46 | | - clangdTarget = path.join(build, 'bin', 'clangd') |
47 | | - alsSuffix = 'Darwin_amd64.zip'; |
48 | | - clangdSuffix = 'macos.zip'; |
| 46 | + clangdExecutablePath = path.join(build, 'bin', 'clangd') |
| 47 | + lsSuffix = 'macOS_amd64.zip'; |
| 48 | + clangdPrefix = 'mac'; |
49 | 49 | break; |
50 | 50 | case 'linux': |
51 | | - clangdTarget = path.join(build, 'bin', 'clangd') |
52 | | - alsSuffix = 'Linux_amd64.zip'; |
53 | | - clangdSuffix = 'linux.zip' |
| 51 | + clangdExecutablePath = path.join(build, 'bin', 'clangd') |
| 52 | + lsSuffix = 'Linux_amd64.zip'; |
| 53 | + clangdPrefix = 'linux' |
54 | 54 | break; |
55 | 55 | case 'win32': |
56 | | - clangdTarget = path.join(build, 'clangd.exe') |
57 | | - alsSuffix = 'Windows_NT_amd64.zip'; |
58 | | - clangdSuffix = 'windows.zip'; |
| 56 | + clangdExecutablePath = path.join(build, 'bin', 'clangd.exe') |
| 57 | + lsSuffix = 'Windows_amd64.zip'; |
| 58 | + clangdPrefix = 'windows'; |
59 | 59 | break; |
60 | 60 | } |
61 | | - if (!alsSuffix) { |
| 61 | + if (!lsSuffix) { |
62 | 62 | shell.echo(`The arduino-language-server is not available for ${platform} ${arch}.`); |
63 | 63 | shell.exit(1); |
64 | 64 | } |
65 | 65 |
|
66 | | - const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${alsVersion === 'nightly' ? 'nightly/arduino-language-server' : 'arduino-language-server_' + alsVersion}_${alsSuffix}`; |
67 | | - downloader.downloadUnzipAll(alsUrl, build, alsTarget, force); |
| 66 | + const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${alsVersion === 'nightly' ? 'nightly/arduino-language-server' : 'arduino-language-server_' + alsVersion}_${lsSuffix}`; |
| 67 | + downloader.downloadUnzipAll(alsUrl, build, lsExecutablePath, force); |
68 | 68 |
|
69 | | - const clangdUrl = `https://downloads.arduino.cc/arduino-language-server/clangd/clangd_${clangdVersion}_${clangdSuffix}`; |
70 | | - downloader.downloadUnzipAll(clangdUrl, build, clangdTarget, force); |
| 69 | + const clangdUrl = `https://downloads.arduino.cc/arduino-language-server/clangd/clangd-${clangdPrefix}-${clangdVersion}.zip`; |
| 70 | + downloader.downloadUnzipAll(clangdUrl, build, clangdExecutablePath, force, { strip: 1 }); // `strip`: the new clangd (12.x) is zipped into a folder, so we have to strip the outmost folder. |
71 | 71 |
|
72 | 72 | })(); |
0 commit comments