Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable embroider-optimized #413

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- ember-canary
- ember-classic
- embroider-safe
# - embroider-optimized
- embroider-optimized

steps:
- uses: actions/checkout@v3
Expand Down
38 changes: 38 additions & 0 deletions addon/helpers/app-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { helper } from '@ember/component/helper';

import config from 'ember-get-config';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid using ember-get-config by making this a class-based helper and resolving the config ourselves.


import {
shaRegExp,
versionRegExp,
versionExtendedRegExp,
} from 'ember-cli-app-version/utils/regexp';

export function appVersion(_, hash = {}) {
// e.g. 1.0.0-alpha.1+4jds75hf
let version = config.APP.version;

// Allow use of 'hideSha' and 'hideVersion' For backwards compatibility
let versionOnly = hash.versionOnly || hash.hideSha;
let shaOnly = hash.shaOnly || hash.hideVersion;

let match = null;

if (versionOnly) {
if (hash.showExtended) {
match = version.match(versionExtendedRegExp); // 1.0.0-alpha.1
}
// Fallback to just version
if (!match) {
match = version.match(versionRegExp); // 1.0.0
}
}

if (shaOnly) {
match = version.match(shaRegExp); // 4jds75hf
}

return match ? match[0] : version;
}

export default helper(appVersion);
38 changes: 5 additions & 33 deletions app/helpers/app-version.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
import { helper } from '@ember/component/helper';
import config from '../config/environment';
import {
shaRegExp,
versionRegExp,
versionExtendedRegExp,
} from 'ember-cli-app-version/utils/regexp';
default as Helper,
appVersion as _private,
} from 'ember-cli-app-version/helpers/app-version';

export function appVersion(_, hash = {}) {
const version = config.APP.version;
// e.g. 1.0.0-alpha.1+4jds75hf
export const appVersion = _private;

// Allow use of 'hideSha' and 'hideVersion' For backwards compatibility
let versionOnly = hash.versionOnly || hash.hideSha;
let shaOnly = hash.shaOnly || hash.hideVersion;

let match = null;

if (versionOnly) {
if (hash.showExtended) {
match = version.match(versionExtendedRegExp); // 1.0.0-alpha.1
}
// Fallback to just version
if (!match) {
match = version.match(versionRegExp); // 1.0.0
}
}

if (shaOnly) {
match = version.match(shaRegExp); // 4jds75hf
}

return match ? match[0] : version;
}

