Added config-url-helpers to config

- getSubdir, getSiteUrl & getAdminUrl were currently part of @tryghost/url-utils
- They have been split out into their own library, and refactored so that they expect to be bound to nconf
- With this commit we can do e.g. config.getSubdir() rather than needing @tryghost/url-utils
- These functions will be passed to url-utils via DI
- This is the first step in breaking down url-utils into smaller pieces
- This commit only does a single change in Gruntfile.js to use the new funtions - this will be rolled out slowly
This commit is contained in:
Hannah Wolfe 2021-06-17 12:15:44 +01:00
parent 536d7a76d6
commit 6aafb735b1
No known key found for this signature in database
GPG Key ID: 9F8C7532D0A6BA55
4 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,6 @@
//
// **Debug tip:** If you have any problems with any Grunt tasks, try running them with the `--verbose` command
const config = require('./core/shared/config');
const urlService = require('./core/frontend/services/url');
const _ = require('lodash');
const fs = require('fs-extra');
const KnexMigrator = require('knex-migrator');
@ -333,7 +332,7 @@ const configureGrunt = function (grunt) {
watch: {
projects: {
'core/client': ['shell:ember:watch', '--live-reload-base-url="' + urlService.utils.getSubdir() + '/ghost/"']
'core/client': ['shell:ember:watch', '--live-reload-base-url="' + config.getSubdir() + '/ghost/"']
}
}
},

View File

@ -6,8 +6,13 @@ const _debug = require('@tryghost/debug')._base;
const debug = _debug('ghost:config');
const localUtils = require('./utils');
const helpers = require('./helpers');
const urlHelpers = require('@tryghost/config-url-helpers');
const env = process.env.NODE_ENV || 'development';
/**
* @param {object} options
* @returns {Nconf.Provider & urlHelpers.BoundHelpers}
*/
function loadNconf(options) {
debug('config start');
options = options || {};
@ -47,6 +52,7 @@ function loadNconf(options) {
// Expose dynamic utility methods
nconf.isPrivacyDisabled = helpers.isPrivacyDisabled.bind(nconf);
nconf.getContentPath = helpers.getContentPath.bind(nconf);
urlHelpers.bindAll(nconf);
// ## Sanitization

View File

@ -46,6 +46,7 @@
"@tryghost/admin-api-schema": "2.3.0",
"@tryghost/bookshelf-plugins": "0.1.2",
"@tryghost/bootstrap-socket": "0.2.9",
"@tryghost/config-url-helpers": "^0.1.0",
"@tryghost/constants": "0.1.8",
"@tryghost/debug": "0.1.1",
"@tryghost/email-analytics-provider-mailgun": "1.0.0",

View File

@ -626,6 +626,11 @@
dependencies:
long-timeout "^0.1.1"
"@tryghost/config-url-helpers@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@tryghost/config-url-helpers/-/config-url-helpers-0.1.0.tgz#10cb3930c19a72e4967b52c6d6450a05449a3f9d"
integrity sha512-zZU4+sKlK7L7wz7X7s6XEPrhWYJuMSaR65FaktZsdUQNneTHcmSQXJyLhWKLMFeayP51Os6tPYlLitBvHFLUOA==
"@tryghost/constants@0.1.8":
version "0.1.8"
resolved "https://registry.yarnpkg.com/@tryghost/constants/-/constants-0.1.8.tgz#b08074cdc6f8a379209750e60c2ab62c8ba895cf"