@hippo-digital/hippocampus 1.0.0-rc.7 → 1.0.0-rc.8

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 CHANGED
@@ -143,6 +143,32 @@ than inside the importer, which loads a PDF parser, a zip reader and an XML
143
143
  parser for the deck path. Reading a spreadsheet needs none of them, and a test
144
144
  that loaded them inherited every way they can fail on a given Node version.
145
145
 
146
+ ### Promotion in a host
147
+
148
+ `promote` wrote its data and then reported that validation had failed, when
149
+ validation had never run. Both promote commands, and both sync commands,
150
+ shelled out to `npm run validate:knowledge` - a script this repo and the demo
151
+ define and **no host does**. They now run the sibling script directly, which
152
+ needs nothing of the host but node.
153
+
154
+ `promote project-context` also failed outright on a project that had never
155
+ recorded context, because it merged into a `project-context.json` that `init`
156
+ cannot create: the schema requires a non-empty id, title and summary, and
157
+ inventing those is worse than leaving the file out. The first promotion into a
158
+ fresh project is now a create rather than a merge - which is the case that
159
+ matters, since it is how every project's context begins.
160
+
161
+ The install test now runs `promote project-context` against the scratch host.
162
+ It is the only command that writes to `hippocampus/source/` and it was the one
163
+ command the gate never exercised, which is how both of these shipped.
164
+
165
+ Every remaining `npm run ...` in an error message became its `npx hippocampus`
166
+ equivalent. They named scripts no host has.
167
+
168
+ The install test also removes its scratch project on success. Each run is a
169
+ full `node_modules`; fifty-seven of them filled a disk before anybody noticed.
170
+ A failing run still leaves its tree behind, and now says where.
171
+
146
172
  ### Validation
147
173
 
148
174
  - Three tiers: errors are broken references, warnings are gaps worth filling,
@@ -68,7 +68,7 @@ function migrateInMemory (knowledge, meta) {
68
68
  version += 1
69
69
  warnings.push(
70
70
  `Knowledge base read as schemaVersion ${version - 1} and migrated to ${version} in memory. ` +
71
- 'Run `npm run migrate:knowledge` to write the upgrade back.'
71
+ 'Run `npx hippocampus migrate` to write the upgrade back.'
72
72
  )
73
73
  }
74
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hippo-digital/hippocampus",
3
- "version": "1.0.0-rc.7",
3
+ "version": "1.0.0-rc.8",
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",
@@ -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: npm run import:design-actions -- --workbook path/to/tracker.xlsx [--dry-run]')
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 npm run validate:knowledge to confirm.`)
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: npm run import:research-batch -- --source path/to/files --batch-id batch-id [--date YYYY-MM-DD] [--concurrency 4]')
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: npm run import:research-deck -- --deck path/to/artefact --round-id round-id [--artefact-id artefact-id] --title "Round title" --date YYYY-MM-DD')
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)
@@ -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: npm run promote:project-context-draft -- --draft ${path.relative(ctx.root, path.join(projectImportsDir, 'context-id.json'))} [--dry-run]`)
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
- const current = readJson(projectContextPath)
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
- const validation = spawnSync('npm', ['run', 'validate:knowledge'], {
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: npm run promote:research-draft -- --draft ${path.relative(ctx.root, path.join(researchImportsDir, 'round-id.json'))} [--dry-run]`)
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
- const validation = spawnSync('npm', ['run', 'validate:knowledge'], {
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
  })
@@ -98,11 +98,15 @@ async function main () {
98
98
  if (!shouldPromote) return
99
99
 
100
100
  for (const item of promotable) {
101
- const result = spawnSync('npm', [
102
- 'run',
103
- 'promote:project-context-draft',
104
- '--',
105
- `--draft=${item.draftPath}`
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
- const result = spawnSync('npm', [
112
- 'run',
113
- 'promote:research-draft',
114
- '--',
115
- `--draft=${item.draftPath}`
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'