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
|
@@ -4,92 +4,83 @@ import { execFileSync } from "node:child_process";
|
|
|
4
4
|
import { planExports } from "./planExports.js";
|
|
5
5
|
import { EXPORTS_FILE } from "../record/consts.js";
|
|
6
6
|
import { inProgress } from "../lib/git/inProgress.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
fs.writeFileSync(plan.file, plan.text);
|
|
26
|
-
// a merge, rebase, cherry-pick or revert refuses a one-path commit: write, and say how to finish
|
|
27
|
-
const busy = inProgress(plan.dir);
|
|
28
|
-
if (busy)
|
|
29
|
-
note = `${busy} — the manifest is written; git add it and conclude it`;
|
|
30
|
-
else {
|
|
31
|
-
const git = (args) => {
|
|
32
|
-
try {
|
|
33
|
-
return execFileSync("git", args, { cwd: plan.dir, stdio: ["ignore", "pipe", "pipe"] })
|
|
34
|
-
.toString()
|
|
35
|
-
.trim();
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
throw new Error(`git ${args[0]} in ${path.relative(store.root, plan.dir) || "."} failed: ${String(e.stderr || e.message).trim()}`, { cause: e });
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
// an emptied manifest git never tracked: nothing to add, nothing to commit
|
|
42
|
-
// an emptied manifest is un-staged with --ignore-unmatch: one git never tracked leaves nothing to commit
|
|
43
|
-
git(plan.text === null
|
|
44
|
-
? ["rm", "--cached", "-q", "--ignore-unmatch", "--", EXPORTS_FILE]
|
|
45
|
-
: ["add", "--", EXPORTS_FILE]);
|
|
46
|
-
// back to what HEAD already holds (a hand edit undone), or never tracked: nothing to commit
|
|
47
|
-
let same = false;
|
|
7
|
+
/** Write (and commit) this workspace's manifest; returns the exit code. */
|
|
8
|
+
export function runExports(store, { dryRun = false, json = false } = {}) {
|
|
9
|
+
const plan = planExports(store);
|
|
10
|
+
const before = fs.existsSync(plan.file) ? fs.readFileSync(plan.file, "utf8") : null;
|
|
11
|
+
const where = path.relative(store.root, plan.file);
|
|
12
|
+
let committed = null;
|
|
13
|
+
let note = null;
|
|
14
|
+
if (!dryRun && before !== plan.text) {
|
|
15
|
+
if (plan.text === null)
|
|
16
|
+
fs.rmSync(plan.file);
|
|
17
|
+
else
|
|
18
|
+
fs.writeFileSync(plan.file, plan.text);
|
|
19
|
+
// a merge, rebase, cherry-pick or revert refuses a one-path commit: write, and say how to finish
|
|
20
|
+
const busy = inProgress(plan.dir);
|
|
21
|
+
if (busy)
|
|
22
|
+
note = `${busy} — the manifest is written; git add it and conclude it`;
|
|
23
|
+
else {
|
|
24
|
+
const git = (args) => {
|
|
48
25
|
try {
|
|
49
|
-
execFileSync("git",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
same = true;
|
|
26
|
+
return execFileSync("git", args, { cwd: plan.dir, stdio: ["ignore", "pipe", "pipe"] })
|
|
27
|
+
.toString()
|
|
28
|
+
.trim();
|
|
54
29
|
}
|
|
55
|
-
catch {
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (!same) {
|
|
59
|
-
git([
|
|
60
|
-
"commit",
|
|
61
|
-
"--only",
|
|
62
|
-
"-q",
|
|
63
|
-
"-m",
|
|
64
|
-
`dreamteamer: exports — ${plan.entries} entr${plan.entries === 1 ? "y" : "ies"}`,
|
|
65
|
-
"--",
|
|
66
|
-
EXPORTS_FILE,
|
|
67
|
-
]);
|
|
68
|
-
committed = git(["rev-parse", "--short", "HEAD"]);
|
|
30
|
+
catch (e) {
|
|
31
|
+
throw new Error(`git ${args[0]} in ${path.relative(store.root, plan.dir) || "."} failed: ${String(e.stderr || e.message).trim()}`, { cause: e });
|
|
69
32
|
}
|
|
33
|
+
};
|
|
34
|
+
// an emptied manifest git never tracked: nothing to add, nothing to commit
|
|
35
|
+
// an emptied manifest is un-staged with --ignore-unmatch: one git never tracked leaves nothing to commit
|
|
36
|
+
git(plan.text === null
|
|
37
|
+
? ["rm", "--cached", "-q", "--ignore-unmatch", "--", EXPORTS_FILE]
|
|
38
|
+
: ["add", "--", EXPORTS_FILE]);
|
|
39
|
+
// back to what HEAD already holds (a hand edit undone), or never tracked: nothing to commit
|
|
40
|
+
let same = false;
|
|
41
|
+
try {
|
|
42
|
+
execFileSync("git", ["diff", "--cached", "--quiet", "HEAD", "--", EXPORTS_FILE], {
|
|
43
|
+
cwd: plan.dir,
|
|
44
|
+
stdio: "ignore",
|
|
45
|
+
});
|
|
46
|
+
same = true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* differs, or no HEAD yet */
|
|
50
|
+
}
|
|
51
|
+
if (!same) {
|
|
52
|
+
git([
|
|
53
|
+
"commit",
|
|
54
|
+
"--only",
|
|
55
|
+
"-q",
|
|
56
|
+
"-m",
|
|
57
|
+
`dreamteamer: exports — ${plan.entries} entr${plan.entries === 1 ? "y" : "ies"}`,
|
|
58
|
+
"--",
|
|
59
|
+
EXPORTS_FILE,
|
|
60
|
+
]);
|
|
61
|
+
committed = git(["rev-parse", "--short", "HEAD"]);
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
|
-
const count = (k) => plan.changes.filter(c => c.kind === k).length;
|
|
73
|
-
out.push({
|
|
74
|
-
repo,
|
|
75
|
-
path: where,
|
|
76
|
-
changed: before !== plan.text,
|
|
77
|
-
changes: plan.changes,
|
|
78
|
-
entries: plan.entries,
|
|
79
|
-
committed,
|
|
80
|
-
note,
|
|
81
|
-
});
|
|
82
|
-
if (json)
|
|
83
|
-
continue;
|
|
84
|
-
console.log(before === plan.text
|
|
85
|
-
? `✔ ${repo ?? "this workspace"} · ${where} — exports manifest current (${plan.entries} entr${plan.entries === 1 ? "y" : "ies"})`
|
|
86
|
-
: `${dryRun ? "·" : "✔"} ${repo ?? "this workspace"} · ${where} — ${count("add")} added, ${count("refresh") + count("fill")} changed, ${count("drop")} dropped (${plan.entries} entr${plan.entries === 1 ? "y" : "ies"})${dryRun ? " — dry run, nothing written" : committed ? ` · committed ${committed}` : ""}`);
|
|
87
|
-
for (const c of plan.changes)
|
|
88
|
-
console.log(` ${c.kind} ${c.ref} — ${c.why}`);
|
|
89
|
-
if (note)
|
|
90
|
-
console.log(`⚠ ${note}`);
|
|
91
64
|
}
|
|
92
|
-
|
|
93
|
-
|
|
65
|
+
const count = (k) => plan.changes.filter(c => c.kind === k).length;
|
|
66
|
+
const result = {
|
|
67
|
+
path: where,
|
|
68
|
+
changed: before !== plan.text,
|
|
69
|
+
changes: plan.changes,
|
|
70
|
+
entries: plan.entries,
|
|
71
|
+
committed,
|
|
72
|
+
note,
|
|
73
|
+
};
|
|
74
|
+
if (json) {
|
|
75
|
+
console.log(JSON.stringify({ dryRun, manifests: [{ repo: null, ...result }] }, null, 2));
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
console.log(before === plan.text
|
|
79
|
+
? `✔ this workspace · ${where} — exports manifest current (${plan.entries} entr${plan.entries === 1 ? "y" : "ies"})`
|
|
80
|
+
: `${dryRun ? "·" : "✔"} this workspace · ${where} — ${count("add")} added, ${count("refresh") + count("fill")} changed, ${count("drop")} dropped (${plan.entries} entr${plan.entries === 1 ? "y" : "ies"})${dryRun ? " — dry run, nothing written" : committed ? ` · committed ${committed}` : ""}`);
|
|
81
|
+
for (const c of plan.changes)
|
|
82
|
+
console.log(` ${c.kind} ${c.ref} — ${c.why}`);
|
|
83
|
+
if (note)
|
|
84
|
+
console.log(`⚠ ${note}`);
|
|
94
85
|
return 0;
|
|
95
86
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Workspace } from "../types.js";
|
|
2
2
|
/**
|
|
3
|
-
* The modules that declare an extension entry: the workspace's own `modules/<id>/` first, then
|
|
4
|
-
*
|
|
5
|
-
* direct dependencies, each sorted by name — the three channels module content arrives through. A workspace module is the operator's own code, exactly
|
|
3
|
+
* The modules that declare an extension entry: the workspace's own `modules/<id>/` first, then its
|
|
4
|
+
* direct dependencies, each sorted by name — the two channels module content arrives through. A workspace module is the operator's own code, exactly
|
|
6
5
|
* like its `bin/`, so it needs no package and no npm — and it SHADOWS a dependency of the same name,
|
|
7
6
|
* the rule module content already follows. A module DISABLED by a bare `dreamteamer.disable` entry
|
|
8
7
|
* is not an extension either — disabling is how a workspace keeps a module and switches it off.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { layerEntries } from "../workspace/layerEntries.js";
|
|
4
3
|
import { engineVersion } from "../runtime/runtime.js";
|
|
5
4
|
import { disablesPackage } from "./extensions.js";
|
|
6
5
|
import { satisfies } from "../lib/npm/satisfies.js";
|
|
7
6
|
/**
|
|
8
|
-
* The modules that declare an extension entry: the workspace's own `modules/<id>/` first, then
|
|
9
|
-
*
|
|
10
|
-
* direct dependencies, each sorted by name — the three channels module content arrives through. A workspace module is the operator's own code, exactly
|
|
7
|
+
* The modules that declare an extension entry: the workspace's own `modules/<id>/` first, then its
|
|
8
|
+
* direct dependencies, each sorted by name — the two channels module content arrives through. A workspace module is the operator's own code, exactly
|
|
11
9
|
* like its `bin/`, so it needs no package and no npm — and it SHADOWS a dependency of the same name,
|
|
12
10
|
* the rule module content already follows. A module DISABLED by a bare `dreamteamer.disable` entry
|
|
13
11
|
* is not an extension either — disabling is how a workspace keeps a module and switches it off.
|
|
@@ -53,32 +51,6 @@ export function declaredExtensions(ws) {
|
|
|
53
51
|
}
|
|
54
52
|
for (const id of inline)
|
|
55
53
|
consider(path.join(ws.root, "modules", id), id);
|
|
56
|
-
const listed = (dir) => {
|
|
57
|
-
try {
|
|
58
|
-
return fs.readdirSync(dir).sort();
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const layers = new Set(layerEntries(ws.pkg, ws.root).map(l => l.name));
|
|
65
|
-
for (const clone of listed(path.join(ws.root, "git_modules"))) {
|
|
66
|
-
if (layers.has(clone))
|
|
67
|
-
continue; // a record layer: another workspace's data, never its code
|
|
68
|
-
const root = path.join(ws.root, "git_modules", clone);
|
|
69
|
-
let rootName = clone;
|
|
70
|
-
try {
|
|
71
|
-
rootName = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8")).name ?? clone;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
/* no manifest */
|
|
75
|
-
}
|
|
76
|
-
if (disablesPackage(disable, rootName))
|
|
77
|
-
continue; // a disabled bundle takes its children with it
|
|
78
|
-
consider(root, clone);
|
|
79
|
-
for (const id of listed(path.join(root, "modules")))
|
|
80
|
-
consider(path.join(root, "modules", id), id);
|
|
81
|
-
}
|
|
82
54
|
for (const dep of Object.keys({ ...ws.pkg?.dependencies, ...ws.pkg?.devDependencies }).sort())
|
|
83
55
|
consider(path.join(ws.root, "node_modules", dep), dep);
|
|
84
56
|
return out;
|
|
@@ -4,7 +4,7 @@ import type { RepoCommit } from "../workspace/types.js";
|
|
|
4
4
|
* `dt fmt [<collection>]` — rewrite descriptor and mixin sources in block style with their top-level
|
|
5
5
|
* keys in canonical order (`formatSource`). One collection's sources, or every inline source.
|
|
6
6
|
*
|
|
7
|
-
* A source under `
|
|
7
|
+
* A source under `node_modules/` belongs to another repo and is only counted: it
|
|
8
8
|
* is formatted there. A v1 source is refused, every one listed, before anything is written. The
|
|
9
9
|
* write goes through `writeGated` — comment guard, compile gate, one commit per repo.
|
|
10
10
|
* @returns {{ changed: string[], unchanged: number, skipped: string[], commits?: object[] }}
|
|
@@ -14,7 +14,7 @@ import { writeGated } from "../workspace/writeGated.js";
|
|
|
14
14
|
* `dt fmt [<collection>]` — rewrite descriptor and mixin sources in block style with their top-level
|
|
15
15
|
* keys in canonical order (`formatSource`). One collection's sources, or every inline source.
|
|
16
16
|
*
|
|
17
|
-
* A source under `
|
|
17
|
+
* A source under `node_modules/` belongs to another repo and is only counted: it
|
|
18
18
|
* is formatted there. A v1 source is refused, every one listed, before anything is written. The
|
|
19
19
|
* write goes through `writeGated` — comment guard, compile gate, one commit per repo.
|
|
20
20
|
* @returns {{ changed: string[], unchanged: number, skipped: string[], commits?: object[] }}
|
package/dist/init/init.js
CHANGED
|
@@ -7,7 +7,6 @@ import { ensureEditorRecommendation } from "../compile/ensureEditorRecommendatio
|
|
|
7
7
|
import { KINDS } from "../compile/consts.js";
|
|
8
8
|
import { appendMissing } from "../lib/appendMissing.js";
|
|
9
9
|
const GITIGNORE = `node_modules/
|
|
10
|
-
git_modules/
|
|
11
10
|
.worktrees/
|
|
12
11
|
.dreamteamer/
|
|
13
12
|
.claude/
|
package/dist/init/seedBlock.js
CHANGED
|
@@ -30,7 +30,6 @@ export function seedBlock(flags = {}, existing = {}) {
|
|
|
30
30
|
// misreading it invites — `default/tasks` — is a compile error whose message states the rule.
|
|
31
31
|
// Override with `--workspace_module <name>` if a workspace wants its own spelling.
|
|
32
32
|
workspace_module: (flags.workspace_module ?? "default"),
|
|
33
|
-
git_modules: {},
|
|
34
33
|
disable: [],
|
|
35
34
|
...existing,
|
|
36
35
|
};
|
|
@@ -2,7 +2,6 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { declaredDeps } from "./declaredDeps.js";
|
|
5
|
-
import { install as restoreGitModules } from "./install.js";
|
|
6
5
|
import { resolves } from "./resolves.js";
|
|
7
6
|
import { childEnv } from "../lib/childEnv.js";
|
|
8
7
|
import { compile } from "../compile/compile.js";
|
|
@@ -129,7 +128,6 @@ const RUN = {
|
|
|
129
128
|
}),
|
|
130
129
|
env: guard(".env", (ws, st) => placeLink(path.join(st.checkout.primary, ".env"), path.join(ws.root, ".env"))),
|
|
131
130
|
asset: guard("asset", (ws, st, rel) => placeLink(path.join(st.checkout.primary, rel), path.join(ws.root, rel))),
|
|
132
|
-
git_modules: guard("git modules", ws => restoreGitModules(ws)),
|
|
133
131
|
compile: guard("compile", ws => compile(ws)), // `ws` is REOPENED first — see applyInstall
|
|
134
132
|
postinstall: guard("postinstall", (ws, st, rel, stdio) => spawnSync(st.postinstall, {
|
|
135
133
|
cwd: ws.root,
|
|
@@ -144,19 +142,13 @@ const RUN = {
|
|
|
144
142
|
* a named failure is more useful than one that stopped at the first thing it could not do.
|
|
145
143
|
*/
|
|
146
144
|
export async function applyInstall(ws, state, steps, { dryRun = false, log = console.log, stdio = "inherit", npm = resolveNpm(), open = null, } = {}) {
|
|
147
|
-
let failed = 0, installed = false
|
|
145
|
+
let failed = 0, installed = false;
|
|
148
146
|
for (const s of steps) {
|
|
149
147
|
// ⚠ NEW PACKAGES ARE NEW SOURCES. The plan judged the runtime fresh BEFORE npm put a module (or an
|
|
150
148
|
// extension) into node_modules, so a compiled workspace that just gained a dependency kept the
|
|
151
149
|
// old runtime at exit 0. Once dependencies were installed, the compile runs whatever the plan said.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// `✔ compile: fresh` and a runtime that did not know it (the first review of 0.46.0, finding eng-03).
|
|
155
|
-
if (s.id === "compile" && (installed || restored) && s.state === "already")
|
|
156
|
-
Object.assign(s, {
|
|
157
|
-
label: installed ? "compile: dependencies were just installed" : "compile: git modules were just restored",
|
|
158
|
-
state: "todo",
|
|
159
|
-
});
|
|
150
|
+
if (s.id === "compile" && installed && s.state === "already")
|
|
151
|
+
Object.assign(s, { label: "compile: dependencies were just installed", state: "todo" });
|
|
160
152
|
const glyph = s.state === "todo" ? "▶" : s.state === "already" ? "✔" : "—";
|
|
161
153
|
log(`${glyph} ${s.label}${s.why ? `\n ${s.why}` : ""}`);
|
|
162
154
|
if (s.state !== "todo" || dryRun)
|
|
@@ -183,8 +175,6 @@ export async function applyInstall(ws, state, steps, { dryRun = false, log = con
|
|
|
183
175
|
}
|
|
184
176
|
else if (kind === "dependencies")
|
|
185
177
|
installed = true;
|
|
186
|
-
else if (kind === "git_modules")
|
|
187
|
-
restored = true;
|
|
188
178
|
}
|
|
189
179
|
return failed ? 1 : 0;
|
|
190
180
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { installCheckout } from "./installCheckout.js";
|
|
2
|
-
import { installClone } from "./installClone.js";
|
|
3
2
|
import { installModules } from "./installModules.js";
|
|
4
3
|
import { warnIfStale } from "../compile/warnIfStale.js";
|
|
5
4
|
import { listRepos } from "../repos/listRepos.js";
|
|
@@ -11,11 +10,6 @@ export async function installCommand(ws, rest, { open, verify, ensureRepos }) {
|
|
|
11
10
|
return;
|
|
12
11
|
throw new Error(`${stray.join(" ")} ${stray.length > 1 ? "are not flags" : "is not a flag"} of \`${form}\` — that form takes ${allowed.join(" ")}`);
|
|
13
12
|
};
|
|
14
|
-
const ci = rest.indexOf("--clone");
|
|
15
|
-
if (ci > -1) {
|
|
16
|
-
refuse("dt install --clone <url> [name]", ["--clone"]);
|
|
17
|
-
return installClone(ws, rest[ci + 1], rest[ci + 2]);
|
|
18
|
-
}
|
|
19
13
|
const target = rest.find(a => !a.startsWith("--"));
|
|
20
14
|
if (target === "repos" || target?.startsWith("repos/")) {
|
|
21
15
|
refuse(`dt install ${target}`, ["--all", "--json"]);
|
|
@@ -70,7 +70,7 @@ export async function npmAndCompile(ws, list, { npm = resolveNpm(), open, json =
|
|
|
70
70
|
try {
|
|
71
71
|
let fresh;
|
|
72
72
|
if (childCompile) {
|
|
73
|
-
// --workspace pins the root
|
|
73
|
+
// --workspace pins the root
|
|
74
74
|
const c = spawnSync(process.execPath, [BIN, "--workspace", ws.root, "compile"], {
|
|
75
75
|
cwd: ws.root,
|
|
76
76
|
stdio: json ? ["ignore", 2, 2] : "inherit",
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { declaredDeps } from "./declaredDeps.js";
|
|
4
|
-
import { offRef } from "./offRef.js";
|
|
5
4
|
import { resolves } from "./resolves.js";
|
|
6
|
-
import { declaredGitModules } from "../workspace/declaredGitModules.js";
|
|
7
5
|
import { describeCheckout } from "../lib/git/describeCheckout.js";
|
|
8
6
|
import { discoverModules } from "../workspace/discoverModules.js";
|
|
9
7
|
import { staleness } from "../compile/staleness.js";
|
|
@@ -71,27 +69,6 @@ export function observeState(ws) {
|
|
|
71
69
|
isLinkHere: isLink(here(a.rel)),
|
|
72
70
|
presentInPrimary: resolves(there(a.rel)),
|
|
73
71
|
})),
|
|
74
|
-
// ⚠ THE MISSING clones and the ones off their declared ref, not every declared one. A settled
|
|
75
|
-
// worktree would otherwise print `▶ git modules: …` for ever, and this is the step whose result
|
|
76
|
-
// nobody looks at — so the narrowing here is what makes the empty case mean "nothing to do".
|
|
77
|
-
// … and the ones a clone on disk NEEDS (`declaredGitModules`): missing, off their ref, nothing yet under
|
|
78
|
-
// a declarer (a clone of its own there is satisfied), or a nested copy missing or off its ref. Before
|
|
79
|
-
// the first install only this workspace's own are visible.
|
|
80
|
-
gitModules: [
|
|
81
|
-
...new Set([
|
|
82
|
-
...[...declaredGitModules(ws.pkg, ws.root).map]
|
|
83
|
-
.filter(([n, m]) => !resolves(here(path.join("git_modules", n))) ||
|
|
84
|
-
offRef(here(path.join("git_modules", n)), m.ref) ||
|
|
85
|
-
m.declarers.some(by => by && !resolves(here(path.join(by, "git_modules", n)))))
|
|
86
|
-
.map(([n]) => n),
|
|
87
|
-
// a nested copy that is still a LINK (laid while the declarer agreed with the top) is work to do
|
|
88
|
-
...declaredGitModules(ws.pkg, ws.root)
|
|
89
|
-
.nested.filter(c => isLink(here(path.join(c.by, "git_modules", c.name))) ||
|
|
90
|
-
!resolves(here(path.join(c.by, "git_modules", c.name))) ||
|
|
91
|
-
offRef(here(path.join(c.by, "git_modules", c.name)), c.ref))
|
|
92
|
-
.map(c => c.name),
|
|
93
|
-
]),
|
|
94
|
-
],
|
|
95
72
|
stale: !s.compiled || s.stale.length > 0,
|
|
96
73
|
postinstall: ws.pkg.dreamteamer?.postinstall ?? null,
|
|
97
74
|
};
|
|
@@ -51,16 +51,6 @@ export function planInstall(state, opts = {}) {
|
|
|
51
51
|
else
|
|
52
52
|
steps.push({ id, label: `${a.rel}: link → ${c.primary}/${a.rel}`, state: "todo" });
|
|
53
53
|
}
|
|
54
|
-
// gitModules carries the declared clones that are MISSING on this checkout or off their declared
|
|
55
|
-
// ref, not every declared one — the observer narrows it, which is what makes an empty array mean "nothing to restore"
|
|
56
|
-
// rather than "none declared", and what lets a settled checkout plan with nothing todo.
|
|
57
|
-
steps.push({
|
|
58
|
-
id: "git_modules",
|
|
59
|
-
label: state.gitModules.length
|
|
60
|
-
? `git modules: restore or re-point ${state.gitModules.join(", ")}`
|
|
61
|
-
: "git modules: nothing to restore",
|
|
62
|
-
state: state.gitModules.length ? "todo" : "skip",
|
|
63
|
-
});
|
|
64
54
|
steps.push({
|
|
65
55
|
id: "compile",
|
|
66
56
|
label: state.stale ? "compile: runtime missing or stale" : "compile: fresh",
|
package/dist/lib/consts.js
CHANGED
|
@@ -78,7 +78,7 @@ const FORCE_RM = ["json", "force", "dry-run"];
|
|
|
78
78
|
const NAV_MOVE = ["json", "after", "before", "top", "bottom"];
|
|
79
79
|
export const VERB_FLAGS = {
|
|
80
80
|
list: ["json", "filter", "where", "sort"],
|
|
81
|
-
get: ["json"
|
|
81
|
+
get: ["json"],
|
|
82
82
|
add: ["json", "id", "from", "force"],
|
|
83
83
|
set: JSON_ONLY,
|
|
84
84
|
rm: FORCE_RM,
|
|
@@ -13,9 +13,6 @@ export function removeModule(ws, store, id, { force = false, dryRun = false } =
|
|
|
13
13
|
if (fields.location === "node_modules") {
|
|
14
14
|
throw new Error(`module "${id}" is installed by npm (${fields.path}) — remove it from package.json dependencies and run \`npm install\`; a delete under node_modules/ is erased by the next install.`);
|
|
15
15
|
}
|
|
16
|
-
if (fields.location === "git_modules") {
|
|
17
|
-
throw new Error(`module "${id}" is a clone under ${fields.path}, and its package.json lives in ANOTHER repo — remove it from dreamteamer.git_modules and delete the clone. This verb removes inline modules only.`);
|
|
18
|
-
}
|
|
19
16
|
if (ws.pkg.dreamteamer?.workspace_module === id) {
|
|
20
17
|
throw new Error(`module "${id}" IS this workspace's own module (dreamteamer.workspace_module) — removing it would leave the workspace with no sources of its own. Point workspace_module at another module first.`);
|
|
21
18
|
}
|
|
@@ -18,13 +18,6 @@ export function renameModule(ws, store, oldId, newId) {
|
|
|
18
18
|
if (fields.location === "node_modules") {
|
|
19
19
|
throw new Error(`module "${oldId}" ships from node_modules (${fields.path}) — a write there is erased by the next \`npm install\`. Rename it in its own repo and release.`);
|
|
20
20
|
}
|
|
21
|
-
if (fields.location === "git_modules") {
|
|
22
|
-
// ⚠ TWO COMMITS BY CONSTRUCTION, and the verb says so rather than half-doing it: the module's
|
|
23
|
-
// package.json lives in the clone's own repo, and this workspace's half (git_modules,
|
|
24
|
-
// dependencies, modules/<id> refs) is a commit here. Perform the workspace half only after the
|
|
25
|
-
// clone half has landed and been pushed.
|
|
26
|
-
throw new Error(`module "${oldId}" is a clone under ${fields.path}, whose package.json is in ANOTHER repo — a git-shape rename is TWO commits by construction.\n 1. rename it there (package.json name → "${newId}") and push;\n 2. re-run this to perform the workspace half: dreamteamer.git_modules, every dependencies entry, and modules/${oldId} references.`);
|
|
27
|
-
}
|
|
28
21
|
const oldPkgName = fields.name;
|
|
29
22
|
const oldRoot = path.join(ws.root, "modules", oldId);
|
|
30
23
|
const newRoot = path.join(ws.root, "modules", newId);
|
|
@@ -6,8 +6,7 @@ import type { Workspace } from "../types.js";
|
|
|
6
6
|
* `dist/`, where a TypeScript module's code has to live — without shipping a shim at every old path.
|
|
7
7
|
*
|
|
8
8
|
* The module resolves through `discoverModules`, the layering extensions load through: `modules/<id>`,
|
|
9
|
-
* then
|
|
10
|
-
* and a disabled module is not there at all. The script runs on this node (`process.execPath`), at the
|
|
9
|
+
* then the installed package, so an inline copy shadows what npm installed and a disabled module is not there at all. The script runs on this node (`process.execPath`), at the
|
|
11
10
|
* workspace root, with the terminal; its exit code is returned and a signal that killed it kills this
|
|
12
11
|
* process too. `argv[1]` is the script's REAL path, so a script's "am I the entry point" guard — its
|
|
13
12
|
* own realpath against argv[1]'s — holds through the node_modules symlink a `./folder` install makes.
|
|
@@ -10,8 +10,7 @@ const USAGE_LINE = "dt run <module> [<script> [<arg>…]] — the module by pack
|
|
|
10
10
|
* `dist/`, where a TypeScript module's code has to live — without shipping a shim at every old path.
|
|
11
11
|
*
|
|
12
12
|
* The module resolves through `discoverModules`, the layering extensions load through: `modules/<id>`,
|
|
13
|
-
* then
|
|
14
|
-
* and a disabled module is not there at all. The script runs on this node (`process.execPath`), at the
|
|
13
|
+
* then the installed package, so an inline copy shadows what npm installed and a disabled module is not there at all. The script runs on this node (`process.execPath`), at the
|
|
15
14
|
* workspace root, with the terminal; its exit code is returned and a signal that killed it kills this
|
|
16
15
|
* process too. `argv[1]` is the script's REAL path, so a script's "am I the entry point" guard — its
|
|
17
16
|
* own realpath against argv[1]'s — holds through the node_modules symlink a `./folder` install makes.
|
|
@@ -42,7 +42,7 @@ export function setModule(ws, store, id, changes) {
|
|
|
42
42
|
}
|
|
43
43
|
const file = path.join(ws.root, rec.fields.path, "package.json");
|
|
44
44
|
if (IN_NODE_MODULES(rec.fields.path)) {
|
|
45
|
-
throw new Error(`module "${id}" ships from node_modules (${rec.fields.path}) — a write there is erased by the next \`npm install\`. Vendor it into modules
|
|
45
|
+
throw new Error(`module "${id}" ships from node_modules (${rec.fields.path}) — a write there is erased by the next \`npm install\`. Vendor it into modules/.`);
|
|
46
46
|
}
|
|
47
47
|
const changed = [];
|
|
48
48
|
// ⚠ THE WORKSPACE'S REDUNDANT COPY GOES IN THE SAME WRITE. Declaring a namespace on the module
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import type { ExportsContext } from "./types.js";
|
|
2
|
-
import type { exportsFacts } from "../runtime/exportsFacts.js";
|
|
3
2
|
import type { Descriptors } from "../types.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* The one context every judgement uses. `layers` are the runtime's layer facts (null: an older runtime —
|
|
7
|
-
* nothing is known, so no layer is complete and no layer holder is seen); `own` this workspace's package
|
|
8
|
-
* name. A repo is named by its layer name, the write root by null.
|
|
9
|
-
*/
|
|
10
|
-
export declare function exportsContext({ root, descriptors, own, layers, dataPath, }: {
|
|
3
|
+
/** The one context every exports judgement uses; `own` is this workspace's package name. */
|
|
4
|
+
export declare function exportsContext({ root, descriptors, own, dataPath, }: {
|
|
11
5
|
root: string;
|
|
12
6
|
descriptors: Descriptors;
|
|
13
7
|
own: string | null;
|
|
14
|
-
layers: LayerFact[] | null;
|
|
15
8
|
dataPath?: string;
|
|
16
9
|
}): ExportsContext;
|
|
17
|
-
export {};
|
|
@@ -4,7 +4,7 @@ import { storageOf } from "./storageOf.js";
|
|
|
4
4
|
import { walk } from "../lib/walk.js";
|
|
5
5
|
/**
|
|
6
6
|
* Is every file under `dataDir` inside one of the `reads` folders (paths relative to `root`)? Judged on
|
|
7
|
-
* the disk NOW, so a folder a pull added after compile makes the
|
|
7
|
+
* the disk NOW, so a folder a pull added after compile makes the workspace incomplete without a recompile.
|
|
8
8
|
*/
|
|
9
9
|
function readsAll(root, dataDir, reads) {
|
|
10
10
|
const abs = path.join(root, dataDir);
|
|
@@ -16,31 +16,9 @@ function readsAll(root, dataDir, reads) {
|
|
|
16
16
|
return false;
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* name. A repo is named by its layer name, the write root by null.
|
|
23
|
-
*/
|
|
24
|
-
export function exportsContext({ root, descriptors, own, layers, dataPath = "data", }) {
|
|
25
|
-
const facts = new Map((layers ?? []).map(l => [l.name, l]));
|
|
26
|
-
const rootsOf = (coll) => {
|
|
27
|
-
const d = descriptors.get(coll);
|
|
28
|
-
if (!d)
|
|
29
|
-
return [];
|
|
30
|
-
return storageOf(d).roots.map(r => {
|
|
31
|
-
const fact = r.layer ? facts.get(r.layer) : null;
|
|
32
|
-
return {
|
|
33
|
-
layer: r.layer ?? null,
|
|
34
|
-
package: r.layer ? (fact?.package ?? null) : own,
|
|
35
|
-
present: !r.layer || (!!fact && fs.existsSync(path.join(root, r.repo))),
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
const complete = (layer) => {
|
|
40
|
-
if (layer) {
|
|
41
|
-
const l = facts.get(layer);
|
|
42
|
-
return !!l && !l.narrowed && readsAll(root, l.data, l.reads);
|
|
43
|
-
}
|
|
19
|
+
/** The one context every exports judgement uses; `own` is this workspace's package name. */
|
|
20
|
+
export function exportsContext({ root, descriptors, own, dataPath = "data", }) {
|
|
21
|
+
const complete = () => {
|
|
44
22
|
const reads = [];
|
|
45
23
|
for (const d of descriptors.values()) {
|
|
46
24
|
if (storageOf(d).unavailable)
|
|
@@ -52,11 +30,5 @@ export function exportsContext({ root, descriptors, own, layers, dataPath = "dat
|
|
|
52
30
|
}
|
|
53
31
|
return readsAll(root, dataPath, reads);
|
|
54
32
|
};
|
|
55
|
-
return {
|
|
56
|
-
own,
|
|
57
|
-
rootsOf,
|
|
58
|
-
complete,
|
|
59
|
-
packageOf: layer => (layer ? (facts.get(layer)?.package ?? null) : own),
|
|
60
|
-
rootOf: layer => (layer ? path.join(root, facts.get(layer)?.root ?? path.join("git_modules", layer)) : root),
|
|
61
|
-
};
|
|
33
|
+
return { own, root, reads: coll => descriptors.has(coll), complete };
|
|
62
34
|
}
|
|
@@ -6,19 +6,18 @@ import { storageOf } from "./storageOf.js";
|
|
|
6
6
|
* match + suffix/format (file shape) or entry (folder shape). non-records → null.
|
|
7
7
|
*/
|
|
8
8
|
export function pathToRecord(descriptors, relPath) {
|
|
9
|
-
let best = null; //
|
|
9
|
+
let best = null; // the longest root
|
|
10
10
|
for (const d of descriptors.values()) {
|
|
11
11
|
if (storageOf(d).runtime)
|
|
12
12
|
continue; // runtime entities aren't item events
|
|
13
13
|
if (storageOf(d).unavailable)
|
|
14
14
|
continue; // its path is still the template — a literal `${env:…}/` folder is nobody's record
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
15
|
+
const base = storageOf(d).path;
|
|
16
|
+
if (!base || !relPath.startsWith(base + "/"))
|
|
17
|
+
continue;
|
|
18
|
+
if (best && base.length <= best.base.length)
|
|
19
|
+
continue;
|
|
20
|
+
best = { d, base };
|
|
22
21
|
}
|
|
23
22
|
if (!best)
|
|
24
23
|
return null;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { ExportChange, ExportRefs, ExportsContext, OutsideRef } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* The manifest `dt exports` would write
|
|
3
|
+
* The manifest `dt exports` would write in this context, and why — design §3's rules:
|
|
4
4
|
* add an outside reference that resolves here; refresh a label only where the entry's holder is seen
|
|
5
5
|
* and still has the id (its `from` never changes); fill a holder-less entry whose id resolves here;
|
|
6
|
-
* drop an entry for an id the
|
|
7
|
-
* context reads every record of the
|
|
6
|
+
* drop an entry for an id the workspace now holds, one whose seen holder lost the id, and — only where this
|
|
7
|
+
* context reads every record of the workspace — one nothing references; keep everything else as written.
|
|
8
8
|
*/
|
|
9
|
-
export declare function regenerate({ current, outside, ctx,
|
|
9
|
+
export declare function regenerate({ current, outside, ctx, held, }: {
|
|
10
10
|
current: ExportRefs | null;
|
|
11
11
|
outside: Map<string, OutsideRef>;
|
|
12
12
|
ctx: ExportsContext;
|
|
13
|
-
repo: string | null;
|
|
14
13
|
held: (coll: string, id: string) => boolean;
|
|
15
14
|
}): {
|
|
16
15
|
next: ExportRefs;
|