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

Update Ember CLI blueprints to 3.26.0 #198

Merged
merged 15 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
Expand Down
9 changes: 2 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
{
files: [
'.eslintrc.js',
'.prettierrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'index.js',
Expand All @@ -50,13 +51,7 @@ module.exports = {
node: true,
},
plugins: ['node'],
rules: Object.assign(
{},
require('eslint-plugin-node').configs.recommended.rules,
{
// add your custom rules and overrides for node files here
}
),
extends: ['plugin:node/recommended'],
},
// mocha tests, extending node files configuration
{
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/.env*
/.pnp*
/.sass-cache
/.eslintcache
/connect.lock
/coverage/
/libpeerconnection.log
Expand All @@ -23,6 +24,3 @@
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try

# cache
.eslintcache
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
/.editorconfig
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
/.gitignore
/.prettierignore
/.prettierrc.js
/.template-lintrc.js
/.travis.yml
/.watchmanconfig
Expand Down
21 changes: 21 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
/* eslint-env node */

module.exports = {
singleQuote: true,
};
25 changes: 10 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@

## Installation

- `git clone https://github.com/rwjblue/ember-cli-content-security-policy.git`
- `cd ember-cli-content-security-policy`
- `yarn install`
* `git clone <repository-url>`
snewcomer marked this conversation as resolved.
Show resolved Hide resolved
* `cd ember-cli-content-security-policy`
* `yarn install`

## Linting

- `yarn lint:hbs`
- `yarn lint:js`
- `yarn lint:js --fix`

## Formating

- `yarn format`
* `yarn lint`
* `yarn lint:fix`

## Running tests

- `ember test` – Runs the test suite on the current Ember version
- `ember test --server` – Runs the test suite in "watch mode"
- `ember try:each` – Runs the test suite against multiple Ember versions
* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions

## Running the dummy application

- `ember serve`
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
45 changes: 8 additions & 37 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,25 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
return {
useYarn: true,
scenarios: [
{
name: 'ember-lts-2.18',
Copy link
Collaborator

Choose a reason for hiding this comment

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

The new scenarios for Ember 3.16, 3.20 and Embroider should be added without replacing the existing scenarios. We need them to ensure that we do not break compatibility commitment without noticing. Maybe we should add a Ember 3.12 scenario as well to cover all LTS versions since 2.18.

Copy link
Collaborator

@jelhan jelhan Apr 17, 2021

Choose a reason for hiding this comment

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

I fear I got confused. The addon does not seem to run Ember Try at all. It uses a custom setup to test against multiple Ember CLI versions: https://github.com/rwjblue/ember-cli-content-security-policy/blob/master/.github/workflows/ci.yml#L145

This implicitly covers ember-source versions as well. But does not include ember-source@2.18.

It also means that Embroider tests are not run yet. Even after merging this one.

I guess we need to revisit the compatibility guarantee and test suite. But it could be done independently from this merge request.

I'm sorry that I asked you to put time into updating the ember try configuration.

env: {
EMBER_OPTIONAL_FEATURES: JSON.stringify({
'jquery-integration': true,
}),
},
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1',
'ember-source': '~2.18.0',
},
},
},
{
name: 'ember-lts-3.4',
name: 'ember-lts-3.16',
npm: {
devDependencies: {
'ember-source': '~3.4.0',
'ember-source': '~3.16.0',
},
},
},
{
name: 'ember-lts-3.8',
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': '~3.8.0',
},
},
},
{
name: 'ember-lts-3.12',
npm: {
devDependencies: {
'ember-source': '~3.12.0',
'ember-source': '~3.20.5',
},
},
},
Expand Down Expand Up @@ -68,16 +47,6 @@ module.exports = async function () {
},
},
},
// The default `.travis.yml` runs this scenario via `yarn test`,
// not via `ember try`. It's still included here so that running
// `ember try:each` manually or from a customized CI config will run it
// along with all the other scenarios.
{
name: 'ember-default',
npm: {
devDependencies: {},
},
},
{
name: 'ember-default-with-jquery',
env: {
Expand All @@ -87,7 +56,7 @@ module.exports = async function () {
},
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1',
'@ember/jquery': '^1.1.0',
},
},
},
Expand All @@ -106,6 +75,8 @@ module.exports = async function () {
},
},
},
embroiderSafe(),
embroiderOptimized(),
],
};
};
3 changes: 2 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ module.exports = function (defaults) {
behave. You most likely want to be modifying `./index.js` or app's build file
*/

return app.toTree();
const { maybeEmbroider } = require('@embroider/test-setup');
return maybeEmbroider(app);
};
4 changes: 1 addition & 3 deletions fastboot/instance-initializers/content-security-policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ function readAddonConfig(appInstance) {
// if already available through CSP meta element
assert(
'Required configuration is available at run-time',
addonConfig &&
addonConfig.hasOwnProperty('reportOnly') &&
addonConfig.hasOwnProperty('policy')
addonConfig && addonConfig['reportOnly'] && addonConfig['policy']
);

return config['ember-cli-content-security-policy'];
Expand Down
19 changes: 15 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,23 @@ module.exports = {

// Add nonce to <script> tag inserted by Ember CLI to assert that test file was loaded.
if (type === 'test-body-footer') {
let emberCliDependency = new VersionChecker(this.project).for(
'ember-cli'
);

existingContent.forEach((entry, index) => {
if (
/<script>\s*Ember.assert\(.*EmberENV.TESTS_FILE_LOADED\);\s*<\/script>/.test(
let result;
if (emberCliDependency.exists() && emberCliDependency.lt('3.25.1')) {
result = /<script>\s*Ember.assert\(.*EmberENV.TESTS_FILE_LOADED\);\s*<\/script>/.test(
entry
);
} else {
result = /<script>.*?Ember\.assert\(.*EmberENV\.TESTS_FILE_LOADED\);\s*}\);<\/script>/.test(
entry
)
) {
);
}
jelhan marked this conversation as resolved.
Show resolved Hide resolved

if (result) {
existingContent[index] = entry.replace(
'<script>',
'<script nonce="' + STATIC_TEST_NONCE + '">'
Expand Down
28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@
"body-parser": "^1.17.0",
"chalk": "^4.0.0",
"debug": "^4.3.1",
"ember-cli-babel": "^7.17.2",
"ember-cli-babel": "^7.26.3",
"ember-cli-version-checker": "^5.0.2"
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^2.2.5",
"@embroider/test-setup": "^0.37.0",
"@glimmer/tracking": "^1.0.0",
"babel-eslint": "^10.0.3",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"chai": "^4.3.0",
"denodeify": "^1.2.1",
"ember-addon-tests": "^0.0.2",
"ember-cli": "~3.16.1",
"ember-cli": "~3.26.0",
"ember-cli-addon-tests": "^0.11.1",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-eslint": "^5.1.0",
Expand All @@ -48,27 +50,29 @@
"ember-cli-inject-live-reload": "^2.0.2",
"ember-cli-sri": "^2.1.1",
"ember-cli-template-lint": "^2.0.2",
"ember-cli-uglify": "^3.0.0",
"ember-cli-terser": "^4.0.1",
"ember-disable-prototype-extensions": "^1.1.3",
"ember-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.2",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit": "^4.6.0",
"ember-qunit": "^5.1.4",
"ember-resolver": "^8.0.2",
"ember-source": "~3.25.1",
"ember-source": "~3.26.1",
"ember-source-channel-url": "^3.0.0",
"ember-try": "^1.4.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-ember": "^8.14.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-ember": "^10.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"execa": "^4.1.0",
"fs-extra": "^9.1.0",
"loader.js": "^4.7.0",
"mocha": "^7.0.0",
"npm-run-all": "^4.1.5",
"prettier": "2.2.1",
"qunit-dom": "^1.0.0",
"prettier": "~2.2.1",
"qunit": "^2.14.1",
"qunit-dom": "^1.6.0",
"release-it": "^14.4.1",
"release-it-lerna-changelog": "^3.1.0",
"request": "^2.88.0",
Expand Down
14 changes: 6 additions & 8 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
import config from 'dummy/config/environment';

const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver,
});
export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);

export default App;
12 changes: 5 additions & 7 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
import config from 'dummy/config/environment';

const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL,
});
export default class Router extends EmberRouter {
location = config.locationType;
rootURL = config.rootURL;
}

Router.map(function () {});

export default Router;
2 changes: 2 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{page-title "Dummy"}}

{{!-- The following component displays Ember's default welcome message. --}}
<WelcomePage />
{{!-- Feel free to remove this! --}}
Expand Down
21 changes: 21 additions & 0 deletions tests/dummy/config/ember-cli-update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"schemaVersion": "1.0.0",
"packages": [
{
"name": "ember-cli",
"version": "3.26.0",
"blueprints": [
{
"name": "addon",
"outputRepo": "https://github.com/ember-cli/ember-addon-output",
"codemodsSource": "ember-addon-codemods-manifest@1",
"isBaseBlueprint": true,
"options": [
"--welcome",
"--yarn"
]
}
]
}
]
}
Loading