dotsync 0.1.0 → 0.1.1

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: 77b4b56e47651cc2c8ab828bb4c77db6d1e8e5e58fb36df1e00f2a2a30ded2e3
4
- data.tar.gz: f0c445bb9a6436a3e0058e589fe0373015a41e1013109272b06b0d948bd1dc6c
3
+ metadata.gz: 7656490334da78bcf97bcadae816a7adb7993c0e39a6925c642ef3f0c79e39ad
4
+ data.tar.gz: '006061689d4068a5e73d7cbce3b36b8443090a8799095935b691dc3a7cdbcaca'
5
5
  SHA512:
6
- metadata.gz: 73551d747d9687c969df56906d18354c133d1f947066fd3a2de3404512152a6f8fe07a6a0404556389da9702777615e4cf1b75b231f1cc3b14d84e6cceef5acd
7
- data.tar.gz: 3bf4d314b25b8dfcc045c3dcf7a050ca09c33341acf6978717b218a43ca394b8fd416d1437e9b0ed7c27b304c65cbf2b8621482cf948683fe808dcd8282847f8
6
+ metadata.gz: ef03747509e578fe268adfe14f0834035d794bae10ec28432ca188771fa8909afeca678ee0e9557903c5aa7805476ccf9a9886faf79927178ddb5f726799cd15
7
+ data.tar.gz: bd06222f5a2b8e329833565a611a2cf2b2be93baa0fc1a34eaec4c8e4d6b84d897b2a0116bab4b11c1dfe500c3ca079cbb3f60c857d935359dd3073acc888be2
@@ -30,6 +30,7 @@ jobs:
30
30
  bundle exec rake
31
31
 
32
32
  - name: Publish to RubyGems
33
+ if: matrix.ruby == '3.2'
33
34
  run: |
34
35
  mkdir -p $HOME/.gem
35
36
  touch $HOME/.gem/credentials
@@ -21,3 +21,25 @@ jobs:
21
21
  GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
22
22
  OWNER: ${{ github.repository_owner }}
23
23
 
24
+ publish:
25
+ needs: test
26
+ runs-on: ubuntu-latest
27
+ if: github.ref == 'refs/heads/master' && matrix.ruby == '3.2'
28
+
29
+ steps:
30
+ - uses: actions/checkout@v4
31
+
32
+ - name: Set up Ruby
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: 3.2
36
+ bundler-cache: true
37
+
38
+ - name: Check if gem version has changed
39
+ id: gem_version_check
40
+ run: |
41
+ gem build *.gemspec
42
+ gem_name=$(ls *.gem | head -n 1)
43
+ gem info $gem_name --remote || echo "new_version" > version_changed
44
+ env:
45
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.1
2
+
3
+ Add gem executables
4
+
1
5
  # 0.1.0
2
6
 
3
7
  Initial version
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dotsync (0.1.0)
4
+ dotsync (0.1.1)
5
5
  fileutils (~> 1.7.3)
6
6
  listen (~> 3.9.0)
7
7
  logger (~> 1.7.0)
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Dotsync
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dotsync`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Ruby Gem Test Status](https://github.com/dsaenztagarro/dotsync/actions/workflows/gem-push.yml/badge.svg)](https://github.com/dsaenztagarro/dotsync/actions)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Welcome to Dotsync! This gem helps you manage and synchronize your dotfiles effortlessly. Below you'll find information on installation, usage, and some tips for getting started.
6
6
 
7
7
  ## Installation
8
8
 
@@ -14,7 +14,7 @@ gem 'dotsync'
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ $ bundle install
18
18
 
19
19
  Or install it yourself as:
20
20
 
@@ -22,9 +22,33 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
+ ### Executable Commands
26
+
27
+ Dotsync provides the following commands to manage your dotfiles:
28
+
29
+ - **Push**: Transfer dotfiles from your local machine to the destination repository.
30
+ ```shell
31
+ dotsync push
32
+ ```
33
+
34
+ - **Pull**: Synchronize dotfiles from the repository to your local machine.
35
+ ```shell
36
+ dotsync pull
37
+ ```
38
+
39
+ - **Watch**: Continuously monitor and sync changes between your local machine and the repository.
40
+ ```shell
41
+ dotsync watch
42
+ ```
43
+
44
+ - **Setup**: Generate a default configuration file at `~/.config/dotsync.toml` with example mappings for `pull`, `push`, and `watch`.
45
+ ```shell
46
+ dotsync setup
47
+ ```
48
+
25
49
  ### Configuration
26
50
 
27
- The configuration file now uses a single `mappings` structure where `src` can represent both files and folders. Here is an example configuration file:
51
+ The configuration file uses a `mappings` structure to define the source and destination of your dotfiles. Here is an example:
28
52
 
29
53
  ```toml
30
54
  [pull]
