adapt-authoring-core 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,6 @@ export default class CoreModules {
30
30
  const badges = await this.getWorkflowBadges(homepage)
31
31
  return `| ${homepage ? `[${name}](${homepage})` : name} | ${version} | ${description} | ${badges.join('<br>')} |`
32
32
  }))
33
- return `| Name | Version | Description | Status |\n| - | :-: | - | :-: |\n${rows.join('\n')}`
33
+ return `| Name | Version | Description | Status |\n| - | :-: | - | - |\n${rows.join('\n')}`
34
34
  }
35
35
  }
@@ -131,6 +131,7 @@ class DependencyLoader {
131
131
  ...pkg,
132
132
  ...await fs.readJson(path.join(modDir, metadataFileName)),
133
133
  name: stripScope(pkg.name),
134
+ packageName: pkg.name,
134
135
  rootDir: modDir
135
136
  }
136
137
  }
@@ -150,7 +151,7 @@ class DependencyLoader {
150
151
  if (config.module === false) {
151
152
  return
152
153
  }
153
- const { default: ModClass } = await import(modName)
154
+ const { default: ModClass } = await import(config.packageName)
154
155
 
155
156
  if (!_.isFunction(ModClass)) {
156
157
  throw new Error('Expected class to be exported')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-core",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "A bundle of reusable 'core' functionality",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-core",
6
6
  "license": "GPL-3.0",
@@ -306,6 +306,36 @@ describe('DependencyLoader', () => {
306
306
 
307
307
  assert.equal(config.rootDir, testModuleDir)
308
308
  })
309
+
310
+ it('should store original package name as packageName', async () => {
311
+ const mockApp = { rootDir: '/test' }
312
+ const loader = new DependencyLoader(mockApp)
313
+
314
+ const config = await loader.loadModuleConfig(testModuleDir)
315
+
316
+ assert.equal(config.packageName, 'test-module')
317
+ })
318
+
319
+ it('should preserve scoped package name in packageName while stripping scope from name', async () => {
320
+ const scopedDir = path.join(__dirname, 'data', 'scoped-module')
321
+ await fs.ensureDir(scopedDir)
322
+ await fs.writeJson(path.join(scopedDir, 'package.json'), {
323
+ name: '@cgkineo/adapt-authoring-test',
324
+ version: '1.0.0'
325
+ })
326
+ await fs.writeJson(path.join(scopedDir, 'adapt-authoring.json'), {
327
+ module: true
328
+ })
329
+
330
+ const mockApp = { rootDir: '/test' }
331
+ const loader = new DependencyLoader(mockApp)
332
+ const config = await loader.loadModuleConfig(scopedDir)
333
+
334
+ assert.equal(config.name, 'adapt-authoring-test')
335
+ assert.equal(config.packageName, '@cgkineo/adapt-authoring-test')
336
+
337
+ await fs.remove(scopedDir)
338
+ })
309
339
  })
310
340
 
311
341
  describe('#loadModules()', () => {