dreamteamer 0.50.0 → 0.51.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/bin/dreamteamer.js +16 -148
- package/collections/modules.collection.yaml +1 -1
- package/collections/repos.collection.yaml +1 -1
- package/dist/api.d.ts +1 -2
- package/dist/api.js +0 -1
- package/dist/changes/commitPending.js +2 -12
- package/dist/changes/consts.d.ts +1 -1
- package/dist/changes/consts.js +1 -1
- package/dist/changes/deriveEvents.d.ts +1 -3
- package/dist/changes/deriveEvents.js +8 -11
- package/dist/changes/foldChanges.d.ts +1 -2
- package/dist/changes/foldChanges.js +2 -3
- package/dist/changes/groupChanges.d.ts +1 -4
- package/dist/changes/groupChanges.js +2 -6
- package/dist/changes/lib/reportLine.d.ts +1 -1
- package/dist/changes/lib/reportLine.js +2 -2
- package/dist/changes/printChanges.d.ts +1 -1
- package/dist/changes/printChanges.js +2 -2
- package/dist/changes/recordChanges.d.ts +0 -1
- package/dist/changes/recordChanges.js +0 -2
- package/dist/changes/rowChanges.js +0 -3
- package/dist/changes/types.d.ts +0 -2
- package/dist/check/check.js +82 -188
- package/dist/check/unreadData.js +1 -2
- package/dist/cli.js +1 -2
- package/dist/collections/renameCollection.js +0 -5
- package/dist/commands/compileCommand.js +2 -2
- package/dist/commands/exportsCommand.js +1 -4
- package/dist/commands/fmtCommand.js +1 -2
- package/dist/commands/lib/unknownVerb.js +1 -1
- package/dist/commands/relationsCommand.js +2 -7
- package/dist/commands/updateCommand.js +3 -11
- package/dist/compile/compile.js +21 -86
- package/dist/compile/consts.js +1 -2
- package/dist/compile/lib/compileCollections.d.ts +4 -8
- package/dist/compile/lib/compileCollections.js +5 -97
- package/dist/compile/types.d.ts +0 -9
- package/dist/exports/planExports.d.ts +2 -2
- package/dist/exports/planExports.js +9 -24
- package/dist/exports/runExports.d.ts +2 -3
- package/dist/exports/runExports.js +72 -81
- package/dist/extensions/declaredExtensions.d.ts +2 -3
- package/dist/extensions/declaredExtensions.js +2 -30
- package/dist/fmt/formatDescriptors.d.ts +1 -1
- package/dist/fmt/formatDescriptors.js +1 -1
- package/dist/init/init.js +0 -1
- package/dist/init/seedBlock.js +0 -1
- package/dist/install/applyInstall.js +3 -13
- package/dist/install/installCommand.js +0 -6
- package/dist/install/npmAndCompile.js +1 -1
- package/dist/install/observeState.d.ts +0 -1
- package/dist/install/observeState.js +0 -23
- package/dist/install/planInstall.js +0 -10
- package/dist/lib/consts.js +1 -1
- package/dist/modules/removeModule.js +0 -3
- package/dist/modules/renameModule.js +0 -7
- package/dist/modules/runModuleScript.d.ts +1 -2
- package/dist/modules/runModuleScript.js +1 -2
- package/dist/modules/setModule.js +1 -1
- package/dist/record/exportsContext.d.ts +2 -10
- package/dist/record/exportsContext.js +5 -33
- package/dist/record/pathToRecord.js +7 -8
- package/dist/record/regenerate.d.ts +4 -5
- package/dist/record/regenerate.js +5 -5
- package/dist/record/sees.d.ts +2 -2
- package/dist/record/sees.js +3 -3
- package/dist/record/storageOf.js +1 -7
- package/dist/record/types.d.ts +7 -10
- package/dist/records/history.d.ts +1 -1
- package/dist/records/history.js +1 -1
- package/dist/records/lib/landedIn.d.ts +1 -1
- package/dist/records/lib/landedIn.js +1 -1
- package/dist/records/recordsCommand.js +2 -2
- package/dist/repos/lib/relPath.js +3 -4
- package/dist/repos/materializeRepo.js +1 -1
- package/dist/runtime/exportsFacts.d.ts +1 -13
- package/dist/runtime/exportsFacts.js +2 -6
- package/dist/scripts/migrate-stubs.js +54 -72
- package/dist/statusCommand.js +2 -83
- package/dist/store/Store.d.ts +13 -31
- package/dist/store/Store.js +17 -51
- package/dist/store/add.js +1 -1
- package/dist/store/addedDates.js +5 -5
- package/dist/store/external.d.ts +1 -3
- package/dist/store/external.js +2 -12
- package/dist/store/lib/applyMirrorEdits.js +2 -3
- package/dist/store/lib/assertUnambiguous.js +1 -1
- package/dist/store/lib/checkRefs.d.ts +2 -5
- package/dist/store/lib/checkRefs.js +4 -7
- package/dist/store/lib/commit.js +3 -6
- package/dist/store/lib/idsKey.js +2 -3
- package/dist/store/lib/indexAdd.js +0 -2
- package/dist/store/lib/validate.d.ts +1 -2
- package/dist/store/lib/validate.js +2 -2
- package/dist/store/lib/walkIds.js +0 -23
- package/dist/store/recordFiles.js +1 -4
- package/dist/store/recordRoot.js +0 -7
- package/dist/store/rename.js +2 -11
- package/dist/store/revert.js +2 -2
- package/dist/store/set.js +1 -1
- package/dist/store/types.d.ts +0 -5
- package/dist/store/vouched.d.ts +2 -2
- package/dist/store/vouched.js +4 -5
- package/dist/types.d.ts +3 -37
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +18 -28
- package/dist/workspace/discoverModules.d.ts +2 -4
- package/dist/workspace/discoverModules.js +5 -43
- package/dist/workspace/findWorkspace.js +3 -3
- package/dist/workspace/lib/aheadCount.d.ts +1 -1
- package/dist/workspace/lib/aheadCount.js +1 -1
- package/dist/workspace/types.d.ts +2 -7
- package/package.json +1 -1
- package/skills/using-dreamteamer/SKILL.md +9 -10
- package/skills/using-dreamteamer/references/before-you-build.md +2 -2
- package/skills/using-dreamteamer/references/changes.md +6 -7
- package/skills/using-dreamteamer/references/collections.md +22 -91
- package/skills/using-dreamteamer/references/records.md +1 -2
- package/skills/using-dreamteamer/references/writing-a-module.md +2 -2
- package/dist/changes/layerOf.d.ts +0 -6
- package/dist/changes/layerOf.js +0 -12
- package/dist/install/buildClone.d.ts +0 -5
- package/dist/install/buildClone.js +0 -22
- package/dist/install/commitOf.d.ts +0 -1
- package/dist/install/commitOf.js +0 -2
- package/dist/install/install.d.ts +0 -8
- package/dist/install/install.js +0 -177
- package/dist/install/installClone.d.ts +0 -6
- package/dist/install/installClone.js +0 -32
- package/dist/install/isLink.d.ts +0 -1
- package/dist/install/isLink.js +0 -9
- package/dist/install/offRef.d.ts +0 -7
- package/dist/install/offRef.js +0 -19
- package/dist/record/ownersReadIn.d.ts +0 -9
- package/dist/record/ownersReadIn.js +0 -11
- package/dist/update/update.d.ts +0 -7
- package/dist/update/update.js +0 -57
- package/dist/workspace/declaredGitModules.d.ts +0 -51
- package/dist/workspace/declaredGitModules.js +0 -89
- package/dist/workspace/layerEntries.d.ts +0 -16
- package/dist/workspace/layerEntries.js +0 -36
package/bin/dreamteamer.js
CHANGED
|
@@ -1,34 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// self-shadowing (decision 24, applied to the engine itself): when the workspace carries a
|
|
3
|
-
// git_modules/dreamteamer working clone, THAT engine runs — same npm-link semantics module
|
|
4
|
-
// content already gets. the npm-installed copy is bootstrap + fallback; the dev clone wins.
|
|
5
2
|
import fs from "node:fs"
|
|
6
3
|
import path from "node:path"
|
|
7
|
-
import {
|
|
4
|
+
import { fileURLToPath } from "node:url"
|
|
8
5
|
|
|
9
|
-
// path
|
|
10
|
-
// workspace. Declared up here, not beside findDevClone: that call sits at module top level, so a
|
|
11
|
-
// `const` below it is still in its temporal dead zone when the walk needs it.
|
|
12
|
-
const MODULE_SEGMENTS = new Set(["node_modules", "git_modules", "modules"])
|
|
13
|
-
|
|
14
|
-
const self = fileURLToPath(import.meta.url)
|
|
15
|
-
|
|
16
|
-
// `--workspace <name-or-path>` / `-w` — run the verb in ANOTHER workspace without leaving this one
|
|
6
|
+
// `--workspace <path>` / `-w` — run the verb in ANOTHER workspace without leaving this one
|
|
17
7
|
// (`--vault <path>` is its pre-0.41.0 spelling, kept as a silent alias). Consumed HERE, before
|
|
18
8
|
// anything else resolves, because every verb downstream answers "which workspace am I in" from
|
|
19
|
-
// process.cwd(): changing the directory once IS the whole implementation
|
|
20
|
-
// dev-clone walk below at the TARGET's git_modules rather than the caller's.
|
|
21
|
-
//
|
|
22
|
-
// ⚠ It is spliced out of process.argv, not just out of the slice handed to run(): the dev-clone
|
|
23
|
-
// branch re-enters this same file, and a flag left in place would be applied a SECOND time — the
|
|
24
|
-
// path resolving against the already-changed directory, i.e. at the wrong workspace, silently.
|
|
9
|
+
// process.cwd(): changing the directory once IS the whole implementation.
|
|
25
10
|
//
|
|
26
|
-
//
|
|
27
|
-
// relative path in the command then resolves against the target — the rule a `cd` would give.
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// for this process only: a clone under git_modules/ is otherwise climbed out of by discovery, which
|
|
31
|
-
// would run the verb in the workspace AROUND it — a write landing in the reader and printing ✔.
|
|
11
|
+
// The PATH resolves against the INVOKING directory, which is where the caller typed it; every other
|
|
12
|
+
// relative path in the command then resolves against the target — the rule a `cd` would give. The
|
|
13
|
+
// target is PINNED for this process only: a workspace nested under another's modules/ is otherwise
|
|
14
|
+
// climbed out of by discovery, which would run the verb in the workspace AROUND it.
|
|
32
15
|
// `--workspace=<x>` (npm's spelling too) is the same flag in one argument.
|
|
33
16
|
//
|
|
34
17
|
// The scan stops where `dt run <module> <script>` hands its arguments to the script: those are the
|
|
@@ -45,7 +28,7 @@ if (flagAt !== -1) {
|
|
|
45
28
|
console.error(
|
|
46
29
|
flag === "--vault"
|
|
47
30
|
? "\u2716 --vault needs a path to a workspace, e.g. `--vault ../another-workspace`"
|
|
48
|
-
: "\u2716 --workspace needs a
|
|
31
|
+
: "\u2716 --workspace needs a path to a workspace, e.g. `-w ../another-workspace`"
|
|
49
32
|
)
|
|
50
33
|
process.exit(1)
|
|
51
34
|
}
|
|
@@ -54,54 +37,20 @@ if (flagAt !== -1) {
|
|
|
54
37
|
console.error(`\u2716 ${flag} ${target} \u2014 ${why}`)
|
|
55
38
|
process.exit(1)
|
|
56
39
|
}
|
|
57
|
-
|
|
58
|
-
if (!fs.existsSync(resolved))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const layers = here ? declaredLayers(here) : new Map()
|
|
62
|
-
if (/[\\/]/.test(target) || !layers.has(target))
|
|
63
|
-
refuse(
|
|
64
|
-
`no such directory, and no layer of that name is declared here (declared layers: ${
|
|
65
|
-
[...layers]
|
|
66
|
-
.filter(([, k]) => k === "layer")
|
|
67
|
-
.map(([n]) => n)
|
|
68
|
-
.join(", ") || "none"
|
|
69
|
-
})`
|
|
70
|
-
)
|
|
71
|
-
resolved = path.join(here, "git_modules", target)
|
|
72
|
-
if (layers.get(target) === "bundle")
|
|
73
|
-
refuse(
|
|
74
|
-
`git_modules/${target} is a bundle (its package.json names no workspace_module), not a workspace — there is nothing to run a verb in`
|
|
75
|
-
)
|
|
76
|
-
if (!fs.existsSync(resolved))
|
|
77
|
-
refuse(`the layer is declared but not installed (${resolved}); run dreamteamer install`)
|
|
78
|
-
}
|
|
79
|
-
// the TARGET must be a workspace root: a plain folder (one that merely shares a layer's name, say)
|
|
80
|
-
// would be pinned, discovery would climb out of it, and the verb would run in the workspace around it
|
|
40
|
+
const resolved = path.resolve(process.cwd(), target)
|
|
41
|
+
if (!fs.existsSync(resolved)) refuse("no such directory")
|
|
42
|
+
// the TARGET must be a workspace root: a plain folder would be pinned, discovery would climb out
|
|
43
|
+
// of it, and the verb would run in the workspace around it
|
|
81
44
|
if (!isWorkspaceDir(resolved)) refuse(`${resolved} is not a workspace (no package.json with a "dreamteamer" section)`)
|
|
82
45
|
process.chdir(resolved)
|
|
83
|
-
// PROCESS-LOCAL, never an environment variable:
|
|
84
|
-
//
|
|
85
|
-
// an extension spawning dt — and a dt run inside the clone by any of them answered from the layer
|
|
86
|
-
// alone instead of the reader's union.
|
|
46
|
+
// PROCESS-LOCAL, never an environment variable: an env var would reach every child — git hooks, an
|
|
47
|
+
// extension spawning dt — and pin each of them to this workspace too.
|
|
87
48
|
pinned()[Symbol.for("dreamteamer.workspace")] = process.cwd() // the physical path, as discovery will see it
|
|
88
49
|
process.argv.splice(flagAt, joined ? 1 : 2)
|
|
89
50
|
}
|
|
90
51
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
// workspace whose git_modules/dreamteamer is a SYMLINK to the engine it is already running (the
|
|
94
|
-
// normal shape for a dev clone, and a common shape under a repos folder) compared two spellings
|
|
95
|
-
// of one file, decided they differed, and re-imported itself — a circular import that never
|
|
96
|
-
// settles, so the process exited silently having done nothing at all. Worse than a crash: every
|
|
97
|
-
// command "succeeded" with no output and no effect.
|
|
98
|
-
if (devBin && realpath(devBin) !== realpath(self)) {
|
|
99
|
-
console.error(`… running the git_modules/dreamteamer dev clone (shadows the installed engine)`)
|
|
100
|
-
await import(pathToFileURL(devBin).href)
|
|
101
|
-
} else {
|
|
102
|
-
const { run } = await import(engineEntry("cli"))
|
|
103
|
-
run(process.argv.slice(2))
|
|
104
|
-
}
|
|
52
|
+
const { run } = await import(engineEntry("cli"))
|
|
53
|
+
run(process.argv.slice(2))
|
|
105
54
|
|
|
106
55
|
/** Where `dt run`'s pass-through arguments begin — after the verb, the module and the script —
|
|
107
56
|
* or argv's length for every other verb. A global flag before the verb is skipped with its value.
|
|
@@ -132,50 +81,6 @@ function engineEntry(name) {
|
|
|
132
81
|
return entry.href
|
|
133
82
|
}
|
|
134
83
|
|
|
135
|
-
/** Canonical on-disk identity of a path — symlinks followed, falling back to the literal path. */
|
|
136
|
-
/** @param {string} p @returns {string} */
|
|
137
|
-
function realpath(p) {
|
|
138
|
-
try {
|
|
139
|
-
return fs.realpathSync(p)
|
|
140
|
-
} catch {
|
|
141
|
-
return path.resolve(p)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// same workspace rule as src/lib/workspace.ts (nearest package.json with a `dreamteamer` key, climbing
|
|
146
|
-
// out only of module nesting), duplicated here because the dev clone must be found BEFORE choosing
|
|
147
|
-
// which src/ to load. Keep the two in step — they must never disagree about which workspace this is.
|
|
148
|
-
/** @param {string} start @returns {string | null} */
|
|
149
|
-
function findWorkspaceRoot(start) {
|
|
150
|
-
let dir = path.resolve(start)
|
|
151
|
-
const candidates = [] // nearest → topmost
|
|
152
|
-
while (true) {
|
|
153
|
-
const p = path.join(dir, "package.json")
|
|
154
|
-
if (fs.existsSync(p)) {
|
|
155
|
-
try {
|
|
156
|
-
if ("dreamteamer" in JSON.parse(fs.readFileSync(p, "utf8"))) candidates.push(dir)
|
|
157
|
-
} catch {
|
|
158
|
-
/* unparseable — keep walking */
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const parent = path.dirname(dir)
|
|
162
|
-
if (parent === dir) break
|
|
163
|
-
dir = parent
|
|
164
|
-
}
|
|
165
|
-
if (!candidates.length) return null
|
|
166
|
-
let workspace = candidates[0]
|
|
167
|
-
for (const higher of candidates.slice(1)) {
|
|
168
|
-
if (workspace === pinned()[Symbol.for("dreamteamer.workspace")]) break // an explicitly targeted workspace is never climbed out of
|
|
169
|
-
const viaModule = path
|
|
170
|
-
.relative(higher, workspace)
|
|
171
|
-
.split(path.sep)
|
|
172
|
-
.some(seg => MODULE_SEGMENTS.has(seg))
|
|
173
|
-
if (!viaModule) break
|
|
174
|
-
workspace = higher
|
|
175
|
-
}
|
|
176
|
-
return workspace
|
|
177
|
-
}
|
|
178
|
-
|
|
179
84
|
/** Does a directory's package.json carry a `dreamteamer` section — is it a workspace (or module) root? */
|
|
180
85
|
/** @param {string} dir @returns {boolean} */
|
|
181
86
|
function isWorkspaceDir(dir) {
|
|
@@ -185,40 +90,3 @@ function isWorkspaceDir(dir) {
|
|
|
185
90
|
return false
|
|
186
91
|
}
|
|
187
92
|
}
|
|
188
|
-
|
|
189
|
-
/** The git_modules entries a workspace declares, name -> 'layer' | 'bundle' — the rule of
|
|
190
|
-
* src/lib/workspace.ts layerEntries, restated because this file runs before any src/ is chosen: `records`
|
|
191
|
-
* or `module: true` declares a layer, a clone on disk is a layer when its manifest names
|
|
192
|
-
* `workspace_module`, and one not on disk is a layer not installed. */
|
|
193
|
-
/** @param {string} root @returns {Map<string, "layer" | "bundle">} */
|
|
194
|
-
function declaredLayers(root) {
|
|
195
|
-
/** @type {Map<string, "layer" | "bundle">} */
|
|
196
|
-
const out = new Map()
|
|
197
|
-
/** @type {Record<string, { records?: unknown; module?: unknown }>} */
|
|
198
|
-
let entries = {}
|
|
199
|
-
try {
|
|
200
|
-
entries = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8")).dreamteamer?.git_modules ?? {}
|
|
201
|
-
} catch {
|
|
202
|
-
/* none */
|
|
203
|
-
}
|
|
204
|
-
for (const [name, e] of Object.entries(entries)) {
|
|
205
|
-
const clone = path.join(root, "git_modules", name)
|
|
206
|
-
let wm = null
|
|
207
|
-
try {
|
|
208
|
-
wm = JSON.parse(fs.readFileSync(path.join(clone, "package.json"), "utf8")).dreamteamer?.workspace_module ?? null
|
|
209
|
-
} catch {
|
|
210
|
-
/* absent */
|
|
211
|
-
}
|
|
212
|
-
const layer = e?.records !== undefined || e?.module === true || !fs.existsSync(clone) || !!wm
|
|
213
|
-
out.set(name, layer ? "layer" : "bundle")
|
|
214
|
-
}
|
|
215
|
-
return out
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/** @param {string} start @returns {string | null} */
|
|
219
|
-
function findDevClone(start) {
|
|
220
|
-
const workspace = findWorkspaceRoot(start)
|
|
221
|
-
if (!workspace) return null
|
|
222
|
-
const bin = path.join(workspace, "git_modules", "dreamteamer", "bin", "dreamteamer.js")
|
|
223
|
-
return fs.existsSync(bin) ? bin : null
|
|
224
|
-
}
|
|
@@ -39,7 +39,7 @@ fields:
|
|
|
39
39
|
location:
|
|
40
40
|
type: string
|
|
41
41
|
required: true
|
|
42
|
-
enum: [modules,
|
|
42
|
+
enum: [modules, node_modules, root]
|
|
43
43
|
passthrough: true
|
|
44
44
|
description: >-
|
|
45
45
|
Where this module's sources sit — the folder name, so `dt status` needs no legend. `root` is the
|
|
@@ -7,7 +7,7 @@ use_when: >-
|
|
|
7
7
|
per machine) before assuming a path or concluding a clone is unreachable; `dt status` reports
|
|
8
8
|
each one and `dt install repos/<id>` materializes it
|
|
9
9
|
# Owns CLONE LIFECYCLE ONLY — a repo record never contributes schema, skills or UI (that is what a
|
|
10
|
-
# module is,
|
|
10
|
+
# module is, under modules/<id>/ or pinned in package.json, because modules must be installable
|
|
11
11
|
# BEFORE compile can run). Working trees are materialized on demand, never as part of making a
|
|
12
12
|
# checkout ready. Internal: workspace plumbing rather than a domain noun, so it is drawn on the
|
|
13
13
|
# schema surface; its records are ordinary, writable, committed data.
|
package/dist/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { findWorkspace } from "./workspace/findWorkspace.js";
|
|
2
2
|
import type { Workspace } from "./types.js";
|
|
3
3
|
export * from "./records-api.js";
|
|
4
|
-
export type { Workspace, PackageJson, DreamteamerBlock,
|
|
4
|
+
export type { Workspace, PackageJson, DreamteamerBlock, Flags, Contribution, CheckItem, DoctorRow, ExtensionContext, Activate, LoadedExtension, Entry, CompileDraft, HarnessContext, TemplatePart, SchemaOp, NavDoc, NavEntry, NavWarning, } from "./types.js";
|
|
5
5
|
import { openWorkspace } from "./openWorkspace.js";
|
|
6
6
|
export { openWorkspace };
|
|
7
7
|
export { findWorkspace };
|
|
@@ -70,7 +70,6 @@ export { setEntityFrontmatter } from "./entities/setEntityFrontmatter.js";
|
|
|
70
70
|
export { init } from "./init/init.js";
|
|
71
71
|
export { ensureRepo, ensureAllRepos } from "./repos/repos.js";
|
|
72
72
|
export { listRepos } from "./repos/listRepos.js";
|
|
73
|
-
export { installClone } from "./install/installClone.js";
|
|
74
73
|
export { describeCheckout } from "./lib/git/describeCheckout.js";
|
|
75
74
|
export { resolveNpm } from "./lib/npm/resolveNpm.js";
|
|
76
75
|
export { childEnv } from "./lib/childEnv.js";
|
package/dist/api.js
CHANGED
|
@@ -122,7 +122,6 @@ export { setEntityFrontmatter } from "./entities/setEntityFrontmatter.js";
|
|
|
122
122
|
export { init } from "./init/init.js";
|
|
123
123
|
export { ensureRepo, ensureAllRepos } from "./repos/repos.js";
|
|
124
124
|
export { listRepos } from "./repos/listRepos.js";
|
|
125
|
-
export { installClone } from "./install/installClone.js";
|
|
126
125
|
export { describeCheckout } from "./lib/git/describeCheckout.js";
|
|
127
126
|
export { resolveNpm } from "./lib/npm/resolveNpm.js";
|
|
128
127
|
export { childEnv } from "./lib/childEnv.js";
|
|
@@ -402,14 +402,6 @@ function scopeByRepo(descriptors, only) {
|
|
|
402
402
|
if (!byRepo.has(repo))
|
|
403
403
|
byRepo.set(repo, []);
|
|
404
404
|
byRepo.get(repo).push(p);
|
|
405
|
-
// a record layer's root is watched in the LAYER's repo — an edit of one of its records is
|
|
406
|
-
// published there, and skipping it is the "nothing pending" that looks like success
|
|
407
|
-
for (const r of storageOf(d).roots.slice(1)) {
|
|
408
|
-
if (!byRepo.has(r.repo))
|
|
409
|
-
byRepo.set(r.repo, []);
|
|
410
|
-
if (!byRepo.get(r.repo).includes(r.path))
|
|
411
|
-
byRepo.get(r.repo).push(r.path);
|
|
412
|
-
}
|
|
413
405
|
// A collection stored UNDER another keeps most of its files inside the parent's folder, so
|
|
414
406
|
// scoping `git status` to its own path alone would sample only the fallback root and report
|
|
415
407
|
// the rest as "nothing pending" — the one report that looks like success. The parent's path
|
|
@@ -550,10 +542,8 @@ function commitPlan(store, { only = [], message, dryRun = false } = {}) {
|
|
|
550
542
|
// repo's rows before it can tell a renamed record from a concurrent deletion.
|
|
551
543
|
const sampled = [];
|
|
552
544
|
for (const [repo, dirs] of byRepo) {
|
|
553
|
-
// A
|
|
554
|
-
//
|
|
555
|
-
// the WHOLE verb, so not one record of this workspace could be published; check and status
|
|
556
|
-
// already say the layer is not installed.
|
|
545
|
+
// A repo folder that does not exist has nothing pending; spawning git there would throw ENOENT
|
|
546
|
+
// out of the whole verb.
|
|
557
547
|
if (repo !== "." && !fs.existsSync(path.resolve(store.root, repo)))
|
|
558
548
|
continue;
|
|
559
549
|
const { cwd, rows } = sample(store.root, repo, dirs, store.descriptors);
|
package/dist/changes/consts.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type ChangeKind, type EventType } from "./types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* ── the record-change report (0.42.0) ────────────────────────────────────────────────────────────
|
|
4
4
|
* What `dt changes` and `dt commit` print, and what a session appends to its reply after a write.
|
|
5
|
-
* A change is `{ collection, id, ref, path, repo,
|
|
5
|
+
* A change is `{ collection, id, ref, path, repo, change }` with `change` one of the three
|
|
6
6
|
* words the report uses; `deriveEvents`' `item-*` types are the same three facts, older spelling.
|
|
7
7
|
*/
|
|
8
8
|
export declare const CHANGE_OF: Record<EventType, ChangeKind>;
|
package/dist/changes/consts.js
CHANGED
|
@@ -2,7 +2,7 @@ import {} from "./types.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* ── the record-change report (0.42.0) ────────────────────────────────────────────────────────────
|
|
4
4
|
* What `dt changes` and `dt commit` print, and what a session appends to its reply after a write.
|
|
5
|
-
* A change is `{ collection, id, ref, path, repo,
|
|
5
|
+
* A change is `{ collection, id, ref, path, repo, change }` with `change` one of the three
|
|
6
6
|
* words the report uses; `deriveEvents`' `item-*` types are the same three facts, older spelling.
|
|
7
7
|
*/
|
|
8
8
|
export const CHANGE_OF = {
|
|
@@ -11,9 +11,7 @@ interface RecordEvent {
|
|
|
11
11
|
* Record events between two points, across EVERY repo that holds records. `from` is a sha or a
|
|
12
12
|
* date — a sha is meaningless in another repo, so it is resolved to its commit DATE and each
|
|
13
13
|
* repo then resolves that date to its own sha. Still cursor-less and stores nothing, so it can
|
|
14
|
-
* be run twice with no consequence.
|
|
15
|
-
* each record layer's — and an event carries the repo it was read from; sampling the write root
|
|
16
|
-
* alone answered `events: []` for a commit made in a layer's clone.
|
|
14
|
+
* be run twice with no consequence. An event carries the repo it was read from.
|
|
17
15
|
*/
|
|
18
16
|
export declare function deriveEvents(root: string, descriptors: Descriptors, from: string, to?: string): RecordEvent[];
|
|
19
17
|
export {};
|
|
@@ -7,9 +7,7 @@ import { storageOf } from "../record/storageOf.js";
|
|
|
7
7
|
* Record events between two points, across EVERY repo that holds records. `from` is a sha or a
|
|
8
8
|
* date — a sha is meaningless in another repo, so it is resolved to its commit DATE and each
|
|
9
9
|
* repo then resolves that date to its own sha. Still cursor-less and stores nothing, so it can
|
|
10
|
-
* be run twice with no consequence.
|
|
11
|
-
* each record layer's — and an event carries the repo it was read from; sampling the write root
|
|
12
|
-
* alone answered `events: []` for a commit made in a layer's clone.
|
|
10
|
+
* be run twice with no consequence. An event carries the repo it was read from.
|
|
13
11
|
*/
|
|
14
12
|
export function deriveEvents(root, descriptors, from, to = "HEAD") {
|
|
15
13
|
commitArg(to);
|
|
@@ -19,14 +17,13 @@ export function deriveEvents(root, descriptors, from, to = "HEAD") {
|
|
|
19
17
|
continue; // runtime entities aren't item events
|
|
20
18
|
if (storageOf(d).external || storageOf(d).unavailable)
|
|
21
19
|
continue; // an env-pointed root: no repo here holds its history
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
20
|
+
const { path: p, repo } = storageOf(d);
|
|
21
|
+
if (!p)
|
|
22
|
+
continue;
|
|
23
|
+
if (!byRepo.has(repo))
|
|
24
|
+
byRepo.set(repo, []);
|
|
25
|
+
if (!byRepo.get(repo).includes(p))
|
|
26
|
+
byRepo.get(repo).push(p);
|
|
30
27
|
}
|
|
31
28
|
const when = asDate(root, from);
|
|
32
29
|
const events = [];
|
|
@@ -5,8 +5,7 @@ import type { RecordChange } from "./types.js";
|
|
|
5
5
|
* twice only as a MOVE (a relocate, a placed record re-parented: deleted at one path, created at
|
|
6
6
|
* another), which is one update at the live path. Across the halves the net change wins: created
|
|
7
7
|
* then deleted never existed at either end and is dropped; created then edited is still created;
|
|
8
|
-
* deleted then re-created is an update. The SAME ref in two repos is two records
|
|
9
|
-
* is not the workspace's.
|
|
8
|
+
* deleted then re-created is an update. The SAME ref in two repos is two records.
|
|
10
9
|
*/
|
|
11
10
|
export declare function foldChanges<T extends RecordChange>(before: T[], after: T[]): (T & {
|
|
12
11
|
committed: boolean;
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* twice only as a MOVE (a relocate, a placed record re-parented: deleted at one path, created at
|
|
5
5
|
* another), which is one update at the live path. Across the halves the net change wins: created
|
|
6
6
|
* then deleted never existed at either end and is dropped; created then edited is still created;
|
|
7
|
-
* deleted then re-created is an update. The SAME ref in two repos is two records
|
|
8
|
-
* is not the workspace's.
|
|
7
|
+
* deleted then re-created is an update. The SAME ref in two repos is two records.
|
|
9
8
|
*/
|
|
10
9
|
export function foldChanges(before, after) {
|
|
11
10
|
const key = (c) => `${c.repo}\0${c.ref}`;
|
|
@@ -36,7 +35,7 @@ export function foldChanges(before, after) {
|
|
|
36
35
|
else
|
|
37
36
|
out.delete(k);
|
|
38
37
|
}
|
|
39
|
-
const order = (c) => [c.collection, c.
|
|
38
|
+
const order = (c) => [c.collection, c.id];
|
|
40
39
|
return [...out.values()].sort((a, b) => {
|
|
41
40
|
const [x, y] = [order(a), order(b)];
|
|
42
41
|
for (let i = 0; i < x.length; i++)
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { ChangeGroup, RecordChange } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* One group per collection AND layer, in the order `foldChanges` sorted them: a collection changed
|
|
4
|
-
* both here and in a layer is two entries, so the line never hides which repo a write landed in.
|
|
5
|
-
*/
|
|
2
|
+
/** One group per collection, in the order `foldChanges` sorted them. */
|
|
6
3
|
export declare function groupChanges<T extends RecordChange>(changes: T[]): ChangeGroup<T>[];
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One group per collection AND layer, in the order `foldChanges` sorted them: a collection changed
|
|
3
|
-
* both here and in a layer is two entries, so the line never hides which repo a write landed in.
|
|
4
|
-
*/
|
|
1
|
+
/** One group per collection, in the order `foldChanges` sorted them. */
|
|
5
2
|
export function groupChanges(changes) {
|
|
6
3
|
const groups = new Map();
|
|
7
4
|
for (const c of changes) {
|
|
8
|
-
const k =
|
|
5
|
+
const k = c.collection;
|
|
9
6
|
if (!groups.has(k))
|
|
10
7
|
groups.set(k, {
|
|
11
8
|
collection: c.collection,
|
|
12
|
-
layer: c.layer ?? null,
|
|
13
9
|
created: 0,
|
|
14
10
|
updated: 0,
|
|
15
11
|
deleted: 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChangeGroup } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* `records — contacts: 1 created, 2 updated · issues
|
|
3
|
+
* `records — contacts: 1 created, 2 updated · issues: 1 created` — the report's first
|
|
4
4
|
* line, the one the skill tells a session to end its reply with. Empty when nothing changed: the
|
|
5
5
|
* rule is that nothing written appends nothing.
|
|
6
6
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `records — contacts: 1 created, 2 updated · issues
|
|
2
|
+
* `records — contacts: 1 created, 2 updated · issues: 1 created` — the report's first
|
|
3
3
|
* line, the one the skill tells a session to end its reply with. Empty when nothing changed: the
|
|
4
4
|
* rule is that nothing written appends nothing.
|
|
5
5
|
*/
|
|
@@ -10,5 +10,5 @@ export function reportLine(groups) {
|
|
|
10
10
|
.filter(w => g[w])
|
|
11
11
|
.map(w => `${g[w]} ${w}`)
|
|
12
12
|
.join(", ");
|
|
13
|
-
return `records — ${groups.map(g => `${g.collection}
|
|
13
|
+
return `records — ${groups.map(g => `${g.collection}: ${counts(g)}`).join(" · ")}`;
|
|
14
14
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RecordChange } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* The record-change report: the report line, then one row per record — its change, ref, workspace
|
|
4
|
-
* path (what a reply links to), committed or not
|
|
4
|
+
* path (what a reply links to), and committed or not — capped like every
|
|
5
5
|
* other listing here. `dt changes` and `dt commit` print it identically, so what a session copies
|
|
6
6
|
* into its reply does not depend on which of the two it ran.
|
|
7
7
|
*/
|
|
@@ -3,7 +3,7 @@ import { groupChanges } from "./groupChanges.js";
|
|
|
3
3
|
import { reportLine } from "./lib/reportLine.js";
|
|
4
4
|
/**
|
|
5
5
|
* The record-change report: the report line, then one row per record — its change, ref, workspace
|
|
6
|
-
* path (what a reply links to), committed or not
|
|
6
|
+
* path (what a reply links to), and committed or not — capped like every
|
|
7
7
|
* other listing here. `dt changes` and `dt commit` print it identically, so what a session copies
|
|
8
8
|
* into its reply does not depend on which of the two it ran.
|
|
9
9
|
*/
|
|
@@ -13,7 +13,7 @@ export function printChanges(changes) {
|
|
|
13
13
|
const rows = groups.flatMap(g => g.records);
|
|
14
14
|
for (const c of rows.slice(0, ROWS_SHOWN)) {
|
|
15
15
|
const state = c.committed ? `committed${c.sha ? ` ${c.sha}` : ""}` : "uncommitted";
|
|
16
|
-
console.log(` ${c.change.padEnd(7)} ${c.ref} ${c.path} · ${state}
|
|
16
|
+
console.log(` ${c.change.padEnd(7)} ${c.ref} ${c.path} · ${state}`);
|
|
17
17
|
}
|
|
18
18
|
if (rows.length > ROWS_SHOWN)
|
|
19
19
|
console.log(` + ${rows.length - ROWS_SHOWN} more — --json lists every record`);
|
|
@@ -2,7 +2,6 @@ import { CHANGE_OF, TYPE_OF } from "./consts.js";
|
|
|
2
2
|
import { deriveEvents } from "./deriveEvents.js";
|
|
3
3
|
import { commitPending } from "./commitPending.js";
|
|
4
4
|
import { foldChanges } from "./foldChanges.js";
|
|
5
|
-
import { layerOf } from "./layerOf.js";
|
|
6
5
|
import { rowChanges } from "./rowChanges.js";
|
|
7
6
|
/**
|
|
8
7
|
* `dt changes`: the records changed since `since`, across every repo that holds records. `HEAD` (the
|
|
@@ -24,7 +23,6 @@ export function recordChanges(store, { since = "HEAD" } = {}) {
|
|
|
24
23
|
ref: `${e.collection}/${e.id}`,
|
|
25
24
|
path: e.path,
|
|
26
25
|
repo: e.repo,
|
|
27
|
-
layer: layerOf(store.descriptors, e.repo),
|
|
28
26
|
change: CHANGE_OF[e.type],
|
|
29
27
|
}));
|
|
30
28
|
// `type` is the 0.41.0 spelling of `change`, kept so a reader of the old JSON keeps working
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { layerOf } from "./layerOf.js";
|
|
2
1
|
import { pathToRecord } from "../record/pathToRecord.js";
|
|
3
2
|
/**
|
|
4
3
|
* One sampled repo's rows (the sampler above: `dt commit`, `dt status`) as report changes. A staged
|
|
@@ -6,14 +5,12 @@ import { pathToRecord } from "../record/pathToRecord.js";
|
|
|
6
5
|
*/
|
|
7
6
|
export function rowChanges(descriptors, repo, rows) {
|
|
8
7
|
const prefix = repo === "." ? "" : `${repo}/`;
|
|
9
|
-
const layer = layerOf(descriptors, repo);
|
|
10
8
|
const of = (rec, rel, change) => ({
|
|
11
9
|
collection: rec.collection,
|
|
12
10
|
id: rec.id,
|
|
13
11
|
ref: `${rec.collection}/${rec.id}`,
|
|
14
12
|
path: prefix + rel,
|
|
15
13
|
repo,
|
|
16
|
-
layer,
|
|
17
14
|
change,
|
|
18
15
|
});
|
|
19
16
|
const out = [];
|
package/dist/changes/types.d.ts
CHANGED
|
@@ -15,12 +15,10 @@ export interface RecordChange {
|
|
|
15
15
|
ref: string;
|
|
16
16
|
repo: string;
|
|
17
17
|
change: ChangeKind;
|
|
18
|
-
layer?: string | null;
|
|
19
18
|
path?: string;
|
|
20
19
|
}
|
|
21
20
|
export interface ChangeGroup<T extends RecordChange = RecordChange> {
|
|
22
21
|
collection: string;
|
|
23
|
-
layer: string | null;
|
|
24
22
|
created: number;
|
|
25
23
|
updated: number;
|
|
26
24
|
deleted: number;
|