coppy 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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/coppy.gemspec +36 -0
- data/exe/coppy +5 -0
- data/lib/coppy/cli.rb +23 -0
- data/lib/coppy/dsl.rb +32 -0
- data/lib/coppy/environment.rb +16 -0
- data/lib/coppy/manifesto.rb +43 -0
- data/lib/coppy/name.rb +18 -0
- data/lib/coppy/runner.rb +30 -0
- data/lib/coppy/steps/base.rb +20 -0
- data/lib/coppy/steps/copy.rb +36 -0
- data/lib/coppy/steps/git.rb +41 -0
- data/lib/coppy/steps/in_files.rb +33 -0
- data/lib/coppy/version.rb +3 -0
- data/lib/coppy.rb +18 -0
- metadata +156 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2a10618e27d8229b4c78f37cfdc0c1360206cad6e924941f54376368387dcd3d
|
|
4
|
+
data.tar.gz: 62f99548f0024a77db553e650f47e4bda45b926acd5874bbd035b6916751da3d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c4a0305803cec7d66299d112a91492e4b8e48cc360cbf90a1cb1b015283ca4b11657f9a9c2c65aa42dac57db023085cb15fac6fc410f967736287fa2d16cfbe0
|
|
7
|
+
data.tar.gz: 17c4586271c580a2612e70e3fb2bac00358b449fe052d9439541e046b8b29df18392404d60d6881b932864f1b16206ad0bc4f4cf370614346748385e768114d6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at sklajn@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
coppy (0.1.0)
|
|
5
|
+
thor (~> 1.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
byebug (11.1.3)
|
|
11
|
+
coderay (1.1.3)
|
|
12
|
+
diff-lcs (1.4.4)
|
|
13
|
+
method_source (1.0.0)
|
|
14
|
+
pry (0.13.1)
|
|
15
|
+
coderay (~> 1.1)
|
|
16
|
+
method_source (~> 1.0)
|
|
17
|
+
pry-byebug (3.9.0)
|
|
18
|
+
byebug (~> 11.0)
|
|
19
|
+
pry (~> 0.13.0)
|
|
20
|
+
rake (10.5.0)
|
|
21
|
+
rspec (3.10.0)
|
|
22
|
+
rspec-core (~> 3.10.0)
|
|
23
|
+
rspec-expectations (~> 3.10.0)
|
|
24
|
+
rspec-mocks (~> 3.10.0)
|
|
25
|
+
rspec-core (3.10.1)
|
|
26
|
+
rspec-support (~> 3.10.0)
|
|
27
|
+
rspec-expectations (3.10.1)
|
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
29
|
+
rspec-support (~> 3.10.0)
|
|
30
|
+
rspec-mocks (3.10.1)
|
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
32
|
+
rspec-support (~> 3.10.0)
|
|
33
|
+
rspec-support (3.10.1)
|
|
34
|
+
thor (1.1.0)
|
|
35
|
+
|
|
36
|
+
PLATFORMS
|
|
37
|
+
ruby
|
|
38
|
+
|
|
39
|
+
DEPENDENCIES
|
|
40
|
+
bundler (~> 2.0)
|
|
41
|
+
byebug
|
|
42
|
+
coppy!
|
|
43
|
+
pry
|
|
44
|
+
pry-byebug
|
|
45
|
+
rake (~> 10.0)
|
|
46
|
+
rspec (~> 3.0)
|
|
47
|
+
|
|
48
|
+
BUNDLED WITH
|
|
49
|
+
2.0.2
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Stanislaw Klajn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Stanislaw Klajn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Coppy
|
|
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/coppy`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'coppy'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install coppy
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
TODO: Write usage instructions here
|
|
26
|
+
|
|
27
|
+
## Development
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
+
|
|
33
|
+
## Contributing
|
|
34
|
+
|
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/coppy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
40
|
+
|
|
41
|
+
## Code of Conduct
|
|
42
|
+
|
|
43
|
+
Everyone interacting in the Coppy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/coppy/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "coppy"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/coppy.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "coppy/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "coppy"
|
|
7
|
+
spec.version = Coppy::VERSION
|
|
8
|
+
spec.authors = ["Stanislaw Klajn"]
|
|
9
|
+
spec.email = ["sklajn@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = %q{Utility gem to create and clone application templates}
|
|
12
|
+
spec.homepage = "https://github.com/BroiSatse/coppy"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/BroiSatse/coppy"
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
24
|
+
end
|
|
25
|
+
spec.bindir = "exe"
|
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.add_dependency "thor", "~> 1.0"
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency "pry"
|
|
32
|
+
spec.add_development_dependency "byebug"
|
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
36
|
+
end
|
data/exe/coppy
ADDED
data/lib/coppy/cli.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'coppy'
|
|
4
|
+
|
|
5
|
+
module Coppy
|
|
6
|
+
class CLI < Thor
|
|
7
|
+
include Thor::Actions
|
|
8
|
+
|
|
9
|
+
def self.exit_on_failure?
|
|
10
|
+
true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "TEMPLATE TARGET", "copies template folder into target, applying .coppy manifest of the template"
|
|
14
|
+
def copy(template_path, target_path)
|
|
15
|
+
Runner.new(template_path, target_path).call
|
|
16
|
+
rescue Coppy::Manifesto::InvalidManifesto => e
|
|
17
|
+
say "Failed to load manifesto. #{e.message}"
|
|
18
|
+
exit(1)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
default_task :copy
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/coppy/dsl.rb
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'coppy/steps/base'
|
|
2
|
+
|
|
3
|
+
module Coppy
|
|
4
|
+
class DSL
|
|
5
|
+
def initialize
|
|
6
|
+
@steps = {}
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def step(name)
|
|
10
|
+
steps[name]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def add_step(name, step_class = nil, &block)
|
|
14
|
+
raise "Cannot define DSL step with both block and class" if step_class && block
|
|
15
|
+
steps[name] = step_class || Steps::Base.wrap(&block)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module Module
|
|
19
|
+
def dsl
|
|
20
|
+
@dsl ||= DSL.new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def step(name, step_class = nil, &block)
|
|
24
|
+
dsl.add_step(name, step_class, &block)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
attr_reader :steps
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'ostruct'
|
|
2
|
+
|
|
3
|
+
module Coppy
|
|
4
|
+
class Environment < OpenStruct
|
|
5
|
+
def subenv(hash = {})
|
|
6
|
+
self.class.new(_parent: self, **hash)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def method_missing(mid, *args)
|
|
10
|
+
return super if mid.to_s.end_with?('=')
|
|
11
|
+
return @table[mid] if @table.key?(mid)
|
|
12
|
+
return _parent.send(mid, *args) if _parent
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'coppy/dsl'
|
|
2
|
+
|
|
3
|
+
module Coppy
|
|
4
|
+
class Manifesto
|
|
5
|
+
InvalidManifesto = Class.new(StandardError)
|
|
6
|
+
|
|
7
|
+
def steps
|
|
8
|
+
@steps ||= []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def execute!(env)
|
|
12
|
+
steps.each do |step|
|
|
13
|
+
step.call(env)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.load(dsl, &block)
|
|
18
|
+
manifesto = new
|
|
19
|
+
builder = Builder.new(dsl, manifesto)
|
|
20
|
+
builder.instance_exec(&block)
|
|
21
|
+
|
|
22
|
+
manifesto
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Builder
|
|
26
|
+
def initialize(dsl, manifesto)
|
|
27
|
+
@manifesto = manifesto
|
|
28
|
+
@dsl = dsl
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def method_missing(name, *args, &block)
|
|
32
|
+
unless step = @dsl.step(name)
|
|
33
|
+
raise InvalidManifesto, "Unknown step #{name}"
|
|
34
|
+
end
|
|
35
|
+
@manifesto.steps << step.new(*args, &block)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def respond_to_missing?(name, private = false)
|
|
39
|
+
!!@dsl.step(name) || super
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/coppy/name.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Coppy
|
|
2
|
+
class Name
|
|
3
|
+
def initialize(name)
|
|
4
|
+
@underscore = name
|
|
5
|
+
.gsub(/::/, '/')
|
|
6
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
|
7
|
+
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
|
8
|
+
.tr("-", "_")
|
|
9
|
+
.downcase
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :underscore
|
|
13
|
+
|
|
14
|
+
def camelcase
|
|
15
|
+
@underscore.split('_').map(&:capitalize).join
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/coppy/runner.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'coppy/manifesto'
|
|
2
|
+
require 'coppy/name'
|
|
3
|
+
|
|
4
|
+
module Coppy
|
|
5
|
+
class Runner
|
|
6
|
+
def initialize(source, target)
|
|
7
|
+
@source = source
|
|
8
|
+
@target = target
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
manifesto = load_manifesto
|
|
13
|
+
env = Environment.new(
|
|
14
|
+
source: source,
|
|
15
|
+
target: target,
|
|
16
|
+
app_name: Name.new(target.split(File::Separator).last)
|
|
17
|
+
)
|
|
18
|
+
manifesto.execute!(env)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
attr_reader :source, :target
|
|
24
|
+
|
|
25
|
+
def load_manifesto
|
|
26
|
+
manifesto_source = File.join(source, '.coppy')
|
|
27
|
+
Manifesto.load(Coppy.dsl) { instance_eval File.read(manifesto_source) }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Coppy
|
|
2
|
+
module Steps
|
|
3
|
+
class Base
|
|
4
|
+
def self.wrap(&block)
|
|
5
|
+
Class.new(self) do
|
|
6
|
+
define_method(:block, &block)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def initialize(*args, &block)
|
|
11
|
+
@args = args
|
|
12
|
+
@given_block = block
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def call(env)
|
|
16
|
+
block(env, *@args, &@given_block)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
module Coppy
|
|
4
|
+
module Steps
|
|
5
|
+
class Copy
|
|
6
|
+
extend DSL::Module
|
|
7
|
+
|
|
8
|
+
step :ignore do |env, pattern|
|
|
9
|
+
env.ignore << pattern
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize(&block)
|
|
13
|
+
@manifesto = Manifesto.load(self.class.dsl, &block)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call(env)
|
|
17
|
+
copy_env = Environment.new(ignore: [])
|
|
18
|
+
@manifesto.execute!(copy_env)
|
|
19
|
+
|
|
20
|
+
files = Dir.glob(File.join env.source, "**", "*")
|
|
21
|
+
ignored_files = copy_env.ignore.flat_map do |ignore|
|
|
22
|
+
pattern = File.join env.source, ignore
|
|
23
|
+
pattern = File.join(pattern, "**", '*') if File.directory?(pattern)
|
|
24
|
+
Dir.glob(pattern)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
(files - ignored_files).each do |file|
|
|
28
|
+
relative = file.sub(env.source, '')
|
|
29
|
+
target = File.join(env.target, relative)
|
|
30
|
+
FileUtils.mkdir_p(File.dirname target)
|
|
31
|
+
FileUtils.cp(file, target, preserve: true) unless File.directory?(file)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Coppy
|
|
2
|
+
module Steps
|
|
3
|
+
class Git
|
|
4
|
+
extend DSL::Module
|
|
5
|
+
|
|
6
|
+
step :add_all do |env|
|
|
7
|
+
system "git add ."
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
step :commit do |env, message = nil, &block|
|
|
11
|
+
message ||= block.call(env)
|
|
12
|
+
system "git commit -m '#{message}'", out: File::NULL
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(&block)
|
|
16
|
+
@manifesto = Manifesto.load(self.class.dsl, &block)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def call(env)
|
|
20
|
+
source_hash = Dir.chdir(env.source) { `git rev-parse HEAD` }
|
|
21
|
+
source_origin = Dir.chdir(env.source) do
|
|
22
|
+
`git remote -v`.each_line
|
|
23
|
+
.map {|line| line.split("\t") }
|
|
24
|
+
.find {|remote, src, fetch_or_push| remote == "origin" && fetch_or_push == "fetch" }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Dir.chdir(env.target) do
|
|
28
|
+
system "git init", out: File::NULL
|
|
29
|
+
git_env = Environment.new(
|
|
30
|
+
source: Environment.new(
|
|
31
|
+
hash: source_hash,
|
|
32
|
+
remote: source_origin
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
@manifesto.execute!(git_env)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
module Coppy
|
|
4
|
+
module Steps
|
|
5
|
+
class InFiles
|
|
6
|
+
extend DSL::Module
|
|
7
|
+
|
|
8
|
+
step :replace do |env, source, target|
|
|
9
|
+
source = source.call(env) if source.respond_to?(:call)
|
|
10
|
+
target = target.call(env) if target.respond_to?(:call)
|
|
11
|
+
|
|
12
|
+
env.file.gsub!(source, target)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(*file_patterns, &block)
|
|
16
|
+
@patterns = file_patterns
|
|
17
|
+
@manifesto = Manifesto.load(self.class.dsl, &block)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def call(env)
|
|
21
|
+
files = @patterns.flat_map { |pattern| Dir.glob(File.join env.target, pattern) }
|
|
22
|
+
files.each do |file_path|
|
|
23
|
+
file = File.read(file_path)
|
|
24
|
+
local_env = env.subenv(
|
|
25
|
+
file: file
|
|
26
|
+
)
|
|
27
|
+
@manifesto.execute!(local_env)
|
|
28
|
+
File.open(file_path, 'w') { |f| f.write local_env.file }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/coppy.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "coppy/version"
|
|
2
|
+
require "coppy/manifesto"
|
|
3
|
+
require "coppy/dsl"
|
|
4
|
+
require 'coppy/environment'
|
|
5
|
+
|
|
6
|
+
require "coppy/steps/copy"
|
|
7
|
+
require "coppy/steps/in_files"
|
|
8
|
+
require "coppy/steps/git"
|
|
9
|
+
require "coppy/runner"
|
|
10
|
+
|
|
11
|
+
module Coppy
|
|
12
|
+
class Error < StandardError; end
|
|
13
|
+
|
|
14
|
+
extend DSL::Module
|
|
15
|
+
step(:copy, Steps::Copy)
|
|
16
|
+
step(:git, Steps::Git)
|
|
17
|
+
step(:in_files, Steps::InFiles)
|
|
18
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: coppy
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Stanislaw Klajn
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2021-01-27 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: pry
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: byebug
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bundler
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '10.0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '10.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rspec
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '3.0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '3.0'
|
|
97
|
+
description:
|
|
98
|
+
email:
|
|
99
|
+
- sklajn@gmail.com
|
|
100
|
+
executables:
|
|
101
|
+
- coppy
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- CODE_OF_CONDUCT.md
|
|
109
|
+
- Gemfile
|
|
110
|
+
- Gemfile.lock
|
|
111
|
+
- LICENSE
|
|
112
|
+
- LICENSE.txt
|
|
113
|
+
- README.md
|
|
114
|
+
- Rakefile
|
|
115
|
+
- bin/console
|
|
116
|
+
- bin/setup
|
|
117
|
+
- coppy.gemspec
|
|
118
|
+
- exe/coppy
|
|
119
|
+
- lib/coppy.rb
|
|
120
|
+
- lib/coppy/cli.rb
|
|
121
|
+
- lib/coppy/dsl.rb
|
|
122
|
+
- lib/coppy/environment.rb
|
|
123
|
+
- lib/coppy/manifesto.rb
|
|
124
|
+
- lib/coppy/name.rb
|
|
125
|
+
- lib/coppy/runner.rb
|
|
126
|
+
- lib/coppy/steps/base.rb
|
|
127
|
+
- lib/coppy/steps/copy.rb
|
|
128
|
+
- lib/coppy/steps/git.rb
|
|
129
|
+
- lib/coppy/steps/in_files.rb
|
|
130
|
+
- lib/coppy/version.rb
|
|
131
|
+
homepage: https://github.com/BroiSatse/coppy
|
|
132
|
+
licenses:
|
|
133
|
+
- MIT
|
|
134
|
+
metadata:
|
|
135
|
+
homepage_uri: https://github.com/BroiSatse/coppy
|
|
136
|
+
source_code_uri: https://github.com/BroiSatse/coppy
|
|
137
|
+
post_install_message:
|
|
138
|
+
rdoc_options: []
|
|
139
|
+
require_paths:
|
|
140
|
+
- lib
|
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
|
+
requirements:
|
|
148
|
+
- - ">="
|
|
149
|
+
- !ruby/object:Gem::Version
|
|
150
|
+
version: '0'
|
|
151
|
+
requirements: []
|
|
152
|
+
rubygems_version: 3.0.6
|
|
153
|
+
signing_key:
|
|
154
|
+
specification_version: 4
|
|
155
|
+
summary: Utility gem to create and clone application templates
|
|
156
|
+
test_files: []
|