1
1
/// <reference path=".d.ts" />
2
2
"use strict" ;
3
3
4
- import yok = require( '../lib/common/yok' ) ;
5
- import stubs = require( './stubs' ) ;
6
- import NpmLib = require( "../lib/node-package-manager" ) ;
7
- import FsLib = require( "../lib/common/file-system" ) ;
8
- import ProjectDataLib = require( "../lib/project-data" ) ;
9
- import ChildProcessLib = require( "../lib/common/child-process" ) ;
10
- import PlatformServiceLib = require( '../lib/services/platform-service' ) ;
11
- import OptionsLib = require( "../lib/options" ) ;
12
- import CommandsServiceLib = require( "../lib/common/services/commands-service" ) ;
13
- import StaticConfigLib = require( "../lib/config" ) ;
14
- import HostInfoLib = require( "../lib/common/host-info" ) ;
15
- import ErrorsLib = require( "../lib/common/errors" ) ;
16
- import ProjectHelperLib = require( "../lib/common/project-helper" ) ;
17
- import PlatformsDataLib = require( "../lib/platforms-data" ) ;
18
- import ProjectDataServiceLib = require( "../lib/services/project-data-service" ) ;
19
- import helpers = require( "../lib/common/helpers" ) ;
20
- import ProjectFilesManagerLib = require( "../lib/services/project-files-manager" ) ;
21
- import { EOL } from "os" ;
22
- import PluginsServiceLib = require( "../lib/services/plugins-service" ) ;
23
- import AddPluginCommandLib = require( "../lib/commands/plugin/add-plugin" ) ;
24
- import { assert } from "chai" ;
4
+ import { Yok } from '../lib/common/yok' ;
5
+ import * as stubs from './stubs' ;
6
+ import { NodePackageManager } from "../lib/node-package-manager" ;
7
+ import { FileSystem } from "../lib/common/file-system" ;
8
+ import { ProjectData } from "../lib/project-data" ;
9
+ import { ChildProcess } from "../lib/common/child-process" ;
10
+ import { PlatformService } from '../lib/services/platform-service' ;
11
+ import { Options } from "../lib/options" ;
12
+ import { CommandsService } from "../lib/common/services/commands-service" ;
13
+ import { StaticConfig } from "../lib/config" ;
14
+ import { HostInfo } from "../lib/common/host-info" ;
15
+ import { Errors } from "../lib/common/errors" ;
16
+ import { ProjectHelper } from "../lib/common/project-helper" ;
17
+ import { PlatformsData } from "../lib/platforms-data" ;
18
+ import { ProjectDataService } from "../lib/services/project-data-service" ;
19
+ import * as helpers from "../lib/common/helpers" ;
20
+ import { ProjectFilesManager } from "../lib/services/project-files-manager" ;
21
+ import { ResourceLoader } from "../lib/common/resource-loader" ;
22
+ import { EOL } from "os" ;
23
+
24
+ import { PluginsService } from "../lib/services/plugins-service" ;
25
+ import { AddPluginCommand } from "../lib/commands/plugin/add-plugin" ;
26
+
27
+ import { assert } from "chai"
25
28
import * as path from "path" ;
26
29
import * as temp from "temp" ;
27
30
temp . track ( ) ;
28
31
29
32
let isErrorThrown = false ;
30
33
31
34
function createTestInjector ( ) {
32
- let testInjector = new yok . Yok ( ) ;
35
+ let testInjector = new Yok ( ) ;
33
36
34
- testInjector . register ( "npm" , NpmLib . NodePackageManager ) ;
35
- testInjector . register ( "fs" , FsLib . FileSystem ) ;
36
- testInjector . register ( "projectData" , ProjectDataLib . ProjectData ) ;
37
+ testInjector . register ( "npm" , NodePackageManager ) ;
38
+ testInjector . register ( "fs" , FileSystem ) ;
39
+ testInjector . register ( "projectData" , ProjectData ) ;
37
40
testInjector . register ( "platforsmData" , stubs . PlatformsDataStub ) ;
38
- testInjector . register ( "childProcess" , ChildProcessLib . ChildProcess ) ;
39
- testInjector . register ( "platformService" , PlatformServiceLib . PlatformService ) ;
40
- testInjector . register ( "platformsData" , PlatformsDataLib . PlatformsData ) ;
41
+ testInjector . register ( "childProcess" , ChildProcess ) ;
42
+ testInjector . register ( "platformService" , PlatformService ) ;
43
+ testInjector . register ( "platformsData" , PlatformsData ) ;
41
44
testInjector . register ( "androidProjectService" , { } ) ;
42
45
testInjector . register ( "iOSProjectService" , { } ) ;
43
46
testInjector . register ( "devicesServices" , { } ) ;
44
- testInjector . register ( "projectDataService" , ProjectDataServiceLib . ProjectDataService ) ;
47
+ testInjector . register ( "projectDataService" , ProjectDataService ) ;
45
48
testInjector . register ( "prompter" , { } ) ;
49
+ testInjector . register ( "resources" , ResourceLoader ) ;
46
50
testInjector . register ( "broccoliBuilder" , { } ) ;
47
- testInjector . register ( "options" , OptionsLib . Options ) ;
48
- testInjector . register ( "errors" , ErrorsLib . Errors ) ;
51
+ testInjector . register ( "options" , Options ) ;
52
+ testInjector . register ( "errors" , Errors ) ;
49
53
testInjector . register ( "logger" , stubs . LoggerStub ) ;
50
- testInjector . register ( "staticConfig" , StaticConfigLib . StaticConfig ) ;
54
+ testInjector . register ( "staticConfig" , StaticConfig ) ;
51
55
testInjector . register ( "hooksService" , stubs . HooksServiceStub ) ;
52
- testInjector . register ( "commandsService" , CommandsServiceLib . CommandsService ) ;
56
+ testInjector . register ( "commandsService" , CommandsService ) ;
53
57
testInjector . register ( "commandsServiceProvider" , {
54
58
registerDynamicSubCommands : ( ) => { }
55
59
} ) ;
56
- testInjector . register ( "hostInfo" , HostInfoLib . HostInfo ) ;
60
+ testInjector . register ( "hostInfo" , HostInfo ) ;
57
61
testInjector . register ( "lockfile" , { } ) ;
58
- testInjector . register ( "projectHelper" , ProjectHelperLib . ProjectHelper ) ;
62
+ testInjector . register ( "projectHelper" , ProjectHelper ) ;
59
63
60
- testInjector . register ( "pluginsService" , PluginsServiceLib . PluginsService ) ;
64
+ testInjector . register ( "pluginsService" , PluginsService ) ;
61
65
testInjector . register ( "analyticsService" , {
62
66
trackException : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; } ,
63
67
checkConsent : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; } ,
64
68
trackFeature : ( ) => { return ( ( ) => { } ) . future < void > ( ) ( ) ; }
65
69
} ) ;
66
- testInjector . register ( "projectFilesManager" , ProjectFilesManagerLib . ProjectFilesManager ) ;
70
+ testInjector . register ( "projectFilesManager" , ProjectFilesManager ) ;
67
71
68
72
return testInjector ;
69
73
}
@@ -120,7 +124,7 @@ function addPluginWhenExpectingToFail(testInjector: IInjector, plugin: string, e
120
124
mockBeginCommand ( testInjector , "Exception: " + expectedErrorMessage ) ;
121
125
122
126
isErrorThrown = false ;
123
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
127
+ let commandsService = testInjector . resolve ( CommandsService ) ;
124
128
commandsService . tryExecuteCommand ( "plugin|add" , [ plugin ] ) . wait ( ) ;
125
129
126
130
assert . isTrue ( isErrorThrown ) ;
@@ -154,7 +158,7 @@ describe("Plugins service", () => {
154
158
let testInjector : IInjector ;
155
159
beforeEach ( ( ) => {
156
160
testInjector = createTestInjector ( ) ;
157
- testInjector . registerCommand ( "plugin|add" , AddPluginCommandLib . AddPluginCommand ) ;
161
+ testInjector . registerCommand ( "plugin|add" , AddPluginCommand ) ;
158
162
} ) ;
159
163
160
164
describe ( "plugin add" , ( ) => {
@@ -188,7 +192,7 @@ describe("Plugins service", () => {
188
192
mockBeginCommand ( testInjector , "Exception: " + 'Plugin "plugin1" is already installed.' ) ;
189
193
190
194
isErrorThrown = false ;
191
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
195
+ let commandsService = testInjector . resolve ( CommandsService ) ;
192
196
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName ] ) . wait ( ) ;
193
197
194
198
assert . isTrue ( isErrorThrown ) ;
@@ -260,7 +264,8 @@ describe("Plugins service", () => {
260
264
} ) . future < IPluginData [ ] > ( ) ( ) ;
261
265
} ;
262
266
263
- pluginsService . add ( pluginName ) . wait ( ) ;
267
+ let commandsService = testInjector . resolve ( CommandsService ) ;
268
+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName ] ) . wait ( ) ;
264
269
265
270
let fs = testInjector . resolve ( "fs" ) ;
266
271
@@ -296,7 +301,8 @@ describe("Plugins service", () => {
296
301
} ) . future < IPluginData [ ] > ( ) ( ) ;
297
302
} ;
298
303
299
- pluginsService . add ( pluginName + "@1.0.0" ) . wait ( ) ;
304
+ let commandsService = testInjector . resolve ( CommandsService ) ;
305
+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginName + "@1.0.0" ] ) . wait ( ) ;
300
306
301
307
let fs = testInjector . resolve ( "fs" ) ;
302
308
@@ -345,7 +351,8 @@ describe("Plugins service", () => {
345
351
} ) . future < IPluginData [ ] > ( ) ( ) ;
346
352
} ;
347
353
348
- pluginsService . add ( pluginFolderPath ) . wait ( ) ;
354
+ let commandsService = testInjector . resolve ( CommandsService ) ;
355
+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
349
356
350
357
// Assert that the all plugin's content is successfully added to node_modules folder
351
358
let nodeModulesFolderPath = path . join ( projectFolder , "node_modules" ) ;
@@ -393,7 +400,8 @@ describe("Plugins service", () => {
393
400
let options = testInjector . resolve ( "options" ) ;
394
401
options . production = true ;
395
402
396
- pluginsService . add ( pluginFolderPath ) . wait ( ) ;
403
+ let commandsService = testInjector . resolve ( CommandsService ) ;
404
+ commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
397
405
398
406
let nodeModulesFolderPath = path . join ( projectFolder , "node_modules" ) ;
399
407
assert . isFalse ( fs . exists ( path . join ( nodeModulesFolderPath , pluginName , "node_modules" , "grunt" ) ) . wait ( ) ) ;
@@ -434,7 +442,7 @@ describe("Plugins service", () => {
434
442
let options = testInjector . resolve ( "options" ) ;
435
443
options . production = false ;
436
444
437
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
445
+ let commandsService = testInjector . resolve ( CommandsService ) ;
438
446
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
439
447
} ) ;
440
448
} ) ;
@@ -443,7 +451,7 @@ describe("Plugins service", () => {
443
451
let testInjector : IInjector ;
444
452
beforeEach ( ( ) => {
445
453
testInjector = createTestInjector ( ) ;
446
- testInjector . registerCommand ( "plugin|add" , AddPluginCommandLib . AddPluginCommand ) ;
454
+ testInjector . registerCommand ( "plugin|add" , AddPluginCommand ) ;
447
455
} ) ;
448
456
it ( "fails if the plugin contains incorrect xml" , ( ) => {
449
457
let pluginName = "mySamplePlugin" ;
@@ -504,7 +512,7 @@ describe("Plugins service", () => {
504
512
`\n@#[line:1,col:39].` ;
505
513
mockBeginCommand ( testInjector , expectedErrorMessage ) ;
506
514
507
- let commandsService = testInjector . resolve ( CommandsServiceLib . CommandsService ) ;
515
+ let commandsService = testInjector . resolve ( CommandsService ) ;
508
516
commandsService . tryExecuteCommand ( "plugin|add" , [ pluginFolderPath ] ) . wait ( ) ;
509
517
} ) ;
510
518
it ( "merges AndroidManifest.xml and produces correct xml" , ( ) => {
0 commit comments