UNPKG

nativescript

Version:

Command-line interface for building NativeScript projects

50 lines 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PostInstallCliCommand = void 0; const helpers_1 = require("../common/helpers"); const yok_1 = require("../common/yok"); const color_1 = require("../color"); class PostInstallCliCommand { constructor($fs, $commandsService, $helpService, $settingsService, $analyticsService, $logger, $hostInfo) { this.$fs = $fs; this.$commandsService = $commandsService; this.$helpService = $helpService; this.$settingsService = $settingsService; this.$analyticsService = $analyticsService; this.$logger = $logger; this.$hostInfo = $hostInfo; this.disableAnalytics = true; this.allowedParameters = []; } async execute(args) { const isRunningWithSudoUser = !!process.env.SUDO_USER; if (!this.$hostInfo.isWindows) { // when running under 'sudo' we create a working dir with wrong owner (root) and // it is no longer accessible for the user initiating the installation // patch the owner here if (isRunningWithSudoUser) { // TODO: Check if this is the correct place, probably we should set this at the end of the command. await this.$fs.setCurrentUserAsOwner(this.$settingsService.getProfileDir(), process.env.SUDO_USER); } } const canExecutePostInstallTask = !isRunningWithSudoUser || (0, helpers_1.doesCurrentNpmCommandMatch)([/^--unsafe-perm$/]); if (canExecutePostInstallTask) { await this.$helpService.generateHtmlPages(); // Explicitly ask for confirmation of usage-reporting: await this.$analyticsService.checkConsent(); await this.$commandsService.tryExecuteCommand("autocomplete", []); } } async postCommandAction(args) { this.$logger.info(""); this.$logger.info(color_1.color.green.bold("You have successfully installed the NativeScript CLI!")); this.$logger.info(""); this.$logger.info("Your next step is to create a new project:"); this.$logger.info(color_1.color.green.bold("ns create")); this.$logger.info(""); this.$logger.printMarkdown("If you have any questions, check Stack Overflow: `https://stackoverflow.com/questions/tagged/nativescript` and our public Discord channel: `https://nativescript.org/discord`"); } } exports.PostInstallCliCommand = PostInstallCliCommand; yok_1.injector.registerCommand("post-install-cli", PostInstallCliCommand); //# sourceMappingURL=post-install.js.map