nativescript
Version:
Command-line interface for building NativeScript projects
130 lines • 6.71 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BuildVisionOsCommand = exports.BuildAndroidCommand = exports.BuildIosCommand = exports.BuildCommandBase = void 0;
const constants_1 = require("../constants");
const command_base_1 = require("./command-base");
const helpers_1 = require("../common/helpers");
const yok_1 = require("../common/yok");
class BuildCommandBase extends command_base_1.ValidatePlatformCommandBase {
constructor($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger) {
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$errors = $errors;
this.$devicePlatformsConstants = $devicePlatformsConstants;
this.$buildController = $buildController;
this.$buildDataService = $buildDataService;
this.$logger = $logger;
this.dashedOptions = {
watch: {
type: "boolean" /* OptionType.Boolean */,
default: false,
hasSensitiveValue: false,
},
hmr: { type: "boolean" /* OptionType.Boolean */, default: false, hasSensitiveValue: false },
};
this.$projectData.initializeProjectData();
}
async executeCore(args) {
const platform = args[0].toLowerCase();
const buildData = this.$buildDataService.getBuildData(this.$projectData.projectDir, platform, this.$options);
const outputPath = await this.$buildController.prepareAndBuild(buildData);
return outputPath;
}
validatePlatform(platform) {
if (!this.$platformValidationService.isPlatformSupportedForOS(platform, this.$projectData)) {
this.$errors.fail(`Applications for platform ${platform} can not be built on this OS`);
}
}
async validateArgs(args, platform) {
if (args.length !== 0) {
this.$errors.failWithHelp(`The arguments '${args.join(" ")}' are not valid for the current command.`);
}
const result = await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
return result;
}
}
exports.BuildCommandBase = BuildCommandBase;
class BuildIosCommand extends BuildCommandBase {
constructor($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $logger, $buildDataService, $migrateController) {
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
this.$options = $options;
this.$migrateController = $migrateController;
this.allowedParameters = [];
}
async execute(args) {
await this.executeCore([this.$devicePlatformsConstants.iOS.toLowerCase()]);
}
async canExecute(args) {
const platform = this.$devicePlatformsConstants.iOS;
if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms: [platform],
});
}
super.validatePlatform(platform);
let canExecute = await super.canExecuteCommandBase(platform);
if (canExecute) {
canExecute = await super.validateArgs(args, platform);
}
return canExecute;
}
}
exports.BuildIosCommand = BuildIosCommand;
yok_1.injector.registerCommand("build|ios", BuildIosCommand);
class BuildAndroidCommand extends BuildCommandBase {
constructor($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $androidBundleValidatorHelper, $buildDataService, $logger, $migrateController) {
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
this.$options = $options;
this.$errors = $errors;
this.$androidBundleValidatorHelper = $androidBundleValidatorHelper;
this.$logger = $logger;
this.$migrateController = $migrateController;
this.allowedParameters = [];
}
async execute(args) {
await this.executeCore([
this.$devicePlatformsConstants.Android.toLowerCase(),
]);
if (this.$options.aab) {
this.$logger.info(constants_1.AndroidAppBundleMessages.ANDROID_APP_BUNDLE_DOCS_MESSAGE);
if (this.$options.release) {
this.$logger.info(constants_1.AndroidAppBundleMessages.ANDROID_APP_BUNDLE_PUBLISH_DOCS_MESSAGE);
}
}
}
async canExecute(args) {
const platform = this.$devicePlatformsConstants.Android;
if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms: [platform],
});
}
this.$androidBundleValidatorHelper.validateRuntimeVersion(this.$projectData);
let canExecute = await super.canExecuteCommandBase(platform);
if (canExecute) {
if (this.$options.release && !(0, helpers_1.hasValidAndroidSigning)(this.$options)) {
this.$errors.failWithHelp(constants_1.ANDROID_RELEASE_BUILD_ERROR_MESSAGE);
}
canExecute = await super.validateArgs(args, platform);
}
return canExecute;
}
}
exports.BuildAndroidCommand = BuildAndroidCommand;
yok_1.injector.registerCommand("build|android", BuildAndroidCommand);
class BuildVisionOsCommand extends BuildIosCommand {
constructor($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $logger, $buildDataService, $migrateController) {
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $logger, $buildDataService, $migrateController);
this.$options = $options;
this.$migrateController = $migrateController;
}
async canExecute(args) {
this.$errors.fail('Building for "visionOS" platform is not supported via the CLI. Please open the project in Xcode and build it from there.');
return false;
}
}
exports.BuildVisionOsCommand = BuildVisionOsCommand;
yok_1.injector.registerCommand("build|vision", BuildVisionOsCommand);
yok_1.injector.registerCommand("build|visionos", BuildVisionOsCommand);
//# sourceMappingURL=build.js.map