Sha256: ee5cfbf2c369e9d3a1b70706738ef02546abfaa0b468087e79a1aaa953385ffc
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
require_relative 'subspec_bundle' require 'cocoadepot' require 'fileutils' require_relative '../i18n/auto_component' module KCommercial module Resources class LibBundleGenerator < BundleGenerator attr_accessor :depot def depot @depot ||= CocoaDepot::Depot.instance end def check_exist? return !depot.materials_cache.component_for_name(@component_name).nil? end # auto generate componet def generate! unless check_exist? KCommercial::UI.debug("开始自动创建资源组件#{@component_name}") templete_url = 'git@git.corp.kuaishou.com:exploration-client/cocoadepot-toolchain/templates/pod-template.git'.freeze creator = CocoaDepot::MaterialCreator.new(templete_url, @component_name) custom_resource_bundle_config = <<EOF s.resource_bundles = { '#{@bundle_name}Resources' => ['Pod/Assets/**/*.{xcassets,json}'] } EOF bundle_path = "#{@depot.root_path}/#{@depot.configuration.components.origin_configurations[:search_paths].last}" creator.auto_create!(true, bundle_path, custom_resource_bundle_config) KCommercial::UI.info("自动创建资源组件#{@component_name}成功") end copy_resource! end # copy resource def copy_resource! KCommercial::UI.debug("开始自动copy资源到#{@component_name}组件") bundle_path = "#{@depot.root_path}/#{@depot.configuration.components.origin_configurations[:search_paths].last}" target_dir = Pathname(bundle_path).join(component_name).join('Pod').join('Assets') FileUtils.rm_rf(target_dir) if File.exist?(target_dir) FileUtils.mkdir(target_dir) FileUtils.copy_entry(@resource_path, target_dir) KCommercial::UI.debug("开始自动copy资源到#{@component_name}组件完成") KCommercial::UI.info("如需要使用#{@app_name}资源请添加#{@component_name}组件依赖") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
KCommercialPipeline-0.2.5.1 | lib/KCommercialPipeline/core/resource/source/lib_bundle.rb |