-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move logic out of
ember-cli
commands
- Loading branch information
1 parent
e0d196e
commit bda3dce
Showing
20 changed files
with
297 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import getConfig from '../utils/config.js'; | ||
import { log } from '../utils/console.js'; | ||
|
||
export async function config({ configPath, cwd }) { | ||
const config = await getConfig({ configPath, cwd }); | ||
|
||
log(JSON.stringify(config, null, 2)); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ResetTask from '../tasks/reset.js'; | ||
import getConfig from '../utils/config.js'; | ||
|
||
export async function reset({ configPath, cwd }) { | ||
const config = await getConfig({ configPath, cwd }); | ||
const resetTask = new ResetTask({ config, cwd }); | ||
|
||
await resetTask.run(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import TryEachTask from '../tasks/try-each.js'; | ||
import getConfig from '../utils/config.js'; | ||
|
||
export async function tryEach({ | ||
configPath, | ||
cwd, | ||
skipCleanup, | ||
|
||
// For testing purposes: | ||
_getConfig = getConfig, | ||
_TryEachTask = TryEachTask, | ||
}) { | ||
const config = await _getConfig({ configPath, cwd }); | ||
const tryEachTask = new _TryEachTask({ config, cwd }); | ||
|
||
await tryEachTask.run(config.scenarios, { skipCleanup }); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import TryEachTask from '../tasks/try-each.js'; | ||
import getConfig from '../utils/config.js'; | ||
|
||
export async function tryEmber({ | ||
configPath, | ||
cwd, | ||
ember, | ||
skipCleanup, | ||
|
||
// For testing purposes: | ||
_getConfig = getConfig, | ||
_TryEachTask = TryEachTask, | ||
}) { | ||
const config = await _getConfig({ | ||
configPath, | ||
cwd, | ||
versionCompatibility: { ember }, | ||
}); | ||
|
||
const tryEachTask = new _TryEachTask({ config, cwd }); | ||
|
||
await tryEachTask.run(config.scenarios, { skipCleanup }); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import TryEachTask from '../tasks/try-each.js'; | ||
import getConfig from '../utils/config.js'; | ||
|
||
export async function tryOne({ | ||
configPath, | ||
cwd, | ||
scenarioName, | ||
skipCleanup, | ||
|
||
// For testing purposes: | ||
_args = process.argv, | ||
_getConfig = getConfig, | ||
_TryEachTask = TryEachTask, | ||
}) { | ||
const config = await _getConfig({ configPath, cwd }); | ||
const scenario = config.scenarios.find((s) => s.name === scenarioName); | ||
|
||
if (scenario === undefined) { | ||
throw new Error('The `try:one` command requires a scenario name specified in the config.'); | ||
} | ||
|
||
const tryEachTask = new _TryEachTask({ | ||
commandArgs: getCommandArgs(_args), | ||
config, | ||
cwd, | ||
}); | ||
|
||
await tryEachTask.run([scenario], { skipCleanup }); | ||
} | ||
|
||
export function getCommandArgs(args) { | ||
const separatorIndex = args.indexOf('---'); | ||
|
||
if (separatorIndex === -1) { | ||
return []; | ||
} else { | ||
return args.slice(separatorIndex + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'try:config', | ||
description: 'Displays the config that will be used', | ||
works: 'insideProject', | ||
availableOptions: [{ name: 'config-path', type: String }], | ||
|
||
async run({ configPath }) { | ||
const { config } = await import('../commands/config.mjs'); | ||
|
||
await config({ configPath, cwd: this.project.root }); | ||
}, | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'try:reset', | ||
description: 'Resets dependencies to their committed state. For when things get messy.', | ||
works: 'insideProject', | ||
availableOptions: [{ name: 'config-path', type: String }], | ||
|
||
async run({ configPath }) { | ||
const { reset } = await import('../commands/reset.mjs'); | ||
|
||
await reset({ configPath, cwd: this.project.root }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'try:each', | ||
description: | ||
'Runs each of the dependency scenarios specified in config with the specified command. The command defaults to `ember test`', | ||
works: 'insideProject', | ||
|
||
availableOptions: [ | ||
{ name: 'config-path', type: String }, | ||
{ name: 'skip-cleanup', type: Boolean, default: false }, | ||
], | ||
|
||
async run({ configPath, skipCleanup }) { | ||
const { tryEach } = await import('../commands/try-each.mjs'); | ||
|
||
await tryEach({ configPath, cwd: this.project.root, skipCleanup }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
name: 'try:ember', | ||
description: | ||
'Runs with each Ember version matching the semver statement given. The command defaults to `ember test`', | ||
works: 'insideProject', | ||
|
||
anonymousOptions: ['<ember-semver-statement>'], | ||
|
||
availableOptions: [ | ||
{ name: 'config-path', type: String }, | ||
{ name: 'skip-cleanup', type: Boolean, default: false }, | ||
], | ||
|
||
async run({ configPath, skipCleanup }, [ember]) { | ||
const { tryEmber } = await import('../commands/try-ember.mjs'); | ||
|
||
await tryEmber({ configPath, cwd: this.project.root, ember, skipCleanup }); | ||
}, | ||
}; |
Oops, something went wrong.