Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ yarn-error.log
# ember-try
.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
/package.json.ember-try
6 changes: 5 additions & 1 deletion packages/ember-cli-code-coverage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ module.exports = {
*/
_getIncludesForInRepoAddonDirectories() {
return this._findInRepoAddons().reduce((acc, addon) => {
let addonDir = path.join(this.project.root, 'lib', addon.name);
let addonDir =
typeof addon.root === 'string'
? addon.root
: path.join(this.project.root, 'lib', addon.name);

let addonAppDir = path.join(addonDir, 'app');
let addonAddonDir = path.join(addonDir, 'addon');
const addonAddonTestSupportDir = path.join(addonDir, 'addon-test-support');
Expand Down
75 changes: 75 additions & 0 deletions test-packages/custom-path-in-repo-addon-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

const fs = require('fs-extra');
const util = require('util');
const rimraf = util.promisify(require('rimraf'));
const chai = require('chai');
const expect = chai.expect;
const chaiFiles = require('chai-files');
const dir = chaiFiles.dir;
const file = chaiFiles.file;
const path = require('path');
const execa = require('execa');

chai.use(chaiFiles);

const BASE_PATH = path.join(__dirname, 'my-app-with-custom-path-in-repo-addon');

describe('alternate in-repo addon coverage generation', function () {
this.timeout(10000000);

beforeEach(async function () {
await rimraf(`${BASE_PATH}/coverage*`);
await execa('git', ['clean', '-f', 'my-app-with-custom-path-in-repo-addon'], { cwd: __dirname });
await execa('git', ['restore', 'my-app-with-custom-path-in-repo-addon'], { cwd: __dirname });
});

afterEach(async function () {
await rimraf(`${BASE_PATH}/coverage*`);
await execa('git', ['clean', '-f', 'my-app-with-custom-path-in-repo-addon'], { cwd: __dirname });
await execa('git', ['restore', 'my-app-with-custom-path-in-repo-addon'], { cwd: __dirname });
});

it('runs coverage on in-repo addons from a non-standard directory structure', async function () {
expect(dir(`${BASE_PATH}/coverage`)).to.not.exist;

let env = { COVERAGE: 'true' };
await execa('ember', ['test'], { cwd: BASE_PATH, env });
expect(file(`${BASE_PATH}/coverage/lcov-report/index.html`)).to.not.be.empty;
expect(file(`${BASE_PATH}/coverage/index.html`)).to.not.be.empty;

const summary = fs.readJSONSync(`${BASE_PATH}/coverage/coverage-summary.json`);
expect(summary.total.lines.pct).to.equal(46.67);
expect(summary['app/utils/my-covered-util-app.js'].lines.total).to.equal(1);

// Check that local-lib/addons/my-in-repo-addon/utils/my-covered-utill
// is 1 line and that 1 line is covered
expect(
summary['local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js'].lines.total
).to.equal(1);
expect(
summary['local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js'].lines.covered
).to.equal(1);

// Check that local-lib/addons/my-in-repo-addon/utils/my-uncovered-utill
// is 1 line and that 0 lines are covered
expect(
summary['local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js'].lines.total
).to.equal(1);
expect(
summary['local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js'].lines.covered
).to.equal(0);

// Check that local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support
// is 4 lines and that 0 lines are covered
expect(
summary['local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js']
.lines.total
).to.equal(4);

expect(
summary['local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js']
.lines.covered
).to.equal(0);
});
});
47 changes: 47 additions & 0 deletions test-packages/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,53 @@ describe('index.js', function () {
});
});
});

describe('for an app with an inrepo addon under a custom path', function () {
let root = path.join(__dirname, 'my-app-with-custom-path-in-repo-addon');
let addon = { name: 'my-in-repo-addon', root: root + '/local-lib/addons/my-in-repo-addon' };

beforeEach(function () {
sandbox.stub(path, 'basename').returns('my-in-repo-addon');
sandbox.stub(Index, 'project').value({
pkg: {
'ember-addon': {
paths: [''],
},
},
root: root,
findAddonByName() {
return addon;
},
});
});

afterEach(function () {
addon = null;
});

it('instruments the inrepo addon', function () {
const includes = Index._getIncludesForInRepoAddonDirectories();
expect(includes).to.deep.equal([
'my-app/utils/my-covered-util.js',
'my-app/utils/my-uncovered-util.js',
'my-in-repo-addon/utils/my-covered-util.js',
'my-in-repo-addon/utils/my-uncovered-util.js',
'my-in-repo-addon/test-support/uncovered-test-support.js',
]);
expect(Index.fileLookup).to.deep.equal({
'my-app/utils/my-covered-util.js':
'local-lib/addons/my-in-repo-addon/app/utils/my-covered-util.js',
'my-app/utils/my-uncovered-util.js':
'local-lib/addons/my-in-repo-addon/app/utils/my-uncovered-util.js',
'my-in-repo-addon/utils/my-covered-util.js':
'local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js',
'my-in-repo-addon/utils/my-uncovered-util.js':
'local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js',
'my-in-repo-addon/test-support/uncovered-test-support.js':
'local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js',
});
});
});
});
});
});
19 changes: 19 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
20 changes: 20 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
56 changes: 56 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
'ember/no-jquery': 'error'
},
overrides: [
// node files
{
files: [
'.eslintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'lib/*/index.js',
'server/**/*.js'
],
parserOptions: {
sourceType: 'script'
},
env: {
browser: false,
node: true
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here

// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off'
})
}
]
};
25 changes: 25 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/.env*
/.pnp*
/.sass-cache
/connect.lock
/coverage/
/libpeerconnection.log
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
extends: 'octane'
};
27 changes: 27 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
language: node_js
node_js:
- "10"

dist: trusty

addons:
chrome: stable

cache:
directories:
- $HOME/.npm

env:
global:
# See https://git.io/vdao3 for details.
- JOBS=1

branches:
only:
- master

script:
- npm run lint:hbs
- npm run lint:js
- npm test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
57 changes: 57 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# my-app-with-custom-path-in-repo-addon

This README outlines the details of collaborating on this Ember application.
A short introduction of this app could easily go here.

## Prerequisites

You will need the following things properly installed on your computer.

* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org/) (with npm)
* [Ember CLI](https://ember-cli.com/)
* [Google Chrome](https://google.com/chrome/)

## Installation

* `git clone <repository-url>` this repository
* `cd my-app-with-custom-path-in-repo-addon`
* `npm install`

## Running / Development

* `ember serve`
* Visit your app at [http://localhost:4200](http://localhost:4200).
* Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).

### Code Generators

Make use of the many generators for code, try `ember help generate` for more details

### Running Tests

* `ember test`
* `ember test --server`

### Linting

* `npm run lint:hbs`
* `npm run lint:js`
* `npm run lint:js -- --fix`

### Building

* `ember build` (development)
* `ember build --environment production` (production)

### Deploying

Specify what it takes to deploy your app.

## Further Reading / Useful Links

* [ember.js](https://emberjs.com/)
* [ember-cli](https://ember-cli.com/)
* Development Browser Extensions
* [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
* [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
12 changes: 12 additions & 0 deletions test-packages/my-app-with-custom-path-in-repo-addon/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);
Loading