diff --git a/assets/js/index.js b/assets/js/index.js index 6e51b7ba..0157ff4f 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -7,55 +7,6 @@ import './predictors' govukFrontend.initAll() mojFrontend.initAll() -MOJFrontend.BackendSortableTable = params => { - this.table = $(params.table) - - if (this.table.data('moj-search-toggle-initialised')) { - return - } - - this.table.data('moj-search-toggle-initialised', true) - - this.setupOptions(params) - this.body = this.table.find('tbody') - this.createHeadingButtons() - this.setNaturalOrder() - this.createStatusBox() - this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick')) -} - -MOJFrontend.BackendSortableTable.prototype.sortNatural = (rowA, rowB) => { - const tdA = $(rowA).find('td').eq(this.naturalSortColumn) - const tdB = $(rowB).find('td').eq(this.naturalSortColumn) - const valueA = this.getCellValue(tdA) - const valueB = this.getCellValue(tdB) - if (this.naturalSortDirection === 'ascending') { - if (valueA < valueB) { - return -1 - } - if (valueA > valueB) { - return 1 - } - return 0 - } - if (valueB < valueA) { - return -1 - } - if (valueB > valueA) { - return 1 - } - return 0 -} - -MOJFrontend.BackendSortableTable.prototype.getCellValue = cell => { - let val = cell.attr('data-sort-value') - val = val || cell.html() - if ($.isNumeric(val)) { - val = parseInt(val, 10) - } - return val -} - /* eslint-disable no-restricted-globals */ const lastAppointment = () => { const repeatingFrequency = document.querySelector('div[data-repeating-frequency]') diff --git a/esbuild/esbuild.config.js b/esbuild/esbuild.config.js index b2d4f018..4aeb8a2f 100644 --- a/esbuild/esbuild.config.js +++ b/esbuild/esbuild.config.js @@ -51,13 +51,30 @@ function main() { Promise.all([buildApp(buildConfig), buildAssets(buildConfig)]).catch(() => process.exit(1)) } + if (args.includes('--feature-dev-server')) { + let serverProcess = null + chokidar.watch(['dist']).on('all', () => { + if (serverProcess) serverProcess.kill() + serverProcess = spawn( + 'node', + ['--inspect=0.0.0.0', '--enable-source-maps', 'dist/server.js', ' | bunyan -o short'], + { + stdio: 'inherit', + }, + ) + }) + } if (args.includes('--dev-server')) { let serverProcess = null chokidar.watch(['dist']).on('all', () => { if (serverProcess) serverProcess.kill() - serverProcess = spawn('node', ['--inspect=0.0.0.0', '--enable-source-maps', 'dist/server.js'], { - stdio: 'inherit', - }) + serverProcess = spawn( + 'node', + ['--inspect=0.0.0.0', '--enable-source-maps', '-r', 'dotenv/config', 'dist/server.js', ' | bunyan -o short'], + { + stdio: 'inherit', + }, + ) }) } diff --git a/package.json b/package.json index cd839e1d..24d651b9 100644 --- a/package.json +++ b/package.json @@ -6,17 +6,9 @@ "license": "MIT", "scripts": { "prepare": "husky", - "copy-views": "cp -R server/views dist/server/", - "compile-sass": "sass --quiet-deps --no-source-map --load-path=node_modules/govuk-frontend/dist --load-path=node_modules/@ministryofjustice/frontend --load-path=. assets/scss/application.scss:./assets/stylesheets/application.css --style compressed", - "watch-ts": "tsc -w", - "watch-views": "nodemon --watch server/views -e html,njk -x npm run copy-views", - "watch-node": "DEBUG=gov-starter-server* nodemon -r dotenv/config --watch dist/ dist/server.js | bunyan -o short", - "watch-sass": "npm run compile-sass -- --watch", - "build": "npm run compile-sass && tsc && npm run copy-views && npm run sentry:sourcemaps", - "start": "node $NODE_OPTIONS dist/server.js | bunyan -o short", - "start:dev": "concurrently -k -p \"[{name}]\" -n \"Views,TypeScript,Node,Sass\" -c \"yellow.bold,cyan.bold,green.bold,blue.bold\" \"npm run watch-views\" \"npm run watch-ts\" \"npm run watch-node\" \"npm run watch-sass\"", + "start:dev": "concurrently -k -p \"[{name}]\" -n \"Views,TypeScript,ESBuild,Node,Sass\" -c \"yellow.bold,cyan.bold,green.bold,blue.bold\" \"node esbuild/esbuild.config.js --build --watch\" \"node esbuild/esbuild.config.js --dev-server\"", "start-feature": "concurrently -k -p \"[{name}]\" -n \"WireMock,Node\" -c \"magenta.bold,green.bold\" \"npm run wiremock\" \"npm run start-node-feature\"", - "start-feature:dev": "export $(cat feature.env) && concurrently -k -p \"[{name}]\" -n \"WireMock,Views,TypeScript,ESBuild,Node,Sass\" -c \"yellow.bold,cyan.bold\" \"npm run wiremock\" \"node esbuild/esbuild.config.js --build --watch\" \"node esbuild/esbuild.config.js --dev-server\"", + "start-feature:dev": "export $(cat feature.env) && concurrently -k -p \"[{name}]\" -n \"WireMock,Views,TypeScript,ESBuild,Node,Sass\" -c \"yellow.bold,cyan.bold\" \"npm run wiremock\" \"node esbuild/esbuild.config.js --build --watch\" \"node esbuild/esbuild.config.js --feature-dev-server\"", "start-node-feature": "export $(cat feature.env) && node $NODE_DEBUG_OPTION dist/server.js | bunyan -o short", "watch-node-feature": "export $(cat feature.env) && nodemon --watch dist/ $NODE_DEBUG_OPTION dist/server.js | bunyan -o short", "wiremock": "npx wiremock --port 9091 --root-dir wiremock --local-response-templating", diff --git a/server/applicationInfo.ts b/server/applicationInfo.ts index 3c7a1e4f..5ac87082 100644 --- a/server/applicationInfo.ts +++ b/server/applicationInfo.ts @@ -15,7 +15,7 @@ export type ApplicationInfo = { } export default (): ApplicationInfo => { - const packageJson = path.join(__dirname, './package.json') + const packageJson = path.join(__dirname, '../package.json') const { name: applicationName, version } = JSON.parse(fs.readFileSync(packageJson).toString()) return { applicationName, version, buildNumber, gitRef, gitShortHash: gitRef.substring(0, 7), productId, branchName } } diff --git a/server/views/partials/layout.njk b/server/views/partials/layout.njk index c8811d5e..a19f194c 100644 --- a/server/views/partials/layout.njk +++ b/server/views/partials/layout.njk @@ -25,7 +25,6 @@ {% block pageTitle %}{{pageTitle | default(applicationName)}}{% endblock %} {% block header %} -{{applicationInsightsConnectionString }} {% include "./header.njk" %} {% block banner %}{% endblock %}