Skip to content

Commit f4410b4

Browse files
authored
Merge pull request #182 from NativeScript/iiivanov/remove-ipc-2
Remove IPC
2 parents e0719c7 + 56df155 commit f4410b4

File tree

85 files changed

+1091
-2355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1091
-2355
lines changed

Diff for: .travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
3+
node_js:
4+
- "8.0"
5+
6+
script:
7+
- npm run build
8+
- npm test
9+
- npm run tslint

Diff for: .vscode/launch.json

+19-58
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
"version": "0.1.0",
33
"configurations": [
44
{
5-
"name": "launch as server",
5+
"name": "Launch as server",
66
"type": "node",
77
"request": "launch",
88
"program": "${workspaceRoot}/out/debug-adapter/nativeScriptDebug.js",
9-
"runtimeArgs": ["--nolazy"],
9+
"runtimeArgs": ["--nolazy"],
1010
"args": [ "--server=4712" ],
1111
"stopOnEntry": false,
1212
"sourceMaps": true,
1313
"outFiles": [ "${workspaceFolder}/out/**/*.js" ],
1414
"cwd": "${workspaceFolder}"
1515
},
1616
{
17-
"name": "launch in extension host",
17+
"name": "Launch in extension host",
1818
"type": "extensionHost",
1919
"request": "launch",
2020
// Path to VSCode executablensDebugClient
@@ -24,61 +24,22 @@
2424
],
2525
"stopOnEntry": false,
2626
"sourceMaps": true,
27-
"outFiles": [ "${workspaceFolder}/out/**/*.js" ],
27+
"outFiles": [ "${workspaceFolder}/out/**/*.js" ]
2828
},
29-
{
30-
"name": "run tests on mac",
31-
"type": "node",
32-
"request": "launch",
33-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
34-
"runtimeArgs": [ "--nolazy" ],
35-
"args": [
36-
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
37-
"--config", "${workspaceRoot}/src/tests/config/mac.json",
38-
"${workspaceRoot}/out/tests/"
39-
],
40-
"stopOnEntry": false,
41-
"sourceMaps": true,
42-
"outDir": "${workspaceRoot}/out",
43-
"cwd": "${workspaceRoot}"
44-
},
45-
{
46-
"name": "run tests on win",
47-
"type": "node",
48-
"request": "launch",
49-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
50-
"runtimeArgs": [ "--nolazy" ],
51-
"args": [
52-
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
53-
"--config", "${workspaceRoot}/src/tests/config/win.json",
54-
"${workspaceRoot}/out/tests/"
55-
],
56-
"stopOnEntry": false,
57-
"sourceMaps": true,
58-
"outDir": "${workspaceRoot}/out",
59-
"cwd": "${workspaceRoot}"
60-
},
61-
{
62-
"name": "run tests (custom)",
63-
"type": "node",
64-
"request": "launch",
65-
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
66-
"runtimeArgs": [ "--nolazy" ],
67-
"args": [
68-
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
69-
"--config", "${workspaceRoot}/src/tests/config/custom.json",
70-
"${workspaceRoot}/out/tests/"
71-
],
72-
"stopOnEntry": false,
73-
"sourceMaps": true,
74-
"outDir": "${workspaceRoot}/out",
75-
"cwd": "${workspaceRoot}"
76-
}
29+
{
30+
"name": "Run tests",
31+
"type": "node",
32+
"request": "launch",
33+
"runtimeExecutable": "npm",
34+
"runtimeArgs": [
35+
"run", "test", "--"
36+
]
37+
}
7738
],
78-
"compounds": [
79-
{
80-
"name": "Extension + Server",
81-
"configurations": [ "launch in extension host", "launch as server" ]
82-
}
83-
]
39+
"compounds": [
40+
{
41+
"name": "Extension + Server",
42+
"configurations": [ "Launch in extension host", "Launch as server" ]
43+
}
44+
]
8445
}

