ember-try 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -4
- package/README.md +31 -52
- package/index.js +2 -2
- package/lib/commands/config.js +8 -8
- package/lib/commands/reset.js +8 -10
- package/lib/commands/try-each.js +14 -16
- package/lib/commands/try-ember.js +16 -19
- package/lib/commands/try-one.js +23 -28
- package/lib/dependency-manager-adapters/npm.js +169 -70
- package/lib/dependency-manager-adapters/pnpm.js +170 -0
- package/lib/dependency-manager-adapters/workspace.js +60 -42
- package/lib/tasks/reset.js +9 -2
- package/lib/tasks/try-each.js +78 -67
- package/lib/utils/config.js +54 -64
- package/lib/utils/dependency-manager-adapter-factory.js +28 -9
- package/lib/utils/find-ember-path.js +7 -8
- package/lib/utils/result-summary.js +15 -3
- package/lib/utils/run-command.js +15 -20
- package/lib/utils/run.js +11 -11
- package/lib/utils/scenario-manager.js +18 -29
- package/package.json +70 -63
- package/.codeclimate.yml +0 -17
- package/config/environment.js +0 -5
- package/lib/dependency-manager-adapters/bower.js +0 -198
package/lib/tasks/reset.js
CHANGED
|
@@ -7,8 +7,15 @@ const DependencyManagerAdapterFactory = require('./../utils/dependency-manager-a
|
|
|
7
7
|
|
|
8
8
|
module.exports = CoreObject.extend({
|
|
9
9
|
run() {
|
|
10
|
-
let dependencyAdapters =
|
|
11
|
-
|
|
10
|
+
let dependencyAdapters =
|
|
11
|
+
this.dependencyManagerAdapters ||
|
|
12
|
+
DependencyManagerAdapterFactory.generateFromConfig(this.config, this.project.root);
|
|
13
|
+
debug(
|
|
14
|
+
'DependencyManagerAdapters: %s',
|
|
15
|
+
dependencyAdapters.map((item) => {
|
|
16
|
+
return item.configKey;
|
|
17
|
+
})
|
|
18
|
+
);
|
|
12
19
|
return new ScenarioManager({ dependencyManagerAdapters: dependencyAdapters }).cleanup();
|
|
13
20
|
},
|
|
14
21
|
});
|
package/lib/tasks/try-each.js
CHANGED
|
@@ -1,102 +1,118 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const CoreObject = require('core-object');
|
|
4
|
-
const RSVP = require('rsvp');
|
|
5
|
-
const mapSeries = require('promise-map-series');
|
|
6
4
|
const chalk = require('chalk');
|
|
7
5
|
const debug = require('debug')('ember-try:task:try-each');
|
|
8
6
|
const runCommand = require('./../utils/run-command');
|
|
9
7
|
|
|
10
8
|
module.exports = CoreObject.extend({
|
|
11
|
-
run(scenarios, options) {
|
|
9
|
+
async run(scenarios, options) {
|
|
12
10
|
// Required lazily to improve startup speed.
|
|
13
11
|
let ScenarioManager = require('./../utils/scenario-manager');
|
|
14
12
|
let DependencyManagerAdapterFactory = require('./../utils/dependency-manager-adapter-factory');
|
|
15
13
|
this.ResultSummary = require('./../utils/result-summary');
|
|
16
14
|
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
let dependencyManagerAdapters =
|
|
16
|
+
this.dependencyManagerAdapters ||
|
|
17
|
+
DependencyManagerAdapterFactory.generateFromConfig(this.config, this.project.root);
|
|
18
|
+
debug(
|
|
19
|
+
'DependencyManagerAdapters: %s',
|
|
20
|
+
dependencyManagerAdapters.map((item) => {
|
|
21
|
+
return item.configKey;
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
this.ScenarioManager = new ScenarioManager({
|
|
25
|
+
ui: this.ui,
|
|
22
26
|
dependencyManagerAdapters,
|
|
23
27
|
});
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
29
|
+
this._canceling = false;
|
|
30
|
+
this._on('SIGINT', () => {
|
|
31
|
+
this._canceling = true;
|
|
32
|
+
this.ui.writeLine('\nGracefully shutting down from SIGINT (Ctrl-C)');
|
|
33
|
+
return this.ScenarioManager.cleanup();
|
|
30
34
|
});
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
try {
|
|
37
|
+
await this.ScenarioManager.setup();
|
|
33
38
|
debug('Scenario Manager setup');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
|
|
40
|
+
let results = [];
|
|
41
|
+
for (let scenario of scenarios) {
|
|
42
|
+
results.push(await this._runCommandForThisScenario(scenario));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
await this._optionallyCleanup(options);
|
|
46
|
+
|
|
47
|
+
debug('Output results');
|
|
48
|
+
this._printResults(results);
|
|
49
|
+
|
|
50
|
+
return this._exitAsAppropriate(results);
|
|
51
|
+
} catch (err) {
|
|
52
|
+
this.ui.writeLine(chalk.red('Error!'));
|
|
53
|
+
|
|
43
54
|
if (err) {
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
this.ui.writeLine(chalk.red(err));
|
|
56
|
+
this.ui.writeLine(chalk.red(err.stack));
|
|
46
57
|
}
|
|
58
|
+
|
|
47
59
|
return 1; // Signifies exit code
|
|
48
|
-
}
|
|
60
|
+
}
|
|
49
61
|
},
|
|
50
62
|
|
|
51
|
-
_runCommandForThisScenario(scenario) {
|
|
52
|
-
|
|
63
|
+
async _runCommandForThisScenario(scenario) {
|
|
64
|
+
if (this._canceling) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
53
67
|
|
|
54
|
-
|
|
68
|
+
let scenarioDependencyState = await this.ScenarioManager.changeTo(scenario);
|
|
55
69
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
if (this._canceling) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
59
73
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let command = task._determineCommandFor(scenario);
|
|
63
|
-
let runResults = {
|
|
64
|
-
scenario: scenario.name,
|
|
65
|
-
allowedToFail: !!scenario.allowedToFail,
|
|
66
|
-
dependencyState: scenarioDependencyState,
|
|
67
|
-
envState: scenario.env,
|
|
68
|
-
command: command.join(' '),
|
|
69
|
-
};
|
|
74
|
+
process.env.EMBER_TRY_CURRENT_SCENARIO = scenario.name;
|
|
75
|
+
this._writeHeader(`Scenario: ${scenario.name}`);
|
|
70
76
|
|
|
71
|
-
|
|
77
|
+
let command = this._determineCommandFor(scenario);
|
|
78
|
+
let runResults = {
|
|
79
|
+
scenario: scenario.name,
|
|
80
|
+
allowedToFail: !!scenario.allowedToFail,
|
|
81
|
+
dependencyState: scenarioDependencyState,
|
|
82
|
+
envState: scenario.env,
|
|
83
|
+
command: command.join(' '),
|
|
84
|
+
};
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
if (task._canceling) { return; }
|
|
86
|
+
debug('With:\n', runResults);
|
|
75
87
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
let result = await this._runCommand({
|
|
89
|
+
commandArgs: command,
|
|
90
|
+
commandOptions: this._commandOptions(scenario.env),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (this._canceling) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
runResults.result = result;
|
|
98
|
+
this._writeFooter(`Result: ${result}`);
|
|
99
|
+
|
|
100
|
+
return runResults;
|
|
81
101
|
},
|
|
82
102
|
|
|
83
103
|
_writeHeader(text) {
|
|
84
|
-
let task = this;
|
|
85
104
|
let count = 75 - text.length;
|
|
86
105
|
let separator = new Array(count + 1).join('=');
|
|
87
|
-
|
|
106
|
+
this.ui.writeLine(chalk.blue(`\n=== ${text} ${separator}\n`));
|
|
88
107
|
},
|
|
89
108
|
|
|
90
109
|
_writeFooter(text) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
task.ui.writeLine(chalk.blue('---\n'));
|
|
110
|
+
this.ui.writeLine(chalk.blue(`\n${text}`));
|
|
111
|
+
this.ui.writeLine(chalk.blue('---\n'));
|
|
94
112
|
},
|
|
95
113
|
|
|
96
114
|
_determineCommandFor(scenario) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (task.commandArgs && task.commandArgs.length) {
|
|
115
|
+
if (this.commandArgs && this.commandArgs.length) {
|
|
100
116
|
return this.commandArgs;
|
|
101
117
|
}
|
|
102
118
|
|
|
@@ -104,8 +120,8 @@ module.exports = CoreObject.extend({
|
|
|
104
120
|
return scenario.command.split(' ');
|
|
105
121
|
}
|
|
106
122
|
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
123
|
+
if (this.config.command) {
|
|
124
|
+
return this.config.command.split(' ');
|
|
109
125
|
}
|
|
110
126
|
|
|
111
127
|
return this._defaultCommandArgs();
|
|
@@ -139,21 +155,17 @@ module.exports = CoreObject.extend({
|
|
|
139
155
|
return this._exitBasedOnCondition(outcomes.indexOf(false) > -1);
|
|
140
156
|
},
|
|
141
157
|
|
|
142
|
-
_optionallyCleanup(options) {
|
|
158
|
+
async _optionallyCleanup(options) {
|
|
143
159
|
debug('Cleanup');
|
|
144
160
|
delete process.env.EMBER_TRY_CURRENT_SCENARIO;
|
|
145
161
|
|
|
146
|
-
let task = this;
|
|
147
|
-
let promise;
|
|
148
162
|
if (options && options.skipCleanup) {
|
|
149
163
|
// Create a fake promise for consistency
|
|
150
164
|
debug('Skip ScenarioManager cleanup');
|
|
151
|
-
promise = RSVP.Promise.resolve();
|
|
152
165
|
} else {
|
|
153
166
|
debug('Cleanup ScenarioManager');
|
|
154
|
-
|
|
167
|
+
return await this.ScenarioManager.cleanup();
|
|
155
168
|
}
|
|
156
|
-
return promise;
|
|
157
169
|
},
|
|
158
170
|
|
|
159
171
|
_exitBasedOnCondition(condition) {
|
|
@@ -170,5 +182,4 @@ module.exports = CoreObject.extend({
|
|
|
170
182
|
_on(signal, fn) {
|
|
171
183
|
process.on(signal, fn);
|
|
172
184
|
},
|
|
173
|
-
|
|
174
185
|
});
|
package/lib/utils/config.js
CHANGED
|
@@ -2,96 +2,88 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const extend = require('extend');
|
|
6
|
-
const RSVP = require('rsvp');
|
|
7
5
|
const findByName = require('./find-by-name');
|
|
8
6
|
const debug = require('debug')('ember-try:utils:config');
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
function getConfigPath(project) {
|
|
9
|
+
let possibleConfigPath;
|
|
10
|
+
if (project.pkg && project.pkg['ember-addon'] && project.pkg['ember-addon']['configPath']) {
|
|
11
|
+
let configDir = project.pkg['ember-addon']['configPath'];
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let configFile = path.join(options.project.root, relativePath);
|
|
15
|
-
let configData;
|
|
13
|
+
possibleConfigPath = path.join(configDir, 'ember-try.js');
|
|
14
|
+
}
|
|
16
15
|
|
|
17
|
-
if (fs.existsSync(
|
|
18
|
-
|
|
16
|
+
if (fs.existsSync(possibleConfigPath)) {
|
|
17
|
+
debug(`using config from package.json ember-addon.configPath: ${possibleConfigPath}`);
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
configData = configData(options.project);
|
|
22
|
-
}
|
|
23
|
-
} else {
|
|
24
|
-
debug('Config file does not exist %s', configFile);
|
|
19
|
+
return possibleConfigPath;
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let versionCompatibility = options.versionCompatibility || versionCompatibilityFromPackageJSON(options.project.root);
|
|
33
|
-
|
|
34
|
-
if (versionCompatibility) {
|
|
35
|
-
// Required lazily to improve startup speed.
|
|
36
|
-
let autoScenarioConfigForEmber = require('ember-try-config');
|
|
37
|
-
return autoScenarioConfigForEmber({ versionCompatibility, project: options.project }).then((autoConfig) => {
|
|
38
|
-
return mergeAutoConfigAndConfigFileData(autoConfig, data);
|
|
39
|
-
});
|
|
40
|
-
} else {
|
|
41
|
-
return RSVP.reject(new Error('No ember-try configuration found. Please see the README for configuration options'));
|
|
42
|
-
}
|
|
43
|
-
});
|
|
22
|
+
debug('using config from config/ember-try.js');
|
|
23
|
+
|
|
24
|
+
return path.join('config', 'ember-try.js');
|
|
44
25
|
}
|
|
45
26
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
async function getBaseConfig(options) {
|
|
28
|
+
let relativeConfigPath = options.configPath || getConfigPath(options.project);
|
|
29
|
+
let configPath = path.join(options.project.root, relativeConfigPath);
|
|
30
|
+
let data;
|
|
31
|
+
|
|
32
|
+
if (fs.existsSync(configPath)) {
|
|
33
|
+
let configData = await require(configPath);
|
|
34
|
+
|
|
35
|
+
data = typeof configData === 'function' ? await configData(options.project) : configData;
|
|
36
|
+
} else {
|
|
37
|
+
debug('Config file does not exist %s', configPath);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (data && data.scenarios && !data.useVersionCompatibility && !options.versionCompatibility) {
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let versionCompatibility =
|
|
45
|
+
options.versionCompatibility || versionCompatibilityFromPackageJSON(options.project.root);
|
|
46
|
+
if (versionCompatibility) {
|
|
47
|
+
// Required lazily to improve startup speed.
|
|
48
|
+
let autoScenarioConfigForEmber = require('ember-try-config');
|
|
49
|
+
|
|
50
|
+
let autoConfig = await autoScenarioConfigForEmber({
|
|
51
|
+
versionCompatibility,
|
|
52
|
+
project: options.project,
|
|
53
|
+
});
|
|
54
|
+
return await mergeAutoConfigAndConfigFileData(autoConfig, data);
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error(
|
|
57
|
+
'No ember-try configuration found. Please see the README for configuration options'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
50
60
|
}
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
async function config(options) {
|
|
63
|
+
const configData = await getBaseConfig(options);
|
|
53
64
|
|
|
54
|
-
function addImplicitBowerToScenarios(configData) {
|
|
55
|
-
configData.scenarios.forEach((scenario) => {
|
|
56
|
-
if (!('bower' in scenario)) {
|
|
57
|
-
// Don't do anything for scenarios that don't include bower
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if ('npm' in scenario) {
|
|
62
|
-
let npm = scenario.npm;
|
|
63
|
-
if ((npm.dependencies && npm.dependencies.bower) ||
|
|
64
|
-
(npm.devDependencies && npm.devDependencies.bower)) {
|
|
65
|
-
// Dont' do anything for scenarios that already include bower in npm,
|
|
66
|
-
// either as a dependency or a dev dependency
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// add an implicit bower dev dependency to npm for this scenario
|
|
72
|
-
scenario.npm = scenario.npm || {};
|
|
73
|
-
scenario.npm.devDependencies = scenario.npm.devDependencies || {};
|
|
74
|
-
scenario.npm.devDependencies.bower = IMPLICIT_BOWER_VERSION;
|
|
75
|
-
});
|
|
76
65
|
return configData;
|
|
77
66
|
}
|
|
78
67
|
|
|
68
|
+
module.exports = config;
|
|
69
|
+
|
|
79
70
|
function mergeAutoConfigAndConfigFileData(autoConfig, configData) {
|
|
80
71
|
configData = configData || {};
|
|
81
72
|
configData.scenarios = configData.scenarios || [];
|
|
82
73
|
|
|
83
|
-
let conf =
|
|
74
|
+
let conf = Object.assign({}, autoConfig, configData);
|
|
84
75
|
|
|
85
76
|
let overriddenScenarios = autoConfig.scenarios.map((scenario) => {
|
|
86
77
|
let overriddenScenario = findByName(configData.scenarios, scenario.name);
|
|
87
|
-
return
|
|
78
|
+
return Object.assign({}, scenario, overriddenScenario);
|
|
88
79
|
});
|
|
89
80
|
|
|
90
81
|
let additionalScenarios = configData.scenarios.filter((scenario) => {
|
|
91
82
|
return !findByName(autoConfig.scenarios, scenario.name);
|
|
92
83
|
});
|
|
93
84
|
|
|
94
|
-
conf.scenarios = [
|
|
85
|
+
conf.scenarios = [...overriddenScenarios, ...additionalScenarios];
|
|
86
|
+
|
|
95
87
|
return conf;
|
|
96
88
|
}
|
|
97
89
|
|
|
@@ -99,9 +91,7 @@ function versionCompatibilityFromPackageJSON(root) {
|
|
|
99
91
|
let packageJSONFile = path.join(root, 'package.json');
|
|
100
92
|
if (fs.existsSync(packageJSONFile)) {
|
|
101
93
|
let packageJSON = JSON.parse(fs.readFileSync(packageJSONFile));
|
|
94
|
+
|
|
102
95
|
return packageJSON['ember-addon'] ? packageJSON['ember-addon'].versionCompatibility : null;
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
|
-
|
|
106
|
-
// Used for internal testing purposes.
|
|
107
|
-
module.exports._addImplicitBowerToScenarios = addImplicitBowerToScenarios;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const BowerAdapter = require('../dependency-manager-adapters/bower');
|
|
4
3
|
const NpmAdapter = require('../dependency-manager-adapters/npm');
|
|
4
|
+
const PnpmAdapter = require('../dependency-manager-adapters/pnpm');
|
|
5
5
|
const WorkspaceAdapter = require('../dependency-manager-adapters/workspace');
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
@@ -22,21 +22,40 @@ module.exports = {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
25
|
+
if (hasBower) {
|
|
26
|
+
throw new Error('[ember-try] bower configuration is no longer supported');
|
|
27
|
+
}
|
|
29
28
|
|
|
29
|
+
if (config.useWorkspaces) {
|
|
30
30
|
adapters.push(
|
|
31
31
|
new WorkspaceAdapter({
|
|
32
32
|
cwd: root,
|
|
33
33
|
managerOptions: config.npmOptions,
|
|
34
|
-
useYarnCommand: config.useYarn
|
|
34
|
+
useYarnCommand: config.useYarn,
|
|
35
|
+
buildManagerOptions: config.buildManagerOptions,
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
} else if (config.usePnpm) {
|
|
39
|
+
console.warn(
|
|
40
|
+
'pnpm support is experimental for now. if you notice any problems please open an issue.'
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
adapters.push(
|
|
44
|
+
new PnpmAdapter({
|
|
45
|
+
cwd: root,
|
|
46
|
+
managerOptions: config.npmOptions,
|
|
47
|
+
buildManagerOptions: config.buildManagerOptions,
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
} else if (hasNpm) {
|
|
51
|
+
adapters.push(
|
|
52
|
+
new NpmAdapter({
|
|
53
|
+
cwd: root,
|
|
54
|
+
managerOptions: config.npmOptions,
|
|
55
|
+
useYarnCommand: config.useYarn,
|
|
56
|
+
buildManagerOptions: config.buildManagerOptions,
|
|
35
57
|
})
|
|
36
58
|
);
|
|
37
|
-
} else if (hasNpm || hasBower) {
|
|
38
|
-
adapters.push(new NpmAdapter({ cwd: root, managerOptions: config.npmOptions, useYarnCommand: config.useYarn }));
|
|
39
|
-
adapters.push(new BowerAdapter({ cwd: root, managerOptions: config.bowerOptions }));
|
|
40
59
|
}
|
|
41
60
|
|
|
42
61
|
return adapters;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const
|
|
5
|
-
const resolve =
|
|
4
|
+
const utils = require('util');
|
|
5
|
+
const resolve = utils.promisify(require('resolve'));
|
|
6
6
|
|
|
7
|
-
module.exports = function(root) {
|
|
7
|
+
module.exports = async function (root) {
|
|
8
8
|
/* Find ember-cli's entry point module relative to
|
|
9
9
|
the current projects root */
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
10
|
+
let emberPath = await resolve('ember-cli', { basedir: root });
|
|
11
|
+
|
|
12
|
+
// Return the path to the ember command script
|
|
13
|
+
return path.join(emberPath, '..', '..', '..', 'bin', 'ember');
|
|
15
14
|
};
|
|
@@ -47,12 +47,19 @@ module.exports = CoreObject.extend({
|
|
|
47
47
|
task.ui.writeLine('');
|
|
48
48
|
},
|
|
49
49
|
_printDependencyTable(dependencyStatus) {
|
|
50
|
-
if (!dependencyStatus.length) {
|
|
50
|
+
if (!dependencyStatus.length) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
51
53
|
let task = this;
|
|
52
54
|
let colorForDepFn;
|
|
53
55
|
let tableRow;
|
|
54
56
|
let table = new Table({
|
|
55
|
-
head: [
|
|
57
|
+
head: [
|
|
58
|
+
chalk.gray('Dependency'),
|
|
59
|
+
chalk.gray('Expected'),
|
|
60
|
+
chalk.gray('Used'),
|
|
61
|
+
chalk.gray('Type'),
|
|
62
|
+
],
|
|
56
63
|
colWidths: [20, 20, 30, 10],
|
|
57
64
|
});
|
|
58
65
|
dependencyStatus.forEach((dep) => {
|
|
@@ -61,7 +68,12 @@ module.exports = CoreObject.extend({
|
|
|
61
68
|
} else {
|
|
62
69
|
colorForDepFn = chalk.yellow;
|
|
63
70
|
}
|
|
64
|
-
tableRow = [
|
|
71
|
+
tableRow = [
|
|
72
|
+
dep.name,
|
|
73
|
+
dep.versionExpected || 'Not Installed',
|
|
74
|
+
dep.versionSeen || 'Not Installed',
|
|
75
|
+
dep.packageManager,
|
|
76
|
+
].map((column) => {
|
|
65
77
|
return colorForDepFn(column);
|
|
66
78
|
});
|
|
67
79
|
table.push(tableRow);
|
package/lib/utils/run-command.js
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const RSVP = require('rsvp');
|
|
4
|
-
const extend = require('extend');
|
|
5
3
|
const findEmberPath = require('./find-ember-path');
|
|
6
4
|
const run = require('./run');
|
|
7
5
|
|
|
8
|
-
module.exports = function(root, commandArgs, opts) {
|
|
9
|
-
let options =
|
|
10
|
-
let
|
|
11
|
-
let command = commandArgs[0];
|
|
12
|
-
let actualArgs = commandArgs.slice(1);
|
|
6
|
+
module.exports = async function (root, commandArgs, opts) {
|
|
7
|
+
let options = Object.assign({ cwd: root }, opts);
|
|
8
|
+
let [command, ...actualArgs] = commandArgs;
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
try {
|
|
11
|
+
if (command === 'ember') {
|
|
12
|
+
let emberPath = await findEmberPath(root);
|
|
13
|
+
await run('node', [`"${emberPath}"`, ...actualArgs], options);
|
|
14
|
+
} else {
|
|
15
|
+
await run(command, actualArgs, options);
|
|
16
|
+
}
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}).catch((errorCode) => {
|
|
18
|
+
return true;
|
|
19
|
+
} catch (errorCode) {
|
|
25
20
|
if (errorCode !== 1) {
|
|
26
|
-
|
|
21
|
+
throw new Error(`The command ${commandArgs.join(' ')} exited ${errorCode}`);
|
|
27
22
|
} else {
|
|
28
|
-
return
|
|
23
|
+
return false;
|
|
29
24
|
}
|
|
30
|
-
}
|
|
25
|
+
}
|
|
31
26
|
};
|
package/lib/utils/run.js
CHANGED
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
const execa = require('execa');
|
|
4
4
|
const debug = require('debug')('ember-try:utils:run');
|
|
5
5
|
|
|
6
|
-
module.exports = function run(command, args,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
opts.stdio = opts.stdio || 'inherit';
|
|
6
|
+
module.exports = async function run(command, args, _options) {
|
|
7
|
+
let options = Object.assign({ stdio: 'inherit', shell: true }, _options);
|
|
10
8
|
|
|
11
9
|
if (process.env.SHUT_UP) {
|
|
12
|
-
|
|
10
|
+
options.stdio = 'ignore';
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
let cmdArgs = `${command} ${args.join(' ')}`;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
debug('spawned with execa.shell', cmdArgs, opts);
|
|
14
|
+
try {
|
|
15
|
+
debug('spawning execa.shell', cmdArgs, options);
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
return await execa(cmdArgs, options);
|
|
18
|
+
} catch (error) {
|
|
21
19
|
debug('error', error);
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
|
|
21
|
+
// TODO: should refactor this to throw an error (easier to track down stack traces)
|
|
22
|
+
throw error.exitCode;
|
|
23
|
+
}
|
|
24
24
|
};
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const CoreObject = require('core-object');
|
|
4
|
-
const RSVP = require('rsvp');
|
|
5
|
-
const mapSeries = require('promise-map-series');
|
|
6
4
|
|
|
7
5
|
module.exports = CoreObject.extend({
|
|
8
|
-
|
|
9
|
-
this
|
|
10
|
-
this._checkDependencyManagerAdapters();
|
|
11
|
-
},
|
|
6
|
+
async setup() {
|
|
7
|
+
let { ui } = this;
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error('No dependency manager adapter');
|
|
9
|
+
for (let depManager of this.dependencyManagerAdapters) {
|
|
10
|
+
await depManager.setup({ ui });
|
|
16
11
|
}
|
|
17
12
|
},
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
return mapSeries(this.dependencyManagerAdapters, (depManager) => {
|
|
23
|
-
return depManager.setup({ ui });
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
changeTo(scenario) {
|
|
28
|
-
return mapSeries(this.dependencyManagerAdapters, (depManager) => {
|
|
14
|
+
async changeTo(scenario) {
|
|
15
|
+
let results = [];
|
|
16
|
+
for (let depManager of this.dependencyManagerAdapters) {
|
|
29
17
|
if (scenario[depManager.configKey]) {
|
|
30
|
-
|
|
18
|
+
let depManagerResults = await depManager.changeToDependencySet(
|
|
19
|
+
scenario[depManager.configKey]
|
|
20
|
+
);
|
|
21
|
+
results.push(...depManagerResults);
|
|
31
22
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return results;
|
|
36
26
|
},
|
|
37
27
|
|
|
38
|
-
cleanup() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
28
|
+
async cleanup() {
|
|
29
|
+
for (let depManager of this.dependencyManagerAdapters) {
|
|
30
|
+
await depManager.cleanup();
|
|
31
|
+
}
|
|
42
32
|
},
|
|
43
33
|
});
|
|
44
|
-
|