@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,245 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Scaffolding a new recipe repository, which is what `sous repo init` does.
|
|
3
|
-
*
|
|
4
|
-
* The scaffold is built in memory first, validated with the very parsers sous
|
|
5
|
-
* uses to read a real repository, and only then written to disk. A scaffold
|
|
6
|
-
* that sous itself cannot read would be worse than no scaffold at all, so
|
|
7
|
-
* `scaffoldRepo` reads every manifest back after writing it and reports the
|
|
8
|
-
* failure against the file it just produced.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import fs from "node:fs";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import { ConfigError } from "../../errors.js";
|
|
14
|
-
import {
|
|
15
|
-
INDEX_FILENAME,
|
|
16
|
-
MANIFEST_EXTENSIONS,
|
|
17
|
-
RECIPE_MANIFEST_BASENAME,
|
|
18
|
-
REPO_MANIFEST_BASENAME,
|
|
19
|
-
} from "../formats/common.js";
|
|
20
|
-
import { parseIndexFile } from "../formats/index-file.js";
|
|
21
|
-
import { parseRecipeManifest } from "../formats/recipe-manifest.js";
|
|
22
|
-
import { parseRepoManifest } from "../formats/repo-manifest.js";
|
|
23
|
-
import { findRepoManifest, loadJsonFile, loadManifestFile } from "../load-manifest.js";
|
|
24
|
-
import {
|
|
25
|
-
buildAgentsMd,
|
|
26
|
-
buildClaudeMd,
|
|
27
|
-
buildContributing,
|
|
28
|
-
buildExampleSkill,
|
|
29
|
-
buildGitignore,
|
|
30
|
-
buildIndexFile,
|
|
31
|
-
buildReadme,
|
|
32
|
-
buildRecipeManifest,
|
|
33
|
-
buildReleaseWorkflow,
|
|
34
|
-
buildRepoManifest,
|
|
35
|
-
exampleRecipePath,
|
|
36
|
-
type ScaffoldContext,
|
|
37
|
-
} from "./templates.js";
|
|
38
|
-
|
|
39
|
-
export * from "./templates.js";
|
|
40
|
-
|
|
41
|
-
/** The name given to the one example recipe every scaffold writes. */
|
|
42
|
-
export const EXAMPLE_RECIPE_NAME = "example";
|
|
43
|
-
|
|
44
|
-
/** What to scaffold, and where. */
|
|
45
|
-
export type ScaffoldOptions = {
|
|
46
|
-
/** Absolute path to the directory the repository is created in. */
|
|
47
|
-
directory: string;
|
|
48
|
-
/** The repository's short name. Defaults to the directory's own name. */
|
|
49
|
-
name?: string;
|
|
50
|
-
/** The one namespace to declare. Defaults to the repository's name. */
|
|
51
|
-
namespace?: string;
|
|
52
|
-
/** Overwrite an existing repository rather than refusing to touch it. */
|
|
53
|
-
force?: boolean;
|
|
54
|
-
/** Work out every file and validate the plan, but write nothing. */
|
|
55
|
-
dryRun?: boolean;
|
|
56
|
-
/** The version of sous recorded in the generated index. */
|
|
57
|
-
sousVersion: string;
|
|
58
|
-
/** When the scaffold ran, recorded in the generated index. Defaults to now. */
|
|
59
|
-
now?: Date;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/** What a scaffold produced. */
|
|
63
|
-
export type ScaffoldResult = {
|
|
64
|
-
/** The directory the repository was created in. */
|
|
65
|
-
directory: string;
|
|
66
|
-
/** The repository's short name. */
|
|
67
|
-
name: string;
|
|
68
|
-
/** The namespace that was declared. */
|
|
69
|
-
namespace: string;
|
|
70
|
-
/** Paths of every file, relative to the directory, in the order they were written. */
|
|
71
|
-
files: string[];
|
|
72
|
-
/** True when nothing was actually written. */
|
|
73
|
-
dryRun: boolean;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/** One planned file: where it goes, and what goes in it. */
|
|
77
|
-
type PlannedFile = {
|
|
78
|
-
/** Path relative to the repository root. */
|
|
79
|
-
relativePath: string;
|
|
80
|
-
/** The complete file contents. */
|
|
81
|
-
contents: string;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Creates a new recipe repository modeled on `sous-io/sous-recipes`: a repo
|
|
86
|
-
* manifest, one example recipe with a placeholder skill, an empty but valid
|
|
87
|
-
* index, a README, a `CONTRIBUTING.md`, a `CLAUDE.md` and an `AGENTS.md` for
|
|
88
|
-
* agents, release automation and a `.gitignore`.
|
|
89
|
-
*
|
|
90
|
-
* @param options - What to scaffold, and where.
|
|
91
|
-
*/
|
|
92
|
-
export function scaffoldRepo(options: ScaffoldOptions): ScaffoldResult {
|
|
93
|
-
const directory = path.resolve(options.directory);
|
|
94
|
-
const name = normalizeName(options.name ?? path.basename(directory), "--name");
|
|
95
|
-
const namespace = normalizeName(options.namespace ?? name, "--namespace");
|
|
96
|
-
const dryRun = options.dryRun === true;
|
|
97
|
-
|
|
98
|
-
assertNoExistingRepo(directory, options.force === true);
|
|
99
|
-
|
|
100
|
-
const context: ScaffoldContext = {
|
|
101
|
-
name,
|
|
102
|
-
namespace,
|
|
103
|
-
recipe: EXAMPLE_RECIPE_NAME,
|
|
104
|
-
sousVersion: options.sousVersion,
|
|
105
|
-
generatedAt: (options.now ?? new Date()).toISOString(),
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const files = planFiles(context);
|
|
109
|
-
|
|
110
|
-
if (!dryRun) {
|
|
111
|
-
for (const file of files) {
|
|
112
|
-
const target = path.join(directory, file.relativePath);
|
|
113
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
114
|
-
fs.writeFileSync(target, file.contents, "utf8");
|
|
115
|
-
}
|
|
116
|
-
verifyScaffold(directory, context);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
directory,
|
|
121
|
-
name,
|
|
122
|
-
namespace,
|
|
123
|
-
files: files.map((file) => file.relativePath),
|
|
124
|
-
dryRun,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** Builds every file the scaffold writes, in the order they are written. */
|
|
129
|
-
function planFiles(context: ScaffoldContext): PlannedFile[] {
|
|
130
|
-
const recipeDir = exampleRecipePath(context);
|
|
131
|
-
return [
|
|
132
|
-
{
|
|
133
|
-
relativePath: `${REPO_MANIFEST_BASENAME}${MANIFEST_EXTENSIONS[0]}`,
|
|
134
|
-
contents: buildRepoManifest(context),
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
relativePath: INDEX_FILENAME,
|
|
138
|
-
contents: buildIndexFile(context),
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
relativePath: `${recipeDir}/${RECIPE_MANIFEST_BASENAME}${MANIFEST_EXTENSIONS[0]}`,
|
|
142
|
-
contents: buildRecipeManifest(context),
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
relativePath: `${recipeDir}/skills/example-skill/SKILL.tpl.md`,
|
|
146
|
-
contents: buildExampleSkill(context),
|
|
147
|
-
},
|
|
148
|
-
{ relativePath: "README.md", contents: buildReadme(context) },
|
|
149
|
-
{ relativePath: "CONTRIBUTING.md", contents: buildContributing(context) },
|
|
150
|
-
{ relativePath: "CLAUDE.md", contents: buildClaudeMd(context) },
|
|
151
|
-
{ relativePath: "AGENTS.md", contents: buildAgentsMd() },
|
|
152
|
-
{
|
|
153
|
-
relativePath: ".github/workflows/sous-release.yml",
|
|
154
|
-
contents: buildReleaseWorkflow(),
|
|
155
|
-
},
|
|
156
|
-
{ relativePath: ".gitignore", contents: buildGitignore() },
|
|
157
|
-
];
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Refuses to scaffold over a repository that already exists, unless the caller
|
|
162
|
-
* asked to. The manifest is the thing that makes a directory a repository, so
|
|
163
|
-
* that is what is checked; an ordinary directory with unrelated files in it is
|
|
164
|
-
* a perfectly reasonable place to create one.
|
|
165
|
-
*/
|
|
166
|
-
function assertNoExistingRepo(directory: string, force: boolean): void {
|
|
167
|
-
if (force) return;
|
|
168
|
-
|
|
169
|
-
const existing = findRepoManifest(directory);
|
|
170
|
-
if (existing !== undefined) {
|
|
171
|
-
throw new ConfigError(
|
|
172
|
-
`${directory} is already a sous repository.\n` +
|
|
173
|
-
` It holds ${path.basename(existing)}, which sous will not overwrite.\n` +
|
|
174
|
-
` Pass --force to write the scaffold over it, or choose another directory.`
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Reads back every file that has to parse, using the same loaders and schemas
|
|
181
|
-
* that read a published repository, so a scaffold is never reported as a
|
|
182
|
-
* success unless sous can actually read it.
|
|
183
|
-
*/
|
|
184
|
-
function verifyScaffold(directory: string, context: ScaffoldContext): void {
|
|
185
|
-
const manifestPath = path.join(
|
|
186
|
-
directory,
|
|
187
|
-
`${REPO_MANIFEST_BASENAME}${MANIFEST_EXTENSIONS[0]}`
|
|
188
|
-
);
|
|
189
|
-
const manifest = parseRepoManifest(loadManifestFile(manifestPath), manifestPath);
|
|
190
|
-
|
|
191
|
-
const indexPath = path.join(directory, INDEX_FILENAME);
|
|
192
|
-
parseIndexFile(loadJsonFile(indexPath, "repo index"), indexPath);
|
|
193
|
-
|
|
194
|
-
for (const recipePath of manifest.recipes) {
|
|
195
|
-
const recipeManifestPath = path.join(
|
|
196
|
-
directory,
|
|
197
|
-
recipePath,
|
|
198
|
-
`${RECIPE_MANIFEST_BASENAME}${MANIFEST_EXTENSIONS[0]}`
|
|
199
|
-
);
|
|
200
|
-
const recipe = parseRecipeManifest(
|
|
201
|
-
loadManifestFile(recipeManifestPath),
|
|
202
|
-
recipeManifestPath
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
if (!Object.hasOwn(manifest.namespaces, recipe.namespace)) {
|
|
206
|
-
throw new ConfigError(
|
|
207
|
-
`The scaffold in ${directory} is inconsistent.\n` +
|
|
208
|
-
` The recipe at ${recipePath} declares the namespace ` +
|
|
209
|
-
`'${recipe.namespace}', which ${REPO_MANIFEST_BASENAME}` +
|
|
210
|
-
`${MANIFEST_EXTENSIONS[0]} does not declare.\n` +
|
|
211
|
-
` This is a bug in sous; please report it.`
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (manifest.name !== context.name) {
|
|
217
|
-
throw new ConfigError(
|
|
218
|
-
`The scaffold in ${directory} is inconsistent: the repo manifest names it ` +
|
|
219
|
-
`'${manifest.name}' rather than '${context.name}'.\n` +
|
|
220
|
-
` This is a bug in sous; please report it.`
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Checks that a name sous is about to write into a manifest is a name the
|
|
227
|
-
* manifest schema accepts, and says how to fix it when it is not. Lower-cases
|
|
228
|
-
* the value first, so a directory called `My-Recipes` yields `my-recipes`
|
|
229
|
-
* instead of an error.
|
|
230
|
-
*/
|
|
231
|
-
function normalizeName(value: string, flagName: string): string {
|
|
232
|
-
const normalized = value.trim().toLowerCase();
|
|
233
|
-
|
|
234
|
-
if (!/^[a-z][a-z0-9-]*$/.test(normalized)) {
|
|
235
|
-
throw new ConfigError(
|
|
236
|
-
`'${value}' cannot be used as a name here.\n` +
|
|
237
|
-
` A repository name and a namespace name are lowercase kebab-case: a ` +
|
|
238
|
-
`letter, then letters, digits or hyphens (for example 'sous-recipes').\n` +
|
|
239
|
-
` Pass ${flagName} to choose one, or run the command in a directory whose ` +
|
|
240
|
-
`own name fits.`
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return normalized;
|
|
245
|
-
}
|