This commit is contained in:
sentsin
2017-08-21 08:50:25 +08:00
parent 06c11ba9cd
commit 7feaa4eca0
1899 changed files with 181363 additions and 22513 deletions

4
node_modules/uglify-save-license/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,4 @@
.travis.yml
.jshintrc
Gruntfile.coffee
test/

20
node_modules/uglify-save-license/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 - 2014 Shinnosuke Watanabe
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

192
node_modules/uglify-save-license/README.md generated vendored Normal file
View File

@@ -0,0 +1,192 @@
# uglify-save-license
[![NPM version](https://badge.fury.io/js/uglify-save-license.svg)](http://badge.fury.io/js/uglify-save-license)
[![Build Status](https://travis-ci.org/shinnn/uglify-save-license.svg)](https://travis-ci.org/shinnn/uglify-save-license)
[![devDependency Status](https://david-dm.org/shinnn/uglify-save-license/dev-status.svg)](https://david-dm.org/shinnn/uglify-save-license#info=devDependencies)
A support module for [UglifyJS](http://lisperator.net/uglifyjs/) to detect and preserve license comments
```javascript
// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function(root, factory) {
// Set up Backbone appropriately for the environment. Start with AMD.
if (typeof define === 'function' && define.amd) {
define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
//...
```
```javascript
// Backbone.js 1.1.2
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
!function(a,b){if("function"==typeof define&&define.amd)define(["underscore","jquery","exports"],function(c,d,e){a.Backbone=b(a,e,c,d)});else if("undefined"!=typeof exports){...
```
## Overview
This module enables us to preserve license comments when using UglifyJS.
Even if the license statement is in multiple line comments, or the comment has no directive such as `@license` and `/*!`, this module keeps them readable.
## Installation
Install with [npm](https://npmjs.org/). (Make sure you have installed [Node](http://nodejs.org/download/).)
```
npm install --save-dev uglify-save-license
```
## Usage
First of all, load `uglify-save-license` module.
```javascript
var saveLicense = require('uglify-save-license');
```
### Use with [UglifyJS](https://github.com/mishoo/UglifyJS2)
Pass this module to the [`comments` option](https://github.com/mishoo/UglifyJS2#keeping-comments-in-the-output).
```javascript
var result = UglifyJS.minify('file1.js', {
output: {
comments: saveLicense
}
});
```
### Use with [grunt-contrib-uglify](https://github.com/gruntjs/grunt-contrib-uglify)
Pass this module to the [`preserveComments` option](https://github.com/gruntjs/grunt-contrib-uglify#preservecomments).
```javascript
grunt.initConfig({
uglify: {
my_target: {
options: {
preserveComments: saveLicense
},
src: ['src/app.js'],
dest: 'dest/app.min.js'
}
}
});
```
## How it works
*uglify-save-license* checks each [comment token](http://lisperator.net/uglifyjs/ast#tokens) of a JavaScript file.
The comment will be regarded as a license statement and preserved after compression, if it meets at least one of the following requirements:
1. The comment is in the *first* line of a file.
2. [The regexp for license statement](./uglify-save-license.js#L7) matches the string of the comment. It matches, for example, `MIT` and `Copyright`.
3. There is a comment at the *previous* line, and it matches 1. 2. or 3.
## Examples
### CLI tool example
#### Main script (`uglify-example.js`)
```javascript
#!/usr/bin/env node
var UglifyJS = require('uglify-js'),
saveLicense = require('uglify-save-license');
var minified = UglifyJS.minify(process.argv[2], {
output: {
comments: saveLicense
}
}).code;
console.log(minified);
```
#### Target file
```javascript
// First line
// (c) 2014 John <- contains '(c)'
// The previous line is preserved
// This line won't be preserved.
(function(win, doc) {
var str = 'Hello World! :' + doc.title;
// This line will not, too.
console.log(str);
}(window, document));
```
#### Command
```
node uglify-example.js <target filename>
```
#### Output
```javascript
// First line
// (c) 2014 John <- contains '(c)'
// The previous line is preserved
!function(o,l){var n="Hello World! :"+l.title;console.log(n)}(window,document);
```
### [Gruntfile.coffee](http://gruntjs.com/getting-started#the-gruntfile) example
```coffeescript
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-contrib-concat'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.initConfig
uglify:
target:
options:
preserveComments: require 'uglify-save-license'
files: [
expand: true
flatten: true
cwd: 'path/to/src'
src: ['**/*.js']
dest: 'tmp/'
]
concat:
js:
src: ['tmp/*.js']
dest: 'path/to/build/app.js'
clean:
tmpdir: ['tmp']
grunt.registerTask 'default' ['uglify', 'concat', 'clean']
```
## Acknowledgements
*uglify-save-license* is inspired by [grunt-license-saver](https://github.com/kyo-ago/grunt-license-saver) and I used it as reference.
Thanks, [kyo-ago](https://github.com/kyo-ago).
## License
Copyright (c) 2013 - 2014 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT license](./LICENSE).

105
node_modules/uglify-save-license/package.json generated vendored Normal file
View File

@@ -0,0 +1,105 @@
{
"_args": [
[
{
"raw": "uglify-save-license@^0.4.1",
"scope": null,
"escapedName": "uglify-save-license",
"name": "uglify-save-license",
"rawSpec": "^0.4.1",
"spec": ">=0.4.1 <0.5.0",
"type": "range"
},
"D:\\web\\layui\\res\\layui\\node_modules\\gulp-uglify"
]
],
"_from": "uglify-save-license@>=0.4.1 <0.5.0",
"_id": "uglify-save-license@0.4.1",
"_inCache": true,
"_location": "/uglify-save-license",
"_npmUser": {
"name": "shinnn",
"email": "snnskwtnb@gmail.com"
},
"_npmVersion": "1.4.7",
"_phantomChildren": {},
"_requested": {
"raw": "uglify-save-license@^0.4.1",
"scope": null,
"escapedName": "uglify-save-license",
"name": "uglify-save-license",
"rawSpec": "^0.4.1",
"spec": ">=0.4.1 <0.5.0",
"type": "range"
},
"_requiredBy": [
"/gulp-uglify"
],
"_resolved": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz",
"_shasum": "95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1",
"_shrinkwrap": null,
"_spec": "uglify-save-license@^0.4.1",
"_where": "D:\\web\\layui\\res\\layui\\node_modules\\gulp-uglify",
"author": {
"name": "Shinnosuke Watanabe",
"url": "https://github.com/shinnn"
},
"bugs": {
"url": "https://github.com/shinnn/uglify-save-license/issues"
},
"dependencies": {},
"description": "License detector for UglifyJS",
"devDependencies": {
"grunt": "^0.4.4",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-nodeunit": "^0.3.3",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-release": "^0.7.0",
"grunt-replace": "^0.7.7",
"load-grunt-tasks": "^0.4.0",
"semver": "^2.2.1"
},
"directories": {},
"dist": {
"shasum": "95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1",
"tarball": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz"
},
"homepage": "https://github.com/shinnn/uglify-save-license",
"keywords": [
"uglify",
"compression",
"minification",
"comment",
"license",
"copyright",
"detection",
"preservation",
"banner"
],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/shinnn/uglify-save-license/blob/master/LICENSE"
}
],
"main": "./uglify-save-license.js",
"maintainers": [
{
"name": "shinnn",
"email": "snnskwtnb@gmail.com"
}
],
"name": "uglify-save-license",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/shinnn/uglify-save-license.git"
},
"scripts": {
"test": "grunt build"
},
"version": "0.4.1"
}

View File

@@ -0,0 +1,34 @@
// uglify-save-license.js v0.4.1
// Copyright (c) 2013 - 2014 Shinnosuke Watanabe
// Licensed uder the MIT license
'use strict';
var licenseRegexp = /@preserve|@cc_on|\bMIT\b|\bMPL\b|\bGPL\b|\bBSD\b|\bISCL\b|\(c\)|License|Copyright/mi;
// number of line where license comment appeared last
var prevCommentLine = 0;
// name of the file minified last
var prevFile = '';
module.exports = function saveLicense(node, comment) {
if (comment.file !== prevFile) {
prevCommentLine = 0;
}
var isLicense = licenseRegexp.test(comment.value) ||
(comment.type === 'comment2' &&
comment.value.charAt(0) === '!') ||
comment.line === 1 ||
comment.line === prevCommentLine + 1;
if (isLicense) {
prevCommentLine = comment.line;
} else {
prevCommentLine = 0;
}
prevFile = comment.file;
return isLicense;
};