Registry / devops / ember-cli-version-checker

ember-cli-version-checker

JSON →
library5.1.2jsnpmunverified

The `ember-cli-version-checker` package is a fundamental utility for Ember CLI addon authors. It provides a robust mechanism to programmatically determine the installed versions of NPM or (historically) Bower packages within a consuming Ember application's dependency tree. This allows addons to implement conditional logic, such as providing different features, templates, or polyfills, based on the host application's Ember CLI or Ember.js version, thus ensuring broad compatibility. The current stable version is 5.1.2, with releases occurring on an as-needed basis for bug fixes and minor enhancements rather than a fixed cadence. Its core differentiator lies in its deep integration with the Ember CLI project context, simplifying complex semver comparisons for specific dependencies.

devops
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Ember CLI addons are typically CommonJS modules. Using `require` is the standard pattern. Direct ESM import is not commonly supported or recommended in this context.

const VersionChecker = require('ember-cli-version-checker');

Methods are accessed on an instance of VersionChecker, which must be initialized with the `this.project` object from an Ember CLI addon context.

const checker = new VersionChecker(this.project); const dep = checker.for('ember-cli'); if (dep.gte('2.0.0')) { /* ... */ }

Demonstrates initializing `VersionChecker` within an Ember CLI addon's hooks, asserting minimum dependency versions, and conditionally loading resources based on the host application's Ember.js version.

const path = require('path'); const VersionChecker = require('ember-cli-version-checker'); // This code would typically reside in an Ember CLI addon's index.js file // inside the module.exports object. module.exports = { name: 'my-awesome-addon', init() { this._super.init.apply(this, arguments); const checker = new VersionChecker(this.project); // Assert a minimum Ember CLI version checker.for('ember-cli').assertAbove('2.13.0', '`my-awesome-addon` requires Ember CLI >= 2.13.0'); const emberDep = checker.for('ember'); if (!emberDep.exists()) { console.warn('Ember.js not found in project dependencies. This addon may not function correctly.'); } console.log(`Ember version: ${emberDep.version || 'N/A'}`); }, treeForAddonTemplates(tree) { const checker = new VersionChecker(this.project); const emberDep = checker.for('ember'); const baseTemplatesPath = path.join(this.root, 'addon/templates'); // Conditionally provide templates based on Ember version if (emberDep.satisfies('>= 3.0.0')) { return this.treeGenerator(path.join(baseTemplatesPath, 'modern')); } else if (emberDep.satisfies('>= 2.0.0')) { return this.treeGenerator(path.join(baseTemplatesPath, 'classic')); } else { // Fallback for older Ember versions or non-existent Ember return this.treeGenerator(path.join(baseTemplatesPath, 'legacy')); } } };
Debug
Known footguns
breakingThis package requires Node.js version `10.* || >= 12.*`. Usage with unsupported Node.js versions will result in errors.
gotchaThe `VersionChecker` constructor *must* be initialized with an `EmberCLIProject` instance, typically `this.project` when used within an Ember CLI addon's `index.js` file. Attempting to use it without this context will lead to runtime errors.
deprecatedWhile `ember-cli-version-checker` still supports checking Bower dependencies via `checker.for('package', 'bower')`, Bower itself is largely deprecated in the Ember ecosystem. Focus on checking NPM dependencies.
gotchaThe `hasSingleImplementation` method had bug fixes across multiple major versions (v4.1.1, v5.0.2). If relying on this specific API, ensure you are on the latest stable version to avoid potential incorrect results.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
11 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
Resources