refactor(xod-arduino-deploy, xod-client-electron): remove xod-arduino-deploy package

This commit is contained in:
Kirill Shumilov
2018-09-28 23:01:57 +03:00
parent ffcfbc9851
commit b3701b65e5
27 changed files with 4 additions and 3242 deletions

View File

@@ -1,12 +0,0 @@
{
"presets": [
[
"env",
{
"targets": {
"node": "8.6.0"
}
}
]
]
}

View File

@@ -1,661 +0,0 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

View File

@@ -1,7 +0,0 @@
# xod-arduino-deploy
This package is a part of the [XOD](https://github.com/xodio/xod) project.
It provides functions to manage packages, compile C++ code and upload binaries to the boards.
It uses `arduino-builder` and tools like `avrdude`, `bossac` and etc.

View File

@@ -1,42 +0,0 @@
{
"name": "xod-arduino-deploy",
"version": "0.24.0",
"description": "Utility to build and upload binaries on Arduino microcontrollers.",
"main": "dist/index.js",
"scripts": {
"copy-index": " cpx \"src/*.json\" dist",
"build": "babel src -d dist && yarn copy-index",
"dev": "yarn run build --watch",
"test": "mocha test/**/*.spec.js",
"clean:dist": "rimraf ./dist",
"test-func": "mocha --opts test-func/mocha.opts test-func/**/*.spec.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/xodio/xod.git"
},
"author": "XOD Team <dev@xod.io>",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/xodio/xod/issues"
},
"homepage": "https://github.com/xodio/xod#readme",
"dependencies": {
"child-process-promise": "^2.2.1",
"fs-extra": "^4.0.2",
"node-fetch": "^1.7.1",
"ramda": "^0.24.1",
"serialport": "^7.0.2",
"tar": "^3.1.8",
"unbzip2-stream": "^1.2.5",
"xod-fs": "^0.24.0",
"xod-func-tools": "^0.24.0"
},
"devDependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-fs": "^2.0.0",
"commander": "^2.11.0",
"cpx": "^1.5.0"
}
}

View File

