nativescript
Version:
Command-line interface for building NativeScript projects
157 lines • 7.38 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunVisionOSCommand = exports.RunAndroidCommand = exports.RunIosCommand = exports.RunCommandBase = void 0;
const constants_1 = require("../common/constants");
const decorators_1 = require("../common/decorators");
const helpers_1 = require("../common/helpers");
const yok_1 = require("../common/yok");
const constants_2 = require("../constants");
class RunCommandBase {
constructor($devicePlatformsConstants, $errors, $hostInfo, $liveSyncCommandHelper, $migrateController, $options, $projectData, $keyCommandHelper) {
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$errors = $errors;
this.$hostInfo = $hostInfo;
this.$liveSyncCommandHelper = $liveSyncCommandHelper;
this.$migrateController = $migrateController;
this.$options = $options;
this.$projectData = $projectData;
this.$keyCommandHelper = $keyCommandHelper;
this.liveSyncCommandHelperAdditionalOptions = {};
this.allowedParameters = [];
}
async execute(args) {
await this.$liveSyncCommandHelper.executeCommandLiveSync(this.platform, this.liveSyncCommandHelperAdditionalOptions);
if (process.env.NS_IS_INTERACTIVE) {
this.$keyCommandHelper.attachKeyCommands(this.platform, "run");
}
}
async canExecute(args) {
if (args.length) {
this.$errors.failWithHelp(constants_1.ERROR_NO_VALID_SUBCOMMAND_FORMAT, "run");
}
this.platform = args[0] || this.platform;
if (!this.platform && !this.$hostInfo.isDarwin) {
this.platform = this.$devicePlatformsConstants.Android;
}
this.$projectData.initializeProjectData();
const platforms = this.platform
? [this.platform]
: [
this.$devicePlatformsConstants.Android,
this.$devicePlatformsConstants.iOS,
];
if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms,
});
}
await this.$liveSyncCommandHelper.validatePlatform(this.platform);
return true;
}
}
exports.RunCommandBase = RunCommandBase;
yok_1.injector.registerCommand("run|*all", RunCommandBase);
class RunIosCommand {
get runCommand() {
const runCommand = this.$injector.resolve(RunCommandBase);
runCommand.platform = this.platform;
return runCommand;
}
get platform() {
return this.$devicePlatformsConstants.iOS;
}
constructor($devicePlatformsConstants, $errors, $injector, $options, $platformValidationService, $projectDataService) {
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$errors = $errors;
this.$injector = $injector;
this.$options = $options;
this.$platformValidationService = $platformValidationService;
this.$projectDataService = $projectDataService;
this.allowedParameters = [];
}
async execute(args) {
return this.runCommand.execute(args);
}
async canExecute(args) {
const projectData = this.$projectDataService.getProjectData();
if (!this.$platformValidationService.isPlatformSupportedForOS(this.platform, projectData)) {
this.$errors.fail(`Applications for platform ${this.platform} can not be built on this OS`);
}
const result = (await this.runCommand.canExecute(args)) &&
(await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, projectData, this.platform.toLowerCase()));
return result;
}
}
exports.RunIosCommand = RunIosCommand;
__decorate([
(0, decorators_1.cache)()
], RunIosCommand.prototype, "runCommand", null);
yok_1.injector.registerCommand("run|ios", RunIosCommand);
class RunAndroidCommand {
get runCommand() {
const runCommand = this.$injector.resolve(RunCommandBase);
runCommand.platform = this.platform;
return runCommand;
}
get platform() {
return this.$devicePlatformsConstants.Android;
}
constructor($devicePlatformsConstants, $errors, $injector, $options, $platformValidationService, $projectData) {
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$errors = $errors;
this.$injector = $injector;
this.$options = $options;
this.$platformValidationService = $platformValidationService;
this.$projectData = $projectData;
this.allowedParameters = [];
}
async execute(args) {
return this.runCommand.execute(args);
}
async canExecute(args) {
await this.runCommand.canExecute(args);
if (!this.$platformValidationService.isPlatformSupportedForOS(this.$devicePlatformsConstants.Android, this.$projectData)) {
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS`);
}
if ((this.$options.release || this.$options.aab) &&
!(0, helpers_1.hasValidAndroidSigning)(this.$options)) {
if (this.$options.release) {
this.$errors.failWithHelp(constants_2.ANDROID_RELEASE_BUILD_ERROR_MESSAGE);
}
else {
this.$errors.failWithHelp(constants_2.ANDROID_APP_BUNDLE_SIGNING_ERROR_MESSAGE);
}
}
return this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, this.$devicePlatformsConstants.Android.toLowerCase());
}
}
exports.RunAndroidCommand = RunAndroidCommand;
__decorate([
(0, decorators_1.cache)()
], RunAndroidCommand.prototype, "runCommand", null);
yok_1.injector.registerCommand("run|android", RunAndroidCommand);
class RunVisionOSCommand extends RunIosCommand {
get platform() {
return this.$devicePlatformsConstants.visionOS;
}
constructor($devicePlatformsConstants, $errors, $injector, $options, $platformValidationService, $projectDataService) {
super($devicePlatformsConstants, $errors, $injector, $options, $platformValidationService, $projectDataService);
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$errors = $errors;
this.$injector = $injector;
this.$options = $options;
this.$platformValidationService = $platformValidationService;
this.$projectDataService = $projectDataService;
}
}
exports.RunVisionOSCommand = RunVisionOSCommand;
yok_1.injector.registerCommand("run|vision", RunVisionOSCommand);
yok_1.injector.registerCommand("run|visionos", RunVisionOSCommand);
//# sourceMappingURL=run.js.map