arli 0.7.0 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +0 -2
  4. data/README.md +149 -48
  5. data/arli.gemspec +1 -3
  6. data/docs/arli-in-action.png +0 -0
  7. data/docs/arlifile.png +0 -0
  8. data/exe/arli +5 -1
  9. data/lib/arli.rb +2 -2
  10. data/lib/arli/actions.rb +6 -1
  11. data/lib/arli/actions/action.rb +57 -37
  12. data/lib/arli/actions/dir_name.rb +18 -16
  13. data/lib/arli/actions/git_repo.rb +8 -8
  14. data/lib/arli/actions/move_to_library_path.rb +54 -0
  15. data/lib/arli/actions/{zip_file.rb → unzip_file.rb} +14 -10
  16. data/lib/arli/arli_file.rb +52 -32
  17. data/lib/arli/cli/app.rb +11 -4
  18. data/lib/arli/cli/command_finder.rb +14 -11
  19. data/lib/arli/cli/parser.rb +70 -29
  20. data/lib/arli/cli/parser_factory.rb +105 -50
  21. data/lib/arli/cli/runner.rb +8 -4
  22. data/lib/arli/commands.rb +1 -0
  23. data/lib/arli/commands/base.rb +11 -6
  24. data/lib/arli/commands/bundle.rb +43 -0
  25. data/lib/arli/commands/install.rb +56 -13
  26. data/lib/arli/commands/search.rb +82 -27
  27. data/lib/arli/configuration.rb +37 -18
  28. data/lib/arli/errors.rb +6 -0
  29. data/lib/arli/library.rb +4 -46
  30. data/lib/arli/library/installer.rb +71 -0
  31. data/lib/arli/library/proxy.rb +79 -0
  32. data/lib/arli/lock/file.rb +65 -0
  33. data/lib/arli/lock/formats.rb +4 -0
  34. data/lib/arli/lock/formats/base.rb +26 -0
  35. data/lib/arli/lock/formats/cmake.rb +24 -0
  36. data/lib/arli/lock/formats/json.rb +25 -0
  37. data/lib/arli/lock/formats/text.rb +13 -0
  38. data/lib/arli/lock/formats/yaml.rb +14 -0
  39. data/lib/arli/output.rb +94 -11
  40. data/lib/arli/version.rb +1 -1
  41. metadata +17 -35
  42. data/docs/arli-full.png +0 -0
  43. data/lib/arli/installer.rb +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c24d0e256205e016bc76654f761283e2f7bf2b21
4
- data.tar.gz: 67cf5af188033eee75bdcdb430623464c36f40a4
3
+ metadata.gz: 4403d1e6ec0453ea707b6a1bca1cf89f47a8e848
4
+ data.tar.gz: 8387afcccd21d9c8cc62bd43140e70bbd34eced2
5
5
  SHA512:
6
- metadata.gz: 7d34e117d98f741237f0de0a15c1e0ebae3251d85a614c7e70179e123fe0c66ac8d72523fece8a9f0d9f189fdb67ea163e32efea1260390f68b675337ce663c6
7
- data.tar.gz: fddbd83b57fbbc4fe57147fd9209ea9ed9ebad1141c6a3327643b48b1292fdd454e162504e99da8448012e73bbcbac77b55a08ab58b6ec2962ec436a80be2fe7
6
+ metadata.gz: 448cc7c706ea9192bc13db514060d319ff7beac6bb749131aaab0a7deead3f3b036cf61cbad8b99a86eeb560d1b2018085cd7efc0c5617d83d0c75d21ee76068
7
+ data.tar.gz: b67cd69f59905e5136bb4bd4175e696d929a53563412c7293719b881758145e56a650f28a23419ba112abf4bb8d6cb40820f80fd85969dc03484b08c27d56a91
data/.gitignore CHANGED
@@ -15,3 +15,5 @@
15
15
  .ruby-version
16
16
  .rspec_status
17
17
  !/lib/arli/commands/install.rb