@@ -1,137 +0,0 @@
import * as R from 'ramda';
import path from 'path';
import fse from 'fs-extra';
import * as Utils from './utils';
// =============================================================================
//
// Utils
//
// =============================================================================
/**
* Parses Arduino's `.txt` definition file. Like `boards.txt` or `platform.txt`.
*
* In the reduce function we have to store value of `A.menu.cpu.B` into special
* property to avoid breaking it with associating other properties.
* E.G.
* `nano.menu.cpu.atmega328 = ATmega328`
* stores String 'ATmega328' by the path `menu.cpu.atmega328`
* but then config has next lines:
* `nano.menu.cpu.atmega328.upload.speed = 12800`
* so our string will be converted into object in which will be associated
* object `upload` with property `speed`.
* As a result we have something like this:
* ```
* {
* menu: {
* cpu: {
* atmega328: {
* 0: 'A',
* 1: 'T',
* 2: 'm',
* ...
* upload: {
* speed: '12800'
* }
* }
* }
* }
* }
* ```
* To prevent it we'll store `nano.menu.cpu.atmega328 = ATmega328` into
* special property `cpuName` and then we have:
* ```
* {
* atmega328: {
* cpuName: 'ATmega328',
* upload: {
* speed: '12800'
* }
* }
* }
* ```
*/
// :: String -> Object
const parseTxtConfig = R.compose(
R.reduce(
(acc, [tokens, value]) =>
R.compose(
R.assocPath(R.__, value, acc),
R.when(
R.both(R.propEq(1, 'menu'), R.compose(R.equals(4), R.length)),
R.append('cpuName')
)
)(tokens),
{}
),
R.map(R.compose(R.zipWith(R.call, [R.split('.'), R.identity]), R.split('='))),
R.reject(R.test(/^(#|$)/)),
R.map(R.trim),
R.split(/$/gm)
);
/** Returns a parsed boards.txt from specified platform directory. */
// :: Path -> Promise (StrMap BoardPrefs) Error
export const loadBoards = R.curry(platformDir =>
R.pipeP(
() => Promise.resolve(path.resolve(platformDir, 'boards.txt')),
filePath => fse.readFile(filePath, 'utf8'),
parseTxtConfig
)()
);
// =============================================================================
//
// Load board preferences
//
// =============================================================================
// :: FQBN -> Map boardIdentifier BoardPrefs -> BoardPrefs
const getBoardPrefsByFqbn = R.curry((fqbn, boardPrefsMap) => {
const pabc = Utils.parseFQBN(fqbn);
const getCpuPrefs = R.pathOr({}, ['menu', 'cpu', pabc.cpu]);
return R.compose(
R.omit('menu'),
boardPrefs =>
R.compose(R.mergeDeepLeft(boardPrefs), getCpuPrefs)(boardPrefs),
R.prop(pabc.boardIdentifier)
)(boardPrefsMap);
});
/**
* Loads board preferences from boards.txt and returns only preferences for specified board.
*/
// :: FQBN -> Path -> Promise BoardPrefs Error
export const loadBoardPrefs = R.curry((fqbn, packagesDir) => {
const architectureDir = Utils.getArchitectureDirectory(fqbn, packagesDir);
return loadBoards(architectureDir).then(getBoardPrefsByFqbn(fqbn));
});
// BoardInfo :: {
// name: String,
// package: String,
// architecture: String,
// boardIdentifier: String,
// }
// :: FQBN -> Path -> [BoardInfo]
export const loadPABs = R.curry((fqbn, packagesDir) => {
const pab = Utils.parseFQBN(fqbn);
const architectureDir = Utils.getArchitectureDirectory(fqbn, packagesDir);
return loadBoards(architectureDir).then(
R.compose(
R.values,
R.mapObjIndexed((boardData, boardKey) => ({
name: boardData.name,
package: pab.package,
architecture: pab.architecture,
boardIdentifier: boardKey,
}))
)
);
});
export default loadBoardPrefs;

View File

@@ -1,76 +0,0 @@
import * as R from 'ramda';
import path from 'path';
import cpp from 'child-process-promise';
import fse from 'fs-extra';
import * as Utils from './utils';
// =============================================================================
//
// Prepare command and build
//
// =============================================================================
/**
* Transforms paths to libraries into arduino-builder arguments.
* E.G.
* ['/tmp/libs', '/usr/a/libs'] -> ['-libraries="/tmp/libs"', '-libraries="/usr/a/libs"']
*
* :: [String] -> [String]
*/
const composeLibArgs = R.map(p => `-libraries="${p}"`);
export const composeCommand = (
sketchFilePath,
fqbn,
packagesDir,
libraryDirs,
buildDir,
builderToolDir
) => {
const builderExecFileName = Utils.isWindows
? 'arduino-builder.exe'
: 'arduino-builder';
const builderExec = path.join(builderToolDir, builderExecFileName);
const builderHardware = path.join(builderToolDir, 'hardware');
const builderTools = path.join(builderToolDir, 'tools');
return [
`"${builderExec}"`,
`-hardware="${builderHardware}"`,
`-hardware="${packagesDir}"`,
...composeLibArgs(libraryDirs),
`-tools="${builderTools}"`,
`-tools="${packagesDir}"`,
`-fqbn="${fqbn}"`,
`-build-path="${buildDir}"`,
`"${sketchFilePath}"`,
].join(' ');
};
// :: Path -> FQBN -> Path -> Path -> Path -> PortName -> Promise { exitCode, stdout, stderr } Error
export const build = R.curry(
(
sketchFilePath,
fqbn,
packagesDir,
libraryDirs,
buildDir,
builderToolDir
) => {
const cmd = composeCommand(
sketchFilePath,
fqbn,
packagesDir,
libraryDirs,
buildDir,
builderToolDir
);
return fse
.ensureDir(buildDir)
.then(() => cpp.exec(cmd))
.then(Utils.normalizeChildProcessResult);
}
);

View File

@@ -1,29 +0,0 @@
import * as R from 'ramda';
import path from 'path';
import fse from 'fs-extra';
import fetch from 'node-fetch';
import { tapP } from 'xod-func-tools';
/**
* Downloads some file from the internet and put in the destination path.
* If the destination path has directories that do not exist it creates them.
*/
// :: URL -> Path -> Promise Path Error
export default R.curry((url, destinationPath) =>
fetch(url)
.then(tapP(() => fse.ensureDir(path.dirname(destinationPath))))
.then(res => {
const partPath = `${destinationPath}.part`;
const file = fse.createWriteStream(partPath);
return new Promise((resolve, reject) => {
res.body
.pipe(file)
.on('error', reject)
.on('finish', () => {
file.close(() => resolve(partPath));
});
});
})
.then(partPath => fse.rename(partPath, destinationPath))
.then(R.always(destinationPath))
);

View File

@@ -1,7 +0,0 @@
export { loadBoardPrefs, loadPABs } from './boardsParser';
export { build } from './builder';
export { upload, buildAndUpload } from './uploader';
export { installArchitecture, installTool } from './packageManager';
export { listPorts, openPort, openAndReadPort, closePort } from './serialport';
export { default as packageIndex } from './packageIndex.json';
export { listBoardsFromIndex, parseFQBN, strigifyFQBN } from './utils';

View File

@@ -1,413 +0,0 @@
{
"arduino": [
{
"name": "Arduino AVR Boards",
"architecture": "avr",
"version": "1.6.19",
"url": "http://downloads.arduino.cc/cores/avr-1.6.19.tar.bz2",
"toolsUrls": {
"win32": "https://storage.googleapis.com/releases.xod.io/packages/win32-avr-tools.tar.gz",
"darwin": "https://storage.googleapis.com/releases.xod.io/packages/darwin-avr-tools.tar.gz",
"linux": "https://storage.googleapis.com/releases.xod.io/packages/linux-avr-tools.tar.gz"
},
"boards": [
{
"name": "Arduino Yún",
"boardsTxtBoardId": "yun",
"platformioBoardId": "yun"
},
{
"name": "Arduino/Genuino Uno",
"boardsTxtBoardId": "uno",
"platformioBoardId": "uno"
},
{
"name": "Arduino Uno WiFi",
"boardsTxtBoardId": "unowifi",
"platformioBoardId": "the_things_uno"
},
{
"name": "Arduino Diecimila",
"cpuName": "ATmega328",
"cpuId": "atmega328",
"boardsTxtBoardId": "diecimila",
"platformioBoardId": "diecimilaatmega328"
},
{
"name": "Arduino Diecimila",
"cpuName": "ATmega168",
"cpuId": "atmega168",
"boardsTxtBoardId": "diecimila",
"platformioBoardId": "diecimilaatmega168"
},
{
"name": "Arduino Nano",
"cpuName": "ATmega328",
"cpuId": "atmega328",
"boardsTxtBoardId": "nano",
"platformioBoardId": "nanoatmega328"
},
{
"name": "Arduino Nano",
"cpuName": "ATmega168",
"cpuId": "atmega168",
"boardsTxtBoardId": "nano",
"platformioBoardId": "nanoatmega168"
},
{
"name": "Arduino/Genuino Mega or Mega 2560",
"cpuName": "ATmega2560",
"cpuId": "atmega2560",
"boardsTxtBoardId": "mega",
"platformioBoardId": "megaatmega2560"
},
{
"name": "Arduino/Genuino Mega or Mega 2560",
"cpuName": "ATmega1280",
"cpuId": "atmega1280",
"boardsTxtBoardId": "mega",
"platformioBoardId": "megaatmega1280"
},
{
"name": "Arduino MegaADK",
"boardsTxtBoardId": "megaADK",
"platformioBoardId": "megaADK"
},
{
"name": "Arduino Leonardo",
"boardsTxtBoardId": "leonardo",
"platformioBoardId": "leonardo"
},
{
"name": "Arduino Leonardo Ethernet",
"boardsTxtBoardId": "leonardoeth",
"platformioBoardId": "leonardoeth"
},
{
"name": "Arduino/Genuino Micro",
"boardsTxtBoardId": "micro",
"platformioBoardId": "micro"
},
{
"name": "Arduino Esplora",
"boardsTxtBoardId": "esplora",
"platformioBoardId": "esplora"
},
{
"name": "Arduino Mini",
"cpuName": "ATmega328",
"cpuId": "atmega328",
"boardsTxtBoardId": "mini",
"platformioBoardId": "miniatmega328"
},
{
"name": "Arduino Mini",
"cpuName": "ATmega168",
"cpuId": "atmega168",
"boardsTxtBoardId": "mini",
"platformioBoardId": "miniatmega168"
},
{
"name": "Arduino Ethernet",
"boardsTxtBoardId": "ethernet",
"platformioBoardId": "ethernet"
},
{
"name": "Arduino Fio",
"boardsTxtBoardId": "fio",
"platformioBoardId": "fio"
},
{
"name": "Arduino BT",
"cpuName": "ATmega328",
"cpuId": "atmega328",
"boardsTxtBoardId": "bt",
"platformioBoardId": "btatmega328"
},
{
"name": "Arduino BT",
"cpuName": "ATmega168",
"cpuId": "atmega168",
"boardsTxtBoardId": "bt",
"platformioBoardId": "btatmega168"
},
{
"name": "Arduino LilyPadUSB",
"boardsTxtBoardId": "LilyPadUSB",
"platformioBoardId": "LilyPadUSB"
},
{
"name": "Arduino Lilypad",
"cpuName": "ATmega328",
"cpuId": "atmega328",
"boardsTxtBoardId": "lilypad",
"platformioBoardId": "lilypadatmega328"
},
{
"name": "Arduino Lilypad",
"cpuName": "ATmega168",
"cpuId": "atmega168",
"boardsTxtBoardId": "lilypad",
"platformioBoardId": "lilypadatmega168"
},
{
"name": "Arduino Pro",
"cpuName": "ATmega328 (5V, 16MHz)",
"cpuId": "16MHzatmega328",
"boardsTxtBoardId": "pro",
"platformioBoardId": "pro16MHzatmega328"
},
{
"name": "Arduino Pro",
"cpuName": "ATmega328 (3.3V, 8MHz)",
"cpuId": "8MHzatmega328",
"boardsTxtBoardId": "pro",
"platformioBoardId": "pro8MHzatmega328"
},
{
"name": "Arduino Pro",
"cpuName": "ATmega168 (5V, 16MHz)",
"cpuId": "16MHzatmega168",
"boardsTxtBoardId": "pro",
"platformioBoardId": "pro16MHzatmega168"
},
{
"name": "Arduino Pro",
"cpuName": "ATmega168 (3.3V, 8MHz)",
"cpuId": "8MHzatmega168",
"boardsTxtBoardId": "pro",
"platformioBoardId": "pro8MHzatmega168"
},
{
"name": "Arduino ATMegaNG",
"cpuName": "ATmega168",
"cpuId": "atmega168",
"boardsTxtBoardId": "atmegang",
"platformioBoardId": "atmegangatmega168"
},
{
"name": "Arduino ATMegaNG",
"cpuName": "ATmega8",
"cpuId": "atmega8",
"boardsTxtBoardId": "atmegang",
"platformioBoardId": "atmegangatmega8"
},
{
"name": "Arduino Robot Control",
"boardsTxtBoardId": "robotControl",
"platformioBoardId": "robotControl"
},
{
"name": "Arduino Robot Motor",
"boardsTxtBoardId": "robotMotor",
"platformioBoardId": "robotMotor"
},
{
"name": "Adafruit Circuit Playground",
"boardsTxtBoardId": "circuitplay32u4cat"
},
{
"name": "Arduino Yún Mini",
"boardsTxtBoardId": "yunmini",
"platformioBoardId": "yunmini"
},
{
"name": "Arduino Industrial 101",
"boardsTxtBoardId": "chiwawa",
"platformioBoardId": "chiwawa"
},
{
"name": "Linino One",
"boardsTxtBoardId": "one",
"platformioBoardId": "one"
}
],
"tools": [
{
"name": "avr-gcc",
"version": "4.9.2-atmel3.5.4-arduino2",
"systems": {
"darwin": "http://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-i386-apple-darwin11.tar.bz2",
"win32": "http://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-i686-mingw32.zip",
"linux": "http://downloads.arduino.cc/tools/avr-gcc-4.9.2-atmel3.5.4-arduino2-x86_64-pc-linux-gnu.tar.bz2"
}
},
{
"name": "avrdude",
"version": "6.3.0-arduino9",
"systems": {
"darwin": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-i386-apple-darwin11.tar.bz2",
"linux": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-x86_64-pc-linux-gnu.tar.bz2",
"win32": "http://downloads.arduino.cc/tools/avrdude-6.3.0-arduino9-i686-w64-mingw32.zip"
}
},
{
"name": "arduinoOTA",
"version": "1.1.1",
"systems": {
"linux": "http://downloads.arduino.cc/tools/arduinoOTA-1.1.1-linux_amd64.tar.bz2",
"darwin": "http://downloads.arduino.cc/tools/arduinoOTA-1.1.1-darwin_amd64.tar.bz2",
"win32": "http://downloads.arduino.cc/tools/arduinoOTA-1.1.1-windows_386.zip"
}
}
]
},
{
"name": "Arduino SAM Boards (32-bits ARM Cortex-M3)",
"architecture": "sam",
"version": "1.6.11",
"url": "http://downloads.arduino.cc/cores/sam-1.6.11.tar.bz2",
"toolsUrls": {
"win32": "https://storage.googleapis.com/releases.xod.io/packages/win32-sam-tools.tar.gz",
"darwin": "https://storage.googleapis.com/releases.xod.io/packages/darwin-sam-tools.tar.gz",
"linux": "https://storage.googleapis.com/releases.xod.io/packages/linux-sam-tools.tar.gz"
},
"boards": [
{
"name": "Arduino Due (Programming Port)",
"boardsTxtBoardId": "arduino_due_x_dbg",
"platformioBoardId": "due"
},
{
"name": "Arduino Due (Native USB Port)",
"boardsTxtBoardId": "arduino_due_x",
"platformioBoardId": "dueUSB"
}
],
"tools": [
{
"name": "arm-none-eabi-gcc",
"version": "4.8.3-2014q1",
"systems": {
"win32": "http://downloads.arduino.cc/gcc-arm-none-eabi-4.8.3-2014q1-windows.tar.gz",
"darwin": "http://downloads.arduino.cc/gcc-arm-none-eabi-4.8.3-2014q1-mac.tar.gz",
"linux": "http://downloads.arduino.cc/gcc-arm-none-eabi-4.8.3-2014q1-linux64.tar.gz"
}
},
{
"name": "bossac",
"version": "1.6.1-arduino",
"systems": {
"win32": "http://downloads.arduino.cc/bossac-1.6.1-arduino-mingw32.tar.gz",
"darwin": "http://downloads.arduino.cc/bossac-1.6.1-arduino-i386-apple-darwin14.5.0.tar.gz",
"linux": "http://downloads.arduino.cc/bossac-1.6.1-arduino-x86_64-linux-gnu.tar.gz"
}
}
]
},
{
"name": "Arduino SAMD Boards (32-bits ARM Cortex-M0+)",
"architecture": "samd",
"version": "1.6.15",
"url": "http://downloads.arduino.cc/cores/samd-1.6.15.tar.bz2",
"toolsUrls": {
"win32": "https://storage.googleapis.com/releases.xod.io/packages/win32-samd-tools.tar.gz",
"darwin": "https://storage.googleapis.com/releases.xod.io/packages/darwin-samd-tools.tar.gz",
"linux": "https://storage.googleapis.com/releases.xod.io/packages/linux-samd-tools.tar.gz"
},
"boards": [
{
"name": "Arduino/Genuino Zero (Programming Port)",
"boardsTxtBoardId": "arduino_zero_edbg",
"platformioBoardId": "zero"
},
{
"name": "Arduino/Genuino Zero (Native USB Port)",
"boardsTxtBoardId": "arduino_zero_native",
"platformioBoardId": "zeroUSB"
},
{
"name": "Arduino/Genuino MKR1000",
"boardsTxtBoardId": "mkr1000",
"platformioBoardId": "mkr1000USB"
},
{
"name": "Arduino MKRZero",
"boardsTxtBoardId": "mkrzero",
"platformioBoardId": "mkrzero"
},
{
"name": "Arduino MKRFox1200",
"boardsTxtBoardId": "mkrfox1200",
"platformioBoardId": "mkrfox1200"
},
{
"name": "Arduino M0 Pro (Programming Port)",
"boardsTxtBoardId": "mzero_pro_bl_dbg",
"platformioBoardId": "mzeropro"
},
{
"name": "Arduino M0 Pro (Native USB Port)",
"boardsTxtBoardId": "mzero_pro_bl",
"platformioBoardId": "mzeroproUSB"
},
{
"name": "Arduino M0",
"boardsTxtBoardId": "mzero_bl",
"platformioBoardId": "mzeroUSB"
},
{
"name": "Adafruit Circuit Playground Express",
"boardsTxtBoardId": "adafruit_circuitplayground_m0",
"platformioBoardId": "adafruit_circuitplayground_m0"
}
],
"tools": [
{
"name": "arm-none-eabi-gcc",
"version": "4.8.3-2014q1",
"systems": {
"win32": "http://downloads.arduino.cc/gcc-arm-none-eabi-4.8.3-2014q1-windows.tar.gz",
"darwin": "http://downloads.arduino.cc/gcc-arm-none-eabi-4.8.3-2014q1-mac.tar.gz",
"linux": "http://downloads.arduino.cc/gcc-arm-none-eabi-4.8.3-2014q1-linux64.tar.gz"
}
},
{
"name": "arduinoOTA",
"version": "1.2.0",
"systems": {
"linux": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.0-linux_amd64.tar.bz2",
"darwin": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.0-darwin_amd64.tar.bz2",
"win32": "http://downloads.arduino.cc/tools/arduinoOTA-1.2.0-windows_386.zip"
}
},
{
"name": "bossac",
"version": "1.7.0",
"systems": {
"win32": "http://downloads.arduino.cc/tools/bossac-1.7.0-mingw32.tar.gz",
"darwin": "http://downloads.arduino.cc/tools/bossac-1.7.0-i386-apple-darwin15.6.0.tar.gz",
"linux": "http://downloads.arduino.cc/tools/bossac-1.7.0-x86_64-linux-gnu.tar.gz"
}
},
{
"name": "openocd",
"version": "0.9.0-arduino6-static",
"systems": {
"win32": "http://downloads.arduino.cc/tools/openocd-0.9.0-arduino6-static-i686-w64-mingw32.zip",
"darwin": "http://downloads.arduino.cc/tools/openocd-0.9.0-arduino6-static-x86_64-apple-darwin15.6.0.tar.bz2",
"linux": "http://downloads.arduino.cc/tools/openocd-0.9.0-arduino6-static-x86_64-linux-gnu.tar.bz2"
}
},
{
"name": "CMSIS",
"version": "4.5.0",
"systems": {
"win32": "http://downloads.arduino.cc/CMSIS-4.5.0.tar.bz2",
"darwin": "http://downloads.arduino.cc/CMSIS-4.5.0.tar.bz2",
"linux": "http://downloads.arduino.cc/CMSIS-4.5.0.tar.bz2"
}
},
{
"name": "CMSIS-Atmel",
"version": "1.1.0",
"systems": {
"win32": "http://downloads.arduino.cc/CMSIS-Atmel-1.1.0.tar.bz2",
"darwin": "http://downloads.arduino.cc/CMSIS-Atmel-1.1.0.tar.bz2",
"linux": "http://downloads.arduino.cc/CMSIS-Atmel-1.1.0.tar.bz2"
}
}
]
}
]
}

View File

@@ -1,218 +0,0 @@
import * as R from 'ramda';
import path from 'path';
import fse from 'fs-extra';
import tar from 'tar';
import bz2 from 'unbzip2-stream';
import * as Utils from './utils';
import download from './download';
// =============================================================================
//
// Promise utils
//
// =============================================================================
// :: Path -> Boolean
const isFileSync = filePath => {
try {
return fse.statSync(filePath).isFile();
} catch (err) {
if (err.code === 'ENOENT') return false;
throw err;
}
};
// :: Path -> Boolean
const isDirSync = dirPath => {
try {
return fse.statSync(dirPath).isDirectory();
} catch (err) {
if (err.code === 'ENOENT') return false;
throw err;
}
};
// =============================================================================
//
// Extracting utils
//
// =============================================================================
// :: Path -> Promise Path Error
export const extractBzip2IfNecessary = archivePath =>
new Promise((resolve, reject) => {
if (path.extname(archivePath) !== '.bz2') {
resolve(archivePath);
return;
}
const resultPath = archivePath.substr(
0,
archivePath.length - '.bz2'.length
);
const source = fse.createReadStream(archivePath);
const target = fse.createWriteStream(resultPath);
source.on('error', reject);
target
.on('error', reject)
.on('finish', () =>
fse.remove(archivePath).then(() => resolve(resultPath))
);
source.pipe(bz2()).pipe(target);
});
/**
* Unpacks tar[.gz] into the same directory.
* Use `strip` argument to cut specified number of leading path elements in the archive.
* Details: https://github.com/npm/node-tar#tarxoptions-filelist-callback-alias-tarextract
*/
// :: Path -> Number -> Promise Path Error
export const extractArchive = (archivePath, strip = 0) =>
extractBzip2IfNecessary(archivePath).then(tarPath =>
tar
.x({ file: tarPath, cwd: path.dirname(tarPath), strip })
.then(() => fse.remove(tarPath))
);
// InstallResult :: { path: Path, installed: Boolean, downloaded: Boolean }
// :: URL -> Path -> Path -> Number -> Promise InstallResult Error
export const downloadAndExtract = R.curry((url, unpackDest, strip) => {
const archiveName = path.basename(url);
const archivePath = path.join(unpackDest, archiveName);
return download(url, archivePath)
.then(() => extractArchive(archivePath, strip))
.then(() => ({
path: unpackDest,
installed: true,
downloaded: true,
}));
});
// =============================================================================
//
// Check for existence of installed architectures and tools
//
// =============================================================================
// :: FQBN -> PackagesDirPath -> Boolean
export const doesHardwareExist = R.compose(
isDirSync,
Utils.getArchitectureDirectory
);
// :: Tool -> ToolsDirPath -> Boolean
export const doesToolExist = R.curry((toolsDir, tool) =>
R.compose(isDirSync, Utils.getToolVersionDirectory)(
tool.name,
tool.version,
toolsDir
)
);
// :: [Tool] -> ToolsDirPath -> Boolean
export const doAllToolsExist = R.curry((toolsDir, tools) =>
R.all(doesToolExist(toolsDir), tools)
);
// TODO: unused?!
// :: FQBN -> PackageIndex -> Path -> Boolean
export const doesArchitectureInstalled = R.curry(
(fqbn, packageIndex, packagesDir) => {
const toolsDir = Utils.getToolsDirectory(fqbn, packagesDir);
const isHardwareInstalled = doesHardwareExist(fqbn, packagesDir);
const isToolsInstalled = R.compose(
R.all(tool => doesToolExist(toolsDir, tool)),
Utils.getToolsByFqbn
)(fqbn, packageIndex);
return R.and(isHardwareInstalled, isToolsInstalled);
}
);
// Because we delete archive after extracting it,
// its presence means the last time installation process
// went wrong and we need to start over
const doesStaleArchiveExist = (archiveUrl, unpackDest) => {
const archiveName = path.basename(archiveUrl);
const archivePath = path.join(unpackDest, archiveName);
return isFileSync(archivePath);
};
// =============================================================================
//
// Install hardware and tools
//
// =============================================================================
// :: FQBN -> PackagesDirPath -> PackageIndex -> Promise InstallResult Error
export const installHardware = R.curry((fqbn, packagesDir, packageIndex) => {
const architectureDir = Utils.getArchitectureDirectory(fqbn, packagesDir);
const architecture = Utils.getArchitectureByFqbn(fqbn, packageIndex);
const archiveUrl = R.prop('url', architecture);
if (
doesHardwareExist(fqbn, packagesDir) &&
!doesStaleArchiveExist(archiveUrl, architectureDir)
) {
return Promise.resolve({
path: architectureDir,
downloaded: false,
installed: true,
});
}
return downloadAndExtract(archiveUrl, architectureDir, 1);
});
// :: FQBN -> PackagesDirPath -> PackageIndex -> Promise InstallResult Error
export const installTools = R.curry((fqbn, packagesDir, packageIndex) => {
const tools = Utils.getToolsByFqbn(fqbn, packageIndex);
const toolsDir = Utils.getToolsDirectory(fqbn, packagesDir);
const archiveUrl = Utils.getToolsUrl(fqbn, packageIndex);
if (
doAllToolsExist(toolsDir, tools) &&
!doesStaleArchiveExist(archiveUrl, toolsDir)
) {
return Promise.resolve({
path: toolsDir,
downloaded: false,
installed: true,
});
}
return downloadAndExtract(archiveUrl, toolsDir, 0);
});
// :: Path -> Path -> URL -> Promise InstallResult Error
export const installTool = R.curry((toolsDir, toolName, archiveUrl) => {
const installedToolDir = path.resolve(toolsDir, toolName);
if (
isDirSync(installedToolDir) &&
!doesStaleArchiveExist(archiveUrl, toolsDir)
) {
return Promise.resolve({
path: toolsDir,
downloaded: false,
installed: true,
});
}
return downloadAndExtract(archiveUrl, toolsDir, 0);
});
// :: FQBN -> PackagesDirPath -> PackageIndex ->
// Promise { hardware: InstallResult, tools: InstallResult } Error
export const installArchitecture = R.curry((fqbn, packagesDir, packageIndex) =>
Promise.all([
installHardware(fqbn, packagesDir, packageIndex),
installTools(fqbn, packagesDir, packageIndex),
]).then(([hardware, tools]) => ({ hardware, tools }))
);

View File

@@ -1,182 +0,0 @@
import * as R from 'ramda';
import { tapP, delay as delayP } from 'xod-func-tools';
// =============================================================================
//
// Types
//
// =============================================================================
/**
* PortInfo :: { comName: PortName }
* Plain object, that contains comName (required field)
* and other fields, that provided by connected device.
*/
/**
* PortName :: String
* A string pointer to portName.
* E.G. `/dev/tty.usbmodem1421`, `COM4`.
*/
/**
* Port :: SerialPort
* It's an instance of SerialPort class.
* See docs:
* https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/4.0.7/README.md
*/
/**
* PortOptions :: Object
* Plain object, that contains flags to be set to open port.
* See docs:
* https://github.com/EmergingTechnologyAdvisors/node-serialport/blob/4.0.7/README.md#set-options-callback
*/
// =============================================================================
//
// Utils
//
// =============================================================================
const delay = ms => () => delayP(ms);
// :: PortOptions -> Port -> Promise Port Error
const setPortOptions = R.curry(
(options, port) =>
new Promise((resolve, reject) => {
port.set(options, err => {
if (err) {
reject(err);
}
resolve(port);
});
})
);
// :: Port -> Promise Port Error
const flushPort = port =>
new Promise((resolve, reject) => {
port.flush(err => {
if (err) reject(err);
resolve(port);
});
});
// =============================================================================
//
// Serial Port functions
//
// =============================================================================
/** Lists the available {@link Port}s.
* @type {Function}
* @return {Promise<Port[], Error>} */
// :: () -> [PortInfo]
export const listPorts = () =>
new Promise((resolve, reject) => {
// serialport is a native module that can conflict in ABI versions
// with one built for Electron:
//
// Error: The module '.../node_modules/serialport/build/Release/serialport.node'
// was compiled against a different Node.js version using
// NODE_MODULE_VERSION 53. This version of Node.js requires
// NODE_MODULE_VERSION 51. Please try re-compiling or re-installing
//
// Localize its require so that the conflict never arise if were
// using CLI for things not related to serial port.
//
// eslint-disable-next-line global-require
const SerialPort = require('serialport');
SerialPort.list((err, ports) => {
if (err) reject(err);
else resolve(ports);
});
});
// :: PortName -> PortOptions -> Promise Port Error
export const openPort = (portName, opts = {}) =>
new Promise((resolve, reject) => {
// eslint-disable-next-line global-require
const SerialPort = require('serialport');
try {
const port = new SerialPort(portName, opts);
port.on('error', reject);
port.on('open', () => resolve(port));
} catch (err) {
reject(err);
}
});
// :: Port -> Promise Port Error
export const closePort = port =>
new Promise((resolve, reject) => {
port.close(err => {
if (err) reject(err);
resolve(port);
});
});
// :: PortName -> (String -> *) -> Promise Port Error
export const openAndReadPort = (portName, onData, onClose) => {
// eslint-disable-next-line global-require
const SerialPort = require('serialport');
return openPort(portName, {
baudRate: 115200,
}).then(
R.tap(port => {
const parser = port.pipe(
new SerialPort.parsers.Readline({ delimiter: '\n' })
);
parser.on('data', onData);
port.on('close', onClose);
})
);
};
// :: PortName -> Promise Port Error
export const flushSerialBuffer = portName =>
openPort(portName)
.then(flushPort)
.then(setPortOptions({ dtr: false, rts: false }))
.then(tapP(delay(100)))
.then(setPortOptions({ dtr: true, rts: true }))
.then(closePort);
// :: PortName -> Promise Port Error
export const touchPort1200 = portName =>
openPort(portName, { baudRate: 1200 })
.then(setPortOptions({ dtr: false }))
.then(closePort)
.then(tapP(delay(400)));
// :: PortName -> Promise PortName Error
export const waitNewPort = async initialPorts => {
let beforePorts = initialPorts;
let elapsed = 0;
const enumDelay = 50;
while (elapsed < 10000) {
const afterPorts = await listPorts();
const diff = R.differenceWith(
(a, b) => a.comName === b.comName,
afterPorts,
beforePorts
);
if (diff.length > 0) {
await delay(200)();
return diff[0].comName;
}
beforePorts = afterPorts;
await delay(enumDelay)();
elapsed += enumDelay;
}
throw new Error('Board programming port did not appear');
};

View File

@@ -1,248 +0,0 @@
import * as R from 'ramda';
import path from 'path';
import cpp from 'child-process-promise';
import packageIndex from './packageIndex.json';
import * as Utils from './utils';
import { loadBoardPrefs } from './boardsParser';
import { build } from './builder';
import {
flushSerialBuffer,
touchPort1200,
waitNewPort,
listPorts,
} from './serialport';
// =============================================================================
//
// Tool specific commands
//
// =============================================================================
const bossacCommand = opts => {
const {
toolDirPath,
sketchFileName,
buildDir,
boardPrefs,
portName,
debug = false,
} = opts;
const toolExecFile = Utils.isWindows ? 'bossac.exe' : 'bossac';
const toolExecPath = path.join(toolDirPath, toolExecFile);
const artifactPath = path.join(buildDir, `${sketchFileName}.bin`);
const verbose = debug ? ' -i -d' : '';
return `"${toolExecPath}"${verbose} --port=${portName} -U ${
boardPrefs.upload.native_usb
} -e -w -b "${artifactPath}" -R`;
};
const avrdudeCommand = opts => {
const {
toolDirPath,
sketchFileName,
buildDir,
boardPrefs,
portName,
debug = false,
} = opts;
const toolExecFile = Utils.isWindows ? 'bin/avrdude.exe' : 'bin/avrdude';
const toolExecPath = path.join(toolDirPath, toolExecFile);
const configFile = path.join(toolDirPath, 'etc/avrdude.conf');
const artifactPath = path.join(buildDir, `${sketchFileName}.hex`);
const verbose = debug ? ' -v -v' : '';
const mcu = boardPrefs.build.emu
? boardPrefs.build.emu.mcu
: boardPrefs.build.mcu;
return `"${toolExecPath}" -C "${configFile}"${verbose} -p ${mcu} -c ${
boardPrefs.upload.protocol
} -P ${portName} -b ${
boardPrefs.upload.speed
} -D "-Uflash:w:${artifactPath}:i"`;
};
const openocdCommand = opts => {
const {
toolDirPath,
sketchFileName,
buildDir,
boardPrefs,
platformDir,
debug = false,
} = opts;
const toolExecFile = Utils.isWindows ? 'bin/openocd.exe' : 'bin/openocd';
const toolExecPath = path.join(toolDirPath, toolExecFile);
const scriptsDir = path.join(toolDirPath, 'share/openocd/scripts');
const buildVariant = path.join(
platformDir,
'variants',
boardPrefs.build.variant,
boardPrefs.build.openocdscript
);
const artifactPath = path.join(buildDir, `${sketchFileName}.bin`);
const bootloaderSize = boardPrefs.bootloader.size || '0x2000';
const verbose = debug ? ' -d2' : '';
return `"${toolExecPath}"${verbose} -s "${scriptsDir}" -f "${buildVariant}" -c "telnet_port disabled; program ${artifactPath} verify reset ${bootloaderSize}; shutdown"`;
};
// =============================================================================
//
// Prepare command and upload
//
// =============================================================================
// :: Path -> FQBN -> Path -> Path -> PortName -> BoardPrefs -> String
export const composeCommand = R.curry(
(sketchFilePath, fqbn, packagesDir, buildDir, boardPrefs, portName) => {
const pab = Utils.parseFQBN(fqbn);
const platformDir = Utils.getArchitectureDirectory(fqbn, packagesDir);
const toolName = Utils.getBoardUploadTool(boardPrefs);
const toolVersion = Utils.getToolVersion(fqbn, toolName, packageIndex);
const toolsDir = Utils.getToolsDirectory(fqbn, packagesDir);
const toolDirPath = Utils.getToolVersionDirectory(
toolName,
toolVersion,
toolsDir
);
const sketchFileName = path.basename(sketchFilePath);
switch (toolName) {
case 'bossac':
return bossacCommand({
toolDirPath,
sketchFileName,
buildDir,
boardPrefs,
portName,
});
case 'avrdude':
return avrdudeCommand({
toolDirPath,
sketchFileName,
buildDir,
boardPrefs,
portName,
});
case 'openocd':
case 'openocd-withbootsize':
return openocdCommand({
toolDirPath,
sketchFileName,
buildDir,
boardPrefs,
platformDir,
});
default: {
throw new Error(
`Architecture "${
pab.architecture
}" (${fqbn}) is not supported now. You can make a request to add it at https://forum.xod.io/`
);
}
}
}
);
// :: BoardPrefs -> Boolean
const getUploadBoolProp = R.curry((propName, boardPrefs) =>
R.compose(R.equals('true'), R.pathOr('false', ['upload', propName]))(
boardPrefs
)
);
// :: PortName -> BoardPrefs -> Promise PortName Error
const prepareBoardUpload = async (portName, boardPrefs) => {
if (!getUploadBoolProp('disable_flushing', boardPrefs)) {
await flushSerialBuffer(portName);
}
const ports = await listPorts();
if (getUploadBoolProp('use_1200bps_touch', boardPrefs)) {
await touchPort1200(portName);
}
const protocol = R.path(['upload', 'protocol'], boardPrefs);
const uploadPortName = getUploadBoolProp('wait_for_upload_port', boardPrefs)
? await waitNewPort(ports)
: portName;
return protocol === 'sam-ba' ? path.basename(uploadPortName) : uploadPortName;
};
// :: Path -> FQBN -> Path -> Path -> PortName -> Promise { exitCode, stdout, stderr } Error
export const upload = R.curry(
async (sketchFilePath, fqbn, packagesDir, buildDir, portName) => {
const boardPrefs = await loadBoardPrefs(fqbn, packagesDir);
const newPortName = await prepareBoardUpload(portName, boardPrefs);
const cmd = composeCommand(
sketchFilePath,
fqbn,
packagesDir,
buildDir,
boardPrefs,
newPortName
);
const exec = await cpp.exec(cmd);
return Utils.normalizeChildProcessResult(exec);
}
);
// :: Path -> FQBN -> Path -> Path -> Path -> PortName -> (String -> ()) -> Promise { exitCode, stdout, stderr } Error
export const buildAndUpload = R.curry(
(
sketchFilePath,
fqbn,
packagesDir,
libraryDirs,
buildDir,
portName,
builderToolDir,
onBuildStdout
) =>
build(
sketchFilePath,
fqbn,
packagesDir,
libraryDirs,
buildDir,
builderToolDir
).then(buildResult => {
if (buildResult.exitCode !== 0) {
return Promise.reject(
Object.assign(new Error(buildResult.stderr), buildResult)
);
}
onBuildStdout(buildResult.stdout);
return upload(sketchFilePath, fqbn, packagesDir, buildDir, portName).then(
uploadResult => {
if (uploadResult.exitCode !== 0) {
return Promise.reject(
Object.assign(new Error(uploadResult.stderr), uploadResult)
);
}
return {
exitCode: uploadResult.exitCode,
stdout: uploadResult.stdout,
stderr: uploadResult.stderr,
};
}
);
})
);

View File

@@ -1,143 +0,0 @@
import os from 'os';
import * as R from 'ramda';
import path from 'path';
export const isWindows = os.platform() === 'win32';
// :: FQBN -> String
const parseCpuParam = R.compose(
R.defaultTo(''),
R.nth(1),
R.match(/:{0,1}cpu=(\w+)/),
R.defaultTo('')
);
// :: FQBN -> { package: String, architecture: String, boardIdentifier: String, cpu: String }
export const parseFQBN = R.compose(
R.applySpec({
package: R.nth(0),
architecture: R.nth(1),
boardIdentifier: R.nth(2),
cpu: R.compose(parseCpuParam, R.nth(3)),
}),
R.split(':')
);
// :: { package: String, architecture: String, boardIdentifier: String, cpu: String } -> FQBN
export const strigifyFQBN = ({
package: pkg,
architecture,
boardIdentifier,
cpu = '',
}) =>
`${pkg}:${architecture}:${boardIdentifier}${
cpu && cpu.length > 0 ? `:cpu=${cpu}` : ''
}`;
// :: FQBN -> String -> PackageIndex -> String
export const getToolVersion = R.curry((fqbn, toolName, packageIndex) =>
R.compose(
pab =>
R.compose(
R.ifElse(
// ArduinoIDE has a preinstalled avr hardware
// And some boards (arduino:samd:tian) uses tools from this package.
// But PackageIndex doesn't has it in the `toolsDependencies` list.
// So for these cases we have to fallback to avr architecture
// to search for tools...
R.both(R.isNil, () => pab.architecture !== 'avr'),
() =>
getToolVersion(
`${pab.package}:avr:${pab.boardIdentifier}`,
toolName,
packageIndex
),
R.prop('version')
),
R.find(R.propEq('name', toolName)),
R.prop('tools'),
R.find(R.propEq('architecture', pab.architecture)),
R.prop(pab.package)
)(packageIndex),
parseFQBN
)(fqbn)
);
// :: { package: String, architecture: String } -> Path -> Path
export const getArchitectureDirectory = R.curry((fqbn, packagesDir) => {
const pab = parseFQBN(fqbn);
return path.join(packagesDir, pab.package, 'hardware', pab.architecture);
});
// :: FQBN -> PackageIndex -> Architecture
export const getArchitectureByFqbn = R.curry((fqbn, packageIndex) => {
const pab = parseFQBN(fqbn);
return R.compose(
R.find(R.propEq('architecture', pab.architecture)),
R.prop(pab.package)
)(packageIndex);
});
// :: FQBN -> PackageIndex -> [Tool]
export const getToolsByFqbn = R.compose(R.prop('tools'), getArchitectureByFqbn);
// :: FQBN -> PackageIndex -> URL
export const getToolsUrl = R.compose(
R.prop(os.platform()),
R.prop('toolsUrls'),
getArchitectureByFqbn
);
// :: FQBN -> PackageIndex -> Path
export const getToolsDirectory = R.curry((fqbn, packagesDir) =>
path.join(packagesDir, parseFQBN(fqbn).package, 'tools')
);
// :: String -> String -> Path -> Path
export const getToolVersionDirectory = R.curry(
(toolName, toolVersion, toolsDir) =>
path.join(toolsDir, toolName, toolVersion)
);
// :: BoardPrefs -> String
export const getBoardUploadTool = R.compose(
R.when(
// Dirty hack to use `openocd` tool to upload with bootloader size
R.equals('openocd-withbootsize'),
R.always('openocd')
),
R.path(['upload', 'tool'])
);
// :: PackageIndex -> [Board]
export const listBoardsFromIndex = R.compose(
R.flatten,
R.values,
R.mapObjIndexed((pkg, pkgName) =>
R.map(
arch =>
R.compose(
R.map(board => ({
name: board.name,
boardsTxtId: board.boardsTxtBoardId,
pio: board.platformioBoardId,
package: pkgName,
architecture: arch.architecture,
version: arch.version,
cpuName: R.defaultTo('', board.cpuName),
cpuId: R.defaultTo('', board.cpuId),
})),
R.prop('boards')
)(arch),
pkg
)
)
);
// :: ChildProcessResult -> { exitCode: Number, stdout: String, stderr: String }
export const normalizeChildProcessResult = r => ({
exitCode: r.childProcess.exitCode,
stdout: r.stdout,
stderr: r.stderr,
});

View File

@@ -1,4 +0,0 @@
--require babel-register
--colors
--timeout 300000
--bail

View File

@@ -1,65 +0,0 @@
import { assert } from 'chai';
import path from 'path';
import fse from 'fs-extra';
import * as PM from '../src/packageManager';
import packageIndex from '../src/packageIndex.json';
const tmpDir = path.resolve(__dirname, '.tmp');
const packagesDir = path.resolve(tmpDir, 'packages');
const removeTmpDir = () => fse.remove(tmpDir);
describe('Package Manager', () => {
before(removeTmpDir);
afterEach(removeTmpDir);
// Installing
it('installHardware() downloads and installs not existent hardware', () =>
PM.installHardware('arduino:avr:uno', packagesDir, packageIndex)
.then(res => {
assert.isTrue(res.installed);
assert.isTrue(res.downloaded);
})
// Call it again to be sure that we won't download and install it again
.then(() =>
PM.installHardware('arduino:avr:uno', packagesDir, packageIndex)
)
.then(res => {
assert.isTrue(res.installed);
assert.isFalse(res.downloaded);
}));
it('installTools() downloads and installs all tools', () =>
PM.installTools('arduino:avr:uno', packagesDir, packageIndex).then(res => {
assert.isTrue(res.installed);
assert.isTrue(res.downloaded);
}));
it('installArchitecture() downloads and installs hardware and all tools', () =>
PM.installArchitecture(
'arduino:sam:arduino_due_x',
packagesDir,
packageIndex
).then(res => {
assert.isTrue(res.hardware.installed);
assert.isTrue(res.tools.installed);
}));
describe('installTool', () => {
const toolName = 'avrdude/6.3.0-arduino9';
const url =
'https://storage.googleapis.com/releases.xod.io/tools/avrdude_darwin.tar.bz2';
// Installing
it('downloads and installs tool', () =>
PM.installTool(tmpDir, toolName, url)
.then(res => {
assert.isTrue(res.installed);
assert.isTrue(res.downloaded);
})
.then(() => PM.installTool(tmpDir, toolName, url))
.then(res => {
// already downloaded and installed
assert.isTrue(res.installed);
assert.isFalse(res.downloaded);
}));
});
});

View File

@@ -1,30 +0,0 @@
import path from 'path';
import { assert } from 'chai';
import * as BP from '../src/boardsParser';
describe('BoardsParser', () => {
const fixture = p => path.resolve(__dirname, 'fixtures', p);
const packagesDir = fixture('packages');
it('loadBoardPrefs() returns correct BoardPrefs', async () => {
const mkr1000 = await BP.loadBoardPrefs(
'arduino:samd:mkr1000',
packagesDir
);
const nano168 = await BP.loadBoardPrefs(
'arduino:avr:nano:cpu=atmega168',
packagesDir
);
assert.nestedPropertyVal(mkr1000, 'name', 'Arduino/Genuino MKR1000');
assert.nestedPropertyVal(mkr1000, 'build.mcu', 'cortex-m0plus');
assert.nestedPropertyVal(mkr1000, 'upload.tool', 'bossac');
assert.nestedPropertyVal(nano168, 'name', 'Arduino Nano');
assert.nestedPropertyVal(nano168, 'cpuName', 'ATmega168');
assert.nestedPropertyVal(nano168, 'build.mcu', 'atmega168');
assert.nestedPropertyVal(nano168, 'upload.tool', 'avrdude');
assert.nestedPropertyVal(nano168, 'upload.speed', '19200');
});
});

View File

@@ -1,50 +0,0 @@
import path from 'path';
import { assert } from 'chai';
import { composeCommand } from '../src/builder';
import { isWindows } from '../src/utils';
const winExt = isWindows ? '.exe' : '';
describe('Builder', () => {
it('composeCommand() returns correct command', () => {
const sketch = path.normalize('/tmp/test.cpp');
const packagesDir = path.normalize('/xod/packages/');
const libraryDirs = [
path.normalize('/xod/libraries/'),
path.normalize('/xod/my-libs'),
];
const artifacts = path.normalize('/xod/artifacts/');
const builderDir = path.normalize('/xod/arduino-builder/');
const cmd = composeCommand(
sketch,
'arduino:avr:uno',
packagesDir,
libraryDirs,
artifacts,
builderDir
);
const execCmd = path.normalize(
`/xod/arduino-builder/arduino-builder${winExt}`
);
const hardwareA = path.normalize('/xod/arduino-builder/hardware');
const toolsA = path.normalize('/xod/arduino-builder/tools');
assert.strictEqual(
cmd,
[
`"${execCmd}"`,
`-hardware="${hardwareA}"`,
`-hardware="${packagesDir}"`,
`-libraries="${libraryDirs[0]}"`,
`-libraries="${libraryDirs[1]}"`,
`-tools="${toolsA}"`,
`-tools="${packagesDir}"`,
'-fqbn="arduino:avr:uno"',
`-build-path="${artifacts}"`,
`"${sketch}"`,
].join(' ')
);
});
});

View File

@@ -1,44 +0,0 @@
nano.name=Arduino Nano
nano.upload.tool=avrdude
nano.upload.protocol=arduino
nano.bootloader.tool=avrdude
nano.bootloader.unlock_bits=0x3F
nano.bootloader.lock_bits=0x0F
nano.build.f_cpu=16000000L
nano.build.board=AVR_NANO
nano.build.core=arduino
nano.build.variant=eightanaloginputs
## Arduino Nano w/ ATmega328
## -------------------------
nano.menu.cpu.atmega328=ATmega328
nano.menu.cpu.atmega328.upload.maximum_size=30720
nano.menu.cpu.atmega328.upload.maximum_data_size=2048
nano.menu.cpu.atmega328.upload.speed=57600
nano.menu.cpu.atmega328.bootloader.low_fuses=0xFF
nano.menu.cpu.atmega328.bootloader.high_fuses=0xDA
nano.menu.cpu.atmega328.bootloader.extended_fuses=0xFD
nano.menu.cpu.atmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
nano.menu.cpu.atmega328.build.mcu=atmega328p
## Arduino Nano w/ ATmega168
## -------------------------
nano.menu.cpu.atmega168=ATmega168
nano.menu.cpu.atmega168.upload.maximum_size=14336
nano.menu.cpu.atmega168.upload.maximum_data_size=1024
nano.menu.cpu.atmega168.upload.speed=19200
nano.menu.cpu.atmega168.bootloader.low_fuses=0xff
nano.menu.cpu.atmega168.bootloader.high_fuses=0xdd
nano.menu.cpu.atmega168.bootloader.extended_fuses=0xF8
nano.menu.cpu.atmega168.bootloader.file=atmega/ATmegaBOOT_168_diecimila.hex
nano.menu.cpu.atmega168.build.mcu=atmega168

View File

@@ -1,370 +0,0 @@
# Copyright (c) 2014-2015 Arduino LLC. All right reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Arduino/Genuino Zero (Prorgamming Port)
# ---------------------------------------
arduino_zero_edbg.name=Arduino/Genuino Zero (Programming Port)
arduino_zero_edbg.vid.0=0x03eb
arduino_zero_edbg.pid.0=0x2157
arduino_zero_edbg.upload.tool=openocd
arduino_zero_edbg.upload.protocol=sam-ba
arduino_zero_edbg.upload.maximum_size=262144
arduino_zero_edbg.upload.use_1200bps_touch=false
arduino_zero_edbg.upload.wait_for_upload_port=false
arduino_zero_edbg.upload.native_usb=false
arduino_zero_edbg.build.mcu=cortex-m0plus
arduino_zero_edbg.build.f_cpu=48000000L
arduino_zero_edbg.build.usb_product="Arduino Zero"
arduino_zero_edbg.build.usb_manufacturer="Arduino LLC"
arduino_zero_edbg.build.board=SAMD_ZERO
arduino_zero_edbg.build.core=arduino
arduino_zero_edbg.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
arduino_zero_edbg.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
arduino_zero_edbg.build.openocdscript=openocd_scripts/arduino_zero.cfg
arduino_zero_edbg.build.variant=arduino_zero
arduino_zero_edbg.build.variant_system_lib=
arduino_zero_edbg.build.vid=0x2341
arduino_zero_edbg.build.pid=0x804d
arduino_zero_edbg.bootloader.tool=openocd
arduino_zero_edbg.bootloader.file=zero/samd21_sam_ba.bin
# Arduino/Genuino Zero (Native USB Port)
# ---------------------------------------
arduino_zero_native.name=Arduino/Genuino Zero (Native USB Port)
arduino_zero_native.vid.0=0x2341
arduino_zero_native.pid.0=0x804d
arduino_zero_native.vid.1=0x2341
arduino_zero_native.pid.1=0x004d
arduino_zero_native.vid.2=0x2341
arduino_zero_native.pid.2=0x824d
# If the board is a 2341:824d use 2341:824d for build and set other parameters as well
arduino_zero_native.vid.2.build.vid=0x2341
arduino_zero_native.vid.2.build.pid=0x824d
arduino_zero_native.vid.2.build.usb_product="Genuino Zero"
arduino_zero_native.vid.2.bootloader.file=zero/samd21_sam_ba_genuino.bin
arduino_zero_native.vid.3=0x2341
arduino_zero_native.pid.3=0x024d
# If the board is a 2341:024d use 2341:824d for build and set other parameters as well
arduino_zero_native.vid.3.build.vid=0x2341
arduino_zero_native.vid.3.build.pid=0x824d
arduino_zero_native.vid.3.build.usb_product="Genuino Zero"
arduino_zero_native.vid.3.bootloader.file=zero/samd21_sam_ba_genuino.bin
arduino_zero_native.upload.tool=bossac
arduino_zero_native.upload.protocol=sam-ba
arduino_zero_native.upload.maximum_size=262144
arduino_zero_native.upload.use_1200bps_touch=true
arduino_zero_native.upload.wait_for_upload_port=true
arduino_zero_native.upload.native_usb=true
arduino_zero_native.build.mcu=cortex-m0plus
arduino_zero_native.build.f_cpu=48000000L
arduino_zero_native.build.usb_product="Arduino Zero"
arduino_zero_native.build.usb_manufacturer="Arduino LLC"
arduino_zero_native.build.board=SAMD_ZERO
arduino_zero_native.build.core=arduino
arduino_zero_native.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
arduino_zero_native.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
arduino_zero_native.build.openocdscript=openocd_scripts/arduino_zero.cfg
arduino_zero_native.build.variant=arduino_zero
arduino_zero_native.build.variant_system_lib=
arduino_zero_native.build.vid=0x2341
arduino_zero_native.build.pid=0x804d
arduino_zero_native.bootloader.tool=openocd
arduino_zero_native.bootloader.file=zero/samd21_sam_ba.bin
# Arduino/Genuino MKR1000
# ---------------------------------------
mkr1000.name=Arduino/Genuino MKR1000
mkr1000.vid.0=0x2341
mkr1000.pid.0=0x804e
mkr1000.vid.1=0x2341
mkr1000.pid.1=0x004e
mkr1000.vid.2=0x2341
mkr1000.pid.2=0x824e
# If the board is a 2341:824e use 2341:824e for build and set other parameters as well
mkr1000.vid.2.build.vid=0x2341
mkr1000.vid.2.build.pid=0x824e
mkr1000.vid.2.build.usb_product="Genuino MKR1000"
mkr1000.vid.2.bootloader.file=mkr1000/samd21_sam_ba_genuino_mkr1000.bin
mkr1000.vid.3=0x2341
mkr1000.pid.3=0x024e
# If the board is a 2341:024e use 2341:824e for build and set other parameters as well
mkr1000.vid.3.build.vid=0x2341
mkr1000.vid.3.build.pid=0x824e
mkr1000.vid.3.build.usb_product="Genuino MKR1000"
mkr1000.vid.3.bootloader.file=mkr1000/samd21_sam_ba_genuino_mkr1000.bin
mkr1000.upload.tool=bossac
mkr1000.upload.protocol=sam-ba
mkr1000.upload.maximum_size=262144
mkr1000.upload.use_1200bps_touch=true
mkr1000.upload.wait_for_upload_port=true
mkr1000.upload.native_usb=true
mkr1000.build.mcu=cortex-m0plus
mkr1000.build.f_cpu=48000000L
mkr1000.build.usb_product="Arduino MKR1000"
mkr1000.build.usb_manufacturer="Arduino LLC"
mkr1000.build.board=SAMD_MKR1000
mkr1000.build.core=arduino
mkr1000.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
mkr1000.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
mkr1000.build.openocdscript=openocd_scripts/arduino_zero.cfg
mkr1000.build.variant=mkr1000
mkr1000.build.vid=0x2341
mkr1000.build.pid=0x804e
mkr1000.bootloader.tool=openocd
mkr1000.bootloader.file=mkr1000/samd21_sam_ba_arduino_mkr1000.bin
# Arduino MKRZero
# ---------------
mkrzero.name=Arduino MKRZero
mkrzero.vid.0=0x2341
mkrzero.pid.0=0x804f
mkrzero.vid.1=0x2341
mkrzero.pid.1=0x004f
mkrzero.upload.tool=bossac
mkrzero.upload.protocol=sam-ba
mkrzero.upload.maximum_size=262144
mkrzero.upload.use_1200bps_touch=true
mkrzero.upload.wait_for_upload_port=true
mkrzero.upload.native_usb=true
mkrzero.build.mcu=cortex-m0plus
mkrzero.build.f_cpu=48000000L
mkrzero.build.usb_product="Arduino MKRZero"
mkrzero.build.usb_manufacturer="Arduino LLC"
mkrzero.build.board=SAMD_MKRZERO
mkrzero.build.core=arduino
mkrzero.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
mkrzero.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
mkrzero.build.openocdscript=openocd_scripts/arduino_zero.cfg
mkrzero.build.variant=mkrzero
mkrzero.build.vid=0x2341
mkrzero.build.pid=0x804f
mkrzero.bootloader.tool=openocd
mkrzero.bootloader.file=mkrzero/samd21_sam_ba_arduino_mkrzero.bin
# Arduino MKRFox1200
# ---------------
mkrfox1200.name=Arduino MKRFox1200
mkrfox1200.vid.0=0x2341
mkrfox1200.pid.0=0x8050
mkrfox1200.vid.1=0x2341
mkrfox1200.pid.1=0x0050
mkrfox1200.upload.tool=bossac
mkrfox1200.upload.protocol=sam-ba
mkrfox1200.upload.maximum_size=262144
mkrfox1200.upload.use_1200bps_touch=true
mkrfox1200.upload.wait_for_upload_port=true
mkrfox1200.upload.native_usb=true
mkrfox1200.build.mcu=cortex-m0plus
mkrfox1200.build.f_cpu=48000000L
mkrfox1200.build.usb_product="Arduino MKRFox1200"
mkrfox1200.build.usb_manufacturer="Arduino LLC"
mkrfox1200.build.board=SAMD_MKRFox1200
mkrfox1200.build.core=arduino
mkrfox1200.build.extra_flags=-D__SAMD21G18A__ {build.usb_flags}
mkrfox1200.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
mkrfox1200.build.openocdscript=openocd_scripts/arduino_zero.cfg
mkrfox1200.build.variant=mkrfox1200
mkrfox1200.build.vid=0x2341
mkrfox1200.build.pid=0x8050
mkrfox1200.bootloader.tool=openocd
mkrfox1200.bootloader.file=mkrfox1200/samd21_sam_ba_arduino_mkrfox1200.bin
# Adafruit Circuit Playground M0
# ------------------------------
adafruit_circuitplayground_m0.name=Adafruit Circuit Playground Express
adafruit_circuitplayground_m0.vid.0=0x239A
adafruit_circuitplayground_m0.pid.0=0x8018
adafruit_circuitplayground_m0.vid.1=0x239A
adafruit_circuitplayground_m0.pid.1=0x0018
adafruit_circuitplayground_m0.upload.tool=bossac
adafruit_circuitplayground_m0.upload.protocol=sam-ba
adafruit_circuitplayground_m0.upload.maximum_size=262144
adafruit_circuitplayground_m0.upload.use_1200bps_touch=true
adafruit_circuitplayground_m0.upload.wait_for_upload_port=true
adafruit_circuitplayground_m0.upload.native_usb=true
adafruit_circuitplayground_m0.build.mcu=cortex-m0plus
adafruit_circuitplayground_m0.build.f_cpu=48000000L
adafruit_circuitplayground_m0.build.usb_product="Circuit Playground Express"
adafruit_circuitplayground_m0.build.usb_manufacturer="Adafruit"
adafruit_circuitplayground_m0.build.board=SAMD_CIRCUITPLAYGROUND_EXPRESS
adafruit_circuitplayground_m0.build.core=arduino
adafruit_circuitplayground_m0.build.extra_flags=-DCRYSTALLESS -DARDUINO_SAMD_ZERO -D__SAMD21G18A__ {build.usb_flags}
adafruit_circuitplayground_m0.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
adafruit_circuitplayground_m0.build.openocdscript=openocd_scripts/arduino_zero.cfg
adafruit_circuitplayground_m0.build.variant=circuitplay
adafruit_circuitplayground_m0.build.variant_system_lib=
adafruit_circuitplayground_m0.build.vid=0x239A
adafruit_circuitplayground_m0.build.pid=0x8018
adafruit_circuitplayground_m0.bootloader.tool=openocd
adafruit_circuitplayground_m0.bootloader.file=circuitplay/circuitplay_m0_samd21g18_sam_ba.bin
######################################################
#ARDUINO M0 PRO (WITH) BOOTLOADER - PROGRAMMING PORT
mzero_pro_bl_dbg.name=Arduino M0 Pro (Programming Port)
mzero_pro_bl_dbg.vid.0=0x03eb
mzero_pro_bl_dbg.pid.0=0x2111
mzero_pro_bl_dbg.upload.tool=openocd-withbootsize
mzero_pro_bl_dbg.upload.protocol=sam-ba
mzero_pro_bl_dbg.upload.maximum_size=262144
mzero_pro_bl_dbg.upload.use_1200bps_touch=false
mzero_pro_bl_dbg.upload.wait_for_upload_port=false
mzero_pro_bl_dbg.upload.native_usb=false
mzero_pro_bl_dbg.build.mcu=cortex-m0plus
mzero_pro_bl_dbg.build.f_cpu=48000000L
mzero_pro_bl_dbg.build.usb_product="Arduino M0 Pro"
mzero_pro_bl_dbg.build.board=SAM_ZERO
mzero_pro_bl_dbg.build.core=arduino
mzero_pro_bl_dbg.build.extra_flags=-D__SAMD21G18A__ -mthumb {build.usb_flags}
mzero_pro_bl_dbg.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
mzero_pro_bl_dbg.build.openocdscript=openocd_scripts/arduino_zero.cfg
mzero_pro_bl_dbg.build.variant=arduino_mzero
mzero_pro_bl_dbg.build.variant_system_lib=
mzero_pro_bl_dbg.build.vid=0x2a03
mzero_pro_bl_dbg.build.pid=0x804f
mzero_pro_bl_dbg.build.preferred_out_format=hex
mzero_pro_bl_dbg.bootloader.size=0x4000
mzero_pro_bl_dbg.bootloader.tool=openocd
mzero_pro_bl_dbg.bootloader.cmd_unprotect=at91samd bootloader 0
mzero_pro_bl_dbg.bootloader.cmd_protect=at91samd bootloader 16384
mzero_pro_bl_dbg.bootloader.cmd_protect_verify=at91samd bootloader
mzero_pro_bl_dbg.bootloader.file=mzero/Bootloader_D21_M0_Pro_150427.hex
######################################################
#ARDUINO M0 PRO (WITH) BOOTLOADER - NATIVE PORT
mzero_pro_bl.name=Arduino M0 Pro (Native USB Port)
mzero_pro_bl.vid.0=0x2a03
mzero_pro_bl.pid.0=0x004d
mzero_pro_bl.vid.1=0x2a03
mzero_pro_bl.pid.1=0x804d
mzero_pro_bl.vid.2=0x2a03
mzero_pro_bl.pid.2=0x004f
mzero_pro_bl.vid.3=0x2a03
mzero_pro_bl.pid.3=0x804f
mzero_pro_bl.upload.tool=avrdude
mzero_pro_bl.upload.protocol=stk500v2
mzero_pro_bl.upload.maximum_size=262144
mzero_pro_bl.upload.use_1200bps_touch=true
mzero_pro_bl.upload.wait_for_upload_port=true
mzero_pro_bl.upload.native_usb=true
mzero_pro_bl.upload.speed=57600
mzero_pro_bl.build.mcu=cortex-m0plus
mzero_pro_bl.build.f_cpu=48000000L
mzero_pro_bl.build.usb_product="Arduino M0 Pro"
mzero_pro_bl.build.board=SAM_ZERO
mzero_pro_bl.build.core=arduino
mzero_pro_bl.build.extra_flags=-D__SAMD21G18A__ -mthumb {build.usb_flags}
mzero_pro_bl.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
mzero_pro_bl.build.variant=arduino_mzero
mzero_pro_bl.build.variant_system_lib=
mzero_pro_bl.build.vid=0x2a03
mzero_pro_bl.build.pid=0x804f
mzero_pro_bl.build.preferred_out_format=hex
mzero_pro_bl.bootloader.size=0x4000
mzero_pro_bl.build.emu.mcu=atmega2560
mzero_pro_bl.bootloader.tool=avrdude
mzero_pro_bl.bootloader.low_fuses=0xff
######################################################
#ARDUINO M0 (WITH) BOOTLOADER
mzero_bl.name=Arduino M0
mzero_bl.vid.0=0x2a03
mzero_bl.pid.0=0x004d
mzero_bl.vid.1=0x2a03
mzero_bl.pid.1=0x804d
mzero_bl.vid.2=0x2a03
mzero_bl.pid.2=0x004e
mzero_bl.vid.3=0x2a03
mzero_bl.pid.3=0x804e
mzero_bl.upload.tool=avrdude
mzero_bl.upload.protocol=stk500v2
mzero_bl.upload.maximum_size=262144
mzero_bl.upload.use_1200bps_touch=true
mzero_bl.upload.wait_for_upload_port=true
mzero_bl.upload.native_usb=true
mzero_bl.upload.speed=57600
mzero_bl.build.mcu=cortex-m0plus
mzero_bl.build.f_cpu=48000000L
mzero_bl.build.usb_product="Arduino M0"
mzero_bl.build.board=SAM_ZERO
mzero_bl.build.core=arduino
mzero_bl.build.extra_flags=-D__SAMD21G18A__ -mthumb {build.usb_flags}
mzero_bl.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
mzero_bl.build.variant=arduino_mzero
mzero_bl.build.variant_system_lib=
mzero_bl.build.vid=0x2a03
mzero_bl.build.pid=0x804e
mzero_bl.build.preferred_out_format=hex
mzero_bl.bootloader.size=0x4000
mzero_bl.build.emu.mcu=atmega2560
mzero_bl.bootloader.tool=avrdude
mzero_bl.bootloader.low_fuses=0xff
######################################################
#ARDUINO TIAN (WITH) BOOTLOADER
tian.name=Arduino Tian
tian.upload.via_ssh=true
tian.vid.0=0x10C4
tian.pid.0=0xEA70
tian.descriptor.0=Enhanced Com Port
tian.upload.tool=avrdude
#tian.upload.protocol=stk500v2
tian.upload.protocol=wiring
tian.upload.maximum_size=262144
tian.upload.use_1200bps_touch=true
tian.upload.wait_for_upload_port=true
tian.upload.native_usb=true
tian.upload.speed=57600
tian.build.mcu=cortex-m0plus
tian.build.f_cpu=48000000L
tian.build.usb_product="Arduino Tian"
tian.build.board=SAMD_TIAN
tian.build.core=arduino
tian.build.extra_flags=-D__SAMD21G18A__ -mthumb {build.usb_flags}
tian.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
tian.build.openocdscript=openocd_scripts/arduino_zero.cfg
tian.build.variant=arduino_mzero
tian.build.variant_system_lib=
tian.build.vid=0x2a03
tian.build.pid=0x8052
tian.build.preferred_out_format=hex
tian.bootloader.size=0x4000
tian.build.emu.mcu=atmega2560
tian.bootloader.tool=openocd-withbootsize
tian.bootloader.low_fuses=0xff
tian.bootloader.file=sofia/Sofia_Tian_151118.hex
tian.drivers=SiliconLabs-CP2105/Silicon Labs VCP Driver.pkg
######################################################
#ARDUINO TIAN CONSOLE PORT (NOT FOR UPLOAD)
tian_cons.name=Arduino Tian (MIPS Console port)
tian_cons.vid.0=0x10C4
tian_cons.pid.0=0xEA70
tian_cons.descriptor.0=Standard Com Port
tian_cons.hide=true
tian_cons.build.board=SAMD_TIAN

View File

@@ -1,39 +0,0 @@
import { assert } from 'chai';
import { getLibraryNameFromUrl } from '../src/libraryManager';
describe('Library Manager', () => {
describe('getLibraryNameFromUrl()', () => {
const assertJustEq = (url, expected) => {
const res = getLibraryNameFromUrl(url);
assert.isTrue(res.isJust);
res.map(val => assert.strictEqual(val, expected));
};
it('returns unchanged `Just String` for simple library name', () => {
assertJustEq('https://github.com/arduino-libraries/8266', '8266');
assertJustEq('https://github.com/arduino-libraries/GSM', 'GSM');
assertJustEq('https://github.com/FastLED/FastLED', 'FastLED');
});
it('returns normalized `Just String` for library name with forbidden characters', () => {
assertJustEq(
'https://github.com/z3t0/Arduino-IRremote',
'Arduino_IRremote'
);
assertJustEq(
'https://github.com/test/very-$tЯangэ-libName25',
'very_tang_libName25'
);
});
it('returns `Nothing` for library that contains only forbidden characters', () => {
assert.isTrue(
getLibraryNameFromUrl('https://github.com/test/~~|+&%@@').isNothing
);
});
it('returns `Nothing` for invalid Url', () => {
assert.isTrue(
getLibraryNameFromUrl('https://github.com/xodio').isNothing
);
assert.isTrue(getLibraryNameFromUrl('http://xod.io/').isNothing);
});
});
});

View File

@@ -1,2 +0,0 @@
--require babel-register
--colors

View File

@@ -1,89 +0,0 @@
import { assert } from 'chai';
import path from 'path';
import { composeCommand } from '../src/uploader';
import { isWindows } from '../src/utils';
import { loadBoardPrefs } from '../src/boardsParser';
const winExt = isWindows ? '.exe' : '';
describe('Uploader', () => {
const fixture = p => path.resolve(__dirname, 'fixtures', p);
const packagesDir = fixture('packages');
const artifactsDir = fixture('artifacts');
it('composeCommand() for `arduino:samd:arduino_zero_native` (bossac)', async () => {
const fqbn = 'arduino:samd:arduino_zero_native';
const boardPrefs = await loadBoardPrefs(fqbn, packagesDir);
const cmd = composeCommand(
'/tmp/test.cpp',
'arduino:samd:arduino_zero_native',
packagesDir,
artifactsDir,
boardPrefs,
'/dev/cu.usbmodem1411'
);
const execCmd = path.normalize(
`${packagesDir}/arduino/tools/bossac/1.7.0/bossac${winExt}`
);
const binaryFile = path.join(artifactsDir, 'test.cpp.bin');
assert.strictEqual(
cmd,
`"${execCmd}" --port=/dev/cu.usbmodem1411 -U true -e -w -b "${binaryFile}" -R`
);
});
it('composeCommand() for `arduino:samd:mzero_pro_bl_dbg` (openocd-withbootsize)', async () => {
const fqbn = 'arduino:samd:mzero_pro_bl_dbg';
const boardPrefs = await loadBoardPrefs(fqbn, packagesDir);
const cmd = composeCommand(
'/tmp/test.cpp',
fqbn,
packagesDir,
artifactsDir,
boardPrefs,
'/dev/cu.usbmodem1411'
);
const execCmd = path.normalize(
`${packagesDir}/arduino/tools/openocd/0.9.0-arduino6-static/bin/openocd${winExt}`
);
const scripts = path.normalize(
`${packagesDir}/arduino/tools/openocd/0.9.0-arduino6-static/share/openocd/scripts`
);
const config = path.normalize(
`${packagesDir}/arduino/hardware/samd/variants/arduino_mzero/openocd_scripts/arduino_zero.cfg`
);
const binaryFile = path.join(artifactsDir, 'test.cpp.bin');
assert.strictEqual(
cmd,
`"${execCmd}" -s "${scripts}" -f "${config}" -c "telnet_port disabled; program ${binaryFile} verify reset 0x4000; shutdown"`
);
});
it('composeCommand() for `arduino:samd:tian` (avrdude)', async () => {
const fqbn = 'arduino:samd:tian';
const boardPrefs = await loadBoardPrefs(fqbn, packagesDir);
const cmd = composeCommand(
'/tmp/test.cpp',
'arduino:samd:tian',
packagesDir,
artifactsDir,
boardPrefs,
'/dev/cu.usbmodem1411'
);
const execCmd = path.normalize(
`${packagesDir}/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude${winExt}`
);
const config = path.normalize(
`${packagesDir}/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf`
);
const binaryFile = path.join(artifactsDir, 'test.cpp.hex');
assert.strictEqual(
cmd,
`"${execCmd}" -C "${config}" -p atmega2560 -c wiring -P /dev/cu.usbmodem1411 -b 57600 -D "-Uflash:w:${binaryFile}:i"`
);
});
});

View File

@@ -1,76 +0,0 @@
import path from 'path';
import { assert } from 'chai';
import * as Utils from '../src/utils';
import packageIndex from '../src/packageIndex.json';
describe('Utils', () => {
it('parseFQBN() returns { package, architecture, boardIdentifier, cpu }', () => {
assert.deepEqual(Utils.parseFQBN('arduino:avr:uno'), {
package: 'arduino',
architecture: 'avr',
boardIdentifier: 'uno',
cpu: '',
});
assert.deepEqual(Utils.parseFQBN('arduino:avr:nano:cpu=atmega328'), {
package: 'arduino',
architecture: 'avr',
boardIdentifier: 'nano',
cpu: 'atmega328',
});
});
it('getToolVersion() returns version', () => {
const version = Utils.getToolVersion(
'arduino:samd:arduino_zero_native',
'bossac',
packageIndex
);
assert.equal(
version,
'1.7.0',
'Should return proper version of a tool from packageIndex'
);
});
it('getToolsByFqbn() returns a list of tools', () => {
const tools = Utils.getToolsByFqbn(
'arduino:samd:arduino_zero_native',
packageIndex
);
assert.lengthOf(tools, 6);
});
it('getArchitectureDirectory() returns correct path', () => {
const dir = Utils.getArchitectureDirectory('arduino:avr:uno', '/xod/');
assert.strictEqual(dir, path.normalize('/xod/arduino/hardware/avr'));
});
it('getToolsDirectory() returns correct path', () => {
const dir = Utils.getToolsDirectory('arduino:avr:uno', '/xod/');
assert.strictEqual(dir, path.normalize('/xod/arduino/tools'));
});
it('getToolVersionDirectory() returns correct path', () => {
const dir = Utils.getToolVersionDirectory(
'avrdude',
'1.0.0-arduino1',
'/xod/arduino/tools/'
);
assert.strictEqual(
dir,
path.normalize('/xod/arduino/tools/avrdude/1.0.0-arduino1')
);
});
it('listBoardsFromIndex() returns flat list of board objects', () => {
const boards = Utils.listBoardsFromIndex(packageIndex);
assert.isArray(boards);
assert.isNotEmpty(boards);
assert.hasAllKeys(boards[0], [
'name',
'package',
'architecture',
'version',
'cpuName',
'cpuId',
'pio',
'boardsTxtId',
]);
});
});

View File

@@ -46,7 +46,6 @@
"serialport": "^7.0.2",
"which": "^1.3.1",
"xod-arduino": "^0.24.0",
"xod-arduino-deploy": "^0.24.0",
"xod-client": "^0.24.0",
"xod-deploy": "^0.24.0",
"xod-fs": "^0.24.0",

View File

@@ -1,17 +1,10 @@
import * as R from 'ramda';
import os from 'os';
import fse from 'fs-extra';
import { resolve, join as pjoin } from 'path';
import { app } from 'electron';
import { writeFile } from 'xod-fs';
import { tapP, rejectWithCode, delay } from 'xod-func-tools';
import * as xad from 'xod-arduino-deploy';
import { rejectWithCode, delay } from 'xod-func-tools';
import * as xd from 'xod-deploy';
import * as settings from './settings';
import * as MESSAGES from '../shared/messages';
import formatError from '../shared/errorFormatter';
import * as ERROR_CODES from '../shared/errorCodes';
import * as EVENTS from '../shared/events';
import {
@@ -19,34 +12,6 @@ import {
parseDebuggerMessage,
createErrorMessage,
} from '../shared/debuggerMessages';
import { errorToPlainObject, IS_DEV } from './utils';
import { getArdulibsPath, getBundledArdulibsPath } from './arduinoDependencies';
// =============================================================================
//
// Computed paths
//
// =============================================================================
const arduinoPackagesPath = resolve(app.getPath('userData'), 'packages');
const arduinoBuilderPlatformMap = {
win32: 'win',
linux: 'linux',
darwin: 'mac',
};
const arduinoBuilderPath = IS_DEV
? resolve(
app.getAppPath(),
'arduino-builders',
arduinoBuilderPlatformMap[os.platform()]
)
: resolve(process.resourcesPath, 'arduino-builder');
const artifactTmpDir = resolve(app.getPath('userData'), 'upload-temp');
// Another place to store uploader tools
// Will be used by xod-deploy (cloud compiler)
const uploadToolsPath = resolve(app.getPath('userData'), 'tools');
// =============================================================================
//
@@ -54,12 +19,6 @@ const uploadToolsPath = resolve(app.getPath('userData'), 'tools');
//
// =============================================================================
/**
* Returns a list of Boards, that was bundled into `xod-client-electron`.
*/
// :: () -> [Board]
export const getListOfBoards = () => xad.listBoardsFromIndex(xad.packageIndex);
/**
* Returns a target Board.
* It tries to take a value from Settings, if it doesn't exist
@@ -89,13 +48,6 @@ export const saveTargetBoard = board =>
// Upload actions
//
// =============================================================================
/**
* Install hardware data and tools by fqbn
*/
export const installPackage = fqbn =>
xad
.installArchitecture(fqbn, arduinoPackagesPath, xad.packageIndex)
.catch(rejectWithCode(ERROR_CODES.CANT_INSTALL_ARCHITECTURE));
/**
* Gets list of all serial ports
@@ -132,187 +84,6 @@ export const checkPort = port =>
)
.catch(rejectWithCode(ERROR_CODES.PORT_NOT_FOUND));
/**
* Upload transpiled code to specified device at specified port
* @param {Object} pab
* @param {Object} port
* @param {String} code
* @returns {Promise<String, Error>} Promise with Stdout or Error
*/
export const uploadToArduino = (
pab,
port,
code,
ardulibsPath,
onBuildStdout = () => {}
) => {
// Create tmpDir in userData instead of os.tmpdir() to avoid error "readdirent: result too large
const sketchFile = pjoin(artifactTmpDir, 'xod-arduino-sketch.cpp');
const buildDir = pjoin(artifactTmpDir, 'build');
const clearTmp = () => fse.remove(artifactTmpDir);
let libPaths = [getBundledArdulibsPath()];
return writeFile(sketchFile, code, 'utf8')
.then(
tapP(() =>
fse.pathExists(ardulibsPath).then(exists => {
if (exists) {
libPaths = R.append(ardulibsPath, libPaths);
}
})
)
)
.then(({ path }) =>
xad.buildAndUpload(
path,
pab,
arduinoPackagesPath,
libPaths,
buildDir,
port,
arduinoBuilderPath,
onBuildStdout
)
)
.then(tapP(clearTmp))
.catch(err =>
clearTmp().then(() => rejectWithCode(ERROR_CODES.UPLOAD_ERROR, err))
);
};
// :: String -> [Board] -> Board
const findBoardById = R.curry((id, boards) =>
R.find(R.propEq('boardIdentifier', id), boards)
);
// =============================================================================
//
// Local compiling and uploading case
//
// =============================================================================
const deployToArduino = ardulibsPath => ({
payload,
sendProgress,
sendSuccess,
}) => {
const boardId = payload.board.boardsTxtId;
const boardCpuId = payload.board.cpuId;
const { package: pkg, architecture } = payload.board;
const fqbn = `${pkg}:${architecture}:unknown`;
return R.pipeP(
sendProgress(MESSAGES.CODE_TRANSPILED, 10),
() => checkPort(payload.port).then(port => ({ port: port.comName })),
sendProgress(MESSAGES.PORT_FOUND, 15),
tapP(() => installPackage(fqbn)),
sendProgress(MESSAGES.TOOLCHAIN_INSTALLED, 30),
({ port }) =>
xad.loadPABs(fqbn, arduinoPackagesPath).then(boards => ({
port,
pab: R.compose(R.assoc('cpu', boardCpuId), findBoardById(boardId))(
boards
),
})),
({ port, pab }) =>
uploadToArduino(
xad.strigifyFQBN(pab),
port,
payload.code,
ardulibsPath,
buildStdout => {
sendProgress(buildStdout, 60)();
}
),
result => {
if (result.exitCode !== 0) {
return Promise.reject(
Object.assign(
new Error(`Upload tool exited with error code: ${result.exitCode}`),
result
)
);
}
sendSuccess([result.stdout, result.stderr].join('\n\n'), 100)();
return result;
}
)(Promise.resolve());
};
// =============================================================================
//
// Cloud compiling and uploading case
//
// =============================================================================
// :: UploadConfig -> Promise Path Error
const installTool = R.converge(xad.installTool(uploadToolsPath), [
xd.getToolVersionPath,
xd.getToolUrl,
]);
const deployToArduinoThroughCloud = ({
payload,
sendProgress,
sendSuccess,
}) => {
const { code } = payload;
const pio = payload.board.pio;
return R.pipeP(
sendProgress(MESSAGES.CODE_TRANSPILED, 10),
() =>
checkPort(payload.port).then(port => ({
port: port.comName,
})),
sendProgress(MESSAGES.PORT_FOUND, 15),
({ port }) =>
xd
.getUploadConfig(pio)
.then(uploadConfig => ({ port, uploadConfig }))
.catch(err => {
const errCode = R.cond([
[
R.propEq('status', 404),
R.always(ERROR_CODES.BOARD_NOT_SUPPORTED),
],
[R.has('status'), R.always(ERROR_CODES.CANT_GET_UPLOAD_CONFIG)],
[R.T, R.always(ERROR_CODES.CLOUD_NETWORK_ERROR)],
])(err);
return rejectWithCode(errCode, err);
}),
data =>
installTool(data.uploadConfig).then(res =>
R.assoc('toolPath', res.path, data)
),
sendProgress(MESSAGES.CLOUD_TOOLCHAIN_INSTALLED, 30),
data =>
xd
.compile(pio, code)
.then(xd.saveCompiledBinary(artifactTmpDir))
.then(artifactPath => R.assoc('artifactPath', artifactPath, data)),
sendProgress(MESSAGES.CODE_COMPILED, 75),
({ uploadConfig, toolPath, artifactPath, port }) =>
xd.upload(uploadConfig, { toolPath, artifactPath, port }),
result => {
if (result.exitCode !== 0) {
return Promise.reject(
Object.assign(
new Error(`Upload tool exited with error code: ${result.exitCode}`),
result
)
);
}
sendSuccess([result.stderr, result.stdout].join('\n\n'), 100)();
return result;
}
)(Promise.resolve());
};
// =============================================================================
//
// Debug
@@ -423,52 +194,6 @@ export const startDebugSessionHandler = (storeFn, onCloseCb) => (
export const stopDebugSessionHandler = (event, port) => xd.closePort(port);
export const uploadToArduinoHandler = (event, payload, wsPath) => {
let lastPercentage = 0;
// Messages
const send = status =>
R.compose(
data => arg => {
event.sender.send('UPLOAD_TO_ARDUINO', data);
return arg;
},
R.assoc(status, true),
(message, percentage, err = null) => {
lastPercentage = percentage;
return {
success: false,
progress: false,
failure: false,
error: err,
message,
percentage,
};
}
);
// :: (message, percentage, error) -> a -> a
const sendSuccess = send('success');
const sendProgress = send('progress');
const sendFailure = send('failure');
const convertAndSendError = err =>
R.compose(
msg => sendFailure(msg, lastPercentage, errorToPlainObject(err))(),
formatError
)(err);
const ardulibsPath = getArdulibsPath(wsPath);
const deployFn = payload.cloud
? deployToArduinoThroughCloud
: deployToArduino(ardulibsPath);
return deployFn({
payload,
sendProgress,
sendSuccess,
}).catch(convertAndSendError);
};
export const listPortsHandler = event =>
listPorts()
.then(ports =>
@@ -484,12 +209,6 @@ export const listPortsHandler = event =>
})
);
export const listBoardsHandler = event =>
event.sender.send(EVENTS.LIST_BOARDS, {
err: false,
data: getListOfBoards(),
});
export const loadTargetBoardHandler = event =>
event.sender.send(EVENTS.GET_SELECTED_BOARD, {
err: false,

View File

@@ -13,7 +13,6 @@ import {
import * as EVENTS from '../shared/events';
import {
listBoardsHandler,
listPortsHandler,
loadTargetBoardHandler,
saveTargetBoardHandler,
@@ -221,7 +220,6 @@ const onReady = () => {
);
ipcMain.on(EVENTS.STOP_DEBUG_SESSION, stopDebugSession);
ipcMain.on(EVENTS.LIST_PORTS, listPortsHandler);
ipcMain.on(EVENTS.LIST_BOARDS, listBoardsHandler);
ipcMain.on(EVENTS.GET_SELECTED_BOARD, loadTargetBoardHandler);
ipcMain.on(EVENTS.SET_SELECTED_BOARD, saveTargetBoardHandler);
ipcMain.on(EVENTS.CONFIRM_CLOSE_WINDOW, () => {

View File

@@ -8406,13 +8406,13 @@ minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
minipass@^2.0.2, minipass@^2.2.1:
minipass@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.2.1.tgz#5ada97538b1027b4cf7213432428578cb564011f"
dependencies:
yallist "^3.0.0"
minizlib@^1.0.3, minizlib@^1.0.4:
minizlib@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.0.4.tgz#8ebb51dd8bbe40b0126b5633dbb36b284a2f523c"
dependencies:
@@ -8630,7 +8630,7 @@ node-dir@^0.1.10:
dependencies:
minimatch "^3.0.2"
node-fetch@1.7.3, node-fetch@^1.0.1, node-fetch@^1.7.1, node-fetch@^1.7.2:
node-fetch@1.7.3, node-fetch@^1.0.1, node-fetch@^1.7.2:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
dependencies:
@@ -12262,16 +12262,6 @@ tar@^2.0.0, tar@^2.2.1:
fstream "^1.0.2"
inherits "2"
tar@^3.1.8:
version "3.2.1"
resolved "https://registry.yarnpkg.com/tar/-/tar-3.2.1.tgz#9aa8e41c88f09e76c166075bc71f93d5166e61b1"
dependencies:
chownr "^1.0.1"
minipass "^2.0.2"
minizlib "^1.0.3"
mkdirp "^0.5.0"
yallist "^3.0.2"
tar@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/tar/-/tar-4.0.2.tgz#e8e22bf3eec330e5c616d415a698395e294e8fad"