diff --git a/ghost/core/core/server/data/importer/import-manager.js b/ghost/core/core/server/data/importer/import-manager.js index f6cd379f27..11ba7c1734 100644 --- a/ghost/core/core/server/data/importer/import-manager.js +++ b/ghost/core/core/server/data/importer/import-manager.js @@ -11,7 +11,7 @@ const debug = require('@tryghost/debug')('import-manager'); const logging = require('@tryghost/logging'); const errors = require('@tryghost/errors'); const ImageHandler = require('./handlers/image'); -const MediaHandler = require('@tryghost/importer-handler-media'); +const MediaHandler = require('@tryghost/importer-handler-content-files'); const RevueHandler = require('./handlers/revue'); const JSONHandler = require('./handlers/json'); const MarkdownHandler = require('./handlers/markdown'); diff --git a/ghost/core/package.json b/ghost/core/package.json index bcd2653858..bcda877f76 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -88,7 +88,7 @@ "@tryghost/html-to-plaintext": "0.0.0", "@tryghost/http-cache-utils": "0.1.7", "@tryghost/image-transform": "1.2.3", - "@tryghost/importer-handler-media": "0.0.0", + "@tryghost/importer-handler-content-files": "0.0.0", "@tryghost/importer-revue": "0.0.0", "@tryghost/job-manager": "0.0.0", "@tryghost/kg-card-factory": "4.0.4", diff --git a/ghost/importer-handler-media/.eslintrc.js b/ghost/importer-handler-content-files/.eslintrc.js similarity index 100% rename from ghost/importer-handler-media/.eslintrc.js rename to ghost/importer-handler-content-files/.eslintrc.js diff --git a/ghost/importer-handler-media/README.md b/ghost/importer-handler-content-files/README.md similarity index 90% rename from ghost/importer-handler-media/README.md rename to ghost/importer-handler-content-files/README.md index c3f7208ef7..3745d3a268 100644 --- a/ghost/importer-handler-media/README.md +++ b/ghost/importer-handler-content-files/README.md @@ -1,6 +1,6 @@ # Importer Media -Media content importer +Importer content file handler ## Usage diff --git a/ghost/importer-handler-content-files/index.js b/ghost/importer-handler-content-files/index.js new file mode 100644 index 0000000000..53e5aa0d27 --- /dev/null +++ b/ghost/importer-handler-content-files/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/ImporterContentFileHandler'); diff --git a/ghost/importer-handler-media/lib/ImporterMediaHandler.js b/ghost/importer-handler-content-files/lib/ImporterContentFileHandler.js similarity index 96% rename from ghost/importer-handler-media/lib/ImporterMediaHandler.js rename to ghost/importer-handler-content-files/lib/ImporterContentFileHandler.js index b766d4ed91..e925773a9f 100644 --- a/ghost/importer-handler-media/lib/ImporterMediaHandler.js +++ b/ghost/importer-handler-content-files/lib/ImporterContentFileHandler.js @@ -1,7 +1,7 @@ const _ = require('lodash'); const path = require('path'); -class ImporterMediaHandler { +class ImporterContentFileHandler { /** * * @param {Object} deps dependencies @@ -69,4 +69,4 @@ class ImporterMediaHandler { } } -module.exports = ImporterMediaHandler; +module.exports = ImporterContentFileHandler; diff --git a/ghost/importer-handler-media/package.json b/ghost/importer-handler-content-files/package.json similarity index 88% rename from ghost/importer-handler-media/package.json rename to ghost/importer-handler-content-files/package.json index cfdc2303f9..3a390e81b3 100644 --- a/ghost/importer-handler-media/package.json +++ b/ghost/importer-handler-content-files/package.json @@ -1,7 +1,7 @@ { - "name": "@tryghost/importer-handler-media", + "name": "@tryghost/importer-handler-content-files", "version": "0.0.0", - "repository": "https://github.com/TryGhost/Ghost/tree/main/packages/importer-handler-media", + "repository": "https://github.com/TryGhost/Ghost/tree/main/packages/importer-handler-content-files", "author": "Ghost Foundation", "private": true, "main": "index.js", diff --git a/ghost/importer-handler-media/test/.eslintrc.js b/ghost/importer-handler-content-files/test/.eslintrc.js similarity index 100% rename from ghost/importer-handler-media/test/.eslintrc.js rename to ghost/importer-handler-content-files/test/.eslintrc.js diff --git a/ghost/importer-handler-media/test/ImporterMediaHandler.test.js b/ghost/importer-handler-content-files/test/ImporterContentFileHandler.test.js similarity index 79% rename from ghost/importer-handler-media/test/ImporterMediaHandler.test.js rename to ghost/importer-handler-content-files/test/ImporterContentFileHandler.test.js index ab25b41b6a..7d82388743 100644 --- a/ghost/importer-handler-media/test/ImporterMediaHandler.test.js +++ b/ghost/importer-handler-content-files/test/ImporterContentFileHandler.test.js @@ -1,21 +1,21 @@ const assert = require('assert'); const sinon = require('sinon'); -const ImporterMedia = require('../index'); +const ImporterContentFileHandler = require('../index'); -describe('ImporterMediaHandler', function () { +describe('ImporterContentFileHandler', function () { it('creates an instance', function () { - const mediaImporter = new ImporterMedia({ + const contentFileImporter = new ImporterContentFileHandler({ storage: {}, config: {}, urlUtils: {} }); - assert.ok(mediaImporter); - assert.equal(mediaImporter.type, 'media'); + assert.ok(contentFileImporter); + assert.equal(contentFileImporter.type, 'media'); }); it('returns configured extensions', function () { - const mediaImporter = new ImporterMedia({ + const contentFileImporter = new ImporterContentFileHandler({ storage: {}, config: { get: () => ({ @@ -27,11 +27,11 @@ describe('ImporterMediaHandler', function () { urlUtils: {} }); - assert.deepEqual(mediaImporter.extensions, ['mp4']); + assert.deepEqual(contentFileImporter.extensions, ['mp4']); }); it('returns configured contentTypes', function () { - const mediaImporter = new ImporterMedia({ + const contentFileImporter = new ImporterContentFileHandler({ storage: {}, config: { get: () => ({ @@ -43,7 +43,7 @@ describe('ImporterMediaHandler', function () { urlUtils: {} }); - assert.deepEqual(mediaImporter.contentTypes, ['video/mp4']); + assert.deepEqual(contentFileImporter.contentTypes, ['video/mp4']); }); // @NOTE: below tests need more work, they are just covering the basics @@ -51,7 +51,7 @@ describe('ImporterMediaHandler', function () { // from the image importer and the tests were adapted to the media importer describe('loadFile', function () { it('loads files and decorates them with newPath with subdirectory', async function () { - const mediaImporter = new ImporterMedia({ + const contentFileImporter = new ImporterContentFileHandler({ storage: { staticFileURLPrefix: 'content/media', getUniqueFileName: (file, targetDir) => Promise.resolve(targetDir + '/' + file.name) @@ -72,7 +72,7 @@ describe('ImporterMediaHandler', function () { }]; const subDir = 'blog'; - await mediaImporter.loadFile(files, subDir); + await contentFileImporter.loadFile(files, subDir); assert.equal(files[0].name, '1.mp4'); assert.equal(files[0].originalPath, 'content/media/1.mp4'); @@ -81,7 +81,7 @@ describe('ImporterMediaHandler', function () { }); it('loads files and decorates them with newPath with NO subdirectory', async function () { - const mediaImporter = new ImporterMedia({ + const contentFileImporter = new ImporterContentFileHandler({ storage: { staticFileURLPrefix: 'content/media', getUniqueFileName: (file, targetDir) => Promise.resolve(targetDir + '/' + file.name) @@ -101,7 +101,7 @@ describe('ImporterMediaHandler', function () { name: 'content/media/1.mp4' }]; - await mediaImporter.loadFile(files); + await contentFileImporter.loadFile(files); assert.equal(files[0].name, '1.mp4'); assert.equal(files[0].originalPath, 'content/media/1.mp4'); diff --git a/ghost/importer-handler-media/index.js b/ghost/importer-handler-media/index.js deleted file mode 100644 index bdf47f9ad3..0000000000 --- a/ghost/importer-handler-media/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/ImporterMediaHandler');