adapt-authoring-adaptframework 2.0.3 → 2.0.4

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.
@@ -661,40 +661,41 @@ class AdaptFrameworkImport {
661
661
  throw App.instance.errors.FW_IMPORT_MISSING_PLUGINS
662
662
  .setData({ plugins: pluginsToInstall.join(', ') })
663
663
  }
664
- const errors = []
665
- await Promise.all([...pluginsToInstall, ...pluginsToUpdate].map(async p => {
664
+ const allPlugins = [...pluginsToInstall, ...pluginsToUpdate]
665
+ // pre-process: store update metadata and fix missing targetAttributes
666
+ for (const p of allPlugins) {
667
+ const isUpdate = pluginsToUpdate.includes(p)
668
+ if (isUpdate && this.installedPlugins[p]) {
669
+ this.updatedContentPlugins[p] = this.installedPlugins[p]
670
+ }
671
+ const pluginBowerPath = path.join(this.usedContentPlugins[p].path, 'bower.json')
672
+ const bowerJson = await readJson(pluginBowerPath)
673
+ if (!bowerJson.targetAttribute) {
674
+ bowerJson.targetAttribute = `_${bowerJson.component || bowerJson.extension || bowerJson.menu || bowerJson.theme}`
675
+ await writeJson(pluginBowerPath, bowerJson)
676
+ }
677
+ this.statusReport.info.push({ code: 'INSTALL_PLUGIN', data: { name: p, version: bowerJson.version } })
678
+ }
679
+ if (!this.settings.isDryRun) {
666
680
  try {
667
- // Store original plugin metadata for updates before overwriting
668
- const isUpdate = pluginsToUpdate.includes(p)
669
- if (isUpdate && this.installedPlugins[p]) {
670
- this.updatedContentPlugins[p] = this.installedPlugins[p]
671
- }
672
- // try and infer a targetAttribute if there isn't one
673
- const pluginBowerPath = path.join(this.usedContentPlugins[p].path, 'bower.json')
674
- const bowerJson = await readJson(pluginBowerPath)
675
- if (!bowerJson.targetAttribute) {
676
- bowerJson.targetAttribute = `_${bowerJson.component || bowerJson.extension || bowerJson.menu || bowerJson.theme}`
677
- await writeJson(pluginBowerPath, bowerJson)
678
- }
679
- if (!this.settings.isDryRun) {
680
- const [pluginData] = await this.contentplugin.installPlugins([[p, this.usedContentPlugins[p].path]], { strict: true })
681
- if (!isUpdate) {
682
- this.newContentPlugins[p] = pluginData
681
+ const installed = await this.contentplugin.installPlugins(
682
+ allPlugins.map(p => [p, this.usedContentPlugins[p].path]),
683
+ { strict: true }
684
+ )
685
+ installed.forEach(pluginData => {
686
+ if (!pluginsToUpdate.includes(pluginData.name)) {
687
+ this.newContentPlugins[pluginData.name] = pluginData
683
688
  }
684
- }
685
- this.statusReport.info.push({ code: 'INSTALL_PLUGIN', data: { name: p, version: bowerJson.version } })
689
+ })
686
690
  } catch (e) {
687
- if (e.code === 'EEXIST') {
688
- log('warn', 'PLUGIN_ALREADY_EXISTS', p)
689
- } else {
690
- log('error', 'PLUGIN_IMPORT_FAILED', p, e)
691
- errors.push({ plugin: p, error: e.data?.errors?.[0] ?? e })
692
- }
691
+ const errors = e.data?.errors?.map(err => ({
692
+ plugin: err.data?.name ?? 'unknown',
693
+ error: err.data?.errors?.[0] ?? err
694
+ })) ?? [{ plugin: 'unknown', error: e }]
695
+ errors.forEach(err => log('error', 'PLUGIN_IMPORT_FAILED', err.plugin, err.error))
696
+ throw App.instance.errors.FW_IMPORT_PLUGINS_FAILED
697
+ .setData({ errors: errors.map(e => App.instance.lang.translate(undefined, e)).join(', ') })
693
698
  }
694
- }))
695
- if (errors.length) {
696
- throw App.instance.errors.FW_IMPORT_PLUGINS_FAILED
697
- .setData({ errors: errors.map(e => App.instance.lang.translate(undefined, e)).join(', ') })
698
699
  }
699
700
  }
700
701
  this.componentNameMap = Object.values({ ...this.installedPlugins, ...this.newContentPlugins }).reduce((m, v) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-adaptframework",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Adapt framework integration for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-adaptframework",
6
6
  "license": "GPL-3.0",