Skip to content

Commit

Permalink
Merge pull request #185 from ember-cli/kg-upgrade-ember-try-config
Browse files Browse the repository at this point in the history
Upgrade ember-try-config to 3.0
  • Loading branch information
kategengler authored Feb 9, 2018
2 parents cc44a10 + ff8dd36 commit 6836181
Show file tree
Hide file tree
Showing 4 changed files with 406 additions and 116 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ If `useVersionCompatibility` is set to `true` in the config file, the autogenera

To keep this from getting out of hand, `ember-try` will limit the versions of Ember used to the lasted point release per minor version. For example, ">1.11.0 <=2.0.0", would (as of writing) run with versions ['1.11.4', '1.12.2', '1.13.13', '2.0.0'].

As of v1.0.0, This will only work for projects starting with ember provided by npm, not bower.

##### Configuration Files

Configuration will be read from a file in your ember app in `config/ember-try.js`. Here are the possible options:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"cli-table2": "^0.2.0",
"core-object": "^3.1.5",
"debug": "^3.1.0",
"ember-try-config": "^2.2.0",
"ember-try-config": "^3.0.0",
"extend": "^3.0.0",
"fs-extra": "^5.0.0",
"promise-map-series": "^0.2.1",
Expand Down
151 changes: 42 additions & 109 deletions test/utils/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,84 +214,51 @@ describe('utils/config', () => {

it('is used if there is no config file', () => {
return getConfig({ project }).then((config) => {
expect(config).to.eql({
scenarios: [
{ name: 'default', bower: { dependencies: {} }, npm: { devDependencies: { bower: '^1.8.2' } } },
{
name: 'ember-beta',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#beta' }, resolutions: { ember: 'beta' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-canary',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#canary' }, resolutions: { ember: 'canary' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-2.2.0',
bower: { dependencies: { ember: '2.2.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
],
});
let scenarios = config.scenarios;
expect(scenarios.length).to.equal(5);
expect(scenarios).to.include.deep.members([
{ name: 'default', npm: { devDependencies: { } } },
{
name: 'ember-2.2.0',
bower: { dependencies: { ember: '2.2.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
]);

let scenarioNames = scenarios.map((s) => { return s.name; });
expect(scenarioNames).to.include.members(['ember-beta', 'ember-release', 'ember-canary']);
});
});

it('is always used if passed in and behaves as if config file has "useVersionCompatibility: true"', () => {
generateConfigFile('module.exports = { scenarios: [ { foo: "bar" }] };');
return getConfig({ project, versionCompatibility: { ember: '1.13.0' } }).then((config) => {
expect(config).to.eql({
scenarios: [
{ name: 'default', bower: { dependencies: {} }, npm: { devDependencies: { bower: '^1.8.2' } } },
{
name: 'ember-beta',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#beta' }, resolutions: { ember: 'beta' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-canary',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#canary' }, resolutions: { ember: 'canary' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-1.13.0',
bower: { dependencies: { ember: '1.13.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{ foo: 'bar' },
],
});
let scenarios = config.scenarios;
expect(scenarios.length).to.equal(6);
expect(scenarios).to.include.deep.members([
{ name: 'default', npm: { devDependencies: { } } },
{
name: 'ember-1.13.0',
bower: { dependencies: { ember: '1.13.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{ foo: 'bar' },
]);
});
});

it('can be overridden by passed in versionCompatibility', () => {
return getConfig({ project, versionCompatibility: { ember: '1.13.0' } }).then((config) => {
expect(config).to.eql({
scenarios: [
{ name: 'default', bower: { dependencies: {} }, npm: { devDependencies: { bower: '^1.8.2' } } },
{
name: 'ember-beta',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#beta' }, resolutions: { ember: 'beta' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-canary',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#canary' }, resolutions: { ember: 'canary' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-1.13.0',
bower: { dependencies: { ember: '1.13.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
],
});
let scenarios = config.scenarios;
expect(scenarios.length).to.equal(5);
expect(scenarios).to.include.deep.members([
{ name: 'default', npm: { devDependencies: { } } },
{
name: 'ember-1.13.0',
bower: { dependencies: { ember: '1.13.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
]);
});
});

Expand All @@ -307,33 +274,8 @@ describe('utils/config', () => {
it('is merged with config if config does not have scenarios', () => {
generateConfigFile('module.exports = { bowerOptions: ["--allow-root=true"] };');
return getConfig({ project }).then((config) => {
expect(config).to.eql({
bowerOptions: ['--allow-root=true'],
scenarios: [
{
name: 'default',
bower: { dependencies: {} },
npm: { devDependencies: { bower: '^1.8.2' } },
},
{
name: 'ember-beta',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#beta' }, resolutions: { ember: 'beta' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-canary',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#canary' }, resolutions: { ember: 'canary' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-2.2.0',
bower: { dependencies: { ember: '2.2.0' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
],
});
expect(config.bowerOptions).to.eql(['--allow-root=true']);
expect(config.scenarios.length).to.equal(5);
});
});

Expand All @@ -344,23 +286,11 @@ describe('utils/config', () => {
return getConfig({ project }).then((config) => {
expect(config.useVersionCompatibility).to.equal(true);
expect(config.bowerOptions).to.eql(['--allow-root=true']);
expect(config.scenarios).to.eql([
expect(config.scenarios.length).to.equal(6);
expect(config.scenarios).to.include.deep.members([
{
name: 'default',
bower: { dependencies: {} },
npm: { devDependencies: { bower: '^1.8.2' } },
},
{
name: 'ember-beta',
allowedToFail: false,
bower: { dependencies: { ember: 'components/ember#beta' }, resolutions: { ember: 'beta' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
},
{
name: 'ember-canary',
allowedToFail: true,
bower: { dependencies: { ember: 'components/ember#canary' }, resolutions: { ember: 'canary' } },
npm: { devDependencies: { 'ember-source': null, bower: '^1.8.2' } },
npm: { devDependencies: { } },
},
{
name: 'ember-2.2.0',
Expand All @@ -369,6 +299,9 @@ describe('utils/config', () => {
},
{ name: 'bar' },
]);

let betaScenario = config.scenarios.find((s) => { return s.name === 'ember-beta'; });
expect(betaScenario.allowedToFail).to.equal(false);
});
});
});
Expand Down
Loading

0 comments on commit 6836181

Please sign in to comment.