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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea63de6b8dc974f078ebfb115a23e601e6d9b532dba46aac1d35e8ad099fee79
4
- data.tar.gz: 4ae37db6d7f02c28790feb78d0e1202941c8b9f8e5be6a6bb019cbc43665cc04
3
+ metadata.gz: 1ce141fc8171c80a83672d2c96cb73bf22f3eb5980d1957ff81dbbca7a6b486a
4
+ data.tar.gz: 8031a92926449afe17a570ba170d44757b1a950e24112b3c5fcb96fa7058e256
5
5
  SHA512:
6
- metadata.gz: 73a5ec835865a020fb23edb0f28c83e43f83b8828efc621f041be0a4781c224d671b5145c5f991637089050ee0a21867107ee7dcd4205ce194a4436532743e68
7
- data.tar.gz: 5694d4e88cf8f841dc088e3828dea22393e926bffe2ce58dccf0da7fa16156932960577148bb4f0c63078c4fd5a34930b4c017a8c79cc59ee62b81589b72d425
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? $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
+
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
- $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,32 +41,40 @@ 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
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($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.7'.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.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 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