Sha256: d42c98c1060b78357dd93fda6325b4e752cf778cdd1fcd20195fc9ebc26ae898

Contents?: true

Size: 1.82 KB

Versions: 15

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

namespace :ext do
  rootdir = Pathname("extensions")

  desc "Build Chrome Extension"
  task chrome: "chrome:build"

  namespace :chrome do
    dist   = Pathname("dist/crx")
    extdir = rootdir.join(dist)
    manifest_json = rootdir.join("chrome/manifest.json")

    directory extdir

    task build: [ extdir, "lib:templates" ] do
      cd rootdir do
        cp_r [ "img/", "tmp/lib/" ], dist
        `cd chrome && git ls-files`.split("\n").each do |src|
          dest = dist.join(src)
          mkdir_p dest.dirname
          cp Pathname("chrome").join(src), dest
        end
      end
    end

    # Generate a .crx file.
    task crx: [ :build, :npm ] do
      out = "crx-web-console-#{JSON.parse(File.read(manifest_json))["version"]}.crx"
      cd(extdir) { sh "node \"$(npm bin)/crx\" pack ./ -p ../crx-web-console.pem -o ../#{out}" }
    end

    # Generate a .zip file for Chrome Web Store.
    task zip: [ :build ] do
      version = JSON.parse(File.read(manifest_json))["version"]
      cd(extdir) { sh "zip -r ../crx-web-console-#{version}.zip ./" }
    end

    desc "Launch a browser with the chrome extension."
    task run: [ :build ] do
      cd(rootdir) { sh "sh ./script/run_chrome.sh --load-extension=#{dist}" }
    end
  end

  task :npm do
    cd(rootdir) { sh "npm install --silent" }
  end

  namespace :lib do
    templates = Pathname("lib/web_console/templates")
    tmplib    = rootdir.join("tmp/lib/")
    js_erb    = FileList.new(templates.join("**/*.js.erb"))
    dirs      = js_erb.pathmap("%{^#{templates},#{tmplib}}d")

    task templates: dirs + js_erb.pathmap("%{^#{templates},#{tmplib}}X")

    dirs.each { |d| directory d }
    rule ".js" => [ "%{^#{tmplib},#{templates}}X.js.erb" ] do |t|
      File.write(t.name, WebConsole::Testing::ERBPrecompiler.new(t.source).build)
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/web-console-4.2.1/lib/web_console/tasks/extensions.rake
web-console-4.2.1 lib/web_console/tasks/extensions.rake
web-console-4.2.0 lib/web_console/tasks/extensions.rake
web-console-4.1.0 lib/web_console/tasks/extensions.rake
web-console-4.0.4 lib/web_console/tasks/extensions.rake
web-console-4.0.3 lib/web_console/tasks/extensions.rake
web-console-4.0.2 lib/web_console/tasks/extensions.rake
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/web-console-4.0.1/lib/web_console/tasks/extensions.rake
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/web-console-4.0.1/lib/web_console/tasks/extensions.rake
web-console-4.0.1 lib/web_console/tasks/extensions.rake
web-console-4.0.0 lib/web_console/tasks/extensions.rake
web-console-3.7.0 lib/web_console/tasks/extensions.rake
web-console-3.6.2 lib/web_console/tasks/extensions.rake
web-console-3.6.1 lib/web_console/tasks/extensions.rake
web-console-3.6.0 lib/web_console/tasks/extensions.rake