Skip to content

Commit 011b769

Browse files
Skip JSDoc, SassDoc and Rollup stats in development
Updates Review app UI to hide links when not available
1 parent c697c80 commit 011b769

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"build-release": "./bin/build-release.sh",
2121
"publish-release": "./bin/publish-release.sh",
2222
"publish-preview": "./bin/publish-preview.sh",
23-
"predev": "npm run build",
23+
"predev": "npm run build -- --ignore-scripts",
2424
"dev": "concurrently \"npm run dev --workspace @govuk-frontend/review\" \"npm run dev --workspace govuk-frontend\" --kill-others --names \"app,pkg\" --prefix-colors \"red.dim,blue.dim\"",
2525
"build": "npm run build --workspace govuk-frontend --workspace @govuk-frontend/review",
2626
"build:app": "cross-env-shell NODE_ENV=production npm run build --workspace @govuk-frontend/review",

packages/govuk-frontend-review/src/app.mjs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { stat } from 'fs/promises'
2+
import { join } from 'path'
3+
14
import { paths } from '@govuk-frontend/config'
25
import {
36
getComponentsFixtures,
@@ -48,7 +51,17 @@ export default async () => {
4851
// Feature flags
4952
const flags = /** @type {FeatureFlags} */ ({
5053
isDeployedToHeroku: !!process.env.HEROKU_APP,
51-
isDevelopment: !['test', 'production'].includes(process.env.NODE_ENV)
54+
isDevelopment: !['test', 'production'].includes(process.env.NODE_ENV),
55+
56+
// Check for JSDoc and SassDoc
57+
hasDocs: await stat(join(paths.app, 'dist/docs'))
58+
.then(() => true)
59+
.catch(() => false),
60+
61+
// Check for Rollup stats
62+
hasStats: await stat(join(paths.stats, 'dist'))
63+
.then(() => true)
64+
.catch(() => false)
5265
})
5366

5467
// Set up Express.js
@@ -213,4 +226,6 @@ export default async () => {
213226
* @typedef {object} FeatureFlags
214227
* @property {boolean} isDeployedToHeroku - Review app using `HEROKU_APP`
215228
* @property {boolean} isDevelopment - Review app not using `NODE_ENV` production or test
229+
* @property {boolean} hasDocs - JSDoc and SassDoc are available
230+
* @property {boolean} hasStats - Rollup stats are available
216231
*/

packages/govuk-frontend-review/src/views/index.njk

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
</div>
6363

64+
{% if flags.hasDocs %}
6465
<div class="govuk-grid-row">
6566

6667
<div class="govuk-grid-column-two-thirds-from-desktop">
@@ -89,7 +90,9 @@
8990
</div>
9091
</div>
9192
</div>
93+
{% endif %}
9294

95+
{% if flags.hasStats %}
9396
<div class="govuk-grid-row">
9497
<div class="govuk-grid-column-two-thirds-from-desktop">
9598
<hr class="govuk-section-break govuk-section-break--xl govuk-section-break--visible">
@@ -138,4 +141,5 @@
138141
}) }}
139142
</div>
140143
</div>
144+
{% endif %}
141145
{% endblock %}

0 commit comments

Comments
 (0)