adapt-authoring-ui 1.8.5 → 1.8.6
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.
- package/lib/CacheManager.js +7 -11
- package/lib/JavaScriptTask.js +2 -2
- package/lib/UiBuild.js +1 -1
- package/package.json +1 -1
package/lib/CacheManager.js
CHANGED
|
@@ -9,10 +9,11 @@ const ONE_HOUR = 60 * ONE_MINUTE
|
|
|
9
9
|
const ONE_WEEK = 7 * 24 * ONE_HOUR
|
|
10
10
|
|
|
11
11
|
export default class CacheManager {
|
|
12
|
-
constructor (maxAge = ONE_WEEK, logger
|
|
12
|
+
constructor ({ maxAge = ONE_WEEK, logger, tempDir } = {}) {
|
|
13
13
|
this.maxAge = maxAge
|
|
14
|
-
this.logger = logger
|
|
15
|
-
|
|
14
|
+
this.logger = logger ?? { log: (level, ...args) => console[level](...args) }
|
|
15
|
+
this.tempDir = tempDir ?? path.join(os.tmpdir(), 'adapt-authoring')
|
|
16
|
+
fs.ensureDirSync(this.tempDir)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
static hash (path) {
|
|
@@ -22,19 +23,14 @@ export default class CacheManager {
|
|
|
22
23
|
.digest('hex')
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
get tempPath () {
|
|
26
|
-
const tempPath = path.join(os.tmpdir(), 'adapt-authoring')
|
|
27
|
-
return tempPath
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
cachePath (basePath, outputFilePath = process.cwd()) {
|
|
31
27
|
const projectHash = CacheManager.hash(path.join(basePath, outputFilePath))
|
|
32
|
-
const cachePath = path.join(this.
|
|
28
|
+
const cachePath = path.join(this.tempDir, `${projectHash}.cache`)
|
|
33
29
|
return cachePath
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
get checkFilePath () {
|
|
37
|
-
const checkFilePath = path.join(this.
|
|
33
|
+
const checkFilePath = path.join(this.tempDir, 'last.touch')
|
|
38
34
|
return checkFilePath
|
|
39
35
|
}
|
|
40
36
|
|
|
@@ -52,7 +48,7 @@ export default class CacheManager {
|
|
|
52
48
|
await fs.writeFile(this.checkFilePath, String(Date.now()))
|
|
53
49
|
this.logger.log('debug', 'Clearing compilation cache')
|
|
54
50
|
// Fetch all cache files except checkFile
|
|
55
|
-
const files = await glob([`${this.
|
|
51
|
+
const files = await glob([`${this.tempDir}/**`, `!${this.checkFilePath}`], { nodir: true })
|
|
56
52
|
// Fetch file ages
|
|
57
53
|
const fileAges = []
|
|
58
54
|
const now = Date.now()
|
package/lib/JavaScriptTask.js
CHANGED
|
@@ -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, uiPlugins) {
|
|
15
|
+
constructor (buildDir, logFunc, uiPlugins, tempDir) {
|
|
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,7 +20,7 @@ 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({ logger: { log: this.log } })
|
|
23
|
+
this.cacheManager = new CacheManager({ logger: { log: this.log }, tempDir })
|
|
24
24
|
this.resolvedNodeModules = {}
|
|
25
25
|
this.resolvedNodeModulesPaths = []
|
|
26
26
|
|
package/lib/UiBuild.js
CHANGED
|
@@ -60,7 +60,7 @@ class UiBuild {
|
|
|
60
60
|
this.preBuildHook = new Hook()
|
|
61
61
|
this.postBuildHook = new Hook()
|
|
62
62
|
|
|
63
|
-
this.jsTask = new JavaScriptTask(this.Paths.Output, this.log, this.uiPlugins)
|
|
63
|
+
this.jsTask = new JavaScriptTask(this.Paths.Output, this.log, this.uiPlugins, this.app.getConfig('tempDir'))
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
collate (collateAtFolderName, destFolder, srcFileName) {
|
package/package.json
CHANGED