vimpk 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.overcommit.yml +35 -0
- data/lib/vimpk/cli.rb +18 -7
- data/lib/vimpk/colorizer.rb +2 -0
- data/lib/vimpk/move.rb +41 -0
- data/lib/vimpk/options.rb +1 -0
- data/lib/vimpk/remove.rb +2 -2
- data/lib/vimpk/version.rb +1 -1
- data/lib/vimpk.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4859149e17e0bc00e3a7230deeeecc6304eab4ed9acd2671509ea3d4ac016ae
|
4
|
+
data.tar.gz: ed44805797dbaa69cdf31c2767fdf928691169c9606df2ab610b412ea84adc20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7de3bfbf7b2fd882f2f9b8c0fc10b4cd8ad11bfff0b480a8b5fefc14bee11c10c393a521075bfe61de130ad3eb221fe573d2d11e1880121ce995b8374ed49c0
|
7
|
+
data.tar.gz: 3824e72fcc014941d33d1b139143185e752166a794809c7917c5824138db94c55b2caec2c896f88150c76c63d44f4d69c10ea66dbcd5c79fd151b3df5efeffe3
|
data/.overcommit.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
gemfile: Gemfile
|
3
|
+
|
4
|
+
PreCommit:
|
5
|
+
TrailingWhitespace:
|
6
|
+
enabled: true
|
7
|
+
YamlSyntax:
|
8
|
+
enabled: true
|
9
|
+
|
10
|
+
CommitMsg:
|
11
|
+
CapitalizedSubject:
|
12
|
+
enabled: false
|
13
|
+
EmptyMessage:
|
14
|
+
enabled: true
|
15
|
+
MessageFormat:
|
16
|
+
enabled: true
|
17
|
+
pattern: "^(feat|fix|docs|style|refactor|perf|test|chore|revert)?: [A-Z].*"
|
18
|
+
sample_message: "feat: Add new feature"
|
19
|
+
TrailingPeriod:
|
20
|
+
enabled: true
|
21
|
+
SpellCheck:
|
22
|
+
enabled: true
|
23
|
+
|
24
|
+
PostCheckout:
|
25
|
+
ALL:
|
26
|
+
quiet: true
|
27
|
+
BundleInstall:
|
28
|
+
enabled: true
|
29
|
+
quiet: true
|
30
|
+
|
31
|
+
PrePush:
|
32
|
+
ALL:
|
33
|
+
quiet: true
|
34
|
+
Minitest:
|
35
|
+
enabled: true
|
data/lib/vimpk/cli.rb
CHANGED
@@ -12,8 +12,8 @@ module VimPK
|
|
12
12
|
@options = @parser.parse
|
13
13
|
@command = determine_command
|
14
14
|
rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
|
15
|
-
|
16
|
-
abort
|
15
|
+
warn e.message
|
16
|
+
abort "Use --help for usage information"
|
17
17
|
end
|
18
18
|
|
19
19
|
def call
|
@@ -31,12 +31,15 @@ module VimPK
|
|
31
31
|
case name
|
32
32
|
when "i", "install"
|
33
33
|
:install_command
|
34
|
+
when "mv", "move"
|
35
|
+
:move_command
|
34
36
|
when "u", "update"
|
35
37
|
:update_command
|
36
38
|
when "rm", "remove"
|
37
39
|
:remove_command
|
38
40
|
else
|
39
|
-
|
41
|
+
warn colorize("Unknown command: #{name}", color: :red)
|
42
|
+
abort "Use --help for usage information"
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -47,12 +50,20 @@ module VimPK
|
|
47
50
|
install.call
|
48
51
|
puts colorize("Installed #{package} to #{install.dest}. Took #{Time.now - time} seconds.", color: :green)
|
49
52
|
rescue Git::GitError => e
|
50
|
-
|
53
|
+
warn colorize("Error: #{e.message}", color: :red)
|
51
54
|
abort e.output.lines.map { |line| " #{line}" }.join
|
52
55
|
rescue Install::PackageExistsError => e
|
53
|
-
|
56
|
+
warn colorize("Error: #{e.message}", color: :red)
|
54
57
|
rescue ArgumentError => e
|
55
|
-
|
58
|
+
warn colorize("Error: #{e.message}", color: :red)
|
59
|
+
end
|
60
|
+
|
61
|
+
def move_command(name = nil)
|
62
|
+
move = Move.new(name, @options[:path], @options[:pack], @options[:type])
|
63
|
+
move.call
|
64
|
+
puts colorize("Moved #{name} to #{move.dest}.", color: :green)
|
65
|
+
rescue Move::PackageNotFoundError, Move::MultiplePackagesFoundError, ArgumentError => e
|
66
|
+
abort colorize(e.message, color: :red)
|
56
67
|
end
|
57
68
|
|
58
69
|
def update_command
|
@@ -106,7 +117,7 @@ module VimPK
|
|
106
117
|
Remove.new(name, @options[:path]).call
|
107
118
|
|
108
119
|
puts colorize("Package #{name} removed.", color: :green)
|
109
|
-
rescue ArgumentError, VimPK::Remove::
|
120
|
+
rescue ArgumentError, VimPK::Remove::PackageNotFoundError => e
|
110
121
|
abort colorize(e.message, color: :red)
|
111
122
|
end
|
112
123
|
end
|
data/lib/vimpk/colorizer.rb
CHANGED
@@ -3,6 +3,7 @@ module VimPK
|
|
3
3
|
private
|
4
4
|
|
5
5
|
def colorize_diff(line)
|
6
|
+
return line if ENV["NO_COLOR"]
|
6
7
|
case line
|
7
8
|
when /^diff --git/
|
8
9
|
"\e[1;34m#{line}\e[0m"
|
@@ -24,6 +25,7 @@ module VimPK
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def colorize(text, color: :green)
|
28
|
+
return text if ENV["NO_COLOR"]
|
27
29
|
case color
|
28
30
|
when :green
|
29
31
|
"\e[32m#{text}\e[0m"
|
data/lib/vimpk/move.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module VimPK
|
4
|
+
class Move
|
5
|
+
PackageNotFoundError = Class.new(StandardError)
|
6
|
+
MultiplePackagesFoundError = Class.new(StandardError)
|
7
|
+
|
8
|
+
attr_reader :dest
|
9
|
+
|
10
|
+
def initialize(name, path, pack = nil, type = nil)
|
11
|
+
@name = name || raise(ArgumentError, "Package name is required")
|
12
|
+
raise ArgumentError, "New pack or type is required" unless pack || type
|
13
|
+
@path = path
|
14
|
+
@pack = pack
|
15
|
+
@type = type
|
16
|
+
end
|
17
|
+
|
18
|
+
def call
|
19
|
+
glob = Dir.glob(File.join(@path, "*", "{start,opt}", @name))
|
20
|
+
|
21
|
+
if glob.empty?
|
22
|
+
raise PackageNotFoundError, "Package #{@name} not found in #{@path}."
|
23
|
+
elsif glob.size > 1
|
24
|
+
raise MultiplePackagesFoundError, "Multiple packages #{@name} found in #{glob.join(" and ")}."
|
25
|
+
else
|
26
|
+
source = glob.first
|
27
|
+
current_type = File.basename(File.dirname(source))
|
28
|
+
current_pack = File.basename(File.dirname(File.dirname(source)))
|
29
|
+
@dest = File.join(@path, @pack || current_pack, @type || current_type, @name)
|
30
|
+
|
31
|
+
if File.exist?(dest)
|
32
|
+
raise ArgumentError, "Package #{@name} already exists in #{dest}."
|
33
|
+
else
|
34
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
35
|
+
end
|
36
|
+
|
37
|
+
FileUtils.mv(source, dest)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/vimpk/options.rb
CHANGED
@@ -54,6 +54,7 @@ module VimPK
|
|
54
54
|
parser.separator ""
|
55
55
|
parser.separator "Commands:"
|
56
56
|
parser.separator " i|install REPO/NAME [--opt|--start] [--pack=PATH] [--path=PATH] Install a package"
|
57
|
+
parser.separator " mv|move Move a package"
|
57
58
|
parser.separator " u|update Update all packages"
|
58
59
|
parser.separator " rm|remove NAME Remove all occurrences of a package"
|
59
60
|
end
|
data/lib/vimpk/remove.rb
CHANGED
@@ -2,7 +2,7 @@ require "fileutils"
|
|
2
2
|
|
3
3
|
module VimPK
|
4
4
|
class Remove
|
5
|
-
|
5
|
+
PackageNotFoundError = Class.new(StandardError)
|
6
6
|
|
7
7
|
def initialize(name, path)
|
8
8
|
@name = name || raise(ArgumentError, "Package name is required")
|
@@ -13,7 +13,7 @@ module VimPK
|
|
13
13
|
glob = Dir.glob(File.join(@path, "*", "{start,opt}", @name))
|
14
14
|
|
15
15
|
if glob.empty?
|
16
|
-
raise
|
16
|
+
raise PackageNotFoundError, "Package #{@name} not found in #{@path}."
|
17
17
|
else
|
18
18
|
glob.each do |dir|
|
19
19
|
FileUtils.rm_rf(dir)
|
data/lib/vimpk/version.rb
CHANGED
data/lib/vimpk.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimpk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Usewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -18,6 +18,7 @@ executables:
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- ".overcommit.yml"
|
21
22
|
- LICENSE.txt
|
22
23
|
- exe/vimpk
|
23
24
|
- lib/vimpk.rb
|
@@ -26,6 +27,7 @@ files:
|
|
26
27
|
- lib/vimpk/git.rb
|
27
28
|
- lib/vimpk/install.rb
|
28
29
|
- lib/vimpk/job.rb
|
30
|
+
- lib/vimpk/move.rb
|
29
31
|
- lib/vimpk/options.rb
|
30
32
|
- lib/vimpk/remove.rb
|
31
33
|
- lib/vimpk/thread_pool.rb
|