@hippo-digital/hippocampus 2.6.0 → 2.7.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 +23 -0
- package/README.md +7 -0
- package/docs/data-and-governance.md +33 -9
- package/docs/import-a-research-round.md +2 -2
- package/docs/start-here.md +7 -6
- package/docs/turn-personas-into-users-and-needs.md +2 -3
- package/lib/research-in-git.js +69 -0
- package/package.json +1 -1
- package/scripts/doctor.js +55 -1
- package/scripts/init.js +56 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
The guide's advice to keep research files and import drafts out of git, made
|
|
6
|
+
the default. `init` writes the `.gitignore` lines, and `doctor` says when
|
|
7
|
+
research files or drafts are committed. No schema change. `init` now writes
|
|
8
|
+
`.gitignore` without being asked, so this is a minor release rather than a
|
|
9
|
+
patch.
|
|
10
|
+
|
|
11
|
+
- **`init` keeps research files and import drafts out of git.** It adds
|
|
12
|
+
`.gitignore` lines for `hippocampus/inbox` and `hippocampus/imports`, which
|
|
13
|
+
keep the folders' `.gitkeep` files so the empty folders still clone. The
|
|
14
|
+
guide already advised this, but a paragraph is easy to miss before a first
|
|
15
|
+
commit. A folder is left alone when `.gitignore` already names it (a rule,
|
|
16
|
+
or a comment recording that a team commits it on purpose), or when files in
|
|
17
|
+
it are already committed, in which case `init` says how to stop tracking
|
|
18
|
+
them. Running `init` again in an existing project applies the same rules.
|
|
19
|
+
- **`doctor` reports committed research files.** It warns when files under
|
|
20
|
+
`hippocampus/inbox` or `hippocampus/imports` are committed, and says how to
|
|
21
|
+
untrack ones a `.gitignore` rule now excludes. When `.gitignore` names the
|
|
22
|
+
folder but nothing excludes the files, the team has decided, so it says so
|
|
23
|
+
as a note instead. A warning does not fail `doctor`; the last line becomes
|
|
24
|
+
"Working, with 1 warning to look at."
|
|
25
|
+
|
|
3
26
|
## 2.6.0
|
|
4
27
|
|
|
5
28
|
The user guide's data and governance page and four more task recipes, and the
|
package/README.md
CHANGED
|
@@ -32,6 +32,13 @@ you have since edited is reported and left alone rather than overwritten.
|
|
|
32
32
|
prints the edits for you to paste, and `npx hippocampus eject` takes the edits
|
|
33
33
|
back out and leaves every byte of your knowledge base where it is.
|
|
34
34
|
|
|
35
|
+
It also adds `.gitignore` lines that keep `hippocampus/inbox` and
|
|
36
|
+
`hippocampus/imports` out of git: research files and import drafts hold
|
|
37
|
+
participants' words. A folder that `.gitignore` already names, or whose files
|
|
38
|
+
are already committed, is left alone, with a message saying why. `doctor`
|
|
39
|
+
warns when research files or drafts are committed. The guide's Data and
|
|
40
|
+
governance page has the detail.
|
|
41
|
+
|
|
35
42
|
```bash
|
|
36
43
|
npx hippocampus doctor # what is wired, what is not, and where it looked
|
|
37
44
|
npx hippocampus skills install # copy the skills, agents and instructions in
|
|
@@ -58,24 +58,32 @@ every copy of the repository, and on GitHub asking GitHub Support to clear
|
|
|
58
58
|
what it has cached. Plan as if anything committed is permanent.
|
|
59
59
|
|
|
60
60
|
The inbox and the drafts are working copies of research. Keep them on the
|
|
61
|
-
machine that imported them.
|
|
61
|
+
machine that imported them. `npx hippocampus init` adds these lines to your
|
|
62
|
+
prototype's `.gitignore`:
|
|
62
63
|
|
|
63
64
|
```text
|
|
64
|
-
# Research files and import drafts: copies of research with participants'
|
|
65
|
-
# words in them. They stay on the machine that imported them.
|
|
66
65
|
hippocampus/inbox/**
|
|
67
|
-
hippocampus/imports/**
|
|
68
66
|
!hippocampus/inbox/**/
|
|
69
|
-
!hippocampus/imports/**/
|
|
70
67
|
!hippocampus/inbox/**/.gitkeep
|
|
68
|
+
hippocampus/imports/**
|
|
69
|
+
!hippocampus/imports/**/
|
|
71
70
|
!hippocampus/imports/**/.gitkeep
|
|
72
71
|
```
|
|
73
72
|
|
|
74
|
-
The
|
|
75
|
-
there for everyone.
|
|
73
|
+
The two lines after each rule keep the empty folders in the repository, so
|
|
74
|
+
they are there for everyone.
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
Running `init` again in an existing prototype adds them too, apart from two
|
|
77
|
+
cases where it leaves `.gitignore` alone and says why:
|
|
78
|
+
|
|
79
|
+
- **`.gitignore` already names the folder**, in a rule or a comment. That is
|
|
80
|
+
taken as your team's decision, either way.
|
|
81
|
+
- **Files in the folder are already committed.** A rule now would ignore new
|
|
82
|
+
drafts while the old ones stayed tracked. `init` prints the lines to add and
|
|
83
|
+
how to stop tracking the files.
|
|
84
|
+
|
|
85
|
+
To stop tracking files that are already committed (they stay on your
|
|
86
|
+
machine):
|
|
79
87
|
|
|
80
88
|
```bash
|
|
81
89
|
git rm -r --cached hippocampus/inbox hippocampus/imports
|
|
@@ -86,11 +94,27 @@ git commit -m "Stop tracking research files and import drafts"
|
|
|
86
94
|
That removes them from now on. Earlier commits still hold them, so talk to
|
|
87
95
|
your information governance lead about whether the history needs rewriting.
|
|
88
96
|
|
|
97
|
+
`npx hippocampus doctor` warns whenever research files or drafts are
|
|
98
|
+
committed, until they are untracked or your team records the decision.
|
|
99
|
+
|
|
89
100
|
Because drafts are not shared, **whoever imports a round reviews and promotes
|
|
90
101
|
it**, or works alongside the person who does. Someone else cannot import the
|
|
91
102
|
same file again on their own machine: the manifest is shared, and it remembers
|
|
92
103
|
the file was imported.
|
|
93
104
|
|
|
105
|
+
### If your team decides to commit drafts
|
|
106
|
+
|
|
107
|
+
Agree it with your information governance lead first. Then record the
|
|
108
|
+
decision in `.gitignore` as a comment that names the folder, in place of that
|
|
109
|
+
folder's lines if `init` wrote them:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
# hippocampus/imports is committed on purpose: agreed with IG, October 2026.
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`init` then leaves the folder alone, and `doctor` lists the committed files as
|
|
116
|
+
a note rather than a warning.
|
|
117
|
+
|
|
94
118
|
## Nothing joins the record without a person
|
|
95
119
|
|
|
96
120
|
- Importing writes drafts. It never writes to `hippocampus/source/`.
|
|
@@ -26,9 +26,9 @@ participants. Before the first file goes in, agree the points in
|
|
|
26
26
|
[Data and governance](data-and-governance.md#agree-these-before-your-first-import)
|
|
27
27
|
with your information governance lead. In particular:
|
|
28
28
|
|
|
29
|
-
- keep the inbox and the drafts out of git
|
|
29
|
+
- keep the inbox and the drafts out of git. `npx hippocampus init` adds the
|
|
30
|
+
lines to your `.gitignore`; check they are there, as described in
|
|
30
31
|
[Keep research files and drafts out of git](data-and-governance.md#keep-research-files-and-drafts-out-of-git)
|
|
31
|
-
to your `.gitignore`
|
|
32
32
|
- agree which AI agents, if any, may read research files and drafts
|
|
33
33
|
|
|
34
34
|
Importing itself sends nothing anywhere, but the skills that tidy and review
|
package/docs/start-here.md
CHANGED
|
@@ -137,17 +137,17 @@ This writes:
|
|
|
137
137
|
- `hippocampus/`, with an empty knowledge base and its `inbox/`, `imports/`
|
|
138
138
|
and `source/` folders
|
|
139
139
|
- `artefacts/`, with a short README in each folder
|
|
140
|
+
- lines in `.gitignore` that keep `hippocampus/inbox/` and
|
|
141
|
+
`hippocampus/imports/` out of git. Research files and import drafts hold
|
|
142
|
+
participants' words, and anything committed stays in the repository's
|
|
143
|
+
history. See
|
|
144
|
+
[Keep research files and drafts out of git](data-and-governance.md#keep-research-files-and-drafts-out-of-git).
|
|
140
145
|
|
|
141
146
|
It also adds two short blocks to your prototype, one in `app/routes.js` and
|
|
142
147
|
one in `app.js`, so the viewer appears inside it. Both are marked, and
|
|
143
148
|
`npx hippocampus eject` takes them back out without touching your knowledge
|
|
144
149
|
base.
|
|
145
150
|
|
|
146
|
-
Before anyone imports research, add the lines in
|
|
147
|
-
[Keep research files and drafts out of git](data-and-governance.md#keep-research-files-and-drafts-out-of-git)
|
|
148
|
-
to your `.gitignore`. Research files and drafts hold participants' words, and
|
|
149
|
-
anything committed stays in the repository's history.
|
|
150
|
-
|
|
151
151
|
### Check it worked
|
|
152
152
|
|
|
153
153
|
```bash
|
|
@@ -159,7 +159,8 @@ after it will be right: run the command from inside your prototype, or pass
|
|
|
159
159
|
`--root <folder>`.
|
|
160
160
|
|
|
161
161
|
After that, `doctor` checks the config, the knowledge base, the two blocks in
|
|
162
|
-
your prototype and whether the records link up.
|
|
162
|
+
your prototype and whether the records link up. It warns if research files or
|
|
163
|
+
drafts have been committed to git. Then it starts the prototype
|
|
163
164
|
and opens every page to make sure each one loads. A failed check says what went
|
|
164
165
|
wrong, and usually what to run next.
|
|
165
166
|
|
|
@@ -55,9 +55,8 @@ user with two needs, which is the honest result.
|
|
|
55
55
|
## At the command line
|
|
56
56
|
|
|
57
57
|
1. Copy the persona documents into `hippocampus/inbox/personas/`. The
|
|
58
|
-
`.gitignore` lines
|
|
59
|
-
[Keep research files and drafts out of git](data-and-governance.md#keep-research-files-and-drafts-out-of-git)
|
|
60
|
-
keep them out of the repository.
|
|
58
|
+
`.gitignore` lines `init` writes keep them out of the repository; see
|
|
59
|
+
[Keep research files and drafts out of git](data-and-governance.md#keep-research-files-and-drafts-out-of-git).
|
|
61
60
|
|
|
62
61
|
2. Ask your agent to use the `ingest-user-personas` skill on them, for
|
|
63
62
|
example: "Use the ingest-user-personas skill on the documents in
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const { spawnSync } = require('child_process')
|
|
4
|
+
|
|
5
|
+
// Research files (hippocampus/inbox) and import drafts (hippocampus/imports)
|
|
6
|
+
// hold participants' words: transcripts, quotes, notes. The guide's advice is
|
|
7
|
+
// to keep both on the machine that imported them, because anything committed
|
|
8
|
+
// stays in the repository's history. `init` writes the .gitignore lines that do
|
|
9
|
+
// that, and `doctor` says when files there are committed anyway.
|
|
10
|
+
//
|
|
11
|
+
// A team can decide otherwise. A .gitignore line that names the folder - a rule
|
|
12
|
+
// or just a comment - is taken as that decision, so neither command overrides
|
|
13
|
+
// or nags about a choice somebody has written down.
|
|
14
|
+
const RESEARCH_DIRS = ['inbox', 'imports']
|
|
15
|
+
|
|
16
|
+
function ignoreLines (relDir) {
|
|
17
|
+
return [`${relDir}/**`, `!${relDir}/**/`, `!${relDir}/**/.gitkeep`]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function ignoreBlock (relDirs) {
|
|
21
|
+
return [
|
|
22
|
+
'# Research files and import drafts: copies of research with participants\'',
|
|
23
|
+
'# words in them, which stay on the machine that imported them. Written by',
|
|
24
|
+
'# `hippocampus init`. To commit a folder instead, replace its lines with a',
|
|
25
|
+
'# comment that names it, and init and doctor will leave it alone.',
|
|
26
|
+
...relDirs.flatMap(ignoreLines)
|
|
27
|
+
].join('\n') + '\n'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function readGitignore (root) {
|
|
31
|
+
const file = path.join(root, '.gitignore')
|
|
32
|
+
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : ''
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Read at write time, not plan time: init plans more than one change to this
|
|
36
|
+
// file, and a write built from a stale copy would drop the others.
|
|
37
|
+
function appendToGitignore (root, text) {
|
|
38
|
+
const file = path.join(root, '.gitignore')
|
|
39
|
+
const current = readGitignore(root)
|
|
40
|
+
const prefix = current.trim() ? `${current.replace(/\n*$/, '\n')}\n` : ''
|
|
41
|
+
fs.writeFileSync(file, prefix + text)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function mentions (gitignoreText, relDir) {
|
|
45
|
+
return gitignoreText.split('\n').some((line) => line.includes(relDir))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Files git tracks under relDir, apart from the .gitkeep files that keep the
|
|
50
|
+
* empty folders in the repository. `ignoredOnly` narrows that to files a
|
|
51
|
+
* .gitignore rule now matches - committed before the rule was written, and
|
|
52
|
+
* still tracked, because ignoring a file never untracks it.
|
|
53
|
+
*
|
|
54
|
+
* Returns null when there is nothing to ask: not a git repository, or no git.
|
|
55
|
+
*/
|
|
56
|
+
function trackedFiles (root, relDir, { ignoredOnly = false } = {}) {
|
|
57
|
+
const args = ['ls-files', '-z', ...(ignoredOnly ? ['-c', '-i', '--exclude-standard'] : []), '--', relDir]
|
|
58
|
+
const result = spawnSync('git', args, { cwd: root, encoding: 'utf8' })
|
|
59
|
+
if (result.error || result.status !== 0) return null
|
|
60
|
+
return result.stdout.split('\0').filter(Boolean).filter((file) => path.basename(file) !== '.gitkeep')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function relativeDir (root, dir) {
|
|
64
|
+
return path.relative(root, dir).split(path.sep).join('/')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
RESEARCH_DIRS, ignoreLines, ignoreBlock, readGitignore, appendToGitignore, mentions, trackedFiles, relativeDir
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hippo-digital/hippocampus",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.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
|
@@ -8,6 +8,7 @@ const { createContext } = require('../lib/context')
|
|
|
8
8
|
const { lintKnowledge } = require('../lib/lint-knowledge')
|
|
9
9
|
const { findBlock } = require('../lib/host-edit')
|
|
10
10
|
const packagePaths = require('../lib/package-paths')
|
|
11
|
+
const researchInGit = require('../lib/research-in-git')
|
|
11
12
|
|
|
12
13
|
// What doctor is for: answering "why is it not working?" without guessing.
|
|
13
14
|
// The resolved root is the first line of output, because it is the answer to
|
|
@@ -15,6 +16,7 @@ const packagePaths = require('../lib/package-paths')
|
|
|
15
16
|
|
|
16
17
|
const argv = process.argv.slice(2)
|
|
17
18
|
const problems = []
|
|
19
|
+
const warnings = []
|
|
18
20
|
const notes = []
|
|
19
21
|
|
|
20
22
|
function main () {
|
|
@@ -55,6 +57,8 @@ function main () {
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
checkResearchInGit(root, projects)
|
|
61
|
+
|
|
58
62
|
if (!argv.includes('--no-smoke') && projects.length && !problems.length) {
|
|
59
63
|
const smoke = spawnSync(process.execPath, [path.join(packagePaths.scriptsDir, 'smoke-routes.js'), '--root', root],
|
|
60
64
|
{ encoding: 'utf8' })
|
|
@@ -79,7 +83,57 @@ function main () {
|
|
|
79
83
|
process.exit(1)
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
// A warning is not a failure: the prototype works. It is something a person
|
|
87
|
+
// should decide about, so it is said every time until they have.
|
|
88
|
+
console.log(warnings.length
|
|
89
|
+
? `\nWorking, with ${warnings.length} warning${warnings.length === 1 ? '' : 's'} to look at.`
|
|
90
|
+
: '\nAll good.')
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function warn (label, message) {
|
|
94
|
+
console.log(` warn ${label}: ${message}`)
|
|
95
|
+
warnings.push(`${label}: ${message}`)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Research files and import drafts committed to git. Three cases, because the
|
|
99
|
+
// fix differs:
|
|
100
|
+
// - matched by a .gitignore rule but still tracked: committed before the rule
|
|
101
|
+
// existed, and ignoring a file never untracks it
|
|
102
|
+
// - not ignored, and .gitignore never names the folder: nobody has decided
|
|
103
|
+
// - not ignored, and .gitignore names the folder: a team decision, written
|
|
104
|
+
// down. Said once as a note, not as a warning on every run.
|
|
105
|
+
function checkResearchInGit (root, projects) {
|
|
106
|
+
const gitignore = researchInGit.readGitignore(root)
|
|
107
|
+
let checked = false
|
|
108
|
+
let clean = true
|
|
109
|
+
|
|
110
|
+
for (const project of projects) {
|
|
111
|
+
for (const dir of researchInGit.RESEARCH_DIRS) {
|
|
112
|
+
const relDir = researchInGit.relativeDir(root, path.join(project.dir, dir))
|
|
113
|
+
const tracked = researchInGit.trackedFiles(root, relDir)
|
|
114
|
+
if (tracked === null) return // not a git repository: nothing can have been committed
|
|
115
|
+
checked = true
|
|
116
|
+
if (!tracked.length) continue
|
|
117
|
+
clean = false
|
|
118
|
+
|
|
119
|
+
const files = `${tracked.length} ${tracked.length === 1 ? 'file' : 'files'} in ${relDir}`
|
|
120
|
+
const ignored = researchInGit.trackedFiles(root, relDir, { ignoredOnly: true }) || []
|
|
121
|
+
if (ignored.length) {
|
|
122
|
+
const [it, is] = ignored.length === 1 ? ['it', 'is'] : ['them', 'are']
|
|
123
|
+
const ignoredFiles = `${ignored.length} ${ignored.length === 1 ? 'file' : 'files'} in ${relDir}`
|
|
124
|
+
warn('research files', `${ignoredFiles} ${is} still committed, though .gitignore now excludes ${it}. ` +
|
|
125
|
+
`\`git rm -r --cached ${relDir}\` then \`git add ${relDir}\` stops tracking ${it} and keeps ${it} on disk.`)
|
|
126
|
+
} else if (researchInGit.mentions(gitignore, relDir)) {
|
|
127
|
+
notes.push(`${files} ${tracked.length === 1 ? 'is' : 'are'} committed to git, which .gitignore says is deliberate. ` +
|
|
128
|
+
'They hold participants\' words - see Data and governance in the guide.')
|
|
129
|
+
} else {
|
|
130
|
+
warn('research files', `${files} ${tracked.length === 1 ? 'is' : 'are'} committed to git. They hold participants\' ` +
|
|
131
|
+
'words. `npx hippocampus init` explains how to keep them out, or says how to record that your team decided to commit them.')
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (checked && clean) console.log(' ok research files: none committed to git')
|
|
83
137
|
}
|
|
84
138
|
|
|
85
139
|
function report (label, ok, okMessage, problemMessage) {
|
package/scripts/init.js
CHANGED
|
@@ -5,6 +5,7 @@ const { resolveRoot, CONFIG_FILENAME } = require('../lib/resolve-root')
|
|
|
5
5
|
const { CURRENT_SCHEMA_VERSION } = require('../lib/schema-version')
|
|
6
6
|
const hostEdit = require('../lib/host-edit')
|
|
7
7
|
const packagePaths = require('../lib/package-paths')
|
|
8
|
+
const researchInGit = require('../lib/research-in-git')
|
|
8
9
|
|
|
9
10
|
// Set a host project up to use Hippocampus: write the config and an empty
|
|
10
11
|
// knowledge base, then make the two host edits - both inside marked blocks, both
|
|
@@ -13,6 +14,9 @@ const packagePaths = require('../lib/package-paths')
|
|
|
13
14
|
// --dry-run print what would change and write nothing
|
|
14
15
|
// --no-wire write the data, print the host edits to paste by hand
|
|
15
16
|
// --private-artefacts gitignore the copied research material
|
|
17
|
+
//
|
|
18
|
+
// It also gitignores the inbox and the import drafts, unless .gitignore already
|
|
19
|
+
// names them or files in them are already committed. See planResearchIgnore.
|
|
16
20
|
|
|
17
21
|
const argv = process.argv.slice(2)
|
|
18
22
|
const dryRun = argv.includes('--dry-run')
|
|
@@ -41,6 +45,7 @@ function main () {
|
|
|
41
45
|
planKnowledgeBase(root)
|
|
42
46
|
planArtefacts(root, artefactsDir(root))
|
|
43
47
|
planArtefactGovernance(root)
|
|
48
|
+
planResearchIgnore(root)
|
|
44
49
|
if (!noWire) {
|
|
45
50
|
planHostEdit(path.join(root, 'app/routes.js'), wireRoutes)
|
|
46
51
|
planHostEdit(path.join(root, 'app.js'), wireApp)
|
|
@@ -216,8 +221,7 @@ function planArtefactGovernance (root) {
|
|
|
216
221
|
if (privateArtefacts) {
|
|
217
222
|
if (alreadyIgnored) return
|
|
218
223
|
plan(`.gitignore (${ARTEFACTS_IGNORE_LINE})`, () => {
|
|
219
|
-
|
|
220
|
-
fs.writeFileSync(gitignorePath, prefix +
|
|
224
|
+
researchInGit.appendToGitignore(root,
|
|
221
225
|
'# Research material copied into the knowledge base: transcripts and\n' +
|
|
222
226
|
'# participant quotes. Kept out of this repo by `hippocampus init --private-artefacts`.\n' +
|
|
223
227
|
`${ARTEFACTS_IGNORE_LINE}\n`)
|
|
@@ -245,6 +249,56 @@ function planArtefactGovernance (root) {
|
|
|
245
249
|
].join('\n'))
|
|
246
250
|
}
|
|
247
251
|
|
|
252
|
+
// The inbox and the import drafts are working copies of research, with
|
|
253
|
+
// participants' words in them. Unlike source-artefacts - material a team may
|
|
254
|
+
// well decide to keep - the guide's advice for these is settled: keep them on
|
|
255
|
+
// the machine that imported them. So they are ignored by default, rather than
|
|
256
|
+
// left to a paragraph somebody may not read before their first commit.
|
|
257
|
+
//
|
|
258
|
+
// Two things stop it. A .gitignore line naming the folder means the team has
|
|
259
|
+
// already decided, either way. And files there that are already committed
|
|
260
|
+
// mean a rule now would ignore new drafts while the old ones stayed tracked -
|
|
261
|
+
// half a decision, made silently - so init says what it found instead.
|
|
262
|
+
function planResearchIgnore (root) {
|
|
263
|
+
const current = researchInGit.readGitignore(root)
|
|
264
|
+
const toIgnore = []
|
|
265
|
+
const committed = []
|
|
266
|
+
|
|
267
|
+
for (const dir of researchInGit.RESEARCH_DIRS) {
|
|
268
|
+
const relDir = `hippocampus/${dir}`
|
|
269
|
+
if (researchInGit.mentions(current, relDir)) continue
|
|
270
|
+
const tracked = researchInGit.trackedFiles(root, relDir) || []
|
|
271
|
+
if (tracked.length) committed.push({ relDir, count: tracked.length })
|
|
272
|
+
else toIgnore.push(relDir)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (toIgnore.length) {
|
|
276
|
+
plan(`.gitignore (${toIgnore.join(', ')})`, () => {
|
|
277
|
+
researchInGit.appendToGitignore(root, researchInGit.ignoreBlock(toIgnore))
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
for (const { relDir, count } of committed) {
|
|
282
|
+
manual.push([
|
|
283
|
+
`${count} ${count === 1 ? 'file' : 'files'} in ${relDir} ${count === 1 ? 'is' : 'are'} committed to git, so .gitignore was left alone.`,
|
|
284
|
+
'',
|
|
285
|
+
'Research files and import drafts hold participants\' words. The guide\'s',
|
|
286
|
+
'Data and governance page explains what to agree with your information',
|
|
287
|
+
'governance lead.',
|
|
288
|
+
'',
|
|
289
|
+
'To keep them out of git from now on, add to .gitignore:',
|
|
290
|
+
...researchInGit.ignoreLines(relDir).map((line) => ` ${line}`),
|
|
291
|
+
'then stop tracking them (the files stay on your machine):',
|
|
292
|
+
` git rm -r --cached ${relDir}`,
|
|
293
|
+
` git add ${relDir}`,
|
|
294
|
+
'Earlier commits still hold them.',
|
|
295
|
+
'',
|
|
296
|
+
`If your team has decided they belong in the repo, add a .gitignore comment`,
|
|
297
|
+
`that names ${relDir}, and init and doctor will leave it alone.`
|
|
298
|
+
].join('\n'))
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
248
302
|
function countFiles (dir) {
|
|
249
303
|
if (!fs.existsSync(dir)) return 0
|
|
250
304
|
let total = 0
|