@tryghost/mg-fs-utils 0.12.4 → 0.12.5

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/index.js CHANGED
@@ -3,11 +3,13 @@ import zip from './lib/zip.js';
3
3
  import {readZipEntries} from './lib/read-zip.js';
4
4
  import ghostJSON from './lib/ghostJSON.js';
5
5
  import csv from './lib/csv.js';
6
+ import * as utils from './lib/utils.js';
6
7
 
7
8
  export default {
8
9
  FileCache,
9
10
  zip,
10
11
  ghostJSON,
11
12
  csv,
12
- readZipEntries
13
+ readZipEntries,
14
+ utils
13
15
  };
package/lib/FileCache.js CHANGED
@@ -9,6 +9,7 @@ import imageTransform from '@tryghost/image-transform';
9
9
  import errors from '@tryghost/errors';
10
10
  import transliterate from 'transliteration';
11
11
  import csv from './csv.js';
12
+ import {cacheNameFromPath} from './utils.js';
12
13
 
13
14
  const basePath = 'mg';
14
15
  const knownImageExtensions = ['.jpg', '.jpeg', '.gif', '.png', '.svg', '.svgz', '.ico', 'webp'];
@@ -21,8 +22,7 @@ class FileCache {
21
22
  this.options = Object.assign({contentDir: true}, options);
22
23
 
23
24
  // Remove any extension, handles removing TLDs as well if the name is based on a URL
24
- let ext = extname(cacheName);
25
- this.cacheName = basename(cacheName, ext);
25
+ this.cacheName = cacheNameFromPath(cacheName);
26
26
 
27
27
  if (options.batchName) {
28
28
  this.batchName = options.batchName;
package/lib/utils.js ADDED
@@ -0,0 +1,15 @@
1
+ import {extname, basename} from 'node:path';
2
+ import {slugify} from '@tryghost/string';
3
+
4
+ const cacheNameFromPath = (path) => {
5
+ let ext = extname(path);
6
+ let base = basename(path, ext);
7
+ let slug = slugify(base);
8
+ let noUnderscore = slug.replace(/_/g, '-');
9
+
10
+ return noUnderscore;
11
+ };
12
+
13
+ export {
14
+ cacheNameFromPath
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mg-fs-utils",
3
- "version": "0.12.4",
3
+ "version": "0.12.5",
4
4
  "repository": "https://github.com/TryGhost/migrate/tree/main/packages/mg-fs-utils",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -27,6 +27,7 @@
27
27
  "dependencies": {
28
28
  "@tryghost/errors": "1.2.20",
29
29
  "@tryghost/image-transform": "1.2.3",
30
+ "@tryghost/string": "0.2.3",
30
31
  "@tryghost/zip": "1.1.32",
31
32
  "adm-zip": "0.5.10",
32
33
  "csv-parse": "5.3.6",
@@ -37,5 +38,5 @@
37
38
  "sharp": "0.31.3",
38
39
  "transliteration": "2.3.5"
39
40
  },
40
- "gitHead": "9a613a18b22c794c0e3eed734c4b6963e905f68d"
41
+ "gitHead": "1cf2e5fd70c7275c24eb956d13cbaabdde17eddb"
41
42
  }