diff --git a/arduino-ide-extension/package.json b/arduino-ide-extension/package.json index 537c4b45..861026a0 100644 --- a/arduino-ide-extension/package.json +++ b/arduino-ide-extension/package.json @@ -12,6 +12,7 @@ "@theia/core": "next", "@theia/editor": "next", "@theia/filesystem": "next", + "@theia/git": "next", "@theia/languages": "next", "@theia/markers": "next", "@theia/monaco": "next", @@ -19,7 +20,6 @@ "@theia/workspace": "next", "@theia/navigator": "next", "@theia/terminal": "next", - "@theia/git": "next", "@theia/search-in-workspace": "next", "@types/ps-tree": "^1.1.0", "@types/which": "^1.3.1", @@ -40,11 +40,12 @@ }, "devDependencies": { "decompress": "^4.2.0", - "decompress-tarbz2": "^4.1.1", + "decompress-targz": "^4.1.1", "decompress-unzip": "^4.0.1", "download": "^7.1.0", "grpc-tools": "^1.7.3", "grpc_tools_node_protoc_ts": "^2.5.0", + "moment": "^2.24.0", "ncp": "^2.0.0", "rimraf": "^2.6.1", "shelljs": "^0.8.3", diff --git a/arduino-ide-extension/scripts/download-cli.js b/arduino-ide-extension/scripts/download-cli.js index 27bd76e5..e7d229d8 100755 --- a/arduino-ide-extension/scripts/download-cli.js +++ b/arduino-ide-extension/scripts/download-cli.js @@ -1,11 +1,16 @@ // @ts-check -// The links to the downloads as of today (11.08.) are the followings: -// - https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli-nightly-latest-${FILE_NAME} -// - https://downloads.arduino.cc/arduino-cli/arduino-cli-latest-${FILE_NAME} +// The links to the downloads as of today (19.08.) are the followings: +// In order to get the latest nightly build for your platform use the following links replacing with the current date, using the format YYYYMMDD (i.e for 2019/Aug/06 use 20190806 ) +// Linux 64 bit: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-_Linux_64bit.tar.gz +// Linux ARM 64 bit: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-_Linux_ARM64.tar.gz +// Windows 64 bit: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-_Windows_64bit.zip +// Mac OSX: https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-_macOS_64bit.tar.gz (async () => { - const DEFAULT_VERSION = 'nightly'; + // TODO: currently, the download dates are one day behind. + // https://typefox.slack.com/archives/CJJHJCJSJ/p1567062276016400 + const DEFAULT_VERSION = require('moment')().subtract(1, 'day').format('YYYYMMDD'); const os = require('os'); const fs = require('fs'); @@ -14,7 +19,7 @@ const download = require('download'); const decompress = require('decompress'); const unzip = require('decompress-unzip'); - const untarbz = require('decompress-tarbz2'); + const untargz = require('decompress-targz'); process.on('unhandledRejection', (reason, _) => { shell.echo(String(reason)); @@ -31,11 +36,7 @@ .option('cli-version', { alias: 'cv', default: DEFAULT_VERSION, - choices: [ - // 'latest', // TODO: How do we get the source for `latest`. Currently, `latest` is the `0.3.7-alpha.preview`. - 'nightly' - ], - describe: `The version of the 'arduino-cli' to download. Defaults to ${DEFAULT_VERSION}.` + describe: `The version of the 'arduino-cli' to download with the YYYYMMDD format. Defaults to ${DEFAULT_VERSION}.` }) .option('force-download', { alias: 'fd', @@ -68,13 +69,12 @@ const suffix = (() => { switch (platform) { - case 'darwin': return 'macosx.zip'; - case 'win32': return 'windows.zip'; + case 'darwin': return 'macOS_64bit.tar.gz'; + case 'win32': return 'Windows_64bit.zip'; case 'linux': { switch (arch) { - case 'arm64': return 'linuxarm.tar.bz2'; - case 'x32': return 'linux32.tar.bz2'; - case 'x64': return 'linux64.tar.bz2'; + case 'arm64': return 'Linux_ARM64.tar.gz'; + case 'x64': return 'Linux_64bit.tar.gz'; default: return undefined; } } @@ -86,7 +86,7 @@ shell.exit(1); } - const url = `https://downloads.arduino.cc/arduino-cli/${version === 'nightly' ? 'nightly/' : ''}arduino-cli-${version}-latest-${suffix}`; + const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`; shell.echo(`>>> Downloading 'arduino-cli' from '${url}'...`); const data = await download(url); shell.echo(`<<< Download succeeded.`); @@ -94,16 +94,21 @@ const files = await decompress(data, downloads, { plugins: [ unzip(), - untarbz() + untargz() ] }); - shell.echo('<<< Decompressing succeeded.'); - - if (files.length !== 1) { + if (files.length === 0) { shell.echo('Error ocurred when decompressing the CLI.'); shell.exit(1); } - if (shell.mv('-f', path.join(downloads, files[0].path), cli).code !== 0) { + const cliIndex = files.findIndex(f => f.path.startsWith('arduino-cli')); + if (cliIndex === -1) { + shell.echo('The downloaded artifact does not contains the CLI.'); + shell.exit(1); + } + shell.echo('<<< Decompressing succeeded.'); + + if (shell.mv('-f', path.join(downloads, files[cliIndex].path), cli).code !== 0) { shell.echo(`Could not move file to ${cli}.`); shell.exit(1); } diff --git a/yarn.lock b/yarn.lock index cdc8943d..ae96ea90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4473,7 +4473,7 @@ decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1: is-stream "^1.1.0" tar-stream "^1.5.2" -decompress-tarbz2@^4.0.0, decompress-tarbz2@^4.1.1: +decompress-tarbz2@^4.0.0: version "4.1.1" resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b" integrity sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A== @@ -4484,7 +4484,7 @@ decompress-tarbz2@^4.0.0, decompress-tarbz2@^4.1.1: seek-bzip "^1.0.5" unbzip2-stream "^1.0.9" -decompress-targz@^4.0.0: +decompress-targz@^4.0.0, decompress-targz@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee" integrity sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w== @@ -8098,7 +8098,7 @@ modify-values@^1.0.0: resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== -moment@^2.10.6, moment@^2.18.1, moment@^2.21.0: +moment@^2.10.6, moment@^2.18.1, moment@^2.21.0, moment@^2.24.0: version "2.24.0" resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==