adapt-authoring-ui 1.1.0 → 1.2.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.
@@ -12,7 +12,7 @@ import { deflate, unzip, constants } from 'zlib'
12
12
  import { globSync } from 'glob'
13
13
 
14
14
  export default class JavaScriptTask {
15
- constructor (buildDir, logFunc) {
15
+ constructor (buildDir, logFunc, uiPlugins) {
16
16
  this.log = logFunc ?? ((level, ...args) => console.log(level.toUpperCase(), ...args))
17
17
  this.convertSlashes = /\\/g
18
18
  this.cwd = process.cwd().replace(this.convertSlashes, '/') + '/'
@@ -20,19 +20,18 @@ export default class JavaScriptTask {
20
20
  this.isFirstRun = true
21
21
  this.cache = null
22
22
  this.extensions = ['.js', '.jsx']
23
- this.cacheManager = new CacheManager()
23
+ this.cacheManager = new CacheManager({ logger: { log: this.log } })
24
24
  this.resolvedNodeModules = {}
25
25
  this.resolvedNodeModulesPaths = []
26
26
 
27
27
  this.buildConfig = {
28
28
  }
29
29
 
30
- const packagesWithUiPlugin = globSync('node_modules/adapt-authoring-*/ui-plugins/')
31
- const packageJsons = globSync(packagesWithUiPlugin.map(p => path.join(path.dirname(p), 'package.json')))
30
+ const packageJsons = globSync(uiPlugins.map(p => path.join(path.dirname(p), 'package.json')))
32
31
  const uiPluginDeps = packageJsons.reduce((arr, p) => {
33
32
  const packageJson = fs.readJSONSync(p)
34
33
  if (!packageJson.dependencies) return arr
35
- return arr.concat(Object.keys(packageJson.dependencies))
34
+ return arr.concat(Object.keys(packageJson.dependencies).filter(k => !k.startsWith('adapt-authoring-')))
36
35
  }, [])
37
36
 
38
37
  this.options = {
@@ -42,6 +41,7 @@ export default class JavaScriptTask {
42
41
  out: path.join(buildDir, 'js', 'adapt.min.js'),
43
42
  modulesGlob: 'node_modules/adapt-authoring-ui/app/modules/*/index.js',
44
43
  pluginsGlob: 'node_modules/adapt-authoring-*/ui-plugins/*/index.js',
44
+ pluginsDirs: uiPlugins,
45
45
  pluginsOrder: files => files,
46
46
  external: {
47
47
  jquery: 'empty:',
@@ -145,12 +145,14 @@ export default class JavaScriptTask {
145
145
  })
146
146
  }
147
147
 
148
+ /* this throws an error
148
149
  findNodeModule = (cwd, baseUrl, moduleId) => {
149
150
  if (this.resolvedNodeModules[moduleId]) return this.resolvedNodeModules[moduleId]
150
151
  const resolved = this.resolvedNodeModules[moduleId] = resolve.sync(moduleId, { basedir: path.resolve(cwd, baseUrl) })
151
152
  if (resolved) this.resolvedNodeModulesPaths.push(path.normalize(resolved))
152
153
  return resolved
153
154
  }
155
+ */
154
156
 
155
157
  logPrettyError (err, cachePath, basePath) {
156
158
  let hasOutput = false
@@ -187,7 +189,7 @@ export default class JavaScriptTask {
187
189
  const cachePath = this.buildConfig.cachepath ?? this.cacheManager.cachePath(cwd, options.out)
188
190
  const isSourceMapped = Boolean(options.generateSourceMaps)
189
191
  const basePath = path.resolve(cwd + '/' + options.baseUrl).replace(this.convertSlashes, '/') + '/'
190
- const findNodeModule = this.findNodeModule
192
+ // const findNodeModule = this.findNodeModule
191
193
  const resolvedNodeModulesPaths = this.resolvedNodeModulesPaths
192
194
  let resolveCount = 0
193
195
 
@@ -201,7 +203,7 @@ export default class JavaScriptTask {
201
203
  }
202
204
  })
203
205
 
204
- const plugins = globSync(this.options.pluginsGlob).map(entry => {
206
+ const plugins = this.options.pluginsDirs.map(entry => {
205
207
  return {
206
208
  name: path.basename(path.dirname(entry)),
207
209
  main: path.basename(entry),
@@ -288,8 +290,8 @@ export default class JavaScriptTask {
288
290
  // Resolve node modules
289
291
  if (
290
292
  isNodeResolved ||
291
- isImportedByNodeModule ||
292
- (!moduleId.includes('adapt-') && findNodeModule(cwd, options.baseUrl, moduleId))
293
+ isImportedByNodeModule /*|| @note resolve undefined
294
+ (!moduleId.includes('adapt-') && findNodeModule(cwd, options.baseUrl, moduleId))*/
293
295
  ) {
294
296
  return null
295
297
  }
package/lib/UiBuild.js CHANGED
@@ -9,11 +9,12 @@ import chalk from 'chalk'
9
9
  import JavaScriptTask from './JavaScriptTask.js'
10
10
 
11
11
  class UiBuild {
12
- constructor ({ app, log, isDev, buildDir, enableWatch }) {
12
+ constructor ({ app, log, isDev, buildDir, enableWatch, uiPlugins }) {
13
13
  this.app = app
14
14
  this.log = log
15
15
  this.isDev = isDev
16
16
  this.enableWatch = enableWatch
17
+ this.uiPlugins = uiPlugins
17
18
 
18
19
  const outputDir = buildDir.replaceAll('\\', '/')
19
20
 
@@ -61,7 +62,7 @@ class UiBuild {
61
62
  this.preBuildHook = new Hook()
62
63
  this.postBuildHook = new Hook()
63
64
 
64
- this.jsTask = new JavaScriptTask(this.Paths.Output, this.log)
65
+ this.jsTask = new JavaScriptTask(this.Paths.Output, this.log, this.uiPlugins)
65
66
  }
66
67
 
67
68
  collate (collateAtFolderName, destFolder, srcFileName) {
@@ -152,7 +153,7 @@ class UiBuild {
152
153
  isCore ? sorted[0].push(f) : sorted[1].push(f)
153
154
  return sorted
154
155
  }, [[], []])
155
- const lessImports = [...core, ...theRest].reduce((s, p) => `${s}@import '${p}';\n`, '')
156
+ const lessImports = [...core.sort(), ...theRest.sort()].reduce((s, p) => `${s}@import '${p}';\n`, '')
156
157
  const { css, map } = await less.render(lessImports, lessOptions)
157
158
 
158
159
  try {
package/lib/UiModule.js CHANGED
@@ -80,7 +80,8 @@ class UiModule extends AbstractModule {
80
80
  log: this.log.bind(this),
81
81
  isDev: !this.isProduction,
82
82
  buildDir: this.buildDir,
83
- enableWatch: this.app.args.w || this.app.args.watch
83
+ enableWatch: this.app.args.w || this.app.args.watch,
84
+ uiPlugins: this.uiPlugins
84
85
  })
85
86
  build.preBuildHook.tap(() => this.preBuildHook.invoke(build))
86
87
  build.postBuildHook.tap(() => this.postBuildHook.invoke(build))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Front-end application for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
6
  "license": "GPL-3.0",