mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-08 02:52:39 -05:00
Moved @tryghost/mw-version-match to core folder
fix https://linear.app/ghost/issue/ENG-2112/mw-version-match - this commit moves the lib code and tests to the core folder so we can colocate code in one place rather than splitting it out across packages, which increases the cognitive load and overhead
This commit is contained in:
parent
ac369cfa06
commit
ba9063130b
11 changed files with 4 additions and 76 deletions
|
@ -103,7 +103,6 @@ COPY ghost/members-csv/package.json ghost/members-csv/package.json
|
|||
COPY ghost/milestones/package.json ghost/milestones/package.json
|
||||
COPY ghost/minifier/package.json ghost/minifier/package.json
|
||||
COPY ghost/mw-error-handler/package.json ghost/mw-error-handler/package.json
|
||||
COPY ghost/mw-version-match/package.json ghost/mw-version-match/package.json
|
||||
COPY ghost/mw-vhost/package.json ghost/mw-vhost/package.json
|
||||
COPY ghost/offers/package.json ghost/offers/package.json
|
||||
COPY ghost/payments/package.json ghost/payments/package.json
|
||||
|
|
|
@ -69,7 +69,6 @@ services:
|
|||
- node_modules_ghost_minifier:/home/ghost/ghost/minifier/node_modules:delegated
|
||||
- node_modules_ghost_model-to-domain-event-interceptor:/home/ghost/ghost/model-to-domain-event-interceptor/node_modules:delegated
|
||||
- node_modules_ghost_mw-error-handler:/home/ghost/ghost/mw-error-handler/node_modules:delegated
|
||||
- node_modules_ghost_mw-version-match:/home/ghost/ghost/mw-version-match/node_modules:delegated
|
||||
- node_modules_ghost_mw-vhost:/home/ghost/ghost/mw-vhost/node_modules:delegated
|
||||
- node_modules_ghost_nql-filter-expansions:/home/ghost/ghost/nql-filter-expansions/node_modules:delegated
|
||||
- node_modules_ghost_offers:/home/ghost/ghost/offers/node_modules:delegated
|
||||
|
@ -213,7 +212,6 @@ volumes:
|
|||
node_modules_ghost_minifier: {}
|
||||
node_modules_ghost_model-to-domain-event-interceptor: {}
|
||||
node_modules_ghost_mw-error-handler: {}
|
||||
node_modules_ghost_mw-version-match: {}
|
||||
node_modules_ghost_mw-vhost: {}
|
||||
node_modules_ghost_nql-filter-expansions: {}
|
||||
node_modules_ghost_offers: {}
|
||||
|
|
|
@ -2,8 +2,8 @@ const debug = require('@tryghost/debug')('web:endpoints:admin:app');
|
|||
const boolParser = require('express-query-boolean');
|
||||
const bodyParser = require('body-parser');
|
||||
const errorHandler = require('@tryghost/mw-error-handler');
|
||||
const versionMatch = require('@tryghost/mw-version-match');
|
||||
|
||||
const versionMatch = require('../../middleware/version-match');
|
||||
const labs = require('../../../../../shared/labs');
|
||||
const shared = require('../../../shared');
|
||||
const express = require('../../../../../shared/express');
|
||||
|
|
|
@ -7,7 +7,7 @@ const messages = {
|
|||
versionMismatch: 'Client request for {clientVersion} does not match server version {serverVersion}.'
|
||||
};
|
||||
|
||||
function checkVersionMatch(req, res, next) {
|
||||
module.exports = function checkVersionMatch(req, res, next) {
|
||||
const clientVersion = req.get('X-Ghost-Version');
|
||||
// can contain pre-release suffix, you should be able to use e.g. 1.19.0-pre [server] with 1.18.0 [client]
|
||||
const serverVersion = res.locals.version.match(/^(\d+\.)?(\d+\.)?(\d+)/)[0];
|
||||
|
@ -38,6 +38,4 @@ function checkVersionMatch(req, res, next) {
|
|||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
module.exports = checkVersionMatch;
|
||||
};
|
|
@ -119,7 +119,6 @@
|
|||
"@tryghost/milestones": "0.0.0",
|
||||
"@tryghost/minifier": "0.0.0",
|
||||
"@tryghost/mw-error-handler": "0.0.0",
|
||||
"@tryghost/mw-version-match": "0.0.0",
|
||||
"@tryghost/mw-vhost": "0.0.0",
|
||||
"@tryghost/nodemailer": "0.3.45",
|
||||
"@tryghost/nql": "0.12.7",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require('should');
|
||||
const sinon = require('sinon');
|
||||
|
||||
const versionMatch = require('../');
|
||||
const versionMatch = require('../../../../../../core/server/web/api/middleware/version-match');
|
||||
|
||||
describe('Version Mismatch', function () {
|
||||
let req;
|
|
@ -1,6 +0,0 @@
|
|||
module.exports = {
|
||||
plugins: ['ghost'],
|
||||
extends: [
|
||||
'plugin:ghost/node'
|
||||
]
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
# Mw Version Match
|
||||
|
||||
Version compatibility middleware 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
|
||||
|
|
@ -1 +0,0 @@
|
|||
module.exports = require('./lib/mw-version-match');
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"name": "@tryghost/mw-version-match",
|
||||
"version": "0.0.0",
|
||||
"repository": "https://github.com/TryGhost/Ghost/tree/main/packages/mw-version-match",
|
||||
"author": "Ghost Foundation",
|
||||
"private": true,
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "echo \"Implement me!\"",
|
||||
"test:unit": "NODE_ENV=testing c8 --all --check-coverage --100 --reporter text --reporter cobertura -- mocha --reporter dot './test/**/*.test.js'",
|
||||
"test": "yarn test:unit",
|
||||
"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": "8.0.1",
|
||||
"mocha": "10.8.2",
|
||||
"sinon": "15.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tryghost/errors": "1.3.5",
|
||||
"@tryghost/tpl": "0.1.32",
|
||||
"semver": "7.7.1"
|
||||
}
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
module.exports = {
|
||||
plugins: ['ghost'],
|
||||
extends: [
|
||||
'plugin:ghost/test'
|
||||
]
|
||||
};
|
Loading…
Add table
Reference in a new issue