cmt 0.0.5 → 0.0.6
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 +5 -5
- data/lib/config/config.rb +3 -2
- data/lib/config/git_config.rb +29 -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: 4df6c8d43f4b993e82bbf050c270c7d891e949f31f5c7e68ea2eeb4eb5703b8a
|
4
|
+
data.tar.gz: cebf41863388b9dc98cc4b6f60a1c3fc097e61c26d52b073f44be5e368ec1013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dafe415e6f6af6928593482ac77f41c6b3de7c4f8354e6492f0aee1bb6a1fd27d2f7fdad7c6c56dbcac45fff132646f1f6203207c130574102de574f4b111c12
|
7
|
+
data.tar.gz: 3630fcfeaba1c8f8d7a28478a185ffddcd059c4d75b4b155d669aa428d66efb278421716ab9f2bb15c523e803c7451346910a49b7e8fea0a6e66529b84665c96
|
data/lib/cmt.rb
CHANGED
@@ -15,16 +15,16 @@ 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
28
|
end
|
29
29
|
|
30
30
|
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,31 +41,31 @@ 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
|
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.6
|
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
|