Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 6fbcb97

Browse files
Merge pull request #1027 from telerik/vladimirov/release-331
Cherry-pick commits for {N} CLI 3.3.1 release
2 parents d20d42d + 10e353d commit 6fbcb97

29 files changed

+803
-134
lines changed

appbuilder/device-emitter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventEmitter } from "events";
2-
import { DeviceDiscoveryEventNames } from "../constants";
2+
import { DeviceDiscoveryEventNames, DEVICE_LOG_EVENT_NAME } from "../constants";
33

44
export class DeviceEmitter extends EventEmitter {
55
constructor(private $deviceLogProvider: EventEmitter,
@@ -34,7 +34,7 @@ export class DeviceEmitter extends EventEmitter {
3434
});
3535

3636
this.$deviceLogProvider.on("data", (identifier: string, data: any) => {
37-
this.emit('deviceLogData', identifier, data.toString());
37+
this.emit(DEVICE_LOG_EVENT_NAME, identifier, data.toString());
3838
});
3939
}
4040

appbuilder/proton-static-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ export class ProtonStaticConfig extends StaticConfigBase {
2020
public CLIENT_NAME = "Desktop Client - Universal";
2121

2222
public ANALYTICS_EXCEPTIONS_API_KEY: string = null;
23+
24+
public PROFILE_DIR_NAME: string = ".appbuilder-desktop-universal";
2325
}
2426
$injector.register("staticConfig", ProtonStaticConfig);

bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ $injector.require("dynamicHelpService", "./services/dynamic-help-service");
9292
$injector.require("microTemplateService", "./services/micro-templating-service");
9393
$injector.require("mobileHelper", "./mobile/mobile-helper");
9494
$injector.require("devicePlatformsConstants", "./mobile/device-platforms-constants");
95-
$injector.require("htmlHelpService", "./services/html-help-service");
95+
$injector.require("helpService", "./services/help-service");
9696
$injector.require("messageContractGenerator", "./services/message-contract-generator");
9797
$injector.require("proxyService", "./services/proxy-service");
9898
$injector.require("credentialsService", "./services/credentials-service");

commands/help.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import { EOL } from "os";
2-
31
export class HelpCommand implements ICommand {
4-
constructor(private $logger: ILogger,
5-
private $injector: IInjector,
6-
private $htmlHelpService: IHtmlHelpService,
7-
private $staticConfig: Config.IStaticConfig,
2+
constructor(private $injector: IInjector,
3+
private $helpService: IHelpService,
84
private $options: ICommonOptions) { }
95

106
public enableHooks = false;
@@ -22,14 +18,9 @@ export class HelpCommand implements ICommand {
2218
}
2319

2420
if (this.$options.help) {
25-
const help = await this.$htmlHelpService.getCommandLineHelpForCommand(topic);
26-
if (this.$staticConfig.FULL_CLIENT_NAME) {
27-
this.$logger.info(this.$staticConfig.FULL_CLIENT_NAME.green.bold + EOL);
28-
}
29-
30-
this.$logger.printMarkdown(help);
21+
await this.$helpService.showCommandLineHelp(topic);
3122
} else {
32-
await this.$htmlHelpService.openHelpForCommandInBrowser(topic);
23+
await this.$helpService.openHelpForCommandInBrowser(topic);
3324
}
3425
}
3526
}

commands/post-install.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export class PostInstallCommand implements ICommand {
22
constructor(private $fs: IFileSystem,
33
private $staticConfig: Config.IStaticConfig,
44
private $commandsService: ICommandsService,
5-
private $htmlHelpService: IHtmlHelpService,
6-
private $options: ICommonOptions,
5+
private $helpService: IHelpService,
6+
private $settingsService: ISettingsService,
77
private $doctorService: IDoctorService,
88
private $analyticsService: IAnalyticsService,
99
private $logger: ILogger) {
@@ -18,11 +18,11 @@ export class PostInstallCommand implements ICommand {
1818
// it is no longer accessible for the user initiating the installation
1919
// patch the owner here
2020
if (process.env.SUDO_USER) {
21-
await this.$fs.setCurrentUserAsOwner(this.$options.profileDir, process.env.SUDO_USER);
21+
await this.$fs.setCurrentUserAsOwner(this.$settingsService.getProfileDir(), process.env.SUDO_USER);
2222
}
2323
}
2424

25-
await this.$htmlHelpService.generateHtmlPages();
25+
await this.$helpService.generateHtmlPages();
2626

2727
const doctorResult = await this.$doctorService.printWarnings({ trackResult: false });
2828
// Explicitly ask for confirmation of usage-reporting:

commands/preuninstall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ export class PreUninstallCommand implements ICommand {
66
public allowedParameters: ICommandParameter[] = [];
77

88
constructor(private $fs: IFileSystem,
9-
private $options: ICommonOptions) { }
9+
private $settingsService: ISettingsService) { }
1010

1111
public async execute(args: string[]): Promise<void> {
12-
this.$fs.deleteFile(path.join(this.$options.profileDir, "KillSwitches", "cli"));
12+
this.$fs.deleteFile(path.join(this.$settingsService.getProfileDir(), "KillSwitches", "cli"));
1313
}
1414
}
1515

constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export class DeviceDiscoveryEventNames {
3939
static DEVICE_LOST = "deviceLost";
4040
}
4141

42+
export const DEVICE_LOG_EVENT_NAME = "deviceLogData";
43+
4244
export const TARGET_FRAMEWORK_IDENTIFIERS = {
4345
Cordova: "Cordova",
4446
NativeScript: "NativeScript"

declarations.d.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ interface IConfigurationSettings {
7979
* This string will be used when constructing the UserAgent http header.
8080
* @type {string}
8181
*/
82-
userAgentName: string;
82+
userAgentName?: string;
83+
84+
/**
85+
* Describes the profile directory that will be used for various CLI settings, like user-settings.json file location, extensions, etc.
86+
* @type {string}
87+
*/
88+
profileDir?: string;
8389
}
8490

8591
/**
@@ -92,6 +98,12 @@ interface ISettingsService {
9298
* @returns {void}
9399
*/
94100
setSettings(settings: IConfigurationSettings): void;
101+
102+
/**
103+
* Returns currently used profile directory.
104+
* @returns {string}
105+
*/
106+
getProfileDir(): string;
95107
}
96108

97109
/**
@@ -540,7 +552,7 @@ interface IErrors {
540552
fail(formatStr: string, ...args: any[]): never;
541553
fail(opts: { formatStr?: string; errorCode?: number; suppressCommandHelp?: boolean }, ...args: any[]): never;
542554
failWithoutHelp(message: string, ...args: any[]): never;
543-
beginCommand(action: () => Promise<boolean>, printCommandHelp: () => Promise<boolean>): Promise<boolean>;
555+
beginCommand(action: () => Promise<boolean>, printCommandHelp: () => Promise<void>): Promise<boolean>;
544556
verifyHeap(message: string): void;
545557
printCallStack: boolean;
546558
}
@@ -721,6 +733,13 @@ interface IAnalyticsSettingsService {
721733
* @returns {Promise<string>}
722734
*/
723735
getClientId(): Promise<string>;
736+
737+
/**
738+
* Gets user agent string identifing the current system in the following format: `${identifier} (${systemInfo}) ${osArch}`
739+
* @param {string} identifier The product identifier.
740+
* @returns {string} The user agent string.
741+
*/
742+
getUserAgentString(identifier: string): string;
724743
}
725744

