scanoss 0.4.8-beta → 0.4.10-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/workspace.xml +100 -3
- package/build/main/cli/bin/cli-bin.js +2 -3
- package/build/main/cli/commands/scan.js +1 -16
- package/build/main/index.d.ts +1 -8
- package/build/main/index.js +2 -13
- package/build/main/sdk/filters/filtering.js +1 -1
- package/build/main/sdk/scanner/Dispatcher/Dispatcher.js +1 -1
- package/build/main/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.d.ts +2 -2
- package/build/main/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.js +2 -1
- package/build/main/sdk/scanner/WfpProvider/WfpProvider.d.ts +4 -1
- package/build/main/sdk/scanner/WfpProvider/WfpProvider.js +7 -1
- package/build/main/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.d.ts +2 -1
- package/build/main/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +54 -10
- package/build/main/sdk/tree/File.js +2 -2
- package/build/main/sdk/tree/Filters/DependencyFilter.js +2 -2
- package/build/main/sdk/tree/Filters/ScanFilter.js +2 -2
- package/build/main/sdk/tree/Folder.d.ts +0 -1
- package/build/main/sdk/tree/Folder.js +2 -5
- package/build/main/sdk/tree/Node.d.ts +0 -1
- package/build/main/sdk/tree/Node.js +1 -4
- package/build/main/sdk/tree/Tree.js +1 -2
- package/build/main/tsconfig.tsbuildinfo +63 -223
- package/build/module/cli/bin/cli-bin.js +2 -3
- package/build/module/cli/commands/scan.js +1 -16
- package/build/module/index.d.ts +1 -8
- package/build/module/index.js +2 -13
- package/build/module/sdk/filters/filtering.js +1 -1
- package/build/module/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.d.ts +2 -2
- package/build/module/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.js +2 -1
- package/build/module/sdk/scanner/WfpProvider/WfpProvider.d.ts +4 -1
- package/build/module/sdk/scanner/WfpProvider/WfpProvider.js +7 -1
- package/build/module/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.d.ts +2 -1
- package/build/module/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.js +53 -10
- package/build/module/sdk/tree/File.js +2 -2
- package/build/module/sdk/tree/Filters/DependencyFilter.js +2 -2
- package/build/module/sdk/tree/Filters/ScanFilter.js +2 -2
- package/build/module/sdk/tree/Folder.d.ts +0 -1
- package/build/module/sdk/tree/Folder.js +2 -5
- package/build/module/sdk/tree/Node.d.ts +0 -1
- package/build/module/sdk/tree/Node.js +1 -4
- package/build/module/sdk/tree/Tree.js +1 -2
- package/build/module/tsconfig.module.tsbuildinfo +63 -223
- package/package-lock.json +2 -2
- package/package.json +2 -9
- package/src/cli/bin/cli-bin.ts +2 -2
- package/src/cli/commands/scan.ts +0 -21
- package/src/index.ts +2 -14
- package/src/sdk/filters/filtering.ts +0 -1
- package/src/sdk/scanner/WfpProvider/WfpCalculator/WfpCalculator.ts +3 -1
- package/src/sdk/scanner/WfpProvider/WfpProvider.ts +15 -1
- package/src/sdk/scanner/WfpProvider/WfpSplitter/WfpSplitter.ts +70 -10
- package/src/sdk/tree/File.ts +1 -1
- package/src/sdk/tree/Filters/DependencyFilter.ts +1 -1
- package/src/sdk/tree/Filters/ScanFilter.ts +1 -1
- package/src/sdk/tree/Folder.ts +1 -4
- package/src/sdk/tree/Node.ts +0 -4
- package/src/sdk/tree/Tree.ts +0 -1
- package/tests/scanoss.sh +61 -0
- package/tests/sdk/Scanner/WfpProvider/WfpSplitter/WfpSplitter.spec.ts +37 -0
- package/tests/sdk/Scanner/WfpProvider/WfpSplitter/samples/wfp.wfp +68 -0
- package/tests/sdk/Scanner/WfpProvider/WfpSplitter/samples/wfp.wfp~ +68 -0
- package/yarn.lock +4736 -5067
- package/src/sdk/Decompress/DecompressionManager.ts +0 -80
- package/src/sdk/Decompress/Decompressor/DecompressTgz.ts +0 -20
- package/src/sdk/Decompress/Decompressor/DecompressZips.ts +0 -21
- package/src/sdk/Decompress/Decompressor/Decompressor.ts +0 -20
- package/src/sdk/tree/Filters/DecompressionFilter.ts +0 -22
- package/tests/sdk/DataLayer/DataProviderManager.spec.ts +0 -19
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { Tree } from '../tree/Tree';
|
|
4
|
-
import { DecompressionFilter } from '../tree/Filters/DecompressionFilter';
|
|
5
|
-
import { Decompressor } from './Decompressor/Decompressor';
|
|
6
|
-
import { DecompressZip } from './Decompressor/DecompressZips';
|
|
7
|
-
import { DecompressTgz } from './Decompressor/DecompressTgz';
|
|
8
|
-
|
|
9
|
-
export class DecompressionManager {
|
|
10
|
-
|
|
11
|
-
private decompressorList: Array<Decompressor>
|
|
12
|
-
|
|
13
|
-
private decompressionLevel: number;
|
|
14
|
-
|
|
15
|
-
private suffix: string;
|
|
16
|
-
|
|
17
|
-
private removeFolderOnFailure: boolean;
|
|
18
|
-
|
|
19
|
-
constructor(decompressionLevel: number = 1, suffix: string = "-unzipped", removeFolderOnFailure: boolean = false) {
|
|
20
|
-
this.decompressionLevel = decompressionLevel;
|
|
21
|
-
this.removeFolderOnFailure = removeFolderOnFailure;
|
|
22
|
-
this.suffix = suffix;
|
|
23
|
-
|
|
24
|
-
this.decompressorList = [
|
|
25
|
-
new DecompressTgz(),
|
|
26
|
-
new DecompressZip()
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public addDecompressor(d: Decompressor) {
|
|
32
|
-
this.decompressorList.push(d);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public getSupportedFormats(): Array<string> {
|
|
36
|
-
const supportedFormats = [];
|
|
37
|
-
this.decompressorList.forEach((d) => {
|
|
38
|
-
supportedFormats.push(...d.getSupportedFormats())
|
|
39
|
-
});
|
|
40
|
-
return supportedFormats;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public async decompress(archivesPaths: Array<string>): Promise<Array<string>> {
|
|
44
|
-
for (const archivePath of archivesPaths) await this.decompressRecursive(archivePath, 0);
|
|
45
|
-
const parentFoldersPath = archivesPaths.map(archivePath => `${archivePath}${this.suffix}`);
|
|
46
|
-
return parentFoldersPath;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public async decompressRecursive(archivePath: string, level: number): Promise<void> {
|
|
50
|
-
if(level>=this.decompressionLevel) return
|
|
51
|
-
|
|
52
|
-
const archiveRootPath = path.dirname(archivePath);
|
|
53
|
-
const archiveName = path.basename(archivePath);
|
|
54
|
-
const newFolderPath = `${archiveRootPath}${path.sep}${archiveName}${this.suffix}`;
|
|
55
|
-
|
|
56
|
-
const isSupported = this.decompressorList.some((d) => d.isSupported(archiveName))
|
|
57
|
-
if(isSupported) {
|
|
58
|
-
await fs.promises.mkdir(newFolderPath, { recursive: true });
|
|
59
|
-
|
|
60
|
-
//Search for decompressor and extract archive
|
|
61
|
-
for (const d of this.decompressorList) {
|
|
62
|
-
if (d.isSupported(archiveName)) {
|
|
63
|
-
await d.run(archivePath, newFolderPath);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//Search for new archives
|
|
70
|
-
const tree = new Tree(newFolderPath);
|
|
71
|
-
tree.build()
|
|
72
|
-
const newFilesPath = tree.getFileList(new DecompressionFilter(""));
|
|
73
|
-
for (const newFilePath of newFilesPath) {
|
|
74
|
-
await this.decompressRecursive(newFilePath, level+1);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Decompressor } from './Decompressor';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import tar from 'tar';
|
|
4
|
-
|
|
5
|
-
export class DecompressTgz extends Decompressor{
|
|
6
|
-
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
this.supportedFormats = [
|
|
10
|
-
".tar.gz",
|
|
11
|
-
".tgz",
|
|
12
|
-
".tar",
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public async run(archivePath: string, destPath: string): Promise<void> {
|
|
17
|
-
return tar.x({C: destPath, file: archivePath});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Decompressor } from './Decompressor';
|
|
2
|
-
import AdmZip from 'adm-zip';
|
|
3
|
-
|
|
4
|
-
export class DecompressZip extends Decompressor{
|
|
5
|
-
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.supportedFormats = [
|
|
9
|
-
".zip",
|
|
10
|
-
".jar",
|
|
11
|
-
".ear",
|
|
12
|
-
".war"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public async run(archivePath: string, destPath: string): Promise<void> {
|
|
17
|
-
const zip = new AdmZip(archivePath);
|
|
18
|
-
zip.extractAllTo(destPath);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export abstract class Decompressor {
|
|
2
|
-
protected supportedFormats: Array<string>;
|
|
3
|
-
|
|
4
|
-
public abstract async run(archivePath: string, destPath: string): Promise<void>;
|
|
5
|
-
|
|
6
|
-
public isSupported(filename: string) {
|
|
7
|
-
if (this.supportedFormats.some((format) => filename.endsWith(format))) return true;
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Returns the extension supported by this decompressor
|
|
14
|
-
* Includes the '.' appended
|
|
15
|
-
*/
|
|
16
|
-
public getSupportedFormats(): Array<string> {
|
|
17
|
-
return this.supportedFormats;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Filter } from './Filter';
|
|
2
|
-
import Node, { NodeType } from '../Node';
|
|
3
|
-
import { DecompressionManager } from '../../Decompress/DecompressionManager';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
export class DecompressionFilter extends Filter {
|
|
7
|
-
|
|
8
|
-
private supportedFileExtension: Array<string>;
|
|
9
|
-
|
|
10
|
-
public constructor(filterName: string) {
|
|
11
|
-
super();
|
|
12
|
-
this.supportedFileExtension = new DecompressionManager().getSupportedFormats();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
//Returns true if you want the file
|
|
16
|
-
public evaluate(node: Node): boolean {
|
|
17
|
-
if(node.getType() == NodeType.FOLDER) return true;
|
|
18
|
-
if (this.supportedFileExtension.some(supportedFormat => node.getName().endsWith(supportedFormat))) return true;
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { expect } from 'chai';
|
|
4
|
-
|
|
5
|
-
import { ComponentDataProvider } from '../../../src/sdk/DataLayer/DataProviders/ComponentDataProvider';
|
|
6
|
-
import { DependencyDataProvider } from '../../../src/sdk/DataLayer/DataProviders/DependencyDataProvider';
|
|
7
|
-
import { SummaryDataProvider } from '../../../src/sdk/DataLayer/DataProviders/SummaryDataProvider';
|
|
8
|
-
import { LicenseDataProvider } from '../../../src/sdk/DataLayer/DataProviders/LicenseDataProvider';
|
|
9
|
-
|
|
10
|
-
import { DataProviderManager } from '../../../src/sdk/DataLayer/DataProviderManager';
|
|
11
|
-
|
|
12
|
-
// describe('Suit test for DataProviderManager', () => {
|
|
13
|
-
//
|
|
14
|
-
// it('Test DataProviderManager Simple', function () {
|
|
15
|
-
//
|
|
16
|
-
// });
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// });
|