Skip to content

Commit bc5fec7

Browse files
authored
Merge pull request #335 from isleofcode/feat/change-proxy-behaviour
[WIP] Change proxy to ember cdv:proxy $command
2 parents 90af889 + b64bccd commit bc5fec7

File tree

4 files changed

+93
-65
lines changed

4 files changed

+93
-65
lines changed

lib/commands/cordova.js

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,26 @@
11
'use strict';
2+
/* eslint-disable max-len */
23

34
var Command = require('./-command');
5+
var ProxyCommand = require('./proxy');
46

5-
var BashTask = require('../tasks/bash');
6-
var cordovaPath = require('../utils/cordova-path');
77
var logger = require('../utils/logger');
88

9-
var ValidateCordova = require('../tasks/validate/cordova-installed');
10-
119
module.exports = Command.extend({
1210
name: 'cordova',
1311
aliases: ['cdv'],
14-
description: 'Passes commands to Cordova CLI',
12+
description: 'Deprecated',
1513
works: 'insideProject',
1614

17-
supportedCommands: [
18-
'build',
19-
'platform',
20-
'platforms',
21-
'plugin',
22-
'plugins',
23-
'prepare'
24-
],
25-
26-
knownCordovaCommands: [
27-
'run',
28-
'emulate'
29-
],
30-
31-
validateAndRun: function(rawArgs) {
32-
var warning;
33-
34-
if (this.supportedCommands.indexOf(rawArgs[0]) >= 0) {
35-
warning = rawArgs +
36-
' run in cordova, but bypassed ember-cordova command.' +
37-
' Consider running ember cdv:' + rawArgs + ' instead';
38-
39-
} else if (this.knownCordovaCommands.indexOf(rawArgs[0]) === -1) {
40-
warning = rawArgs +
41-
' passed to Cordova, but is an unknown Cordova command';
42-
43-
}
44-
45-
if (warning !== undefined) {
46-
logger.warn(warning);
47-
}
48-
49-
return this.run({}, rawArgs);
50-
},
51-
5215
run: function(options, rawArgs) {
53-
this._super.apply(this, arguments);
54-
55-
var project = this.project;
56-
57-
var isInstalled = new ValidateCordova({
58-
project: project
59-
});
60-
61-
return isInstalled.run().then(function() {
62-
var joinedArgs = rawArgs.join(' ');
63-
var cdvCommand = 'cordova ' + joinedArgs;
64-
65-
var msg = 'Running \'cordova ' + joinedArgs + '\'';
66-
logger.success(msg);
67-
68-
return new BashTask({
69-
command: cdvCommand,
70-
options: {
71-
cwd: cordovaPath(project)
72-
}
73-
}).run();
74-
}).catch(function(e) {
75-
logger.error(e);
76-
});
16+
logger.warn(
17+
'DEPRECATION WARNING (ember-cordova): ember cdv proxy syntax has changed\n' +
18+
'The prior proxy command was "ember cdv $COMMAND" \n' +
19+
'To ease confusion this is now "ember cdv:proxy $COMMAND". No other changes are required. \n' +
20+
'So ember cdv run would now be ember cdv:proxy run \n \n' +
21+
'This is just a warning, your command has been proxied for now. The old proxy syntax will be fully deprecated on July 1 in favour of ember cdv:proxy.'
22+
);
23+
24+
return new ProxyCommand({project: this.project}).validateAndRun(rawArgs);
7725
}
7826
});

lib/commands/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
'cordova:platform' : require('./platform'),
77
'cordova:plugin' : require('./plugin'),
88
'cordova:prepare' : require('./prepare'),
9+
'cordova:proxy' : require('./proxy'),
910
'cordova:serve' : require('./serve'),
1011
'cordova:make-icons' : require('./make-icons'),
1112
'cordova:make-splashes' : require('./make-splashes'),

lib/commands/proxy.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
'use strict';
2+
3+
var Command = require('./-command');
4+
5+
var BashTask = require('../tasks/bash');
6+
var cordovaPath = require('../utils/cordova-path');
7+
var logger = require('../utils/logger');
8+
9+
var ValidateCordova = require('../tasks/validate/cordova-installed');
10+
11+
module.exports = Command.extend({
12+
name: 'cordova:proxy',
13+
aliases: ['cdv:proxy'],
14+
description: 'Passes commands to Cordova CLI',
15+
works: 'insideProject',
16+
17+
supportedCommands: [
18+
'build',
19+
'platform',
20+
'platforms',
21+
'plugin',
22+
'plugins',
23+
'prepare'
24+
],
25+
26+
knownCordovaCommands: [
27+
'run',
28+
'emulate'
29+
],
30+
31+
validateAndRun: function(rawArgs) {
32+
console.log('got', rawArgs);
33+
var warning;
34+
35+
if (this.supportedCommands.indexOf(rawArgs[0]) >= 0) {
36+
warning = rawArgs +
37+
' run in cordova, but bypassed ember-cordova command.' +
38+
' Consider running ember cdv:' + rawArgs + ' instead';
39+
40+
} else if (this.knownCordovaCommands.indexOf(rawArgs[0]) === -1) {
41+
warning = rawArgs +
42+
' passed to Cordova, but is an unknown Cordova command';
43+
44+
}
45+
46+
if (warning !== undefined) {
47+
logger.warn(warning);
48+
}
49+
50+
return this.run({}, rawArgs);
51+
},
52+
53+
run: function(options, rawArgs) {
54+
this._super.apply(this, arguments);
55+
56+
var project = this.project;
57+
58+
var isInstalled = new ValidateCordova({
59+
project: project
60+
});
61+
62+
return isInstalled.run().then(function() {
63+
var joinedArgs = rawArgs.join(' ');
64+
var cdvCommand = 'cordova ' + joinedArgs;
65+
66+
var msg = 'Running \'cordova ' + joinedArgs + '\'';
67+
logger.success(msg);
68+
69+
return new BashTask({
70+
command: cdvCommand,
71+
options: {
72+
cwd: cordovaPath(project)
73+
}
74+
}).run();
75+
}).catch(function(e) {
76+
logger.error(e);
77+
});
78+
}
79+
});

node-tests/unit/commands/cordova-test.js renamed to node-tests/unit/commands/proxy-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var BashTask = require('../../../lib/tasks/bash');
44
var VerifyInstall = require('../../../lib/tasks/validate/cordova-installed');
5-
var CordovaCmd = require('../../../lib/commands/cordova');
5+
var CordovaCmd = require('../../../lib/commands/proxy');
66
var logger = require('../../../lib/utils/logger');
77

88

0 commit comments

Comments
 (0)