diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c342705e..56c5bb99 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ jobs: lint: name: Linting runs-on: ubuntu-latest + timeout-minutes: 5 steps: - uses: actions/checkout@v1 @@ -23,6 +24,7 @@ jobs: test-ember: name: Tests / Ember runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v1 @@ -34,6 +36,7 @@ jobs: test-node: name: Tests / Node runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@v1 @@ -49,6 +52,7 @@ jobs: test-float: name: Tests / floating dependencies runs-on: ubuntu-latest + timeout-minutes: 5 steps: - uses: actions/checkout@v1 @@ -61,6 +65,7 @@ jobs: name: Tests / ${{ matrix.ember-try-scenario }} runs-on: ubuntu-latest needs: [lint, test-ember] + timeout-minutes: 15 strategy: matrix: @@ -72,6 +77,8 @@ jobs: - ember-canary - ember-default-with-jquery - ember-classic + - embroider-safe + # - embroider-optimized steps: - uses: actions/checkout@v1 diff --git a/config/ember-try.js b/config/ember-try.js index a49b554b..c9d0dd79 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -1,6 +1,7 @@ 'use strict'; const getChannelURL = require('ember-source-channel-url'); +const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); module.exports = async function () { return { @@ -77,6 +78,8 @@ module.exports = async function () { }, }, }, + embroiderSafe(), + embroiderOptimized(), ], }; }; diff --git a/ember-cli-build.js b/ember-cli-build.js index ba0649dc..39a8ffca 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -1,6 +1,8 @@ 'use strict'; const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); +const { maybeEmbroider } = require('@embroider/test-setup'); +const { treeForManifest } = require('./index'); module.exports = function (defaults) { let app = new EmberAddon(defaults, { @@ -14,5 +16,7 @@ module.exports = function (defaults) { behave. You most likely want to be modifying `./index.js` or app's build file */ - return app.toTree(); + return maybeEmbroider(app, { + extraPublicTrees: [treeForManifest(app)], + }); }; diff --git a/index.js b/index.js index c38fab53..fcb6fc19 100644 --- a/index.js +++ b/index.js @@ -3,9 +3,10 @@ const BroccoliMergeTrees = require('broccoli-merge-trees'); const Manifest = require('./lib/manifest'); const Browserconfig = require('./lib/browserconfig'); const tags = require('./lib/tags'); +const pkg = require('./package'); module.exports = { - name: require('./package').name, + name: pkg.name, shouldIncludeChildAddon(childAddon) { if (childAddon.name === 'broccoli-asset-rev') { @@ -17,6 +18,15 @@ module.exports = { included(app) { this.app = app; + }, + + treeForPublic() { + if (!this.manifest) { + return this._treeForManifest(this.app); + } + }, + + _treeForManifest(app) { app.options = app.options || {}; app.options[this.name] = app.options[this.name] || {}; @@ -26,19 +36,19 @@ module.exports = { this.manifest.configureFingerprint(); this.browserconfig.configureFingerprint(); - this._super.included.apply(this, arguments); - }, - - treeForPublic() { - let manifest = this.manifest.toTree(); - let browserconfig = this.browserconfig.toTree(); - - return new BroccoliMergeTrees([manifest, browserconfig]); + return new BroccoliMergeTrees([ + this.manifest.toTree(), + this.browserconfig.toTree(), + ]); }, contentFor(section) { - if (section === 'head') { + if (this.manifest && section === 'head') { return tags(this.manifest.configuration); } }, }; + +module.exports.treeForManifest = function treeForManifest(app) { + return app.project.findAddonByName(pkg.name)._treeForManifest(app); +}; diff --git a/node-tests/blueprints/ember-web-app-test.js b/node-tests/blueprints/ember-web-app-test.js index 4caa7d88..582bff96 100644 --- a/node-tests/blueprints/ember-web-app-test.js +++ b/node-tests/blueprints/ember-web-app-test.js @@ -1,10 +1,10 @@ 'use strict'; const { expect } = require('ember-cli-blueprint-test-helpers/chai'); + const { setupTestHooks, emberNew, emberGenerate, - emberGenerateDestroy, emberDestroy, } = require('ember-cli-blueprint-test-helpers/helpers'); @@ -12,27 +12,19 @@ describe('Blueprints', function () { setupTestHooks(this); describe('ember generate', function () { - it('generates config/manifest.js file', function () { + it('generates files', function () { let args = ['ember-web-app', 'foo']; return emberNew().then(() => - emberGenerateDestroy(args, (file) => { + emberGenerate(args, (file) => { expect(file('config/manifest.js')) .to.contain('name: "my-app"') .to.contain('short_name: "my-app"') .to.contain('display: "standalone"'); - }) - ); - }); - it('adds manifest link & browserconfig meta into app/index.html file', function () { - let args = ['ember-web-app', 'foo']; - - return emberNew().then(() => - emberGenerate(args, (file) => { expect(file('app/index.html')) .to.contain( - '' + '' ) .to.contain( '' diff --git a/package.json b/package.json index 7dc489d5..c23b9d8b 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "release": "release-it", "changelog": "lerna-changelog", "fast-test": "SKIP_ACCEPTANCE=true yarn node-test", - "node-test": "nyc --reporter=lcov mocha --recursive node-tests", + "node-test": "nyc --reporter=lcov mocha --recursive node-tests/**/*-test.js", "lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"", "lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix", "lint:hbs": "ember-template-lint .", @@ -50,6 +50,7 @@ "devDependencies": { "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.5.0", + "@embroider/test-setup": "^0.47.0", "@glimmer/component": "^1.0.4", "@glimmer/tracking": "^1.0.4", "babel-eslint": "^10.1.0", diff --git a/tests/dummy/app/templates/docs/advanced/fingerprinting.md b/tests/dummy/app/templates/docs/advanced/fingerprinting.md index 5a74f3bd..245847e0 100644 --- a/tests/dummy/app/templates/docs/advanced/fingerprinting.md +++ b/tests/dummy/app/templates/docs/advanced/fingerprinting.md @@ -7,12 +7,12 @@ The following example prepends with a custom domain and adds fingerprint checksu ```javascript 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); -const broccoliAssetRevDefaults = require('broccoli-asset-rev/lib/default-options'); +const { extensions } = require('broccoli-asset-rev/lib/default-options'); -module.exports = function(defaults) { +module.exports = function (defaults) { let options = { fingerprint: { - extensions: broccoliAssetRevDefaults.extensions.concat(['webmanifest']), + extensions: [...extensions, 'webmanifest'], prepend: 'https://www.example.com/', }, }; diff --git a/tests/dummy/app/templates/docs/advanced/generating-icons.md b/tests/dummy/app/templates/docs/advanced/generating-icons.md index 4237ff4a..4b819b1d 100644 --- a/tests/dummy/app/templates/docs/advanced/generating-icons.md +++ b/tests/dummy/app/templates/docs/advanced/generating-icons.md @@ -7,7 +7,7 @@ If your `config/manifest.js` looks like this and needs a `192px` and a `512px` i ```javascript 'use strict'; -module.exports = function() { +module.exports = function () { return { icons: [ { @@ -15,7 +15,7 @@ module.exports = function() { sizes: '32x32', targets: ['favicon'], }, - ...[192, 280, 512].map(size => ({ + ...[192, 280, 512].map((size) => ({ src: `/assets/icons/appicon-${size}.png`, sizes: `${size}x${size}`, })), @@ -28,8 +28,9 @@ You can start with a base `brand-icon.svg` image and automatically build the `19 ```javascript 'use strict'; +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); -module.exports = function(defaults) { +module.exports = function (defaults) { let options = { 'ember-cli-image-transformer': { images: [ diff --git a/tests/dummy/app/templates/docs/getting-started/installation.md b/tests/dummy/app/templates/docs/getting-started/installation.md index c252bf78..62a00dcd 100644 --- a/tests/dummy/app/templates/docs/getting-started/installation.md +++ b/tests/dummy/app/templates/docs/getting-started/installation.md @@ -9,10 +9,32 @@ ember install ember-web-app Ember should install the addon, add a `config/manifest.js` file, and insert HTML tags for `manifest.webmanifest` and `browserconfig.xml` into `app/index.html` file. ```html +
- - + + ``` Check out the {{docs-link "upgrade guide" "docs.getting-started.upgrade-guide"}} if you're coming from a previous version of Web App. + +## Embroider + +When application uses Embroider, then pass manifest tree into `extraPublicTrees` configuration property. + +```javascript +// ember-cli-build.js +'use strict'; + +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); +const { treeForManifest } = require('ember-web-app'); + +module.exports = function (defaults) { + let app = new EmberApp(defaults, {}); + + const { Webpack } = require('@embroider/webpack'); + return require('@embroider/compat').compatBuild(app, Webpack, { + extraPublicTrees: [treeForManifest(app)], + }); +}; +``` diff --git a/tests/dummy/app/templates/docs/getting-started/overview.md b/tests/dummy/app/templates/docs/getting-started/overview.md index 846bdc35..af49036c 100644 --- a/tests/dummy/app/templates/docs/getting-started/overview.md +++ b/tests/dummy/app/templates/docs/getting-started/overview.md @@ -14,7 +14,7 @@ From [MDN](https://developer.mozilla.org/en-US/docs/Web/Manifest) The generated `manifest.webmanifest` file is linked to the application using `link` tag in `app/index.html` file. ```html - + ``` _The generated manifest is validated using `web-app-manifest-validator` package._ @@ -28,7 +28,7 @@ From [Microsoft](https://msdn.microsoft.com/en-us/library/dn320426%28v=vs.85%29. The generated `browserconfig.xml` file is linked to the application using `meta` tag in `app/index.html` file. ```html - + ``` _You can skip generating of `browserconfig.xml` file by removing the `meta` tag from the `app/index.html` file._ diff --git a/yarn.lock b/yarn.lock index e0bdc8a0..fb6ef820 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1165,23 +1165,14 @@ mkdirp "^1.0.4" silent-error "^1.1.1" -"@ember/render-modifiers@^1.0.1": +"@ember/render-modifiers@^1.0.1", "@ember/render-modifiers@cibernox/ember-render-modifiers#e3574ed03409ef7a048d7716b8bea361ed6cd6e2": version "1.0.2" - resolved "https://registry.yarnpkg.com/@ember/render-modifiers/-/render-modifiers-1.0.2.tgz#2e87c48db49d922ce4850d707215caaac60d8444" - integrity sha512-6tEnHl5+62NTSAG2mwhGMFPhUrJQjoVqV+slsn+rlTknm2Zik+iwxBQEbwaiQOU1FUYxkS8RWcieovRNMR8inQ== + resolved "https://codeload.github.com/cibernox/ember-render-modifiers/tar.gz/e3574ed03409ef7a048d7716b8bea361ed6cd6e2" dependencies: ember-cli-babel "^7.10.0" + ember-compatibility-helpers "^1.2.4" ember-modifier-manager-polyfill "^1.1.0" -"@ember/render-modifiers@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@ember/render-modifiers/-/render-modifiers-2.0.0.tgz#7106928078c6463bc6ee3cbffb6d71dbb8602145" - integrity sha512-FbvowKEnYx102MaNMrePBC7RCmuf3BaqPKbp6QP7S6oJaDMuLrGblXW4TxOrE93C6II+6D4QNB4WFGuPeQ3ZBg== - dependencies: - ember-cli-babel "^7.26.6" - ember-compatibility-helpers "^1.2.5" - ember-modifier-manager-polyfill "^1.2.0" - "@ember/string@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@ember/string/-/string-3.0.0.tgz#e3a3cc7874c9f64eadfdac644d8b1238721ce289" @@ -1314,6 +1305,14 @@ semver "^7.3.2" typescript-memoize "^1.0.0-alpha.3" +"@embroider/test-setup@^0.47.0": + version "0.47.0" + resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-0.47.0.tgz#ea307583efaac227b71c5ad348fecac362637e0c" + integrity sha512-KadqpSno0qyhVW2VtXTU7i9OQHNT1tpcrQ+06sTaFmX275yGxHUTcSr//CV1ErtzejcVPvkGnRQIUKPRXZsNVA== + dependencies: + lodash "^4.17.21" + resolve "^1.20.0" + "@embroider/util@^0.43.5": version "0.43.5" resolved "https://registry.yarnpkg.com/@embroider/util/-/util-0.43.5.tgz#d3acc98b3f92fbb26fa9265cff4f245ca8e6b61e" @@ -1403,10 +1402,10 @@ dependencies: "@simple-dom/interface" "^1.4.0" -"@glimmer/interfaces@0.81.0": - version "0.81.0" - resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.81.0.tgz#a2e8fb829d90f531b5c8021e51412002d5e60812" - integrity sha512-ZhdQrMLMHaIU0ReWWNo5uKE8c6E3r98ekknSFOzGqDOq1337yBAUE1nQIA1Ao1sipZuo9ug51E6eoS3NskObGg== +"@glimmer/interfaces@0.80.0": + version "0.80.0" + resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.80.0.tgz#eabc7551ffe7ad27c44ba96d39e2af6ebf01c942" + integrity sha512-evD9aVhYacFe/lD/FzaPs0CuuIgkr17+KbOCWDeEMXW0q2FnrLiQET40eP5nyhGLELhKE62mlIzdGmleUR6XYg== dependencies: "@simple-dom/interface" "^1.4.0" @@ -1480,15 +1479,15 @@ "@handlebars/parser" "^1.1.0" simple-html-tokenizer "^0.5.10" -"@glimmer/syntax@^0.81.0": - version "0.81.0" - resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.81.0.tgz#8c9b959e06213dfdcd8378dbdc5c3105ae5fb2e8" - integrity sha512-96XFYXuhCN8M22yeX1RBahnQuBPVtDFWUr5uqAHAZ/zElpAJxD5cMmx6emjf7c3k2G3Gx8/A/SM2ZuvEcvB18Q== +"@glimmer/syntax@^0.80.0": + version "0.80.0" + resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.80.0.tgz#5f9c2e5824fdc8f88ec3e71861598c339b6777c1" + integrity sha512-LP8I5MmcguUiHhahyF96dgjKrPE6l1QVl2rlJY23FkzPSVMtUAQxNsxHPZ7vqi+gu7wucNiOfIPNTh9avOr20Q== dependencies: - "@glimmer/interfaces" "0.81.0" - "@glimmer/util" "0.81.0" + "@glimmer/interfaces" "0.80.0" + "@glimmer/util" "0.80.0" "@handlebars/parser" "~2.0.0" - simple-html-tokenizer "^0.5.11" + simple-html-tokenizer "^0.5.10" "@glimmer/tracking@^1.0.2", "@glimmer/tracking@^1.0.4": version "1.0.4" @@ -1507,13 +1506,13 @@ "@glimmer/interfaces" "0.65.4" "@simple-dom/interface" "^1.4.0" -"@glimmer/util@0.81.0": - version "0.81.0" - resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.81.0.tgz#2cb45d10a6cbd3d835ee4478608c2909a05bb937" - integrity sha512-uheYr2j9T7EKOzKlSIGO/ePeWj0knWebGIm6VJAe5hTKnx5fw0R0iiV6x1whLrbfS/6feVtKTopF4lSN0arELQ== +"@glimmer/util@0.80.0": + version "0.80.0" + resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.80.0.tgz#286ec9e2c8c9e2f364e49272a3baf9d0fe3dc40c" + integrity sha512-fvr4zyGVp58vzVajwTwbGwp0LmPxm2SVWkfIGFcCr9r2BmYD+9bd52I0u00LsZvNJQqFNyI8RB+qXThRMi+TiA== dependencies: "@glimmer/env" "0.1.7" - "@glimmer/interfaces" "0.81.0" + "@glimmer/interfaces" "0.80.0" "@simple-dom/interface" "^1.4.0" "@glimmer/util@^0.42.2": @@ -6989,7 +6988,7 @@ ember-code-snippet@^3.0.0: es6-promise "^1.0.0" glob "^7.1.3" -ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.0, ember-compatibility-helpers@^1.2.1, ember-compatibility-helpers@^1.2.4, ember-compatibility-helpers@^1.2.5: +ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.0, ember-compatibility-helpers@^1.2.1, ember-compatibility-helpers@^1.2.4: version "1.2.5" resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-1.2.5.tgz#b8363b1d5b8725afa9a4fe2b2986ac28626c6f23" integrity sha512-7cddkQQp8Rs2Mqrj0xqZ0uO7eC9tBCKyZNcP2iE1RxQqOGPv8fiPkj1TUeidUB/Qe80lstoVXWMEuqqhW7Yy9A== @@ -14119,7 +14118,7 @@ silent-error@^1.0.0, silent-error@^1.0.1, silent-error@^1.1.1: dependencies: debug "^2.2.0" -simple-html-tokenizer@^0.5.10, simple-html-tokenizer@^0.5.11, simple-html-tokenizer@^0.5.8: +simple-html-tokenizer@^0.5.10, simple-html-tokenizer@^0.5.8: version "0.5.11" resolved "https://registry.yarnpkg.com/simple-html-tokenizer/-/simple-html-tokenizer-0.5.11.tgz#4c5186083c164ba22a7b477b7687ac056ad6b1d9" integrity sha512-C2WEK/Z3HoSFbYq8tI7ni3eOo/NneSPRoPpcM7WdLjFOArFuyXEjAoCdOC3DgMfRyziZQ1hCNR4mrNdWEvD0og==