From 811b6cf9981d7b778f7643fbbb10c548927560f5 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Tue, 19 Jun 2018 19:43:32 +0200 Subject: Set up compilation to JavaScript using Opal --- .gitignore | 4 ++++ .rubocop.yml | 4 ++++ .travis.yml | 1 + Gemfile | 5 +++++ Rakefile | 19 +++++++++++++++++++ package.json | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 23f8e8c..7039ac3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,12 @@ /.yardoc/ /coverage/ /doc/ +/js/ /pkg/ /tmp/ +node_modules/ Gemfile.lock +package-lock.json *.bundle *.gem +*.log diff --git a/.rubocop.yml b/.rubocop.yml index 880c493..da8564c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -26,6 +26,10 @@ Layout/MultilineMethodCallIndentation: Lint/EndAlignment: EnforcedStyleAlignWith: variable +Layout/IndentHash: + Exclude: + - Rakefile + Metrics/AbcSize: Max: 30 diff --git a/.travis.yml b/.travis.yml index 7825d8e..4476f2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,7 @@ before_install: script: - bundle exec rake spec - bundle exec rake rubocop + - bundle exec rake build:js deploy: provider: rubygems diff --git a/Gemfile b/Gemfile index 80fe15a..ea42769 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,11 @@ unless ENV.fetch('ASCIIDOCTOR_VERSION', '').empty? end end +group :development do + # Keep in sync with version used for asciidoctor.js. + gem 'opal', '~> 0.11.0' +end + group :ci do gem 'codacy-coverage', '~> 1.1', require: false end diff --git a/Rakefile b/Rakefile index aa8614e..bc86f92 100644 --- a/Rakefile +++ b/Rakefile @@ -22,3 +22,22 @@ begin rescue LoadError => e warn "#{e.path} is not available" end + +namespace :build do + desc 'Transcompile to JavaScript using Opal' + task :js do + require 'opal' + + builder = Opal::Builder.new(compiler_options: { + dynamic_require_severity: :error, + }) + builder.append_paths 'lib' + builder.build 'asciidoctor-interdoc-reftext' + + out_file = 'js/asciidoctor-interdoc-reftext.js' + + mkdir_p(File.dirname(out_file), verbose: false) + File.binwrite out_file, builder.to_s + File.binwrite "#{out_file}.map", builder.source_map + end +end diff --git a/package.json b/package.json new file mode 100644 index 0000000..e2f04de --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "asciidoctor-interdoc-reftext", + "version": "0.2.0", + "description": "Asciidoctor extension providing implicit (automatic) reference text (label) for inter-document cross references", + "main": "js/asciidoctor-interdoc-reftext.js", + "files": [ + "js/asciidoctor-interdoc-reftext.js", + "LICENSE", + "README.adoc" + ], + "scripts": { + "prepublishOnly": "bundle install && bundle exec rake build:js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/jirutka/asciidoctor-interdoc-reftext.git" + }, + "keywords": [ + "asciidoc", + "asciidoctor", + "extension", + "opal" + ], + "author": "Jakub Jirutka ", + "license": "MIT", + "bugs": { + "url": "https://github.com/jirutka/asciidoctor-interdoc-reftext/issues" + }, + "homepage": "https://github.com/jirutka/asciidoctor-interdoc-reftext", + "dependencies": { + "asciidoctor.js": "^1.5.6", + "opal-runtime": "^1.0.3" + } +} -- cgit v1.2.3