prelands_rails 0.1.0 → 0.1.4
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 +4 -4
- data/.ci/dver.rb +5 -0
- data/.dockerignore +17 -0
- data/.gitignore +2 -1
- data/.gitlab-ci.yml +29 -0
- data/.rspec +0 -1
- data/Dockerfile +27 -0
- data/Gemfile.lock +609 -601
- data/Makefile +11 -0
- data/README.md +6 -0
- data/build_and_push.sh +4 -0
- data/docker-compose.local.yml +9 -0
- data/lib/prelands_rails/concerns/base.rb +11 -3
- data/lib/prelands_rails/create_simple_source/check_zip_files/extract_files.rb +2 -2
- data/lib/prelands_rails/create_simple_source/check_zip_files.rb +4 -0
- data/lib/prelands_rails/create_simple_source/upload.rb +1 -1
- data/lib/prelands_rails/create_simple_source/validate_zip_content/validate_css/css.rb +60 -0
- data/lib/prelands_rails/create_simple_source/validate_zip_content/validate_css.rb +35 -0
- data/lib/prelands_rails/create_simple_source/validate_zip_content/validate_html/html.rb +3 -3
- data/lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive.rb +88 -0
- data/lib/prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files.rb +31 -0
- data/lib/prelands_rails/create_simple_source/validate_zip_content/validate_js.rb +5 -1
- data/lib/prelands_rails/create_simple_source/validate_zip_content.rb +2 -2
- data/lib/prelands_rails/create_simple_source.rb +1 -0
- data/lib/prelands_rails/recompile_simple_source/download_zip.rb +39 -0
- data/lib/prelands_rails/recompile_simple_source/upload.rb +39 -0
- data/lib/prelands_rails/recompile_simple_source.rb +58 -0
- data/lib/prelands_rails/update_simple_source/validate_zip_content.rb +4 -6
- data/lib/prelands_rails/update_simple_source.rb +1 -0
- data/lib/prelands_rails/validate_simple_source.rb +1 -0
- data/lib/prelands_rails.rb +8 -2
- data/prelands_rails.gemspec +10 -7
- metadata +63 -24
- data/.travis.yml +0 -6
- data/lib/prelands_rails/version.rb +0 -3
data/Makefile
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
+
.PHONY: test all
|
2
|
+
|
1
3
|
DIR = $(shell pwd)
|
2
4
|
|
3
5
|
setup_local_gem:
|
4
6
|
bundle config local.prelands_rails $(DIR)
|
7
|
+
|
8
|
+
all:
|
9
|
+
@docker-compose -f docker-compose.local.yml build
|
10
|
+
|
11
|
+
test:
|
12
|
+
@docker-compose -f docker-compose.local.yml run runner rspec
|
13
|
+
|
14
|
+
build_and_push_docker:
|
15
|
+
./build_and_push.sh
|
data/README.md
CHANGED
@@ -2,3 +2,9 @@
|
|
2
2
|
|
3
3
|
Код, занимающийся валидацией и публикацией прелендов V4.
|
4
4
|
|
5
|
+
# How to publish gem
|
6
|
+
|
7
|
+
1. Bump version inside `prelands_rails.gemspec`.
|
8
|
+
2. Make commit & push to `master` branch.
|
9
|
+
3. Then checkout `tags` branch and `git rebase master` (accept theirs if there are any conflicts).
|
10
|
+
4. Then `git push` - and Gitlab CI publish the new version of the gem.
|
data/build_and_push.sh
ADDED
@@ -5,8 +5,11 @@ module PrelandsRails
|
|
5
5
|
|
6
6
|
private
|
7
7
|
|
8
|
-
RX_HTML_FILE
|
9
|
-
|
8
|
+
RX_HTML_FILE = /\.html/
|
9
|
+
RX_CSS_FILE = /\.css/.freeze
|
10
|
+
NAME_RX = /index_(\w{2})\.html/
|
11
|
+
# DIST_FOLDER = 'dist'
|
12
|
+
# KNOWN_FILES_EXTENSIONS = /\.(gif|jpe?g|tiff?|png|webp|bmp|mov|avi|wmv|flv|3gp|mp4|mpg|css|js|ico|icon)/.freeze
|
10
13
|
|
11
14
|
# извлекаем входящие html файлы из контекста
|
12
15
|
def incoming_html_files
|
@@ -18,8 +21,13 @@ module PrelandsRails
|
|
18
21
|
context.compiled_htmls.select { |key| key =~ RX_HTML_FILE }
|
19
22
|
end
|
20
23
|
|
24
|
+
# извлекаем входящие css файлы из контекста
|
25
|
+
def incoming_css_files
|
26
|
+
context.files_content.select { |key| key =~ RX_CSS_FILE }
|
27
|
+
end
|
28
|
+
|
21
29
|
def make_tmp_path
|
22
|
-
'tmp
|
30
|
+
'/tmp/%s' % SecureRandom.uuid
|
23
31
|
end
|
24
32
|
end
|
25
33
|
end
|
@@ -12,14 +12,14 @@ module PrelandsRails
|
|
12
12
|
next unless expected_files.find_index { |efile| efile.name == entry.name }.present?
|
13
13
|
|
14
14
|
# Extract
|
15
|
-
tmp_path =
|
15
|
+
tmp_path = make_tmp_path
|
16
16
|
entry.extract tmp_path
|
17
17
|
|
18
18
|
# Read into memory
|
19
19
|
content = entry.get_input_stream.read
|
20
20
|
|
21
21
|
# Remove tmp file
|
22
|
-
File.delete(tmp_path) if File.exist?(tmp_path)
|
22
|
+
# File.delete(tmp_path) if File.exist?(tmp_path)
|
23
23
|
|
24
24
|
[entry.name, content]
|
25
25
|
end.compact.to_h
|
@@ -27,6 +27,7 @@ module PrelandsRails
|
|
27
27
|
|
28
28
|
assures do
|
29
29
|
required(:files_content).value(type?: Hash) # js,html,css: { file_name => file_content, ... }
|
30
|
+
required(:incoming_files).value(type?: Array) # список всех файлов архива { ftype, name }
|
30
31
|
end
|
31
32
|
|
32
33
|
before do
|
@@ -56,6 +57,9 @@ module PrelandsRails
|
|
56
57
|
rx1 = /\.(css|js|html)/
|
57
58
|
files = @expected_files.select { |file| file.ftype == :file && file.name =~ rx1 }
|
58
59
|
context.files_content, context.tmp_paths = read_into_memory files, context.archive.tempfile
|
60
|
+
|
61
|
+
# фиксируем список всех файлов из архива
|
62
|
+
context.incoming_files = incoming_files
|
59
63
|
end
|
60
64
|
|
61
65
|
def incoming_files
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
class CreateSimpleSource
|
5
|
+
class ValidateZipContent
|
6
|
+
class ValidateCss
|
7
|
+
#
|
8
|
+
# Принимает строку с css и валидирует её.
|
9
|
+
# Правила, обязательные для всех css файлов.
|
10
|
+
#
|
11
|
+
class Css
|
12
|
+
attr_reader :errors
|
13
|
+
|
14
|
+
CUSTOM_FONTS = /\.(eot|woff|woff2|ttf)/.freeze
|
15
|
+
SVG_LINKS_DETECTED = /\.svg/.freeze
|
16
|
+
IMAGES_BAD_PATH = /\/images/.freeze
|
17
|
+
|
18
|
+
# @param [String] string Содержимое css файла.
|
19
|
+
def initialize(string)
|
20
|
+
@errors = []
|
21
|
+
@string = string
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid?
|
25
|
+
@errors = [
|
26
|
+
check_svg_links,
|
27
|
+
check_images_relative_paths,
|
28
|
+
check_custom_fonts_absence
|
29
|
+
].compact
|
30
|
+
|
31
|
+
@errors.none?
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# @return [nil] Если всё ОК
|
37
|
+
# @return [String] Иначе - вернёт сообщение об ошибке
|
38
|
+
|
39
|
+
def check_svg_links
|
40
|
+
return unless @string =~ SVG_LINKS_DETECTED
|
41
|
+
|
42
|
+
'Links to svg detected inside css file. Please, use inline variant of svg.'
|
43
|
+
end
|
44
|
+
|
45
|
+
def check_images_relative_paths
|
46
|
+
return unless @string =~ IMAGES_BAD_PATH
|
47
|
+
|
48
|
+
'Images urls in css files must be relative.'
|
49
|
+
end
|
50
|
+
|
51
|
+
def check_custom_fonts_absence
|
52
|
+
return unless @string =~ CUSTOM_FONTS
|
53
|
+
|
54
|
+
'Custom fonts detected in css files. Please, use Google fonts.'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
class CreateSimpleSource
|
5
|
+
class ValidateZipContent
|
6
|
+
#
|
7
|
+
# Валидирует все css файлы.
|
8
|
+
#
|
9
|
+
class ValidateCss
|
10
|
+
include ::PrelandsRails::AbstractInteractor
|
11
|
+
include ::Interactor
|
12
|
+
include ::Interactor::Contracts
|
13
|
+
include ::PrelandsRails::Base
|
14
|
+
|
15
|
+
expects do
|
16
|
+
required(:files_content).value(type?: Hash) # { file_name => file_content, ... }
|
17
|
+
end
|
18
|
+
|
19
|
+
assures do
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def act
|
24
|
+
errors =
|
25
|
+
incoming_css_files.map do |key, content|
|
26
|
+
content = Css.new(content)
|
27
|
+
next if content.valid?
|
28
|
+
[key, content.errors]
|
29
|
+
end.compact.to_h
|
30
|
+
fail! errors: errors if errors.any?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -86,7 +86,7 @@ module PrelandsRails
|
|
86
86
|
title_rx = /<title>[^<]+<\/title>/
|
87
87
|
return if @string[title_rx]
|
88
88
|
|
89
|
-
'Tag
|
89
|
+
'Tag `title` not found.'
|
90
90
|
end
|
91
91
|
|
92
92
|
def check_a_hrefs
|
@@ -97,10 +97,10 @@ module PrelandsRails
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def check_favicon
|
100
|
-
favicon_rx =
|
100
|
+
favicon_rx = /<link.+href="icon.ico">/
|
101
101
|
return if @string[favicon_rx]
|
102
102
|
|
103
|
-
'
|
103
|
+
'`link href="icon.ico"` not found.'
|
104
104
|
end
|
105
105
|
|
106
106
|
protected
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
class CreateSimpleSource
|
5
|
+
class ValidateZipContent
|
6
|
+
class ValidateIncomingFiles
|
7
|
+
class ZipArchive
|
8
|
+
attr_reader :errors
|
9
|
+
|
10
|
+
# @param [Array<{ftype, name}>] incoming_files
|
11
|
+
def initialize(incoming_files)
|
12
|
+
@errors = []
|
13
|
+
@incoming_files = incoming_files
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?
|
17
|
+
@errors = [
|
18
|
+
check_app_js,
|
19
|
+
check_app_css,
|
20
|
+
check_favicon,
|
21
|
+
check_svg_absence
|
22
|
+
].compact
|
23
|
+
|
24
|
+
@errors.none?
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @return [nil] Если `index.js` находится в корне zip-архива.
|
30
|
+
# @return [String] Иначе - вернёт сообщение об ошибке
|
31
|
+
def check_app_js
|
32
|
+
check 'index.js', 'index.js',
|
33
|
+
'The «index.js» JAVASCRIPT file is not found in the zip-archive',
|
34
|
+
'The «index.js» JAVASCRIPT file is not in root of the zip-archive: expected «index.js», got «%s»'
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_app_css
|
38
|
+
check 'index.css', 'index.css',
|
39
|
+
'The «index.css» STYLES file is not found in the zip-archive',
|
40
|
+
'The «index.css» STYLES file is not in root of the zip-archive: expected «index.css», got «%s»'
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_favicon
|
44
|
+
check 'icon.ico', /icon\.ico/,
|
45
|
+
'favicon file is not found in the zip-archive',
|
46
|
+
'favicon file is not in root of the zip-archive: got «%s»'
|
47
|
+
end
|
48
|
+
|
49
|
+
def check_svg_absence
|
50
|
+
checka /\.svg/, 'svg files detected, move inside css'
|
51
|
+
end
|
52
|
+
|
53
|
+
protected
|
54
|
+
|
55
|
+
def check(pattern, name, absent_error, wrong_place_error)
|
56
|
+
error = absent_error
|
57
|
+
|
58
|
+
@incoming_files.each do |file|
|
59
|
+
if file.name[pattern]
|
60
|
+
error = nil
|
61
|
+
unless file.name.index(name)&.zero?
|
62
|
+
error = wrong_place_error % file.name
|
63
|
+
end
|
64
|
+
break
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
error
|
69
|
+
end
|
70
|
+
|
71
|
+
# check absence
|
72
|
+
def checka(pattern, present_error)
|
73
|
+
error = nil
|
74
|
+
|
75
|
+
@incoming_files.each do |file|
|
76
|
+
if file.name[pattern]
|
77
|
+
error = present_error
|
78
|
+
break
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
error
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
class CreateSimpleSource
|
5
|
+
class ValidateZipContent
|
6
|
+
#
|
7
|
+
# Проверит наличие файлов в zip-архиве и их требуемую вложенность.
|
8
|
+
#
|
9
|
+
class ValidateIncomingFiles
|
10
|
+
include ::PrelandsRails::AbstractInteractor
|
11
|
+
include ::Interactor
|
12
|
+
include ::Interactor::Contracts
|
13
|
+
include ::PrelandsRails::Base
|
14
|
+
|
15
|
+
expects do
|
16
|
+
required(:incoming_files).value(type?: Array) # список всех файлов архива { ftype, name }
|
17
|
+
end
|
18
|
+
|
19
|
+
assures do
|
20
|
+
end
|
21
|
+
|
22
|
+
def act
|
23
|
+
zip_archive = ZipArchive.new context.incoming_files
|
24
|
+
unless zip_archive.valid?
|
25
|
+
fail! errors: zip_archive.errors.join('; ')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -16,13 +16,17 @@ module PrelandsRails
|
|
16
16
|
end
|
17
17
|
|
18
18
|
assures do
|
19
|
+
optional(:warnings).maybe(type?: Array)
|
20
|
+
end
|
19
21
|
|
22
|
+
before do
|
23
|
+
context.warnings ||= []
|
20
24
|
end
|
21
25
|
|
22
26
|
def act
|
23
27
|
content = context[:files_content]['index.js']
|
24
28
|
content = Js.new(content)
|
25
|
-
|
29
|
+
context.warnings += content.errors unless content.valid?
|
26
30
|
end
|
27
31
|
|
28
32
|
on_breach { |breaches| bad_expects breaches }
|
@@ -15,10 +15,10 @@ module PrelandsRails
|
|
15
15
|
end
|
16
16
|
|
17
17
|
assures do
|
18
|
-
|
18
|
+
optional(:warnings).maybe(type?: Array)
|
19
19
|
end
|
20
20
|
|
21
|
-
organize ValidateHtml, ValidateJs
|
21
|
+
organize ValidateIncomingFiles, ValidateHtml, ValidateJs, ValidateCss
|
22
22
|
|
23
23
|
on_breach { |breaches| bad_expects breaches }
|
24
24
|
end
|
@@ -34,6 +34,7 @@ module PrelandsRails
|
|
34
34
|
required(:files_content).value(type?: Hash) # распакованные файлы из архива { file_name[String] => file_content[String], ... }
|
35
35
|
required(:compiled_htmls).value(type?: Hash) # скомпилированные исходники { file_name[String] => compiled_content[String], ... }
|
36
36
|
required(:preland_simple_source).filled
|
37
|
+
optional(:warnings).maybe(type?: Array)
|
37
38
|
end
|
38
39
|
|
39
40
|
organize DetectIncomingLocales,
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
class RecompileSimpleSource
|
5
|
+
#
|
6
|
+
# Скачает и разместит в cache-директории zip-архив с исходником лендинга.
|
7
|
+
#
|
8
|
+
class DownloadZip
|
9
|
+
include ::PrelandsRails::AbstractInteractor
|
10
|
+
include ::Interactor
|
11
|
+
include ::Interactor::Contracts
|
12
|
+
include ::PrelandsRails::Base
|
13
|
+
|
14
|
+
expects do
|
15
|
+
required(:prelanding).filled #.value(type?: ::Preland)
|
16
|
+
end
|
17
|
+
|
18
|
+
assures do
|
19
|
+
required(:archive).filled # Rack::Test::UploadedFile | ActionDispatch::Http::UploadedFile
|
20
|
+
required(:tmp_dest).value(type?: String) # путь к временному файлу
|
21
|
+
end
|
22
|
+
|
23
|
+
def act
|
24
|
+
archive_url = prelanding.preland_simple_source.archive.url
|
25
|
+
destination = make_tmp_path
|
26
|
+
|
27
|
+
IO.copy_stream(Kernel.open(archive_url), destination)
|
28
|
+
|
29
|
+
context.archive = ActionDispatch::Http::UploadedFile.new(tempfile: destination)
|
30
|
+
context.tmp_dest = destination
|
31
|
+
end
|
32
|
+
|
33
|
+
on_breach { |breaches| bad_expects breaches }
|
34
|
+
|
35
|
+
delegate :prelanding,
|
36
|
+
:to => :context
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
class RecompileSimpleSource
|
5
|
+
#
|
6
|
+
# Сначала удалить файлы преленда из директории +aws_prefix+, затем загрузить.
|
7
|
+
#
|
8
|
+
class Upload
|
9
|
+
include ::PrelandsRails::AbstractInteractor
|
10
|
+
include ::Interactor
|
11
|
+
include ::Interactor::Contracts
|
12
|
+
include ::PrelandsRails::UpdateSimpleSource::Upload::DeleteCompiledFiles
|
13
|
+
|
14
|
+
expects do
|
15
|
+
required(:archive).filled # Входящий архив с исходниками от фрилансера. Rack::Test::UploadedFile | ActionDispatch::Http::UploadedFile
|
16
|
+
required(:compiled_htmls).value(type?: Hash) # скомпилированные исходники { file_name[String] => compiled_content[String], ... }
|
17
|
+
required(:s3_credentials).schema do
|
18
|
+
required(:access_key).filled(:str?)
|
19
|
+
required(:secret_key).filled(:str?)
|
20
|
+
required(:region).filled(:str?)
|
21
|
+
end
|
22
|
+
required(:bucket_names).value(type?: Array)
|
23
|
+
required(:aws_prefix).value(type?: String)
|
24
|
+
required(:files_content).value(type?: Hash) # { file_name => file_content, ... }
|
25
|
+
end
|
26
|
+
|
27
|
+
assures do
|
28
|
+
end
|
29
|
+
|
30
|
+
def act
|
31
|
+
delete_compiled_files
|
32
|
+
result = ::PrelandsRails::CreateSimpleSource::Upload.call context
|
33
|
+
fail! errors: result.errors unless result.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
on_breach { |breaches| bad_expects breaches }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PrelandsRails
|
4
|
+
#
|
5
|
+
# Перекомпилировать преленд на основе уже загруженного в aws архива.
|
6
|
+
#
|
7
|
+
class RecompileSimpleSource
|
8
|
+
include ::PrelandsRails::AbstractInteractor
|
9
|
+
include ::Interactor::Organizer
|
10
|
+
include ::Interactor::Contracts
|
11
|
+
|
12
|
+
expects do
|
13
|
+
required(:prelanding).filled#.value(type?: ::Preland)
|
14
|
+
required(:static_js_path).value(type?: String)
|
15
|
+
required(:s3_credentials).schema do
|
16
|
+
required(:access_key).filled(:str?)
|
17
|
+
required(:secret_key).filled(:str?)
|
18
|
+
required(:region).filled(:str?)
|
19
|
+
end
|
20
|
+
required(:bucket_names).value(type?: Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
before do
|
24
|
+
context.expected_locales = context.prelanding.locales.map(&:short_name)
|
25
|
+
context.aws_prefix = context.prelanding.preland_simple_source.aws_prefix
|
26
|
+
end
|
27
|
+
|
28
|
+
assures do
|
29
|
+
required(:expected_locales).filled(type?: Array)
|
30
|
+
required(:aws_prefix).value(type?: String)
|
31
|
+
required(:archive).filled
|
32
|
+
required(:tmp_dest).value(type?: String)
|
33
|
+
required(:incoming_locales).filled(type?: Array)
|
34
|
+
required(:files_content).value(type?: Hash)
|
35
|
+
required(:compiled_htmls).value(type?: Hash)
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
clear_tmp_dest
|
40
|
+
context.prelanding.preland_simple_source.update_columns updated_at: Time.now
|
41
|
+
end
|
42
|
+
|
43
|
+
organize DownloadZip,
|
44
|
+
::PrelandsRails::CreateSimpleSource::DetectIncomingLocales,
|
45
|
+
::PrelandsRails::CreateSimpleSource::CheckZipFiles,
|
46
|
+
::PrelandsRails::CreateSimpleSource::Compile,
|
47
|
+
Upload
|
48
|
+
|
49
|
+
on_breach { |breaches| bad_expects breaches }
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def clear_tmp_dest
|
54
|
+
td = context.tmp_dest
|
55
|
+
File.delete(td) if File.exist?(td)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -13,17 +13,15 @@ module PrelandsRails
|
|
13
13
|
end
|
14
14
|
|
15
15
|
assures do
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
before do
|
20
|
-
|
16
|
+
optional(:warnings).maybe(type?: Array)
|
21
17
|
end
|
22
18
|
|
23
19
|
def act
|
24
20
|
if context.files_content
|
25
21
|
result = ::PrelandsRails::CreateSimpleSource::ValidateZipContent.call context
|
26
|
-
|
22
|
+
if result.success?
|
23
|
+
context.warnings = result.warnings
|
24
|
+
else
|
27
25
|
fail!(errors: result.errors)
|
28
26
|
end
|
29
27
|
end
|
@@ -34,6 +34,7 @@ module PrelandsRails
|
|
34
34
|
optional(:files_content).maybe(type?: Hash) # распакованные файлы из архива { file_name[String] => file_content[String], ... }
|
35
35
|
optional(:compiled_htmls).value(type?: Hash) # скомпилированные исходники { file_name[String] => compiled_content[String], ... }
|
36
36
|
required(:preland_simple_source).filled
|
37
|
+
optional(:warnings).maybe(type?: Array)
|
37
38
|
end
|
38
39
|
|
39
40
|
organize ::PrelandsRails::CreateSimpleSource::DetectIncomingLocales,
|
data/lib/prelands_rails.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'prelands_rails/version'
|
4
|
-
|
5
3
|
require 'zip'
|
6
4
|
require 'interactor'
|
7
5
|
require 'interactor/contracts'
|
@@ -18,7 +16,11 @@ require 'prelands_rails/create_simple_source/check_zip_files'
|
|
18
16
|
require 'prelands_rails/create_simple_source/validate_zip_content/validate_html/html'
|
19
17
|
require 'prelands_rails/create_simple_source/validate_zip_content/validate_html'
|
20
18
|
require 'prelands_rails/create_simple_source/validate_zip_content/validate_js/js'
|
19
|
+
require 'prelands_rails/create_simple_source/validate_zip_content/validate_css/css'
|
20
|
+
require 'prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files/zip_archive'
|
21
21
|
require 'prelands_rails/create_simple_source/validate_zip_content/validate_js'
|
22
|
+
require 'prelands_rails/create_simple_source/validate_zip_content/validate_css'
|
23
|
+
require 'prelands_rails/create_simple_source/validate_zip_content/validate_incoming_files'
|
22
24
|
require 'prelands_rails/create_simple_source/validate_zip_content'
|
23
25
|
require 'prelands_rails/create_simple_source/compile/html_compiler'
|
24
26
|
require 'prelands_rails/create_simple_source/compile'
|
@@ -37,5 +39,9 @@ require 'prelands_rails/update_simple_source'
|
|
37
39
|
|
38
40
|
require 'prelands_rails/validate_simple_source'
|
39
41
|
|
42
|
+
require 'prelands_rails/recompile_simple_source/upload'
|
43
|
+
require 'prelands_rails/recompile_simple_source/download_zip'
|
44
|
+
require 'prelands_rails/recompile_simple_source'
|
45
|
+
|
40
46
|
module PrelandsRails
|
41
47
|
end
|
data/prelands_rails.gemspec
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if File.exist?('lib/prelands_rails/version')
|
2
|
+
lib = File.expand_path("lib", __dir__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
end
|
4
5
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "prelands_rails"
|
7
|
-
spec.version =
|
8
|
+
spec.version = "0.1.4"
|
8
9
|
spec.authors = ["C80609A"]
|
9
10
|
spec.email = ["c080609a@gmail.com"]
|
10
11
|
|
@@ -34,15 +35,17 @@ Gem::Specification.new do |spec|
|
|
34
35
|
spec.add_dependency 'aws-sdk'
|
35
36
|
|
36
37
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
38
|
+
spec.add_development_dependency 'mimemagic'
|
39
|
+
spec.add_development_dependency 'sqlite3'
|
40
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
37
41
|
spec.add_development_dependency 'rails', '6.0.2.1'
|
38
42
|
spec.add_development_dependency 'byebug'
|
39
43
|
spec.add_development_dependency 'awesome_print'
|
40
44
|
spec.add_development_dependency 'factory_bot_rails'
|
41
45
|
spec.add_development_dependency 'database_cleaner'
|
42
|
-
spec.add_development_dependency '
|
46
|
+
spec.add_development_dependency 'rspec'
|
43
47
|
spec.add_development_dependency 'rspec-rails', '~> 4.0'
|
44
48
|
spec.add_development_dependency 'rails-controller-testing'
|
45
49
|
spec.add_development_dependency 'paperclip', '5.0.0'
|
46
|
-
spec.add_development_dependency '
|
47
|
-
spec.add_development_dependency 'sqlite3'
|
50
|
+
spec.add_development_dependency 'tzinfo-data'
|
48
51
|
end
|