-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathpreuninstall.ts
49 lines (39 loc) · 1.89 KB
/
preuninstall.ts
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
import * as path from "path";
import { doesCurrentNpmCommandMatch, isInteractive } from "../helpers";
import { TrackActionNames, AnalyticsEventLabelDelimiter } from "../../constants";
export class PreUninstallCommand implements ICommand {
// disabled for now (6/24/2020)
// private static FEEDBACK_FORM_URL = "https://www.nativescript.org/uninstall-feedback";
public allowedParameters: ICommandParameter[] = [];
constructor(private $analyticsService: IAnalyticsService,
private $extensibilityService: IExtensibilityService,
private $fs: IFileSystem,
// private $opener: IOpener,
private $packageInstallationManager: IPackageInstallationManager,
private $settingsService: ISettingsService) { }
public async execute(args: string[]): Promise<void> {
const isIntentionalUninstall = doesCurrentNpmCommandMatch([/^uninstall$/, /^remove$/, /^rm$/, /^r$/, /^un$/, /^unlink$/]);
await this.$analyticsService.trackEventActionInGoogleAnalytics({
action: TrackActionNames.UninstallCLI,
additionalData: `isIntentionalUninstall${AnalyticsEventLabelDelimiter}${isIntentionalUninstall}${AnalyticsEventLabelDelimiter}isInteractive${AnalyticsEventLabelDelimiter}${!!isInteractive()}`
});
if (isIntentionalUninstall) {
await this.handleIntentionalUninstall();
}
this.$fs.deleteFile(path.join(this.$settingsService.getProfileDir(), "KillSwitches", "cli"));
await this.$analyticsService.finishTracking();
}
private async handleIntentionalUninstall(): Promise<void> {
this.$extensibilityService.removeAllExtensions();
this.$packageInstallationManager.clearInspectorCache();
await this.handleFeedbackForm();
}
private async handleFeedbackForm(): Promise<void> {
// disabled for now (6/24/2020)
// if (isInteractive()) {
// this.$opener.open(PreUninstallCommand.FEEDBACK_FORM_URL);
// }
return Promise.resolve();
}
}
$injector.registerCommand("dev-preuninstall", PreUninstallCommand);