Skip to content

Commit

Permalink
Merge pull request #1462 from xodio/feat-1206-upload-on-esp
Browse files Browse the repository at this point in the history
Make possible to upload on esp8266
  • Loading branch information
brusherru authored Oct 12, 2018
2 parents 8df9741 + 96a0f97 commit 69495b3
Show file tree
Hide file tree
Showing 30 changed files with 1,605 additions and 1,093 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ defs:
step-install-arduino-cli-on-mac: &step-install-arduino-cli-on-mac
name: Install arduino-cli
command: |
curl -s --create-dirs -o "$HOME/arduino-cli.zip" "https://downloads.arduino.cc/arduino-cli/arduino-cli-0.2.2-alpha.preview-osx.zip" \
curl -s --create-dirs -o "$HOME/arduino-cli.zip" "https://downloads.arduino.cc/arduino-cli/arduino-cli-0.3.1-alpha.preview-osx.zip" \
&& unzip "$HOME/arduino-cli.zip" -d "$HOME" \
&& mv "$HOME/arduino-cli-0.2.2-alpha.preview-osx" "$HOME/arduino-cli" \
&& mv "$HOME/arduino-cli-0.3.1-alpha.preview-osx" "$HOME/arduino-cli" \
&& cp "$HOME/arduino-cli" "./packages/xod-client-electron/arduino-cli" \
&& mkdir "/tmp/arduino-cli" \
&& cp "$HOME/arduino-cli" "/tmp/arduino-cli/arduino-cli"
step-install-arduino-cli-on-linux: &step-install-arduino-cli-on-linux
name: Install arduino-cli
command: |
curl -s --create-dirs -o "$HOME/arduino-cli.tar.bz2" "https://downloads.arduino.cc/arduino-cli/arduino-cli-0.2.2-alpha.preview-linux64.tar.bz2" \
curl -s --create-dirs -o "$HOME/arduino-cli.tar.bz2" "https://downloads.arduino.cc/arduino-cli/arduino-cli-0.3.1-alpha.preview-linux64.tar.bz2" \
&& tar xvjf "$HOME/arduino-cli.tar.bz2" -C "$HOME" \
&& mv "$HOME/arduino-cli-0.2.2-alpha.preview-linux64" "$HOME/arduino-cli" \
&& mv "$HOME/arduino-cli-0.3.1-alpha.preview-linux64" "$HOME/arduino-cli" \
&& cp "$HOME/arduino-cli" "./packages/xod-client-electron/arduino-cli" \
&& mkdir "/tmp/arduino-cli" \
&& cp "$HOME/arduino-cli" "/tmp/arduino-cli/arduino-cli"
Expand Down
20 changes: 15 additions & 5 deletions packages/arduino-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A javascript wrapper over the [arduino-cli](https://github.com/arduino/arduino-cli) tool

**Works on Arduino-cli 0.2.2-alpha.preview**
**Works on Arduino-cli 0.3.1-alpha.preview**

## How to use

Expand Down Expand Up @@ -177,10 +177,20 @@ Accepts:
- `usbID` `String` — An ID of the board (VID, PID). For example, `2341:0042`
### InstalledBoard
- `name` `<String>` — A board name with an added cpu option name, if it exists.
For example, "Arduino/Genuino Uno" or "Arduino/Genuino Mega2560 (ATmega2560 (Mega 2560))"
- `fqbn` `<String>` — A fully-qualified board name.
For example, `arduino:avr:uno` or `arduino:avr:mega2560:cpu=atmega2560`
- `name` `<String>` — A board name
E.G. "Arduino/Genuino Uno" or "Arduino/Genuino Mega2560"
- `fqbn` `<String>` — A fully-qualified board name
E.G. "arduino:avr:uno" or "arduino:avr:mega2560"
- `options` `<Array<Option>>` — a list of options for this board
### Option
Object, that represents one group of the board option. For example, CPU Frequency.
- `optionName` `<String>` — A human-readable name of the option group ("CPU Frequency")
- `optionId` `<String>` — An id of the option from `boards.txt`. E.G. `CpuFrequency`
- `values` `<Array<OptionValue>>` — a list of option values, that represented as objects
with two fields
- `name` `<String>` — A human-readable option name ("80 MHz")
- `value` `<String>` — A value, that will be used by tools. ("80")
### AvailableBoard
- `name` `<String>` — A board name (e.g., "Arduino/Genuino Mega2560")
Expand Down
153 changes: 0 additions & 153 deletions packages/arduino-cli/src/cpuParser.js

This file was deleted.

52 changes: 35 additions & 17 deletions packages/arduino-cli/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as R from 'ramda';
import { resolve } from 'path';
import { exec, spawn } from 'child-process-promise';
import YAML from 'yamljs';
import { remove } from 'fs-extra';

import { configure, addPackageIndexUrl, addPackageIndexUrls } from './config';
import parseTable from './parseTable';
import { patchBoardsWithCpu } from './cpuParser';
import { patchBoardsWithOptions } from './optionParser';
import listAvailableBoards from './listAvailableBoards';
import parseProgressLog from './parseProgressLog';

Expand Down Expand Up @@ -47,19 +47,27 @@ const ArduinoCli = (pathToBin, config = null) => {

const sketch = name => resolve(cfg.sketchbook_path, name);

const runAndParseTable = args => run(args).then(parseTable);
const runAndParseJson = args => run(args).then(JSON.parse);

const listCores = () =>
run('core list --format json')
.then(R.when(R.isEmpty, R.always('{}')))
.then(JSON.parse)
.then(R.propOr([], 'Platforms'))
.then(R.map(R.over(R.lensProp('ID'), R.replace(/(@.+)$/, ''))));

const listBoardsWith = (listCmd, boardsGetter) =>
Promise.all([
runAndParseTable('core list'),
listCores(),
runAndParseJson(`board ${listCmd} --format json`),
]).then(([cores, boards]) =>
patchBoardsWithCpu(cfg.arduino_data, cores, boardsGetter(boards))
patchBoardsWithOptions(cfg.arduino_data, cores, boardsGetter(boards))
);

const getConfig = () => run('config dump').then(YAML.parse);

return {
dumpConfig: () => run('config dump').then(YAML.parse),
dumpConfig: getConfig,
listConnectedBoards: () => listBoardsWith('list', R.prop('serialBoards')),
listInstalledBoards: () => listBoardsWith('listall', R.prop('boards')),
listAvailableBoards: () => listAvailableBoards(cfg.arduino_data),
Expand All @@ -79,20 +87,30 @@ const ArduinoCli = (pathToBin, config = null) => {
),
core: {
download: (onProgress, pkgName) =>
runWithProgress(
parseProgressLog(onProgress),
`core download ${pkgName}`
// TODO:
// Get rid of `remove` the staging directory when
// arduino-cli fix issue https://github.com/arduino/arduino-cli/issues/43
remove(resolve(cfg.arduino_data, 'staging')).then(() =>
runWithProgress(
parseProgressLog(onProgress),
`core download ${pkgName}`
)
),
install: (onProgress, pkgName) =>
runWithProgress(
parseProgressLog(onProgress),
`core install ${pkgName}`
// TODO:
// Get rid of `remove` the staging directory when
// arduino-cli fix issue https://github.com/arduino/arduino-cli/issues/43
remove(resolve(cfg.arduino_data, 'staging')).then(() =>
runWithProgress(
parseProgressLog(onProgress),
`core install ${pkgName}`
)
),
// We have to call our custon `parseTable`
// until bug with `--format json` in arduino-cli will be fixed
// https://github.com/arduino/arduino-cli/issues/39
list: () => runAndParseTable('core list'),
search: query => runAndParseTable(`core search ${query}`),
list: listCores,
search: query =>
run(`core search ${query} --format json`)
.then(R.prop('Platforms'))
.then(R.defaultTo([])),
uninstall: pkgName => run(`core uninstall ${pkgName}`),
updateIndex: () => run('core update-index'),
upgrade: () => run('core upgrade'),
Expand Down
Loading

0 comments on commit 69495b3

Please sign in to comment.