Skip to content

Commit 6abe032

Browse files
committed
Merge pull request #1057 from NativeScript/kerezov/restructure-error-messaging
Restructure error messaging
2 parents 78835ec + 76ca606 commit 6abe032

7 files changed

+42
-7
lines changed

Gruntfile.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ module.exports = function(grunt) {
3939
},
4040

4141
devlib: {
42-
src: ["lib/**/*.ts", "!lib/common/node_modules/**/*.ts"],
42+
src: ["lib/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts"],
4343
reference: "lib/.d.ts"
4444
},
4545

4646
devall: {
47-
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!lib/common/test/.d.ts"],
47+
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!lib/common/test/.d.ts"],
4848
reference: "lib/.d.ts"
4949
},
5050

5151
release_build: {
52-
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts"],
52+
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts"],
5353
reference: "lib/.d.ts",
5454
options: {
5555
sourceMap: false,
@@ -61,7 +61,7 @@ module.exports = function(grunt) {
6161
tslint: {
6262
build: {
6363
files: {
64-
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!**/*.d.ts"]
64+
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!**/*.d.ts"]
6565
},
6666
options: {
6767
configuration: grunt.file.readJSON("./tslint.json")
@@ -71,7 +71,7 @@ module.exports = function(grunt) {
7171

7272
watch: {
7373
devall: {
74-
files: ["lib/**/*.ts", 'test/**/*.ts', "!lib/common/node_modules/**/*.ts"],
74+
files: ["lib/**/*.ts", 'test/**/*.ts', "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts"],
7575
tasks: [
7676
'ts:devall',
7777
'shell:npm_test'

lib/messages.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
///<reference path=".d.ts"/>
2+
//
3+
// automatically generated code; do not edit manually!
4+
//
5+
interface IMessages{
6+
Devices : {
7+
NotFoundDeviceByIdentifierErrorMessage: string;
8+
NotFoundDeviceByIdentifierErrorMessageWithIdentifier: string;
9+
NotFoundDeviceByIndexErrorMessage: string;
10+
};
11+
12+
}
13+

lib/messages.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
///<reference path=".d.ts"/>
2+
"use strict";
3+
//
4+
// automatically generated code; do not edit manually!
5+
//
6+
7+
export class Messages implements IMessages{
8+
Devices = {
9+
NotFoundDeviceByIdentifierErrorMessage: "Devices.NotFoundDeviceByIdentifierErrorMessage",
10+
NotFoundDeviceByIdentifierErrorMessageWithIdentifier: "Devices.NotFoundDeviceByIdentifierErrorMessageWithIdentifier",
11+
NotFoundDeviceByIndexErrorMessage: "Devices.NotFoundDeviceByIndexErrorMessage",
12+
};
13+
14+
}
15+
$injector.register('messages', Messages);
16+

lib/nativescript-cli.ts

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ fiber(() => {
1717

1818
let commandDispatcher: ICommandDispatcher = $injector.resolve("commandDispatcher");
1919

20+
let messages: IMessagesService = $injector.resolve("$messagesService");
21+
messages.pathsToMessageJsonFiles = [/* Place client-specific json message file paths here */];
22+
2023
if (process.argv[2] === "completion") {
2124
commandDispatcher.completeCommand().wait();
2225
} else {

test/plugin-variables-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {ProjectData} from "../lib/project-data";
1313
import {ProjectDataService} from "../lib/services/project-data-service";
1414
import {ProjectHelper} from "../lib/common/project-helper";
1515
import {StaticConfig} from "../lib/config";
16+
import {MessagesService} from "../lib/common/services/messages-service";
1617
import {Yok} from '../lib/common/yok';
1718
import * as stubs from './stubs';
1819
import * as path from "path";
@@ -22,6 +23,7 @@ temp.track();
2223
function createTestInjector(): IInjector {
2324
let testInjector = new Yok();
2425

26+
testInjector.register("messagesService", MessagesService);
2527
testInjector.register("errors", Errors);
2628
testInjector.register("fs", FileSystem);
2729
testInjector.register("hostInfo", HostInfo);

test/plugins-service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {ResourceLoader} from "../lib/common/resource-loader";
2424
import {EOL} from "os";
2525
import {PluginsService} from "../lib/services/plugins-service";
2626
import {AddPluginCommand} from "../lib/commands/plugin/add-plugin";
27+
import {MessagesService} from "../lib/common/services/messages-service";
2728
import {Builder} from "../lib/tools/broccoli/builder";
2829
import {AndroidProjectService} from "../lib/services/android-project-service";
2930
import {AndroidToolsInfo} from "../lib/android-tools-info";
@@ -37,7 +38,7 @@ let isErrorThrown = false;
3738

3839
function createTestInjector() {
3940
let testInjector = new Yok();
40-
41+
testInjector.register("messagesService", MessagesService);
4142
testInjector.register("npm", NodePackageManager);
4243
testInjector.register("fs", FileSystem);
4344
testInjector.register("projectData", ProjectData);

0 commit comments

Comments
 (0)