KCommercialPipeline 0.2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.idea/.gitignore +8 -0
- data/.idea/inspectionProfiles/Project_Default.xml +6 -0
- data/.idea/inspectionProfiles/profiles_settings.xml +5 -0
- data/.idea/kcommercialpipeline.iml +130 -0
- data/.idea/misc.xml +4 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.rubocop.yml +13 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +224 -0
- data/KCommercialPipeline-0.2.5.0.gem +0 -0
- data/KCommercialPipeline.gemspec +49 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +16 -0
- data/bin/KCommercialPipeline +17 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/KCommercialPipeline/App.rb +18 -0
- data/lib/KCommercialPipeline/command/app_runner.rb +34 -0
- data/lib/KCommercialPipeline/command/auto_cherry_pick_cmd.rb +18 -0
- data/lib/KCommercialPipeline/command/change_log.rb +19 -0
- data/lib/KCommercialPipeline/command/check_release_cmd.rb +34 -0
- data/lib/KCommercialPipeline/command/command.rb +44 -0
- data/lib/KCommercialPipeline/command/feat_check.rb +16 -0
- data/lib/KCommercialPipeline/command/git_hook_install_cmd.rb +29 -0
- data/lib/KCommercialPipeline/command/ios_publish_component.rb +71 -0
- data/lib/KCommercialPipeline/command/rb_auto.rb +30 -0
- data/lib/KCommercialPipeline/command/resource.rb +52 -0
- data/lib/KCommercialPipeline/core/app_demo.rb +196 -0
- data/lib/KCommercialPipeline/core/branch_diffs.rb +95 -0
- data/lib/KCommercialPipeline/core/change_log/change_log_task.rb +317 -0
- data/lib/KCommercialPipeline/core/change_log/doc_builder.rb +91 -0
- data/lib/KCommercialPipeline/core/component_publisher.rb +122 -0
- data/lib/KCommercialPipeline/core/feature_send.rb +88 -0
- data/lib/KCommercialPipeline/core/git.rb +125 -0
- data/lib/KCommercialPipeline/core/git_hook/install_git_hook.rb +84 -0
- data/lib/KCommercialPipeline/core/git_hook/prepare_commit_msg.rb +0 -0
- data/lib/KCommercialPipeline/core/kim_cfg.rb +64 -0
- data/lib/KCommercialPipeline/core/kim_notify.rb +99 -0
- data/lib/KCommercialPipeline/core/resource/auto_publish_resource/update_resource_component.rb +35 -0
- data/lib/KCommercialPipeline/core/resource/bundle/colors_generator.rb +29 -0
- data/lib/KCommercialPipeline/core/resource/bundle/files_generator.rb +36 -0
- data/lib/KCommercialPipeline/core/resource/bundle/fonts_generator.rb +29 -0
- data/lib/KCommercialPipeline/core/resource/bundle/i18ns_generator.rb +29 -0
- data/lib/KCommercialPipeline/core/resource/bundle/images_generator.rb +67 -0
- data/lib/KCommercialPipeline/core/resource/bundle/indexes_generator.rb +55 -0
- data/lib/KCommercialPipeline/core/resource/bundle/scale_pathname.rb +23 -0
- data/lib/KCommercialPipeline/core/resource/code_generator/code_generator.rb +59 -0
- data/lib/KCommercialPipeline/core/resource/code_generator/file_generator.rb +16 -0
- data/lib/KCommercialPipeline/core/resource/code_generator/resources_status.rb +24 -0
- data/lib/KCommercialPipeline/core/resource/component_resources_config.rb +63 -0
- data/lib/KCommercialPipeline/core/resource/file_generator.rb +16 -0
- data/lib/KCommercialPipeline/core/resource/i18n/auto_component.rb +61 -0
- data/lib/KCommercialPipeline/core/resource/i18n/bundle_generator.rb +36 -0
- data/lib/KCommercialPipeline/core/resource/i18n/generator.rb +368 -0
- data/lib/KCommercialPipeline/core/resource/key_defines.rb +41 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/code_model.rb +51 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/oc_file_model.rb +59 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/oc_generator.rb +55 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{component_header_name}}.h +39 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Colors.h +31 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Colors.m +29 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Files.h +31 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Files.m +29 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Fonts.h +31 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Fonts.m +29 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+I18ns.h +31 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+I18ns.m +29 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Images.h +30 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}+Images.m +29 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}.h +39 -0
- data/lib/KCommercialPipeline/core/resource/objective-c/templates/{{oc_class_name}}.m +51 -0
- data/lib/KCommercialPipeline/core/resource/source/asset.rb +120 -0
- data/lib/KCommercialPipeline/core/resource/source/asset_type.rb +16 -0
- data/lib/KCommercialPipeline/core/resource/source/git_source.rb +105 -0
- data/lib/KCommercialPipeline/core/resource/source/git_source_manager.rb +114 -0
- data/lib/KCommercialPipeline/core/resource/source/interface.rb +9 -0
- data/lib/KCommercialPipeline/core/resource/source/lib_bundle.rb +50 -0
- data/lib/KCommercialPipeline/core/resource/source/source.rb +9 -0
- data/lib/KCommercialPipeline/core/resource/source/source_interface.rb +20 -0
- data/lib/KCommercialPipeline/core/resource/source/source_manager.rb +93 -0
- data/lib/KCommercialPipeline/core/resource/source/star_source.rb +145 -0
- data/lib/KCommercialPipeline/core/resource/source/subspec_bundle.rb +34 -0
- data/lib/KCommercialPipeline/core/resource/swift/colors_generator.rb +22 -0
- data/lib/KCommercialPipeline/core/resource/swift/files_generate.rb +22 -0
- data/lib/KCommercialPipeline/core/resource/swift/fonts_generator.rb +22 -0
- data/lib/KCommercialPipeline/core/resource/swift/i18n_generetor.rb +22 -0
- data/lib/KCommercialPipeline/core/resource/swift/images_generator.rb +22 -0
- data/lib/KCommercialPipeline/core/resource/swift/swift_generator.rb +84 -0
- data/lib/KCommercialPipeline/core/resource/xcassets/image.rb +30 -0
- data/lib/KCommercialPipeline/core/resource/xcassets/imageset.rb +53 -0
- data/lib/KCommercialPipeline/core/resource/xcassets/xcassets.rb +63 -0
- data/lib/KCommercialPipeline/core/version_pipeline/auto_cherry_pick.rb +173 -0
- data/lib/KCommercialPipeline/core/version_pipeline/release_branches.rb +183 -0
- data/lib/KCommercialPipeline/core/version_pipeline/release_check.rb +111 -0
- data/lib/KCommercialPipeline/version.rb +5 -0
- data/lib/KCommercialPipeline.rb +19 -0
- metadata +304 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
module KCommercial
|
4
|
+
module Resources
|
5
|
+
class IndexesGenerator
|
6
|
+
|
7
|
+
# @return [Array(Asset)]
|
8
|
+
attr_reader :asset_objects
|
9
|
+
|
10
|
+
# @return [Pathname]
|
11
|
+
attr_reader :root_path
|
12
|
+
|
13
|
+
# @param [Array(Asset)] assets
|
14
|
+
# @param [Pathname] root_path
|
15
|
+
def initialize(assets, root_path)
|
16
|
+
@asset_objects = assets
|
17
|
+
@root_path = root_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate!
|
21
|
+
write_files
|
22
|
+
write_indexes
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def write_files
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def indexes_contents
|
31
|
+
{
|
32
|
+
:version => '1.1.1',
|
33
|
+
:resources => index_resources
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def index_resources
|
38
|
+
{}
|
39
|
+
end
|
40
|
+
|
41
|
+
def indexes_filename
|
42
|
+
raise 'you must implementation this method in subclass'
|
43
|
+
end
|
44
|
+
|
45
|
+
def write_indexes
|
46
|
+
path = root_path.join("#{indexes_filename}.json")
|
47
|
+
path.parent.mkpath unless path.parent.exist?
|
48
|
+
File.open(path, 'w+') do |file|
|
49
|
+
file.write JSON.pretty_generate(indexes_contents)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pathname
|
4
|
+
def filename_without_scale
|
5
|
+
name = basename('.*').to_s
|
6
|
+
if name.match? /.*@[123][xX]/
|
7
|
+
index = name.rindex('@')
|
8
|
+
name = name[..(index - 1)]
|
9
|
+
end
|
10
|
+
name
|
11
|
+
end
|
12
|
+
|
13
|
+
def xcasset_scale
|
14
|
+
name = basename('.*')
|
15
|
+
match_data = name.match? /.*@[123][xX]/
|
16
|
+
if match_data
|
17
|
+
scale = match_data.captures.first
|
18
|
+
scale.downcase
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class String
|
2
|
+
def camelize(uppercase_first_letter = true)
|
3
|
+
string = self
|
4
|
+
if uppercase_first_letter
|
5
|
+
string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
|
6
|
+
else
|
7
|
+
string = string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
|
8
|
+
end
|
9
|
+
string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub("/", "::")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module KCommercial
|
14
|
+
module Resources
|
15
|
+
class CodeGenerator
|
16
|
+
# The super module default is MKResources
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :super_module
|
19
|
+
|
20
|
+
# The key defines for the generator
|
21
|
+
# @return [Array<String>]
|
22
|
+
attr_reader :keys
|
23
|
+
|
24
|
+
# Create a new SwiftGenerator
|
25
|
+
# @param [Array<String>] keys the defines for keys
|
26
|
+
def initialize(keys, options = {})
|
27
|
+
@keys = keys
|
28
|
+
@keys ||= []
|
29
|
+
@super_module = options.delete(:super) { :MKResources }
|
30
|
+
end
|
31
|
+
|
32
|
+
def implementation_contents
|
33
|
+
raise NotImplementedError
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def class_name
|
39
|
+
"Colors"
|
40
|
+
end
|
41
|
+
|
42
|
+
def key_to_code(key)
|
43
|
+
raise NotImplementedError
|
44
|
+
end
|
45
|
+
|
46
|
+
def key_to_function_name(key)
|
47
|
+
key = key.camelize(false)
|
48
|
+
if key.length > 0
|
49
|
+
key[0] = key[0].downcase
|
50
|
+
end
|
51
|
+
key
|
52
|
+
end
|
53
|
+
|
54
|
+
def append_prefix(contents, prefix)
|
55
|
+
contents.lines.map { |l| "#{prefix}#{l}"}.join('')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module KCommercial
|
2
|
+
module Resources
|
3
|
+
# Generator an code file
|
4
|
+
class FileGenerator
|
5
|
+
# initialize a new file generator
|
6
|
+
# @param [Pathname] template_path the template file path, it may be an erb file.
|
7
|
+
def initialize(template_path)
|
8
|
+
@template_path = template_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate(path, bind_params)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module KCommercial
|
2
|
+
module Resources
|
3
|
+
class Generator
|
4
|
+
|
5
|
+
class ResourcesStatus
|
6
|
+
attr_accessor :has_i18ns, :has_images, :has_fonts, :has_files, :has_colors
|
7
|
+
|
8
|
+
alias has_images? has_images
|
9
|
+
alias has_fonts? has_fonts
|
10
|
+
alias has_files? has_files
|
11
|
+
alias has_colors? has_colors
|
12
|
+
alias has_i18ns? has_i18ns
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
has_images = false
|
16
|
+
has_fonts = false
|
17
|
+
has_files = false
|
18
|
+
has_colors = false
|
19
|
+
has_i18ns = false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'key_defines'
|
4
|
+
module KCommercial
|
5
|
+
class Component
|
6
|
+
CONFIGURATION_ROOT = 'Configurations'.freeze
|
7
|
+
RESOURCES_CONFIGURATION_ROOT = 'Resources'.freeze
|
8
|
+
|
9
|
+
def configurations_root
|
10
|
+
path.join CONFIGURATION_ROOT
|
11
|
+
end
|
12
|
+
# Get the root for the resources configurations. it may
|
13
|
+
# be contains i18n or images keys
|
14
|
+
# @return [Pathname]
|
15
|
+
def resources_configuration_root
|
16
|
+
path = configurations_root.join 'resources'
|
17
|
+
return path if path.exist?
|
18
|
+
|
19
|
+
configurations_root.join CONFIGURATION_ROOT
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get the i18ns key defines
|
23
|
+
# @return [KeyDefines]
|
24
|
+
def i18ns_keys
|
25
|
+
@i18n_keys ||= key_defines_for_name('i18ns')
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get the images key defines
|
29
|
+
# @return [KeyDefines]
|
30
|
+
def images_keys
|
31
|
+
@images_keys ||= key_defines_for_name('images')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get the resources key defines
|
35
|
+
# @return [KeyDefines]
|
36
|
+
def files_keys
|
37
|
+
@files_keys ||= key_defines_for_name('files')
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get the fonts key defines
|
41
|
+
# @return [KeyDefines]
|
42
|
+
def fonts_keys
|
43
|
+
@fonts_keys ||= key_defines_for_name('fonts')
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get the colors key defines
|
47
|
+
# @return [KeyDefines]
|
48
|
+
def colors_keys
|
49
|
+
@colors_keys ||= key_defines_for_name('colors')
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def key_defines_for_name(name)
|
54
|
+
path = resources_configuration_root.join "#{name}.yaml"
|
55
|
+
return KCommercial::Resources::KeyDefines.from_file(path) if path.exist?
|
56
|
+
|
57
|
+
path = resources_configuration_root.join "#{name}.yml"
|
58
|
+
return KCommercial::Resources::KeyDefines.from_file(path) if path.exist?
|
59
|
+
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module KCommercial
|
2
|
+
module Resources
|
3
|
+
# Generator an code file
|
4
|
+
class FileGenerator
|
5
|
+
# initialize a new file generator
|
6
|
+
# @param [Pathname] template_path the template file path, it may be an erb file.
|
7
|
+
def initialize(template_path)
|
8
|
+
@template_path = template_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate(path, bind_params)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
module CocoaDepot
|
3
|
+
class MaterialCreator
|
4
|
+
def auto_create!(is_oc, path, custom_resource_bundle)
|
5
|
+
@is_auto_create = true
|
6
|
+
@custom_resource_bundle = custom_resource_bundle || ''
|
7
|
+
@main_language = CocoaDepot::Component::CodeLanguage::SWIFT unless is_oc
|
8
|
+
@path = path
|
9
|
+
clone_template_to_path
|
10
|
+
exec_hook 'pre_create'
|
11
|
+
render_templates
|
12
|
+
exec_hook 'post_create'
|
13
|
+
remove_skip_entries
|
14
|
+
write_main_language
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def clone_template_to_path
|
19
|
+
KCommercial::UI.info "Cloning `#{template_repo_url}` into `#{@name}`."
|
20
|
+
clone_path = @name
|
21
|
+
clone_path = "#{@path}/#{@name}" unless @path.empty?
|
22
|
+
remove_dir_if_needed(clone_path)
|
23
|
+
git! ['clone', template_repo_url, clone_path]
|
24
|
+
end
|
25
|
+
|
26
|
+
def remove_dir_if_needed(dir)
|
27
|
+
component_path = Pathname(dir)
|
28
|
+
FileUtils.rm_rf(dir) if component_path.exist?
|
29
|
+
end
|
30
|
+
|
31
|
+
def collect_meta_infos
|
32
|
+
meta_infos = {
|
33
|
+
'POD_NAME' => @name,
|
34
|
+
'USER_NAME' => user_name,
|
35
|
+
'USER_EMAIL' => user_email,
|
36
|
+
'DATE' => Date.today.to_s,
|
37
|
+
'CUSTOM_RESOURCE_BUNDLES' => @custom_resource_bundle
|
38
|
+
}
|
39
|
+
Dir.chdir(@sandbox_root) do
|
40
|
+
if configure_script_root.join('meta').exist?
|
41
|
+
custom_content = File.read(configure_script_root.join('meta'))
|
42
|
+
custom_meta_infos = @is_auto_create ? {'deployment_target'=> '9.0'} : eval(custom_content)
|
43
|
+
unless custom_meta_infos.is_a? Hash
|
44
|
+
raise 'The configure return value is not an Hash. please check the template!'
|
45
|
+
end
|
46
|
+
meta_infos.merge! custom_meta_infos
|
47
|
+
end
|
48
|
+
end
|
49
|
+
meta_infos.merge! @pass_meta_infos
|
50
|
+
meta_infos
|
51
|
+
end
|
52
|
+
|
53
|
+
def sandbox_root
|
54
|
+
@sandbox_root ||= Pathname(Dir.pwd).join(@name)
|
55
|
+
root_path = Pathname(@path) || Pathname(Dir.pwd)
|
56
|
+
@sandbox_root = root_path.join(@name) if root_path.exist?
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'cocoadepot'
|
2
|
+
require_relative '../source/lib_bundle'
|
3
|
+
require_relative '../code_generator/code_generator'
|
4
|
+
module CocoaDepot
|
5
|
+
# The abstract for the container that contains a component. In cocoa
|
6
|
+
# it may be a pod.
|
7
|
+
class Component
|
8
|
+
# Check the aim bundle is exist or not
|
9
|
+
def check_auto_compoment!
|
10
|
+
all_component_resource_paths = auto_assets_generation_path.children.select(&:directory?)
|
11
|
+
all_component_resource_paths.each do |child|
|
12
|
+
app_id = child.basename
|
13
|
+
bundle_name = auto_bundle_name
|
14
|
+
component_name = "#{bundle_name}#{app_id.to_s.camelize}"
|
15
|
+
lib = KCommercial::Resources::LibBundleGenerator.new(component_name, auto_bundle_name, child)
|
16
|
+
lib.generate!
|
17
|
+
end
|
18
|
+
# rm assets
|
19
|
+
FileUtils.rm_rf(auto_assets_generation_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
def auto_compoment_list
|
23
|
+
auto_assets_generation_path.mkdir unless auto_assets_generation_path.exist?
|
24
|
+
all_component_resource_paths = auto_assets_generation_path.children.select(&:directory?)
|
25
|
+
components = all_component_resource_paths.map do |c|
|
26
|
+
bundle_name = auto_bundle_name
|
27
|
+
app_id = c.basename
|
28
|
+
component_name = "#{bundle_name}#{app_id.to_s.camelize}"
|
29
|
+
component_name
|
30
|
+
end
|
31
|
+
components
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|