@ember/edition-utils
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -0,2 +1,13 @@ | ||
## v1.1.0 (2019-09-15) | ||
#### :rocket: Enhancement | ||
* [#1](https://github.com/emberjs/ember-edition-utils/pull/1) Allow falling back to process.env.EMBER_VERSION. ([@rwjblue](https://github.com/rwjblue)) | ||
#### :memo: Documentation | ||
* [#2](https://github.com/emberjs/ember-edition-utils/pull/2) Add some basic README content. ([@rwjblue](https://github.com/rwjblue)) | ||
#### Committers: 1 | ||
- Robert Jackson ([@rwjblue](https://github.com/rwjblue)) | ||
Could not infer "repo" from the "package.json" file. | ||
13
index.js
@@ -30,3 +30,14 @@ /** | ||
function _getEdition() { | ||
return process.env.EMBER_EDITION; | ||
let edition = process.env.EMBER_EDITION; | ||
if (edition === undefined) { | ||
// check fallback "old" location | ||
edition = process.env.EMBER_VERSION; | ||
if (edition === 'octane') { | ||
console.log('Please update to using @ember/edition-utils. Using process.env.EMBER_VERSION to declare your application / addon as "octane" ready is deprecated.'); | ||
} | ||
} | ||
return edition; | ||
} | ||
@@ -33,0 +44,0 @@ |
{ | ||
"name": "@ember/edition-utils", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Utilities to detect if a given edition is in use in an ember-cli application.", | ||
"repository": "https://github.com/emberjs/ember-octane-utils.git", | ||
"license": "MIT", | ||
@@ -6,0 +7,0 @@ "author": "Robert Jackson <me@rwjblue.com>", |
# @ember/edition-utils | ||
This package is the officially supported mechanism for declaring and detecting | ||
the specific edition that a given application is using. | ||
## Usage | ||
### Declaring Edition | ||
In order to declare which edition of Ember your application (or addon) is compatible with | ||
you would call `setEdition` from within your `.ember-cli.js` file. This might look something like: | ||
```js | ||
const { setEdition } = require('@ember/edition-utils'); | ||
setEdition('octane'); | ||
module.exports = { | ||
// other configuration here | ||
} | ||
``` | ||
### Detecting Edition | ||
In order to detect if the currently running application is using _at least_ a | ||
specific edition, you would call `has`. This will most commonly be used from | ||
within various addon's to determine which blueprint code to run. For example: | ||
```js | ||
const { has } = require('@ember/edition-utils'); | ||
if (has('octane')) { | ||
// do octane stuff | ||
} else { | ||
// do classic mode stuff | ||
} | ||
``` | ||
## License | ||
This project is licensed under the [MIT License](LICENSE.md). |
17
test.js
@@ -5,2 +5,4 @@ const { setEdition, has, _getEdition } = require('./index'); | ||
const OriginalConsole = Object.assign({}, console); | ||
QUnit.module('@ember/edition-utils', function(hooks) { | ||
@@ -16,2 +18,4 @@ // only a test helper **because** we don't want folks to | ||
delete process.env.EMBER_EDITION; | ||
delete process.env.EMBER_VERSION; | ||
Object.assign(console, OriginalConsole); | ||
}); | ||
@@ -43,3 +47,16 @@ | ||
}); | ||
test('should infer edition from process.env.EMBER_VERSION with a warning', function(assert) { | ||
assert.expect(2); | ||
process.env.EMBER_VERSION = 'octane'; | ||
console.log = (...args) => { | ||
assert.deepEqual(args, [ | ||
'Please update to using @ember/edition-utils. Using process.env.EMBER_VERSION to declare your application / addon as "octane" ready is deprecated.', | ||
]); | ||
} | ||
assert.ok(has('octane'), 'finds process.env.EMBER_VERSION'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
9231
8
103
42
5