Extracted oembed service to separate package

refs https://github.com/TryGhost/Toolbox/issues/363

- the oembed service is completely standalone and could do with some
  individual unit tests
- moving it out to a package allows us to draw the boundaries better and
  allows us to remove some dependencies from the core package.json
This commit is contained in:
Daniel Lockyer 2022-08-15 09:33:23 +02:00
parent dfbe8ee296
commit d2eda5cf51
9 changed files with 87 additions and 11 deletions

View File

@ -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');

View File

@ -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"
},

View File

@ -0,0 +1,6 @@
module.exports = {
plugins: ['ghost'],
extends: [
'plugin:ghost/node'
]
};

View File

@ -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

View File

@ -0,0 +1 @@
module.exports = require('./lib/oembed-service');

View File

@ -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"
}
}

View File

@ -0,0 +1,6 @@
module.exports = {
plugins: ['ghost'],
extends: [
'plugin:ghost/test'
]
};

View File

@ -0,0 +1,7 @@
const assert = require('assert');
describe('Hello world', function () {
it('Runs a test', function () {
assert.equal('hello', 'hello');
});
});