Skip to content

Commit f2bc760

Browse files
committed
update arduino and minor tweaks
1 parent d754ad3 commit f2bc760

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

base.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
FROM node:10-alpine
22

3+
USER root
34
RUN addgroup -S duino && adduser -S duino -G duino
45

56
COPY setup /home/duino/setup
67
COPY data /home/duino/data
78
# COPY Arduino /home/duino/Arduino
89

910
RUN chown duino:duino /home/duino -R
11+
RUN apk update && apk add build-base
1012

1113
WORKDIR /home/duino
1214
USER duino
1315

14-
RUN wget https://downloads.arduino.cc/arduino-cli/nightly/arduino-cli_nightly-20190921_Linux_64bit.tar.gz -O - | tar -xz
16+
RUN wget https://github.com/arduino/arduino-cli/releases/download/0.7.2/arduino-cli_0.7.2_Linux_64bit.tar.gz -O - | tar -xz
1517

1618
RUN ls
1719

setup/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const libs = require('../data/libs.json').libraries;
55
// eslint-disable-next-line import/no-unresolved
66
const cores = require('../data/cores.json');
77

8-
const cli = (commands, args) => new Promise((resolve) => {
8+
const cli = (commands, args, consoleLog = false) => new Promise((resolve) => {
99
let res = '';
1010
const exec = spawn(`${__dirname}/../arduino-cli`, [
1111
...(Array.isArray(commands) ? commands : commands.split('.')),
@@ -14,21 +14,24 @@ const cli = (commands, args) => new Promise((resolve) => {
1414
], { cwd: `${__dirname}/../` });
1515

1616
exec.on('close', () => resolve(res));
17-
const log = (data) => { res += data.toString('utf-8'); };
17+
const log = (data) => {
18+
if (consoleLog) console.log(data.toString('utf-8'));
19+
res += data.toString('utf-8');
20+
};
1821
exec.stdout.on('data', log);
1922
exec.stderr.on('data', log);
2023
});
2124

2225
const loadLibs = () => libs.reduce(async (a, lib, i) => {
2326
await a;
2427
console.log(`Libs (${i + 1}/${libs.length}) Installing ${lib.name}`);
25-
await cli('lib.install', lib.name);
28+
await cli('lib.install', lib.name, true);
2629
}, Promise.resolve());
2730

2831
const loadCores = () => cores.reduce(async (a, core, i) => {
2932
await a;
3033
console.log(`Cores (${i + 1}/${cores.length}) Installing ${core.Name} (${core.ID})`);
31-
await cli('core.install', core.ID);
34+
await cli('core.install', core.ID, true);
3235
}, Promise.resolve());
3336

3437
const loadBoards = async () => {

src/actions/info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const processedCores = cores.map(lowerCaseKeys);
4444
let processedBoards = boards;
4545
processedCores.forEach((core) => {
4646
const [pack, arch] = core.id.split(':');
47-
const path = `${__dirname}/../../data/arduino/packages/${pack}/hardware/${arch}/${core.latest}/boards.txt`;
47+
const path = `/home/duino/.arduino15/packages/${pack}/hardware/${arch}/${core.latest}/boards.txt`;
4848
const props = processFile(path);
4949
processedBoards = processedBoards.map((board) => (!board.fqbn.includes(`${core.id}:`) ? board : {
5050
...board,

src/utils/files.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ const files = {
3636
await Promise.all(fileItems.map(async (file) => {
3737
const filepath = path.join(socket.tmpDir.path, sub, file.name);
3838
files.checkPath(filepath, socket, sub);
39+
try {
40+
const parts = filepath.split('/');
41+
parts.pop();
42+
await fs.mkdir(parts.join('/'), { recursive: true });
43+
} catch (err) { console.error(err); }
3944
await fs.writeFile(filepath, file.content);
4045
if (/.ino$/.test(file.name)) socket.sketchPath = filepath;
4146
}));

0 commit comments

Comments
 (0)