Hello community,
here is the log from the commit of package rubygem-uglifier for
openSUSE:Factory checked in at 2019-11-13 13:25:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-uglifier (Old)
and /work/SRC/openSUSE:Factory/.rubygem-uglifier.new.2990 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-uglifier"
Wed Nov 13 13:25:34 2019 rev:45 rq:747711 version:4.2.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-uglifier/rubygem-uglifier.changes
2018-11-22 13:27:17.517889233 +0100
+++
/work/SRC/openSUSE:Factory/.rubygem-uglifier.new.2990/rubygem-uglifier.changes
2019-11-13 13:25:35.675526886 +0100
@@ -1,0 +2,8 @@
+Tue Nov 12 14:13:36 UTC 2019 - Manuel Schnitzer <[email protected]>
+
+- updated to version 4.2.0
+
+ * show code context for error messages (#167)
+ * defer initialisation of ExecJS context to fix #165
+
+-------------------------------------------------------------------
Old:
----
uglifier-4.1.20.gem
New:
----
uglifier-4.2.0.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-uglifier.spec ++++++
--- /var/tmp/diff_new_pack.OJV31O/_old 2019-11-13 13:25:37.195528468 +0100
+++ /var/tmp/diff_new_pack.OJV31O/_new 2019-11-13 13:25:37.227528501 +0100
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-uglifier
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@@ -24,7 +24,7 @@
#
Name: rubygem-uglifier
-Version: 4.1.20
+Version: 4.2.0
Release: 0
%define mod_name uglifier
%define mod_full_name %{mod_name}-%{version}
++++++ uglifier-4.1.20.gem -> uglifier-4.2.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.github/workflows/ruby.yml
new/.github/workflows/ruby.yml
--- old/.github/workflows/ruby.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/.github/workflows/ruby.yml 2019-09-25 21:50:32.000000000 +0200
@@ -0,0 +1,14 @@
+name: Ruby
+
+on: [push]
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v1
+ - uses: lautis/rubocop-action@master
+ name: Lint
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml
--- old/.rubocop.yml 2018-11-17 22:25:20.000000000 +0100
+++ new/.rubocop.yml 2019-09-25 21:50:32.000000000 +0200
@@ -6,6 +6,9 @@
- "vendor/**/*"
- "gemfiles/vendor/**/*"
+Metrics/AbcSize:
+ Max: 20
+
Metrics/BlockLength:
Enabled: true
Exclude:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml 2018-11-17 22:25:20.000000000 +0100
+++ new/.travis.yml 2019-09-25 21:50:32.000000000 +0200
@@ -6,28 +6,29 @@
- 2.0.0
- 2.1.10
- 2.2.10
- - 2.3.7
- - 2.4.4
- - 2.5.1
+ - 2.3.8
+ - 2.4.5
+ - 2.5.3
+ - 2.6.0
- ruby-head
- - jruby-9.2.0.0
+ - jruby-9.2.5.0
before_install:
- - gem install bundler -v 1.16.1
+ - gem install bundler -v 1.17.3
git:
submodules: false
gemfile:
- Gemfile
matrix:
include:
- - rvm: 2.5.1
+ - rvm: 2.5.3
gemfile: gemfiles/rubyracer
- - rvm: jruby-9.2.0.0
+ - rvm: jruby-9.2.5.0
gemfile: gemfiles/rubyrhino
- - rvm: 2.5.1
+ - rvm: 2.5.3
gemfile: gemfiles/alaska
env: ALASKA=1
allow_failures:
- - rvm: 2.5.1
+ - rvm: 2.5.3
gemfile: gemfiles/alaska
env: ALASKA=1
- rvm: ruby-head
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2018-11-17 22:25:20.000000000 +0100
+++ new/CHANGELOG.md 2019-09-25 21:50:32.000000000 +0200
@@ -1,3 +1,8 @@
+## 4.2.0 (25 September 2019)
+
+- show code context for error messages (#167)
+- defer initialisation of ExecJS context to fix #165
+
## 4.1.20 (17 November 2018)
- update UglifyJS to
[3.4.8](https://github.com/mishoo/UglifyJS2/compare/v3.4.9...v3.4.8)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2018-11-17 22:25:20.000000000 +0100
+++ new/README.md 2019-09-25 21:50:32.000000000 +0200
@@ -168,6 +168,7 @@
:output_filename => nil, # The filename or URL where the minified
output can be found
:input_source_map => nil # The contents of the source map describing
the input
},
+ :error_context_lines => 8, # How many context lines surrounding the error
line. Env var ERROR_CONTEXT_LINES overrides this option
:harmony => false # Enable ES6/Harmony mode (experimental).
Disabling mangling and compressing is recommended with Harmony mode.
}
```
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/uglifier/version.rb new/lib/uglifier/version.rb
--- old/lib/uglifier/version.rb 2018-11-17 22:25:20.000000000 +0100
+++ new/lib/uglifier/version.rb 2019-09-25 21:50:32.000000000 +0200
@@ -1,4 +1,4 @@
class Uglifier
# Current version of Uglifier.
- VERSION = "4.1.20"
+ VERSION = "4.2.0"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/uglifier.rb new/lib/uglifier.rb
--- old/lib/uglifier.rb 2018-11-17 22:25:20.000000000 +0100
+++ new/lib/uglifier.rb 2019-09-25 21:50:32.000000000 +0200
@@ -98,6 +98,7 @@
:toplevel => false,
:ie8 => true, # Generate safe code for IE8
:source_map => false, # Generate source map
+ :error_context_lines => 8, # How many lines surrounding the error line
:harmony => false # Enable ES6/Harmony mode (experimental). Disabling
mangling and compressing is recommended with Harmony mode.
}
@@ -149,9 +150,6 @@
raise ArgumentError, "Invalid option: #{missing}"
end
@options = options
-
- source = harmony? ? source_with(HarmonySourcePath) :
source_with(SourcePath)
- @context = ExecJS.compile(source)
end
# Minifies JavaScript code
@@ -180,6 +178,13 @@
private
+ def context
+ @context ||= begin
+ source = harmony? ? source_with(HarmonySourcePath) :
source_with(SourcePath)
+ ExecJS.compile(source)
+ end
+ end
+
def source_map_comments
return '' unless @options[:source_map].respond_to?(:[])
@@ -213,25 +218,77 @@
:ie8 => ie8?
}
- parse_result(@context.call("uglifier", options), generate_map)
+ parse_result(context.call("uglifier", options), generate_map, options)
end
def harmony?
@options[:harmony]
end
- def error_message(result)
- result['error']['message'] +
- if result['error']['message'].start_with?("Unexpected token") &&
!harmony?
- ". To use ES6 syntax, harmony mode must be enabled with " \
- "Uglifier.new(:harmony => true)."
+ def harmony_error_message(message)
+ if message.start_with?("Unexpected token")
+ ". To use ES6 syntax, harmony mode must be enabled with " \
+ "Uglifier.new(:harmony => true)."
+ else
+ ""
+ end
+ end
+
+ def error_context_lines
+ @options.fetch(:error_context_lines, DEFAULTS[:error_context_lines]).to_i
+ end
+
+ def error_context_format_options(low, high, line_index, column)
+ line_width = high.to_s.size
+ {
+ :line_index => line_index,
+ :base_index => low,
+ :line_width => line_width,
+ :line_format => "\e[36m%#{line_width + 1}d\e[0m ", # cyan
+ :col => column
+ }
+ end
+
+ def format_error_line(line, options)
+ # light red
+ indicator = ' => '.rjust(options[:line_width] + 2)
+ colored_line = "#{line[0...options[:col]]}\e[91m#{line[options[:col]..-1]}"
+ "\e[91m#{indicator}\e[0m#{colored_line}\e[0m"
+ end
+
+ def format_lines(lines, options)
+ lines.map.with_index do |line, index|
+ if options[:base_index] + index == options[:line_index]
+ format_error_line(line, options)
else
- ""
+ "#{options[:line_format] % (options[:base_index] + index + 1)}#{line}"
end
+ end
+ end
+
+ def context_lines_message(source, line_number, column)
+ return if line_number.nil?
+
+ line_index = line_number - 1
+ lines = source.split("\n")
+
+ first_line = [line_index - error_context_lines, 0].max
+ last_line = [line_number + error_context_lines, lines.size].min
+ options = error_context_format_options(first_line, last_line, line_index,
column)
+ context_lines = lines[first_line...last_line]
+
+ "--\n#{format_lines(context_lines, options).join("\n")}\n=="
+ end
+
+ def error_message(result, options)
+ err = result['error']
+ harmony_msg = harmony? ? '' : harmony_error_message(err['message'].to_s)
+ src_ctx = context_lines_message(options[:source], err['line'], err['col'])
+ "#{err['message']}#{harmony_msg}\n#{src_ctx}"
end
- def parse_result(result, generate_map)
- raise Error, error_message(result) if result.has_key?('error')
+ def parse_result(result, generate_map, options)
+ raise Error, error_message(result, options) if result.has_key?('error')
if generate_map
[result['code'] + source_map_comments, result['map']]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2018-11-17 22:25:20.000000000 +0100
+++ new/metadata 2019-09-25 21:50:32.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: uglifier
version: !ruby/object:Gem::Version
- version: 4.1.20
+ version: 4.2.0
platform: ruby
authors:
- Ville Lautanala
autorequire:
bindir: bin
cert_chain: []
-date: 2018-11-17 00:00:00.000000000 Z
+date: 2019-09-25 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: execjs
@@ -62,14 +62,14 @@
name: bundler
requirement: !ruby/object:Gem::Requirement
requirements:
- - - "~>"
+ - - ">="
- !ruby/object:Gem::Version
version: '1.3'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - "~>"
+ - - ">="
- !ruby/object:Gem::Version
version: '1.3'
- !ruby/object:Gem::Dependency
@@ -99,6 +99,7 @@
- CONTRIBUTING.md
files:
- ".document"
+- ".github/workflows/ruby.yml"
- ".gitignore"
- ".gitmodules"
- ".rspec"
@@ -139,8 +140,7 @@
- !ruby/object:Gem::Version
version: '0'
requirements: []
-rubyforge_project:
-rubygems_version: 2.7.6
+rubygems_version: 3.0.3
signing_key:
specification_version: 4
summary: Ruby wrapper for UglifyJS JavaScript compressor
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/uglifier.gemspec new/uglifier.gemspec
--- old/uglifier.gemspec 2018-11-17 22:25:20.000000000 +0100
+++ new/uglifier.gemspec 2019-09-25 21:50:32.000000000 +0200
@@ -30,6 +30,6 @@
spec.add_runtime_dependency "execjs", [">= 0.3.0", "< 3"]
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rake", "~> 12.0"
- spec.add_development_dependency "bundler", "~> 1.3"
+ spec.add_development_dependency "bundler", ">= 1.3"
spec.add_development_dependency "sourcemap", "~> 0.1.1"
end