7
7
*/
8
8
// tslint:disable:no-implicit-dependencies
9
9
import { JsonObject , logging } from '@angular-devkit/core' ;
10
+ import * as path from 'path' ;
11
+ import { packages } from '../lib/packages' ;
10
12
11
13
require ( '../lib/bootstrap-local' ) ;
12
14
13
- const path = require ( 'path' ) ;
14
15
const spdxSatisfies = require ( 'spdx-satisfies' ) ;
15
16
16
17
@@ -43,9 +44,6 @@ const licensesWhitelist = [
43
44
44
45
// Combinations.
45
46
'(AFL-2.1 OR BSD-2-Clause)' ,
46
- '(MIT OR CC-BY-3.0)' ,
47
- '(MIT OR Apache-2.0)' ,
48
- '(MIT OR BSD-3-Clause)' ,
49
47
] ;
50
48
51
49
// Name variations of SPDX licenses that some packages have.
@@ -62,40 +60,39 @@ const licenseReplacements: { [key: string]: string } = {
62
60
63
61
// Specific packages to ignore, add a reason in a comment. Format: package-name@version.
64
62
const ignoredPackages = [
65
- '[email protected] ' , // CC0 but it's content only (index.json, no code) and not distributed.
63
+ // * Development only
66
64
'[email protected] ' , // CC0 but it's content only (index.json, no code) and not distributed.
67
- '[email protected] ' , // MIT, license but it's not listed in package.json.
68
- '[email protected] ' , // LGPL,MIT but has a broken licenses array.
69
- '[email protected] ' , // Apache-2.0 but broken license in package.json
65
+ '[email protected] ' , // LGPL-3.0 but only used as a tool, not linked in the build.
66
+
67
+ // * Broken license fields
68
+ '[email protected] ' , // MIT but no license field in package.json
70
69
'[email protected] ' , // MIT but broken license in package.json
70
+ '[email protected] ' , // Apache-2.0 but broken license in package.json
71
71
72
+ // * Other
72
73
'[email protected] ' , // TODO(hansl): fix this. this is not an acceptable license, but is 8 deps down
73
74
// so hard to manage. In talk with owner and users to switch over.
74
-
75
- '[email protected] ' , // TODO(filipesilva): remove this when karma is moved to e2e tests.
75
+ '[email protected] ' , // Zlib -- TODO(filipesilva): remove this when karma is moved to e2e tests.
76
76
// TODO(filipesilva): remove this when spec_large is moved to e2e tests.
77
77
'[email protected] ' , // (OFL-1.1 AND MIT)
78
-
79
- '@webassemblyjs/[email protected] ' , // MIT but no LICENSE file. `license` field in package.json.
80
- '@webassemblyjs/[email protected] ' , // Apache 2.0 license, but get discovered as "Apache".
81
- '@webassemblyjs/[email protected] ' , // Apache 2.0 license, but get discovered as "Apache".
82
-
83
- '[email protected] ' , // LGPL-3.0 but only used as a tool, not linked in the build.
84
78
] ;
85
79
80
+ // Ignore own packages (all MIT)
81
+ for ( const packageName of Object . keys ( packages ) ) {
82
+ ignoredPackages . push ( `${ packageName } @0.0.0` ) ;
83
+ }
84
+
86
85
// Find all folders directly under a `node_modules` that have a package.json.
87
86
const checker = require ( 'license-checker' ) ;
88
87
89
88
90
89
// Check if a license is accepted by an array of accepted licenses
91
90
function _passesSpdx ( licenses : string [ ] , accepted : string [ ] ) {
92
- return accepted . some ( l => {
93
- try {
94
- return spdxSatisfies ( licenses . join ( ' AND ' ) , l ) ;
95
- } catch ( _ ) {
96
- return false ;
97
- }
98
- } ) ;
91
+ try {
92
+ return spdxSatisfies ( licenses . join ( ' AND ' ) , accepted . join ( ' OR ' ) ) ;
93
+ } catch {
94
+ return false ;
95
+ }
99
96
}
100
97
101
98
@@ -113,8 +110,7 @@ export default function (_options: {}, logger: logging.Logger): Promise<number>
113
110
. map ( key => ( {
114
111
id : key ,
115
112
licenses : ( [ ] as string [ ] )
116
- // tslint:disable-next-line:non-null-operator
117
- . concat ( ( json [ key ] ! as JsonObject ) . licenses as string [ ] )
113
+ . concat ( ( json [ key ] as JsonObject ) . licenses as string [ ] )
118
114
// `*` is used when the license is guessed.
119
115
. map ( x => x . replace ( / \* $ / , '' ) )
120
116
. map ( x => x in licenseReplacements ? licenseReplacements [ x ] : x ) ,
0 commit comments