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.
@@ -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
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gitee_pack.gemspec
4
+ gemspec
@@ -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.
@@ -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
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -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__)
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gitee_pack'
4
+
5
+ base, head = ARGV[0], ARGV[1]
6
+
7
+ start_at = Time.now
8
+ GiteePack.execute(base, head)
9
+ end_at = Time.now
10
+
11
+ puts "\033[32mComplete! cost time: #{end_at - start_at} seconds.\033[0m"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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
@@ -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,11 @@
1
+ module GiteePack
2
+ class Precompile
3
+ class << self
4
+ def with_webpack
5
+ Folder.rm_dir('public/webpacks')
6
+ `npm run build-vendor`
7
+ `npm run f-build`
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module GiteePack
2
+ VERSION = "1.0.0"
3
+ 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: []