Skip to content

Commit

Permalink
added readme(need to continue), remove updates (almost done), install…
Browse files Browse the repository at this point in the history
… script
  • Loading branch information
ksrichard committed Apr 21, 2021
1 parent f6ef905 commit 05e7372
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 4 deletions.
84 changes: 84 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apm (Arduino Package Manager)
---

A package manager for Arduino projects to make them portable (no more manual download etc...).

This tool fully includes the official `arduino-cli` (it won't be installed nor need to be installed)
so it is automatically compatible with any kind of Arduino projects/sketches.

### Features
```bash
A package manager for Arduino projects.
The official arduino-cli packages are used to perform actions.

Usage:
apm [command]

Available Commands:
add Adding new libraries to the project
help Help about any command
init Init APM project
install Install dependencies of project
remove Remove library from the project

Flags:
-h, --help help for apm
-p, --project-dir string Project directory to use (default "/Users/klavorar/Documents/Arduino/temp_sensor")

Use "apm [command] --help" for more information about a command.
```

### Showcase


### How it works
Every `apm` based project must have a file called `apm.json` in the project root (it can be create by running `apm init`)
This configuration file is containing all the information that an Arduino project needs.

`NOTE on versioning` - if you would like to use always the latest version, please use `latest` in any package version and always latest will be used!

`apm.json` structure:
- `board` - (Optional) you can select here the package/architecture of the board you will use, it will be automatically installed
- `package` - Arduino core package name
- `architecture` - Architecture of Arduino core package
- `version` - Version of core package (`latest` for always latest version)
- `board_manager_url` - (Optional) Additional Board Manager URL if needed for the board core package to be installed
- `dependencies` - (Optional, if empty, no dependencies will be installed of course)
contains all Arduino Library dependencies that the actual project needs (if any Version mismatch will be in place, process will be stopped)
- `library` - Arduino Library name
- `version` - Arduino Library version
- `git` - (Optional - if it's set, do not set `library` and `version`) install library from git repository
- `zip` - (Optional - if it's set, do not set `library` and `version`) install library from local zip file

Example `apm.json`:
```json
{
"board": {
"package": "esp8266",
"architecture": "esp8266",
"version": "latest",
"board_manager_url": "https://arduino.esp8266.com/stable/package_esp8266com_index.json"
},
"dependencies": [
{
"library": "HomeKit-ESP8266",
"version": "1.2.0"
},
{
"library": "OneWire",
"version": "latest"
},
{
"library": "DallasTemperature",
"version": "latest"
},
{
"git": "https://github.com/jandrassy/ArduinoOTA"
},
{
"zip": "ESP8266NetBIOS.zip"
}
]
}
```

17 changes: 13 additions & 4 deletions cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (

// removeCmd represents the remove command
var removeCmd = &cobra.Command{
Use: "remove",
Use: "remove",
Example: "apm remove\napm remove OneWire\napm remove onewire\napm remove \"robot control\"\napm remove \"Robot Control\"",
Short: "Remove library from the project",
Long: `Remove library from the Arduino project`,
Short: "Remove library from the project",
Long: `Remove library from the Arduino project`,
RunE: func(cmd *cobra.Command, args []string) error {
// project details
details, err := project.GetProjectDetails(cmd)
Expand All @@ -53,7 +53,16 @@ var removeCmd = &cobra.Command{
fmt.Println("No library provided...")
items := make(map[string]interface{})
for _, dep := range details.Dependencies {
items[fmt.Sprintf("%s (%s)", dep.Library, dep.Version)] = dep.Library
// TODO: continue
//if dep.Library == "" && dep.Git != "" {
// items[dep.Git] = dep.Git
//}
//if dep.Library == "" && dep.Zip != "" {
// items[dep.Zip] = dep.Zip
//}
if dep.Library != "" && dep.Version != "" {
items[fmt.Sprintf("%s (%s)", dep.Library, dep.Version)] = dep.Library
}
}
selectedLib, err := util.Select("Select library to remove", []string{"Cancel"}, items)
if err != nil {
Expand Down
29 changes: 29 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
if ! command -v curl &> /dev/null
then
echo "'curl' could not be found, please install it!"
exit
fi

if ! command -v jq &> /dev/null
then
echo "'jq' could not be found, please install it!"
exit
fi

os=""
target=""
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os="linux"
target="/usr/local/bin/apm"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os="darwin"
target="/usr/local/bin/apm"
else
echo "Not supported OS!"
exit 1
fi
echo "Installing/Updating apm to ${target}..."
rm -rf ${target}
curl -L $(curl -s https://api.github.com/repos/ksrichard/apm/releases/latest | jq -r ".assets[] | select(.name | test(\"${os}_amd64\")) | .browser_download_url") --output ${target}
chmod +x ${target}
echo "apm is ready to use!"

0 comments on commit 05e7372

Please sign in to comment.