planter-cli 0.0.4 → 3.0.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 +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +21 -0
- data/README.md +28 -1
- data/Rakefile +52 -16
- data/bin/plant +1 -1
- data/docker/Dockerfile-2.6 +5 -5
- data/docker/Dockerfile-2.7 +3 -3
- data/docker/Dockerfile-3.0 +3 -3
- data/lib/planter/array.rb +17 -0
- data/lib/planter/fileentry.rb +5 -1
- data/lib/planter/filelist.rb +8 -0
- data/lib/planter/hash.rb +17 -1
- data/lib/planter/plant.rb +2 -0
- data/lib/planter/tag.rb +54 -0
- data/lib/planter/version.rb +1 -1
- data/lib/planter.rb +4 -1
- data/planter-cli.gemspec +1 -0
- data/spec/planter/hash_spec.rb +27 -0
- data/spec/planter_spec.rb +15 -0
- data/spec/templates/test/%%project:snake%%.rtf +10 -0
- data/spec/templates/test/Rakefile +6 -0
- data/spec/templates/test/test.rb +5 -0
- data/src/_README.md +15 -0
- metadata +24 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b4906c83392316be6ac61380bd0d2401a847f4c08f6afc91bdfbd4858980568
|
4
|
+
data.tar.gz: 7253e2ec572be45e7543d82ad2b1dde685fc5b8ba7b256ec914b0575e44ad507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98fd1c334e3d2efdcdc10171d7a5b5f81898e9a03890bc08cd65e2f3c8a10941cfe46e5e5b23584f28c87aad3b85471ab544c3665049c5abfd911006b40bfbe8
|
7
|
+
data.tar.gz: a7a86edaf7bf49cb65cde877ab4aec8bd92a6f27a90c09f526e50f9f1ddc84c27655e67bfea75b9463c8033601ae1961e4854bce76f4e268bfe87aa3171c7677
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
### 3.0.1
|
2
|
+
|
3
|
+
2024-08-31 14:19
|
4
|
+
|
5
|
+
### 3.0.0-alpha
|
6
|
+
|
7
|
+
2024-08-31 14:18
|
8
|
+
|
9
|
+
#### NEW
|
10
|
+
|
11
|
+
- Initial release
|
12
|
+
- Preserve Finder tags when planting (config option `preserve_tags: true`)
|
13
|
+
|
14
|
+
#### IMPROVED
|
15
|
+
|
16
|
+
- More tests
|
17
|
+
|
18
|
+
#### FIXED
|
19
|
+
|
20
|
+
- Code refactoring
|
21
|
+
|
1
22
|
### 0.0.3
|
2
23
|
|
3
24
|
2024-08-28 09:46
|
data/README.md
CHANGED
@@ -14,7 +14,18 @@ If [Gum](https://github.com/charmbracelet/gum) is available it will be used for
|
|
14
14
|
|
15
15
|
## Configuration
|
16
16
|
|
17
|
-
Planter's base configuration is in `~/.config/planter/
|
17
|
+
Planter's base configuration is in `~/.config/planter/planter.yml`. This file can contain any of the keys used in templates (see below) and will serve as a base configuration for all templates. Any key defined in this file will be overridden if it exists in a template.
|
18
|
+
|
19
|
+
Example config (written on first run):
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
files:
|
23
|
+
.DS_Store: ignore
|
24
|
+
"*.tmp": ignore
|
25
|
+
"*.bak": ignore
|
26
|
+
git_init: false
|
27
|
+
preserve_tags: true
|
28
|
+
```
|
18
29
|
|
19
30
|
### Scripts.
|
20
31
|
|
@@ -49,6 +60,10 @@ replacements: # Dictionary of pattern/replacments for regex substitution, see [R
|
|
49
60
|
repo: # If a repository URL is provided, it will be pulled and duplicated instead of copying a file structure
|
50
61
|
```
|
51
62
|
|
63
|
+
#### Default values in template strings
|
64
|
+
|
65
|
+
In a template you can add a default value for a placholder by adding `%default value` to it. For example, `%%project%Default Project%%` will set the placeholder to `Default Project` if the variable value matches the default value in the configuration. This allows you to accept the default on the command line but have a different value inserted in the template. To use another variable in its place, use `$KEY` in the placeholder, e.g. `%%project%$title%%` will replace the `project` key with the value of `title` if the default is selected. Modifiers can be used on either side of the `%`, e.g. `%%project%$title:snake%%`.
|
66
|
+
|
52
67
|
### File-specific handling
|
53
68
|
|
54
69
|
A `files` dictionary can specify how to handle specific files. Options are `copy`, `overwrite`, `merge`, or `ask`. The key for each entry is a filename or glob that matches the source filename (accounting for template variables if applicable):
|
@@ -67,6 +82,14 @@ Merged content
|
|
67
82
|
// /merge
|
68
83
|
```
|
69
84
|
|
85
|
+
Or
|
86
|
+
|
87
|
+
```
|
88
|
+
# merge
|
89
|
+
Merged content
|
90
|
+
# /merge
|
91
|
+
```
|
92
|
+
|
70
93
|
By default files that already exist in the destination directory are not overwritten, and merging allows you to add missing parts to a Rakefile or Makefile, for example.
|
71
94
|
|
72
95
|
If `ask` is specified, a memu will be provided on the command line asking how to handle a file. If the file doesn't already exist, you will be asked only whether to copy the file or not. If it does exist, `overwrite` and `merge` options will be added.
|
@@ -83,6 +106,10 @@ replacements:
|
|
83
106
|
|
84
107
|
Replacements are performed on both file/directory names and file contents.
|
85
108
|
|
109
|
+
### Finder Tags
|
110
|
+
|
111
|
+
If `preserve_tags` is set to `true` in the config (either base or template), then existing Finder tags on the file or folder will be copied to the new file when a template is planted.
|
112
|
+
|
86
113
|
## Usage
|
87
114
|
|
88
115
|
The executable for Planter is `plant`. You can run `plant TEMPLATE` in any directory and TEMPLATE will be planted in the current directory. You can also use `--in PATH` to plant in another directory.
|
data/Rakefile
CHANGED
@@ -38,17 +38,6 @@ end
|
|
38
38
|
desc 'Clobber files'
|
39
39
|
task clobber: :clobber_packages
|
40
40
|
|
41
|
-
desc 'Development version check'
|
42
|
-
task :ver do
|
43
|
-
gver = `git ver`
|
44
|
-
cver = IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
|
45
|
-
res = `grep VERSION lib/planter/version.rb`
|
46
|
-
version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
|
47
|
-
puts "git tag: #{gver}"
|
48
|
-
puts "version.rb: #{version}"
|
49
|
-
puts "changelog: #{cver}"
|
50
|
-
end
|
51
|
-
|
52
41
|
desc 'Get Script Version'
|
53
42
|
task :sver do
|
54
43
|
res = `grep VERSION lib/planter/version.rb`
|
@@ -56,11 +45,6 @@ task :sver do
|
|
56
45
|
print version
|
57
46
|
end
|
58
47
|
|
59
|
-
desc 'Changelog version check'
|
60
|
-
task :cver do
|
61
|
-
puts IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
|
62
|
-
end
|
63
|
-
|
64
48
|
desc 'Run tests in Docker'
|
65
49
|
task :dockertest, :version, :login, :attempt do |_, args|
|
66
50
|
args.with_defaults(version: 'all', login: false, attempt: 1)
|
@@ -78,6 +62,9 @@ task :dockertest, :version, :login, :attempt do |_, args|
|
|
78
62
|
Rake::Task['dockertest'].invoke(v, false)
|
79
63
|
end
|
80
64
|
Process.exit 0
|
65
|
+
when /^3\.?3/
|
66
|
+
img = 'plantertest33'
|
67
|
+
file = 'docker/Dockerfile-3.3'
|
81
68
|
when /^3/
|
82
69
|
version = '3.0'
|
83
70
|
img = 'plantertest3'
|
@@ -130,3 +117,52 @@ end
|
|
130
117
|
|
131
118
|
desc 'alias for build'
|
132
119
|
task package: :build
|
120
|
+
|
121
|
+
desc 'Development version check'
|
122
|
+
task :ver do
|
123
|
+
gver = `git ver`
|
124
|
+
cver = IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
|
125
|
+
res = `grep VERSION lib/untitled/version.rb`
|
126
|
+
version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
|
127
|
+
puts "git tag: #{gver}"
|
128
|
+
puts "version.rb: #{version}"
|
129
|
+
puts "changelog: #{cver}"
|
130
|
+
end
|
131
|
+
|
132
|
+
desc 'Changelog version check'
|
133
|
+
task :cver do
|
134
|
+
puts IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
|
135
|
+
end
|
136
|
+
|
137
|
+
desc 'Alias for build'
|
138
|
+
task package: :build
|
139
|
+
|
140
|
+
desc 'Bump incremental version number'
|
141
|
+
task :bump, :type do |_, args|
|
142
|
+
args.with_defaults(type: 'inc')
|
143
|
+
version_file = 'lib/untitled/version.rb'
|
144
|
+
content = IO.read(version_file)
|
145
|
+
content.sub!(/VERSION = '(?<major>\d+)\.(?<minor>\d+)\.(?<inc>\d+)(?<pre>\S+)?'/) do
|
146
|
+
m = Regexp.last_match
|
147
|
+
major = m['major'].to_i
|
148
|
+
minor = m['minor'].to_i
|
149
|
+
inc = m['inc'].to_i
|
150
|
+
pre = m['pre']
|
151
|
+
|
152
|
+
case args[:type]
|
153
|
+
when /^maj/
|
154
|
+
major += 1
|
155
|
+
minor = 0
|
156
|
+
inc = 0
|
157
|
+
when /^min/
|
158
|
+
minor += 1
|
159
|
+
inc = 0
|
160
|
+
else
|
161
|
+
inc += 1
|
162
|
+
end
|
163
|
+
|
164
|
+
$stdout.puts "At version #{major}.#{minor}.#{inc}#{pre}"
|
165
|
+
"VERSION = '#{major}.#{minor}.#{inc}#{pre}'"
|
166
|
+
end
|
167
|
+
File.open(version_file, 'w+') { |f| f.puts content }
|
168
|
+
end
|
data/bin/plant
CHANGED
@@ -54,7 +54,7 @@ opts.on('-o', '--overwrite', 'Overwrite existing files') do
|
|
54
54
|
Planter.overwrite = true
|
55
55
|
end
|
56
56
|
|
57
|
-
opts.on_tail('--base-dir', 'Use an alternate base directory for config and templates') do |opt|
|
57
|
+
opts.on_tail('--base-dir DIRECTORY', 'Use an alternate base directory for config and templates') do |opt|
|
58
58
|
Planter.base_dir = opt
|
59
59
|
end
|
60
60
|
|
data/docker/Dockerfile-2.6
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
FROM ruby:2.6
|
2
2
|
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
-
RUN mkdir /
|
4
|
-
WORKDIR /
|
5
|
-
# COPY ./ /
|
3
|
+
RUN mkdir /planter
|
4
|
+
WORKDIR /planter
|
5
|
+
# COPY ./ /planter/
|
6
6
|
RUN gem install bundler:2.2.29
|
7
|
-
RUN apt-get update -y
|
8
|
-
RUN apt-get install -y less vim
|
7
|
+
# RUN apt-get update -y
|
8
|
+
# RUN apt-get install -y less vim
|
9
9
|
COPY ./docker/inputrc /root/.inputrc
|
10
10
|
COPY ./docker/bash_profile /root/.bash_profile
|
11
11
|
RUN mkdir -p /root/.config/planter/templates/test
|
data/docker/Dockerfile-2.7
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
FROM ruby:2.7
|
2
2
|
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
-
RUN mkdir /
|
4
|
-
WORKDIR /
|
5
|
-
# COPY ./ /
|
3
|
+
RUN mkdir /planter
|
4
|
+
WORKDIR /planter
|
5
|
+
# COPY ./ /planter/
|
6
6
|
RUN gem install bundler:2.2.29
|
7
7
|
RUN apt-get update -y
|
8
8
|
RUN apt-get install -y less vim
|
data/docker/Dockerfile-3.0
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
FROM ruby:3.0.0
|
2
2
|
# RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
3
|
-
RUN mkdir /
|
4
|
-
WORKDIR /
|
5
|
-
# COPY ./ /
|
3
|
+
RUN mkdir /planter
|
4
|
+
WORKDIR /planter
|
5
|
+
# COPY ./ /planter/
|
6
6
|
RUN gem install bundler:2.2.29
|
7
7
|
RUN apt-get update -y
|
8
8
|
RUN apt-get install -y less vim
|
data/lib/planter/array.rb
CHANGED
@@ -58,5 +58,22 @@ module Planter
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
#
|
63
|
+
# Destructive version of #symbolize_keys
|
64
|
+
#
|
65
|
+
# @return [Array] Array with symbolized keys
|
66
|
+
#
|
67
|
+
def symbolize_keys!
|
68
|
+
replace deep_dup.symbolize_keys
|
69
|
+
end
|
70
|
+
|
71
|
+
## Deep duplicate an array of hashes or arrays
|
72
|
+
##
|
73
|
+
## @return [Array] Deep duplicated array
|
74
|
+
##
|
75
|
+
def deep_dup
|
76
|
+
map { |v| v.is_a?(Hash) || v.is_a?(Array) ? v.deep_dup : v.dup }
|
77
|
+
end
|
61
78
|
end
|
62
79
|
end
|
data/lib/planter/fileentry.rb
CHANGED
@@ -7,7 +7,7 @@ module Planter
|
|
7
7
|
attr_accessor :operation
|
8
8
|
|
9
9
|
# File path and target path
|
10
|
-
attr_reader :file, :target
|
10
|
+
attr_reader :file, :target, :tags
|
11
11
|
|
12
12
|
##
|
13
13
|
## Initialize a FileEntry object
|
@@ -19,10 +19,14 @@ module Planter
|
|
19
19
|
## @return [FileEntry] a Hash of parameters
|
20
20
|
##
|
21
21
|
def initialize(file, target, operation)
|
22
|
+
return nil unless File.exist?(file)
|
23
|
+
|
22
24
|
@file = file
|
23
25
|
@target = target
|
24
26
|
@operation = operation
|
25
27
|
|
28
|
+
@tags = Tag.get(file)
|
29
|
+
|
26
30
|
super()
|
27
31
|
end
|
28
32
|
|
data/lib/planter/filelist.rb
CHANGED
data/lib/planter/hash.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Hash helpers
|
4
3
|
module Planter
|
5
4
|
## Hash helpers
|
6
5
|
class ::Hash
|
@@ -18,6 +17,14 @@ module Planter
|
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
20
|
+
## Destructive version of #stringify_keys
|
21
|
+
##
|
22
|
+
## @return [Hash] Hash with stringified keys
|
23
|
+
##
|
24
|
+
def stringify_keys!
|
25
|
+
replace stringify_keys
|
26
|
+
end
|
27
|
+
|
21
28
|
##
|
22
29
|
## Turn all keys into symbols
|
23
30
|
##
|
@@ -33,6 +40,15 @@ module Planter
|
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
43
|
+
##
|
44
|
+
## Destructive version of #symbolize_keys
|
45
|
+
##
|
46
|
+
## @return [Hash] Hash with symbolized keys
|
47
|
+
##
|
48
|
+
def symbolize_keys!
|
49
|
+
replace symbolize_keys
|
50
|
+
end
|
51
|
+
|
36
52
|
##
|
37
53
|
## Deep merge a hash
|
38
54
|
##
|
data/lib/planter/plant.rb
CHANGED
@@ -68,6 +68,8 @@ module Planter
|
|
68
68
|
## @example Pass a GitHub-style repo path and get full url
|
69
69
|
## expand_repo("ttscoff/planter-cli") #=> https://github.com/ttscoff/planter-cli.git
|
70
70
|
##
|
71
|
+
## @param repo [String] The repo
|
72
|
+
##
|
71
73
|
## @return { description_of_the_return_value }
|
72
74
|
##
|
73
75
|
def expand_repo(repo)
|
data/lib/planter/tag.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Planter
|
4
|
+
module Tag
|
5
|
+
class << self
|
6
|
+
def set(target, tags)
|
7
|
+
tags = [tags] unless tags.is_a?(Array)
|
8
|
+
|
9
|
+
set_tags(target, tags)
|
10
|
+
$? == 0
|
11
|
+
end
|
12
|
+
|
13
|
+
# Add tags to a directory.
|
14
|
+
#
|
15
|
+
# @param dir [String] The directory to tag.
|
16
|
+
# @param tags [Array<String>] The tags to add.
|
17
|
+
def add(target, tags)
|
18
|
+
tags = [tags] unless tags.is_a?(Array)
|
19
|
+
existing_tags = get(target)
|
20
|
+
tags.concat(existing_tags).uniq!
|
21
|
+
|
22
|
+
set_tags(target, tags)
|
23
|
+
$? == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
def get(target)
|
27
|
+
res = `xattr -p com.apple.metadata:_kMDItemUserTags "#{target}" 2>/dev/null`.clean_encode
|
28
|
+
return [] if res =~ /no such xattr/ || res.empty?
|
29
|
+
|
30
|
+
tags = Plist.parse_xml(res)
|
31
|
+
|
32
|
+
return false if tags.nil?
|
33
|
+
|
34
|
+
tags
|
35
|
+
end
|
36
|
+
|
37
|
+
def copy(source, target)
|
38
|
+
tags = `xattr -px com.apple.metadata:_kMDItemUserTags "#{source}" 2>/dev/null`
|
39
|
+
`xattr -wx com.apple.metadata:_kMDItemUserTags "#{tags}" "#{target}"`
|
40
|
+
$? == 0
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def set_tags(target, tags)
|
46
|
+
tags.map! { |tag| "<string>#{tag}</string>" }
|
47
|
+
`xattr -w com.apple.metadata:_kMDItemUserTags '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
48
|
+
<plist version="1.0">
|
49
|
+
<array>#{tags.join}</array>
|
50
|
+
</plist>' "#{target}"`
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/planter/version.rb
CHANGED
data/lib/planter.rb
CHANGED
@@ -6,6 +6,7 @@ require 'json'
|
|
6
6
|
require 'yaml'
|
7
7
|
require 'fileutils'
|
8
8
|
require 'open3'
|
9
|
+
require 'plist'
|
9
10
|
|
10
11
|
require 'chronic'
|
11
12
|
require 'tty-reader'
|
@@ -18,6 +19,7 @@ require_relative 'planter/hash'
|
|
18
19
|
require_relative 'planter/array'
|
19
20
|
require_relative 'planter/symbol'
|
20
21
|
require_relative 'planter/file'
|
22
|
+
require_relative 'planter/tag'
|
21
23
|
require_relative 'planter/color'
|
22
24
|
require_relative 'planter/errors'
|
23
25
|
require_relative 'planter/prompt'
|
@@ -127,7 +129,8 @@ module Planter
|
|
127
129
|
defaults: false,
|
128
130
|
git_init: false,
|
129
131
|
files: { '_planter.yml' => 'ignore' },
|
130
|
-
color: true
|
132
|
+
color: true,
|
133
|
+
preserve_tags: true
|
131
134
|
}
|
132
135
|
begin
|
133
136
|
File.open(base_config, 'w') { |f| f.puts(YAML.dump(default_base_config.stringify_keys)) }
|
data/planter-cli.gemspec
CHANGED
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency 'yard', '~> 0.9.5'
|
42
42
|
|
43
43
|
spec.add_runtime_dependency 'chronic', '~> 0.10'
|
44
|
+
spec.add_runtime_dependency 'plist', '~> 3.7.1'
|
44
45
|
spec.add_runtime_dependency 'tty-reader', '~> 0.9'
|
45
46
|
spec.add_runtime_dependency 'tty-screen', '~> 0.8'
|
46
47
|
spec.add_runtime_dependency 'tty-spinner', '~> 0.9'
|
data/spec/planter/hash_spec.rb
CHANGED
@@ -80,4 +80,31 @@ describe ::Hash do
|
|
80
80
|
expect(hash[:b]).not_to be_frozen
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
describe '#stringify_keys!' do
|
85
|
+
let(:hash) { { key1: 'value1', key2: 'value2', key3: { key4: 'value4' } } }
|
86
|
+
|
87
|
+
it 'converts symbol keys to strings destructively' do
|
88
|
+
hash.stringify_keys!
|
89
|
+
expect(hash).to eq({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => { 'key4' => 'value4' } })
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'does not modify the original hash if already string keys' do
|
93
|
+
string_hash = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => { 'key4' => 'value4' } }
|
94
|
+
string_hash.stringify_keys!
|
95
|
+
expect(string_hash).to eq({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => { 'key4' => 'value4' } })
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'handles nested hashes' do
|
99
|
+
nested_hash = { key1: { key2: { key3: 'value3' } } }
|
100
|
+
nested_hash.stringify_keys!
|
101
|
+
expect(nested_hash).to eq({ 'key1' => { 'key2' => { 'key3' => 'value3' } } })
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'handles empty hashes' do
|
105
|
+
empty_hash = {}
|
106
|
+
empty_hash.stringify_keys!
|
107
|
+
expect(empty_hash).to eq({})
|
108
|
+
end
|
109
|
+
end
|
83
110
|
end
|
data/spec/planter_spec.rb
CHANGED
@@ -29,6 +29,21 @@ RSpec.describe "Planter" do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
describe '.spinner' do
|
33
|
+
it 'initializes a new TTY::Spinner object if not already initialized' do
|
34
|
+
Planter.instance_variable_set(:@spinner, nil) # Ensure spinner is not initialized
|
35
|
+
spinner = Planter.spinner
|
36
|
+
expect(spinner).to be_a(TTY::Spinner)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns the existing TTY::Spinner object if already initialized' do
|
40
|
+
existing_spinner = TTY::Spinner.new
|
41
|
+
Planter.instance_variable_set(:@spinner, existing_spinner)
|
42
|
+
spinner = Planter.spinner
|
43
|
+
expect(spinner).to eq(existing_spinner)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
32
47
|
describe '.config=' do
|
33
48
|
# it 'sets the config' do
|
34
49
|
# path = File.expand_path('spec/noop')
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{\rtf1\ansi\ansicpg1252\cocoartf2761
|
2
|
+
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
3
|
+
{\colortbl;\red255\green255\blue255;}
|
4
|
+
{\*\expandedcolortbl;;}
|
5
|
+
\margl1440\margr1440\vieww11520\viewh8400\viewkind0
|
6
|
+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
|
7
|
+
|
8
|
+
\f0\fs24 \cf0 Planter\
|
9
|
+
\
|
10
|
+
%%project:title%%}
|
data/src/_README.md
CHANGED
@@ -21,6 +21,17 @@ If [Gum](https://github.com/charmbracelet/gum) is available it will be used for
|
|
21
21
|
|
22
22
|
Planter's base configuration is in `~/.config/planter/planter.yml`. This file can contain any of the keys used in templates (see below) and will serve as a base configuration for all templates. Any key defined in this file will be overridden if it exists in a template.
|
23
23
|
|
24
|
+
Example config (written on first run):
|
25
|
+
|
26
|
+
```yaml
|
27
|
+
files:
|
28
|
+
.DS_Store: ignore
|
29
|
+
"*.tmp": ignore
|
30
|
+
"*.bak": ignore
|
31
|
+
git_init: false
|
32
|
+
preserve_tags: true
|
33
|
+
```
|
34
|
+
|
24
35
|
### Scripts.
|
25
36
|
|
26
37
|
Scripts for execution after planting can be stored in `~/.config/planter/scripts` and referenced by filename only. Alternatively, scripts may be stored within a template in a `_scritps` subfolder.
|
@@ -100,6 +111,10 @@ replacements:
|
|
100
111
|
|
101
112
|
Replacements are performed on both file/directory names and file contents.
|
102
113
|
|
114
|
+
### Finder Tags
|
115
|
+
|
116
|
+
If `preserve_tags` is set to `true` in the config (either base or template), then existing Finder tags on the file or folder will be copied to the new file when a template is planted.
|
117
|
+
|
103
118
|
## Usage
|
104
119
|
|
105
120
|
The executable for Planter is `plant`. You can run `plant TEMPLATE` in any directory and TEMPLATE will be planted in the current directory. You can also use `--in PATH` to plant in another directory.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: planter-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|
@@ -262,6 +262,20 @@ dependencies:
|
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0.10'
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: plist
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: 3.7.1
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: 3.7.1
|
265
279
|
- !ruby/object:Gem::Dependency
|
266
280
|
name: tty-reader
|
267
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -361,6 +375,7 @@ files:
|
|
361
375
|
- lib/planter/script.rb
|
362
376
|
- lib/planter/string.rb
|
363
377
|
- lib/planter/symbol.rb
|
378
|
+
- lib/planter/tag.rb
|
364
379
|
- lib/planter/version.rb
|
365
380
|
- planter-cli.gemspec
|
366
381
|
- scripts/deploy.rb
|
@@ -381,9 +396,12 @@ files:
|
|
381
396
|
- spec/scripts/test.sh
|
382
397
|
- spec/scripts/test_fail.sh
|
383
398
|
- spec/spec_helper.rb
|
399
|
+
- spec/templates/test/%%project:snake%%.rtf
|
400
|
+
- spec/templates/test/Rakefile
|
384
401
|
- spec/templates/test/_planter.yml
|
385
402
|
- spec/templates/test/_scripts/test.sh
|
386
403
|
- spec/templates/test/_scripts/test_fail.sh
|
404
|
+
- spec/templates/test/test.rb
|
387
405
|
- spec/test_out/image.png
|
388
406
|
- spec/test_out/test2.rb
|
389
407
|
- src/_README.md
|
@@ -406,7 +424,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
406
424
|
- !ruby/object:Gem::Version
|
407
425
|
version: '0'
|
408
426
|
requirements: []
|
409
|
-
rubygems_version: 3.2.
|
427
|
+
rubygems_version: 3.2.16
|
410
428
|
signing_key:
|
411
429
|
specification_version: 4
|
412
430
|
summary: Plant files and directories using templates
|
@@ -427,8 +445,11 @@ test_files:
|
|
427
445
|
- spec/scripts/test.sh
|
428
446
|
- spec/scripts/test_fail.sh
|
429
447
|
- spec/spec_helper.rb
|
448
|
+
- spec/templates/test/%%project:snake%%.rtf
|
449
|
+
- spec/templates/test/Rakefile
|
430
450
|
- spec/templates/test/_planter.yml
|
431
451
|
- spec/templates/test/_scripts/test.sh
|
432
452
|
- spec/templates/test/_scripts/test_fail.sh
|
453
|
+
- spec/templates/test/test.rb
|
433
454
|
- spec/test_out/image.png
|
434
455
|
- spec/test_out/test2.rb
|