cmt 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea63de6b8dc974f078ebfb115a23e601e6d9b532dba46aac1d35e8ad099fee79
4
- data.tar.gz: 4ae37db6d7f02c28790feb78d0e1202941c8b9f8e5be6a6bb019cbc43665cc04
3
+ metadata.gz: 4df6c8d43f4b993e82bbf050c270c7d891e949f31f5c7e68ea2eeb4eb5703b8a
4
+ data.tar.gz: cebf41863388b9dc98cc4b6f60a1c3fc097e61c26d52b073f44be5e368ec1013
5
5
  SHA512:
6
- metadata.gz: 73a5ec835865a020fb23edb0f28c83e43f83b8828efc621f041be0a4781c224d671b5145c5f991637089050ee0a21867107ee7dcd4205ce194a4436532743e68
7
- data.tar.gz: 5694d4e88cf8f841dc088e3828dea22393e926bffe2ce58dccf0da7fa16156932960577148bb4f0c63078c4fd5a34930b4c017a8c79cc59ee62b81589b72d425
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? $CONFIG_DIR
18
+ if File.exist? Config::CONFIG_DIR
19
19
  if force
20
- FileUtils.rm_rf($CONFIG_DIR)
20
+ FileUtils.rm_rf(Config::CONFIG_DIR)
21
21
  else
22
- Log::LOGGER.error("Config already exists at '#{$CONFIG_DIR}'")
23
- abort("Config already exists at '#{$CONFIG_DIR}'")
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} #{$CONFIG_DIR}`
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
- $CONFIG_DIR = File.join(Dir.home, '.config', 'cmt')
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)
@@ -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($CONFIG_DIR) do
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 '#{$CONFIG_DIR}'")
17
- abort("No changes to commit in '#{$CONFIG_DIR}'")
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 '#{$CONFIG_DIR}'"
44
+ desc 'status', "Show git status in '#{Config::CONFIG_DIR}'"
28
45
  def status(*args)
29
- Dir.chdir($CONFIG_DIR) do
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 '#{$CONFIG_DIR}'"
51
+ desc 'pull', "Pull newest changes in '#{Config::CONFIG_DIR}'"
35
52
  def pull(*args)
36
- Dir.chdir($CONFIG_DIR) do
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 '#{$CONFIG_DIR}'"
58
+ desc 'exec', "Execute any git command in '#{Config::CONFIG_DIR}'"
42
59
  def exec(*args)
43
- Dir.chdir($CONFIG_DIR) do
60
+ Dir.chdir(Config::CONFIG_DIR) do
44
61
  system 'git', *args
45
62
  end
46
63
  end
47
64
 
48
- desc 'code', "Open '#{$CONFIG_DIR}' in code"
65
+ desc 'code', "Open '#{Config::CONFIG_DIR}' in code"
49
66
  def code(*args)
50
- Log::LOGGER.info("Open '#{$CONFIG_DIR}' in code")
51
- Dir.chdir($CONFIG_DIR) do
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($CONFIG_DIR, CONFIG_SUB_DIR).freeze
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
@@ -7,7 +7,6 @@ require_relative 'pkgm/pip'
7
7
  require_relative 'pkgm/snap'
8
8
  require_relative 'pkgm/winget'
9
9
  require_relative 'pkg_config'
10
-
11
10
  require_relative '../util/log'
12
11
 
13
12
  class Pkg < Thor
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  class PkgConfig
13
13
  CONFIG_SUB_DIR = 'pkg'.freeze
14
- ROOT_PATH = File.join($CONFIG_DIR, CONFIG_SUB_DIR).freeze
14
+ ROOT_PATH = File.join(Config::CONFIG_DIR, CONFIG_SUB_DIR).freeze
15
15
  DEFAULT_CONFIG = {
16
16
  ConfigOptions::PACKAGES => [],
17
17
  ConfigOptions::REMOTES => [],
@@ -1,4 +1,4 @@
1
- class FileUtil
1
+ module FileUtil
2
2
  USER_HOME = 'user-home'.freeze
3
3
 
4
4
  def self.to_local_file(file)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # module Cmt
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  # end
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.5
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 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor