-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathplatform-project-service-base.ts
67 lines (60 loc) · 1.8 KB
/
platform-project-service-base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { EventEmitter } from "events";
import * as _ from "lodash";
import {
IProjectDataService,
IPlatformProjectServiceBase,
IProjectData,
} from "../definitions/project";
import { IPlatformData } from "../definitions/platform";
import { IPluginData } from "../definitions/plugins";
import { IFileSystem } from "../common/declarations";
import { PlatformTypes } from "../constants";
export abstract class PlatformProjectServiceBase
extends EventEmitter
implements IPlatformProjectServiceBase {
constructor(
protected $fs: IFileSystem,
protected $projectDataService: IProjectDataService
) {
super();
}
protected abstract getPlatformData(projectData: IProjectData): IPlatformData;
public getPluginPlatformsFolderPath(
pluginData: IPluginData,
platform: string
): string {
return pluginData.pluginPlatformsFolderPath(platform);
}
public getFrameworkVersion(projectData: IProjectData): string {
const frameworkData = this.$projectDataService.getRuntimePackage(
projectData.projectDir,
<PlatformTypes>this.getPlatformData(projectData).platformNameLowerCase
);
return frameworkData && frameworkData.version;
}
protected getAllNativeLibrariesForPlugin(
pluginData: IPluginData,
platform: string,
filter: (fileName: string, _pluginPlatformsFolderPath: string) => boolean
): string[] {
const pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(
pluginData,
platform
);
let nativeLibraries: string[] = [];
if (
pluginPlatformsFolderPath &&
this.$fs.exists(pluginPlatformsFolderPath)
) {
const platformsContents = this.$fs.readDirectory(
pluginPlatformsFolderPath
);
nativeLibraries = _(platformsContents)
.filter((platformItemName) =>
filter(platformItemName, pluginPlatformsFolderPath)
)
.value();
}
return nativeLibraries;
}
}