Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move moduleToExtensionConversion config to known plugins JSON #1801

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion known-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"@govuk-prototype-kit/step-by-step",
"hmrc-frontend",
"jquery"
]
],
"interned": {
"jquery": {
"scripts": ["/dist/jquery.js"],
"assets": ["/dist"]
}
}
}
}
13 changes: 6 additions & 7 deletions lib/extensions/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ const path = require('path')

// Local dependencies
const appConfig = require('../config')
const { projectDir } = require('../path-utils')
const { packageDir, projectDir } = require('../path-utils')
const pkgPath = path.join(projectDir, 'package.json')
const chokidar = require('chokidar')
const fse = require('fs-extra')
const { shadowNunjucks } = require('../build/config.json').paths

const knownPlugins = fse.readJsonSync(
path.join(packageDir, 'known-plugins.json')
)

// Generic utilities
const removeDuplicates = arr => [...new Set(arr)]
const filterOutParentAndEmpty = part => part && part !== '..'
Expand All @@ -57,12 +61,7 @@ const objectMap = (object, mapFn) => Object.keys(object).reduce((result, key) =>
// File utilities
const getPathFromProjectRoot = (...all) => path.join(...[projectDir].concat(all))
const pathToPackageConfigFile = packageName => getPathFromProjectRoot('node_modules', packageName, 'govuk-prototype-kit.config.json')
const moduleToExtensionConversion = {
jquery: {
scripts: ['/dist/jquery.js'],
assets: ['/dist']
}
}
const moduleToExtensionConversion = knownPlugins.plugins.interned

const readJsonFile = (filePath) => {
return JSON.parse(fs.readFileSync(filePath, 'utf8'))
Expand Down