Need help with build logic for Ember Addon

Hey everyone. I was wondering if someone could give me advice on adding things to my addon tree (from other addons and apps).

This is what I want to do (need help for step 2: BUILD PROCESS):

1. DEFINE MOCKERS

// my-app/mockers/rest-mocker.js
import MswMocker from 'ember-mocking/mockers/msw';
  
export default class SomeRestMocker extends MswMocker {
  handlers = [
    this.rest.get('/some-api-endpoint', (req, res, ctx) => {
      return res(ctx.status(200), ctx.text("Hello World!"))
    });
  ];
}

2. BUILD PROCESS (index.js, broccoli plugin…?)

Add all mockers from apps and addons to the addon tree (treeForAddon)

Example

INPUT OUTPUT
my-app/mockers/rest-mocker.js ember-mocking/mockers/rest-mocker.js
some-addon/mockers/socket-mocker.js ember-mocking/mockers/some-addon/socket-mocker.js
some-addon/mockers/rest-mocker.js ember-mocking/mockers/some-addon/rest-mocker.js
another-addon/mockers/storage-mocker.js ember-mocking/mockers/another-addon/storage-mocker.js

QUESTIONS:

  • How can we build the mockers directory in the addon tree?
  • Is it possible to use TypeScript in these mocker files?

3. LIST ALL MODULES (initializer)

Get an array of all modules the mockers folder of the addon tree (aka ember-mocking/mockers)

Example

const mockerModules = [
  'ember-mocking/mockers/rest-mocker.js',
  'ember-mocking/mockers/some-addon/socket-mocker.js',
  'ember-mocking/mockers/some-addon/rest-mocker.js',
  'ember-mocking/mockers/another-addon/storage-mocker.js',
]

4. CREATE INSTANCES (initializer)

Create an instance of each mocker and register it in the container

for (const module of mockerModules) {
  const mockerClass = require(module);
  ...
}