From 5aa494431c140df1ff7c94fa01fc26e7c169920f Mon Sep 17 00:00:00 2001
From: Jonas Metzener
Date: Tue, 15 Feb 2022 16:19:27 +0100
Subject: [PATCH] chore(config): remove all usage of ember-get-config
---
addon/-private/config.js | 57 +++++++++++++++++++
addon/adapters/-addon-docs.js | 6 +-
addon/components/api/x-class/index.hbs | 2 +-
addon/components/api/x-class/index.js | 6 +-
addon/components/api/x-section/index.hbs | 2 +-
addon/components/api/x-section/index.js | 6 +-
addon/components/docs-header/index.hbs | 6 +-
addon/components/docs-header/index.js | 16 ++----
.../docs-header/search-box/index.js | 13 ++---
.../docs-header/search-results/index.js | 14 ++---
.../docs-header/version-selector/index.hbs | 8 +--
.../docs-header/version-selector/index.js | 19 ++-----
addon/components/docs-hero/index.js | 27 +++------
addon/components/docs-viewer/x-main/index.js | 8 ++-
addon/components/docs-viewer/x-nav/index.js | 14 +++--
addon/routes/docs.js | 9 +--
addon/services/docs-search.js | 14 ++---
addon/services/project-version.js | 30 +++++-----
package.json | 1 -
.../acceptance/sandbox/api/components-test.js | 10 ++--
tests/dummy/mirage/config.js | 2 +-
yarn.lock | 2 +-
22 files changed, 145 insertions(+), 127 deletions(-)
create mode 100644 addon/-private/config.js
diff --git a/addon/-private/config.js b/addon/-private/config.js
new file mode 100644
index 000000000..ffb36aaed
--- /dev/null
+++ b/addon/-private/config.js
@@ -0,0 +1,57 @@
+import { getOwner } from '@ember/application';
+import { cached } from 'tracked-toolbox';
+
+/**
+ * Function to get the currently configured rootURL from the containers.
+ *
+ * @function getRootURL
+ * @private
+ * @param {*} target Instance of an ember class that has an owner
+ * @returns {String} The currently configured rootURL
+ */
+export function getRootURL(target) {
+ return getOwner(target).resolveRegistration('config:environment').rootURL;
+}
+
+/**
+ * Function to get the current configuration of `ember-cli-addon-docs` from the
+ * container.
+ *
+ * @function getAddonDocsConfig
+ * @private
+ * @param {*} target Instance of an ember class that has an owner
+ * @returns {Object} The `ember-cli-addon-docs` configuration object
+ */
+export function getAddonDocsConfig(target) {
+ return getOwner(target).resolveRegistration('config:environment')[
+ 'ember-cli-addon-docs'
+ ];
+}
+
+/**
+ * Decorator to use the `ember-cli-addon-docs` configuration object on a class.
+ *
+ * Usage:
+ *
+ * ```js
+ * class MyComponent extends Component {
+ * @addonDocsConfig config;
+ *
+ * get projectName() {
+ * // will return the value of `projectName` configured in the
+ * // `ember-cli-addon-docs` section of the host configuration
+ * return this.config.projectName:
+ * }
+ * }
+ * ```
+ *
+ * @function addonDocsConfig
+ * @private
+ */
+export function addonDocsConfig(target, property, descriptor) {
+ return cached(target, property, {
+ get() {
+ return getAddonDocsConfig(this);
+ },
+ });
+}
diff --git a/addon/adapters/-addon-docs.js b/addon/adapters/-addon-docs.js
index 466056e17..8c6327b60 100644
--- a/addon/adapters/-addon-docs.js
+++ b/addon/adapters/-addon-docs.js
@@ -1,14 +1,12 @@
-import { getOwner } from '@ember/application';
import Adapter from '@ember-data/adapter';
import fetch from 'fetch';
+import { getRootURL } from 'ember-cli-addon-docs/-private/config';
export default class AddonDocsAdapter extends Adapter {
defaultSerializer = '-addon-docs';
get namespace() {
- const rootURL =
- getOwner(this).resolveRegistration('config:environment').rootURL;
- return `${rootURL.replace(/\/$/, '')}/docs`;
+ return `${getRootURL(this).replace(/\/$/, '')}/docs`;
}
shouldBackgroundReloadAll() {
diff --git a/addon/components/api/x-class/index.hbs b/addon/components/api/x-class/index.hbs
index eb681daee..e49da9059 100644
--- a/addon/components/api/x-class/index.hbs
+++ b/addon/components/api/x-class/index.hbs
@@ -3,7 +3,7 @@
{{! wrapping in a div seems to work around https://github.com/ember-learn/ember-cli-addon-docs/issues/7 }}
{{{@class.description}}}
-{{#if (or (and @class.exportType this.showImportPaths) this.hasToggles)}}
+{{#if (or (and @class.exportType this.config.showImportPaths) this.hasToggles)}}
{{#if @class.exportType}}
diff --git a/addon/components/api/x-class/index.js b/addon/components/api/x-class/index.js
index ee09de5b1..d57fc11ad 100644
--- a/addon/components/api/x-class/index.js
+++ b/addon/components/api/x-class/index.js
@@ -3,12 +3,10 @@ import { tracked } from '@glimmer/tracking';
import { or } from '@ember/object/computed';
import { capitalize } from '@ember/string';
import { memberFilter } from '../../../utils/computed';
-import config from 'ember-get-config';
-
-const { showImportPaths } = config['ember-cli-addon-docs'];
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
export default class XClass extends Component {
- showImportPaths = showImportPaths;
+ @addonDocsConfig config;
@tracked showInherited = false;
@tracked showProtected = false;
diff --git a/addon/components/api/x-section/index.hbs b/addon/components/api/x-section/index.hbs
index 94689eba8..d890c9bca 100644
--- a/addon/components/api/x-section/index.hbs
+++ b/addon/components/api/x-section/index.hbs
@@ -26,7 +26,7 @@
{{{@item.description}}}
- {{#if (or (and @item.exportType this.showImportPaths) this.shouldDisplayParams)}}
+ {{#if (or (and @item.exportType this.config.showImportPaths) this.shouldDisplayParams)}}
{{#if @item.exportType}}
diff --git a/addon/components/api/x-section/index.js b/addon/components/api/x-section/index.js
index 39886549c..f0df880b2 100644
--- a/addon/components/api/x-section/index.js
+++ b/addon/components/api/x-section/index.js
@@ -1,14 +1,12 @@
import Component from '@glimmer/component';
-import config from 'ember-get-config';
-
-const { showImportPaths } = config['ember-cli-addon-docs'];
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
/**
@class Api/XSection
@hide
*/
export default class XSection extends Component {
- showImportPaths = showImportPaths;
+ @addonDocsConfig config;
/**
* Params shouldn't be displayed when there are no descriptions and no subparams,
diff --git a/addon/components/docs-header/index.hbs b/addon/components/docs-header/index.hbs
index a5adfd187..c6d1fdfbb 100644
--- a/addon/components/docs-header/index.hbs
+++ b/addon/components/docs-header/index.hbs
@@ -26,7 +26,7 @@
- {{#if (eq this.currentVersion.key this.latestVersionName)}}
+ {{#if (eq this.currentVersion.key this.config.latestVersionName)}}
{{#if this.currentVersion.tag}}
{{this.currentVersion.tag}}
{{else}}
@@ -40,8 +40,8 @@
- {{#if this.projectHref}}
-
+ {{#if this.config.projectHref}}
+
{{svg-jar "github" width=24 height=24}}
diff --git a/addon/components/docs-header/index.js b/addon/components/docs-header/index.js
index e8ec81e39..d80c30c13 100644
--- a/addon/components/docs-header/index.js
+++ b/addon/components/docs-header/index.js
@@ -1,15 +1,11 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
-import config from 'ember-get-config';
import { classify } from '@ember/string';
import { addonPrefix } from 'ember-cli-addon-docs/utils/computed';
import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';
import { action } from '@ember/object';
-import { localCopy } from 'tracked-toolbox';
-
-const { projectName, projectHref, latestVersionName } =
- config['ember-cli-addon-docs'];
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
/**
Render a header showing a link to your documentation, your project logo, a
@@ -34,8 +30,7 @@ const { projectName, projectHref, latestVersionName } =
export default class DocsHeader extends Component {
@service projectVersion;
- projectHref = projectHref;
- latestVersionName = latestVersionName;
+ @addonDocsConfig config;
@tracked query;
@@ -57,8 +52,9 @@ export default class DocsHeader extends Component {
@argument prefix
@type String?
*/
- @localCopy('args.prefix', addonPrefix(projectName))
- prefix;
+ get prefix() {
+ return this.args.prefix ?? addonPrefix(this.config.projectName);
+ }
/**
The name of your project (without the "ember", "ember-cli" or "ember-data" prefix).
@@ -76,7 +72,7 @@ export default class DocsHeader extends Component {
if (this.args.name) {
return this.args.name;
} else {
- let name = projectName;
+ let name = this.config.projectName;
name = name.replace('ember-data-', '');
name = name.replace('ember-cli-', '');
name = name.replace('ember-', '');
diff --git a/addon/components/docs-header/search-box/index.js b/addon/components/docs-header/search-box/index.js
index 7af46ca29..af4ab3279 100644
--- a/addon/components/docs-header/search-box/index.js
+++ b/addon/components/docs-header/search-box/index.js
@@ -1,9 +1,9 @@
import Component from '@glimmer/component';
import { task } from 'ember-concurrency';
-import { getOwner } from '@ember/application';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { formElementHasFocus } from 'ember-cli-addon-docs/keyboard-config';
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
export default class DocsHeaderSearchBox extends Component {
@service store;
@@ -11,16 +11,11 @@ export default class DocsHeaderSearchBox extends Component {
constructor() {
super(...arguments);
- const config =
- getOwner(this).resolveRegistration('config:environment')[
- 'ember-cli-addon-docs'
- ];
- const { projectName } = config;
-
- this.projectName = projectName;
this.fetchProject.perform();
}
+ @addonDocsConfig config;
+
// TODO: The searchbox doesn't work without the project being fetched.
// We should move this logic (and everywhere else in the code that's fetching
// the project) within a new addonDocs service that wires all that up together.
@@ -28,7 +23,7 @@ export default class DocsHeaderSearchBox extends Component {
// project.
@task
*fetchProject() {
- yield this.store.findRecord('project', this.projectName);
+ yield this.store.findRecord('project', this.config.projectName);
}
@action
diff --git a/addon/components/docs-header/search-results/index.js b/addon/components/docs-header/search-results/index.js
index 56bd1325e..d5fc6a875 100644
--- a/addon/components/docs-header/search-results/index.js
+++ b/addon/components/docs-header/search-results/index.js
@@ -4,7 +4,7 @@ import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { keyResponder, onKey } from 'ember-keyboard';
import { restartableTask } from 'ember-concurrency';
-import { getOwner } from '@ember/application';
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
@keyResponder
export default class DocsHeaderSearchResults extends Component {
@@ -15,23 +15,17 @@ export default class DocsHeaderSearchResults extends Component {
@tracked selectedIndex = null;
@tracked rawSearchResults = [];
+ @addonDocsConfig config;
+
constructor() {
super(...arguments);
- const config =
- getOwner(this).resolveRegistration('config:environment')[
- 'ember-cli-addon-docs'
- ];
- const { projectName } = config;
-
- this.projectName = projectName;
-
// Start downloading the search index immediately
this.docsSearch.loadSearchIndex();
}
get project() {
- return this.store.peekRecord('project', this.projectName);
+ return this.store.peekRecord('project', this.config.projectName);
}
get trimmedQuery() {
diff --git a/addon/components/docs-header/version-selector/index.hbs b/addon/components/docs-header/version-selector/index.hbs
index 15f274edd..20cb1ffb3 100644
--- a/addon/components/docs-header/version-selector/index.hbs
+++ b/addon/components/docs-header/version-selector/index.hbs
@@ -35,8 +35,8 @@
>
{{#if
(or
- (eq version.key this.latestVersionName)
- (eq version.key this.primaryBranch)
+ (eq version.key this.config.latestVersionName)
+ (eq version.key this.config.primaryBranch)
)
}}
{{svg-jar
@@ -51,8 +51,8 @@
{{#if
(or
- (eq version.key this.latestVersionName)
- (eq version.key this.primaryBranch)
+ (eq version.key this.config.latestVersionName)
+ (eq version.key this.config.primaryBranch)
)
}}
{{#if version.tag}}
diff --git a/addon/components/docs-header/version-selector/index.js b/addon/components/docs-header/version-selector/index.js
index 494b58ffa..1e2784729 100644
--- a/addon/components/docs-header/version-selector/index.js
+++ b/addon/components/docs-header/version-selector/index.js
@@ -3,31 +3,20 @@ import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';
import { action } from '@ember/object';
import { A } from '@ember/array';
-import { getOwner } from '@ember/application';
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
export default class VersionSelector extends Component {
@service projectVersion;
- constructor() {
- super(...arguments);
-
- const config =
- getOwner(this).resolveRegistration('config:environment')[
- 'ember-cli-addon-docs'
- ];
- this.latestVersionName = config.latestVersionName;
- this.primaryBranch = config.primaryBranch;
- }
+ @addonDocsConfig config;
@reads('projectVersion.currentVersion')
currentVersion;
get sortedVersions() {
- let latestVersionName = this.latestVersionName;
- let primaryBranch = this.primaryBranch;
let versions = A(this.projectVersion.versions);
- let latest = versions.findBy('key', latestVersionName);
- let primary = versions.findBy('key', primaryBranch);
+ let latest = versions.findBy('key', this.config.latestVersionName);
+ let primary = versions.findBy('key', this.config.primaryBranch);
let otherTags = versions
.reject((v) => [latest, primary].includes(v))
.sort((tagA, tagB) => {
diff --git a/addon/components/docs-hero/index.js b/addon/components/docs-hero/index.js
index 9a54ad611..c99511d3a 100644
--- a/addon/components/docs-hero/index.js
+++ b/addon/components/docs-hero/index.js
@@ -1,11 +1,10 @@
import Component from '@glimmer/component';
-import { tracked } from '@glimmer/tracking';
import {
addonPrefix,
unprefixedAddonName,
} from 'ember-cli-addon-docs/utils/computed';
-import { getOwner } from '@ember/application';
import { classify } from '@ember/string';
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
/**
A component that renders a hero banner. Useful for your docs site's homepage.
@@ -22,20 +21,7 @@ import { classify } from '@ember/string';
@public
*/
export default class DocsHeroComponent extends Component {
- @tracked projectDescription;
- @tracked projectName;
-
- constructor() {
- super(...arguments);
-
- const config =
- getOwner(this).resolveRegistration('config:environment')[
- 'ember-cli-addon-docs'
- ];
- const { projectDescription, projectName } = config;
- this.projectDescription = projectDescription;
- this.projectName = projectName;
- }
+ @addonDocsConfig config;
/**
The prefix to show, typically of: 'Ember', 'EmberCLI', or 'EmberData'
@@ -44,7 +30,7 @@ export default class DocsHeroComponent extends Component {
@type String
*/
get prefix() {
- return this.args.prefix ?? addonPrefix(this.projectName);
+ return this.args.prefix ?? addonPrefix(this.config.projectName);
}
/**
@@ -54,7 +40,10 @@ export default class DocsHeroComponent extends Component {
@type String
*/
get heading() {
- return this.args.heading ?? classify(unprefixedAddonName(this.projectName));
+ return (
+ this.args.heading ??
+ classify(unprefixedAddonName(this.config.projectName))
+ );
}
/**
@@ -64,6 +53,6 @@ export default class DocsHeroComponent extends Component {
@type String
*/
get byline() {
- return this.args.byline ?? this.projectDescription;
+ return this.args.byline ?? this.config.projectDescription;
}
}
diff --git a/addon/components/docs-viewer/x-main/index.js b/addon/components/docs-viewer/x-main/index.js
index 083757ccd..c6e57056f 100644
--- a/addon/components/docs-viewer/x-main/index.js
+++ b/addon/components/docs-viewer/x-main/index.js
@@ -4,8 +4,8 @@ import Component from '@glimmer/component';
import { bind } from '@ember/runloop';
import appFiles from 'ember-cli-addon-docs/app-files';
import addonFiles from 'ember-cli-addon-docs/addon-files';
-import config from 'ember-get-config';
import { getOwner } from '@ember/application';
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
const tagToSize = { H2: 'xxs', H3: 'xxs' };
const tagToIndent = { H2: '0', H3: '4' };
@@ -17,6 +17,8 @@ export default class XMain extends Component {
@service docsRoutes;
+ @addonDocsConfig config;
+
@action
setupElement(element) {
let target = element.querySelector('[data-current-page-index-target]');
@@ -64,7 +66,7 @@ export default class XMain extends Component {
let match = this._locateFile(path);
if (match) {
let { projectHref, addonPathInRepo, docsAppPathInRepo, primaryBranch } =
- config['ember-cli-addon-docs'];
+ this.config;
let parts = [projectHref, 'edit', primaryBranch];
if (match.inTree === 'addon') {
parts.push(addonPathInRepo);
@@ -81,7 +83,7 @@ export default class XMain extends Component {
_locateFile(path) {
path = path.replace(/\./g, '/');
if (path === 'docs/api/item') {
- let { projectName } = config['ember-cli-addon-docs'];
+ let { projectName } = this.config;
let model = getOwner(this)
.lookup('route:application')
.modelFor('docs.api.item');
diff --git a/addon/components/docs-viewer/x-nav/index.js b/addon/components/docs-viewer/x-nav/index.js
index fc962a68f..256b4bf61 100644
--- a/addon/components/docs-viewer/x-nav/index.js
+++ b/addon/components/docs-viewer/x-nav/index.js
@@ -2,13 +2,13 @@ import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { localCopy } from 'tracked-toolbox';
-import config from 'ember-get-config';
import { classify } from '@ember/string';
import { addonLogo } from 'ember-cli-addon-docs/utils/computed';
-
-const projectName = config['ember-cli-addon-docs'].projectName;
+import { addonDocsConfig } from 'ember-cli-addon-docs/-private/config';
export default class XNav extends Component {
+ @addonDocsConfig config;
+
@localCopy('args.root', 'docs')
root;
@@ -17,12 +17,14 @@ export default class XNav extends Component {
@tracked isShowingMenu;
- addonLogo = addonLogo(projectName);
+ get addonLogo() {
+ return addonLogo(this.config.projectName);
+ }
get addonTitle() {
let logo = this.addonLogo;
- return classify(projectName.replace(`${logo}-`, ''));
+ return classify(this.config.projectName.replace(`${logo}-`, ''));
}
get project() {
@@ -30,6 +32,6 @@ export default class XNav extends Component {
return this.args.project;
}
- return this.store.peekRecord('project', projectName);
+ return this.store.peekRecord('project', this.config.projectName);
}
}
diff --git a/addon/routes/docs.js b/addon/routes/docs.js
index 5b5e62f8e..bc3ac0637 100644
--- a/addon/routes/docs.js
+++ b/addon/routes/docs.js
@@ -1,13 +1,14 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
-import config from 'ember-get-config';
-
-const projectName = config['ember-cli-addon-docs'].projectName;
+import { getAddonDocsConfig } from 'ember-cli-addon-docs/-private/config';
export default class DocsRoute extends Route {
@service store;
model() {
- return this.store.findRecord('project', projectName);
+ return this.store.findRecord(
+ 'project',
+ getAddonDocsConfig(this).projectName
+ );
}
}
diff --git a/addon/services/docs-search.js b/addon/services/docs-search.js
index d08f2ac89..8e63b7e32 100644
--- a/addon/services/docs-search.js
+++ b/addon/services/docs-search.js
@@ -1,18 +1,19 @@
import Service from '@ember/service';
-import { getOwner } from '@ember/application';
import lunr from 'lunr';
-import config from 'ember-get-config';
import fetch from 'fetch';
import { enqueueTask } from 'ember-concurrency';
+import {
+ getAddonDocsConfig,
+ getRootURL,
+} from 'ember-cli-addon-docs/-private/config';
const { Index, Query } = lunr;
export default class DocsSearch extends Service {
async search(phrase) {
+ const { searchTokenSeparator } = getAddonDocsConfig(this);
let { index, documents } = await this.loadSearchIndex();
- let words = phrase
- .toLowerCase()
- .split(new RegExp(config['ember-cli-addon-docs'].searchTokenSeparator));
+ let words = phrase.toLowerCase().split(new RegExp(searchTokenSeparator));
let results = index.query((query) => {
// In the future we could boost results based on the field they come from
for (let word of words) {
@@ -105,8 +106,7 @@ export default class DocsSearch extends Service {
}
get _indexURL() {
- let config = getOwner(this).resolveRegistration('config:environment');
- return `${config.rootURL}ember-cli-addon-docs/search-index.json`;
+ return `${getRootURL(this)}ember-cli-addon-docs/search-index.json`;
}
}
diff --git a/addon/services/project-version.js b/addon/services/project-version.js
index 1f32e4689..269e7cc49 100644
--- a/addon/services/project-version.js
+++ b/addon/services/project-version.js
@@ -1,15 +1,17 @@
import Service from '@ember/service';
-import { getOwner } from '@ember/application';
import { task } from 'ember-concurrency';
-import config from 'ember-get-config';
import fetch from 'fetch';
import { tracked } from '@glimmer/tracking';
-
-const { latestVersionName } = config['ember-cli-addon-docs'];
+import {
+ addonDocsConfig,
+ getRootURL,
+} from 'ember-cli-addon-docs/-private/config';
export default class ProjectVersionService extends Service {
@tracked versions;
+ @addonDocsConfig config;
+
@task
*_loadAvailableVersions() {
let response = yield fetch(`${this.root}versions.json`);
@@ -17,7 +19,9 @@ export default class ProjectVersionService extends Service {
if (response.ok) {
json = yield response.json();
} else {
- json = { [latestVersionName]: Object.assign({}, this.currentVersion) };
+ json = {
+ [this.config.latestVersionName]: Object.assign({}, this.currentVersion),
+ };
}
this.versions = Object.keys(json).map((key) => {
@@ -38,9 +42,7 @@ export default class ProjectVersionService extends Service {
}
get root() {
- let rootURL =
- getOwner(this).resolveRegistration('config:environment').rootURL;
- return rootURL.replace(`/${this.currentVersion.path}/`, '/');
+ return getRootURL(this).replace(`/${this.currentVersion.path}/`, '/');
}
get currentVersion() {
@@ -48,18 +50,14 @@ export default class ProjectVersionService extends Service {
return this._currentVersion;
}
- let config =
- getOwner(this).resolveRegistration('config:environment')[
- 'ember-cli-addon-docs'
- ];
- let currentVersion = config.deployVersion;
+ let currentVersion = this.config.deployVersion;
// In development, this token won't have been replaced replaced
if (currentVersion === 'ADDON_DOCS_DEPLOY_VERSION') {
currentVersion = {
- key: latestVersionName,
- name: latestVersionName,
- tag: config?.projectTag,
+ key: this.config.latestVersionName,
+ name: this.config.latestVersionName,
+ tag: this.config.projectTag,
path: '',
sha: 'abcde',
};
diff --git a/package.json b/package.json
index a8567be6a..d34e4bbeb 100644
--- a/package.json
+++ b/package.json
@@ -60,7 +60,6 @@
"ember-composable-helpers": "^5.0.0",
"ember-concurrency": "^2.0.0",
"ember-fetch": "^8.1.1",
- "ember-get-config": "^1.0.0",
"ember-keyboard": "^7.0.1",
"ember-modal-dialog": "^4.0.0",
"ember-responsive": "^4.0.2",
diff --git a/tests/acceptance/sandbox/api/components-test.js b/tests/acceptance/sandbox/api/components-test.js
index d13301c67..a9d8ad170 100644
--- a/tests/acceptance/sandbox/api/components-test.js
+++ b/tests/acceptance/sandbox/api/components-test.js
@@ -2,7 +2,6 @@ import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { currentURL, visit } from '@ember/test-helpers';
-import config from 'ember-get-config';
import modulePage from '../../../pages/api/module';
@@ -44,12 +43,15 @@ module('Acceptance | Sandbox | API | components', function (hooks) {
module('in a nested directory within a repo', function (hooks) {
hooks.beforeEach(function () {
- config['ember-cli-addon-docs'].docsAppPathInRepo =
- 'packages/foo-bar/tests/dummy/app';
+ this.owner.resolveRegistration('config:environment')[
+ 'ember-cli-addon-docs'
+ ].docsAppPathInRepo = 'packages/foo-bar/tests/dummy/app';
});
hooks.afterEach(function () {
- config['ember-cli-addon-docs'].docsAppPathInRepo = '';
+ this.owner.resolveRegistration('config:environment')[
+ 'ember-cli-addon-docs'
+ ].docsAppPathInRepo = '';
});
test("welcome page 'Edit this page' link is correct", async function (assert) {
diff --git a/tests/dummy/mirage/config.js b/tests/dummy/mirage/config.js
index 02391c238..472a7a4dd 100644
--- a/tests/dummy/mirage/config.js
+++ b/tests/dummy/mirage/config.js
@@ -1,4 +1,4 @@
-import config from 'ember-get-config';
+import config from '../config/environment';
const projectTag = config['ember-cli-addon-docs']?.projectTag;
import { createServer } from 'miragejs';
diff --git a/yarn.lock b/yarn.lock
index 44dfb7002..d519eb787 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6818,7 +6818,7 @@ ember-fetch@^8.1.1:
node-fetch "^2.6.1"
whatwg-fetch "^3.6.2"
-"ember-get-config@0.2.4 - 0.5.0 || ^1.0.0", ember-get-config@^1.0.0:
+"ember-get-config@0.2.4 - 0.5.0 || ^1.0.0":
version "1.0.2"
resolved "https://registry.yarnpkg.com/ember-get-config/-/ember-get-config-1.0.2.tgz#f8349a132763008bad37d46d53c8250a0e18d464"
integrity sha512-G8sPknLvHEk0o8yrfs0+1WSeIPy1zOLxMJSm+ESYXy8MTnvxOFX127JSA7CcYmBq21GrDEIe0TL1Y+4cN9tEng==