generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Stringify audit details (#343) Co-authored-by: Paul Solecki <[email protected]> * Update all non major NPM dependencies (#362) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update Helm release generic-service to 3.3 (#363) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Paul Solecki <[email protected]> * CDPS-721: Removing prometheus metrics scraping (#365) * CDPS-721: Adding changelog for PR 365 (#366) * Update all non major NPM dependencies (#367) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update Node.js to v20.14.0 (#368) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency audit-ci to v7 (#369) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update all non major NPM dependencies (#370) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update Helm release generic-prometheus-alerts to 1.8 (#372) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency uuid to v10 (#371) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Paul Solecki <[email protected]> * SDIT-1802: ✨ Add request session to tests (#374) * Added ESBuild for building app and bundling/minfiying assets (#375) * Added ESBuild for bundling and building app * Update all non major NPM dependencies (#376) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Add dotenv to ESBuild server watch (#378) * Update all non major NPM dependencies (#379) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency @types/uuid to v10 (#380) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * jQueryify card.js --------- Co-authored-by: Lee Jacobson <[email protected]> Co-authored-by: Paul Solecki <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jon Brighton <[email protected]> Co-authored-by: petergphillips <[email protected]> Co-authored-by: Thomas-Geraghty <[email protected]>
- Loading branch information
1 parent
1b08f1c
commit 5ec5c07
Showing
30 changed files
with
4,133 additions
and
2,579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
$(() => { | ||
// Loops through dom and finds all elements with card--clickable class | ||
document.querySelectorAll('.card--clickable').forEach(card => { | ||
// Check if card has a link within it | ||
if (card.querySelector('a') !== null) { | ||
// Clicks the link within the heading to navigate to desired page | ||
card.addEventListener('click', () => { | ||
card.querySelector('a').click() | ||
}) | ||
} | ||
module.exports = () => { | ||
$(() => { | ||
// Loops through dom and finds all elements with card--clickable class | ||
$('.card--clickable').each(function () { | ||
const link = this.querySelector('a') | ||
// Check if card has a link within it | ||
if (link !== null) { | ||
// Clicks the link within the heading to navigate to desired page | ||
$(this).on('click', () => { | ||
// Use HTMLAnchorElement.click() rather than jQuery's trigger('click') to prevent recursion | ||
link.click() | ||
}) | ||
} | ||
}) | ||
}) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as govukFrontend from 'govuk-frontend' | ||
import * as mojFrontend from '@ministryofjustice/frontend' | ||
|
||
import card from './card' | ||
import multiSelect from './multiSelect' | ||
import localNameInputSubmit from './localNameInputSubmit' | ||
|
||
govukFrontend.initAll() | ||
mojFrontend.initAll() | ||
|
||
card() | ||
multiSelect(mojFrontend) | ||
localNameInputSubmit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = () => { | ||
$(() => { | ||
$('.local-name-text-input').on('keydown', function (e) { | ||
if (e.key === 'Enter') { | ||
e.preventDefault() | ||
$(this).closest('form').submit() | ||
} | ||
}) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { copy } = require('esbuild-plugin-copy') | ||
const { typecheckPlugin } = require('@jgoz/esbuild-plugin-typecheck') | ||
const esbuild = require('esbuild') | ||
const glob = require('glob') | ||
|
||
module.exports = buildConfig => { | ||
console.log('\u{1b}[1m\u{2728} Building app....\u{1b}[0m') | ||
|
||
esbuild | ||
.build({ | ||
entryPoints: glob.sync(buildConfig.app.entryPoints), | ||
outdir: buildConfig.app.outDir, | ||
bundle: false, | ||
sourcemap: true, | ||
platform: 'node', | ||
format: 'cjs', | ||
plugins: [ | ||
typecheckPlugin(), | ||
copy({ | ||
resolveFrom: 'cwd', | ||
assets: buildConfig.app.copy, | ||
}), | ||
], | ||
}) | ||
.catch(() => process.exit(1)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const { copy } = require('esbuild-plugin-copy') | ||
const { sassPlugin } = require('esbuild-sass-plugin') | ||
const { clean } = require('esbuild-plugin-clean') | ||
const manifestPlugin = require('esbuild-plugin-manifest') | ||
const esbuild = require('esbuild') | ||
const path = require('path') | ||
const { glob } = require('glob') | ||
|
||
const buildAdditionalAssets = buildConfig => | ||
esbuild.build({ | ||
outdir: buildConfig.assets.outDir, | ||
plugins: [ | ||
copy({ | ||
resolveFrom: 'cwd', | ||
assets: buildConfig.assets.copy, | ||
}), | ||
], | ||
}) | ||
|
||
const buildAssets = buildConfig => { | ||
return esbuild.build({ | ||
entryPoints: buildConfig.assets.entryPoints, | ||
outdir: buildConfig.assets.outDir, | ||
entryNames: '[ext]/app', | ||
minify: buildConfig.isProduction, | ||
sourcemap: !buildConfig.isProduction, | ||
platform: 'browser', | ||
target: 'es2018', | ||
external: ['/assets/*'], | ||
bundle: true, | ||
plugins: [ | ||
clean({ | ||
patterns: glob.sync(buildConfig.assets.clear), | ||
}), | ||
manifestPlugin({ | ||
generate: entries => | ||
Object.fromEntries(Object.entries(entries).map(paths => paths.map(p => p.replace(/^dist\//, '/')))), | ||
}), | ||
sassPlugin({ | ||
quietDeps: true, | ||
loadPaths: [process.cwd(), path.join(process.cwd(), 'node_modules')], | ||
}), | ||
], | ||
}) | ||
} | ||
|
||
module.exports = buildConfig => { | ||
console.log('\u{1b}[1m\u{2728} Building assets....\u{1b}[0m') | ||
|
||
Promise.all([buildAssets(buildConfig), buildAdditionalAssets(buildConfig)]).catch(e => { | ||
console.log(e) | ||
process.exit(1) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const path = require('path') | ||
const { glob } = require('glob') | ||
const chokidar = require('chokidar') | ||
const { spawn } = require('child_process') | ||
const buildAssets = require('./assets.config') | ||
const buildApp = require('./app.config') | ||
|
||
const cwd = process.cwd() | ||
const buildConfig = { | ||
isProduction: process.env.NODE_ENV === 'production', | ||
app: { | ||
outDir: path.join(cwd, 'dist'), | ||
entryPoints: glob | ||
.sync([path.join(cwd, '*.ts'), path.join(cwd, 'server/**/*.ts')]) | ||
.filter(file => !file.endsWith('.test.ts')), | ||
copy: [ | ||
{ | ||
from: path.join(cwd, 'server/views/**/*'), | ||
to: path.join(cwd, 'dist/server/views'), | ||
}, | ||
], | ||
}, | ||
|
||
assets: { | ||
outDir: path.join(cwd, 'dist/assets'), | ||
entryPoints: glob.sync([path.join(cwd, 'assets/js/index.js'), path.join(cwd, 'assets/scss/application.scss')]), | ||
copy: [ | ||
{ | ||
from: path.join(cwd, 'assets/images/**/*'), | ||
to: path.join(cwd, 'dist/assets/images'), | ||
}, | ||
], | ||
clear: glob.sync([path.join(cwd, 'dist/assets/{css,js}')]), | ||
}, | ||
} | ||
|
||
function main() { | ||
const chokidarOptions = { | ||
persistent: true, | ||
ignoreInitial: true, | ||
} | ||
|
||
const args = process.argv | ||
if (args.includes('--build')) { | ||
buildApp(buildConfig) | ||
buildAssets(buildConfig) | ||
} | ||
|
||
if (args.includes('--dev-server')) { | ||
let serverProcess = null | ||
chokidar.watch(['dist']).on('all', () => { | ||
if (serverProcess) serverProcess.kill() | ||
serverProcess = spawn('node', ['-r', 'dotenv/config', 'dist/server.js'], { stdio: 'inherit' }) | ||
}) | ||
} | ||
|
||
if (args.includes('--watch')) { | ||
console.log('\u{1b}[1m\u{1F52D} Watching for changes...\u{1b}[0m') | ||
// Assets | ||
chokidar.watch(['assets/**/*'], chokidarOptions).on('all', () => buildAssets(buildConfig)) | ||
|
||
// App | ||
chokidar | ||
.watch(['server/**/*'], { ...chokidarOptions, ignored: ['**/*.test.ts'] }) | ||
.on('all', () => buildApp(buildConfig)) | ||
} | ||
} | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.