platformos-check 0.4.13 → 0.4.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3d6f6042c319fcddd4ffcfd7448d2f1fa23f77e7f10839b1cc77b667bfe5b13
4
- data.tar.gz: b151f8a69281c760f476ac5d1e849a079691f2607f54093e03f3dd64e7b985aa
3
+ metadata.gz: 6e71a05c1655cf1a33b9290f29812cfefffaf5c221a953536f28cd46588f604d
4
+ data.tar.gz: ecc1f13f479711da984373e405f59b5ae55c6c558eef8dc172c1d1d9670ea4e6
5
5
  SHA512:
6
- metadata.gz: 377ff80d76ac4a465bca202d949193ea7b4f836df04068be7eece864eb74e17823e008f983831cd8e259a532e3c1b93d83b210480c3c1ebb8440e113598ce498
7
- data.tar.gz: 34c02ebc74de8ac8d9bd193f502b7ebef6de635df4eb87bdb3a2454bafab841896008a8b5e67a8057ec770b08d9fad5f1e9a24e056bed65f7699c1d819ea9839
6
+ metadata.gz: 496da6087ec91931dec08e7a3939a0b02e0eb43051dd59f7e363a11989be1d59d097380d50628168b088728a86edd978a738e42f0d27207842312767da7f8d87
7
+ data.tar.gz: 5786d06421eefbc59bcd2c7a5eba753db923875f89c170e6918b3a46f2db94bc22a99bb723125ffe382633b93b7e60b6046af9e7f2ba62c69f6f6d6271164839
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ v0.4.14 / 2024-10-11
2
+ ==================
3
+
4
+ * Add support for module overwrite
5
+
1
6
  v0.4.13 / 2024-10-07
2
7
  ==================
3
8
 
@@ -1,2 +1,2 @@
1
1
 
2
- {"revision":"f54926032237f368cd5f4737ddb64d8522474225"}
2
+ {"revision":"57d415b98a26ca47bb6449b1433e8f009a3ca3b9"}
@@ -6,20 +6,20 @@ require "pathname"
6
6
 
7
7
  module PlatformosCheck
8
8
  class App
9
- API_CALLS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/api_call_notifications|api_calls)/(.+)\.liquid\z}
10
- ASSETS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)assets/}
11
- EMAILS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/email_notifications|emails)/(.+)\.liquid\z}
12
- GRAPHQL_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(graph_queries|graphql)s?/(.+)\.graphql\z}
13
-
14
- MIGRATIONS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)migrations/(.+)\.liquid\z}
15
- PAGES_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(pages|views/pages)/(.+).liquid\z}
16
- PARTIALS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/partials|lib)/(.+)\.liquid\z}
17
- FORMS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(form_configurations|forms)/(.+)\.liquid\z}
18
- LAYOUTS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/layouts)/(.+).liquid\z}
19
- SCHEMA_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(custom_model_types|model_schemas|schema)/(.+)\.yml\z}
20
- SMSES_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/sms_notifications|smses)/(.+)\.liquid\z}
9
+ API_CALLS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/api_call_notifications|api_calls)/(.+)\.liquid\z}
10
+ ASSETS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)assets/}
11
+ EMAILS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/email_notifications|emails)/(.+)\.liquid\z}
12
+ GRAPHQL_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(graph_queries|graphql)s?/(.+)\.graphql\z}
13
+
14
+ MIGRATIONS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)migrations/(.+)\.liquid\z}
15
+ PAGES_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(pages|views/pages)/(.+).liquid\z}
16
+ PARTIALS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(views/partials|lib)/(.+)\.liquid\z}
17
+ FORMS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(form_configurations|forms)/(.+)\.liquid\z}
18
+ LAYOUTS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(views/layouts)/(.+).liquid\z}
19
+ SCHEMA_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(custom_model_types|model_schemas|schema)/(.+)\.yml\z}
20
+ SMSES_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/sms_notifications|smses)/(.+)\.liquid\z}
21
21
  USER_SCHEMA_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/)?)user.yml}
22
- TRANSLATIONS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)translations/(.+)\.yml}
22
+ TRANSLATIONS_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)translations/(.+)\.yml}
23
23
  CONFIG_REGEX = %r{\A(?-mix:^/?((marketplace_builder|app)/)?)config.yml}
24
24
 
