gitee_pack 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f4e4fc20534e610006456f1253a49882b4d7366579141ab00268e8fc77b8f9d
4
- data.tar.gz: d4e748f744e3f468974e86d1a9ae3458a0b6d4e534ee836d709eafb9eb54be7e
3
+ metadata.gz: b9ce148ff6e484fdb94e4aa8277d04cffb7f0eabb5898231d991c47448217cb4
4
+ data.tar.gz: aef311b7bec117c679374c73293b6b97f89485357013aaea24cabc5c721c2660
5
5
  SHA512:
6
- metadata.gz: 131088c837eef33d4e89c723348540fb9413ecf8d4fddd87277a6cc78aeeb6e88bcef4b195020e8b46876cb041b3e9abc00e0bb54aee277b3634f88528c25eae
7
- data.tar.gz: 51d709aba694a05a51d6f19c5ea08e080eb19f2827c16ea17d3606f85f5a85235b9fd4aa72bc2d280e593b3a83a1da72c19fad45ff967b7cd7e04acbb4166612
6
+ metadata.gz: 6a282102f070862ae173c4717a8529fbf6aa5a1dfc561e3435f493bd276cdae265dc5daab4c5362143e079b599446743ac7e31e9a16c135ed6e82b2a68dc6b81
7
+ data.tar.gz: 72cf6760cc6549e0bca93e23cf910de8e784a0b0991bbd14c3cb8d7de984afee8e5d0b89ae80ca540000c86f23039c869da39104ba9a6911dc8ae426d0ecad80
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 TODO: Write your name
3
+ Copyright (c) 2020 jk-sun
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -51,3 +51,10 @@ gitee-path: gitee-premium的绝对路径
51
51
  $ ./update.sh /home/gite/gitee-premium/gitee
