From 11e47409182bc1b67f266da5b23ef5e3065284ed Mon Sep 17 00:00:00 2001 From: wangchong1995924 <15229716099@163.com> Date: Fri, 21 Aug 2020 16:01:09 +0800 Subject: [PATCH] fix the warning --- generate-parser.js | 87 ------------------------------- nodejs-spdx-expression-parse.spec | 10 ++-- nodejs-spdx-expression-parse.yaml | 2 +- 3 files changed, 4 insertions(+), 95 deletions(-) delete mode 100644 generate-parser.js diff --git a/generate-parser.js b/generate-parser.js deleted file mode 100644 index bcb2e4e..0000000 --- a/generate-parser.js +++ /dev/null @@ -1,87 +0,0 @@ -var Generator = require('jison').Generator -var options = { - type: 'slr', - moduleType: 'commonjs', - moduleName: 'spdxparse' } - -var words = [ 'AND', 'OR', 'WITH' ] - -var quote = function(argument) { - return '\'' + argument + '\'' } - -var regexEscape = function(s) { - return s.replace(/[\^\\$*+?.()|{}\[\]\/]/g, '\\$&') } - -var handleLicensesAndExceptions = function() { - var ids = require('spdx-license-ids') - var exceptions = require('spdx-exceptions') - - // Sort tokens longest-first (both license ids and exception strings) - var tokens = ids.concat(exceptions) - tokens.sort(function(a, b) { return ( b.length - a.length ) }) - return tokens.map(function(t) { - var type = ( (ids.indexOf(t) >= 0) ? 'LICENSE' : 'EXCEPTION' ) - return [ regexEscape(t), ( 'return ' + quote(type) ) ] }) } - -var grammar = { - lex: { - macros: { }, - rules: [ - [ '$', 'return ' + quote('EOS') ], - [ '\\s+', '/* skip whitespace */' ], - [ '\\+', 'return ' + quote('PLUS') ], - [ '\\(', 'return ' + quote('OPEN') ], - [ '\\)', 'return ' + quote('CLOSE') ], - [ ':', 'return ' + quote('COLON') ], - [ 'DocumentRef-([0-9A-Za-z-+.]+)', - 'return ' + quote('DOCUMENTREF') ], - [ 'LicenseRef-([0-9A-Za-z-+.]+)', - 'return ' + quote('LICENSEREF') ] ] - .concat(words.map(function(word) { - return [ word, 'return ' + quote(word) ] })) - .concat(handleLicensesAndExceptions()) }, - operators: [ - [ 'left', 'OR' ], - [ 'left', 'AND' ], - [ 'right', 'PLUS', 'WITH' ] ], - tokens: [ - 'CLOSE', - 'COLON', - 'EXCEPTION', - 'LICENSE', - 'LICENSEREF', - 'OPEN', - 'PLUS' ] - .concat(words) - .join(' '), - start: 'start', - bnf: { - start: [ - [ 'expression EOS', 'return $$ = $1' ] ], - simpleExpression: [ - [ 'LICENSE', - '$$ = { license: yytext }' ], - [ 'LICENSE PLUS', - '$$ = { license: $1, plus: true }' ], - [ 'LICENSEREF', - '$$ = { license: yytext }' ], - [ 'DOCUMENTREF COLON LICENSEREF', - '$$ = { license: yytext }' ] ], - expression: [ - [ 'simpleExpression', - '$$ = $1' ], - [ 'simpleExpression WITH EXCEPTION', - [ '$$ = { exception: $3 }', - '$$.license = $1.license', - 'if ($1.hasOwnProperty(\'plus\')) {', - ' $$.plus = $1.plus', - '}' ] - .join('\n') ], - [ 'expression AND expression', - '$$ = { conjunction: \'and\', left: $1, right: $3 }' ], - [ 'expression OR expression', - '$$ = { conjunction: \'or\', left: $1, right: $3 }' ], - [ 'OPEN expression CLOSE', - '$$ = $2' ] ] } } - -console.log(new Generator(grammar, options).generate()) diff --git a/nodejs-spdx-expression-parse.spec b/nodejs-spdx-expression-parse.spec index 2778bbf..63e47ec 100644 --- a/nodejs-spdx-expression-parse.spec +++ b/nodejs-spdx-expression-parse.spec @@ -8,25 +8,21 @@ Summary: Parse SPDX license expressions License: MIT and CC-BY URL: https://github.com/kemitchell/spdx-expression-parse.js.git Source0: https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-%{version}.tgz -Source1: https://raw.githubusercontent.com/kemitchell/spdx-expression-parse.js/v%{version}/generate-parser.js ExclusiveArch: %{nodejs_arches} noarch BuildArch: noarch -BuildRequires: nodejs-packaging uglify-js npm(jison) npm(spdx-license-ids) -BuildRequires: npm(spdx-exceptions) +BuildRequires: nodejs-packaging uglify-js npm(jison) npm(spdx-license-ids) +BuildRequires: npm(spdx-exceptions) %if 0%{?enable_tests} %endif -Requires: nodejs +Requires: nodejs %description Parse SPDX license expressions %prep %setup -q -n package -cp -p %{SOURCE1} . -rm parser.generated.js %build %nodejs_symlink_deps --check -%__nodejs generate-parser.js | %{_bindir}/uglifyjs > parser.generated.js %install mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename} diff --git a/nodejs-spdx-expression-parse.yaml b/nodejs-spdx-expression-parse.yaml index 7237a42..ec5fce1 100644 --- a/nodejs-spdx-expression-parse.yaml +++ b/nodejs-spdx-expression-parse.yaml @@ -1,4 +1,4 @@ -version-control: github +version_control: github src_repo: kemitchell/spdx-expression-parse.js tag_prefix: ^v seperator: .