@hippo-digital/hippocampus 1.0.0-rc.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +114 -3
- package/README.md +36 -0
- package/assets/dist/hippocampus.css +1 -1
- package/assets/hippocampus.scss +994 -133
- package/assets/javascript/blueprint.js +21 -0
- package/assets/javascript/trace.js +54 -0
- package/bin/hippocampus.js +9 -3
- package/index.js +2 -1
- package/lib/breadcrumb.js +80 -0
- package/lib/create-router.js +246 -6
- package/lib/discover-projects.js +5 -0
- package/lib/filter.js +81 -0
- package/lib/flow-map.js +214 -0
- package/lib/lint-knowledge.js +31 -0
- package/lib/load-knowledge.js +335 -34
- package/lib/record-links.js +51 -0
- package/lib/schema-version.js +1 -1
- package/lib/templates.js +174 -0
- package/package.json +1 -1
- package/scripts/doctor.js +10 -0
- package/scripts/import-design-actions.js +2 -2
- package/scripts/import-research-batch.js +1 -1
- package/scripts/import-research-deck.js +1 -1
- package/scripts/lib/make-blueprint-template.py +107 -0
- package/scripts/promote-project-context-draft.js +22 -3
- package/scripts/promote-research-draft.js +7 -2
- package/scripts/smoke-routes.js +19 -0
- package/scripts/sync-project-context.js +9 -5
- package/scripts/sync-research-artefacts.js +9 -5
- package/templates/service-blueprint.xlsx +0 -0
- package/views/hippocampus/_layout.html +116 -3
- package/views/hippocampus/blueprint-classic.html +0 -1
- package/views/hippocampus/blueprint.html +0 -1
- package/views/hippocampus/components/_blueprint-cell.njk +6 -3
- package/views/hippocampus/components/_blueprint-controls.njk +2 -1
- package/views/hippocampus/components/_breadcrumb.njk +29 -0
- package/views/hippocampus/components/_connections.njk +38 -0
- package/views/hippocampus/components/_filters.njk +56 -0
- package/views/hippocampus/components/_journey-step.njk +11 -7
- package/views/hippocampus/components/_screen-preview.njk +41 -0
- package/views/hippocampus/doc.html +0 -1
- package/views/hippocampus/docs.html +67 -6
- package/views/hippocampus/evidence-impact.html +66 -33
- package/views/hippocampus/graph.html +137 -31
- package/views/hippocampus/handover-empty.html +0 -1
- package/views/hippocampus/handover.html +0 -1
- package/views/hippocampus/index.html +102 -13
- package/views/hippocampus/journey-flow.html +0 -1
- package/views/hippocampus/journey.html +21 -6
- package/views/hippocampus/journeys.html +63 -0
- package/views/hippocampus/project.html +19 -2
- package/views/hippocampus/record.html +33 -0
- package/views/hippocampus/research.html +14 -2
- package/views/hippocampus/route-review.html +0 -1
- package/views/hippocampus/scenarios.html +21 -3
- package/views/hippocampus/screens.html +45 -0
- package/views/hippocampus/trace.html +35 -22
- package/views/hippocampus/user-needs.html +55 -19
- package/views/hippocampus/user.html +131 -79
- package/views/hippocampus/users.html +33 -19
package/lib/templates.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const packagePaths = require('./package-paths')
|
|
4
|
+
|
|
5
|
+
// Blank workbooks, served the same way the docs are.
|
|
6
|
+
//
|
|
7
|
+
// Both of these already existed; the only place either was mentioned was inside
|
|
8
|
+
// an error message telling you to "start from the blank tracker that ships with
|
|
9
|
+
// the package: node_modules/@hippo-digital/hippocampus/templates/...". That is
|
|
10
|
+
// a path you can only follow if you already knew it was there, and it is the
|
|
11
|
+
// wrong way round: the template is what you want BEFORE you have an error.
|
|
12
|
+
//
|
|
13
|
+
// Serving them rather than copying them into the host is the same argument as
|
|
14
|
+
// the docs. A copied workbook is a workbook whose columns stop matching the
|
|
15
|
+
// importer, quietly, one release later.
|
|
16
|
+
|
|
17
|
+
// What each one is for, and the command that reads it back. A file with no
|
|
18
|
+
// entry here is still listed - somebody adding a template should not have to
|
|
19
|
+
// edit this to see it appear - it just arrives without the prose.
|
|
20
|
+
const DESCRIBED = {
|
|
21
|
+
'project-context.xlsx': {
|
|
22
|
+
title: 'Project context',
|
|
23
|
+
summary:
|
|
24
|
+
'Purpose, vision, policy context, channels, constraints, risks, milestones ' +
|
|
25
|
+
'and source facts. One sheet per kind, one row per record.',
|
|
26
|
+
command: 'hippocampus import project-context <file>',
|
|
27
|
+
then: 'hippocampus promote project-context'
|
|
28
|
+
},
|
|
29
|
+
'service-blueprint.xlsx': {
|
|
30
|
+
title: 'Service blueprint',
|
|
31
|
+
summary:
|
|
32
|
+
'One column per step, one row per swimlane. The row labels are the ones ' +
|
|
33
|
+
'the importer recognises, so filled-in content lands in a mapped ' +
|
|
34
|
+
'destination rather than in the unmapped pile.',
|
|
35
|
+
command: 'hippocampus import blueprint <file>',
|
|
36
|
+
then: ''
|
|
37
|
+
},
|
|
38
|
+
'insight-design-action-tracker.xlsx': {
|
|
39
|
+
title: 'Insight and design action tracker',
|
|
40
|
+
summary:
|
|
41
|
+
'The research tracker: insights from a round, and the design actions that ' +
|
|
42
|
+
'answer them. The sheet names matter - the importer looks for them by name.',
|
|
43
|
+
command: 'hippocampus import design-actions <file>',
|
|
44
|
+
then: 'hippocampus link insight-needs'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A project's copy of a blank, recognised by what is inside it.
|
|
50
|
+
*
|
|
51
|
+
* `DESCRIBED` is keyed by filename, so a blank that a team renamed
|
|
52
|
+
* ("ncrs-insight-design-action-tracker.xlsx") arrives with no summary and,
|
|
53
|
+
* worse, no command - a card that tells you a file exists and nothing about
|
|
54
|
+
* what to do with it.
|
|
55
|
+
*
|
|
56
|
+
* Matching on the filename would be a guess. Matching on the sheet names is
|
|
57
|
+
* not: the importers find their sheets by name, so a workbook whose sheets are
|
|
58
|
+
* exactly a blank's sheets is a workbook that blank's importer will read. An
|
|
59
|
+
* identical set is the only thing accepted - a team that has added or removed
|
|
60
|
+
* a sheet has diverged far enough that naming a command for it would be the
|
|
61
|
+
* page asserting something it cannot know.
|
|
62
|
+
*/
|
|
63
|
+
let blankSignatures = null
|
|
64
|
+
|
|
65
|
+
function sheetSignature (file) {
|
|
66
|
+
try {
|
|
67
|
+
const { openWorkbook } = require('../scripts/lib/xlsx-grid')
|
|
68
|
+
return [...openWorkbook(file).sheetFiles.keys()].sort().join('\u0000')
|
|
69
|
+
} catch {
|
|
70
|
+
// Not a workbook, or one this reader cannot open. Either way there is
|
|
71
|
+
// nothing to match on, and a template that cannot be described is still a
|
|
72
|
+
// template that can be downloaded.
|
|
73
|
+
return null
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function describedBySheets (filePath) {
|
|
78
|
+
if (path.extname(filePath).toLowerCase() !== '.xlsx') return null
|
|
79
|
+
|
|
80
|
+
if (!blankSignatures) {
|
|
81
|
+
blankSignatures = Object.entries(DESCRIBED)
|
|
82
|
+
.map(([file, entry]) => ({
|
|
83
|
+
entry, signature: sheetSignature(path.join(packagePaths.templatesDir, file))
|
|
84
|
+
}))
|
|
85
|
+
.filter((blank) => blank.signature)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const signature = sheetSignature(filePath)
|
|
89
|
+
if (!signature) return null
|
|
90
|
+
|
|
91
|
+
const match = blankSignatures.find((blank) => blank.signature === signature)
|
|
92
|
+
if (!match) return null
|
|
93
|
+
|
|
94
|
+
// Everything except the title. The file keeps the name the team gave it -
|
|
95
|
+
// relabelling somebody's "ncrs-..." workbook as the blank would hide which of
|
|
96
|
+
// the two cards is theirs, which is the confusion this grouping exists to end.
|
|
97
|
+
const { title, ...rest } = match.entry
|
|
98
|
+
return { ...rest, matches: title }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const EXTENSIONS = new Set(['.xlsx', '.xlsm', '.csv', '.docx', '.pptx', '.json', '.md'])
|
|
102
|
+
|
|
103
|
+
function readDir (dir, origin) {
|
|
104
|
+
if (!dir || !fs.existsSync(dir)) return []
|
|
105
|
+
|
|
106
|
+
return fs.readdirSync(dir, { withFileTypes: true })
|
|
107
|
+
// `templates/artefacts/` is scaffolding that `init` copies into a host, not
|
|
108
|
+
// something to fill in and hand back.
|
|
109
|
+
.filter((entry) => entry.isFile() && EXTENSIONS.has(path.extname(entry.name).toLowerCase()))
|
|
110
|
+
.map((entry) => {
|
|
111
|
+
const full = path.join(dir, entry.name)
|
|
112
|
+
const described = DESCRIBED[entry.name] || describedBySheets(full) || {}
|
|
113
|
+
return {
|
|
114
|
+
file: entry.name,
|
|
115
|
+
path: full,
|
|
116
|
+
origin,
|
|
117
|
+
title: described.title || entry.name.replace(/\.[^.]+$/, '').replace(/[-_]/g, ' ')
|
|
118
|
+
.replace(/^./, (c) => c.toUpperCase()),
|
|
119
|
+
summary: described.summary || '',
|
|
120
|
+
command: described.command || '',
|
|
121
|
+
then: described.then || '',
|
|
122
|
+
format: path.extname(entry.name).replace('.', '').toUpperCase(),
|
|
123
|
+
matches: described.matches || '',
|
|
124
|
+
bytes: fs.statSync(full).size
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Both places a template can live, kept apart.
|
|
131
|
+
*
|
|
132
|
+
* The package ships the blanks. A project keeps its own under
|
|
133
|
+
* `hippocampus/templates/` - usually one of those blanks, renamed and adjusted
|
|
134
|
+
* for the team - and in one flat list the two sit side by side as "Insight and
|
|
135
|
+
* design action tracker" and "Ncrs insight design action tracker", which reads
|
|
136
|
+
* as the same thing listed twice rather than as a blank and a project's copy
|
|
137
|
+
* of it.
|
|
138
|
+
*
|
|
139
|
+
* Deduplicating them is the wrong fix: it would mean deciding, from a filename,
|
|
140
|
+
* that two workbooks are the same workbook. They are grouped instead, so the
|
|
141
|
+
* relationship is stated rather than guessed at, and a team that has genuinely
|
|
142
|
+
* diverged from a blank still sees both.
|
|
143
|
+
*/
|
|
144
|
+
function listTemplates (paths) {
|
|
145
|
+
const groups = [
|
|
146
|
+
{
|
|
147
|
+
key: 'project',
|
|
148
|
+
title: "This project's templates",
|
|
149
|
+
note: 'Kept in hippocampus/templates/. Usually a blank below, renamed and ' +
|
|
150
|
+
'adjusted - start from these if your team has already settled on a shape.',
|
|
151
|
+
items: readDir(paths && paths.templatesDir, 'project')
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
key: 'package',
|
|
155
|
+
title: 'Blank templates',
|
|
156
|
+
note: 'Shipped with the package, so their columns always match the importer ' +
|
|
157
|
+
'in the version you have installed.',
|
|
158
|
+
items: readDir(packagePaths.templatesDir, 'package')
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
for (const group of groups) {
|
|
163
|
+
group.items.sort((a, b) => a.title.localeCompare(b.title))
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return groups.filter((group) => group.items.length)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Every template across both groups - for the download route and the smoke test. */
|
|
170
|
+
function allTemplates (paths) {
|
|
171
|
+
return listTemplates(paths).flatMap((group) => group.items)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = { listTemplates, allTemplates, DESCRIBED }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hippo-digital/hippocampus",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A design-knowledge base for NHS Prototype Kit projects: research, insights, needs, journeys and screens, traceable end to end.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
package/scripts/doctor.js
CHANGED
|
@@ -62,6 +62,16 @@ function main () {
|
|
|
62
62
|
(smoke.stderr || smoke.stdout || '').trim().split('\n').slice(0, 4).join('\n '))
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// Working on the package against a real project means symlinking it into that
|
|
66
|
+
// project's node_modules, and then the viewer is running code that is not
|
|
67
|
+
// published. That is the right way to do the work and the wrong thing to
|
|
68
|
+
// forget: a page that works here may not exist for anybody else yet.
|
|
69
|
+
const installedAt = path.join(root, 'node_modules/@hippo-digital/hippocampus')
|
|
70
|
+
if (fs.existsSync(installedAt) && fs.lstatSync(installedAt).isSymbolicLink()) {
|
|
71
|
+
notes.push(`hippocampus is LINKED, not installed - the viewer is running ${fs.realpathSync(installedAt)}`)
|
|
72
|
+
notes.push(' Anything you see here is unpublished. `npm install` restores the released version.')
|
|
73
|
+
}
|
|
74
|
+
|
|
65
75
|
for (const note of notes) console.log(` note ${note}`)
|
|
66
76
|
|
|
67
77
|
if (problems.length) {
|
|
@@ -34,7 +34,7 @@ const EXAMPLE_IDS = /^(R17-05|R17-10|DA-R17-|DEC-R17-)/i
|
|
|
34
34
|
|
|
35
35
|
function main () {
|
|
36
36
|
const args = parseArgs(process.argv.slice(2))
|
|
37
|
-
if (!args.workbook) throw new Error('Usage:
|
|
37
|
+
if (!args.workbook) throw new Error('Usage: npx hippocampus import design-actions -- --workbook path/to/tracker.xlsx [--dry-run]')
|
|
38
38
|
|
|
39
39
|
const workbook = openWorkbook(path.resolve(args.workbook))
|
|
40
40
|
const actionRows = rows(workbook, 'Design Actions')
|
|
@@ -174,7 +174,7 @@ function main () {
|
|
|
174
174
|
for (const [file, data] of Object.entries(proposed)) {
|
|
175
175
|
fs.writeFileSync(path.join(knowledgeSourceDir, file), `${JSON.stringify(data, null, 2)}\n`)
|
|
176
176
|
}
|
|
177
|
-
console.log(`\nImported from ${path.relative(ctx.root, path.resolve(args.workbook))}. Run
|
|
177
|
+
console.log(`\nImported from ${path.relative(ctx.root, path.resolve(args.workbook))}. Run `npx hippocampus validate` to confirm.`)
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
function rows (workbook, sheetName) {
|
|
@@ -10,7 +10,7 @@ const supportedExtensions = new Set(['.pptx', '.pdf'])
|
|
|
10
10
|
async function main () {
|
|
11
11
|
const args = parseArgs(process.argv.slice(2))
|
|
12
12
|
if (!args.source || !args.batchId) {
|
|
13
|
-
throw new Error('Usage:
|
|
13
|
+
throw new Error('Usage: npx hippocampus research batch -- --source path/to/files --batch-id batch-id [--date YYYY-MM-DD] [--concurrency 4]')
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const sourceDir = path.resolve(args.source)
|
|
@@ -16,7 +16,7 @@ async function main () {
|
|
|
16
16
|
args.artefactId = kebab(args.artefactId || args.roundId || '')
|
|
17
17
|
|
|
18
18
|
if (!args.deck || !args.roundId || !args.title || !args.date) {
|
|
19
|
-
throw new Error('Usage:
|
|
19
|
+
throw new Error('Usage: npx hippocampus import research-deck -- --deck path/to/artefact --round-id round-id [--artefact-id artefact-id] --title "Round title" --date YYYY-MM-DD')
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const slides = await extractSlides(args.deck)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Generate the blank blueprint template the package ships.
|
|
2
|
+
|
|
3
|
+
The lane names are not invented here - they are the exact labels the importer's
|
|
4
|
+
swimlane triage matches, so a team filling this in lands in a mapped
|
|
5
|
+
destination rather than in the unmapped pile. The canonical list lives in
|
|
6
|
+
import-blueprint-spreadsheet.js and is passed in, so the two cannot drift.
|
|
7
|
+
"""
|
|
8
|
+
import json, sys
|
|
9
|
+
from openpyxl import Workbook
|
|
10
|
+
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side
|
|
11
|
+
from openpyxl.utils import get_column_letter
|
|
12
|
+
|
|
13
|
+
LANES = json.loads(sys.argv[1])
|
|
14
|
+
OUT = sys.argv[2]
|
|
15
|
+
|
|
16
|
+
wb = Workbook()
|
|
17
|
+
thin = Side(style="thin", color="D8DDE0")
|
|
18
|
+
box = Border(left=thin, right=thin, top=thin, bottom=thin)
|
|
19
|
+
head = Font(bold=True)
|
|
20
|
+
wrap = Alignment(wrap_text=True, vertical="top")
|
|
21
|
+
|
|
22
|
+
# --- How to use -----------------------------------------------------------
|
|
23
|
+
ws = wb.active
|
|
24
|
+
ws.title = "How to use"
|
|
25
|
+
ws.column_dimensions["A"].width = 100
|
|
26
|
+
rows = [
|
|
27
|
+
("Service blueprint", True),
|
|
28
|
+
("", False),
|
|
29
|
+
("Fill in the Blueprint sheet, then import it:", False),
|
|
30
|
+
(" hippocampus import blueprint <this-file.xlsx>", False),
|
|
31
|
+
("", False),
|
|
32
|
+
("That writes a draft for you to check. Nothing reaches the knowledge base", False),
|
|
33
|
+
("until you promote it.", False),
|
|
34
|
+
("", False),
|
|
35
|
+
("The Blueprint sheet", True),
|
|
36
|
+
("", False),
|
|
37
|
+
("One column per step, left to right, in the order the user meets them.", False),
|
|
38
|
+
("One row per swimlane. The row labels in column A are the ones the importer", False),
|
|
39
|
+
("recognises - keep them as they are and your content lands in the right", False),
|
|
40
|
+
("place. A label it does not recognise is not lost: it is reported as", False),
|
|
41
|
+
("unmapped for you to decide about.", False),
|
|
42
|
+
("", False),
|
|
43
|
+
("Put one item per line inside a cell. Blank cells are fine - a lane that", False),
|
|
44
|
+
("does not apply to a step is a fact about the step, not a gap to fill.", False),
|
|
45
|
+
("", False),
|
|
46
|
+
("The Evidence sheet", True),
|
|
47
|
+
("", False),
|
|
48
|
+
("What each step rests on: the need it serves, the research behind it, or", False),
|
|
49
|
+
("the document it came from. One row per link.", False),
|
|
50
|
+
("", False),
|
|
51
|
+
("The Sources sheet", True),
|
|
52
|
+
("", False),
|
|
53
|
+
("Where the evidence came from, so a reader can get back to the original.", False),
|
|
54
|
+
]
|
|
55
|
+
for i, (text, bold) in enumerate(rows, start=1):
|
|
56
|
+
c = ws.cell(row=i, column=1, value=text)
|
|
57
|
+
if bold:
|
|
58
|
+
c.font = head
|
|
59
|
+
|
|
60
|
+
# --- Blueprint ------------------------------------------------------------
|
|
61
|
+
bp = wb.create_sheet("Blueprint")
|
|
62
|
+
bp.column_dimensions["A"].width = 28
|
|
63
|
+
for col in range(2, 8):
|
|
64
|
+
bp.column_dimensions[get_column_letter(col)].width = 34
|
|
65
|
+
|
|
66
|
+
bp.cell(row=1, column=1, value="Swimlane").font = head
|
|
67
|
+
for step in range(1, 7):
|
|
68
|
+
c = bp.cell(row=1, column=step + 1, value=f"{step}. ")
|
|
69
|
+
c.font = head
|
|
70
|
+
c.alignment = wrap
|
|
71
|
+
c.border = box
|
|
72
|
+
bp.cell(row=1, column=1).border = box
|
|
73
|
+
|
|
74
|
+
for r, lane in enumerate(LANES, start=2):
|
|
75
|
+
c = bp.cell(row=r, column=1, value=lane)
|
|
76
|
+
c.font = head
|
|
77
|
+
c.alignment = wrap
|
|
78
|
+
c.border = box
|
|
79
|
+
for step in range(1, 7):
|
|
80
|
+
cell = bp.cell(row=r, column=step + 1, value="")
|
|
81
|
+
cell.alignment = wrap
|
|
82
|
+
cell.border = box
|
|
83
|
+
bp.row_dimensions[r].height = 56
|
|
84
|
+
bp.freeze_panes = "B2"
|
|
85
|
+
|
|
86
|
+
# --- Evidence -------------------------------------------------------------
|
|
87
|
+
ev = wb.create_sheet("Evidence")
|
|
88
|
+
ev_cols = ["Step", "Screen", "Route", "Type", "Round", "Participants", "Statement", "Source ID"]
|
|
89
|
+
for i, name in enumerate(ev_cols, start=1):
|
|
90
|
+
c = ev.cell(row=1, column=i, value=name)
|
|
91
|
+
c.font = head
|
|
92
|
+
c.border = box
|
|
93
|
+
ev.column_dimensions[get_column_letter(i)].width = 22 if name != "Statement" else 60
|
|
94
|
+
ev.freeze_panes = "A2"
|
|
95
|
+
|
|
96
|
+
# --- Sources --------------------------------------------------------------
|
|
97
|
+
sr = wb.create_sheet("Sources")
|
|
98
|
+
sr_cols = ["Source ID", "Source title", "Reference", "Used for"]
|
|
99
|
+
for i, name in enumerate(sr_cols, start=1):
|
|
100
|
+
c = sr.cell(row=1, column=i, value=name)
|
|
101
|
+
c.font = head
|
|
102
|
+
c.border = box
|
|
103
|
+
sr.column_dimensions[get_column_letter(i)].width = 30 if i > 1 else 14
|
|
104
|
+
sr.freeze_panes = "A2"
|
|
105
|
+
|
|
106
|
+
wb.save(OUT)
|
|
107
|
+
print("wrote", OUT)
|
|
@@ -11,11 +11,25 @@ const projectContextPath = path.join(knowledgeSourceDir, 'project-context.json')
|
|
|
11
11
|
function main () {
|
|
12
12
|
const args = parseArgs(process.argv.slice(2))
|
|
13
13
|
if (!args.draft) {
|
|
14
|
-
throw new Error(`Usage:
|
|
14
|
+
throw new Error(`Usage: npx hippocampus promote project-context -- --draft ${path.relative(ctx.root, path.join(projectImportsDir, 'context-id.json'))} [--dry-run]`)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const draft = validateDraft(readJson(path.resolve(args.draft)))
|
|
18
|
-
|
|
18
|
+
// A project that has never recorded context has no project-context.json at
|
|
19
|
+
// all: `init` cannot write one, because the schema requires a non-empty id,
|
|
20
|
+
// title and summary and inventing those is worse than leaving the file out.
|
|
21
|
+
// So the first promotion into a fresh project is a create, not a merge -
|
|
22
|
+
// which is exactly the case that matters, since it is how every project's
|
|
23
|
+
// context starts.
|
|
24
|
+
const current = fs.existsSync(projectContextPath)
|
|
25
|
+
? readJson(projectContextPath)
|
|
26
|
+
: {
|
|
27
|
+
id: draft.projectContext.id,
|
|
28
|
+
title: draft.projectContext.title,
|
|
29
|
+
summary: draft.projectContext.summary,
|
|
30
|
+
users: [], channels: [], policies: [], constraints: [],
|
|
31
|
+
risks: [], milestones: [], facts: [], sourceArtefacts: []
|
|
32
|
+
}
|
|
19
33
|
const proposed = mergeProjectContext(current, draft.projectContext)
|
|
20
34
|
|
|
21
35
|
console.log([
|
|
@@ -36,7 +50,12 @@ function main () {
|
|
|
36
50
|
|
|
37
51
|
writeJson(projectContextPath, proposed)
|
|
38
52
|
|
|
39
|
-
|
|
53
|
+
// Run the sibling script directly rather than `npm run <script>`. Those npm
|
|
54
|
+
// scripts exist in this repo and in the demo, and in no host that installs the
|
|
55
|
+
// package - so this step failed with "Missing script" on a promotion that had
|
|
56
|
+
// already written its data correctly. Spawning node needs nothing of the host
|
|
57
|
+
// but node itself.
|
|
58
|
+
const validation = spawnSync(process.execPath, [path.join(__dirname, 'validate-knowledge.js'), '--root', ctx.root], {
|
|
40
59
|
cwd: ctx.root,
|
|
41
60
|
stdio: 'inherit'
|
|
42
61
|
})
|
|
@@ -19,7 +19,7 @@ const collections = {
|
|
|
19
19
|
function main () {
|
|
20
20
|
const args = parseArgs(process.argv.slice(2))
|
|
21
21
|
if (!args.draft) {
|
|
22
|
-
throw new Error(`Usage:
|
|
22
|
+
throw new Error(`Usage: npx hippocampus promote research -- --draft ${path.relative(ctx.root, path.join(researchImportsDir, 'round-id.json'))} [--dry-run]`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const draft = validateDraft(readJson(path.resolve(args.draft)))
|
|
@@ -43,7 +43,12 @@ function main () {
|
|
|
43
43
|
writeJson(path.join(dataDir, filename), proposed[key])
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
// Run the sibling script directly rather than `npm run <script>`. Those npm
|
|
47
|
+
// scripts exist in this repo and in the demo, and in no host that installs the
|
|
48
|
+
// package - so this step failed with "Missing script" on a promotion that had
|
|
49
|
+
// already written its data correctly. Spawning node needs nothing of the host
|
|
50
|
+
// but node itself.
|
|
51
|
+
const validation = spawnSync(process.execPath, [path.join(__dirname, 'validate-knowledge.js'), '--root', ctx.root], {
|
|
47
52
|
cwd: ctx.root,
|
|
48
53
|
stdio: 'inherit'
|
|
49
54
|
})
|
package/scripts/smoke-routes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { spawn } = require('child_process')
|
|
2
2
|
const { createContextOrExit } = require('../lib/context')
|
|
3
3
|
const { listDocs } = require('../lib/docs')
|
|
4
|
+
const { allTemplates } = require('../lib/templates')
|
|
4
5
|
const ctx = createContextOrExit()
|
|
5
6
|
|
|
6
7
|
const port = process.env.SMOKE_PORT || 4587
|
|
@@ -53,11 +54,13 @@ function buildRoutes (basePath, knowledge) {
|
|
|
53
54
|
`${basePath}/users`,
|
|
54
55
|
`${basePath}/user-needs`,
|
|
55
56
|
`${basePath}/scenarios`,
|
|
57
|
+
`${basePath}/journeys`,
|
|
56
58
|
`${basePath}/research`,
|
|
57
59
|
`${basePath}/graph`,
|
|
58
60
|
`${basePath}/trace`,
|
|
59
61
|
`${basePath}/handover`,
|
|
60
62
|
`${basePath}/docs`,
|
|
63
|
+
`${basePath}/screens`,
|
|
61
64
|
// The viewer serves these itself. If they 404 the pages load unstyled and
|
|
62
65
|
// the blueprint stops working, which is exactly the kind of breakage a
|
|
63
66
|
// smoke test should catch rather than a person noticing later.
|
|
@@ -65,10 +68,26 @@ function buildRoutes (basePath, knowledge) {
|
|
|
65
68
|
`${basePath}/assets/blueprint.js`
|
|
66
69
|
])
|
|
67
70
|
|
|
71
|
+
for (const template of allTemplates()) {
|
|
72
|
+
routes.add(`${basePath}/templates/${template.file}`)
|
|
73
|
+
}
|
|
74
|
+
|
|
68
75
|
for (const doc of listDocs()) {
|
|
69
76
|
routes.add(`${basePath}/docs/${doc.slug}`)
|
|
70
77
|
}
|
|
71
78
|
|
|
79
|
+
// Detail pages are generated per record, so check a sample rather than all
|
|
80
|
+
// of them - 132 needs would make the smoke test a load test.
|
|
81
|
+
for (const collection of [
|
|
82
|
+
{ items: knowledge.needs, path: 'needs' },
|
|
83
|
+
{ items: knowledge.insights, path: 'insights' },
|
|
84
|
+
{ items: knowledge.screens, path: 'screens' }
|
|
85
|
+
]) {
|
|
86
|
+
for (const item of (collection.items || []).slice(0, 3)) {
|
|
87
|
+
routes.add(`${basePath}/${collection.path}/${item.id}`)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
for (const journey of knowledge.journeys) {
|
|
73
92
|
routes.add(`${basePath}/journeys/${journey.id}`)
|
|
74
93
|
routes.add(`${basePath}/journeys/${journey.id}/blueprint`)
|
|
@@ -98,11 +98,15 @@ async function main () {
|
|
|
98
98
|
if (!shouldPromote) return
|
|
99
99
|
|
|
100
100
|
for (const item of promotable) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
// Run the sibling script directly rather than `npm run <script>`. Those npm
|
|
102
|
+
// scripts exist in this repo and in the demo, and in no host that installs the
|
|
103
|
+
// package - so this step failed with "Missing script" on a promotion that had
|
|
104
|
+
// already written its data correctly. Spawning node needs nothing of the host
|
|
105
|
+
// but node itself.
|
|
106
|
+
const result = spawnSync(process.execPath, [
|
|
107
|
+
path.join(__dirname, 'promote-project-context-draft.js'),
|
|
108
|
+
`--draft=${item.draftPath}`,
|
|
109
|
+
'--root', ctx.root
|
|
106
110
|
], {
|
|
107
111
|
cwd: ctx.root,
|
|
108
112
|
stdio: 'inherit'
|
|
@@ -108,11 +108,15 @@ async function main () {
|
|
|
108
108
|
if (!shouldPromote) return
|
|
109
109
|
|
|
110
110
|
for (const item of promotable) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
// Run the sibling script directly rather than `npm run <script>`. Those npm
|
|
112
|
+
// scripts exist in this repo and in the demo, and in no host that installs the
|
|
113
|
+
// package - so this step failed with "Missing script" on a promotion that had
|
|
114
|
+
// already written its data correctly. Spawning node needs nothing of the host
|
|
115
|
+
// but node itself.
|
|
116
|
+
const result = spawnSync(process.execPath, [
|
|
117
|
+
path.join(__dirname, 'promote-research-draft.js'),
|
|
118
|
+
`--draft=${item.draftPath}`,
|
|
119
|
+
'--root', ctx.root
|
|
116
120
|
], {
|
|
117
121
|
cwd: ctx.root,
|
|
118
122
|
stdio: 'inherit'
|
|
Binary file
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
no sass entry point and no stylesheet link to the host project.
|
|
9
9
|
#}
|
|
10
10
|
{% extends "prototype-kit-template.njk" %}
|
|
11
|
+
{% from "hippocampus/components/_breadcrumb.njk" import breadcrumb as breadcrumbTrail %}
|
|
11
12
|
|
|
12
13
|
{% block head %}
|
|
13
14
|
<link href="/nhsuk-frontend/nhsuk-frontend.min.css" rel="stylesheet">
|
|
@@ -17,14 +18,112 @@
|
|
|
17
18
|
{% block header %}
|
|
18
19
|
{{ header({
|
|
19
20
|
service: {
|
|
20
|
-
text: serviceName or
|
|
21
|
+
text: serviceName or serviceTitle or "Knowledge base",
|
|
21
22
|
href: basePath
|
|
22
23
|
}
|
|
23
24
|
}) }}
|
|
24
25
|
{% endblock %}
|
|
25
26
|
|
|
27
|
+
{#
|
|
28
|
+
A navigation bar on every page.
|
|
29
|
+
|
|
30
|
+
Until now the only way between sections was back to the landing page and out
|
|
31
|
+
again - two clicks and a lost train of thought for every sideways move. The
|
|
32
|
+
current section is marked with aria-current so it is announced, not only
|
|
33
|
+
coloured.
|
|
34
|
+
#}
|
|
35
|
+
{% block main %}
|
|
36
|
+
<nav class="knowledge-nav" aria-label="Knowledge base sections">
|
|
37
|
+
<div class="nhsuk-width-container-fluid knowledge-nav__inner">
|
|
38
|
+
{#
|
|
39
|
+
Which tool you are in, kept on screen at all times.
|
|
40
|
+
|
|
41
|
+
The header names the SERVICE, which is also what the prototype's own
|
|
42
|
+
pages are called - so without this, a page of needs and a patient
|
|
43
|
+
search screen carry the same banner. This says which of the two you are
|
|
44
|
+
looking at, and it rides with the navigation so it never scrolls away.
|
|
45
|
+
#}
|
|
46
|
+
<a class="knowledge-nav__wordmark" href="{{ basePath }}">Knowledge base</a>
|
|
47
|
+
<ul class="knowledge-nav__list">
|
|
48
|
+
{#
|
|
49
|
+
`match` lists the URL prefixes that belong to a section. A detail page
|
|
50
|
+
lives at a different path from its list - a need is /needs/:id while
|
|
51
|
+
the list is /user-needs - so matching on the list's own href alone
|
|
52
|
+
leaves every detail page with nothing marked.
|
|
53
|
+
#}
|
|
54
|
+
{% for item in [
|
|
55
|
+
{ href: "", text: "Overview", match: [] },
|
|
56
|
+
{ href: "/project", text: "Project", match: ["/project"] },
|
|
57
|
+
{ href: "/users", text: "Users", match: ["/users"] },
|
|
58
|
+
{ href: "/user-needs", text: "Needs", match: ["/user-needs", "/needs"] },
|
|
59
|
+
{ href: "/scenarios", text: "Scenarios", match: ["/scenarios"] },
|
|
60
|
+
{ href: "/journeys", text: "Journeys", match: ["/journeys", "/handover"] },
|
|
61
|
+
{ href: "/screens", text: "Screens", match: ["/screens"] },
|
|
62
|
+
{ href: "/research", text: "Research", match: ["/research", "/insights"] },
|
|
63
|
+
{ href: "/graph", text: "Graph", match: ["/graph"] },
|
|
64
|
+
{ href: "/trace", text: "Trace", match: ["/trace"] },
|
|
65
|
+
{ href: "/docs", text: "Docs", match: ["/docs"] }
|
|
66
|
+
] %}
|
|
67
|
+
{% set target = basePath + item.href %}
|
|
68
|
+
{% set isCurrent = currentPage == target %}
|
|
69
|
+
{% for prefix in item.match %}
|
|
70
|
+
{% if currentPage == basePath + prefix or currentPage.startsWith(basePath + prefix + "/") %}
|
|
71
|
+
{% set isCurrent = true %}
|
|
72
|
+
{% endif %}
|
|
73
|
+
{% endfor %}
|
|
74
|
+
<li class="knowledge-nav__item">
|
|
75
|
+
<a class="knowledge-nav__link{% if isCurrent %} knowledge-nav__link--current{% endif %}"
|
|
76
|
+
href="{{ target }}"
|
|
77
|
+
{% if isCurrent %}aria-current="page"{% endif %}>{{ item.text }}</a>
|
|
78
|
+
</li>
|
|
79
|
+
{% endfor %}
|
|
80
|
+
</ul>
|
|
81
|
+
</div>
|
|
82
|
+
</nav>
|
|
83
|
+
{{ super() }}
|
|
84
|
+
{% endblock %}
|
|
85
|
+
|
|
86
|
+
{#
|
|
87
|
+
The breadcrumb goes in `beforeContent`, the block the NHS template provides
|
|
88
|
+
just inside the container for exactly this. Putting it here rather than in
|
|
89
|
+
`content` matters: every view overrides `content`, so a breadcrumb placed
|
|
90
|
+
there would be replaced by each page and never render.
|
|
91
|
+
|
|
92
|
+
Rendering it once, centrally, is also the point - the per-page back links it
|
|
93
|
+
replaces were written one at a time and had drifted into saying five
|
|
94
|
+
different things.
|
|
95
|
+
|
|
96
|
+
The locals are called `breadcrumbItems`, not `breadcrumb`, because the kit's
|
|
97
|
+
template-with-imports.njk does `import breadcrumb` at its top level, which
|
|
98
|
+
shadows any context value of that name for every template extending it. A
|
|
99
|
+
`breadcrumb` passed from a route silently arrives here as the NHS macro, and
|
|
100
|
+
the trail renders as nothing at all with no error to explain it.
|
|
101
|
+
#}
|
|
102
|
+
{% block beforeContent %}
|
|
103
|
+
{{ breadcrumbTrail(breadcrumbItems) }}
|
|
104
|
+
{% endblock %}
|
|
105
|
+
|
|
106
|
+
{#
|
|
107
|
+
Integrity belongs in the footer, not on the landing page.
|
|
108
|
+
|
|
109
|
+
A green "validation passed" panel at the top of the home page took the most
|
|
110
|
+
prominent slot on the site to say that nothing was wrong - and only ever said
|
|
111
|
+
it to whoever opened the home page. As a footer line it rides every page, it
|
|
112
|
+
costs no room above the fold, and the date tells you whether the tick is
|
|
113
|
+
about the data you are actually looking at.
|
|
114
|
+
|
|
115
|
+
Failure keeps its callout on the landing page, where the list of what broke
|
|
116
|
+
is; the footer only carries the flag and the way back to it.
|
|
117
|
+
#}
|
|
26
118
|
{% block footer %}
|
|
27
|
-
{
|
|
119
|
+
{#
|
|
120
|
+
An empty `copyright` removes the line rather than overriding it. "© NHS
|
|
121
|
+
England" is the macro's default and it is wrong here twice over: these
|
|
122
|
+
pages are a design tool, not an NHS.UK page, and the notice belongs to
|
|
123
|
+
whatever the prototype itself publishes - which is a different footer.
|
|
124
|
+
#}
|
|
125
|
+
{% call footer({
|
|
126
|
+
copyright: "",
|
|
28
127
|
meta: {
|
|
29
128
|
items: [
|
|
30
129
|
{
|
|
@@ -37,7 +136,21 @@
|
|
|
37
136
|
}
|
|
38
137
|
]
|
|
39
138
|
}
|
|
40
|
-
}) }
|
|
139
|
+
}) %}
|
|
140
|
+
{% if knowledgeValidation.valid %}
|
|
141
|
+
<p class="nhsuk-body-s knowledge-integrity">
|
|
142
|
+
{{ nhsukIcon("tick", { classes: "knowledge-integrity__icon" }) }}
|
|
143
|
+
Knowledge checked{% if knowledgeSourcesUpdated %} · sources updated {{ knowledgeSourcesUpdated }}{% endif %}
|
|
144
|
+
</p>
|
|
145
|
+
{% else %}
|
|
146
|
+
<p class="nhsuk-body-s knowledge-integrity knowledge-integrity--failed">
|
|
147
|
+
<a class="nhsuk-footer__list-item-link" href="{{ basePath }}">
|
|
148
|
+
Knowledge validation failed: {{ knowledgeValidation.errors | length }}
|
|
149
|
+
problem{% if knowledgeValidation.errors | length != 1 %}s{% endif %}
|
|
150
|
+
</a>
|
|
151
|
+
</p>
|
|
152
|
+
{% endif %}
|
|
153
|
+
{% endcall %}
|
|
41
154
|
{% endblock %}
|
|
42
155
|
|
|
43
156
|
{% block bodyEnd %}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
{% block pageTitle %}{{ blueprint.meta.journeyTitle }} matrix{% endblock %}
|
|
5
5
|
|
|
6
6
|
{% block content %}
|
|
7
|
-
<a class="nhsuk-back-link" href="{{ basePath }}/journeys/{{ blueprint.journey.id }}/blueprint">Back to stacked blueprint</a>
|
|
8
7
|
<span class="nhsuk-caption-l">Classic service blueprint</span>
|
|
9
8
|
<h1>{{ blueprint.meta.journeyTitle }}</h1>
|
|
10
9
|
|