Diff for: .vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"editor.insertSpaces": true,
33
"files.trimTrailingWhitespace": true,
4+
"editor.renderWhitespace": "all",
45
"files.exclude": {
56
".git": true,
67
"bin": true,

Diff for: package.json

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@
2626
"license": "SEE LICENSE IN LICENSE.txt",
2727
"dependencies": {
2828
"lodash": "^4.17.10",
29-
"node-ipc": "8.10.3",
29+
"semver": "^5.5.0",
3030
"universal-analytics": "0.4.13",
3131
"uuid": "^3.2.1",
3232
"vscode-chrome-debug-core": "^3.23.11",
3333
"vscode-debugadapter": "^1.28.0-pre.2"
3434
},
3535
"devDependencies": {
3636
"@types/lodash": "^4.14.109",
37-
"@types/mocha": "2.2.41",
37+
"@types/mocha": "^5.2.1",
3838
"@types/node": "6.0.46",
39-
"@types/source-map": "~0.1.0",
40-
"chrome-remote-debug-protocol": "https://github.com/roblourens/chrome-remote-debug-protocol/tarball/master",
41-
"mocha": "2.5.3",
39+
"mocha": "^5.2.0",
40+
"sinon": "^5.0.10",
41+
"tslint": "5.10.0",
42+
"tslint-eslint-rules": "^5.3.1",
4243
"typescript": "2.6.2",
4344
"vsce": "~1.36.0",
4445
"vscode": "~1.1.10",
45-
"vscode-debugadapter-testsupport": "1.26.0",
4646
"vscode-debugprotocol": "^1.28.0-pre.1"
4747
},
4848
"scripts": {
@@ -52,9 +52,8 @@
5252
"package": "vsce package",
5353
"full-build": "npm run clean && npm install && npm run build && npm run package",
5454
"launch-as-server": "node --nolazy ./out/debug-adapter/nativeScriptDebug.js --server=4712",
55-
"test-mac": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/mac.json ./out/tests",
56-
"test-win": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/win.json ./out/tests",
57-
"test-custom": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/custom.json ./out/tests"
55+
"test": "mocha --opts ./src/tests/config/mocha.opts",
56+
"tslint": "tslint -p ./src/tsconfig.json -c tslint.json"
5857
},
5958
"main": "./out/main",
6059
"activationEvents": [

Diff for: src/analytics/analyticsBaseInfo.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ export enum OperatingSystem {
22
Windows,
33
Linux,
44
OSX,
5-
Other
5+
Other,
66
}
77

8-
export interface AnalyticsBaseInfo {
9-
operatingSystem: OperatingSystem,
10-
cliVersion: string,
11-
extensionVersion: string,
12-
clientId: string
13-
}
8+
export interface IAnalyticsBaseInfo {
9+
operatingSystem: OperatingSystem;
10+
cliVersion: string;
11+
extensionVersion: string;
12+
clientId: string;
13+
}

Diff for: src/analytics/analyticsService.ts

+55-46
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,91 @@
1-
import * as os from 'os';
2-
import { Version } from '../common/version';
3-
import { GUAService } from './guaService';
4-
import { AnalyticsBaseInfo, OperatingSystem } from './analyticsBaseInfo';
5-
import { Services } from '../services/extensionHostServices';
6-
import * as utils from '../common/utilities';
1+
import * as _ from 'lodash';
2+
import * as uuid from 'uuid';
73
import * as vscode from 'vscode';
8-
import * as uuid from "uuid";
4+
import { ILogger } from '../common/logger';
5+
import { services } from '../services/extensionHostServices';
6+
import { IAnalyticsBaseInfo, OperatingSystem } from './analyticsBaseInfo';
7+
import { GUAService } from './guaService';
98

109
export class AnalyticsService {
11-
private static HAS_ANALYTICS_PROMPT_SHOWN_KEY = "nativescript.hasAnalyticsPromptShown";
12-
private static CLIENT_ID_KEY = "nativescript.analyticsClientId";
10+
private static HAS_ANALYTICS_PROMPT_SHOWN_KEY = 'nativescript.hasAnalyticsPromptShown';
11+
private static CLIENT_ID_KEY = 'nativescript.analyticsClientId';
12+
private static DOCS_LINK = 'https://github.com/NativeScript/nativescript-vscode-extension/blob/master/README.md#how-to-disable-the-analytics';
1313
private static ANALYTICS_PROMPT_MESSAGE = `Help us improve the NativeScript extension by allowing Progress to collect anonymous usage data.
14-
For more information about the gathered information and how it is used, read our [privacy statement](https://www.progress.com/legal/privacy-policy).
15-
You can [disable the analytics and data collection](https://github.com/NativeScript/nativescript-vscode-extension/blob/master/README.md#how-to-disable-the-analytics) at any given time.
14+
For more information about the gathered information and how it is used,
15+
read our [privacy statement](https://www.progress.com/legal/privacy-policy).
16+
You can [disable the analytics and data collection](${AnalyticsService.DOCS_LINK}) at any given time.
1617
Do you want to enable analytics?`;
17-
private static ANALYTICS_PROMPT_ACCEPT_ACTION = "Yes";
18-
private static ANALYTICS_PROMPT_DENY_ACTION = "No";
18+
19+
private static ANALYTICS_PROMPT_ACCEPT_ACTION = 'Yes';
20+
private static ANALYTICS_PROMPT_DENY_ACTION = 'No';
21+
22+
private static getOperatingSystem(): OperatingSystem {
23+
switch (process.platform) {
24+
case 'win32':
25+
return OperatingSystem.Windows;
26+
case 'darwin':
27+
return OperatingSystem.OSX;
28+
case 'linux':
29+
case 'freebsd':
30+
return OperatingSystem.Linux;
31+
default:
32+
return OperatingSystem.Other;
33+
}
34+
}
1935

2036
private _globalState: vscode.Memento;
21-
private _baseInfo: AnalyticsBaseInfo;
37+
private _logger: ILogger;
38+
private _baseInfo: IAnalyticsBaseInfo;
2239
private _gua: GUAService;
2340
private _analyticsEnabled: boolean;
2441

25-
constructor(globalState: vscode.Memento) {
42+
constructor(globalState: vscode.Memento, cliVersion: string, extensionVersion: string, logger: ILogger) {
2643
this._globalState = globalState;
44+
this._logger = logger;
2745

2846
vscode.workspace.onDidChangeConfiguration(() => this.updateAnalyticsEnabled());
2947

3048
this._baseInfo = {
31-
cliVersion: Services.cli().version.toString(),
32-
extensionVersion: utils.getInstalledExtensionVersion().toString(),
49+
cliVersion,
50+
clientId: this.getOrGenerateClientId(),
51+
extensionVersion,
3352
operatingSystem: AnalyticsService.getOperatingSystem(),
34-
clientId: this.getOrGenerateClientId()
3553
};
3654
}
3755

3856
public launchDebugger(request: string, platform: string): Promise<any> {
39-
if(this._analyticsEnabled) {
57+
if (this._analyticsEnabled) {
4058
try {
4159
return this._gua.launchDebugger(request, platform);
42-
} catch(e) {}
60+
} catch (e) {
61+
this._logger.log(`Analytics error: ${_.isString(e) ? e : e.message}`);
62+
}
4363
}
4464

4565
return Promise.resolve();
4666
}
4767

4868
public runRunCommand(platform: string): Promise<any> {
49-
if(this._analyticsEnabled) {
69+
if (this._analyticsEnabled) {
5070
try {
5171
return this._gua.runRunCommand(platform);
52-
} catch(e) { }
72+
} catch (e) {
73+
this._logger.log(`Analytics error: ${_.isString(e) ? e : e.message}`);
74+
}
5375
}
5476

5577
return Promise.resolve();
5678
}
5779

58-
private static getOperatingSystem() : OperatingSystem {
59-
switch(process.platform) {
60-
case 'win32':
61-
return OperatingSystem.Windows;
62-
case 'darwin':
63-
return OperatingSystem.OSX;
64-
case 'linux':
65-
case 'freebsd':
66-
return OperatingSystem.Linux;
67-
default:
68-
return OperatingSystem.Other;
69-
};
70-
}
71-
72-
public initialize() : void {
80+
public initialize(): void {
7381
const hasAnalyticsPromptShown = this._globalState.get<boolean>(AnalyticsService.HAS_ANALYTICS_PROMPT_SHOWN_KEY);
74-
if(!hasAnalyticsPromptShown) {
82+
83+
if (!hasAnalyticsPromptShown) {
7584
vscode.window.showInformationMessage(AnalyticsService.ANALYTICS_PROMPT_MESSAGE,
7685
AnalyticsService.ANALYTICS_PROMPT_ACCEPT_ACTION,
77-
AnalyticsService.ANALYTICS_PROMPT_DENY_ACTION
86+
AnalyticsService.ANALYTICS_PROMPT_DENY_ACTION,
7887
)
79-
.then(result => this.onAnalyticsMessageConfirmation(result));
88+
.then((result) => this.onAnalyticsMessageConfirmation(result));
8089

8190
return;
8291
}
@@ -87,28 +96,28 @@ export class AnalyticsService {
8796
private getOrGenerateClientId(): string {
8897
let clientId = this._globalState.get<string>(AnalyticsService.CLIENT_ID_KEY);
8998

90-
if(!clientId) {
99+
if (!clientId) {
91100
clientId = uuid.v4();
92101
this._globalState.update(AnalyticsService.CLIENT_ID_KEY, clientId);
93102
}
94103

95104
return clientId;
96105
}
97106

98-
private onAnalyticsMessageConfirmation(result: string) : void {
107+
private onAnalyticsMessageConfirmation(result: string): void {
99108
const shouldEnableAnalytics = result === AnalyticsService.ANALYTICS_PROMPT_ACCEPT_ACTION ? true : false;
100109

101110
this._globalState.update(AnalyticsService.HAS_ANALYTICS_PROMPT_SHOWN_KEY, true);
102111

103-
Services.workspaceConfigService().isAnalyticsEnabled = shouldEnableAnalytics;
112+
services.workspaceConfigService.isAnalyticsEnabled = shouldEnableAnalytics;
104113
this.updateAnalyticsEnabled();
105114
}
106115

107116
private updateAnalyticsEnabled() {
108-
this._analyticsEnabled = Services.workspaceConfigService().isAnalyticsEnabled;
117+
this._analyticsEnabled = services.workspaceConfigService.isAnalyticsEnabled;
109118

110-
if(this._analyticsEnabled && !this._gua) {
119+
if (this._analyticsEnabled && !this._gua) {
111120
this._gua = new GUAService('UA-111455-29', this._baseInfo);
112121
}
113122
}
114-
}
123+
}

0 commit comments

Comments
 (0)