gitee_pack 1.0.0
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 +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +28 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/gitee_pack +11 -0
- data/bin/setup +8 -0
- data/gitee_pack.gemspec +18 -0
- data/lib/gitee_pack.rb +16 -0
- data/lib/gitee_pack/diff.rb +56 -0
- data/lib/gitee_pack/filer.rb +35 -0
- data/lib/gitee_pack/folder.rb +29 -0
- data/lib/gitee_pack/precompile.rb +11 -0
- data/lib/gitee_pack/version.rb +3 -0
- data/lib/gitee_pack/worker.rb +41 -0
- metadata +60 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9167ffab00077990f5de2a6dedbf981ebf86c5e246cb94fdff655177e7d61656
|
|
4
|
+
data.tar.gz: 3cb23c0cdc089eeda2021a1bfcf91ee53827993166341e4e9b2975a44f865191
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 15cbca079fb2b48658af5116bcd4978431a846a81b41c2c10fe2d2a8ebdb19b33307bbb3196ce3ae097922c958cb809f58102a70eb325d56552d417cdc0a474b
|
|
7
|
+
data.tar.gz: 65a87e0230a236f586471d2294dfdea6e744fd0066b7f69c9a458b96f9f03031b8fcf5a5a62cddb181814737dfd2b8f8876914f55380d13443cc2645a1c4bcc0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 TODO: Write your name
|
|
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,28 @@
|
|
|
1
|
+
# GiteePack
|
|
2
|
+
|
|
3
|
+
一个GiteePremium增量打包工具
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
在gitee-premium目录执行:
|
|
8
|
+
|
|
9
|
+
$ gem install gitee_pack
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
在gitee-premium目录执行:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
$ gitee_pack [base] [head]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
base: Commit提交的SHA值作为对比起点
|
|
20
|
+
|
|
21
|
+
head: Commit提交的SHA值作为对比终点
|
|
22
|
+
|
|
23
|
+
示例:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
$ gitee_pack a9b6296 6ac0f97
|
|
27
|
+
```
|
|
28
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "gitee_pack"
|
|
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/gitee_pack
ADDED
data/bin/setup
ADDED
data/gitee_pack.gemspec
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require_relative 'lib/gitee_pack/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "gitee_pack"
|
|
5
|
+
spec.version = GiteePack::VERSION
|
|
6
|
+
spec.authors = ["jk-sun"]
|
|
7
|
+
spec.email = ["jk-sun@qq.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = %q{It's incremental packager for Gitee Premium.}
|
|
10
|
+
spec.homepage = "https://github.com/JK-Sun/gitee_pack"
|
|
11
|
+
spec.license = "MIT"
|
|
12
|
+
|
|
13
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
14
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
15
|
+
end
|
|
16
|
+
spec.executables = ["gitee_pack"]
|
|
17
|
+
spec.require_paths = ["lib"]
|
|
18
|
+
end
|
data/lib/gitee_pack.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
require 'gitee_pack/version'
|
|
4
|
+
require 'gitee_pack/diff'
|
|
5
|
+
require 'gitee_pack/folder'
|
|
6
|
+
require 'gitee_pack/filer'
|
|
7
|
+
require 'gitee_pack/precompile'
|
|
8
|
+
require 'gitee_pack/worker'
|
|
9
|
+
|
|
10
|
+
module GiteePack
|
|
11
|
+
class CmdError < StandardError; end
|
|
12
|
+
|
|
13
|
+
def self.execute(base, head, options = {})
|
|
14
|
+
Worker.new(base, head).execute
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module GiteePack
|
|
2
|
+
class Diff
|
|
3
|
+
attr_reader :empty_folders, :delete_files, :cp_files
|
|
4
|
+
|
|
5
|
+
def initialize(base, head)
|
|
6
|
+
@base = base
|
|
7
|
+
@head = head
|
|
8
|
+
@precompile = false
|
|
9
|
+
@empty_folders = []
|
|
10
|
+
@delete_files = []
|
|
11
|
+
@cp_files = []
|
|
12
|
+
|
|
13
|
+
init_diff_status
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def diff_files
|
|
17
|
+
result = `git diff #{@base} #{@head} --name-only`
|
|
18
|
+
raise CmdError, 'cmd error' if result.empty?
|
|
19
|
+
|
|
20
|
+
result.split("\n")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def diff_files_with_status
|
|
24
|
+
result = `git diff #{@base} #{@head} --name-status`
|
|
25
|
+
raise CmdError, 'cmd error' if result.empty?
|
|
26
|
+
|
|
27
|
+
result.split("\n")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def precompile?
|
|
31
|
+
@precompile
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def init_diff_status
|
|
37
|
+
diff_files.each do |file|
|
|
38
|
+
if file.start_with?('app/assets/javascripts/webpack')
|
|
39
|
+
@precompile = true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if Dir.exist?(file)
|
|
43
|
+
@empty_folders << file
|
|
44
|
+
next
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
unless File.exist?(file)
|
|
48
|
+
@delete_files << file
|
|
49
|
+
next
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
@cp_files << file
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module GiteePack
|
|
2
|
+
class Filer
|
|
3
|
+
class << self
|
|
4
|
+
def cp_diff_files(files)
|
|
5
|
+
files.each do |file|
|
|
6
|
+
dirname = File.join(Folder.upgrade_files_dir, File.dirname(file))
|
|
7
|
+
FileUtils.mkdir_p dirname
|
|
8
|
+
FileUtils.cp file, dirname
|
|
9
|
+
puts "cp #{file} #{dirname}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def cp_webpack_files
|
|
14
|
+
dirname = File.join(Folder.upgrade_files_dir, 'public/webpacks')
|
|
15
|
+
FileUtils.mkdir_p dirname
|
|
16
|
+
FileUtils.cp_r 'public/webpacks/.', dirname
|
|
17
|
+
puts "cp -r public/webpacks/. #{dirname}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def g_file(path, content = [])
|
|
21
|
+
File.open(path, 'w') do |f|
|
|
22
|
+
f.write("#{content.join("\n")}\n")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def g_delete_file(content = [])
|
|
27
|
+
g_file(File.join(Folder.upgrade_dir, 'delete.txt'), content)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def g_diff_file(content = [])
|
|
31
|
+
g_file(File.join(Folder.upgrade_dir, 'diff.txt'), content)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
module GiteePack
|
|
4
|
+
class Folder
|
|
5
|
+
class << self
|
|
6
|
+
def mkdir_upgrade
|
|
7
|
+
rm_dir(upgrade_dir)
|
|
8
|
+
FileUtils.mkdir_p(upgrade_files_dir)
|
|
9
|
+
puts "mkdir #{upgrade_dir}"
|
|
10
|
+
puts "mkdir #{upgrade_files_dir}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def upgrade_dir
|
|
14
|
+
@upgrade_dir ||= "upgrade-#{Time.now.strftime('%Y%m%d')}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def upgrade_files_dir
|
|
18
|
+
@upgrade_files_dir ||= File.join(upgrade_dir, 'files')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def rm_dir(dir)
|
|
22
|
+
if Dir.exist?(dir)
|
|
23
|
+
`rm -rf #{dir}`
|
|
24
|
+
puts "rm -rf #{dir}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module GiteePack
|
|
2
|
+
class Worker
|
|
3
|
+
def initialize(base, head)
|
|
4
|
+
@base = base
|
|
5
|
+
@head = head
|
|
6
|
+
@diff = Diff.new(@base, @head)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def execute
|
|
10
|
+
Folder.mkdir_upgrade
|
|
11
|
+
Filer.cp_diff_files(@diff.cp_files)
|
|
12
|
+
|
|
13
|
+
if @diff.precompile?
|
|
14
|
+
Precompile.with_webpack
|
|
15
|
+
Filer.cp_webpack_files
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Filer.g_diff_file(@diff.diff_files_with_status)
|
|
19
|
+
Filer.g_delete_file(@diff.delete_files)
|
|
20
|
+
|
|
21
|
+
puts_empty_folders
|
|
22
|
+
puts_delete_files
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def puts_delete_files
|
|
28
|
+
unless @diff.delete_files.empty?
|
|
29
|
+
puts "\n\033[33mDelete Files:\n"
|
|
30
|
+
puts "#{@diff.delete_files.join("\n")}\033[0m"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def puts_empty_folders
|
|
35
|
+
unless @diff.empty_folders.empty?
|
|
36
|
+
puts "\n\033[33mEmpty Folders:\n"
|
|
37
|
+
puts "#{@diff.empty_folders.join("\n")}\033[0m"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gitee_pack
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- jk-sun
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
- jk-sun@qq.com
|
|
16
|
+
executables:
|
|
17
|
+
- gitee_pack
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- ".gitignore"
|
|
22
|
+
- Gemfile
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- Rakefile
|
|
26
|
+
- bin/console
|
|
27
|
+
- bin/gitee_pack
|
|
28
|
+
- bin/setup
|
|
29
|
+
- gitee_pack.gemspec
|
|
30
|
+
- lib/gitee_pack.rb
|
|
31
|
+
- lib/gitee_pack/diff.rb
|
|
32
|
+
- lib/gitee_pack/filer.rb
|
|
33
|
+
- lib/gitee_pack/folder.rb
|
|
34
|
+
- lib/gitee_pack/precompile.rb
|
|
35
|
+
- lib/gitee_pack/version.rb
|
|
36
|
+
- lib/gitee_pack/worker.rb
|
|
37
|
+
homepage: https://github.com/JK-Sun/gitee_pack
|
|
38
|
+
licenses:
|
|
39
|
+
- MIT
|
|
40
|
+
metadata: {}
|
|
41
|
+
post_install_message:
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
requirements: []
|
|
56
|
+
rubygems_version: 3.1.2
|
|
57
|
+
signing_key:
|
|
58
|
+
specification_version: 4
|
|
59
|
+
summary: It's incremental packager for Gitee Premium.
|
|
60
|
+
test_files: []
|