export default helper(appVersion);
export default Helper;
8 changes: 8 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ module.exports = function (defaults) {
package: 'qunit',
},
],
pacakgeRules: [
{
package: 'dummy',
// Anyone already on embroider can import this if they need it.
// strict mode is well within reach for folks on embroider.
helpers: { '{{app-version}}': { safeToIgnore: true } },
},
],
});
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"dependencies": {
"ember-cli-babel": "^7.26.11",
"ember-get-config": "^2.1.1",
"git-repo-info": "^2.1.1"
},
"devDependencies": {
Expand All @@ -42,20 +43,21 @@
"@ember/optional-features": "^2.0.0",
"@ember/string": "^3.1.1",
"@ember/test-helpers": "^2.7.0",
"@embroider/macros": "^1.11.1",
"@embroider/test-setup": "^3.0.1",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@release-it-plugins/lerna-changelog": "^5.0.0",
"concurrently": "^8.2.0",
"ember-auto-import": "^2.6.3",
"ember-cli": "^4.12.0",
"ember-cli-dependency-checker": "^3.3.1",
"ember-cli-dependency-checker": "^3.3.2",
"ember-cli-htmlbars": "^6.2.0",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-load-initializers": "^2.1.2",
"ember-page-title": "^7.0.0",
"ember-qunit": "^6.0.0",
"ember-resolver": "^10.1.0",
"ember-resolver": "^10.1.1",
"ember-source": "^4.12.0",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^5.10.1",
Expand Down
6 changes: 5 additions & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

<h2 id="title">EmberCLI App Version</h2>

<p class="message">Your app version is {{app-version}}</p>
{{#if (macroDependencySatisfies "@embroider/core" "*")}}
<p class="message">Your app version is {{(app-version)}}</p>
{{else}}
<p class="message">Your app version is {{app-version}}</p>
{{/if}}
8 changes: 7 additions & 1 deletion tests/integration/helpers/app-version-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ module('Integration | Helper | {{app-version}}', function (hooks) {
test('it displays entire version', async function (assert) {
assert.expect(1);

await render(hbs`{{app-version}}`);
await render(hbs`
{{#if (macroDependencySatisfies "@embroider/core" "*")}}
{{(app-version)}}
{{else}}
{{app-version}}
{{/if}}
`);

assert.ok(this.element.textContent, 'Version not empty');
});
Expand Down
58 changes: 33 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1366,12 +1366,12 @@
ember-cli-version-checker "^5.1.2"
semver "^7.3.5"

"@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.10.0.tgz#af3844d5db48f001b85cfb096c76727c72ad6c1e"
integrity sha512-LMbfQGk/a+f6xtvAv5fq/wf2LRxETnbgSCLUf/z6ebzmuskOUxrke+uP55chF/loWrARi9g6erFQ7RDOUoBMSg==
"@embroider/macros@^0.50.0 || ^1.0.0", "@embroider/macros@^1.11.0", "@embroider/macros@^1.11.1":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.11.1.tgz#62eeb5bb7907ad01bdf750510c7f46c0192b6605"
integrity sha512-yg4Pl5Sw26lKrrtLwk2UEgYkKkztq+Hatn67QYL5A3I3T4IE/bRA3o6xvIslrJNnhyER7jCc2pwusxt3O4HubA==
dependencies:
"@embroider/shared-internals" "2.0.0"
"@embroider/shared-internals" "2.1.0"
assert-never "^1.2.1"
babel-import-util "^1.1.0"
ember-cli-babel "^7.26.6"
Expand All @@ -1380,12 +1380,12 @@
resolve "^1.20.0"
semver "^7.3.2"

"@embroider/macros@^1.11.0":
version "1.11.1"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.11.1.tgz#62eeb5bb7907ad01bdf750510c7f46c0192b6605"
integrity sha512-yg4Pl5Sw26lKrrtLwk2UEgYkKkztq+Hatn67QYL5A3I3T4IE/bRA3o6xvIslrJNnhyER7jCc2pwusxt3O4HubA==
"@embroider/macros@^1.0.0", "@embroider/macros@^1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@embroider/macros/-/macros-1.10.0.tgz#af3844d5db48f001b85cfb096c76727c72ad6c1e"
integrity sha512-LMbfQGk/a+f6xtvAv5fq/wf2LRxETnbgSCLUf/z6ebzmuskOUxrke+uP55chF/loWrARi9g6erFQ7RDOUoBMSg==
dependencies:
"@embroider/shared-internals" "2.1.0"
"@embroider/shared-internals" "2.0.0"
assert-never "^1.2.1"
babel-import-util "^1.1.0"
ember-cli-babel "^7.26.6"
Expand Down Expand Up @@ -3575,7 +3575,7 @@ chalk@^1.0.0:
strip-ansi "^3.0.0"
supports-color "^2.0.0"

chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
Expand Down Expand Up @@ -4551,16 +4551,16 @@ ember-cli-babel@^7.13.0, ember-cli-babel@^7.13.2, ember-cli-babel@^7.22.1, ember
rimraf "^3.0.1"
semver "^5.5.0"

ember-cli-dependency-checker@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/ember-cli-dependency-checker/-/ember-cli-dependency-checker-3.3.1.tgz#16b44d7a1a1e946f59859fad97f32e616d78323a"
integrity sha512-Tg6OeijjXNKWkDm6057Tr0N9j9Vlz/ITewXWpn1A/+Wbt3EowBx5ZKfvoupqz05EznKgL1B/ecG0t+JN7Qm6MA==
ember-cli-dependency-checker@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/ember-cli-dependency-checker/-/ember-cli-dependency-checker-3.3.2.tgz#94ed7e8e3d47e494082eb9ccfaa489d603ab6017"
integrity sha512-PwkrW5oYsdPWwt+0Tojufmv/hxVETTjkrEdK7ANQB2VSnqpA5UcYubwpQM9ONuR2J8wyNDMwEHlqIrk/FYtBsQ==
dependencies:
chalk "^2.3.0"
find-yarn-workspace-root "^1.1.0"
chalk "^2.4.2"
find-yarn-workspace-root "^1.2.1"
is-git-url "^1.0.0"
resolve "^1.5.0"
semver "^5.3.0"
resolve "^1.22.0"
semver "^5.7.1"

ember-cli-get-component-path-option@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -4827,6 +4827,14 @@ ember-destroyable-polyfill@^2.0.3:
ember-cli-version-checker "^5.1.1"
ember-compatibility-helpers "^1.2.1"

ember-get-config@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ember-get-config/-/ember-get-config-2.1.1.tgz#bede76c25d95dbefab8d30064abf7aa00bc19235"
integrity sha512-uNmv1cPG/4qsac8oIf5txJ2FZ8p88LEpG4P3dNcjsJS98Y8hd0GPMFwVqpnzI78Lz7VYRGQWY4jnE4qm5R3j4g==
dependencies:
"@embroider/macros" "^0.50.0 || ^1.0.0"
ember-cli-babel "^7.26.6"

ember-load-initializers@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ember-load-initializers/-/ember-load-initializers-2.1.2.tgz#8a47a656c1f64f9b10cecdb4e22a9d52ad9c7efa"
Expand Down Expand Up @@ -4857,10 +4865,10 @@ ember-qunit@^6.0.0:
silent-error "^1.1.1"
validate-peer-dependencies "^2.2.0"

ember-resolver@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/ember-resolver/-/ember-resolver-10.1.0.tgz#0ac7bb0105f8bd1d5a93603d4ccb5ef0a4205d9f"
integrity sha512-Ju/ORUUbGnR83AgC3qV6fIVuM5tyi/nPRf9ggTM2+kdeGPLNTSkNZ0zSbjWEm0kerDezMjj/RoGuLvZl/L758w==
ember-resolver@^10.1.1:
version "10.1.1"
resolved "https://registry.yarnpkg.com/ember-resolver/-/ember-resolver-10.1.1.tgz#1106a2386337b13a9ee509a9ad2a18b53a728ab3"
integrity sha512-y1zzn6C4YGJui+tJzcCKlsf1oSOSVAkRrvmg8OwqVIKnALKKb9ihx2qLCslHg8x0wJvJgMtDMXgrczvQrZW0Lw==
dependencies:
ember-cli-babel "^7.26.11"

Expand Down Expand Up @@ -5828,7 +5836,7 @@ find-up@^6.3.0:
locate-path "^7.1.0"
path-exists "^5.0.0"

find-yarn-workspace-root@^1.1.0:
find-yarn-workspace-root@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db"
integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q==
Expand Down Expand Up @@ -10440,7 +10448,7 @@ semver-diff@^4.0.0:
dependencies:
semver "^7.3.5"

"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0, semver@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
Expand Down