-
-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathdeploy.ts
More file actions
92 lines (81 loc) · 2.67 KB
/
Copy pathdeploy.ts
File metadata and controls
92 lines (81 loc) · 2.67 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import {
ANDROID_RELEASE_BUILD_ERROR_MESSAGE,
ANDROID_APP_BUNDLE_SIGNING_ERROR_MESSAGE,
} from "../constants";
import { ValidatePlatformCommandBase } from "./command-base";
import { DeployCommandHelper } from "../helpers/deploy-command-helper";
import { hasValidAndroidSigning } from "../common/helpers";
import { IProjectData } from "../definitions/project";
import { IPlatformValidationService, IOptions } from "../declarations";
import { IPlatformsDataService } from "../definitions/platform";
import { IMigrateController } from "../definitions/migrate";
import { ICommand, ICommandParameter } from "../common/definitions/commands";
import { OptionType, IErrors } from "../common/declarations";
import { injector } from "../common/yok";
export class DeployOnDeviceCommand
extends ValidatePlatformCommandBase
implements ICommand {
public allowedParameters: ICommandParameter[] = [];
public dashedOptions = {
watch: {
type: OptionType.Boolean,
default: false,
hasSensitiveValue: false,
},
hmr: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
};
constructor(
$platformValidationService: IPlatformValidationService,
private $platformCommandParameter: ICommandParameter,
$options: IOptions,
$projectData: IProjectData,
private $errors: IErrors,
private $mobileHelper: Mobile.IMobileHelper,
$platformsDataService: IPlatformsDataService,
private $deployCommandHelper: DeployCommandHelper,
private $migrateController: IMigrateController
) {
super(
$options,
$platformsDataService,
$platformValidationService,
$projectData
);
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
const platform = args[0];
await this.$deployCommandHelper.deploy(platform);
}
public async canExecute(args: string[]): Promise<boolean> {
const platform = args[0];
if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms: [platform],
});
}
if (!args || !args.length || args.length > 1) {
return false;
}
if (!(await this.$platformCommandParameter.validate(platform))) {
return false;
}
if (
this.$mobileHelper.isAndroidPlatform(platform) &&
(this.$options.release || this.$options.aab) &&
!hasValidAndroidSigning(this.$options)
) {
if (this.$options.release) {
this.$errors.failWithHelp(ANDROID_RELEASE_BUILD_ERROR_MESSAGE);
} else {
this.$errors.failWithHelp(ANDROID_APP_BUNDLE_SIGNING_ERROR_MESSAGE);
}
}
const result = await super.canExecuteCommandBase(platform, {
validateOptions: true,
});
return result;
}
}
injector.registerCommand("deploy", DeployOnDeviceCommand);