From b21826c802b411909feb7c2db5aab124e03314c1 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sun, 3 Dec 2017 17:53:44 -0800 Subject: [PATCH] Drop support for legacy environments and package managers --- .travis.yml | 20 +++---------------- Gruntfile.js | 31 +---------------------------- README.md | 38 ++--------------------------------- bower.json | 14 ------------- component.json | 16 --------------- package.json | 15 ++++++++------ tests/index.html | 23 +-------------------- utf8.js | 52 +++++------------------------------------------- 8 files changed, 21 insertions(+), 188 deletions(-) delete mode 100644 bower.json delete mode 100644 component.json diff --git a/.travis.yml b/.travis.yml index e15c45e..128917b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,23 +3,9 @@ node_js: - "0.10" - "0.12" - "4" - - "5" - "6" -before_script: - - "npm install -g grunt-cli" - # Narwhal uses a hardcoded path to openjdk v6, so use that version - - "sudo apt-get update -qq" - - "sudo apt-get install -qq openjdk-6-jre" - - "PACKAGE=rhino1_7R5; wget https://github.com/mozilla/rhino/releases/download/Rhino1_7R5_RELEASE/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" - - "PACKAGE=rhino1_7R5; echo -e '#!/bin/sh\\njava -jar /opt/'$PACKAGE'/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino" - - "PACKAGE=ringojs-0.11; wget https://github.com/ringo/ringojs/releases/download/v0.11.0/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" - - "PACKAGE=ringojs-0.11; sudo ln -s /opt/$PACKAGE/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo" - - "PACKAGE=v0.3.2; wget https://github.com/280north/narwhal/archive/$PACKAGE.zip && sudo unzip $PACKAGE -d /opt/ && rm $PACKAGE.zip" - - "PACKAGE=narwhal-0.3.2; sudo ln -s /opt/$PACKAGE/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal" - # If the enviroment stores rt.jar in a different directory, find it and symlink the directory - - "PREFIX=/usr/lib/jvm; if [ ! -d $PREFIX/java-6-openjdk ]; then for d in $PREFIX/java-6-openjdk-*; do if [ -e $d/jre/lib/rt.jar ]; then sudo ln -s $d $PREFIX/java-6-openjdk; break; fi; done; fi" - - "sudo apt-get install -qq python; python --version" + - "8" script: - - "grunt ci" + - npm run ci after_script: - - "grunt shell:cover-coveralls" + - npm run cover-coveralls diff --git a/Gruntfile.js b/Gruntfile.js index 2bded93..aeb8e0f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,36 +7,11 @@ module.exports = function(grunt) { 'stderr': true, 'failOnError': true }, - 'generate-test-data': { // Only when needed - 'command': 'if [ ! -f data.json ]; then python generate-test-data.py; fi', - 'options': { - 'execOptions': { - 'cwd': 'tests' - } - } - }, 'cover-html': { 'command': 'istanbul cover --report "html" --verbose --dir "coverage" "tests/tests.js"; istanbul report --root "coverage" --format "html"' }, 'cover-coveralls': { - 'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && coveralls < coverage/lcov.info|coveralls < coverage/lcov.info; rm -rf coverage/lcov*' - }, - 'test-narwhal': { - 'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "tests/tests.js"' - }, - 'test-phantomjs': { - 'command': 'echo "Testing in PhantomJS..."; phantomjs "tests/tests.js"' - }, - 'test-rhino': { - 'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"', - 'options': { - 'execOptions': { - 'cwd': 'tests' - } - } - }, - 'test-ringo': { - 'command': 'echo "Testing in Ringo..."; ringo -o -1 "tests/tests.js"' + 'command': 'istanbul cover --verbose --dir "coverage" "tests/tests.js" && coveralls < coverage/lcov.info; rm -rf coverage/lcov*' }, 'test-node': { 'command': 'echo "Testing in Node..."; node "tests/tests.js"' @@ -55,10 +30,6 @@ module.exports = function(grunt) { grunt.registerTask('cover', 'shell:cover-html'); grunt.registerTask('ci', [ 'shell:generate-test-data', - 'shell:test-narwhal', - 'shell:test-phantomjs', - 'shell:test-rhino', - 'shell:test-ringo', 'shell:test-node', ]); grunt.registerTask('test', [ diff --git a/README.md b/README.md index 36b8de0..595a51b 100644 --- a/README.md +++ b/README.md @@ -12,50 +12,16 @@ Via [npm](https://www.npmjs.com/): npm install utf8 ``` -Via [Bower](http://bower.io/): - -```bash -bower install utf8 -``` - -Via [Component](https://github.com/component/component): - -```bash -component install mathiasbynens/utf8.js -``` - In a browser: ```html ``` -In [Narwhal](http://narwhaljs.org/), [Node.js](https://nodejs.org/), and [RingoJS ≥ v0.8.0](http://ringojs.org/): - -```js -var utf8 = require('utf8'); -``` - -In [Rhino](http://www.mozilla.org/rhino/): - -```js -load('utf8.js'); -``` - -Using an AMD loader like [RequireJS](http://requirejs.org/): +In [Node.js](https://nodejs.org/): ```js -require( - { - 'paths': { - 'utf8': 'path/to/utf8' - } - }, - ['utf8'], - function(utf8) { - console.log(utf8); - } -); +const utf8 = require('utf8'); ``` ## API diff --git a/bower.json b/bower.json deleted file mode 100644 index fe8fa72..0000000 --- a/bower.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "utf8", - "version": "2.0.0", - "main": "utf8.js", - "ignore": [ - "coverage", - "tests", - ".*", - "component.json", - "Gruntfile.js", - "node_modules", - "package.json" - ] -} diff --git a/component.json b/component.json deleted file mode 100644 index c01c568..0000000 --- a/component.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "utf8", - "version": "2.0.0", - "description": "A well-tested UTF-8 encoder/decoder written in JavaScript.", - "repo": "mathiasbynens/utf8.js", - "license": "MIT", - "scripts": [ - "utf8.js" - ], - "keywords": [ - "charset", - "encoding", - "unicode", - "utf8" - ] -} diff --git a/package.json b/package.json index 91dd9f2..4f0b446 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "utf8", - "version": "2.1.2", + "version": "3.0.0", "description": "A well-tested UTF-8 encoder/decoder written in JavaScript.", "homepage": "https://mths.be/utf8js", "main": "utf8.js", @@ -25,15 +25,18 @@ "utf8.js" ], "scripts": { - "test": "node tests/tests.js" + "test": "node tests/tests.js", + "test-extended": "node tests/tests.js --extended", + "test-browser": "open tests/index.html", + "ci": "npm run build && npm test", + "build": "cd tests; if [ ! -f data.json ]; then python generate-test-data.py; fi", + "cover-html": "istanbul cover --report html --verbose --dir coverage tests/tests.js; istanbul report --root coverage --format html", + "cover-coveralls": "istanbul cover --verbose --dir coverage tests/tests.js && coveralls < coverage/lcov.info; rm -rf coverage/lcov*" }, "devDependencies": { "coveralls": "^2.11.14", - "grunt": "^1.0.1", - "grunt-shell": "^1.1.2", "istanbul": "^0.4.5", "qunit-extras": "^1.4.2", - "qunitjs": "~1.11.0", - "requirejs": "^2.3.2" + "qunitjs": "~1.11.0" } } diff --git a/tests/index.html b/tests/index.html index 13cc04d..b2276cd 100644 --- a/tests/index.html +++ b/tests/index.html @@ -9,27 +9,6 @@
- - + diff --git a/utf8.js b/utf8.js index c55e85c..d301582 100644 --- a/utf8.js +++ b/utf8.js @@ -1,22 +1,6 @@ -/*! https://mths.be/utf8js v2.1.2 by @mathias */ +/*! https://mths.be/utf8js v3.0.0 by @mathias */ ;(function(root) { - // Detect free variables `exports` - var freeExports = typeof exports == 'object' && exports; - - // Detect free variable `module` - var freeModule = typeof module == 'object' && module && - module.exports == freeExports && module; - - // Detect free variable `global`, from Node.js or Browserified code, - // and use it as `root` - var freeGlobal = typeof global == 'object' && global; - if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { - root = freeGlobal; - } - - /*--------------------------------------------------------------------------*/ - var stringFromCharCode = String.fromCharCode; // Taken from https://mths.be/punycode @@ -211,34 +195,8 @@ /*--------------------------------------------------------------------------*/ - var utf8 = { - 'version': '2.1.2', - 'encode': utf8encode, - 'decode': utf8decode - }; - - // Some AMD build optimizers, like r.js, check for specific condition patterns - // like the following: - if ( - typeof define == 'function' && - typeof define.amd == 'object' && - define.amd - ) { - define(function() { - return utf8; - }); - } else if (freeExports && !freeExports.nodeType) { - if (freeModule) { // in Node.js or RingoJS v0.8.0+ - freeModule.exports = utf8; - } else { // in Narwhal or RingoJS v0.7.0- - var object = {}; - var hasOwnProperty = object.hasOwnProperty; - for (var key in utf8) { - hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]); - } - } - } else { // in Rhino or a web browser - root.utf8 = utf8; - } + root.version = '3.0.0'; + root.encode = utf8encode; + root.decode = utf8decode; -}(this)); +}(typeof exports === 'undefined' ? this.utf8 = {} : exports));