Skip to content

Commit

Permalink
Support Detection of Ember/Glimmer apps as dependencies (#524)
Browse files Browse the repository at this point in the history
Support Detection of Ember/Glimmer apps as dependencies

This change allows ember-cli/glimmer to be specified as either a dependency
or devDependency of the project being updated. Currently, `ember-cli-update`
throws an error in some instances, since it is only checking devDependencies.
  • Loading branch information
elwayman02 authored and Kelly Selden committed Mar 11, 2019
1 parent 6cccf77 commit ac1026e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
19 changes: 10 additions & 9 deletions src/get-project-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module.exports = function getProjectOptions({
keywords,
dependencies,
devDependencies
}) {
let isAddon = keywords && keywords.indexOf('ember-addon') !== -1;
Expand All @@ -10,18 +11,18 @@ module.exports = function getProjectOptions({
return ['addon'];
}

if (devDependencies) {
let isGlimmer = devDependencies['@glimmer/blueprint'];
let allDeps = Object.assign({}, dependencies, devDependencies);

if (isGlimmer) {
return ['glimmer'];
}
let isGlimmer = allDeps['@glimmer/blueprint'];

let isApp = devDependencies['ember-cli'];
if (isGlimmer) {
return ['glimmer'];
}

let isApp = allDeps['ember-cli'];

if (isApp) {
return ['app'];
}
if (isApp) {
return ['app'];
}

throw 'Ember CLI project type could not be determined';
Expand Down
39 changes: 36 additions & 3 deletions test/unit/get-project-options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe(getProjectOptions, function() {
}).to.throw('Ember CLI project type could not be determined');
});

it('detects ember app', function() {
it('detects ember app with ember-cli as a devDependency', function() {
let packageJson = {
devDependencies: {
'ember-cli': '2.11'
Expand All @@ -23,7 +23,17 @@ describe(getProjectOptions, function() {
expect(getProjectOptions(packageJson)).to.deep.equal(['app']);
});

it('detects ember addon', function() {
it('detects ember app with ember-cli as a dependency', function() {
let packageJson = {
dependencies: {
'ember-cli': '2.11'
}
};

expect(getProjectOptions(packageJson)).to.deep.equal(['app']);
});

it('detects ember addon with ember-cli as a devDependency', function() {
let packageJson = {
keywords: [
'ember-addon'
Expand All @@ -36,7 +46,20 @@ describe(getProjectOptions, function() {
expect(getProjectOptions(packageJson)).to.deep.equal(['addon']);
});

it('detects glimmer app', function() {
it('detects ember addon with ember-cli as a dependency', function() {
let packageJson = {
keywords: [
'ember-addon'
],
dependencies: {
'ember-cli': '2.11'
}
};

expect(getProjectOptions(packageJson)).to.deep.equal(['addon']);
});

it('detects glimmer app with glimmer as a devDependency', function() {
let packageJson = {
devDependencies: {
'@glimmer/blueprint': '0.3'
Expand All @@ -45,4 +68,14 @@ describe(getProjectOptions, function() {

expect(getProjectOptions(packageJson)).to.deep.equal(['glimmer']);
});

it('detects glimmer app with glimmer as a dependency', function() {
let packageJson = {
dependencies: {
'@glimmer/blueprint': '0.3'
}
};

expect(getProjectOptions(packageJson)).to.deep.equal(['glimmer']);
});
});

0 comments on commit ac1026e

Please sign in to comment.