18
+ !/lib/arli/cli/parser.rb
19
+ /spec/fixtures/file*/Arlifile.lock*
data/Gemfile CHANGED
@@ -2,6 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
- gem 'arduino-library', git: 'https://github.com/kigster/arduino-library'
6
-
7
5
  gemspec
data/README.md CHANGED
@@ -11,10 +11,11 @@ Arli is an awesomely simple and very easy to use Arduino Library Installer. It a
11
11
 
12
12
  That way you can share projects with others and they will be able to automatically download and install the dependent libraries instead of having to do that manually. The project is inspired by [Bundler](http://bundler.io/).
13
13
 
14
- Here is a screenshot of running `arli install` inside a project with the `Arlifile` that defines all of it's library dependencies into a local project folder `./libraries`:
14
+ Here is a screenshot of running `arli bundle` inside a project with the `Arlifile` that defines all of the project's library dependencies. We install into a default libraries folder `~/Documents/Arduino/Libraries`:
15
15
 
16
16
  ![](docs/arli-in-action.png)
17
17
 
18
+ Note that `-f yaml` specifies the format of the "lock" file (`Arlifile.lock`), which is also copied to `Arlifile.lock.[format]`. So in this case our `Arlifile.lock` will be in YAML format, and will contain all library details obtained from the central database.
18
19
 
19
20
  ## Overview
20
21
 
@@ -24,22 +25,12 @@ In a nutshell, Arli relies on the publicly available database of the vast majori
24
25
 
25
26
  Sometimes, however, an Arduino library you use may not part of the main database. No problem! Just add the `url:` attribute together with the library name. The URL can either be a Github URL, or a URL to a downloadable ZIP file. Arli will figure out the rest.
26
27
 
27
- ### Arlifile
28
+ ### Arlifile and `bundle`
28
29
 
29
30
  `Arlifile` is a YAML-formatted file that looks like this below. We list all dependencies using the library names that are provided in the database (you can search for the libraries you need prior to populating this file):
30
31
 
31
32
 
32
- ```yaml
33
- # vi:syntax=yaml
34
- # File: Arlifile
35
- version: 1.0.0
36
- dependencies:
37
- - name: Time
38
- - name: "Adafruit GFX Library"
39
- version: '1.2.1'
40
- - name: SimpleTimer
41
- url: https://github.com/jfturcot/SimpleTimer
42
- ```
33
+ ![](docs/arlifile.png)
43
34
 
44
35
  The libraries may be specified with a name and url only, in which case no search is performed, and the provided URL is used to install the library. The library `SimpleTimer` above is not in the main database, therefore we provide URL for Arli to use.
45
36
 
@@ -53,12 +44,36 @@ You can provide the following fields in the Arilfile if you want the library to
53
44
 
54
45
  In all of the above cases, Arli will search the standard library database provided by the [Arduino official library database](http://downloads.arduino.cc/libraries/library_index.json.gz) JSON file.
55
46
 
56
- ### Single Library Install
47
+ #### Lock File `Arlifile.lock`
48
+
49
+ The lock file is created every time `arli bundle` runs, and it's always in the same folder that the `Arlifile` itself.
50
+
51
+ The purpose of this file is to document the resolved libraries installed. There are four formats that are supported:
52
+
53
+ * text
54
+ * json
55
+ * yaml
56
+ * cmake
57
+
58
+ Each format is sligthly different: YAML and JSON will simply include full library info, while text format includes resolved folder names, versions, and the download URL.
57
59
 
58
- You can also install just a single library by passing `--name` flag (`-n`), for example:
60
+ #### CMake Integration
61
+
62
+ The CMake lock file is meant to be consumed by projects relying on the [arduino-cmake](https://github.com/arduino-cmake/arduino-cmake). We are still working on the complete integration, which would hopefully allow the following features:
63
+
64
+ * auto-generate Arduino project with library dependencies using cmake
65
+ * provide CMake plugin that runs `arli bundle -f cmake`, and reads the `Arlifile.lock.cmake`
66
+ * this will auto-generate each Arduino library into it's own static library, and then link your project with them all.
67
+
68
+ **CMake Coming Soon!**
69
+
70
+
71
+ ### Single Library and `install`
72
+
73
+ You can also install just a single library by using the `install` command, instead of the `bundle`. Install accepts either a `--lib-name` flag (`-n`), or a url `-u`, `--lib-url`, for example:
59
74
 
60
75
  ```bash
61
- arli install --name 'Adafruit GFX Library'
76
+ arli install --lib-name 'Adafruit GFX Library'
62
77
  ```
63
78
 
64
79
  ## Gem Installation
@@ -77,8 +92,10 @@ Run `arli --help` for more information:
77
92
 
78
93
  ```bash
79
94
  Usage:
80
- arli [ options ] [ command [ options ] ]
95
+ arli options
96
+ arli command [ options ]
81
97
 
98
+ -C, --no-color Disable any color output.
82
99
  -D, --debug Print debugging info.
83
100
  -t, --trace Print exception stack traces.
84
101
  -v, --verbose Print more information.
@@ -87,17 +104,18 @@ Usage:
87
104
  -h, --help prints this help
88
105
 
89
106
  Available Commands:
90
- install installs libraries defined in Arlifile or by -n flag
91
- searchFlexible Search of the Arduino Library Database
107
+ search Search standard Arduino Library Database with over 4K entries
108
+ bundleInstalls all libraries specified in Arlifile
109
+ install — Installs a single library either by searching, or url or local ZIP
92
110
 
93
111
  See arli command --help for more information on a specific command.
94
112
 
95
- arli (0.6.1) © 2017 Konstantin Gredeskoul, MIT License.
113
+ arli (0.8.2) © 2017 Konstantin Gredeskoul, MIT License.
96
114
  ```
97
115
 
98
- ### Command `install`
116
+ ### Command `bundle`
99
117
 
100
- Use this command to install or re-install Arduino libraries.
118
+ Use this command to install Arduino libraries.
101
119
 
102
120
  You can specify libraries in the `Arlifile` by providing just the `name:` (and posibly `version`) — the name must match exactly a library in the Arduino standard database. Alternatively, your can pass fields `archiveFileName`, `checksum` — which all uniquely identify a library in the database.
103
121
 
@@ -115,7 +133,7 @@ When Arli downloads libraries in ZIP format, they are unpacked into folder that
115
133
 
116
134
  #### An Example
117
135
 
118
- Here is the `arli install` command inside CMake-based project to build a [Wall Clock using Arduino](https://github.com/kigster/wallclock-arduino). This project has the following `Arlifile`:
136
+ Here is the `arli bundle` command inside CMake-based project to build a [Wall Clock using Arduino](https://github.com/kigster/wallclock-arduino). This project has the following `Arlifile`:
119
137
 
120
138
  ```yaml
121
139
  # vi:syntax=yaml
@@ -135,35 +153,42 @@ dependencies:
135
153
 
136
154
  You can see that most libraries are specified by name, except one (SimpleTimer) is specified together with the URL, which will be used to `git clone` the library.
137
155
 
138
- So let's specify where our libraries live, and run `arli install` inside that project. Below is a screenshot of running `arli` inside of the Wall Clock Arduino project:
139
-
140
- ![](docs/arli-in-action.png)
156
+ So let's specify where our libraries live, and run `arli bundle` inside that project. Below is a screenshot of running `arli` inside of the Wall Clock Arduino project:
141
157
 
142
158
 
143
- Below is the complete help for the install command for reference:
159
+ Below is the complete help for the `bundle` command for reference:
144
160
 
145
161
 
146
162
  ```bash
163
+ ❯ arli bundle -h
147
164
  Description:
148
- installs libraries defined in Arlifile or by -n flag
165
+ Installs all libraries specified in Arlifile
149
166
 
150
- Usage:
151
- arli install [options]
167
+ This command reads Arlifile (from the current folder, by default),
168
+ and then it installs all dependent libraries specified there, checking if
169
+ each already exists, and if not — downloading them, and installing them into
170
+ your Arduino Library folder. Both the folder with the Arlifile, as well as the
171
+ destination library path folder can be changed with the command line flags.
152
172
 
153
- Command Options
154
- -n, --name NAME If provided a library name is searched and, if found
155
- installed. In this mode Arlifile not used.
173
+ Usage:
174
+ arli bundle [options]
156
175
 
157
- -l, --libraries PATH Local folder where custom Arduino libraries are installed
158
- Defaults to ~/Dropbox/Workspace/oss/arduino/libraries
176
+ Options
177
+ -l, --lib-path PATH Destination: typically your Arduino libraries folder
178
+ Defaults to ~/Documents/Arduino/Libraries
159
179
 
160
- -a, --arli-path PATH Folder where Arlifile is located,
180
+ -a, --arli-path PATH An alternate folder with the Arlifile file.
161
181
  Defaults to the current directory.
162
182
 
183
+ -f, --format FMT Arli writes an Arlifile.lock with resolved info.
184
+ The default format is text. Use -f to set it
185
+ to one of: cmake, text, json, yaml
186
+
163
187
  -e, --if-exists ACTION If a library folder already exists, by default
164
188
  it will be overwritten or updated if possible.
165
189
  Alternatively you can either abort or backup
166
190
 
191
+ -C, --no-color Disable any color output.
167
192
  -D, --debug Print debugging info.
168
193
  -t, --trace Print exception stack traces.
169
194
  -v, --verbose Print more information.
@@ -172,11 +197,65 @@ Command Options
172
197
  -h, --help prints this help
173
198
 
174
199
  Examples:
175
- # Install all libs defined in the ./Arlifile file
176
- arli install
200
+ # Install all libs defined in Arlifile:
201
+ arli bundle
177
202
 
178
- # Install a single library matched by the --name flag
179
- arli install -n "Adafruit GFX Library"```
203
+ # Custom Arlifile location, and destination path:
204
+ arli bundle -a ./src -l ./libraries
205
+ ```
206
+
207
+ ### Command `install`
208
+
209
+ Use this command to install a single library by either a name or URL:
210
+
211
+ Eg:
212
+
213
+ ```bash
214
+ ❯ be exe/arli install -n 'Adafruit GFX Library' -l ./libs
215
+ ❯ be exe/arli install -u 'https://github.com/jfturcot/SimpleTimer' -l ./libs
216
+ ```
217
+
218
+ Complete help is:
219
+
220
+
221
+ ```bash
222
+ ❯ arli install -h
223
+ Description:
224
+ Installs a single library either by searching, or url or local ZIP
225
+
226
+ This command installs a single library into your library path
227
+ using the third argument to the command arli install
228
+ which can be a library name, local ZIP file, or a remote URL
229
+ (either ZIP or Git Repo)
230
+
231
+ Usage:
232
+ arli install [ "library name" | url | local-zip ] [options]
233
+
234
+ Options
235
+ -l, --lib-path PATH Destination: typically your Arduino libraries folder
236
+ Defaults to ~/Documents/Arduino/Libraries
237
+
238
+ -e, --if-exists ACTION If a library folder already exists, by default
239
+ it will be overwritten or updated if possible.
240
+ Alternatively you can either abort or backup
241
+
242
+ -C, --no-color Disable any color output.
243
+ -D, --debug Print debugging info.
244
+ -t, --trace Print exception stack traces.
245
+ -v, --verbose Print more information.
246
+ -q, --quiet Print less information.
247
+ -V, --version Print current version and exit
248
+ -h, --help prints this help
249
+
250
+ Examples:
251
+ # Install the latest version of this library
252
+ arli install "Adafruit GFX Library"
253
+
254
+ # Install the library from a Github URL
255
+ arli install https://github.com/jfturcot/SimpleTimer
256
+
257
+ # Install a local ZIP file
258
+ arli install ~/Downloads/DHT-Library.zip
180
259
  ```
181
260
 
182
261
  ### Command `search`
@@ -224,25 +303,47 @@ A detailed description of the complete search functionality is documented in the
224
303
  Below is the help screen for the search command:
225
304
 
226
305
  ```bash
306
+ ❯ arli search -h
227
307
  Description:
228
- Flexible Search of the Arduino Library Database
308
+ Search standard Arduino Library Database with over 4K entries
309
+
310
+ This command provides both the simple name-based search interface,
311
+ and the most sophisticated field-by-field search using a downloaded,
312
+ and locally cached Public Arduino Database JSON file, maintained
313
+ by Arduino and the Community. If you know of another database,
314
+ that's what the --database flag is for.
229
315
 
230
316
  Usage:
231
- arli search [ name-match | expression ] [options]
317
+ arli search [ name | search-expression ] [options]
232
318
 
233
- Command Options
234
- -d FILE/URL, a JSON file name, or a URL that contains the index
235
- --database Defaults to the Arduino-maintained list
319
+ Options
320
+ -d, --database URL a JSON(.gz) file path or a URL of the library database.
321
+ Defaults to the Arduino-maintained database.
236
322
  -m, --max NUMBER if provided, limits the result set to this number
237
- Defaults to 100
323
+ Set to 0 to disable. Default is 100.
324
+ -C, --no-color Disable any color output.
238
325
  -D, --debug Print debugging info.
239
326
  -t, --trace Print exception stack traces.
240
327
  -v, --verbose Print more information.
328
+ -q, --quiet Print less information.
241
329
  -V, --version Print current version and exit
242
330
  -h, --help prints this help
243
331
 
244
- Example:
245
- arli search 'name: /AudioZero/, version: "1.0.1"'
332
+ Examples:
333
+ # Search using the regular expression containing the name:
334
+ arli search AudioZero
335
+
336
+ # Same exact search as above, but using ruby hash syntax:
337
+ arli search 'name: /AudioZero/'
338
+
339
+ # Lets get a particular version of the library
340
+ arli search 'name: "AudioZero", version: "1.0,2"'
341
+
342
+ # Search using case insensitive name search, and :
343
+ arli search 'name: /adafruit/i'
344
+
345
+ # Finally, search for the exact name match:
346
+ arli search '^Time$'
246
347
  ```
247
348
 
248
349
 
@@ -28,14 +28,12 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ['lib']
30
30
 
31
- spec.add_dependency 'arduino-library', '~> 0.5.1'
31
+ spec.add_dependency 'arduino-library', '~> 0.5.4'
32
32
  spec.add_dependency 'colored2'
33
33
  spec.add_dependency 'hashie'
34
34
  spec.add_dependency 'dry-types'
35
35
  spec.add_dependency 'dry-struct'
36
36
  spec.add_dependency 'dry-configurable'
37
- spec.add_dependency 'awesome_print'
38
- spec.add_dependency 'archive-zip'
39
37
  spec.add_dependency 'tty-cursor'
40
38
 
41
39
 
Binary file
Binary file
data/exe/arli CHANGED
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'arli/cli/runner'
3
+ require 'colored2'
4
+ if %w(-C -Ch -hC --no-color).any? { |f| ARGV.include?(f) }
5
+ Colored2.disable!
6
+ end
4
7
 
8
+ require 'arli/cli/runner'
5
9
  Arli::CLI::Runner.new(ARGV.dup).execute!
6
10
 
@@ -26,10 +26,10 @@ module Arli
26
26
  end
27
27
 
28
28
  def default_library_path
29
- dehomify_path(self.config.libraries.path)
29
+ tilda_path(self.config.libraries.path)
30
30
  end
31
31
 
32
- def dehomify_path(absolute_path)
32
+ def tilda_path(absolute_path)
33
33
  absolute_path.gsub(%r(#{ENV['HOME']}), '~')
34
34
  end
35
35
  end
@@ -6,6 +6,10 @@ module Arli
6
6
  def action(name)
7
7
  self.actions[name]
8
8
  end
9
+
10
+ def action_name(klass)
11
+ self.actions.invert[klass]
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -13,6 +17,7 @@ end
13
17
  Arli::Actions.actions = {}
14
18
 
15
19
  require_relative 'actions/action'
16
- require_relative 'actions/zip_file'
20
+ require_relative 'actions/unzip_file'
17
21
  require_relative 'actions/git_repo'
18
22
  require_relative 'actions/dir_name'
23
+ require_relative 'actions/move_to_library_path'
@@ -7,12 +7,45 @@ module Arli
7
7
  include Arli::Output
8
8
 
9
9
  extend Forwardable
10
- def_delegators :@library, :exists?, :path, :dir, :libraries_home
10
+ def_delegators :@library,
11
+ :exists?,
12
+ :path, :temp_path,
13
+ :dir, :temp_dir,
14
+ :libraries_home
11
15
 
12
16
  class << self
13
- def inherited(klazz)
14
- action_name = klazz.name.gsub(/.*::/, '').underscore.to_sym
15
- ::Arli::Actions.actions[action_name] = klazz
17
+ def inherited(base)
18
+
19
+ base.instance_eval do
20
+ class << self
21
+ attr_writer :check_command, :check_pattern, :description
22
+
23
+ def action_name
24
+ name.gsub(/.*::/, '').underscore.to_sym
25
+ end
26
+
27
+ def set_or_get(var_name, val = nil)
28
+ var = "@#{var_name}".to_sym
29
+ self.instance_variable_set(var, val) if val
30
+ self.instance_variable_get(var)
31
+ end
32
+
33
+ def check_pattern(val = nil)
34
+ set_or_get('check_pattern', val)
35
+ end
36
+
37
+ def check_command(val = nil)
38
+ set_or_get('check_command', val)
39
+ end
40
+
41
+ def description(val = nil)
42
+ set_or_get('description', val)
43
+ end
44
+ end
45
+ end
46
+
47
+ # Add to the list of actions
48
+ ::Arli::Actions.actions[base.action_name] = base
16
49
  end
17
50
  end
18
51
 
@@ -23,50 +56,37 @@ module Arli
23
56
  self.config = config
24
57
  end
25
58
 
26
- def act(**_opts)
27
- raise 'Abstract method #act called on Action'
28
- end
29
-
30
- def overwrite?
31
- config.install.if_exists.overwrite
59
+ def run!
60
+ execute
61
+ rescue Exception => e
62
+ action_fail(self, e)
32
63
  end
33
64
 
34
- def backup?
35
- config.install.if_exists.backup
36
- end
37
-
38
- def abort?
39
- config.install.if_exists.abort
65
+ def supported?
66
+ return @supported if defined?(@supported)
67
+ if self.class.check_command && self.class.check_pattern
68
+ @supported = (`#{self.class.check_command} 2>/dev/null | grep "#{self.class.check_pattern}"`.chomp != '')
69
+ else
70
+ @supported = true
71
+ end
40
72
  end
41
73
 
42
74
  def mv(from, to)
43
- handle_preexisting_folder(to)
44
75
  FileUtils.mv(from, to)
45
76
  end
46
77
 
47
- def handle_preexisting_folder(to)
48
- if Dir.exist?(to)
49
- if abort?
50
- raise ::Arli::Errors::LibraryAlreadyExists, "Directory #{to} already exists"
51
- elsif backup?
52
- backup!(to)
53
- elsif overwrite?
54
- FileUtils.rm_rf(to)
55
- end
56
- end
78
+ def to_s
79
+ "<Action:#{(Arli::Actions.action_name(self) || 'unknown action').bold.blue}: lib=#{library.name}>"
57
80
  end
58
81
 
59
- def backup!(p)
60
- if Dir.exist?(p)
61
- backup_path = "#{p}.arli-backup-#{Time.now.strftime('%Y%m%d%H%M%S')}"
62
- FileUtils.mv(p, backup_path)
63
- if config.verbose
64
- ___ "\nNOTE: path #{p.blue} has been backed up to #{backup_path.bold.green}\n"
65
- elsif !config.quiet
66
- ___ ' backed up and'
67
- end
68
- end
82
+ protected
83
+
84
+ def execute(**_opts)
85
+ raise Arli::Errors::AbstractMethodCalled,
86
+ 'Abstract method #execute called on Base'
69
87
  end
88
+
89
+
70
90
  end
71
91
  end
72
92
  end