app_builder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +35 -0
- data/Rakefile +10 -0
- data/app_builder.gemspec +27 -0
- data/bin/console +7 -0
- data/bin/setup +8 -0
- data/lib/app_builder.rb +10 -0
- data/lib/app_builder/archiver.rb +18 -0
- data/lib/app_builder/base.rb +27 -0
- data/lib/app_builder/builder.rb +12 -0
- data/lib/app_builder/config.rb +44 -0
- data/lib/app_builder/version.rb +3 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cf31788f50e6273be39db53433a0d796a48aae60
|
4
|
+
data.tar.gz: a990d3dc8a725b46e7735e27cfaed6ef44152f78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c55a495fcac30f0c8f9621326cdb1ee22191d60c2d14592fca38ea674d36a996cc25ed18866d9c374633e9e347ff9ffb37319d58ba2fd442e16fc38c6a6a81d6
|
7
|
+
data.tar.gz: bd2be65308005e49811120eb513fac67ffc6e5585ed973b3a6a926c041a0cbdefd3c746c11a2ead24934c208d271130603fc83801407b30c6e4522051601a4be
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ken Iiboshi
|
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/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# AppBuilder
|
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/app_builder`. 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 'app_builder'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install app_builder
|
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 test` 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/i2bskn/app_builder.
|
data/Rakefile
ADDED
data/app_builder.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "app_builder/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "app_builder"
|
8
|
+
spec.version = AppBuilder::VERSION
|
9
|
+
spec.authors = ["i2bskn"]
|
10
|
+
spec.email = ["i2bskn@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Application build utilities.}
|
13
|
+
spec.description = %q{Application build utilities.}
|
14
|
+
spec.homepage = "https://github.com/i2bskn/app_builder"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/app_builder.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module AppBuilder
|
2
|
+
class Archiver < Base
|
3
|
+
def archive
|
4
|
+
execute("mkdir -p #{working_path} #{archive_path} #{build_path}")
|
5
|
+
if File.exist?("#{repo_path}/HEAD")
|
6
|
+
execute("git remote update", chdir: repo_path)
|
7
|
+
else
|
8
|
+
execute("git clone --mirror #{remote_repository} #{repo_path}")
|
9
|
+
end
|
10
|
+
|
11
|
+
execute("git archive #{branch} | tar -x -C #{archive_path}", chdir: repo_path)
|
12
|
+
|
13
|
+
rev_hash = { "branch" => branch, "revision" => revision }
|
14
|
+
File.open(revision_path, "w") { |f| f.write(rev_hash.to_yaml) }
|
15
|
+
log(:info, "Create revision: #{rev_hash.inspect}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module AppBuilder
|
2
|
+
class Base
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
attr_accessor :config
|
6
|
+
::AppBuilder::Config::VALID_OPTIONS.each do |name|
|
7
|
+
def_delegator :config, name
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(config = nil)
|
11
|
+
@config = config || ::AppBuilder::Config.new
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def execute(cmd, options = {})
|
17
|
+
log(:info, "Execute command [local]: #{cmd}")
|
18
|
+
stdout, stderr, status = Open3.capture3(cmd, **options)
|
19
|
+
log(:error, "Failed [#{status.exitstatus}]: #{stderr}") unless status.success?
|
20
|
+
stdout.chomp
|
21
|
+
end
|
22
|
+
|
23
|
+
def log(level, message)
|
24
|
+
logger&.send(level, message)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module AppBuilder
|
2
|
+
class Config
|
3
|
+
VALID_OPTIONS = [
|
4
|
+
:build_id,
|
5
|
+
:project_name,
|
6
|
+
:remote_repository,
|
7
|
+
:branch,
|
8
|
+
:revision,
|
9
|
+
:working_path,
|
10
|
+
:repo_path,
|
11
|
+
:archive_path,
|
12
|
+
:build_path,
|
13
|
+
:revision_path,
|
14
|
+
:logger,
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
attr_accessor *VALID_OPTIONS
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
reset
|
21
|
+
end
|
22
|
+
|
23
|
+
def merge(params)
|
24
|
+
params.each do |key, value|
|
25
|
+
self.send("#{key}=", value)
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset
|
31
|
+
self.build_id = Time.now.strftime("%Y%m%d%H%M%S")
|
32
|
+
self.project_name = File.basename(`git rev-parse --show-toplevel`.chomp)
|
33
|
+
self.remote_repository = `git remote get-url origin`.chomp
|
34
|
+
self.branch = ENV.fetch("TARGET_BRANCH", "master")
|
35
|
+
self.revision = `git rev-parse #{branch}`.chomp
|
36
|
+
self.working_path = File.join("/var/tmp", project_name)
|
37
|
+
self.repo_path = File.join(working_path, "repo")
|
38
|
+
self.archive_path = File.join(working_path, "archive", build_id)
|
39
|
+
self.build_path = File.join(working_path, "build", build_id)
|
40
|
+
self.revision_path = File.join(archive_path, "revision.yml")
|
41
|
+
self.logger = Logger.new(STDOUT)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: app_builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- i2bskn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Application build utilities.
|
70
|
+
email:
|
71
|
+
- i2bskn@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- app_builder.gemspec
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/app_builder.rb
|
86
|
+
- lib/app_builder/archiver.rb
|
87
|
+
- lib/app_builder/base.rb
|
88
|
+
- lib/app_builder/builder.rb
|
89
|
+
- lib/app_builder/config.rb
|
90
|
+
- lib/app_builder/version.rb
|
91
|
+
homepage: https://github.com/i2bskn/app_builder
|
92
|
+
licenses: []
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.6.11
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Application build utilities.
|
114
|
+
test_files: []
|