Sha256: 1c8a96d7b6876c8d03db7125ffd98655b8a3a166537d998dc7dee03b6ea1716d

Contents?: true

Size: 1.41 KB

Versions: 37

Compression:

Stored size: 1.41 KB

Contents

module ZendeskAppsTools

  module PackageHelper
    def app_package
      require 'zendesk_apps_support'
      @app_package ||= ZendeskAppsSupport::Package.new(app_dir.to_s)
    end

    def manifest
      require 'zendesk_apps_support'
      require 'zendesk_apps_support/manifest/no_override_hash'
      begin
        @manifest ||= app_package.manifest
      rescue JSON::ParserError, ZendeskAppsSupport::Manifest::OverrideError => e
        say_status "error", "Manifest file is incorrectly formatted: #{e.message}", :red and exit 1
      rescue Errno::ENOENT
        say_status "error", "Manifest file cannot be found in the given path. Check you are pointing to the path that contains your manifest.json", :red and exit 1
      end
    end

    def zip(archive_path)
      require 'zip'
      Zip::File.open(archive_path, 'w') do |zipfile|
        app_package.files.each do |file|
          relative_path = file.relative_path
          path = relative_path
          say_status 'package', "adding #{path}"

          # resolve symlink to source path
          if File.symlink? file.absolute_path
            path = File.expand_path(File.readlink(file.absolute_path), File.dirname(file.absolute_path))
          end
          if file.to_s == 'app.scss'
            relative_path = relative_path.sub 'app.scss', 'app.css'
          end
          zipfile.add(relative_path, app_dir.join(path).to_s)
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
zendesk_apps_tools-3.9.2 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.9.1 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.9.0 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.15.beta.3 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.15.beta.2 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.14 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.13 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.11 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.10 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.9 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.8 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.7 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.6 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.5 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.4 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.3 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.2 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.1 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.8.0 lib/zendesk_apps_tools/package_helper.rb
zendesk_apps_tools-3.7.1 lib/zendesk_apps_tools/package_helper.rb