726745
interface IHostCapabilities {
@@ -948,17 +967,17 @@ interface IMicroTemplateService {
948967
parseContent(data: string, options: { isHtml: boolean }): Promise<string>;
949968
}
950969

951-
interface IHtmlHelpService {
970+
interface IHelpService {
952971
generateHtmlPages(): Promise<void>;
953972

973+
openHelpForCommandInBrowser(commandName: string): Promise<void>;
974+
954975
/**
955-
* Gets the help content for a specific command that should be shown on the terminal.
956-
* @param {string} commandName Name of the command for which to read the help.
957-
* @returns {Promise<string>} Help content of the command parsed with all terminal rules applied (stripped content that should be shown only for html help).
976+
* Shows command line help for specified command.
977+
* @param {string} commandName The name of the command for which to show the help.
978+
* @returns {Promise<void>}
958979
*/
959-
getCommandLineHelpForCommand(commandName: string): Promise<string>;
960-
961-
openHelpForCommandInBrowser(commandName: string): Promise<void>;
980+
showCommandLineHelp(commandName: string): Promise<void>;
962981
}
963982

964983
/**

definitions/config.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ declare module Config {
1313
ERROR_REPORT_SETTING_NAME: string;
1414
SYS_REQUIREMENTS_LINK: string;
1515
version: string;
16-
helpTextPath: string;
1716
getAdbFilePath(): Promise<string>;
1817
disableAnalytics?: boolean;
1918
disableCommandHooks?: boolean;
@@ -29,6 +28,7 @@ declare module Config {
2928
PATH_TO_BOOTSTRAP: string;
3029
QR_SIZE: number;
3130
INSTALLATION_SUCCESS_MESSAGE?: string;
31+
PROFILE_DIR_NAME: string
3232
}
3333

3434
interface IConfig {

definitions/mobile.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ declare module Mobile {
9696
isEmulator: boolean;
9797
openDeviceLogStream(): Promise<void>;
9898
getApplicationInfo(applicationIdentifier: string): Promise<Mobile.IApplicationInfo>;
99+
100+
/**
101+
* Called when device is lost. Its purpose is to clean any resources used by the instance.
102+
* @returns {void}
103+
*/
104+
detach?(): void;
99105
}
100106

101107
interface IiOSDevice extends IDevice {
@@ -767,14 +773,14 @@ declare module Mobile {
767773
}
768774
}
769775

770-
interface IIOSDeviceOperations extends IDisposable {
776+
interface IIOSDeviceOperations extends IDisposable, NodeJS.EventEmitter {
771777
install(ipaPath: string, deviceIdentifiers: string[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse>;
772778

773779
uninstall(appIdentifier: string, deviceIdentifiers: string[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceResponse>;
774780

775781
startLookingForDevices(deviceFoundCallback: DeviceInfoCallback, deviceLostCallback: DeviceInfoCallback, options?: Mobile.IDeviceLookingOptions): Promise<void>;
776782

777-
startDeviceLog(deviceIdentifier: string, printLogFunction: (response: IOSDeviceLib.IDeviceLogData) => void): void;
783+
startDeviceLog(deviceIdentifier: string): void;
778784

779785
apps(deviceIdentifiers: string[], errorHandler?: DeviceOperationErrorHandler): Promise<IOSDeviceAppInfo>;
780786

0 commit comments

Comments
 (0)