From 2fcbd8aaee683815860688faffaa6a397ee594e0 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Wed, 16 Oct 2019 15:08:11 +0100 Subject: [PATCH 01/15] TypeScript support attempt 1 --- .gitignore | 1 + index.js | 4 +++- package.json | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 29c9bc65..6ea2daa8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /node_modules/ # misc +/.idea /.sass-cache /connect.lock /coverage/ diff --git a/index.js b/index.js index 6d84d182..e83c25c2 100644 --- a/index.js +++ b/index.js @@ -196,12 +196,14 @@ module.exports = { * @returns {Array} include paths */ _getIncludesForDir: function(dir, prefix) { + const hasEmberCliTypescript = this.project.findAddonByName('ember-cli-typescript'); + if (fs.existsSync(dir)) { let dirname = path.relative(this.project.root, dir); let globs = this.parentRegistry.extensionsForType('js').map((extension) => `**/*.${extension}`); return walkSync(dir, { directories: false, globs }).map(file => { - let module = prefix + '/' + file.replace(EXT_RE, '.js'); + let module = prefix + '/' + hasEmberCliTypescript ? file : file.replace(EXT_RE, '.js'); this.fileLookup[module] = path.join(dirname, file); return module; }); diff --git a/package.json b/package.json index ee1f62c2..05310d05 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,8 @@ "node": "6.* || 8.* || >= 10.*" }, "ember-addon": { - "configPath": "tests/dummy/config" + "configPath": "tests/dummy/config", + "before": "ember-cli-typescript" }, "changelog": { "repo": "kategengler/ember-cli-code-coverage", From fe27b61f754b575f1cd15691b747c66b43dae964 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Wed, 16 Oct 2019 15:24:27 +0100 Subject: [PATCH 02/15] Fixed interesting concat problem. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index e83c25c2..fa16e243 100644 --- a/index.js +++ b/index.js @@ -203,7 +203,7 @@ module.exports = { let globs = this.parentRegistry.extensionsForType('js').map((extension) => `**/*.${extension}`); return walkSync(dir, { directories: false, globs }).map(file => { - let module = prefix + '/' + hasEmberCliTypescript ? file : file.replace(EXT_RE, '.js'); + let module = prefix + '/' + (hasEmberCliTypescript ? file : file.replace(EXT_RE, '.js')); this.fileLookup[module] = path.join(dirname, file); return module; }); From 7c503ebc5668640b3c91df934075d3b36fc9dfda Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Wed, 16 Oct 2019 15:08:11 +0100 Subject: [PATCH 03/15] TypeScript support attempt 1 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c40a1b2a..601470d8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # misc /.env* /.pnp* +/.idea /.sass-cache /connect.lock /coverage/ From 47c6a002ee669a37f1c57431373e8fd816146ed4 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Sun, 20 Sep 2020 12:27:19 +0100 Subject: [PATCH 04/15] Using in-repo addon's "root" property. --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 80dac0f8..f7521e76 100644 --- a/index.js +++ b/index.js @@ -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'); From b05f9d6782016d11007b98f1959e87a4e1a5f631 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Sun, 20 Sep 2020 13:40:55 +0100 Subject: [PATCH 05/15] Unit test --- .../.eslintrc.js | 43 +++++++++++++++++ .../app/utils/my-covered-util-app.js | 3 ++ .../app/utils/my-uncovered-util-app.js | 3 ++ .../config/coverage.js | 3 ++ .../uncovered-test-support.js | 14 ++++++ .../addon/utils/my-covered-util.js | 3 ++ .../addon/utils/my-uncovered-util.js | 3 ++ .../app/utils/my-covered-util.js | 1 + .../app/utils/my-uncovered-util.js | 2 + .../testem.js | 24 ++++++++++ .../tests/unit/.gitkeep | 0 .../unit/utils/covered-util-in-addon-test.js | 10 ++++ .../tests/unit/utils/my-covered-util-test.js | 10 ++++ test/unit/index-test.js | 48 +++++++++++++++++++ 14 files changed, 167 insertions(+) create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/.eslintrc.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-covered-util-app.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-uncovered-util-app.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/config/coverage.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-covered-util.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-uncovered-util.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/testem.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/.gitkeep create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/covered-util-in-addon-test.js create mode 100644 test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/.eslintrc.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/.eslintrc.js new file mode 100644 index 00000000..a1189c82 --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/.eslintrc.js @@ -0,0 +1,43 @@ +// eslint-disable-next-line no-undef +module.exports = { + root: true, + parserOptions: { + ecmaVersion: 2017, + sourceType: 'module' + }, + extends: [ + 'eslint:recommended' + ], + env: { + browser: true + }, + rules: { + }, + overrides: [ + // node files + { + files: [ + 'index.js', + 'testem.js', + 'ember-cli-build.js', + 'config/**/*.js', + 'test/**', + 'tests/dummy/config/**/*.js' + ], + excludedFiles: [ + 'app/**', + 'addon/**', + 'test/fixtures/**', + 'tests/dummy/app/**' + ], + parserOptions: { + sourceType: 'script', + ecmaVersion: 2015 + }, + env: { + browser: false, + node: true + } + } + ] +}; diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-covered-util-app.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-covered-util-app.js new file mode 100644 index 00000000..50867b0d --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-covered-util-app.js @@ -0,0 +1,3 @@ +export default function myCoveredUtil() { + return true; +} diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-uncovered-util-app.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-uncovered-util-app.js new file mode 100644 index 00000000..8f531cba --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/app/utils/my-uncovered-util-app.js @@ -0,0 +1,3 @@ +export default function myUncoveredUtil() { + return true; +} diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/config/coverage.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/config/coverage.js new file mode 100644 index 00000000..e3724c51 --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/config/coverage.js @@ -0,0 +1,3 @@ +module.exports = { + reporters: ['lcov', 'html', 'text', 'json-summary'] +}; diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js new file mode 100644 index 00000000..21a3f3f7 --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js @@ -0,0 +1,14 @@ +/** + * Just a test function to show that addon-test-support coverage is counted + */ +export function uncoveredFunction(condition) { + if (condition) { + return 'Was true'; + } else { + return 'Was false'; + } +} + +export function anotherUncoveredFunction() { + return 'Not covered'; +} diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js new file mode 100644 index 00000000..50867b0d --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-covered-util.js @@ -0,0 +1,3 @@ +export default function myCoveredUtil() { + return true; +} diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js new file mode 100644 index 00000000..8f531cba --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/addon/utils/my-uncovered-util.js @@ -0,0 +1,3 @@ +export default function myUncoveredUtil() { + return true; +} diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-covered-util.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-covered-util.js new file mode 100644 index 00000000..ea557609 --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-covered-util.js @@ -0,0 +1 @@ +export { default } from 'my-in-repo-addon/utils/my-covered-util'; diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-uncovered-util.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-uncovered-util.js new file mode 100644 index 00000000..64e6c01e --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/app/utils/my-uncovered-util.js @@ -0,0 +1,2 @@ +export { default } from 'my-in-repo-addon/utils/my-uncovered-util'; + diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/testem.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/testem.js new file mode 100644 index 00000000..d1755a4e --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/testem.js @@ -0,0 +1,24 @@ +module.exports = { + test_page: 'tests/index.html?hidepassed', + disable_watching: true, + launch_in_ci: [ + 'Chrome' + ], + launch_in_dev: [ + 'Chrome' + ], + browser_args: { + Chrome: { + mode: 'ci', + args: [ + // --no-sandbox is needed when running Chrome inside a container + process.env.TRAVIS ? '--no-sandbox' : null, + + '--disable-gpu', + '--headless', + '--remote-debugging-port=0', + '--window-size=1440,900' + ].filter(Boolean) + } + } +}; diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/.gitkeep b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/covered-util-in-addon-test.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/covered-util-in-addon-test.js new file mode 100644 index 00000000..7b55fd54 --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/covered-util-in-addon-test.js @@ -0,0 +1,10 @@ +import myCoveredUtil from 'my-in-repo-addon/utils/my-covered-util'; +import { module, test } from 'qunit'; + +module('Unit | Utility | my covered util'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = myCoveredUtil(); + assert.ok(result); +}); diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js new file mode 100644 index 00000000..abc2e84d --- /dev/null +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js @@ -0,0 +1,10 @@ +import myCoveredUtil from 'my-app-with-in-repo-addon/utils/my-covered-util-app'; +import { module, test } from 'qunit'; + +module('Unit | Utility | my covered util app'); + +// Replace this with your real tests. +test('it works', function(assert) { + let result = myCoveredUtil(); + assert.ok(result); +}); diff --git a/test/unit/index-test.js b/test/unit/index-test.js index d12792f1..6837df53 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -484,6 +484,54 @@ describe('index.js', function () { }); }); }); + + + describe('for an app with an inrepo addon under a custom path', function () { + let root = 'test/fixtures/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', + }); + }); + }); }); }); }); From 864d8a0671507924df24f2c71054b635531f0887 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Sun, 20 Sep 2020 15:13:45 +0100 Subject: [PATCH 06/15] Integration test --- .../tests/unit/utils/my-covered-util-test.js | 2 +- test/helpers/custom-dir-in-repo-addon.js | 74 +++++++++++++ ...custom-path-in-repo-addon-coverage-test.js | 101 ++++++++++++++++++ 3 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 test/helpers/custom-dir-in-repo-addon.js create mode 100644 test/integration/custom-path-in-repo-addon-coverage-test.js diff --git a/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js index abc2e84d..c928ac95 100644 --- a/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js +++ b/test/fixtures/my-app-with-custom-path-in-repo-addon/tests/unit/utils/my-covered-util-test.js @@ -1,4 +1,4 @@ -import myCoveredUtil from 'my-app-with-in-repo-addon/utils/my-covered-util-app'; +import myCoveredUtil from 'my-app-with-custom-path-in-repo-addon/utils/my-covered-util-app'; import { module, test } from 'qunit'; module('Unit | Utility | my covered util app'); diff --git a/test/helpers/custom-dir-in-repo-addon.js b/test/helpers/custom-dir-in-repo-addon.js new file mode 100644 index 00000000..cb511ca6 --- /dev/null +++ b/test/helpers/custom-dir-in-repo-addon.js @@ -0,0 +1,74 @@ +'use strict'; + +const path = require('path'); +const fs = require('fs-extra'); +const fixturify = require('fixturify'); + +class InRepoAddon { + static async generate(app, name) { + let args = ['generate', 'in-repo-addon', name]; + await app.runEmberCommand.apply(app, args); + + let addon = new InRepoAddon(app, name); + + // Move generated addon stubs from /lib to /local-lib + await fs.move(path.join(app.path, 'lib', name, 'package.json'), path.join(addon.path, 'package.json')); + await fs.move(path.join(app.path, 'lib', name, 'index.js'), path.join(addon.path, 'index.js')); + + app.editPackageJSON(pkg => { + pkg['ember-addon'].paths = [path.join('local-lib', 'addons', addon.name)]; + }); + + addon.editPackageJSON(pkg => (pkg.dependencies = { 'ember-cli-htmlbars': '*' })); + + return addon; + } + + constructor(app, name) { + this.name = name; + this.app = app; + this.path = path.join(app.path, 'local-lib', 'addons', name); + } + + editPackageJSON(editor) { + let packageJSONPath = path.join(this.path, 'package.json'); + let pkg = fs.readJsonSync(packageJSONPath); + editor(pkg); + fs.writeJsonSync(packageJSONPath, pkg); + } + + writeFixture(fixture) { + fixturify.writeSync(this.path, fixture); + } + + nest(addon) { + this.editPackageJSON(pkg => { + pkg['ember-addon'] = pkg['ember-addon'] || {}; + pkg['ember-addon'].paths = pkg['ember-addon'].paths || []; + pkg['ember-addon'].paths.push(`../${addon.name}`); + }); + } + + async generateNestedAddon(name) { + // Generate another in-repo-addon at the app level... + let args = Array.prototype.slice.call(arguments); + args.unshift(this.app); + let addon = await InRepoAddon.generate.apply(null, args); + + // Remove the in-repo-addon from the app... + this.app.editPackageJSON(pkg => { + pkg['ember-addon'].paths = pkg['ember-addon'].paths.filter(path => path !== `lib/${name}`); + }); + + // Add the in-repo-addon to this engine. + this.editPackageJSON(pkg => { + pkg['ember-addon'] = pkg['ember-addon'] || {}; + pkg['ember-addon'].paths = pkg['ember-addon'].paths || []; + pkg['ember-addon'].paths.push(`../${name}`); + }); + + return addon; + } +} + +module.exports = InRepoAddon; diff --git a/test/integration/custom-path-in-repo-addon-coverage-test.js b/test/integration/custom-path-in-repo-addon-coverage-test.js new file mode 100644 index 00000000..28d861a8 --- /dev/null +++ b/test/integration/custom-path-in-repo-addon-coverage-test.js @@ -0,0 +1,101 @@ +'use strict'; + +var fs = require('fs-extra'); +const util = require('util'); +const rimraf = util.promisify(require('rimraf')); +var chai = require('chai'); +var expect = chai.expect; +var chaiFiles = require('chai-files'); +var dir = chaiFiles.dir; +var file = chaiFiles.file; +var path = require('path'); + +const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; +const CustomPathInRepoAddon = require('../helpers/custom-dir-in-repo-addon'); + +chai.use(chaiFiles); + +describe('in-repo addon coverage generation', function () { + let app; + + this.timeout(10000000); + + beforeEach(async function () { + app = new AddonTestApp(); + await app.create('my-app-with-custom-path-in-repo-addon', { + emberVersion: '3.4.0', + skipNpm: true, + }); + + app.editPackageJSON(pkg => { + delete pkg.devDependencies['ember-cli-eslint']; + + pkg.devDependencies['ember-exam'] = '1.0.0'; + // Temporarily remove the addon before install to work around https://github.com/tomdale/ember-cli-addon-tests/issues/176 + delete pkg.devDependencies['ember-cli-code-coverage']; + }); + + await app.run('npm', 'install'); + + app.editPackageJSON(pkg => { + pkg.devDependencies['ember-cli-code-coverage'] = '*'; + }); + + let addonPath = path.join(app.path, 'node_modules', 'ember-cli-code-coverage'); + fs.removeSync(addonPath); + fs.ensureSymlinkSync(process.cwd(), addonPath); + + await rimraf(`${app.path}/coverage*`); + + debugger; + }); + + afterEach(async function () { + await rimraf(`${app.path}/config/coverage.js`); + }); + + + it('runs coverage on in-repo addons from a non-standard directory structure', async function () { + let addon = await CustomPathInRepoAddon.generate(app, 'my-in-repo-addon'); + + addon.editPackageJSON(pkg => (pkg.dependencies = { 'ember-cli-babel': '*' })); + expect(dir(`${app.path}/coverage`)).to.not.exist; + process.env.COVERAGE = 'true'; + + await app.run('ember', 'test'); + + expect(file(`${app.path}/coverage/lcov-report/index.html`)).to.not.be.empty; + expect(file(`${app.path}/coverage/index.html`)).to.not.be.empty; + + const summary = fs.readJSONSync(`${app.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); + }); +}); From 1004cf1600b60ccfc8243881de21ba8162dca082 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 10:17:24 +0100 Subject: [PATCH 07/15] Linting --- test/helpers/custom-dir-in-repo-addon.js | 6 +++- ...custom-path-in-repo-addon-coverage-test.js | 34 +++++++++---------- test/unit/index-test.js | 1 - 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/test/helpers/custom-dir-in-repo-addon.js b/test/helpers/custom-dir-in-repo-addon.js index cb511ca6..dff2b464 100644 --- a/test/helpers/custom-dir-in-repo-addon.js +++ b/test/helpers/custom-dir-in-repo-addon.js @@ -12,7 +12,11 @@ class InRepoAddon { let addon = new InRepoAddon(app, name); // Move generated addon stubs from /lib to /local-lib - await fs.move(path.join(app.path, 'lib', name, 'package.json'), path.join(addon.path, 'package.json')); + await fs.move( + path.join(app.path, 'lib', name, 'package.json'), + path.join(addon.path, 'package.json') + ); + await fs.move(path.join(app.path, 'lib', name, 'index.js'), path.join(addon.path, 'index.js')); app.editPackageJSON(pkg => { diff --git a/test/integration/custom-path-in-repo-addon-coverage-test.js b/test/integration/custom-path-in-repo-addon-coverage-test.js index 28d861a8..3b2d1f72 100644 --- a/test/integration/custom-path-in-repo-addon-coverage-test.js +++ b/test/integration/custom-path-in-repo-addon-coverage-test.js @@ -46,15 +46,12 @@ describe('in-repo addon coverage generation', function () { fs.ensureSymlinkSync(process.cwd(), addonPath); await rimraf(`${app.path}/coverage*`); - - debugger; }); afterEach(async function () { await rimraf(`${app.path}/config/coverage.js`); }); - it('runs coverage on in-repo addons from a non-standard directory structure', async function () { let addon = await CustomPathInRepoAddon.generate(app, 'my-in-repo-addon'); @@ -73,29 +70,32 @@ describe('in-repo addon coverage generation', function () { // 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 - ); + 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 - ); + 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 + 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 + summary['local-lib/addons/my-in-repo-addon/addon-test-support/uncovered-test-support.js'] + .lines.covered ).to.equal(0); }); }); diff --git a/test/unit/index-test.js b/test/unit/index-test.js index 6837df53..b7b29aaf 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -485,7 +485,6 @@ describe('index.js', function () { }); }); - describe('for an app with an inrepo addon under a custom path', function () { let root = 'test/fixtures/my-app-with-custom-path-in-repo-addon/'; let addon = { name: 'my-in-repo-addon', root: root + 'local-lib/addons/my-in-repo-addon' }; From a2e07681ba98352ed485763c842ebda2506eabc9 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 10:42:25 +0100 Subject: [PATCH 08/15] Putting back some ignores --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6ea2daa8..601470d8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ /node_modules/ # misc +/.env* +/.pnp* /.idea /.sass-cache /connect.lock From 4f9cd45a8a52d3b9a9372fba52b5e1934342bcde Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 18:38:14 +0100 Subject: [PATCH 09/15] Make a proper app to test against. --- .../.editorconfig | 19 ++++++ .../.ember-cli | 9 +++ .../.eslintignore | 20 ++++++ .../.gitignore | 25 ++++++++ .../.template-lintrc.js | 5 ++ .../.travis.yml | 27 ++++++++ .../.watchmanconfig | 3 + .../README.md | 57 +++++++++++++++++ .../app/app.js | 12 ++++ .../app/index.html | 25 ++++++++ .../app/router.js | 10 +++ .../app/styles/app.css | 0 .../app/templates/application.hbs | 5 ++ .../config/environment.js | 51 +++++++++++++++ .../config/optional-features.json | 6 ++ .../config/targets.js | 18 ++++++ .../ember-cli-build.js | 24 +++++++ .../addons/my-in-repo-addon/index.js | 9 +++ .../addons/my-in-repo-addon/package.json | 9 +++ .../package.json | 63 +++++++++++++++++++ 20 files changed, 397 insertions(+) create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.editorconfig create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.ember-cli create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.eslintignore create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.gitignore create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.template-lintrc.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.travis.yml create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/.watchmanconfig create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/README.md create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/app/app.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/app/index.html create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/app/router.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/app/styles/app.css create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/app/templates/application.hbs create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/config/optional-features.json create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/config/targets.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/ember-cli-build.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/index.js create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/package.json create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/package.json diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.editorconfig b/test-packages/my-app-with-custom-path-in-repo-addon/.editorconfig new file mode 100644 index 00000000..c35a0024 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.editorconfig @@ -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 diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.ember-cli b/test-packages/my-app-with-custom-path-in-repo-addon/.ember-cli new file mode 100644 index 00000000..ee64cfed --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.ember-cli @@ -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 +} diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.eslintignore b/test-packages/my-app-with-custom-path-in-repo-addon/.eslintignore new file mode 100644 index 00000000..72df3730 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.eslintignore @@ -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 diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.gitignore b/test-packages/my-app-with-custom-path-in-repo-addon/.gitignore new file mode 100644 index 00000000..c40a1b2a --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.gitignore @@ -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 diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.template-lintrc.js b/test-packages/my-app-with-custom-path-in-repo-addon/.template-lintrc.js new file mode 100644 index 00000000..f3873700 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.template-lintrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + extends: 'octane' +}; diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.travis.yml b/test-packages/my-app-with-custom-path-in-repo-addon/.travis.yml new file mode 100644 index 00000000..a0208ca3 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.travis.yml @@ -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 diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.watchmanconfig b/test-packages/my-app-with-custom-path-in-repo-addon/.watchmanconfig new file mode 100644 index 00000000..e7834e3e --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.watchmanconfig @@ -0,0 +1,3 @@ +{ + "ignore_dirs": ["tmp", "dist"] +} diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/README.md b/test-packages/my-app-with-custom-path-in-repo-addon/README.md new file mode 100644 index 00000000..e7c43634 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/README.md @@ -0,0 +1,57 @@ +# my-app-with-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 ` this repository +* `cd my-app-with-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/) diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/app/app.js b/test-packages/my-app-with-custom-path-in-repo-addon/app/app.js new file mode 100644 index 00000000..d8e2088b --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/app/app.js @@ -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); diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html b/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html new file mode 100644 index 00000000..89dfd0ec --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html @@ -0,0 +1,25 @@ + + + + + + MyAppWithInRepoAddon + + + + {{content-for "head"}} + + + + + {{content-for "head-footer"}} + + + {{content-for "body"}} + + + + + {{content-for "body-footer"}} + + diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/app/router.js b/test-packages/my-app-with-custom-path-in-repo-addon/app/router.js new file mode 100644 index 00000000..224ca426 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/app/router.js @@ -0,0 +1,10 @@ +import EmberRouter from '@ember/routing/router'; +import config from './config/environment'; + +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} + +Router.map(function() { +}); diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/app/styles/app.css b/test-packages/my-app-with-custom-path-in-repo-addon/app/styles/app.css new file mode 100644 index 00000000..e69de29b diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/app/templates/application.hbs b/test-packages/my-app-with-custom-path-in-repo-addon/app/templates/application.hbs new file mode 100644 index 00000000..7b1b1040 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/app/templates/application.hbs @@ -0,0 +1,5 @@ +{{!-- The following component displays Ember's default welcome message. --}} + +{{!-- Feel free to remove this! --}} + +{{outlet}} \ No newline at end of file diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js b/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js new file mode 100644 index 00000000..93c221af --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js @@ -0,0 +1,51 @@ +'use strict'; + +module.exports = function(environment) { + let ENV = { + modulePrefix: 'my-app-with-in-repo-addon', + environment, + rootURL: '/', + locationType: 'auto', + EmberENV: { + FEATURES: { + // Here you can enable experimental features on an ember canary build + // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true + }, + EXTEND_PROTOTYPES: { + // Prevent Ember Data from overriding Date.parse. + Date: false + } + }, + + APP: { + // Here you can pass flags/options to your application instance + // when it is created + } + }; + + if (environment === 'development') { + // ENV.APP.LOG_RESOLVER = true; + // ENV.APP.LOG_ACTIVE_GENERATION = true; + // ENV.APP.LOG_TRANSITIONS = true; + // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; + // ENV.APP.LOG_VIEW_LOOKUPS = true; + } + + if (environment === 'test') { + // Testem prefers this... + ENV.locationType = 'none'; + + // keep test console output quieter + ENV.APP.LOG_ACTIVE_GENERATION = false; + ENV.APP.LOG_VIEW_LOOKUPS = false; + + ENV.APP.rootElement = '#ember-testing'; + ENV.APP.autoboot = false; + } + + if (environment === 'production') { + // here you can enable a production-specific feature + } + + return ENV; +}; diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/config/optional-features.json b/test-packages/my-app-with-custom-path-in-repo-addon/config/optional-features.json new file mode 100644 index 00000000..b26286e2 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/config/optional-features.json @@ -0,0 +1,6 @@ +{ + "application-template-wrapper": false, + "default-async-observers": true, + "jquery-integration": false, + "template-only-glimmer-components": true +} diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/config/targets.js b/test-packages/my-app-with-custom-path-in-repo-addon/config/targets.js new file mode 100644 index 00000000..8ffae363 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/config/targets.js @@ -0,0 +1,18 @@ +'use strict'; + +const browsers = [ + 'last 1 Chrome versions', + 'last 1 Firefox versions', + 'last 1 Safari versions' +]; + +const isCI = !!process.env.CI; +const isProduction = process.env.EMBER_ENV === 'production'; + +if (isCI || isProduction) { + browsers.push('ie 11'); +} + +module.exports = { + browsers +}; diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/ember-cli-build.js b/test-packages/my-app-with-custom-path-in-repo-addon/ember-cli-build.js new file mode 100644 index 00000000..d690a253 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/ember-cli-build.js @@ -0,0 +1,24 @@ +'use strict'; + +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); + +module.exports = function(defaults) { + let app = new EmberApp(defaults, { + // Add options here + }); + + // Use `app.import` to add additional libraries to the generated + // output files. + // + // If you need to use different assets in different + // environments, specify an object as the first parameter. That + // object's keys should be the environment name and the values + // should be the asset to use in that environment. + // + // If the library that you are including contains AMD or ES6 + // modules that you would like to import into your application + // please specify an object with the list of modules as keys + // along with the exports of each module as its value. + + return app.toTree(); +}; diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/index.js b/test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/index.js new file mode 100644 index 00000000..57cf2c24 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/index.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = { + name: require('./package').name, + + isDevelopingAddon() { + return true; + } +}; diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/package.json b/test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/package.json new file mode 100644 index 00000000..ae154ffb --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/local-lib/addons/my-in-repo-addon/package.json @@ -0,0 +1,9 @@ +{ + "name": "my-in-repo-addon", + "keywords": [ + "ember-addon" + ], + "dependencies": { + "ember-cli-babel": "*" + } +} diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/package.json b/test-packages/my-app-with-custom-path-in-repo-addon/package.json new file mode 100644 index 00000000..e0926e75 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/package.json @@ -0,0 +1,63 @@ +{ + "name": "my-app-with-in-repo-addon", + "version": "0.0.0", + "private": true, + "description": "Small description for my-app-with-in-repo-addon goes here", + "repository": "", + "license": "MIT", + "author": "", + "directories": { + "doc": "doc", + "test": "tests" + }, + "scripts": { + "build": "ember build --environment=production", + "lint:hbs": "ember-template-lint .", + "lint:js": "eslint .", + "start": "ember serve", + "test": "ember test" + }, + "devDependencies": { + "@ember/optional-features": "^1.3.0", + "@glimmer/component": "^1.0.0", + "@glimmer/tracking": "^1.0.0", + "babel-eslint": "^10.0.3", + "broccoli-asset-rev": "^3.0.0", + "ember-auto-import": "^1.5.3", + "ember-cli": "~3.16.2", + "ember-cli-app-version": "^3.2.0", + "ember-cli-babel": "^7.17.2", + "ember-cli-code-coverage": "*", + "ember-cli-dependency-checker": "^3.2.0", + "ember-cli-eslint": "^5.1.0", + "ember-cli-htmlbars": "^4.2.2", + "ember-cli-inject-live-reload": "^2.0.2", + "ember-cli-sri": "^2.1.1", + "ember-cli-template-lint": "^1.0.0-beta.3", + "ember-cli-uglify": "^3.0.0", + "ember-data": "~3.16.0", + "ember-export-application-global": "^2.0.1", + "ember-fetch": "^7.0.0", + "ember-load-initializers": "^2.1.1", + "ember-maybe-import-regenerator": "^0.1.6", + "ember-qunit": "^4.6.0", + "ember-resolver": "^7.0.0", + "ember-source": "~3.16.0", + "ember-welcome-page": "^4.0.0", + "eslint-plugin-ember": "^7.7.2", + "eslint-plugin-node": "^11.0.0", + "loader.js": "^4.7.0", + "qunit-dom": "^1.0.0" + }, + "engines": { + "node": "10.* || >= 12" + }, + "ember": { + "edition": "octane" + }, + "ember-addon": { + "paths": [ + "lib/my-in-repo-addon" + ] + } +} From 9e9a4a0e3140bc0a6c4893a73c60c740e624ebe6 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 18:38:58 +0100 Subject: [PATCH 10/15] Correct in-repo addon path --- .../my-app-with-custom-path-in-repo-addon/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/package.json b/test-packages/my-app-with-custom-path-in-repo-addon/package.json index e0926e75..d9c9812a 100644 --- a/test-packages/my-app-with-custom-path-in-repo-addon/package.json +++ b/test-packages/my-app-with-custom-path-in-repo-addon/package.json @@ -57,7 +57,7 @@ }, "ember-addon": { "paths": [ - "lib/my-in-repo-addon" + "local-lib/addons/my-in-repo-addon" ] } } From 384a50d6f8adb26aa9ddb4daea18268e2269ac73 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 18:41:54 +0100 Subject: [PATCH 11/15] Fixup unit test --- test-packages/index-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-packages/index-test.js b/test-packages/index-test.js index a466b81b..b2828e57 100644 --- a/test-packages/index-test.js +++ b/test-packages/index-test.js @@ -486,8 +486,8 @@ describe('index.js', function () { }); describe('for an app with an inrepo addon under a custom path', function () { - let root = 'test/fixtures/my-app-with-custom-path-in-repo-addon/'; - let addon = { name: 'my-in-repo-addon', root: root + 'local-lib/addons/my-in-repo-addon' }; + 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'); From 2fa97fe3394f2c2eea31098a6a85d13788072a27 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 18:45:52 +0100 Subject: [PATCH 12/15] Hello git restore - fix naming --- test-packages/my-app-with-custom-path-in-repo-addon/README.md | 4 ++-- .../my-app-with-custom-path-in-repo-addon/app/index.html | 4 ++-- .../config/environment.js | 2 +- .../my-app-with-custom-path-in-repo-addon/package.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/README.md b/test-packages/my-app-with-custom-path-in-repo-addon/README.md index e7c43634..f0d0fa0e 100644 --- a/test-packages/my-app-with-custom-path-in-repo-addon/README.md +++ b/test-packages/my-app-with-custom-path-in-repo-addon/README.md @@ -1,4 +1,4 @@ -# my-app-with-in-repo-addon +# 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. @@ -15,7 +15,7 @@ You will need the following things properly installed on your computer. ## Installation * `git clone ` this repository -* `cd my-app-with-in-repo-addon` +* `cd my-app-with-custom-path-in-repo-addon` * `npm install` ## Running / Development diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html b/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html index 89dfd0ec..d15eb3b3 100644 --- a/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html +++ b/test-packages/my-app-with-custom-path-in-repo-addon/app/index.html @@ -10,7 +10,7 @@ {{content-for "head"}} - + {{content-for "head-footer"}} @@ -18,7 +18,7 @@ {{content-for "body"}} - + {{content-for "body-footer"}} diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js b/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js index 93c221af..590ce7dd 100644 --- a/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js +++ b/test-packages/my-app-with-custom-path-in-repo-addon/config/environment.js @@ -2,7 +2,7 @@ module.exports = function(environment) { let ENV = { - modulePrefix: 'my-app-with-in-repo-addon', + modulePrefix: 'my-app-with-custom-path-in-repo-addon', environment, rootURL: '/', locationType: 'auto', diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/package.json b/test-packages/my-app-with-custom-path-in-repo-addon/package.json index d9c9812a..0b2f7f5a 100644 --- a/test-packages/my-app-with-custom-path-in-repo-addon/package.json +++ b/test-packages/my-app-with-custom-path-in-repo-addon/package.json @@ -1,8 +1,8 @@ { - "name": "my-app-with-in-repo-addon", + "name": "my-app-with-custom-path-in-repo-addon", "version": "0.0.0", "private": true, - "description": "Small description for my-app-with-in-repo-addon goes here", + "description": "Small description for my-app-with-custom-path-in-repo-addon goes here", "repository": "", "license": "MIT", "author": "", From ef0c456a2bfaae3b690029f3397921a643105d01 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 19:04:05 +0100 Subject: [PATCH 13/15] Adding test-package test files --- .../tests/index.html | 33 +++++++++++++++++++ .../tests/test-helper.js | 8 +++++ .../tests/unit/.gitkeep | 0 3 files changed, 41 insertions(+) create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/tests/index.html create mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/tests/test-helper.js delete mode 100644 test-packages/my-app-with-custom-path-in-repo-addon/tests/unit/.gitkeep diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/tests/index.html b/test-packages/my-app-with-custom-path-in-repo-addon/tests/index.html new file mode 100644 index 00000000..421ed6f1 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/tests/index.html @@ -0,0 +1,33 @@ + + + + + + MyAppWithInRepoAddon Tests + + + + {{content-for "head"}} + {{content-for "test-head"}} + + + + + + {{content-for "head-footer"}} + {{content-for "test-head-footer"}} + + + {{content-for "body"}} + {{content-for "test-body"}} + + + + + + + + {{content-for "body-footer"}} + {{content-for "test-body-footer"}} + + diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/tests/test-helper.js b/test-packages/my-app-with-custom-path-in-repo-addon/tests/test-helper.js new file mode 100644 index 00000000..0382a848 --- /dev/null +++ b/test-packages/my-app-with-custom-path-in-repo-addon/tests/test-helper.js @@ -0,0 +1,8 @@ +import Application from '../app'; +import config from '../config/environment'; +import { setApplication } from '@ember/test-helpers'; +import { start } from 'ember-qunit'; + +setApplication(Application.create(config.APP)); + +start(); diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/tests/unit/.gitkeep b/test-packages/my-app-with-custom-path-in-repo-addon/tests/unit/.gitkeep deleted file mode 100644 index e69de29b..00000000 From 4a0f19aacc4e28e0418e45785927b69f2955b812 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 19:06:31 +0100 Subject: [PATCH 14/15] Lint fix --- .../.eslintrc.js | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/test-packages/my-app-with-custom-path-in-repo-addon/.eslintrc.js b/test-packages/my-app-with-custom-path-in-repo-addon/.eslintrc.js index a1189c82..f3c9d4f2 100644 --- a/test-packages/my-app-with-custom-path-in-repo-addon/.eslintrc.js +++ b/test-packages/my-app-with-custom-path-in-repo-addon/.eslintrc.js @@ -1,43 +1,56 @@ -// eslint-disable-next-line no-undef +'use strict'; + module.exports = { root: true, + parser: 'babel-eslint', parserOptions: { - ecmaVersion: 2017, - sourceType: 'module' + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true + } }, + plugins: [ + 'ember' + ], extends: [ - 'eslint:recommended' + 'eslint:recommended', + 'plugin:ember/recommended' ], env: { browser: true }, rules: { + 'ember/no-jquery': 'error' }, overrides: [ // node files { files: [ - 'index.js', - 'testem.js', + '.eslintrc.js', + '.template-lintrc.js', 'ember-cli-build.js', + 'testem.js', + 'blueprints/*/index.js', 'config/**/*.js', - 'test/**', - 'tests/dummy/config/**/*.js' - ], - excludedFiles: [ - 'app/**', - 'addon/**', - 'test/fixtures/**', - 'tests/dummy/app/**' + 'lib/*/index.js', + 'server/**/*.js' ], parserOptions: { - sourceType: 'script', - ecmaVersion: 2015 + 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' + }) } ] }; From b4b3e810b0dd049a59210f607ad4ea1b4472b391 Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Mon, 21 Sep 2020 19:18:46 +0100 Subject: [PATCH 15/15] Test fixup --- .../custom-path-in-repo-addon-test.js | 75 +++++++++++++ ...custom-path-in-repo-addon-coverage-test.js | 101 ------------------ 2 files changed, 75 insertions(+), 101 deletions(-) create mode 100644 test-packages/custom-path-in-repo-addon-test.js delete mode 100644 test/integration/custom-path-in-repo-addon-coverage-test.js diff --git a/test-packages/custom-path-in-repo-addon-test.js b/test-packages/custom-path-in-repo-addon-test.js new file mode 100644 index 00000000..661ba188 --- /dev/null +++ b/test-packages/custom-path-in-repo-addon-test.js @@ -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); + }); +}); diff --git a/test/integration/custom-path-in-repo-addon-coverage-test.js b/test/integration/custom-path-in-repo-addon-coverage-test.js deleted file mode 100644 index 3b2d1f72..00000000 --- a/test/integration/custom-path-in-repo-addon-coverage-test.js +++ /dev/null @@ -1,101 +0,0 @@ -'use strict'; - -var fs = require('fs-extra'); -const util = require('util'); -const rimraf = util.promisify(require('rimraf')); -var chai = require('chai'); -var expect = chai.expect; -var chaiFiles = require('chai-files'); -var dir = chaiFiles.dir; -var file = chaiFiles.file; -var path = require('path'); - -const AddonTestApp = require('ember-cli-addon-tests').AddonTestApp; -const CustomPathInRepoAddon = require('../helpers/custom-dir-in-repo-addon'); - -chai.use(chaiFiles); - -describe('in-repo addon coverage generation', function () { - let app; - - this.timeout(10000000); - - beforeEach(async function () { - app = new AddonTestApp(); - await app.create('my-app-with-custom-path-in-repo-addon', { - emberVersion: '3.4.0', - skipNpm: true, - }); - - app.editPackageJSON(pkg => { - delete pkg.devDependencies['ember-cli-eslint']; - - pkg.devDependencies['ember-exam'] = '1.0.0'; - // Temporarily remove the addon before install to work around https://github.com/tomdale/ember-cli-addon-tests/issues/176 - delete pkg.devDependencies['ember-cli-code-coverage']; - }); - - await app.run('npm', 'install'); - - app.editPackageJSON(pkg => { - pkg.devDependencies['ember-cli-code-coverage'] = '*'; - }); - - let addonPath = path.join(app.path, 'node_modules', 'ember-cli-code-coverage'); - fs.removeSync(addonPath); - fs.ensureSymlinkSync(process.cwd(), addonPath); - - await rimraf(`${app.path}/coverage*`); - }); - - afterEach(async function () { - await rimraf(`${app.path}/config/coverage.js`); - }); - - it('runs coverage on in-repo addons from a non-standard directory structure', async function () { - let addon = await CustomPathInRepoAddon.generate(app, 'my-in-repo-addon'); - - addon.editPackageJSON(pkg => (pkg.dependencies = { 'ember-cli-babel': '*' })); - expect(dir(`${app.path}/coverage`)).to.not.exist; - process.env.COVERAGE = 'true'; - - await app.run('ember', 'test'); - - expect(file(`${app.path}/coverage/lcov-report/index.html`)).to.not.be.empty; - expect(file(`${app.path}/coverage/index.html`)).to.not.be.empty; - - const summary = fs.readJSONSync(`${app.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); - }); -});