@@ -36,46 +60,29 @@ mappings = [
36
60
  [push]
37
61
  mappings = [
38
62
  { src = "$HOME/.zshenv", dest = "$DOTFILES_DIR/home/.zshenv" },
39
- { src = "$XDG_CONFIG_HOME/alacritty", dest = "$DOTFILES_DIR/config/alacritty" },
40
- { src = "$XDG_CONFIG_HOME/brewfile", dest = "$DOTFILES_DIR/config/brewfile" },
41
- { src = "$XDG_CONFIG_HOME/exercism", dest = "$DOTFILES_DIR/config/exercism" },
42
- { src = "$XDG_CONFIG_HOME/git", dest = "$DOTFILES_DIR/config/git" },
43
- { src = "$XDG_CONFIG_HOME/nvim", dest = "$DOTFILES_DIR/config/nvim", ignore = "lazy-lock.json" },
44
- { src = "$XDG_CONFIG_HOME/zellij", dest = "$DOTFILES_DIR/config/zellij" },
45
- { src = "$XDG_CONFIG_HOME/zsh", dest = "$DOTFILES_DIR/config/zsh", ignore = [".zsh_sessions", ".zsh_history"] },
46
- { src = "$XDG_CONFIG_HOME/starship.toml", dest = "$DOTFILES_DIR/config/starship.toml" },
47
- { src = "$XDG_CONFIG_HOME/dotsync.toml", dest = "$DOTFILES_DIR/dotsync/macmini.toml" }
63
+ { src = "$XDG_CONFIG_HOME/alacritty", dest = "$DOTFILES_DIR/config/alacritty" }
48
64
  ]
49
65
 
50
66
  [watch]
51
- src = '~/.config'
52
- dest = '~/Code/dotfiles/src/'
53
- paths = [
54
- '~/.config/alacritty/',
55
- '~/.config/zellij/',
56
- '~/.config/nvim/',
57
- '~/.config/exercism/',
58
- '~/.config/nvim/init.lua',
59
- '~/.config/nvim/lua/',
60
- '~/.config/nvim/after/'
67
+ mappings = [
68
+ { src = "$HOME/.zshenv", dest = "$DOTFILES_DIR/home/.zshenv" },
69
+ { src = "$XDG_CONFIG_HOME/alacritty", dest = "$DOTFILES_DIR/config/alacritty" }
61
70
  ]
62
71
  ```
63
72
 
64
- ### Synchronization
65
-
66
- To sync your configuration files, use the following commands:
73
+ ### Pro Tips
67
74
 
68
- - **Push**: Transfer dotfiles from your local machine to the destination repository.
75
+ - **Using rbenv**: To ensure the gem uses the correct Ruby version managed by rbenv, you can run:
69
76
  ```shell
70
- dotsync push
77
+ RBENV_VERSION=3.2.0 dotsync push
71
78
  ```
72
79
 
73
- - **Pull**: Synchronize dotfiles from the repository to your local machine.
80
+ - **Global Installation**: Install the gem using a globally available Ruby version to make the executable accessible anywhere:
74
81
  ```shell
75
- dotsync pull
82
+ gem install dotsync
76
83
  ```
77
84
 
78
- ### Development
85
+ ## Development
79
86
 
80
87
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
81
88
 
@@ -91,8 +98,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
91
98
 
92
99
  ## Code of Conduct
93
100
 
94
- Everyone interacting in the Dotsync project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dotsync/blob/master/CODE_OF_CONDUCT.md).
95
-
96
- ## Rake tasks
97
-
98
- List with `bundle exec rake -AT`
101
+ Everyone interacting in the Dotsync project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dsaenztagarro/dotsync/blob/master/CODE_OF_CONDUCT.md).
data/RELEASING.md ADDED
@@ -0,0 +1,8 @@
1
+ ## Check list for releasing a new version
2
+
3
+ - [ ] From the root of your gem project, build the gem using `gem build`. This will create a `.gem` file.
4
+ - [ ] Install the gem locally using `gem install ./your-gem-name-version.gem`. This will install the gem, including its executable.
5
+ - [ ] After installation, the executable should be available globally in your shell path.
6
+ - [ ] To ensure the proper Ruby version is used, confirm that your environment is set up with the correct Ruby version (e.g., using a Ruby version manager like rbenv or rvm).
7
+ - [ ] From any location, you can now run the executable by typing its name (e.g., `dotsync`) to verify it works as expected.
8
+
data/exe/dotsync ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/dotsync'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+
8
+ opt_parser = OptionParser.new do |opts|
9
+ opts.banner = <<~BANNER
10
+ Usage: dotsync [command] [options]
11
+
12
+ Commands:
13
+ push Upload local changes to the remote
14
+ pull Download remote changes to the local
15
+ watch Continuously monitor and sync changes
16
+ setup Initialize a default configuration file
17
+ BANNER
18
+
19
+ opts.on("-h", "--help", "Show this help message") do
20
+ puts opts
21
+ exit
22
+ end
23
+ end
24
+
25
+ opt_parser.parse!
26
+
27
+ command = ARGV.shift
28
+
29
+ case command
30
+ when "push"
31
+ Dotsync::Runner.new.run(:push)
32
+ when "pull"
33
+ Dotsync::Runner.new.run(:pull)
34
+ when "watch"
35
+ Dotsync::Runner.new.run(:watch)
36
+ when "setup"
37
+ Dotsync::Runner.new.run(:setup)
38
+ else
39
+ puts "Unknown command: #{command}"
40
+ puts
41
+ puts opt_parser.banner
42
+ exit 1
43
+ end
44
+
@@ -6,28 +6,65 @@ module Dotsync
6
6
 
7
7
  # action_name should be a symbol, e.g., :pull, :watch, :sync
8
8
  def run(action_name)
9
- begin
10
- action_class = Dotsync.const_get("#{camelize(action_name.to_s)}Action")
11
- config_class = Dotsync.const_get("#{camelize(action_name.to_s)}ActionConfig")
12
-
13
- config = config_class.new(Dotsync.config_path)
14
- action = action_class.new(config, @logger)
15
- action.execute
16
- rescue ConfigError => e
17
- @logger.error("[#{action_name}] config error:")
18
- @logger.info(e.message)
19
- rescue NameError => e
20
- @logger.error("Unknown action '#{action_name}':")
21
- @logger.info(e.message)
22
- rescue => e
23
- @logger.error("Error running '#{action_name}':")
24
- @logger.info(e.message)
25
- raise
9
+ case action_name
10
+ when :setup
11
+ setup_config
12
+ else
13
+ begin
14
+ action_class = Dotsync.const_get("#{camelize(action_name.to_s)}Action")
15
+ config_class = Dotsync.const_get("#{camelize(action_name.to_s)}ActionConfig")
16
+
17
+ config = config_class.new(Dotsync.config_path)
18
+ action = action_class.new(config, @logger)
19
+ action.execute
20
+ rescue ConfigError => e
21
+ @logger.error("[#{action_name}] config error:")
22
+ @logger.info(e.message)
23
+ rescue NameError => e
24
+ @logger.error("Unknown action '#{action_name}':")
25
+ @logger.info(e.message)
26
+ rescue => e
27
+ @logger.error("Error running '#{action_name}':")
28
+ @logger.info(e.message)
29
+ raise
30
+ end
26
31
  end
27
32
  end
28
33
 
29
34
  private
30
35
 
36
+ def setup_config
37
+ require 'toml-rb'
38
+ require 'fileutils'
39
+
40
+ config_path = File.expand_path(Dotsync.config_path)
41
+ FileUtils.mkdir_p(File.dirname(config_path))
42
+
43
+ example_mappings = {
44
+ "pull" => {
45
+ "mappings" => [
46
+ { "src" => "$DOTFILES_DIR/config/", "dest" => "$XDG_CONFIG_HOME", "force" => false },
47
+ { "src" => "$DOTFILES_DIR/home/.zshenv", "dest" => "$HOME" }
48
+ ],
49
+ },
50
+ "push" => {
51
+ "mappings" => [
52
+ { "src" => "$HOME/.zshenv", "dest" => "$DOTFILES_DIR/home/.zshenv" },
53
+ { "src" => "$XDG_CONFIG_HOME/alacritty", "dest" => "$DOTFILES_DIR/config/alacritty" }
54
+ ]
55
+ },
56
+ "watch" => {
57
+ "mappings" => [
58
+ { "src" => "$HOME/.zshenv", "dest" => "$DOTFILES_DIR/home/.zshenv" },
59
+ { "src" => "$XDG_CONFIG_HOME/alacritty", "dest" => "$DOTFILES_DIR/config/alacritty" }
60
+ ]
61
+ }
62
+ }
63
+
64
+ File.write(config_path, TomlRB.dump(example_mappings))
65
+ @logger.info("Configuration file created at #{config_path}")
66
+ end
67
+
31
68
  # Utility to convert 'pull' to 'Pull', 'sync' to 'Sync', etc.
32
69
  def camelize(str)
33
70
  str.split('_').map(&:capitalize).join
@@ -1,3 +1,3 @@
1
1
  module Dotsync
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotsync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Sáenz
@@ -153,7 +153,10 @@ dependencies:
153
153
  description: Keep in sync your dotfiles across machines with a single TOML file
154
154
  email:
155
155
  - david.saenz.tagarro@gmail.com
156
- executables: []
156
+ executables:
157
+ - console
158
+ - dotsync
159
+ - setup
157
160
  extensions: []
158
161
  extra_rdoc_files: []
159
162
  files:
@@ -168,10 +171,12 @@ files:
168
171
  - Gemfile.lock
169
172
  - LICENSE.txt
170
173
  - README.md
174
+ - RELEASING.md
171
175
  - Rakefile
172
- - bin/console
173
- - bin/setup
174
176
  - dotsync.gemspec
177
+ - exe/console
178
+ - exe/dotsync
179
+ - exe/setup
175
180
  - lib/dotsync.rb
176
181
  - lib/dotsync/actions/base_action.rb
177
182
  - lib/dotsync/actions/config/base_config.rb
@@ -212,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
217
  - !ruby/object:Gem::Version
213
218
  version: '0'
214
219
  requirements: []
215
- rubygems_version: 3.5.22
220
+ rubygems_version: 3.4.19
216
221
  signing_key:
217
222
  specification_version: 4
218
223
  summary: Manage dotfiles like a boss
File without changes
/data/{bin → exe}/setup RENAMED
File without changes