Skip to content

Commit c6311ec

Browse files
author
Akos Kitta
committed
Adapted the CLI download script.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent cd94608 commit c6311ec

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

arduino-ide-extension/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"@theia/core": "next",
1313
"@theia/editor": "next",
1414
"@theia/filesystem": "next",
15+
"@theia/git": "next",
1516
"@theia/languages": "next",
1617
"@theia/markers": "next",
1718
"@theia/monaco": "next",
1819
"@theia/outline-view": "next",
1920
"@theia/workspace": "next",
2021
"@theia/navigator": "next",
2122
"@theia/terminal": "next",
22-
"@theia/git": "next",
2323
"@theia/search-in-workspace": "next",
2424
"@types/ps-tree": "^1.1.0",
2525
"@types/which": "^1.3.1",
@@ -40,11 +40,12 @@
4040
},
4141
"devDependencies": {
4242
"decompress": "^4.2.0",
43-
"decompress-tarbz2": "^4.1.1",
43+
"decompress-targz": "^4.1.1",
4444
"decompress-unzip": "^4.0.1",
4545
"download": "^7.1.0",
4646
"grpc-tools": "^1.7.3",
4747
"grpc_tools_node_protoc_ts": "^2.5.0",
48+
"moment": "^2.24.0",
4849
"ncp": "^2.0.0",
4950
"rimraf": "^2.6.1",
5051
"shelljs": "^0.8.3",

arduino-ide-extension/scripts/download-cli.js

+26-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
// @ts-check
2-
// The links to the downloads as of today (11.08.) are the followings:
3-
// - https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli-nightly-latest-${FILE_NAME}
4-
// - https://downloads.arduino.cc/arduino-cli/arduino-cli-latest-${FILE_NAME}
2+
// The links to the downloads as of today (19.08.) are the followings:
3+
// In order to get the latest nightly build for your platform use the following links replacing <DATE> with the current date, using the format YYYYMMDD (i.e for 2019/Aug/06 use 20190806 )
4+
// Linux 64 bit: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-<DATE>_Linux_64bit.tar.gz
5+
// Linux ARM 64 bit: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-<DATE>_Linux_ARM64.tar.gz
6+
// Windows 64 bit: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-<DATE>_Windows_64bit.zip
7+
// Mac OSX: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-<DATE>_macOS_64bit.tar.gz
58

69
(async () => {
710

8-
const DEFAULT_VERSION = 'nightly';
11+
// TODO: currently, the download dates are one day behind.
12+
// https://typefox.slack.com/archives/CJJHJCJSJ/p1567062276016400
13+
const DEFAULT_VERSION = require('moment')().subtract(1, 'day').format('YYYYMMDD');
914

1015
const os = require('os');
1116
const fs = require('fs');
@@ -14,7 +19,7 @@
1419
const download = require('download');
1520
const decompress = require('decompress');
1621
const unzip = require('decompress-unzip');
17-
const untarbz = require('decompress-tarbz2');
22+
const untargz = require('decompress-targz');
1823

1924
process.on('unhandledRejection', (reason, _) => {
2025
shell.echo(String(reason));
@@ -31,11 +36,7 @@
3136
.option('cli-version', {
3237
alias: 'cv',
3338
default: DEFAULT_VERSION,
34-
choices: [
35-
// 'latest', // TODO: How do we get the source for `latest`. Currently, `latest` is the `0.3.7-alpha.preview`.
36-
'nightly'
37-
],
38-
describe: `The version of the 'arduino-cli' to download. Defaults to ${DEFAULT_VERSION}.`
39+
describe: `The version of the 'arduino-cli' to download with the YYYYMMDD format. Defaults to ${DEFAULT_VERSION}.`
3940
})
4041
.option('force-download', {
4142
alias: 'fd',
@@ -68,13 +69,12 @@
6869

6970
const suffix = (() => {
7071
switch (platform) {
71-
case 'darwin': return 'macosx.zip';
72-
case 'win32': return 'windows.zip';
72+
case 'darwin': return 'macOS_64bit.tar.gz';
73+
case 'win32': return 'Windows_64bit.zip';
7374
case 'linux': {
7475
switch (arch) {
75-
case 'arm64': return 'linuxarm.tar.bz2';
76-
case 'x32': return 'linux32.tar.bz2';
77-
case 'x64': return 'linux64.tar.bz2';
76+
case 'arm64': return 'Linux_ARM64.tar.gz';
77+
case 'x64': return 'Linux_64bit.tar.gz';
7878
default: return undefined;
7979
}
8080
}
@@ -86,24 +86,29 @@
8686
shell.exit(1);
8787
}
8888

89-
const url = `https://downloads.arduino.cc/arduino-cli/${version === 'nightly' ? 'nightly/' : ''}arduino-cli-${version}-latest-${suffix}`;
89+
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
9090
shell.echo(`>>> Downloading 'arduino-cli' from '${url}'...`);
9191
const data = await download(url);
9292
shell.echo(`<<< Download succeeded.`);
9393
shell.echo('>>> Decompressing CLI...');
9494
const files = await decompress(data, downloads, {
9595
plugins: [
9696
unzip(),
97-
untarbz()
97+
untargz()
9898
]
9999
});
100-
shell.echo('<<< Decompressing succeeded.');
101-
102-
if (files.length !== 1) {
100+
if (files.length === 0) {
103101
shell.echo('Error ocurred when decompressing the CLI.');
104102
shell.exit(1);
105103
}
106-
if (shell.mv('-f', path.join(downloads, files[0].path), cli).code !== 0) {
104+
const cliIndex = files.findIndex(f => f.path.startsWith('arduino-cli'));
105+
if (cliIndex === -1) {
106+
shell.echo('The downloaded artifact does not contains the CLI.');
107+
shell.exit(1);
108+
}
109+
shell.echo('<<< Decompressing succeeded.');
110+
111+
if (shell.mv('-f', path.join(downloads, files[cliIndex].path), cli).code !== 0) {
107112
shell.echo(`Could not move file to ${cli}.`);
108113
shell.exit(1);
109114
}

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -4473,7 +4473,7 @@ decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1:
44734473
is-stream "^1.1.0"
44744474
tar-stream "^1.5.2"
44754475

4476-
decompress-tarbz2@^4.0.0, decompress-tarbz2@^4.1.1:
4476+
decompress-tarbz2@^4.0.0:
44774477
version "4.1.1"
44784478
resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b"
44794479
integrity sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==
@@ -4484,7 +4484,7 @@ decompress-tarbz2@^4.0.0, decompress-tarbz2@^4.1.1:
44844484
seek-bzip "^1.0.5"
44854485
unbzip2-stream "^1.0.9"
44864486

4487-
decompress-targz@^4.0.0:
4487+
decompress-targz@^4.0.0, decompress-targz@^4.1.1:
44884488
version "4.1.1"
44894489
resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee"
44904490
integrity sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==
@@ -8098,7 +8098,7 @@ modify-values@^1.0.0:
80988098
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
80998099
integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==
81008100

8101-
moment@^2.10.6, moment@^2.18.1, moment@^2.21.0:
8101+
moment@^2.10.6, moment@^2.18.1, moment@^2.21.0, moment@^2.24.0:
81028102
version "2.24.0"
81038103
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
81048104
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==

0 commit comments

Comments
 (0)