@sous-io/sous 0.2.37 → 1.0.2
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/README.md +14 -256
- package/dist/bin.js +11 -0
- package/dist/sous.js +1094 -0
- package/docs/markdown/README.md +5 -4
- package/docs/markdown/_sidebar.md +21 -1
- package/docs/markdown/commands.md +294 -431
- package/docs/markdown/config-discovery.md +25 -14
- package/docs/markdown/config-inspection.md +53 -31
- package/docs/markdown/config-layers.md +168 -66
- package/docs/markdown/config-variables.md +44 -11
- package/docs/markdown/configuration.md +104 -17
- package/docs/markdown/design-principles.md +4 -1
- package/docs/markdown/repositories-authoring.md +30 -0
- package/docs/markdown/repositories-consuming.md +72 -14
- package/docs/markdown/repositories-file-formats.md +31 -13
- package/docs/markdown/repositories-providers.md +48 -57
- package/docs/markdown/repositories-quickstart.md +3 -2
- package/docs/markdown/repositories-troubleshooting.md +27 -1
- package/docs/markdown/repositories-variables.md +6 -1
- package/docs/markdown/repositories.md +18 -8
- package/package.json +48 -107
- package/recipes/core/sous-skills/skills/about-liquid-templates/SKILL.tpl.md +4 -6
- package/recipes/core/sous-skills/skills/about-liquid-templates/references/liquid-filters.tpl.md +2 -0
- package/recipes/core/sous-skills/skills/about-sous/SKILL.tpl.md +10 -9
- package/recipes/core/sous-skills/skills/about-sous-configuration/SKILL.tpl.md +35 -14
- package/recipes/core/sous-skills/skills/about-sous-recipes/SKILL.tpl.md +51 -20
- package/recipes/core/sous-skills/sous.recipe.yaml +1 -1
- package/sous.config.schema.json +351 -132
- package/bin/run.js +0 -51
- package/src/base-command.ts +0 -457
- package/src/commands/build.ts +0 -181
- package/src/commands/clear.ts +0 -79
- package/src/commands/compile.ts +0 -155
- package/src/commands/config/get.ts +0 -110
- package/src/commands/config/show.ts +0 -32
- package/src/commands/config/validate.ts +0 -53
- package/src/commands/help.ts +0 -46
- package/src/commands/init.ts +0 -289
- package/src/commands/launch.ts +0 -139
- package/src/commands/lock/rebuild.ts +0 -239
- package/src/commands/lock/show.ts +0 -115
- package/src/commands/namespace/list.ts +0 -138
- package/src/commands/namespace/show.ts +0 -130
- package/src/commands/prune.ts +0 -43
- package/src/commands/recipe/list.ts +0 -112
- package/src/commands/recipe/show.ts +0 -439
- package/src/commands/repo/add.ts +0 -145
- package/src/commands/repo/contribute.ts +0 -604
- package/src/commands/repo/gc.ts +0 -173
- package/src/commands/repo/init.ts +0 -136
- package/src/commands/repo/link.ts +0 -899
- package/src/commands/repo/list.ts +0 -236
- package/src/commands/repo/release.ts +0 -685
- package/src/commands/repo/remove.ts +0 -194
- package/src/commands/repo/search.ts +0 -243
- package/src/commands/repo/submit.ts +0 -341
- package/src/commands/repo/unlink.ts +0 -461
- package/src/commands/subscription/add.ts +0 -286
- package/src/commands/subscription/list.ts +0 -208
- package/src/commands/subscription/remove.ts +0 -182
- package/src/commands/subscription/update.ts +0 -216
- package/src/commands/update.ts +0 -178
- package/src/commands/vars/ask.ts +0 -417
- package/src/commands/vars/index.ts +0 -79
- package/src/commands/vars/list.ts +0 -67
- package/src/commands/vars/show.ts +0 -77
- package/src/config-command.ts +0 -30
- package/src/lib/build-preparation.ts +0 -128
- package/src/lib/build-service.ts +0 -580
- package/src/lib/config-discovery.ts +0 -378
- package/src/lib/config-inspect.ts +0 -145
- package/src/lib/config-kernel.mjs +0 -379
- package/src/lib/config-schema.ts +0 -401
- package/src/lib/env-file.ts +0 -328
- package/src/lib/env-local.ts +0 -212
- package/src/lib/errors.ts +0 -32
- package/src/lib/glob-pattern.ts +0 -24
- package/src/lib/include-resolver.ts +0 -523
- package/src/lib/interactive.ts +0 -165
- package/src/lib/markdown-compiler.ts +0 -947
- package/src/lib/package-info.ts +0 -25
- package/src/lib/pid-service.ts +0 -99
- package/src/lib/project-install.d.mts +0 -44
- package/src/lib/project-install.mjs +0 -234
- package/src/lib/project-scaffold/index.ts +0 -332
- package/src/lib/project-scaffold/templates.ts +0 -240
- package/src/lib/repos/catalog-display.ts +0 -215
- package/src/lib/repos/catalog-inputs.ts +0 -288
- package/src/lib/repos/catalog.ts +0 -842
- package/src/lib/repos/contribute.ts +0 -452
- package/src/lib/repos/core-recipe.ts +0 -105
- package/src/lib/repos/declarations.ts +0 -187
- package/src/lib/repos/defaults.ts +0 -175
- package/src/lib/repos/formats/common.ts +0 -440
- package/src/lib/repos/formats/index-file.ts +0 -253
- package/src/lib/repos/formats/links-map.ts +0 -98
- package/src/lib/repos/formats/lockfile.ts +0 -169
- package/src/lib/repos/formats/patterns.ts +0 -57
- package/src/lib/repos/formats/recipe-manifest.ts +0 -205
- package/src/lib/repos/formats/repo-manifest.ts +0 -97
- package/src/lib/repos/formats/store-entry.ts +0 -84
- package/src/lib/repos/formats/variable-definition.ts +0 -268
- package/src/lib/repos/freshness.ts +0 -264
- package/src/lib/repos/git-clone.ts +0 -850
- package/src/lib/repos/identity.ts +0 -89
- package/src/lib/repos/index.ts +0 -57
- package/src/lib/repos/links.ts +0 -356
- package/src/lib/repos/load-manifest.ts +0 -237
- package/src/lib/repos/lock-service.ts +0 -454
- package/src/lib/repos/locked-namespace-resolver.ts +0 -232
- package/src/lib/repos/locked-recipe-lookup.ts +0 -123
- package/src/lib/repos/locked-recipes.ts +0 -254
- package/src/lib/repos/managed-layer.ts +0 -422
- package/src/lib/repos/memories-hash-name.ts +0 -33
- package/src/lib/repos/namespace-resolver.ts +0 -527
- package/src/lib/repos/providers/base.ts +0 -268
- package/src/lib/repos/providers/git.ts +0 -245
- package/src/lib/repos/providers/github.ts +0 -589
- package/src/lib/repos/providers/gitlab.ts +0 -332
- package/src/lib/repos/providers/http.ts +0 -128
- package/src/lib/repos/providers/index-cache.ts +0 -421
- package/src/lib/repos/providers/index.ts +0 -106
- package/src/lib/repos/providers/local.ts +0 -410
- package/src/lib/repos/providers/provider.ts +0 -615
- package/src/lib/repos/recipe-config-layers.ts +0 -316
- package/src/lib/repos/recipe-key-matcher.ts +0 -62
- package/src/lib/repos/recipe-memories.ts +0 -178
- package/src/lib/repos/recipe-targets.ts +0 -236
- package/src/lib/repos/ref-search.ts +0 -46
- package/src/lib/repos/release/bump.ts +0 -161
- package/src/lib/repos/release/changelog.ts +0 -461
- package/src/lib/repos/release/git-state.ts +0 -460
- package/src/lib/repos/release/index-builder.ts +0 -1108
- package/src/lib/repos/release/index.ts +0 -19
- package/src/lib/repos/release/plan.ts +0 -521
- package/src/lib/repos/release/settle.ts +0 -154
- package/src/lib/repos/release/submissions.ts +0 -214
- package/src/lib/repos/release/submit-checkout.ts +0 -290
- package/src/lib/repos/release/submit-questions.ts +0 -153
- package/src/lib/repos/release/submit-service.ts +0 -898
- package/src/lib/repos/release/tags.ts +0 -239
- package/src/lib/repos/release/validate.ts +0 -463
- package/src/lib/repos/resolver.ts +0 -1028
- package/src/lib/repos/scaffold/index.ts +0 -245
- package/src/lib/repos/scaffold/templates.ts +0 -517
- package/src/lib/repos/seed.ts +0 -473
- package/src/lib/repos/store/contract.ts +0 -64
- package/src/lib/repos/store/hash.ts +0 -191
- package/src/lib/repos/store/recipe-store.ts +0 -599
- package/src/lib/repos/store/settings.ts +0 -58
- package/src/lib/repos/subscription-service.ts +0 -3859
- package/src/lib/repos/trust.ts +0 -447
- package/src/lib/repos/update-plan.ts +0 -235
- package/src/lib/self-update/index.ts +0 -14
- package/src/lib/self-update/installs.ts +0 -413
- package/src/lib/self-update/managers.ts +0 -126
- package/src/lib/self-update/plan.ts +0 -315
- package/src/lib/self-update/registry.ts +0 -99
- package/src/lib/self-update/run.ts +0 -506
- package/src/lib/self-update/versions.ts +0 -243
- package/src/lib/settings.ts +0 -1107
- package/src/lib/sous-home.ts +0 -104
- package/src/lib/state.ts +0 -167
- package/src/lib/vars/answers.ts +0 -192
- package/src/lib/vars/ask.ts +0 -1152
- package/src/lib/vars/definition-source.ts +0 -261
- package/src/lib/vars/display.ts +0 -231
- package/src/lib/vars/index.ts +0 -20
- package/src/lib/vars/ladder.ts +0 -282
- package/src/lib/vars/mappings.ts +0 -260
- package/src/lib/vars/names.ts +0 -94
- package/src/lib/vars/preanswers.ts +0 -395
- package/src/lib/vars/question-plan.ts +0 -241
- package/src/lib/vars/report.ts +0 -228
- package/src/lib/vars/safe-regex.ts +0 -235
- package/src/lib/vars/secrets.ts +0 -131
- package/src/lib/vars/validate.ts +0 -312
- package/src/lib/version-report.ts +0 -90
- package/src/lib/watch-loop.ts +0 -148
- package/src/lib/watch-service.ts +0 -116
- package/src/services/ref-resolver/container.ts +0 -107
- package/src/services/ref-resolver/dependency.ts +0 -60
- package/src/services/ref-resolver/format.ts +0 -197
- package/src/services/ref-resolver/glob.ts +0 -115
- package/src/services/ref-resolver/hash-names.ts +0 -155
- package/src/services/ref-resolver/index.ts +0 -55
- package/src/services/ref-resolver/injectable.ts +0 -36
- package/src/services/ref-resolver/location.ts +0 -62
- package/src/services/ref-resolver/lookups/cached-index-lookup.ts +0 -53
- package/src/services/ref-resolver/lookups/catalog-lookup.ts +0 -23
- package/src/services/ref-resolver/lookups/catalog-matcher.ts +0 -261
- package/src/services/ref-resolver/lookups/chained-lookup.ts +0 -27
- package/src/services/ref-resolver/lookups/env-var-lookup.ts +0 -65
- package/src/services/ref-resolver/lookups/fetched-index-lookup.ts +0 -150
- package/src/services/ref-resolver/lookups/recorded-dependency-lookup.ts +0 -62
- package/src/services/ref-resolver/lookups/ref-lookup.ts +0 -54
- package/src/services/ref-resolver/lookups/variable-lookup.ts +0 -123
- package/src/services/ref-resolver/named-refs.ts +0 -144
- package/src/services/ref-resolver/parser/env-var-splitter.ts +0 -27
- package/src/services/ref-resolver/parser/location-splitter.ts +0 -239
- package/src/services/ref-resolver/parser/name-path-splitter.ts +0 -200
- package/src/services/ref-resolver/parser/partial-ref.ts +0 -84
- package/src/services/ref-resolver/parser/query-splitter.ts +0 -61
- package/src/services/ref-resolver/parser/range-splitter.ts +0 -52
- package/src/services/ref-resolver/parser/ref-parser.ts +0 -115
- package/src/services/ref-resolver/parser/repo-qualifier-splitter.ts +0 -51
- package/src/services/ref-resolver/parts.ts +0 -115
- package/src/services/ref-resolver/pruners/command-line-pruner.ts +0 -47
- package/src/services/ref-resolver/pruners/include-pruner.ts +0 -66
- package/src/services/ref-resolver/pruners/manifest-pruner.ts +0 -130
- package/src/services/ref-resolver/pruners/ref-pruner.ts +0 -135
- package/src/services/ref-resolver/pruners/rule-helpers.ts +0 -44
- package/src/services/ref-resolver/pruners/stored-key-pruner.ts +0 -136
- package/src/services/ref-resolver/ref-helpers.ts +0 -62
- package/src/services/ref-resolver/ref-picker-service.ts +0 -204
- package/src/services/ref-resolver/ref-report.ts +0 -84
- package/src/services/ref-resolver/ref-resolve-arguments.ts +0 -47
- package/src/services/ref-resolver/ref-resolve-result.ts +0 -36
- package/src/services/ref-resolver/ref-resolver-service.ts +0 -323
- package/src/services/ref-resolver/source.ts +0 -48
- package/src/services/ref-resolver/tokens.ts +0 -25
- package/src/services/ref-resolver/types.ts +0 -155
- package/src/templating/filters/bullet-list.ts +0 -9
- package/src/templating/filters/index.ts +0 -8
- package/src/templating/init-liquid-engine.ts +0 -139
- package/src/templating/lib/glob-files.ts +0 -74
- package/src/templating/lib/import-export.ts +0 -32
- package/src/templating/lib/secret-scope.ts +0 -41
- package/src/templating/lib/tag-args.ts +0 -19
- package/src/templating/tags/exportScalarVarsJs.ts +0 -46
- package/src/templating/tags/getFiles.ts +0 -89
- package/src/templating/tags/index.ts +0 -14
- package/src/templating/tags/listFiles.ts +0 -54
- package/src/templating/tags/showVars.ts +0 -28
- package/src/utils/choice-prompt.ts +0 -143
- package/src/utils/command-errors.ts +0 -186
- package/src/utils/command-help.ts +0 -45
- package/src/utils/confirm-prompt.ts +0 -110
- package/src/utils/flags.ts +0 -177
- package/src/utils/formatting.ts +0 -849
- package/src/utils/prompts.ts +0 -53
- package/src/utils/sous-directory.ts +0 -245
- package/src/utils/table.ts +0 -603
- package/src/utils/value-prompt.ts +0 -119
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How one recipe brings in another: which entry of its manifest names it, and
|
|
3
|
-
* whether that entry is a co-subscription or a build dependency.
|
|
4
|
-
*
|
|
5
|
-
* A manifest lists what it brings in under `depends` and `subscribes`, and one
|
|
6
|
-
* recipe can be covered by more than one entry: `subscribes: [workflow]` covers
|
|
7
|
-
* every recipe of the `workflow` namespace, and `depends: [workflow/task-files]`
|
|
8
|
-
* names one of them again. Three places need one answer per recipe, and they
|
|
9
|
-
* must agree: a release recording the answer in the index, `sous recipe show`
|
|
10
|
-
* describing a recipe whose manifest it can read, and the resolver walking a
|
|
11
|
-
* recipe whose manifest it cannot. This module is that one answer, and its
|
|
12
|
-
* reverse.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import type { DependencyKind } from "./formats/common.js";
|
|
16
|
-
import type { IndexVersion } from "./formats/index-file.js";
|
|
17
|
-
import {
|
|
18
|
-
RefSource,
|
|
19
|
-
isNamedRef,
|
|
20
|
-
locationOf,
|
|
21
|
-
namespaceOfKey,
|
|
22
|
-
settleDependency,
|
|
23
|
-
shortKey,
|
|
24
|
-
sharedRefResolver,
|
|
25
|
-
type RecordedDependencies,
|
|
26
|
-
} from "../../services/ref-resolver/index.js";
|
|
27
|
-
|
|
28
|
-
/** A manifest's two dependency lists, each entry exactly as it was written. */
|
|
29
|
-
export type DependencyLists = {
|
|
30
|
-
/** Build dependencies: fetched and addressable, never in the project's output. */
|
|
31
|
-
depends: string[];
|
|
32
|
-
/** Co-subscriptions: their files land and their questions are asked. */
|
|
33
|
-
subscribes: string[];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** How one recipe is brought in by the manifest that declares it. */
|
|
37
|
-
export type DependencyDeclaration = {
|
|
38
|
-
/**
|
|
39
|
-
* The manifest entry that brings it in, as written. An entry naming the
|
|
40
|
-
* recipe wins over a namespace entry that also covers it; between two
|
|
41
|
-
* entries naming it, the later one (in `depends`, then `subscribes` order)
|
|
42
|
-
* wins, and between two namespace entries, the first.
|
|
43
|
-
*/
|
|
44
|
-
declared: string;
|
|
45
|
-
/** `subscribes` when any entry covering the recipe is a co-subscription. */
|
|
46
|
-
kind: DependencyKind;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** A declaration being gathered, entry by entry. */
|
|
50
|
-
export type GatheredDeclaration = DependencyDeclaration & {
|
|
51
|
-
/** True when an entry named the recipe itself rather than its namespace. */
|
|
52
|
-
named: boolean;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/** One manifest entry covering a recipe. */
|
|
56
|
-
export type CoveringEntry = {
|
|
57
|
-
/** The entry as written. */
|
|
58
|
-
written: string;
|
|
59
|
-
/** The list it sits in. */
|
|
60
|
-
kind: DependencyKind;
|
|
61
|
-
/** True when it names the recipe itself rather than a namespace holding it. */
|
|
62
|
-
named: boolean;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Folds one more manifest entry covering a recipe into what is known about the
|
|
67
|
-
* recipe's declaration, by the rule `DependencyDeclaration` states. Every
|
|
68
|
-
* reader applies this one function, entry by entry in manifest order
|
|
69
|
-
* (`depends` first, then `subscribes`).
|
|
70
|
-
*
|
|
71
|
-
* foldDeclaration(undefined, { written: "workflow", kind: "subscribes", named: false })
|
|
72
|
-
* // -> { declared: "workflow", kind: "subscribes", named: false }
|
|
73
|
-
*
|
|
74
|
-
* @param before - What the earlier entries said, when any covered the recipe.
|
|
75
|
-
* @param entry - The next entry covering it.
|
|
76
|
-
*/
|
|
77
|
-
export function foldDeclaration(
|
|
78
|
-
before: GatheredDeclaration | undefined,
|
|
79
|
-
entry: CoveringEntry
|
|
80
|
-
): GatheredDeclaration {
|
|
81
|
-
const keepBefore = before !== undefined && !entry.named;
|
|
82
|
-
return {
|
|
83
|
-
declared: keepBefore ? before.declared : entry.written.trim(),
|
|
84
|
-
kind: before?.kind === "subscribes" || entry.kind === "subscribes" ? "subscribes" : "depends",
|
|
85
|
-
named: entry.named || before?.named === true,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The declaration that brings one recipe in, or undefined when no entry of the
|
|
91
|
-
* lists covers it. An entry that reads more than one way is settled from what
|
|
92
|
-
* the version's index entry recorded, and one that cannot be settled, or does
|
|
93
|
-
* not parse, covers nothing.
|
|
94
|
-
*
|
|
95
|
-
* declarationFor({ depends: ["workflow/a"], subscribes: ["workflow"] }, "workflow/a")
|
|
96
|
-
* // -> { declared: "workflow/a", kind: "subscribes" }
|
|
97
|
-
*
|
|
98
|
-
* @param lists - The declaring recipe's `depends` and `subscribes` lists.
|
|
99
|
-
* @param key - The recipe being asked about, `namespace/recipe`.
|
|
100
|
-
* @param recorded - What the declaring version's index entry records, for settling.
|
|
101
|
-
*/
|
|
102
|
-
export function declarationFor(
|
|
103
|
-
lists: Partial<DependencyLists>,
|
|
104
|
-
key: string,
|
|
105
|
-
recorded?: RecordedDependencies
|
|
106
|
-
): DependencyDeclaration | undefined {
|
|
107
|
-
let gathered: GatheredDeclaration | undefined;
|
|
108
|
-
|
|
109
|
-
for (const [kind, entries] of [
|
|
110
|
-
["depends", lists.depends ?? []],
|
|
111
|
-
["subscribes", lists.subscribes ?? []],
|
|
112
|
-
] as Array<[DependencyKind, string[]]>) {
|
|
113
|
-
for (const written of entries) {
|
|
114
|
-
let reading;
|
|
115
|
-
try {
|
|
116
|
-
reading = settleDependency(written, recorded === undefined ? {} : { recorded });
|
|
117
|
-
} catch {
|
|
118
|
-
// An entry that does not parse is reported wherever the manifest is
|
|
119
|
-
// validated; here it simply covers nothing.
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (reading === undefined || !isNamedRef(reading)) continue;
|
|
123
|
-
|
|
124
|
-
const named = reading.kind === "recipe";
|
|
125
|
-
const covers = named
|
|
126
|
-
? shortKey(reading) === key
|
|
127
|
-
: namespaceOfKey(key) === reading.name;
|
|
128
|
-
if (covers) gathered = foldDeclaration(gathered, { written, kind, named });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return gathered === undefined ? undefined : { declared: gathered.declared, kind: gathered.kind };
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* The manifest lists a version's index entry records, or undefined when it
|
|
137
|
-
* records neither (a version recorded before the index described recipes).
|
|
138
|
-
* That is what lets the resolver walk a recipe whose files are not on this
|
|
139
|
-
* machine exactly as it would walk its manifest.
|
|
140
|
-
*
|
|
141
|
-
* indexDependencyLists({ subscribes: ["workflow"], depends: [] , ... })
|
|
142
|
-
* // -> { depends: [], subscribes: ["workflow"] }
|
|
143
|
-
*
|
|
144
|
-
* @param version - The version's index entry.
|
|
145
|
-
*/
|
|
146
|
-
export function indexDependencyLists(
|
|
147
|
-
version: Pick<IndexVersion, "depends" | "subscribes">
|
|
148
|
-
): DependencyLists | undefined {
|
|
149
|
-
if (version.depends === undefined && version.subscribes === undefined) return undefined;
|
|
150
|
-
return { depends: [...(version.depends ?? [])], subscribes: [...(version.subscribes ?? [])] };
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Says how a declaration brings a recipe in, the way a person would: a whole
|
|
155
|
-
* namespace is named as one, and anything else is shown as it was written.
|
|
156
|
-
*
|
|
157
|
-
* describeDeclaration("workflow") // -> "the whole 'workflow' namespace"
|
|
158
|
-
* describeDeclaration("workflow/task-files") // -> "workflow/task-files"
|
|
159
|
-
*
|
|
160
|
-
* @param declared - The manifest entry, as written.
|
|
161
|
-
*/
|
|
162
|
-
export function describeDeclaration(declared: string): string {
|
|
163
|
-
try {
|
|
164
|
-
const { refs } = sharedRefResolver().parse(declared, RefSource.Manifest);
|
|
165
|
-
const only = refs[0]!;
|
|
166
|
-
if (refs.length === 1 && only.kind === "namespace") {
|
|
167
|
-
const location = locationOf(only);
|
|
168
|
-
return location === undefined
|
|
169
|
-
? `the whole '${only.name}' namespace`
|
|
170
|
-
: `the whole '${only.name}' namespace of ${location.identity}`;
|
|
171
|
-
}
|
|
172
|
-
} catch {
|
|
173
|
-
// Shown as it was written; the reader sees the bad entry.
|
|
174
|
-
}
|
|
175
|
-
return declared;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Plain-language wording for a dependency kind.
|
|
180
|
-
*
|
|
181
|
-
* @param kind - The kind, when it is known.
|
|
182
|
-
*/
|
|
183
|
-
export function describeDependencyKind(kind: DependencyKind | undefined): string {
|
|
184
|
-
if (kind === "depends") return "build dependency";
|
|
185
|
-
if (kind === "subscribes") return "co-subscription";
|
|
186
|
-
return "not recorded";
|
|
187
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The repository and subscription every project gets without asking.
|
|
3
|
-
*
|
|
4
|
-
* Sous ships one namespace, `core`, holding the skills that teach an agent what
|
|
5
|
-
* sous is and how it works. Every project is subscribed to it, because an agent
|
|
6
|
-
* that does not know sous manages a file will happily hand-edit it. The wiring
|
|
7
|
-
* is deliberately ordinary: sous adds the same two config entries a person could
|
|
8
|
-
* have written by hand, so they can be inspected with `sous config show` and
|
|
9
|
-
* overridden or switched off in the config like anything else.
|
|
10
|
-
*
|
|
11
|
-
* - The repository `sous-recipes`, pointing at the official public repository.
|
|
12
|
-
* Trust is not a question here: sous itself ships the recipe, pins the
|
|
13
|
-
* version to its own, and seeds it from the package, so trusting it adds
|
|
14
|
-
* nothing a person did not already accept by installing sous.
|
|
15
|
-
* - The subscription `core`, a whole-namespace subscription whose range is
|
|
16
|
-
* exactly the running sous version. Core therefore always matches the CLI,
|
|
17
|
-
* and upgrading sous upgrades core with it.
|
|
18
|
-
*
|
|
19
|
-
* Two ways out, both plain config:
|
|
20
|
-
*
|
|
21
|
-
* subscriptions: { core: { enabled: false } } // keep the repo, drop the skills
|
|
22
|
-
* repos: { "sous-recipes": { enabled: false } } // drop the repository entirely
|
|
23
|
-
*
|
|
24
|
-
* A user-written entry under either key REPLACES the default outright, because
|
|
25
|
-
* the defaults are applied underneath whatever the config layers produced. That
|
|
26
|
-
* is what lets a project pin core to a different range, point the repository at
|
|
27
|
-
* a mirror, or turn either off.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import type { RepoEntry, Settings, SubscriptionEntry } from "../settings.js";
|
|
31
|
-
import { SOUS_VERSION } from "../package-info.js";
|
|
32
|
-
import {
|
|
33
|
-
CORE_NAMESPACE,
|
|
34
|
-
OFFICIAL_REPO_NAME,
|
|
35
|
-
OFFICIAL_REPO_PROVIDER,
|
|
36
|
-
OFFICIAL_REPO_URL,
|
|
37
|
-
} from "./core-recipe.js";
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The `addedBy` value on an entry sous provides itself. It is what tells
|
|
41
|
-
* `sous repo list` to print "built in" rather than a date, and it is why these
|
|
42
|
-
* entries are never written to a managed layer: they are recreated on every run
|
|
43
|
-
* from the installed package.
|
|
44
|
-
*/
|
|
45
|
-
export const BUILT_IN_ADDED_BY = "sous";
|
|
46
|
-
|
|
47
|
-
/** The built-in repository entry, exactly as a person could have written it. */
|
|
48
|
-
export function builtInRepoEntry(): RepoEntry {
|
|
49
|
-
return {
|
|
50
|
-
url: OFFICIAL_REPO_URL,
|
|
51
|
-
provider: OFFICIAL_REPO_PROVIDER,
|
|
52
|
-
addedBy: BUILT_IN_ADDED_BY,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The built-in `core` subscription. Its range is the exact running version, not
|
|
58
|
-
* a caret range: core is published in lockstep with the CLI and is meant to
|
|
59
|
-
* match it exactly.
|
|
60
|
-
*
|
|
61
|
-
* @param version - The running sous version. Defaults to this installation's.
|
|
62
|
-
*/
|
|
63
|
-
export function builtInCoreSubscription(version: string = SOUS_VERSION): SubscriptionEntry {
|
|
64
|
-
return { range: version, addedBy: BUILT_IN_ADDED_BY };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Adds the built-in repository and subscription to a merged config, underneath
|
|
69
|
-
* anything the config layers already said.
|
|
70
|
-
*
|
|
71
|
-
* The core subscription is added only when the built-in repository survives: a
|
|
72
|
-
* project that switched the repository off would otherwise be left subscribed to
|
|
73
|
-
* a namespace nothing can resolve.
|
|
74
|
-
*
|
|
75
|
-
* @param settings - The merged, validated config.
|
|
76
|
-
* @param version - The running sous version. Defaults to this installation's.
|
|
77
|
-
*/
|
|
78
|
-
export function applyRepoDefaults(
|
|
79
|
-
settings: Settings,
|
|
80
|
-
version: string = SOUS_VERSION
|
|
81
|
-
): Settings {
|
|
82
|
-
// Anything that is not a map of entries is left exactly as written, so schema
|
|
83
|
-
// validation reports the real mistake rather than a symptom of this merge.
|
|
84
|
-
if (!isEntryMap(settings.repos) || !isEntryMap(settings.subscriptions)) return settings;
|
|
85
|
-
|
|
86
|
-
const repos: Record<string, RepoEntry> = {
|
|
87
|
-
...settings.repos,
|
|
88
|
-
[OFFICIAL_REPO_NAME]: mergeOverDefault(
|
|
89
|
-
builtInRepoEntry(),
|
|
90
|
-
settings.repos?.[OFFICIAL_REPO_NAME]
|
|
91
|
-
),
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const withRepos: Settings = { ...settings, repos };
|
|
95
|
-
if (repos[OFFICIAL_REPO_NAME]?.enabled === false) return withRepos;
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
...withRepos,
|
|
99
|
-
subscriptions: {
|
|
100
|
-
...settings.subscriptions,
|
|
101
|
-
[CORE_NAMESPACE]: mergeOverDefault(
|
|
102
|
-
builtInCoreSubscription(version),
|
|
103
|
-
settings.subscriptions?.[CORE_NAMESPACE]
|
|
104
|
-
),
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Lays what a project wrote over the entry sous provides.
|
|
111
|
-
*
|
|
112
|
-
* The merge is per field, not per entry, which is the whole point: the shortest
|
|
113
|
-
* possible opt-out, `{ enabled: false }`, is a complete entry once the built-in
|
|
114
|
-
* URL and provider are underneath it. A project that wants to repoint the
|
|
115
|
-
* repository writes a `url` and that field alone changes.
|
|
116
|
-
*
|
|
117
|
-
* @param fallback - The entry sous provides.
|
|
118
|
-
* @param written - What the project's config layers produced, when anything did.
|
|
119
|
-
*/
|
|
120
|
-
function mergeOverDefault<T extends object>(fallback: T, written: T | undefined): T {
|
|
121
|
-
if (written === undefined || typeof written !== "object" || Array.isArray(written)) {
|
|
122
|
-
return fallback;
|
|
123
|
-
}
|
|
124
|
-
return { ...fallback, ...written };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** True when a config value is absent or is a plain map of entries. */
|
|
128
|
-
function isEntryMap(value: unknown): boolean {
|
|
129
|
-
return value === undefined || (typeof value === "object" && value !== null && !Array.isArray(value));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* True when an entry is one sous provided rather than one the project wrote.
|
|
134
|
-
*
|
|
135
|
-
* @param entry - A repository or subscription entry.
|
|
136
|
-
*/
|
|
137
|
-
export function isBuiltInEntry(entry: { addedBy?: string } | undefined): boolean {
|
|
138
|
-
return entry?.addedBy === BUILT_IN_ADDED_BY;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* The repositories a project actually uses: everything in the config except the
|
|
143
|
-
* entries switched off with `enabled: false`. A switched-off entry stays in the
|
|
144
|
-
* config, and stays visible to `sous config show`, so the opt-out is legible;
|
|
145
|
-
* it simply takes no part in resolving, fetching or trusting anything.
|
|
146
|
-
*
|
|
147
|
-
* @param settings - The merged config.
|
|
148
|
-
*/
|
|
149
|
-
export function enabledRepos(settings: Settings | undefined): Record<string, RepoEntry> {
|
|
150
|
-
return withoutDisabled(settings?.repos);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* The subscriptions a project actually has, on the same terms as
|
|
155
|
-
* `enabledRepos`.
|
|
156
|
-
*
|
|
157
|
-
* @param settings - The merged config.
|
|
158
|
-
*/
|
|
159
|
-
export function enabledSubscriptions(
|
|
160
|
-
settings: Settings | undefined
|
|
161
|
-
): Record<string, SubscriptionEntry> {
|
|
162
|
-
return withoutDisabled(settings?.subscriptions);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/** Drops every entry whose `enabled` field says false. */
|
|
166
|
-
function withoutDisabled<T extends { enabled?: boolean }>(
|
|
167
|
-
entries: Record<string, T> | undefined
|
|
168
|
-
): Record<string, T> {
|
|
169
|
-
const kept: Record<string, T> = {};
|
|
170
|
-
for (const [key, entry] of Object.entries(entries ?? {})) {
|
|
171
|
-
if (entry?.enabled === false) continue;
|
|
172
|
-
kept[key] = entry;
|
|
173
|
-
}
|
|
174
|
-
return kept;
|
|
175
|
-
}
|