Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a7c85b7

Browse files
author
Akos Kitta
committed
Notify the LS about the new build_path after verify.
Closes #714 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent f4a68e7 commit a7c85b7

File tree

14 files changed

+334
-208
lines changed

14 files changed

+334
-208
lines changed

‎arduino-ide-extension/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
],
157157
"arduino": {
158158
"cli": {
159-
"version": "0.24.0"
159+
"version": "0.25.0-rc1"
160160
},
161161
"fwuploader": {
162162
"version": "2.2.0"
@@ -165,7 +165,7 @@
165165
"version": "14.0.0"
166166
},
167167
"languageServer": {
168-
"version": "0.6.0"
168+
"version": "0.7.0"
169169
}
170170
}
171171
}
Lines changed: 75 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,87 @@
11
// @ts-check
22

33
(async () => {
4+
const path = require('path');
5+
const shell = require('shelljs');
6+
const semver = require('semver');
7+
const moment = require('moment');
8+
const downloader = require('./downloader');
9+
const { goBuildFromGit } = require('./utils');
10+
11+
const version = (() => {
12+
const pkg = require(path.join(__dirname, '..', 'package.json'));
13+
if (!pkg) {
14+
return undefined;
15+
}
416

5-
const fs = require('fs');
6-
const path = require('path');
7-
const temp = require('temp');
8-
const shell = require('shelljs');
9-
const semver = require('semver');
10-
const moment = require('moment');
11-
const downloader = require('./downloader');
12-
13-
const version = (() => {
14-
const pkg = require(path.join(__dirname, '..', 'package.json'));
15-
if (!pkg) {
16-
return undefined;
17-
}
17+
const { arduino } = pkg;
18+
if (!arduino) {
19+
return undefined;
20+
}
1821

19-
const { arduino } = pkg;
20-
if (!arduino) {
21-
return undefined;
22-
}
22+
const { cli } = arduino;
23+
if (!cli) {
24+
return undefined;
25+
}
2326

24-
const { cli } = arduino;
25-
if (!cli) {
26-
return undefined;
27+
const { version } = cli;
28+
return version;
29+
})();
30+
31+
if (!version) {
32+
shell.echo(`Could not retrieve CLI version info from the 'package.json'.`);
33+
shell.exit(1);
34+
}
35+
36+
const { platform, arch } = process;
37+
const buildFolder = path.join(__dirname, '..', 'build');
38+
const cliName = `arduino-cli${platform === 'win32' ? '.exe' : ''}`;
39+
const destinationPath = path.join(buildFolder, cliName);
40+
41+
if (typeof version === 'string') {
42+
const suffix = (() => {
43+
switch (platform) {
44+
case 'darwin':
45+
return 'macOS_64bit.tar.gz';
46+
case 'win32':
47+
return 'Windows_64bit.zip';
48+
case 'linux': {
49+
switch (arch) {
50+
case 'arm':
51+
return 'Linux_ARMv7.tar.gz';
52+
case 'arm64':
53+
return 'Linux_ARM64.tar.gz';
54+
case 'x64':
55+
return 'Linux_64bit.tar.gz';
56+
default:
57+
return undefined;
58+
}
2759
}
28-
29-
const{ version }=cli;
30-
returnversion;
60+
default:
61+
returnundefined;
62+
}
3163
})();
32-
33-
if (!version) {
34-
shell.echo(`Could not retrieve CLI version info from the 'package.json'.`);
35-
shell.exit(1);
64+
if (!suffix) {
65+
shell.echo(`The CLI is not available for ${platform} ${arch}.`);
66+
shell.exit(1);
3667
}
37-
38-
const { platform, arch } = process;
39-
const buildFolder = path.join(__dirname, '..', 'build');
40-
const cliName = `arduino-cli${platform === 'win32' ? '.exe' : ''}`;
41-
const destinationPath = path.join(buildFolder, cliName);
42-
43-
if (typeof version === 'string') {
44-
const suffix = (() => {
45-
switch (platform) {
46-
case 'darwin': return 'macOS_64bit.tar.gz';
47-
case 'win32': return 'Windows_64bit.zip';
48-
case 'linux': {
49-
switch (arch) {
50-
case 'arm': return 'Linux_ARMv7.tar.gz';
51-
case 'arm64': return 'Linux_ARM64.tar.gz';
52-
case 'x64': return 'Linux_64bit.tar.gz';
53-
default: return undefined;
54-
}
55-
}
56-
default: return undefined;
57-
}
58-
})();
59-
if (!suffix) {
60-
shell.echo(`The CLI is not available for ${platform} ${arch}.`);
61-
shell.exit(1);
62-
}
63-
if (semver.valid(version)) {
64-
const url = `https://downloads.arduino.cc/arduino-cli/arduino-cli_${version}_${suffix}`;
65-
shell.echo(`📦 Identified released version of the CLI. Downloading version ${version} from '${url}'`);
66-
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
67-
} else if (moment(version, 'YYYYMMDD', true).isValid()) {
68-
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
69-
shell.echo(`🌙 Identified nightly version of the CLI. Downloading version ${version} from '${url}'`);
70-
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
71-
} else {
72-
shell.echo(`🔥 Could not interpret 'version': ${version}`);
73-
shell.exit(1);
74-
}
68+
if (semver.valid(version)) {
69+
const url = `https://downloads.arduino.cc/arduino-cli/arduino-cli_${version}_${suffix}`;
70+
shell.echo(
71+
`📦 Identified released version of the CLI. Downloading version ${version} from '${url}'`
72+
);
73+
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
74+
} else if (moment(version, 'YYYYMMDD', true).isValid()) {
75+
const url = `https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-${version}_${suffix}`;
76+
shell.echo(
77+
`🌙 Identified nightly version of the CLI. Downloading version ${version} from '${url}'`
78+
);
79+
await downloader.downloadUnzipFile(url, destinationPath, 'arduino-cli');
7580
} else {
76-
77-
// We assume an object with `owner`, `repo`, commitish?` properties.
78-
const { owner, repo, commitish } = version;
79-
if (!owner) {
80-
shell.echo(`Could not retrieve 'owner' from ${JSON.stringify(version)}`);
81-
shell.exit(1);
82-
}
83-
if (!repo) {
84-
shell.echo(`Could not retrieve 'repo' from ${JSON.stringify(version)}`);
85-
shell.exit(1);
86-
}
87-
const url = `https://github.com/${owner}/${repo}.git`;
88-
shell.echo(`Building CLI from ${url}. Commitish: ${commitish ? commitish : 'HEAD'}`);
89-
90-
if (fs.existsSync(destinationPath)) {
91-
shell.echo(`Skipping the CLI build because it already exists: ${destinationPath}`);
92-
return;
93-
}
94-
95-
if (shell.mkdir('-p', buildFolder).code !== 0) {
96-
shell.echo('Could not create build folder.');
97-
shell.exit(1);
98-
}
99-
100-
const tempRepoPath = temp.mkdirSync();
101-
shell.echo(`>>> Cloning CLI source to ${tempRepoPath}...`);
102-
if (shell.exec(`git clone ${url} ${tempRepoPath}`).code !== 0) {
103-
shell.exit(1);
104-
}
105-
shell.echo('<<< Cloned CLI repo.')
106-
107-
if (commitish) {
108-
shell.echo(`>>> Checking out ${commitish}...`);
109-
if (shell.exec(`git -C ${tempRepoPath} checkout ${commitish}`).code !== 0) {
110-
shell.exit(1);
111-
}
112-
shell.echo(`<<< Checked out ${commitish}.`);
113-
}
114-
115-
shell.echo(`>>> Building the CLI...`);
116-
if (shell.exec('go build', { cwd: tempRepoPath }).code !== 0) {
117-
shell.exit(1);
118-
}
119-
shell.echo('<<< CLI build done.')
120-
121-
if (!fs.existsSync(path.join(tempRepoPath, cliName))) {
122-
shell.echo(`Could not find the CLI at ${path.join(tempRepoPath, cliName)}.`);
123-
shell.exit(1);
124-
}
125-
126-
const builtCliPath = path.join(tempRepoPath, cliName);
127-
shell.echo(`>>> Copying CLI from ${builtCliPath} to ${destinationPath}...`);
128-
if (shell.cp(builtCliPath, destinationPath).code !== 0) {
129-
shell.exit(1);
130-
}
131-
shell.echo(`<<< Copied the CLI.`);
132-
133-
shell.echo('<<< Verifying CLI...');
134-
if (!fs.existsSync(destinationPath)) {
135-
shell.exit(1);
136-
}
137-
shell.echo('>>> Verified CLI.');
138-
81+
shell.echo(`🔥 Could not interpret 'version': ${version}`);
82+
shell.exit(1);
13983
}
140-
84+
} else {
85+
goBuildFromGit(version, destinationPath, 'CLI');
86+
}
14187
})();

‎arduino-ide-extension/scripts/download-ls.js‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@
77
const path = require('path');
88
const shell = require('shelljs');
99
const downloader = require('./downloader');
10+
const { goBuildFromGit } = require('./utils');
1011

11-
const [DEFAULT_ALS_VERSION, DEFAULT_CLANGD_VERSION] = (() => {
12+
const [DEFAULT_LS_VERSION, DEFAULT_CLANGD_VERSION] = (() => {
1213
const pkg = require(path.join(__dirname, '..', 'package.json'));
13-
if (!pkg) return undefined;
14+
if (!pkg) return [undefined,undefined];
1415

1516
const { arduino } = pkg;
16-
if (!arduino) return undefined;
17+
if (!arduino) return [undefined,undefined];
1718

1819
const { languageServer, clangd } = arduino;
19-
if (!languageServer) return undefined;
20-
if (!clangd) return undefined;
20+
if (!languageServer) return [undefined,undefined];
21+
if (!clangd) return [undefined,undefined];
2122

2223
return [languageServer.version, clangd.version];
2324
})();
2425

25-
if (!DEFAULT_ALS_VERSION) {
26+
if (!DEFAULT_LS_VERSION) {
2627
shell.echo(
2728
`Could not retrieve Arduino Language Server version info from the 'package.json'.`
2829
);
@@ -39,8 +40,8 @@
3940
const yargs = require('yargs')
4041
.option('ls-version', {
4142
alias: 'lv',
42-
default: DEFAULT_ALS_VERSION,
43-
describe: `The version of the 'arduino-language-server' to download. Defaults to ${DEFAULT_ALS_VERSION}.`,
43+
default: DEFAULT_LS_VERSION,
44+
describe: `The version of the 'arduino-language-server' to download. Defaults to ${DEFAULT_LS_VERSION}.`,
4445
})
4546
.option('clangd-version', {
4647
alias: 'cv',
@@ -56,7 +57,7 @@
5657
.version(false)
5758
.parse();
5859

59-
const alsVersion = yargs['ls-version'];
60+
const lsVersion = yargs['ls-version'];
6061
const clangdVersion = yargs['clangd-version'];
6162
const force = yargs['force-download'];
6263
const { platform, arch } = process;
@@ -87,6 +88,8 @@
8788
lsSuffix = 'Windows_64bit.zip';
8889
clangdSuffix = 'Windows_64bit';
8990
break;
91+
default:
92+
throw new Error(`Unsupported platform/arch: ${platformArch}.`);
9093
}
9194
if (!lsSuffix || !clangdSuffix) {
9295
shell.echo(
@@ -95,12 +98,16 @@
9598
shell.exit(1);
9699
}
97100

98-
const alsUrl = `https://downloads.arduino.cc/arduino-language-server/${
99-
alsVersion === 'nightly'
100-
? 'nightly/arduino-language-server'
101-
: 'arduino-language-server_' + alsVersion
102-
}_${lsSuffix}`;
103-
downloader.downloadUnzipAll(alsUrl, build, lsExecutablePath, force);
101+
if (typeof lsVersion === 'string') {
102+
const lsUrl = `https://downloads.arduino.cc/arduino-language-server/${
103+
lsVersion === 'nightly'
104+
? 'nightly/arduino-language-server'
105+
: 'arduino-language-server_' + lsVersion
106+
}_${lsSuffix}`;
107+
downloader.downloadUnzipAll(lsUrl, build, lsExecutablePath, force);
108+
} else {
109+
goBuildFromGit(lsVersion, lsExecutablePath, 'language-server');
110+
}
104111

105112
const clangdUrl = `https://downloads.arduino.cc/tools/clangd_${clangdVersion}_${clangdSuffix}.tar.bz2`;
106113
downloader.downloadUnzipAll(clangdUrl, build, clangdExecutablePath, force, {

‎arduino-ide-extension/scripts/downloader.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ exports.downloadUnzipFile = async (
8686
* @param targetDir {string} Directory into which to decompress the archive
8787
* @param targetFile {string} Path to the main file expected after decompressing
8888
* @param force {boolean} Whether to download even if the target file exists
89+
* @param decompressOptions {import('decompress').DecompressOptions}
8990
*/
9091
exports.downloadUnzipAll = async (
9192
url,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /