diff --git a/ghost/core/core/server/api/endpoints/oembed.js b/ghost/core/core/server/api/endpoints/oembed.js index f04ee161d2..f9ac28de36 100644 --- a/ghost/core/core/server/api/endpoints/oembed.js +++ b/ghost/core/core/server/api/endpoints/oembed.js @@ -1,7 +1,7 @@ const config = require('../../../shared/config'); const externalRequest = require('../../lib/request-external'); -const OEmbed = require('../../services/oembed'); +const OEmbed = require('@tryghost/oembed-service'); const oembed = new OEmbed({config, externalRequest}); const NFT = require('../../services/nft-oembed'); diff --git a/ghost/core/package.json b/ghost/core/package.json index 493048aef5..5fdb8a5f4d 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -100,6 +100,7 @@ "@tryghost/mw-vhost": "0.0.0", "@tryghost/nodemailer": "0.3.25", "@tryghost/nql": "0.9.2", + "@tryghost/oembed-service": "0.0.0", "@tryghost/package-json": "0.0.0", "@tryghost/pretty-cli": "1.2.30", "@tryghost/promise": "0.1.21", @@ -159,15 +160,6 @@ "knex-migrator": "5.0.3", "lodash": "4.17.21", "luxon": "3.0.1", - "metascraper": "5.30.1", - "metascraper-author": "5.29.15", - "metascraper-description": "5.29.15", - "metascraper-image": "5.29.15", - "metascraper-logo": "5.29.15", - "metascraper-logo-favicon": "5.30.1", - "metascraper-publisher": "5.29.15", - "metascraper-title": "5.29.15", - "metascraper-url": "5.29.15", "moment": "2.24.0", "moment-timezone": "0.5.23", "multer": "1.4.4", @@ -181,7 +173,6 @@ "sanitize-html": "2.7.1", "semver": "7.3.7", "stoppable": "1.1.0", - "tough-cookie": "4.0.0", "uuid": "8.3.2", "xml": "1.0.1" }, diff --git a/ghost/oembed-service/.eslintrc.js b/ghost/oembed-service/.eslintrc.js new file mode 100644 index 0000000000..c9c1bcb522 --- /dev/null +++ b/ghost/oembed-service/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: ['ghost'], + extends: [ + 'plugin:ghost/node' + ] +}; diff --git a/ghost/oembed-service/README.md b/ghost/oembed-service/README.md new file mode 100644 index 0000000000..be30a645e9 --- /dev/null +++ b/ghost/oembed-service/README.md @@ -0,0 +1,23 @@ +# Oembed Service + +Oembed service for Ghost + + +## Usage + + +## Develop + +This is a monorepo package. + +Follow the instructions for the top-level repo. +1. `git clone` this repo & `cd` into it as usual +2. Run `yarn` to install top-level dependencies. + + + +## Test + +- `yarn lint` run just eslint +- `yarn test` run lint and tests + diff --git a/ghost/oembed-service/index.js b/ghost/oembed-service/index.js new file mode 100644 index 0000000000..6e6e4c3bbd --- /dev/null +++ b/ghost/oembed-service/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/oembed-service'); diff --git a/ghost/core/core/server/services/oembed.js b/ghost/oembed-service/lib/oembed-service.js similarity index 100% rename from ghost/core/core/server/services/oembed.js rename to ghost/oembed-service/lib/oembed-service.js diff --git a/ghost/oembed-service/package.json b/ghost/oembed-service/package.json new file mode 100644 index 0000000000..efa840b179 --- /dev/null +++ b/ghost/oembed-service/package.json @@ -0,0 +1,42 @@ +{ + "name": "@tryghost/oembed-service", + "version": "0.0.0", + "repository": "https://github.com/TryGhost/Ghost/tree/main/packages/oembed-service", + "author": "Ghost Foundation", + "private": true, + "main": "index.js", + "scripts": { + "dev": "echo \"Implement me!\"", + "test": "NODE_ENV=testing c8 --all --reporter text --reporter cobertura mocha './test/**/*.test.js'", + "lint:code": "eslint *.js lib/ --ext .js --cache", + "lint": "yarn lint:code && yarn lint:test", + "lint:test": "eslint -c test/.eslintrc.js test/ --ext .js --cache" + }, + "files": [ + "index.js", + "lib" + ], + "devDependencies": { + "c8": "7.12.0", + "mocha": "10.0.0", + "should": "13.2.3", + "sinon": "14.0.0" + }, + "dependencies": { + "@tryghost/errors": "1.2.15", + "@tryghost/logging": "2.2.4", + "@tryghost/tpl": "0.1.18", + "lodash": "4.17.21", + "metascraper": "5.30.1", + "metascraper-author": "5.29.15", + "metascraper-description": "5.29.15", + "metascraper-image": "5.29.15", + "metascraper-logo": "5.29.15", + "metascraper-logo-favicon": "5.30.1", + "metascraper-publisher": "5.29.15", + "metascraper-title": "5.29.15", + "metascraper-url": "5.29.15", + "oembed-parser": "1.4.9", + "tough-cookie": "4.0.0" + } +} diff --git a/ghost/oembed-service/test/.eslintrc.js b/ghost/oembed-service/test/.eslintrc.js new file mode 100644 index 0000000000..829b601eb0 --- /dev/null +++ b/ghost/oembed-service/test/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: ['ghost'], + extends: [ + 'plugin:ghost/test' + ] +}; diff --git a/ghost/oembed-service/test/hello.test.js b/ghost/oembed-service/test/hello.test.js new file mode 100644 index 0000000000..3f9e671446 --- /dev/null +++ b/ghost/oembed-service/test/hello.test.js @@ -0,0 +1,7 @@ +const assert = require('assert'); + +describe('Hello world', function () { + it('Runs a test', function () { + assert.equal('hello', 'hello'); + }); +});