diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2018-06-19 19:43:32 +0200 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2018-06-19 19:57:10 +0200 |
commit | 811b6cf9981d7b778f7643fbbb10c548927560f5 (patch) | |
tree | 325cf73e1074e396e48d4a7a274d1072c900456f | |
parent | 6b19e7a19013db1c344832f0dc12a143071e4188 (diff) |
Set up compilation to JavaScript using Opal
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | .rubocop.yml | 4 | ||||
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | Gemfile | 5 | ||||
-rw-r--r-- | Rakefile | 19 | ||||
-rw-r--r-- | package.json | 34 |
6 files changed, 67 insertions, 0 deletions
@@ -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 @@ -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 @@ -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 <jakub@jirutka.cz>", + "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" + } +} |