@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,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turning subscribed recipes into compile targets.
|
|
3
|
-
*
|
|
4
|
-
* A recipe's manifest lists what it contributes: skills, memories, prompts and
|
|
5
|
-
* config layers. Only skills are copied into the project, compiled exactly the
|
|
6
|
-
* way a project's own `entryGlob` target is: the recipe's directory is the glob
|
|
7
|
-
* root, the static part of each include pattern is the base the output tree
|
|
8
|
-
* mirrors, and the `.tpl.` convention applies unchanged. Memories reach an agent
|
|
9
|
-
* through include lines, never as copied files, and config layers are loaded
|
|
10
|
-
* rather than written.
|
|
11
|
-
*
|
|
12
|
-
* Two rules decide what is compiled at all:
|
|
13
|
-
*
|
|
14
|
-
* - Only recipes held through `subscribes` contribute files. A recipe held
|
|
15
|
-
* only through `depends` is fetched, pinned and addressable from the recipe
|
|
16
|
-
* that declared it, but its files never enter the project's output; that is
|
|
17
|
-
* the whole difference between the two dependency kinds.
|
|
18
|
-
* - Skills go to `recipes.skills.outputs`, which defaults to
|
|
19
|
-
* `.claude/skills` because that is where every agent looks. Prompts have no
|
|
20
|
-
* destination yet, so a recipe that publishes them is skipped with ONE
|
|
21
|
-
* warning naming the `recipes` config key.
|
|
22
|
-
*
|
|
23
|
-
* A recipe's `config` contents are not handled here. They are config layers, and
|
|
24
|
-
* config layers are loaded before any of this runs; see
|
|
25
|
-
* `listRecipeConfigLayers` in `config-discovery.ts`.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import fs from "node:fs";
|
|
29
|
-
import path from "node:path";
|
|
30
|
-
import { globSync } from "glob";
|
|
31
|
-
import type { CompilationTarget } from "../markdown-compiler.js";
|
|
32
|
-
import { inferGlobBase } from "../markdown-compiler.js";
|
|
33
|
-
import { toGlobPattern } from "../glob-pattern.js";
|
|
34
|
-
import type { Settings, VarScope } from "../settings.js";
|
|
35
|
-
import { normalizeConfigPath, substituteVarsStrict } from "../settings.js";
|
|
36
|
-
import type { ContentKind } from "./formats/recipe-manifest.js";
|
|
37
|
-
import {
|
|
38
|
-
listLockedRecipes,
|
|
39
|
-
readRecipeManifestIn,
|
|
40
|
-
type LockedRecipeLocation,
|
|
41
|
-
} from "./locked-recipes.js";
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The content kinds whose files are copied into a project. `config` is a layer,
|
|
45
|
-
* and `memories` are reached by include lines rather than copied.
|
|
46
|
-
*/
|
|
47
|
-
export const WRITABLE_CONTENT_KINDS = ["skills"] as const;
|
|
48
|
-
|
|
49
|
-
/** One content kind whose files land somewhere in the project. */
|
|
50
|
-
export type WritableContentKind = (typeof WRITABLE_CONTENT_KINDS)[number];
|
|
51
|
-
|
|
52
|
-
/** How the recipe targets are built. */
|
|
53
|
-
export type RecipeTargetOptions = {
|
|
54
|
-
/** The project's `.sous/` directory. */
|
|
55
|
-
sousDir: string;
|
|
56
|
-
/** The merged project config, read for `recipes.skills.outputs`. */
|
|
57
|
-
settings: Settings;
|
|
58
|
-
/** The resolved settings scope, used to substitute `${var}` in destinations. */
|
|
59
|
-
scope?: VarScope;
|
|
60
|
-
/**
|
|
61
|
-
* The scope one recipe's own files render with. A recipe's answers to its own
|
|
62
|
-
* questions are laid over the project scope there, so a recipe sees its own
|
|
63
|
-
* answer even when another recipe asks the same name. Defaults to `scope`.
|
|
64
|
-
*/
|
|
65
|
-
scopeFor?: (recipe: LockedRecipeLocation) => VarScope;
|
|
66
|
-
/** The environment to read; decides where the store is. */
|
|
67
|
-
env?: NodeJS.ProcessEnv;
|
|
68
|
-
/** The locked recipes, when the caller has already located them. */
|
|
69
|
-
locked?: LockedRecipeLocation[];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/** What the recipe targets add to a build. */
|
|
73
|
-
export type RecipeTargets = {
|
|
74
|
-
/** One compile target per file a subscribed recipe contributes. */
|
|
75
|
-
targets: CompilationTarget[];
|
|
76
|
-
/** Every destination directory the targets write into, for prune's benefit. */
|
|
77
|
-
destinations: string[];
|
|
78
|
-
/** Directories a watch should follow: the linked checkouts contributing files. */
|
|
79
|
-
watchDirs: string[];
|
|
80
|
-
/** Complete, plain-language sentences a build should print before it compiles. */
|
|
81
|
-
warnings: string[];
|
|
82
|
-
/**
|
|
83
|
-
* Every variable name a recipe declares `secret: true`, which the scope-dumping
|
|
84
|
-
* template tags hide. Set by the build from the resolved answers.
|
|
85
|
-
*/
|
|
86
|
-
secretVariables?: string[];
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The project's root directory: the parent of its `.sous/` directory. Used only
|
|
91
|
-
* for the one destination sous defaults, `.claude/skills`.
|
|
92
|
-
*
|
|
93
|
-
* @param sousDir - The project's `.sous/` directory.
|
|
94
|
-
*/
|
|
95
|
-
export function projectRootFor(sousDir: string): string {
|
|
96
|
-
return path.dirname(path.resolve(sousDir));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Where one content kind's files are written, with `${var}` substituted and each
|
|
101
|
-
* path normalized. An empty list means "nowhere configured", which is what makes
|
|
102
|
-
* the caller warn and skip.
|
|
103
|
-
*
|
|
104
|
-
* @param kind - The content kind.
|
|
105
|
-
* @param options - The project's config, scope and `.sous/` directory.
|
|
106
|
-
*/
|
|
107
|
-
export function destinationsFor(
|
|
108
|
-
kind: WritableContentKind,
|
|
109
|
-
options: RecipeTargetOptions
|
|
110
|
-
): string[] {
|
|
111
|
-
const configured = options.settings.recipes?.[kind]?.outputs;
|
|
112
|
-
|
|
113
|
-
if (configured === undefined || configured.length === 0) {
|
|
114
|
-
// `.claude/skills` is where every agent looks, so it is worth defaulting.
|
|
115
|
-
// Nothing else has an obvious home.
|
|
116
|
-
return kind === "skills"
|
|
117
|
-
? [path.join(projectRootFor(options.sousDir), ".claude", "skills")]
|
|
118
|
-
: [];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return configured.map((destination, index) =>
|
|
122
|
-
normalizeConfigPath(
|
|
123
|
-
substituteVarsStrict(
|
|
124
|
-
destination,
|
|
125
|
-
options.scope ?? {},
|
|
126
|
-
`recipes.${kind}.outputs[${index}]`
|
|
127
|
-
)
|
|
128
|
-
)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Builds the compile targets that the recipes this project subscribes to
|
|
134
|
-
* contribute. Returns an empty result for a project that locks nothing, so a
|
|
135
|
-
* project using no repositories pays nothing for this.
|
|
136
|
-
*
|
|
137
|
-
* @param options - The project's `.sous/` directory, its config and its scope.
|
|
138
|
-
*/
|
|
139
|
-
export function buildRecipeTargets(options: RecipeTargetOptions): RecipeTargets {
|
|
140
|
-
const locked =
|
|
141
|
-
options.locked ??
|
|
142
|
-
listLockedRecipes({
|
|
143
|
-
sousDir: options.sousDir,
|
|
144
|
-
...(options.env === undefined ? {} : { env: options.env }),
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const result: RecipeTargets = {
|
|
148
|
-
targets: [],
|
|
149
|
-
destinations: [],
|
|
150
|
-
watchDirs: [],
|
|
151
|
-
warnings: [],
|
|
152
|
-
};
|
|
153
|
-
if (locked.length === 0) return result;
|
|
154
|
-
|
|
155
|
-
const destinationCache = new Map<WritableContentKind, string[]>();
|
|
156
|
-
let skippedPrompts = false;
|
|
157
|
-
const destinations = new Set<string>();
|
|
158
|
-
const watchDirs = new Set<string>();
|
|
159
|
-
|
|
160
|
-
for (const recipe of locked) {
|
|
161
|
-
// Only a co-subscription contributes files; a build dependency is fetched
|
|
162
|
-
// and addressable, and that is all.
|
|
163
|
-
if (recipe.kind !== "subscribes") continue;
|
|
164
|
-
if (!recipe.present) continue;
|
|
165
|
-
|
|
166
|
-
const manifest = readRecipeManifestIn(recipe.dir);
|
|
167
|
-
if (manifest === undefined) continue;
|
|
168
|
-
|
|
169
|
-
for (const content of manifest.contents) {
|
|
170
|
-
const kind = content.kind;
|
|
171
|
-
if (kind === "prompts") {
|
|
172
|
-
skippedPrompts = true;
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (!isWritableKind(kind)) continue;
|
|
176
|
-
|
|
177
|
-
if (!destinationCache.has(kind)) {
|
|
178
|
-
destinationCache.set(kind, destinationsFor(kind, options));
|
|
179
|
-
}
|
|
180
|
-
const kindDestinations = destinationCache.get(kind)!;
|
|
181
|
-
|
|
182
|
-
if (kindDestinations.length === 0) continue;
|
|
183
|
-
|
|
184
|
-
for (const destination of kindDestinations) destinations.add(destination);
|
|
185
|
-
if (recipe.linked) watchDirs.add(recipe.dir);
|
|
186
|
-
|
|
187
|
-
const recipeScope = options.scopeFor?.(recipe) ?? options.scope ?? {};
|
|
188
|
-
|
|
189
|
-
const ignore = (content.exclude ?? []).map((pattern) =>
|
|
190
|
-
toGlobPattern(path.join(recipe.dir, pattern))
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
for (const include of content.include) {
|
|
194
|
-
const pattern = toGlobPattern(path.join(recipe.dir, include));
|
|
195
|
-
const matched = globSync(pattern, { absolute: true, ignore }).filter(isFile);
|
|
196
|
-
const globBase = normalizeConfigPath(inferGlobBase(pattern));
|
|
197
|
-
|
|
198
|
-
for (const filePath of matched) {
|
|
199
|
-
result.targets.push({
|
|
200
|
-
rootInputPath: filePath,
|
|
201
|
-
globBase,
|
|
202
|
-
outputs: kindDestinations.map((destination) => ({
|
|
203
|
-
destinationDir: destination,
|
|
204
|
-
vars: recipeScope,
|
|
205
|
-
})),
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (skippedPrompts) {
|
|
213
|
-
result.warnings.push(
|
|
214
|
-
`Some subscribed recipes contribute prompts, and the 'recipes' key of your sous ` +
|
|
215
|
-
`config has no destination for prompts yet, so they were skipped.`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
result.destinations = [...destinations].sort();
|
|
220
|
-
result.watchDirs = [...watchDirs].sort();
|
|
221
|
-
return result;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/** True when a content kind produces files rather than a config layer. */
|
|
225
|
-
function isWritableKind(kind: ContentKind): kind is WritableContentKind {
|
|
226
|
-
return (WRITABLE_CONTENT_KINDS as readonly string[]).includes(kind);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/** True when the path is a regular file. */
|
|
230
|
-
function isFile(candidate: string): boolean {
|
|
231
|
-
try {
|
|
232
|
-
return fs.statSync(candidate).isFile();
|
|
233
|
-
} catch {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What was searched when a ref matched nothing.
|
|
3
|
-
*
|
|
4
|
-
* Resolving a ref itself lives in `src/services/ref-resolver/`, which every command shares.
|
|
5
|
-
* All that is left here is the one thing only a repository search can say: which
|
|
6
|
-
* repositories were actually looked in, and which were trusted but unreadable,
|
|
7
|
-
* so the reader can tell "the name is wrong" from "the repository holding it
|
|
8
|
-
* was never fetched".
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { IndexFile } from "./formats/index-file.js";
|
|
12
|
-
|
|
13
|
-
/** The repositories a ref was searched in, and the indexes that were available. */
|
|
14
|
-
export type IndexSearchInputs = {
|
|
15
|
-
/** The name that was searched for. */
|
|
16
|
-
name: string;
|
|
17
|
-
/** The repositories the search covered, in search order. */
|
|
18
|
-
repoOrder: string[];
|
|
19
|
-
/** The cached index of each repository, keyed by short name. */
|
|
20
|
-
indexes: Map<string, IndexFile>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The lines a name that matched nothing is explained with: every repository
|
|
25
|
-
* whose index was searched, and every trusted repository whose index could not
|
|
26
|
-
* be read.
|
|
27
|
-
*
|
|
28
|
-
* @param inputs - The same inputs the search was given.
|
|
29
|
-
*/
|
|
30
|
-
export function describeIndexSearch(inputs: IndexSearchInputs): string[] {
|
|
31
|
-
const searched = inputs.repoOrder.filter((repo) => inputs.indexes.has(repo));
|
|
32
|
-
const missing = inputs.repoOrder.filter((repo) => !inputs.indexes.has(repo));
|
|
33
|
-
|
|
34
|
-
const lines = [
|
|
35
|
-
searched.length === 0
|
|
36
|
-
? ` No repository index could be read, so there was nothing to search.`
|
|
37
|
-
: ` Searched the namespaces and the recipe names of: ${searched.join(", ")}.`,
|
|
38
|
-
];
|
|
39
|
-
if (missing.length > 0) {
|
|
40
|
-
lines.push(
|
|
41
|
-
` These repositories are trusted but their index could not be read, so nothing ` +
|
|
42
|
-
`in them was searched: ${missing.join(", ")}.`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return lines;
|
|
46
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Raising, or setting, the version in a recipe manifest.
|
|
3
|
-
*
|
|
4
|
-
* A recipe manifest is HAND-WRITTEN, and the scaffold sous writes is mostly
|
|
5
|
-
* comments, so a version bump must give the file back to its author looking the
|
|
6
|
-
* way they left it. Both supported formats are edited in place rather than
|
|
7
|
-
* re-serialized from a parsed object: YAML through the `yaml` package's
|
|
8
|
-
* document model, which keeps comments and layout, and JSON through
|
|
9
|
-
* `jsonc-parser`, which edits the exact byte range of the value and leaves
|
|
10
|
-
* everything else, comments included, untouched.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import fs from "node:fs";
|
|
14
|
-
import path from "node:path";
|
|
15
|
-
import semver from "semver";
|
|
16
|
-
import YAML from "yaml";
|
|
17
|
-
import { applyEdits, modify } from "jsonc-parser";
|
|
18
|
-
import { ConfigError } from "../../errors.js";
|
|
19
|
-
import { parseJsoncText } from "../load-manifest.js";
|
|
20
|
-
|
|
21
|
-
/** How far a version is being raised. */
|
|
22
|
-
export const BUMP_LEVELS = ["patch", "minor", "major", "prerelease"] as const;
|
|
23
|
-
|
|
24
|
-
/** One of the ways `sous repo release --bump` can raise a version. */
|
|
25
|
-
export type BumpLevel = (typeof BUMP_LEVELS)[number];
|
|
26
|
-
|
|
27
|
-
/** What one bump did. */
|
|
28
|
-
export type BumpResult = {
|
|
29
|
-
/** The manifest that was rewritten. */
|
|
30
|
-
manifestPath: string;
|
|
31
|
-
/** The version it declared before. */
|
|
32
|
-
from: string;
|
|
33
|
-
/** The version it declares now. */
|
|
34
|
-
to: string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The version one level up from the current one, using npm's own semantics.
|
|
39
|
-
*
|
|
40
|
-
* @param current - The version the manifest declares now.
|
|
41
|
-
* @param level - How far to raise it.
|
|
42
|
-
*/
|
|
43
|
-
export function nextVersion(current: string, level: BumpLevel): string {
|
|
44
|
-
const next = semver.inc(current, level);
|
|
45
|
-
if (next === null) {
|
|
46
|
-
throw new ConfigError(
|
|
47
|
-
`Cannot raise the version '${current}' by a ${level} step.\n` +
|
|
48
|
-
` A recipe version is an exact semantic version, such as '1.4.0' or '2.0.0-beta.1'.`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
return next;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Rewrites a recipe manifest's `version` field in place, preserving the rest of
|
|
56
|
-
* the file as written.
|
|
57
|
-
*
|
|
58
|
-
* @param manifestPath - Absolute path to the recipe manifest.
|
|
59
|
-
* @param level - How far to raise the version.
|
|
60
|
-
*/
|
|
61
|
-
export function bumpRecipeVersion(manifestPath: string, level: BumpLevel): BumpResult {
|
|
62
|
-
return rewriteVersion(manifestPath, (current) => nextVersion(current, level));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Writes an exact version into a recipe manifest, preserving the rest of the
|
|
67
|
-
* file as written.
|
|
68
|
-
*
|
|
69
|
-
* This is what the release pipeline uses to hold the packaged core recipe at
|
|
70
|
-
* the sous package's own version (see `scripts/sync-core-version.mts`), where
|
|
71
|
-
* the new version is dictated rather than stepped. A manifest that already
|
|
72
|
-
* declares this version is left untouched, byte for byte, so running the sync
|
|
73
|
-
* twice cannot reformat a hand-written file.
|
|
74
|
-
*
|
|
75
|
-
* @param manifestPath - Absolute path to the recipe manifest.
|
|
76
|
-
* @param version - The exact semantic version the manifest should declare.
|
|
77
|
-
*/
|
|
78
|
-
export function setRecipeVersion(manifestPath: string, version: string): BumpResult {
|
|
79
|
-
if (semver.valid(version) === null) {
|
|
80
|
-
throw new ConfigError(
|
|
81
|
-
`Cannot set the recipe version to '${version}'.\n` +
|
|
82
|
-
` A recipe version is an exact semantic version, such as '1.4.0' or '2.0.0-beta.1'.`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
return rewriteVersion(manifestPath, () => version);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* The one writer both callers share: read the version the manifest declares,
|
|
90
|
-
* work out what it becomes, and rewrite that value alone.
|
|
91
|
-
*
|
|
92
|
-
* @param manifestPath - Absolute path to the recipe manifest.
|
|
93
|
-
* @param nextFrom - Given the declared version, the version to write.
|
|
94
|
-
*/
|
|
95
|
-
function rewriteVersion(
|
|
96
|
-
manifestPath: string,
|
|
97
|
-
nextFrom: (current: string) => string
|
|
98
|
-
): BumpResult {
|
|
99
|
-
const text = fs.readFileSync(manifestPath, "utf8");
|
|
100
|
-
const extension = path.extname(manifestPath).toLowerCase();
|
|
101
|
-
|
|
102
|
-
if (extension === ".json" || extension === ".jsonc") {
|
|
103
|
-
return rewriteJson(manifestPath, text, nextFrom);
|
|
104
|
-
}
|
|
105
|
-
return rewriteYaml(manifestPath, text, nextFrom);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** Rewrites the version in a YAML manifest, keeping its comments and layout. */
|
|
109
|
-
function rewriteYaml(
|
|
110
|
-
manifestPath: string,
|
|
111
|
-
text: string,
|
|
112
|
-
nextFrom: (current: string) => string
|
|
113
|
-
): BumpResult {
|
|
114
|
-
const document = YAML.parseDocument(text);
|
|
115
|
-
const node = document.get("version", true);
|
|
116
|
-
|
|
117
|
-
if (!YAML.isScalar(node) || typeof node.value !== "string") {
|
|
118
|
-
throw missingVersion(manifestPath);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const from = node.value;
|
|
122
|
-
const to = nextFrom(from);
|
|
123
|
-
if (to === from) return { manifestPath, from, to };
|
|
124
|
-
|
|
125
|
-
node.value = to;
|
|
126
|
-
fs.writeFileSync(manifestPath, document.toString(), "utf8");
|
|
127
|
-
|
|
128
|
-
return { manifestPath, from, to };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Rewrites the version in a JSON or JSONC manifest, editing only that value's bytes. */
|
|
132
|
-
function rewriteJson(
|
|
133
|
-
manifestPath: string,
|
|
134
|
-
text: string,
|
|
135
|
-
nextFrom: (current: string) => string
|
|
136
|
-
): BumpResult {
|
|
137
|
-
// The manifest dialect allows comments and trailing commas, so it is read
|
|
138
|
-
// through the loader's own permissive parser rather than JSON.parse.
|
|
139
|
-
const parsed = parseJsoncText(text, manifestPath);
|
|
140
|
-
const from =
|
|
141
|
-
typeof parsed === "object" && parsed !== null
|
|
142
|
-
? (parsed as Record<string, unknown>).version
|
|
143
|
-
: undefined;
|
|
144
|
-
if (typeof from !== "string") throw missingVersion(manifestPath);
|
|
145
|
-
|
|
146
|
-
const to = nextFrom(from);
|
|
147
|
-
if (to === from) return { manifestPath, from, to };
|
|
148
|
-
|
|
149
|
-
const edits = modify(text, ["version"], to, {});
|
|
150
|
-
fs.writeFileSync(manifestPath, applyEdits(text, edits), "utf8");
|
|
151
|
-
|
|
152
|
-
return { manifestPath, from, to };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** The error for a manifest with no usable `version` field. */
|
|
156
|
-
function missingVersion(manifestPath: string): ConfigError {
|
|
157
|
-
return new ConfigError(
|
|
158
|
-
`The recipe manifest at ${manifestPath} has no 'version' field to write.\n` +
|
|
159
|
-
` Every recipe declares an exact semantic version; add one, then try again.`
|
|
160
|
-
);
|
|
161
|
-
}
|