@tryghost/mg-fs-utils 0.11.0 → 0.11.1
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/FileCache.js +9 -2
- package/lib/zip.js +6 -2
- package/package.json +2 -2
package/lib/FileCache.js
CHANGED
|
@@ -13,6 +13,8 @@ const knownImageExtensions = ['.jpg', '.jpeg', '.gif', '.png', '.svg', '.svgz',
|
|
|
13
13
|
|
|
14
14
|
class FileCache {
|
|
15
15
|
constructor(cacheName, options = {}) {
|
|
16
|
+
this.tmpPath = options.tmpPath || false;
|
|
17
|
+
|
|
16
18
|
this.originalName = cacheName;
|
|
17
19
|
this.options = Object.assign({contentDir: true}, options);
|
|
18
20
|
|
|
@@ -25,8 +27,13 @@ class FileCache {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
// This will be the path specified by `--tmpPath` if set. If not, it'll use a hidden tmp dir
|
|
31
|
+
get tmpDirPath() {
|
|
32
|
+
return this.tmpPath || os.tmpdir();
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
get cacheBaseDir() {
|
|
29
|
-
return path.join(
|
|
36
|
+
return path.join(this.tmpDirPath, basePath);
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
get cacheKey() {
|
|
@@ -54,7 +61,7 @@ class FileCache {
|
|
|
54
61
|
*/
|
|
55
62
|
get cacheDir() {
|
|
56
63
|
if (!this._cacheDir) {
|
|
57
|
-
this._cacheDir = path.join(
|
|
64
|
+
this._cacheDir = path.join(this.tmpDirPath, basePath, this.cacheKey);
|
|
58
65
|
fs.mkdirpSync(path.join(this.tmpDir));
|
|
59
66
|
|
|
60
67
|
// don't create the content directory when migrating members
|
package/lib/zip.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {join} from 'node:path';
|
|
2
2
|
import AdmZip from 'adm-zip';
|
|
3
|
+
import {ensureDirSync} from 'fs-extra';
|
|
3
4
|
import zip from '@tryghost/zip';
|
|
4
5
|
import errors from '@tryghost/errors';
|
|
5
6
|
|
|
@@ -43,7 +44,10 @@ const read = (zipPath, callback) => {
|
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
const write = async (zipPath, contentFolder, fileName) => {
|
|
46
|
-
|
|
47
|
+
// Ensure the directory we want to wite to exists
|
|
48
|
+
ensureDirSync(zipPath);
|
|
49
|
+
|
|
50
|
+
const outputPath = join(zipPath, fileName || `ghost-import-${Date.now()}.zip`);
|
|
47
51
|
|
|
48
52
|
return await zip.compress(contentFolder, outputPath);
|
|
49
53
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mg-fs-utils",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-fs-utils",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"sharp": "0.31.2",
|
|
37
37
|
"transliteration": "2.3.5"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "83d2a7e6b254a6d8b5c54b3b143b379276250b36"
|
|
40
40
|
}
|