adapt-authoring-adaptframework 1.7.0 → 1.8.0

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.
@@ -19,9 +19,7 @@ class AdaptFrameworkBuild {
19
19
  * @return {Promise} Resolves to this AdaptFrameworkBuild instance
20
20
  */
21
21
  static async run (options) {
22
- const instance = new AdaptFrameworkBuild(options)
23
- await instance.build()
24
- return instance
22
+ return new AdaptFrameworkBuild(options).build()
25
23
  }
26
24
 
27
25
  /**
@@ -229,6 +227,8 @@ class AdaptFrameworkBuild {
229
227
  await this.postBuildHook.invoke(this)
230
228
 
231
229
  this.buildData = await this.recordBuildAttempt()
230
+
231
+ return this
232
232
  }
233
233
 
234
234
  /**
@@ -166,6 +166,11 @@ class AdaptFrameworkImport {
166
166
  info: [],
167
167
  warn: []
168
168
  }
169
+ /**
170
+ * Summary information for the import run
171
+ * @type {AdaptFrameworkImportSummary}
172
+ */
173
+ this.summary = undefined
169
174
  /**
170
175
  * User-defined settings related to what is included with the import
171
176
  * @type {Object}
@@ -249,7 +254,7 @@ class AdaptFrameworkImport {
249
254
  [this.prepare],
250
255
  [this.loadAssetData],
251
256
  [this.loadPluginData],
252
- [() => this.preImportHook.invoke(this), true],
257
+ [() => this.preImportHook.invoke(this)],
253
258
  [this.importTags, importContent],
254
259
  [this.importCourseAssets, importContent],
255
260
  [this.importCoursePlugins, isDryRun && importPlugins],
@@ -257,7 +262,8 @@ class AdaptFrameworkImport {
257
262
  [this.loadCourseData, isDryRun && importContent],
258
263
  [this.migrateCourseData, !isDryRun && importContent],
259
264
  [this.loadCourseData, !isDryRun && importContent],
260
- [this.importCourseData, !isDryRun && importContent]
265
+ [this.importCourseData, !isDryRun && importContent],
266
+ [this.generateSummary]
261
267
  ]
262
268
  for (const [func, test] of tasks) {
263
269
  if (test === true || test === undefined) await func.call(this)
@@ -793,6 +799,15 @@ class AdaptFrameworkImport {
793
799
  })
794
800
  }
795
801
 
802
+ /**
803
+ * Performs necessary clean-up tasks
804
+ * @param {Error|Boolean} error If param is truthy, extra error-related clean-up tasks are performed
805
+ * @return {Promise}
806
+ */
807
+ async generateSummary () {
808
+ this.summary = await FWUtils.getImportSummary(this)
809
+ }
810
+
796
811
  /**
797
812
  * Performs necessary clean-up tasks
798
813
  * @param {Error|Boolean} error If param is truthy, extra error-related clean-up tasks are performed
@@ -308,9 +308,10 @@ class AdaptFrameworkModule extends AbstractModule {
308
308
  * @return {AdaptFrameworkBuild}
309
309
  */
310
310
  async buildCourse (options) {
311
- const builder = AdaptFrameworkBuild.run(options)
311
+ const builder = new AdaptFrameworkBuild(options)
312
312
  builder.preBuildHook.tap(() => this.preBuildHook.invoke(builder))
313
313
  builder.postBuildHook.tap(() => this.postBuildHook.invoke(builder))
314
+ return builder.build()
314
315
  }
315
316
 
316
317
  /**
@@ -319,10 +320,10 @@ class AdaptFrameworkModule extends AbstractModule {
319
320
  * @return {AdaptFrameworkImportSummary}
320
321
  */
321
322
  async importCourse (options) {
322
- const importer = await AdaptFrameworkImport.run(options)
323
+ const importer = new AdaptFrameworkImport(options)
323
324
  importer.preImportHook.tap(() => this.preImportHook.invoke(importer))
324
325
  importer.postImportHook.tap(() => this.postImportHook.invoke(importer))
325
- return await FWUtils.getImportSummary(importer)
326
+ return importer.import()
326
327
  }
327
328
  }
328
329
 
@@ -287,8 +287,7 @@ class AdaptFrameworkUtils {
287
287
  migrateContent: AdaptFrameworkUtils.toBoolean(req.body.migrateContent),
288
288
  updatePlugins: AdaptFrameworkUtils.toBoolean(req.body.updatePlugins)
289
289
  })
290
- const summary = await AdaptFrameworkUtils.getImportSummary(importer)
291
- res.json(summary)
290
+ res.json(importer.summary)
292
291
  } catch (e) {
293
292
  return next(App.instance.errors.FW_IMPORT_FAILED.setData({ error: e }))
294
293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-adaptframework",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
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",