cmt 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cmt.rb +12 -5
- data/lib/config/config.rb +3 -2
- data/lib/config/git_config.rb +37 -12
- data/lib/env/env.rb +1 -1
- data/lib/pkg/pkg.rb +0 -1
- data/lib/pkg/pkg_config.rb +1 -1
- data/lib/util/file_util.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ce141fc8171c80a83672d2c96cb73bf22f3eb5980d1957ff81dbbca7a6b486a
|
4
|
+
data.tar.gz: 8031a92926449afe17a570ba170d44757b1a950e24112b3c5fcb96fa7058e256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963846c837e44c903c0b8c17b9ed3523ed75cb1e6befe9df68d4a90f463dee474bddbf4365a76d675250e7b85c6232748439978f49ad5b0effa9c901976d7ce6
|
7
|
+
data.tar.gz: bcd52e54cefdf979ea08fa0fcc5531d576a9f2d4a9930aa21d7ed431e2adaa8610cbdbc8c88a0c604878926970d9948f0a39ec8ad56df53d628fc357303d327a
|
data/lib/cmt.rb
CHANGED
@@ -15,16 +15,23 @@ class Cmt < Pkg
|
|
15
15
|
def init(repo)
|
16
16
|
force = options['force']
|
17
17
|
|
18
|
-
if File.exist?
|
18
|
+
if File.exist? Config::CONFIG_DIR
|
19
19
|
if force
|
20
|
-
FileUtils.rm_rf(
|
20
|
+
FileUtils.rm_rf(Config::CONFIG_DIR)
|
21
21
|
else
|
22
|
-
Log::LOGGER.error("Config already exists at '#{
|
23
|
-
abort("Config already exists at '#{
|
22
|
+
Log::LOGGER.error("Config already exists at '#{Config::CONFIG_DIR}'")
|
23
|
+
abort("Config already exists at '#{Config::CONFIG_DIR}'")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
`git clone #{repo} #{
|
27
|
+
`git clone #{repo} #{Config::CONFIG_DIR}`
|
28
|
+
|
29
|
+
return if Gem.win_platform?
|
30
|
+
|
31
|
+
hostname = `hostname`
|
32
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
33
|
+
`git checkout -b #{hostname}`
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
desc 'config SUBCOMMAND ...ARGS', 'manage set of tracked repositories'
|
data/lib/config/config.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'json'
|
3
4
|
|
4
|
-
|
5
|
+
module Config
|
6
|
+
CONFIG_DIR = File.join(Dir.home, '.config', 'cmt').freeze
|
5
7
|
|
6
|
-
class Config
|
7
8
|
def self.get_config_json(file, default_config)
|
8
9
|
FileUtils.mkdir_p File.dirname(file)
|
9
10
|
File.write(file, JSON.pretty_generate(default_config, { indent: ' ' })) unless File.exist?(file)
|
data/lib/config/git_config.rb
CHANGED
@@ -4,17 +4,34 @@ require_relative 'config'
|
|
4
4
|
require_relative '../util/log'
|
5
5
|
|
6
6
|
class GitConfig < Thor
|
7
|
+
desc 'init', 'Init'
|
8
|
+
option :force, type: :boolean, default: false
|
9
|
+
def init(repo)
|
10
|
+
force = options['force']
|
11
|
+
|
12
|
+
if File.exist? Config::CONFIG_DIR
|
13
|
+
if force
|
14
|
+
FileUtils.rm_rf(Config::CONFIG_DIR)
|
15
|
+
else
|
16
|
+
Log::LOGGER.error("Config already exists at '#{Config::CONFIG_DIR}'")
|
17
|
+
abort("Config already exists at '#{Config::CONFIG_DIR}'")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
`git clone #{repo} #{Config::CONFIG_DIR}`
|
22
|
+
end
|
23
|
+
|
7
24
|
desc 'update', 'update'
|
8
25
|
option :message, default: 'Update config'
|
9
26
|
def update
|
10
27
|
message = options['message']
|
11
|
-
Dir.chdir(
|
28
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
12
29
|
changes = `git status --porcelain=v1`
|
13
30
|
num_changes = changes.split.length
|
14
31
|
|
15
32
|
if num_changes.zero?
|
16
|
-
Log::LOGGER.error("No changes to commit in '#{
|
17
|
-
abort("No changes to commit in '#{
|
33
|
+
Log::LOGGER.error("No changes to commit in '#{Config::CONFIG_DIR}'")
|
34
|
+
abort("No changes to commit in '#{Config::CONFIG_DIR}'")
|
18
35
|
else
|
19
36
|
Log::LOGGER.info('Commit changes')
|
20
37
|
system 'git', 'add', '.'
|
@@ -24,32 +41,40 @@ class GitConfig < Thor
|
|
24
41
|
end
|
25
42
|
end
|
26
43
|
|
27
|
-
desc 'status', "Show git status in '#{
|
44
|
+
desc 'status', "Show git status in '#{Config::CONFIG_DIR}'"
|
28
45
|
def status(*args)
|
29
|
-
Dir.chdir(
|
46
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
30
47
|
system 'git', 'status', *args
|
31
48
|
end
|
32
49
|
end
|
33
50
|
|
34
|
-
desc 'pull', "Pull newest changes in '#{
|
51
|
+
desc 'pull', "Pull newest changes in '#{Config::CONFIG_DIR}'"
|
35
52
|
def pull(*args)
|
36
|
-
Dir.chdir(
|
53
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
37
54
|
system 'git', 'pull', *args
|
38
55
|
end
|
39
56
|
end
|
40
57
|
|
41
|
-
desc 'exec', "Execute any git command in '#{
|
58
|
+
desc 'exec', "Execute any git command in '#{Config::CONFIG_DIR}'"
|
42
59
|
def exec(*args)
|
43
|
-
Dir.chdir(
|
60
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
44
61
|
system 'git', *args
|
45
62
|
end
|
46
63
|
end
|
47
64
|
|
48
|
-
desc 'code', "Open '#{
|
65
|
+
desc 'code', "Open '#{Config::CONFIG_DIR}' in code"
|
49
66
|
def code(*args)
|
50
|
-
Log::LOGGER.info("Open '#{
|
51
|
-
Dir.chdir(
|
67
|
+
Log::LOGGER.info("Open '#{Config::CONFIG_DIR}' in code")
|
68
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
52
69
|
system 'code', '.', *args
|
53
70
|
end
|
54
71
|
end
|
72
|
+
|
73
|
+
desc 'nvim', "Open '#{Config::CONFIG_DIR}' in nvim"
|
74
|
+
def nvim(*args)
|
75
|
+
Log::LOGGER.info("Open '#{Config::CONFIG_DIR}' in nvim")
|
76
|
+
Dir.chdir(Config::CONFIG_DIR) do
|
77
|
+
system 'nvim', '.', *args
|
78
|
+
end
|
79
|
+
end
|
55
80
|
end
|
data/lib/env/env.rb
CHANGED
@@ -10,7 +10,7 @@ require_relative '../util/log'
|
|
10
10
|
|
11
11
|
class Env
|
12
12
|
CONFIG_SUB_DIR = 'env'.freeze
|
13
|
-
ROOT_PATH = File.join(
|
13
|
+
ROOT_PATH = File.join(Config::CONFIG_DIR, CONFIG_SUB_DIR).freeze
|
14
14
|
CONFIG_FILE = File.join(ROOT_PATH, 'env.json').freeze
|
15
15
|
FILES_PATH = File.join(ROOT_PATH, 'files').freeze
|
16
16
|
FOLDERS_PATH = File.join(ROOT_PATH, 'folders').freeze
|
data/lib/pkg/pkg.rb
CHANGED
data/lib/pkg/pkg_config.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
class PkgConfig
|
13
13
|
CONFIG_SUB_DIR = 'pkg'.freeze
|
14
|
-
ROOT_PATH = File.join(
|
14
|
+
ROOT_PATH = File.join(Config::CONFIG_DIR, CONFIG_SUB_DIR).freeze
|
15
15
|
DEFAULT_CONFIG = {
|
16
16
|
ConfigOptions::PACKAGES => [],
|
17
17
|
ConfigOptions::REMOTES => [],
|
data/lib/util/file_util.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- simon.schuster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|