52
52
  ```
53
53
 
54
+ ## TODO
55
+
56
+ - 支持中文文件名打包
57
+ - 支持gem打包
58
+ - 源码中记录版本信息功能
59
+ - ~~备份功能~~
60
+
@@ -2,6 +2,15 @@
2
2
 
3
3
  require 'gitee_pack'
4
4
 
5
+ HELP_CMD = ['-v', '-h', '--help'].freeze
6
+
7
+ if HELP_CMD.include?(ARGV[0])
8
+ GiteePack.logger.debug "Usage: #{File.basename($0)} [base] [head]"
9
+ GiteePack.logger.debug "Version: #{GiteePack::VERSION}"
10
+ exit 0
11
+ end
12
+
13
+
5
14
  base, head = ARGV[0], ARGV[1]
6
15
 
7
16
  start_at = Time.now
@@ -1,5 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
+ # Check parameter
3
4
  GITEE_PATH=$1
4
5
  if [ ! $GITEE_PATH ]; then
5
6
  printf "\033[31mERROR: gitee-path cannot not be empty.\033[0m\n"
@@ -11,6 +12,7 @@ if [ $FINAL = '/' ]; then
11
12
  GITEE_PATH=${GITEE_PATH%?}
12
13
  fi
13
14
 
15
+ # Check path
14
16
  APP_PATH=$GITEE_PATH/app
15
17
  CONFIG_APTH=$GITEE_PATH/config
16
18
  DB_APTH=$GITEE_PATH/db
@@ -19,9 +21,25 @@ if [ ! -d $APP_PATH ] || [ ! -d $CONFIG_PATH ] || [ ! -d $DB_PATH ]; then
19
21
  exit 1
20
22
  fi
21
23
 
22
- cp -r files/* $GITEE_PATH
23
- echo cp -r files/\* $GITEE_PATH
24
+ # Backup
25
+ BACKUP_DIR="$(dirname $GITEE_PATH)/backup/`date "+%Y%m%d%H%M%S"`"
26
+ echo mkdir -p $BACKUP_DIR
27
+ mkdir -p $BACKUP_DIR
28
+ echo cp -r $GITEE_PATH $BACKUP_DIR
29
+ cp -r $GITEE_PATH $BACKUP_DIR
30
+ if [ $? -ne 0 ]; then
31
+ printf "\033[31mERROR: Gitee backup failed.\033[0m\n"
32
+ exit 1
33
+ fi
24
34
 
35
+ # Delete webpacks dir
36
+ WEBPACK_PATH=$GITEE_PATH/public/webpacks
37
+ if [ -d files/public/webpacks ] && [ -d $WEBPACK_PATH ]; then
38
+ rm -rf $WEBPACK_PATH
39
+ echo rm -rf $WEBPACK_PATH
40
+ fi
41
+
42
+ # Delete files with delete.txt
25
43
  DELETE_FILE=delete.txt
26
44
  if [ -f $DELETE_FILE ]; then
27
45
  while read LINE
@@ -31,5 +49,9 @@ if [ -f $DELETE_FILE ]; then
31
49
  done < $DELETE_FILE
32
50
  fi
33
51
 
52
+ # Update files
53
+ cp -rf files/* $GITEE_PATH
54
+ echo cp -rf files/\* $GITEE_PATH
55
+
34
56
  exit 0
35
57
 
@@ -1,9 +1,10 @@
1
1
  module GiteePack
2
2
  class Diff
3
- attr_reader :empty_folders, :delete_files, :cp_files
3
+ attr_reader :empty_folders, :delete_files, :cp_files, :webpack_files
4
4
 
5
5
  IGNORE_FILES = [
6
6
  'config/gitee.yml',
7
+ 'config/gitee.yml.example',
7
8
  'config/database.yml',
8
9
  'config/startup.yml',
9
10
  'app/assets/javascripts/webpack/webide'
@@ -12,10 +13,10 @@ module GiteePack
12
13
  def initialize(base, head)
13
14
  @base = base
14
15
  @head = head
15
- @precompile = false
16
16
  @empty_folders = []
17
17
  @delete_files = []
18
18
  @cp_files = []
19
+ @webpack_files = []
19
20
 
20
21
  init_list_by_files
21
22
  end
@@ -34,8 +35,8 @@ module GiteePack
34
35
  result.split("\n")
35
36
  end
36
37
 
37
- def precompile?
38
- @precompile
38
+ def has_webpack_file?
39
+ !webpack_files.empty?
39
40
  end
40
41
 
41
42
  private
@@ -55,7 +56,9 @@ module GiteePack
55
56
  diff_files.each do |file|
56
57
  next if IGNORE_FILES.include?(file)
57
58
 
58
- file.start_with?('app/assets/javascripts/webpack') && @precompile = true
59
+ if file.start_with?('app/assets/javascripts/webpack')
60
+ @webpack_files << file
61
+ end
59
62
 
60
63
  if Dir.exist?(file)
61
64
  @empty_folders << file
@@ -18,7 +18,7 @@ module GiteePack
18
18
  end
19
19
 
20
20
  def cp_update_file
21
- filepath = File.join(File.dirname(__FILE__), 'exe/update.sh')
21
+ filepath = File.join(File.expand_path('../../../', __FILE__), 'exe/update.sh')
22
22
  FileUtils.cp filepath, Folder.upgrade_dir
23
23
  GiteePack.logger.debug "cp #{filepath} #{Folder.upgrade_dir}"
24
24
  end
@@ -36,6 +36,10 @@ module GiteePack
36
36
  def g_diff_file(content = [])
37
37
  g_file(File.join(Folder.upgrade_dir, 'diff.txt'), content)
38
38
  end
39
+
40
+ def g_commit_file(content = [])
41
+ g_file(File.join(Folder.upgrade_dir, 'commit.txt'), content)
42
+ end
39
43
  end
40
44
  end
41
45
  end
@@ -3,8 +3,7 @@ module GiteePack
3
3
  class << self
4
4
  def with_webpack
5
5
  Folder.rm_dir('public/webpacks')
6
- `npm run build-vendor`
7
- `npm run f-build`
6
+ `npm run build-vendor && npm run f-build`
8
7
  end
9
8
  end
10
9
  end
@@ -1,3 +1,3 @@
1
1
  module GiteePack
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -10,13 +10,14 @@ module GiteePack
10
10
  Folder.mkdir_upgrade
11
11
  Filer.cp_diff_files(@diff.cp_files)
12
12
 
13
- if @diff.precompile?
13
+ if @diff.has_webpack_file?
14
14
  Precompile.with_webpack
15
15
  Filer.cp_webpack_files
16
16
  end
17
17
 
18
18
  Filer.g_diff_file(@diff.diff_files_with_status)
19
19
  Filer.g_delete_file(@diff.delete_files)
20
+ Filer.g_commit_file(["old: #{@base}", "new: #{@head}"])
20
21
  Filer.cp_update_file
21
22
 
22
23
  puts_empty_folders
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitee_pack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jk-sun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -23,13 +23,11 @@ files:
23
23
  - LICENSE.txt
24
24
  - README.md
25
25
  - Rakefile
26
- - bin/console
27
26
  - bin/gitee_pack
28
- - bin/setup
27
+ - exe/update.sh
29
28
  - gitee_pack.gemspec
30
29
  - lib/gitee_pack.rb
31
30
  - lib/gitee_pack/diff.rb
32
- - lib/gitee_pack/exe/update.sh
33
31
  - lib/gitee_pack/filer.rb
34
32
  - lib/gitee_pack/folder.rb
35
33
  - lib/gitee_pack/logger.rb
@@ -1,14 +0,0 @@
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/setup DELETED
@@ -1,8 +0,0 @@
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