Browse Source

Maintenance: Reorganize Zammad Rails generators.

Martin Gruner 2 years ago
parent
commit
fb34e2af55

+ 1 - 1
.github/workflows/ci/lint.sh

@@ -11,7 +11,7 @@ source .gitlab/environment.env
 echo "Checking .po file syntax..."
 for FILE in i18n/*.pot i18n/*.po; do echo "Checking $FILE"; msgfmt -o /dev/null -c "$FILE"; done
 echo "Checking .pot catalog consistency..."
-bundle exec rails generate translation_catalog --check
+bundle exec rails generate zammad:translation_catalog --check
 echo "Brakeman security check..."
 bundle exec brakeman -o /dev/stdout -o tmp/brakeman-report.html
 echo "Rails zeitwerk:check autoloader check..."

+ 1 - 1
.gitlab/ci/lint.yml

@@ -41,7 +41,7 @@
     - echo "Checking .po file syntax..."
     - for FILE in i18n/*.pot i18n/*.po; do echo "Checking $FILE"; msgfmt -o /dev/null -c $FILE; done
     - echo "Checking .pot catalog consistency..."
-    - bundle exec rails generate translation_catalog --check
+    - bundle exec rails generate zammad:translation_catalog --check
     - echo "Brakeman security check..."
     - bundle exec brakeman -o /dev/stdout -o tmp/brakeman-report.html
     - echo "Rails zeitwerk:check autoloader check..."

+ 1 - 1
.overcommit.sh

@@ -3,6 +3,6 @@
 set -eux
 
 echo "Checking .pot catalog consistency..."
-rails generate translation_catalog --check
+rails generate zammad:translation_catalog --check
 
 .gitlab/check_graphql_api_consistency.sh

+ 1 - 0
config/application.rb

@@ -41,6 +41,7 @@ module Zammad
       autoloader.ignore            "#{config.root}/app/frontend"
       autoloader.do_not_eager_load "#{config.root}/lib/core_ext"
       autoloader.collapse          "#{config.root}/lib/omniauth"
+      autoloader.collapse          "#{config.root}/lib/generators"
       autoloader.inflector.inflect(
         'github_database' => 'GithubDatabase',
         'otrs'            => 'OTRS',

+ 2 - 2
doc/developer_manual/standards/how-to-handle-localization.md

@@ -33,11 +33,11 @@ Feel free to send pull requests to add more helpful examples to existing files o
 If changes to translatable strings are made during the development process, developers can just run the following to
 re-extract the strings to the catalog file:
 
-`rails generate translation_catalog`
+`rails generate zammad:translation_catalog`
 
 This will update the `i18n/zammad.pot` file in Zammad. To do this for an existing addon module, call
 
-`rails generate translation_catalog --addon-path /path/to/addon`
+`rails generate zammad:translation_catalog --addon-path /path/to/addon`
 
 ### Testing Translation Changes from Weblate
 

+ 0 - 5
lib/generators/graphql_introspection/USAGE

@@ -1,5 +0,0 @@
-Description:
-    Create JSON from the GraphQL introspection information
-
-Example:
-    rails generate graphql_introspection

+ 0 - 9
lib/generators/translation_catalog/USAGE

@@ -1,9 +0,0 @@
-Description:
-    Create the translation catalog file for Zammad or an addon
-
-Example:
-    # Regenerate the catalog for Zammad
-    rails generate translation_catalog
-
-    # Regenerate for an addon
-    rails generate translation_catalog --addon /path/to/addon

+ 3 - 5
lib/generators/graphql_introspection/graphql_introspection_generator.rb → lib/generators/zammad/graphql_introspection_generator.rb

@@ -1,6 +1,8 @@
 # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
-class Generators::GraphqlIntrospection::GraphqlIntrospectionGenerator < Rails::Generators::Base
+class Zammad::GraphqlIntrospectionGenerator < Rails::Generators::Base
+
+  desc 'Create JSON from the GraphQL introspection information and output it to STDOUT'
 
   def generate
     result = Gql::ZammadSchema.execute(introspection_query, variables: {}, context: { is_graphql_introspection_generator: true })
@@ -117,7 +119,3 @@ class Generators::GraphqlIntrospection::GraphqlIntrospectionGenerator < Rails::G
     INTROSPECTION_QUERY
   end
 end
-
-# Allow Rails to find the generator
-class GraphqlIntrospectionGenerator < Generators::GraphqlIntrospection::GraphqlIntrospectionGenerator
-end

+ 1 - 1
lib/generators/translation_catalog/extracted_string.rb → lib/generators/zammad/translation_catalog/extracted_string.rb

@@ -1,6 +1,6 @@
 # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
-class Generators::TranslationCatalog::ExtractedString
+class Zammad::TranslationCatalog::ExtractedString
   attr_accessor :string, :comment, :references, :skip_translation_sync
 
   def initialize(string:, references:, comment: nil, skip_translation_sync: false)

+ 1 - 1
lib/generators/translation_catalog/extracted_strings.rb → lib/generators/zammad/translation_catalog/extracted_strings.rb

@@ -1,6 +1,6 @@
 # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
 
-class Generators::TranslationCatalog::ExtractedStrings < SimpleDelegator
+class Zammad::TranslationCatalog::ExtractedStrings < SimpleDelegator
   def initialize
     super({})
   end

Some files were not shown because too many files changed in this diff