25
25
  REGEXP_MAP = {
@@ -60,10 +60,19 @@ module PlatformosCheck
60
60
  next unless regexp
61
61
 
62
62
  f = klass.new(path, storage)
63
+
63
64
  if remove
64
65
  @grouped_files[klass].delete(f.name)
66
+ if f.module_overwrite_file? && storage.files.include?(f.module_original_file_path)
67
+ original_file = klass.new(f.module_original_file_path, storage)
68
+ @grouped_files[klass][original_file.name] = original_file
69
+ elsif f.module_original_file? && storage.files.include?(f.module_overwrite_file_path)
70
+ overwrite_file = klass.new(f.module_overwrite_file_path, storage)
71
+ @grouped_files[klass][overwrite_file.name] = overwrite_file
72
+ end
65
73
  else
66
- @grouped_files[klass][f.name] = f
74
+ # we want to keep the reference to a module overwrite, if exists
75
+ @grouped_files[klass][f.name] = f unless f.module_original_file? && @grouped_files[klass][f.name] && @grouped_files[klass][f.name].module_overwrite_file?
67
76
  end
68
77
  end
69
78
  @grouped_files
@@ -48,10 +48,31 @@ module PlatformosCheck
48
48
  end
49
49
 
50
50
  def module_name
51
- @module_name ||= begin
52
- dir_names = @relative_path.split(File::SEPARATOR).reject(&:empty?)
53
- dir_names.first == 'modules' ? dir_names[1] : nil
54
- end
51
+ @module_name ||= if module_original_file?
52
+ dir_names[1]
53
+ elsif module_overwrite_file?
54
+ return dir_names[2]
55
+ end
56
+ end
57
+
58
+ def module_original_file?
59
+ dir_names[0] == 'modules'
60
+ end
61
+
62
+ def module_overwrite_file?
63
+ dir_names[0] == 'app' && dir_names[1] == 'modules'
64
+ end
65
+
66
+ def module_overwrite_file_path
67
+ @module_overwrite_file_path ||= module_original_file? ? 'app/' + relative_path.to_s : nil
68
+ end
69
+
70
+ def module_original_file_path
71
+ @module_original_file_path ||= module_overwrite_file? ? dir_names[1..].join(File::SEPARATOR) : nil
72
+ end
73
+
74
+ def dir_names
75
+ @dir_names ||= @relative_path.split(File::SEPARATOR).reject(&:empty?)
55
76
  end
56
77
 
57
78
  # For the corrector to work properly, we should have a
@@ -4,7 +4,7 @@ require "zlib"
4
4
 
5
5
  module PlatformosCheck
6
6
  class AssetFile < AppFile
7
- DIR_PREFIX = %r{\A/?((marketplace_builder|app)/assets/|modules/((\w|-)*)/(private|public)/assets/)}
7
+ DIR_PREFIX = %r{\A/?((marketplace_builder|app)/assets/|(app/)?modules/((\w|-)*)/(private|public)/assets/)}
8
8
 
9
9
  def initialize(relative_path, storage)
10
10
  super
@@ -31,7 +31,7 @@ module PlatformosCheck
31
31
 
32
32
  file(relative_path).dirname.mkpath unless file(relative_path).dirname.directory?
33
33
  file(relative_path).write(content, mode: 'w+b', encoding: 'UTF-8')
34
- @platformos_app&.update([relative_path])
34
+ @platformos_app&.update([relative_path], remove: !file_exists?(relative_path))
35
35
  end
36
36
 
37
37
  def remove(relative_path)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module PlatformosCheck
4
4
  class FormFile < LiquidFile
5
- DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(form_configurations|forms)/|modules/((\w|-)*)/(private|public)/(form_configurations|forms)/)}
5
+ DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(form_configurations|forms)/|(app/)?modules/((\w|-)*)/(private|public)/(form_configurations|forms)/)}
6
6
 
7
7
  def form?
8
8
  true
@@ -4,7 +4,7 @@ require 'graphql'
4
4
 
5
5
  module PlatformosCheck
6
6
  class GraphqlFile < AppFile
7
- DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(graph_queries|graphql)s?/|modules/((\w|-)*)/(private|public)/(graph_queries|graphql)s?/)}
7
+ DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(graph_queries|graphql)s?/|(app/)?modules/((\w|-)*)/(private|public)/(graph_queries|graphql)s?/)}
8
8
 
9
9
  def write
10
10
  content = rewriter.to_s
@@ -28,6 +28,8 @@ module PlatformosCheck
28
28
 
29
29
  def cursor
30
30
  @cursor ||= (absolute_cursor - token&.start) || 0
31
+ rescue StandardError
32
+ 0
31
33
  end
32
34
 
33
35
  def content
@@ -2,7 +2,7 @@
2
2
 
3
3
  module PlatformosCheck
4
4
  class LayoutFile < LiquidFile
5
- DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(views/layouts)/|modules/((\w|-)*)/(private|public)/(views/layouts)/)}
5
+ DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(views/layouts)/|(app/)?modules/((\w|-)*)/(private|public)/(views/layouts)/)}
6
6
 
7
7
  def layout?
8
8
  true
@@ -2,7 +2,7 @@
2
2
 
3
3
  module PlatformosCheck
4
4
  class PartialFile < LiquidFile
5
- DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(views/partials|liquid_views|views|lib)/|modules/((\w|-)*)/(private|public)/(views/partials|liquid_views|views|lib)/)}
5
+ DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(views/partials|liquid_views|views|lib)/|(app/)?modules/((\w|-)*)/(private|public)/(views/partials|liquid_views|views|lib)/)}
6
6
 
7
7
  def partial?
8
8
  true
@@ -2,7 +2,7 @@
2
2
 
3
3
  module PlatformosCheck
4
4
  class TranslationFile < YamlFile
5
- DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(translations)/|modules/((\w|-)*)/(private|public)/(translations)/)}
5
+ DIR_PREFIX = %r{\A/?((marketplace_builder|app)/(translations)/|(app/)?modules/((\w|-)*)/(private|public)/(translations)/)}
6
6
  TRANSLATION_FILTERS = Set.new(%w[t t_escape translate translate_escape]).freeze
7
7
  attr_reader :language
8
8
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformosCheck
4
- VERSION = "0.4.13"
4
+ VERSION = "0.4.14"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platformos-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.13
4
+ version: 0.4.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Bliszczyk
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-10-07 00:00:00.000000000 Z
13
+ date: 2024-10-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: graphql