Skip to content

Commit 94c0d02

Browse files
committed
feat: replace demo build with normal (no webpack) build
1 parent 6f8e193 commit 94c0d02

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

lib/checker.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { MarketplaceService } from './marketplace.service';
22
import { ProjectService } from './project.service';
3-
import { GithubService } from './github.service';
43
import { writeFileSync } from 'fs';
54
import { execPromise } from './execPromise';
65
import { Logger } from './log.service';
@@ -9,8 +8,8 @@ interface ResultsInterface {
98
name: string;
109
webpack: any;
1110
webpackTime: number;
12-
demos: any;
13-
demoTime: number;
11+
build: any;
12+
buildTime: number;
1413
}
1514

1615
class OutputModel {
@@ -51,19 +50,21 @@ export async function run() {
5150
for (let index = 0; index < plugins.length; index++) {
5251
const plugin = plugins[index];
5352
Logger.log(`Start check ${plugin.name}`);
54-
const startDate = new Date().getTime();
53+
5554
// Test if the plugin builds when added to an app
56-
const resultWP = await ProjectService.testPlugin(plugin);
55+
await ProjectService.prepareProject(plugin);
56+
const startDate = new Date().getTime();
57+
const resultWP = await ProjectService.testWebpack(plugin);
5758
const midDate = new Date().getTime();
58-
// Test if the plugin builds its demo (if available)
59-
const resultD = await GithubService.testPlugin(plugin);
59+
const resultB = await ProjectService.testBuild(plugin);
6060
const endDate = new Date().getTime();
61+
await ProjectService.cleanProject();
6162
results.push({
6263
name: plugin.name,
6364
webpack: resultWP,
6465
webpackTime: Math.round((midDate - startDate) / 1000),
65-
demos: resultD,
66-
demoTime: Math.round((endDate - midDate) / 1000)
66+
build: resultB,
67+
buildTime: Math.round((endDate - midDate) / 1000)
6768
});
6869
Logger.log(JSON.stringify(results[results.length - 1]));
6970
}

lib/project.service.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,63 @@ export namespace ProjectService {
2121
await _createProject(testProject);
2222
await _renameTestProject();
2323
}
24+
export async function prepareProject(plugin: MarketplaceService.PluginModel) {
25+
try {
26+
await _copyTestProject(testProject);
27+
await _installPlugin(plugin.name, testProject, _isDev(plugin.name));
28+
} catch (errExec) {
29+
Logger.error(JSON.stringify(errExec));
30+
}
31+
}
2432

25-
export async function testPlugin(plugin: MarketplaceService.PluginModel) {
33+
export async function cleanProject() {
34+
try {
35+
await new Promise((resolve) => {
36+
setTimeout(() => {
37+
resolve();
38+
}, 2000);
39+
});
40+
await _removeDirectory(path.join(testDirectory, testProject));
41+
} catch (errExec) {
42+
Logger.error(JSON.stringify(errExec));
43+
}
44+
}
45+
46+
export async function testWebpack(plugin: MarketplaceService.PluginModel) {
47+
return await testPlugin(plugin, '--bundle');
48+
}
49+
50+
export async function testBuild(plugin: MarketplaceService.PluginModel) {
51+
return await testPlugin(plugin, '');
52+
}
53+
54+
async function testPlugin(plugin: MarketplaceService.PluginModel, options: string) {
2655
const result = { android: false, ios: false };
2756
let hasPlatform = false;
2857
try {
29-
await _copyTestProject(testProject);
30-
await _installPlugin(plugin.name, testProject, _isDev(plugin.name));
3158
if (plugin.badges.androidVersion) {
32-
result.android = !!(await _buildProject(testProject, 'android'));
59+
result.android = !!(await _buildProject(testProject, 'android', options));
3360
hasPlatform = true;
3461
}
3562

3663
if (plugin.badges.iosVersion) {
37-
result.ios = !!(await _buildProject(testProject, 'ios'));
64+
result.ios = !!(await _buildProject(testProject, 'ios', options));
3865
hasPlatform = true;
3966
}
4067

4168
if (!hasPlatform) {
4269
Logger.error('plugin has no platform');
4370
}
44-
45-
await _removeDirectory(path.join(testDirectory, testProject));
4671
} catch (errExec) {
4772
Logger.error(JSON.stringify(errExec));
4873
}
4974
return result;
5075
}
5176

52-
async function _buildProject(projectName: string, platform: string) {
77+
async function _buildProject(projectName: string, platform: string, options: string) {
5378
Logger.debug(`building project for ${platform} ...`);
5479
const cwd = path.join(testDirectory, projectName);
55-
const result = await execPromise(cwd, `tns build ${platform} --bundle`);
80+
const result = await execPromise(cwd, `tns build ${platform} ${options}`);
5681
return result;
5782
}
5883

0 commit comments

Comments
 (0)