@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,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `sous repo remove <name>`: stop trusting a repository.
|
|
3
|
-
*
|
|
4
|
-
* The exact reverse of adding one. Adding a repository IS trusting it, so
|
|
5
|
-
* removing the entry is how that trust is withdrawn, and everything the project
|
|
6
|
-
* held through it goes with it: every subscription that resolves into it, every
|
|
7
|
-
* recipe those subscriptions alone held, and the files those recipes compiled.
|
|
8
|
-
*
|
|
9
|
-
* Informed consent, never prevention: the command prints all of that before it
|
|
10
|
-
* writes anything, asks once, and then does exactly what it described. The
|
|
11
|
-
* checkout behind a link is never deleted, because it is somebody's working
|
|
12
|
-
* copy and sous did not necessarily put it there.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { Args, Flags } from "@oclif/core";
|
|
16
|
-
import { BaseCommand } from "../../base-command.js";
|
|
17
|
-
import { runProjectBuild } from "../../lib/build-service.js";
|
|
18
|
-
import { ConfigError } from "../../lib/errors.js";
|
|
19
|
-
import { resolveRootScope } from "../../lib/settings.js";
|
|
20
|
-
import { subscriptionServiceFor } from "../../lib/repos/subscription-service.js";
|
|
21
|
-
import { confirmationFlag } from "../../utils/flags.js";
|
|
22
|
-
import { renderTable, type TableColumn } from "../../utils/table.js";
|
|
23
|
-
import {
|
|
24
|
-
blankLine,
|
|
25
|
-
dryRunNotice,
|
|
26
|
-
footer,
|
|
27
|
-
heading,
|
|
28
|
-
indent,
|
|
29
|
-
log,
|
|
30
|
-
showCommandVars,
|
|
31
|
-
subheading,
|
|
32
|
-
} from "../../utils/formatting.js";
|
|
33
|
-
|
|
34
|
-
/** How far every line of this command's output is indented. */
|
|
35
|
-
const INDENT = 2;
|
|
36
|
-
|
|
37
|
-
/** The columns the report of what stayed behind shows. */
|
|
38
|
-
const STAYED_COLUMNS: TableColumn[] = [
|
|
39
|
-
{ key: "key", header: "Recipe", kind: "path", overflow: "truncate", minWidth: 12 },
|
|
40
|
-
{ key: "heldBy", header: "Still held by", overflow: "wrap", flex: 1, minWidth: 16 },
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
export default class RepoRemove extends BaseCommand {
|
|
44
|
-
static description = "Stop trusting a repository, and remove everything it brought in";
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The other spelling of the topic. It lives under a hidden topic, so it is
|
|
48
|
-
* typable everywhere without ever reaching the top-level listing.
|
|
49
|
-
*/
|
|
50
|
-
static aliases = ["repos:remove"];
|
|
51
|
-
|
|
52
|
-
static examples = [
|
|
53
|
-
"<%= config.bin %> repo remove my-recipes",
|
|
54
|
-
"<%= config.bin %> repo remove my-recipes --dry-run",
|
|
55
|
-
"<%= config.bin %> repo remove my-recipes --yes",
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
static args = {
|
|
59
|
-
repo: Args.string({
|
|
60
|
-
description: "The repository's short name, as this project records it",
|
|
61
|
-
required: true,
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
static flags = {
|
|
66
|
-
...BaseCommand.baseFlags,
|
|
67
|
-
// The only question this command asks is whether to go ahead with what it
|
|
68
|
-
// has just described, so the shared confirmation flag answers it.
|
|
69
|
-
yes: confirmationFlag(),
|
|
70
|
-
"dry-run": Flags.boolean({
|
|
71
|
-
description: "Print what would be removed without writing anything",
|
|
72
|
-
default: false,
|
|
73
|
-
}),
|
|
74
|
-
"no-build": Flags.boolean({
|
|
75
|
-
description: "Remove the repository without rebuilding the project",
|
|
76
|
-
default: false,
|
|
77
|
-
}),
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
async run(): Promise<void> {
|
|
81
|
-
const { args, flags } = await this.parse(RepoRemove);
|
|
82
|
-
const dryRun = flags["dry-run"];
|
|
83
|
-
|
|
84
|
-
showCommandVars({
|
|
85
|
-
Project: this.projectLabel,
|
|
86
|
-
Config: this.configContext.configPath,
|
|
87
|
-
Repository: args.repo,
|
|
88
|
-
"Dry Run": dryRun,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// The heading is not followed by a blank line here: the plan that comes
|
|
92
|
-
// next opens with one of its own.
|
|
93
|
-
heading("Removing a repository");
|
|
94
|
-
|
|
95
|
-
if (dryRun) dryRunNotice("Nothing will be written.");
|
|
96
|
-
|
|
97
|
-
const service = subscriptionServiceFor({
|
|
98
|
-
configContext: this.configContext,
|
|
99
|
-
settings: this.settings,
|
|
100
|
-
shellEnv: this.shellEnv,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const outcome = await service.removeRepo({
|
|
104
|
-
name: args.repo,
|
|
105
|
-
yes: flags.yes,
|
|
106
|
-
dryRun,
|
|
107
|
-
// The output files a removed recipe wrote can only be named once the
|
|
108
|
-
// `recipes.skills.outputs` destinations have had their variables substituted.
|
|
109
|
-
scope: resolveRootScope(this.settings, this.configContext),
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
blankLine();
|
|
113
|
-
subheading("Lockfile");
|
|
114
|
-
blankLine();
|
|
115
|
-
if (outcome.diff.unchanged) {
|
|
116
|
-
log(indent("Nothing changed; nothing was locked because of this repository."));
|
|
117
|
-
} else {
|
|
118
|
-
for (const line of outcome.diff.lines) log(indent(line));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (outcome.stayed.length > 0) {
|
|
122
|
-
blankLine();
|
|
123
|
-
subheading("What stayed, and why");
|
|
124
|
-
blankLine();
|
|
125
|
-
const rows = outcome.stayed.map((entry) => ({
|
|
126
|
-
key: entry.key,
|
|
127
|
-
heldBy: entry.heldBy.join(", "),
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
for (const line of renderTable(STAYED_COLUMNS, rows, { indent: INDENT })) {
|
|
131
|
-
log(indent(line, INDENT));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const rebuilding = !dryRun && !flags["no-build"];
|
|
136
|
-
|
|
137
|
-
// The closing sentence names the build only when this run is not about to
|
|
138
|
-
// do it, so nobody is told to run a command that is already running.
|
|
139
|
-
const pruneHint = rebuilding
|
|
140
|
-
? ``
|
|
141
|
-
: ` Run 'sous build' to prune what it used to write.`;
|
|
142
|
-
|
|
143
|
-
blankLine();
|
|
144
|
-
log(
|
|
145
|
-
indent(
|
|
146
|
-
dryRun
|
|
147
|
-
? "Nothing was written. Run the same command without '--dry-run' to remove it."
|
|
148
|
-
: outcome.optedOut
|
|
149
|
-
? `The repository '${outcome.name}' is one sous provides itself, so it was ` +
|
|
150
|
-
`switched off rather than deleted: this project's config now records ` +
|
|
151
|
-
`'${outcome.name}: { enabled: false }'.${pruneHint}`
|
|
152
|
-
: `This project no longer trusts '${outcome.name}'. Nothing is read from it ` +
|
|
153
|
-
`any more, and its entry is gone from the repositories layer.${pruneHint}`
|
|
154
|
-
)
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
footer();
|
|
158
|
-
|
|
159
|
-
if (rebuilding) await this.rebuildProject(outcome.name);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Rebuilds the project now that the repository has been removed, so the files
|
|
164
|
-
* its recipes used to contribute are pruned before this command returns.
|
|
165
|
-
*
|
|
166
|
-
* The repositories and subscriptions both live in managed `conf.d/` layers, so
|
|
167
|
-
* the settings loaded when this command started no longer describe the
|
|
168
|
-
* project; they are reloaded before the build, or it would compile the old
|
|
169
|
-
* recipe set straight back onto disk. A build that fails leaves the removal in
|
|
170
|
-
* place, because it is already written and locked; the message says so and
|
|
171
|
-
* names the command to run once the cause is fixed.
|
|
172
|
-
*
|
|
173
|
-
* @param name - The repository that was just removed, for the failure message.
|
|
174
|
-
*/
|
|
175
|
-
private async rebuildProject(name: string): Promise<void> {
|
|
176
|
-
await this.reloadDiscoveredConfig();
|
|
177
|
-
|
|
178
|
-
const succeeded = await runProjectBuild({
|
|
179
|
-
settings: this.settings,
|
|
180
|
-
configContext: this.configContext,
|
|
181
|
-
shellEnv: this.shellEnv,
|
|
182
|
-
heading: "Building the project",
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
if (!succeeded) {
|
|
186
|
-
throw new ConfigError(
|
|
187
|
-
`The repository '${name}' was removed, but the build that followed it failed, ` +
|
|
188
|
-
`so this project may still hold files its recipes used to write. The removal ` +
|
|
189
|
-
`itself is recorded and locked; fix what the build reported above and run ` +
|
|
190
|
-
`'sous build' again.`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `sous repo search <text>`.
|
|
3
|
-
*
|
|
4
|
-
* Searches the cached index of every repository this project trusts: recipe
|
|
5
|
-
* names, namespace names and descriptions. By default it reads only what is
|
|
6
|
-
* already on disk, so it works offline and never downloads anything; a
|
|
7
|
-
* repository whose index has not been fetched yet is named at the end rather
|
|
8
|
-
* than silently left out of the results. `--latest` searches each index as
|
|
9
|
-
* upstream serves it, saving nothing, and `--installed` searches only the
|
|
10
|
-
* recipes the lockfile pins, showing the installed version.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { Args, Flags } from "@oclif/core";
|
|
14
|
-
import { BaseCommand } from "../../base-command.js";
|
|
15
|
-
import { subscriptionServiceFor } from "../../lib/repos/subscription-service.js";
|
|
16
|
-
import { readTrustedIndexes } from "../../lib/repos/catalog-inputs.js";
|
|
17
|
-
import {
|
|
18
|
-
LINKED_NOTE,
|
|
19
|
-
describeIndexSource,
|
|
20
|
-
pinnedCell,
|
|
21
|
-
} from "../../lib/repos/catalog-display.js";
|
|
22
|
-
import { readEffectiveLinks } from "../../lib/repos/links.js";
|
|
23
|
-
import { renderTable, type TableColumn } from "../../utils/table.js";
|
|
24
|
-
import { namespaceOfKey } from "../../services/ref-resolver/index.js";
|
|
25
|
-
import { browsingFlags } from "../../utils/flags.js";
|
|
26
|
-
import {
|
|
27
|
-
blankLine,
|
|
28
|
-
footer,
|
|
29
|
-
indent,
|
|
30
|
-
log,
|
|
31
|
-
note,
|
|
32
|
-
paragraph,
|
|
33
|
-
section,
|
|
34
|
-
showCommandVars,
|
|
35
|
-
} from "../../utils/formatting.js";
|
|
36
|
-
|
|
37
|
-
/** How far every line of this command's output is indented. */
|
|
38
|
-
const INDENT = 2;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The columns the results show. The recipe and its versions are why anybody ran
|
|
42
|
-
* the search, so they stay however narrow the terminal is; the description takes
|
|
43
|
-
* whatever room is left and wraps rather than being cut, because half a sentence
|
|
44
|
-
* helps nobody.
|
|
45
|
-
*/
|
|
46
|
-
const COLUMNS: TableColumn[] = [
|
|
47
|
-
{ key: "key", header: "Recipe", kind: "path", overflow: "truncate", minWidth: 12 },
|
|
48
|
-
{ key: "versions", header: "Versions", overflow: "truncate", minWidth: 7 },
|
|
49
|
-
{ key: "repo", header: "Repository", overflow: "truncate", priority: "medium" },
|
|
50
|
-
{
|
|
51
|
-
key: "description",
|
|
52
|
-
header: "What it is",
|
|
53
|
-
overflow: "wrap",
|
|
54
|
-
flex: 1,
|
|
55
|
-
priority: "low",
|
|
56
|
-
minWidth: 16,
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
/** The column an `--installed` search adds: the version the lockfile pins. */
|
|
61
|
-
const INSTALLED_COLUMN: TableColumn = {
|
|
62
|
-
key: "installed",
|
|
63
|
-
header: "Installed",
|
|
64
|
-
overflow: "truncate",
|
|
65
|
-
minWidth: 9,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/** One recipe that matched, ready to be shown. */
|
|
69
|
-
type Match = {
|
|
70
|
-
repo: string;
|
|
71
|
-
key: string;
|
|
72
|
-
description: string;
|
|
73
|
-
versions: string[];
|
|
74
|
-
/** The version the lockfile pins, when it pins this recipe from this repository. */
|
|
75
|
-
installed?: string;
|
|
76
|
-
/** The linked checkout builds read it from, when it is installed and its repository is linked. */
|
|
77
|
-
linkedPath?: string;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default class RepoSearch extends BaseCommand {
|
|
81
|
-
static description =
|
|
82
|
-
"Search the recipes every trusted repository publishes, by name or description";
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Searching is the way into every other repository command, so it is also a
|
|
86
|
-
* top-level `sous search` and is listed as one. `repos:search` is the plural
|
|
87
|
-
* spelling of the topic.
|
|
88
|
-
*/
|
|
89
|
-
static aliases = ["search", "repos:search"];
|
|
90
|
-
|
|
91
|
-
static examples = [
|
|
92
|
-
"<%= config.bin %> repo search task",
|
|
93
|
-
"<%= config.bin %> repo search browser --limit 50",
|
|
94
|
-
"<%= config.bin %> repo search task --installed --latest",
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
static args = {
|
|
98
|
-
text: Args.string({
|
|
99
|
-
description: "The text to look for in a namespace, recipe name or description",
|
|
100
|
-
required: true,
|
|
101
|
-
}),
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
static flags = {
|
|
105
|
-
...BaseCommand.baseFlags,
|
|
106
|
-
...browsingFlags(),
|
|
107
|
-
limit: Flags.integer({
|
|
108
|
-
description: "How many matches to show",
|
|
109
|
-
default: 25,
|
|
110
|
-
}),
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
async run(): Promise<void> {
|
|
114
|
-
const { args, flags } = await this.parse(RepoSearch);
|
|
115
|
-
const needle = args.text.trim().toLowerCase();
|
|
116
|
-
|
|
117
|
-
showCommandVars({
|
|
118
|
-
Project: this.projectLabel,
|
|
119
|
-
Config: this.configContext.configPath,
|
|
120
|
-
Searching: args.text,
|
|
121
|
-
Reading: describeIndexSource(flags.latest),
|
|
122
|
-
...(flags.installed ? { Showing: "only what this project has installed" } : {}),
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
section("Recipes matching your search");
|
|
126
|
-
|
|
127
|
-
const service = subscriptionServiceFor({
|
|
128
|
-
configContext: this.configContext,
|
|
129
|
-
settings: this.settings,
|
|
130
|
-
shellEnv: this.shellEnv,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const repos = Object.keys(service.currentRepos()).sort();
|
|
134
|
-
const matches: Match[] = [];
|
|
135
|
-
const indexes = await readTrustedIndexes(service, { latest: flags.latest });
|
|
136
|
-
const { notFetched, notChecked } = indexes;
|
|
137
|
-
const lock = service.lockService.read();
|
|
138
|
-
const links = readEffectiveLinks(this.configContext.sousDir);
|
|
139
|
-
|
|
140
|
-
for (const { name: repo, index } of indexes.repos) {
|
|
141
|
-
for (const [key, recipe] of Object.entries(index.recipes)) {
|
|
142
|
-
const locked = lock.recipes[key];
|
|
143
|
-
const installed = locked?.repo === repo ? locked.version : undefined;
|
|
144
|
-
if (flags.installed && installed === undefined) continue;
|
|
145
|
-
|
|
146
|
-
const namespace = namespaceOfKey(key);
|
|
147
|
-
const haystack = [
|
|
148
|
-
key,
|
|
149
|
-
recipe.description ?? "",
|
|
150
|
-
index.namespaces[namespace]?.description ?? "",
|
|
151
|
-
]
|
|
152
|
-
.join(" ")
|
|
153
|
-
.toLowerCase();
|
|
154
|
-
if (!haystack.includes(needle)) continue;
|
|
155
|
-
|
|
156
|
-
matches.push({
|
|
157
|
-
repo,
|
|
158
|
-
key,
|
|
159
|
-
description: recipe.description ?? "",
|
|
160
|
-
versions: Object.keys(recipe.versions).sort(),
|
|
161
|
-
...(installed === undefined ? {} : { installed }),
|
|
162
|
-
...(installed === undefined || links[repo] === undefined
|
|
163
|
-
? {}
|
|
164
|
-
: { linkedPath: links[repo]!.path }),
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
matches.sort((left, right) =>
|
|
170
|
-
left.key === right.key
|
|
171
|
-
? left.repo.localeCompare(right.repo)
|
|
172
|
-
: left.key.localeCompare(right.key)
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// Whatever the results themselves could not say goes into one closing
|
|
176
|
-
// summary, rather than a stack of separate notes under the table.
|
|
177
|
-
const summary: string[] = [];
|
|
178
|
-
|
|
179
|
-
if (matches.length === 0) {
|
|
180
|
-
paragraph(
|
|
181
|
-
repos.length === 0
|
|
182
|
-
? "This project trusts no repositories yet, so there is nothing to search. " +
|
|
183
|
-
"Add one with 'sous repo add <url>'."
|
|
184
|
-
: flags.installed
|
|
185
|
-
? `Nothing this project has installed matches '${args.text}'.`
|
|
186
|
-
: `Nothing in the repositories this project trusts matches '${args.text}'.`
|
|
187
|
-
);
|
|
188
|
-
} else {
|
|
189
|
-
const shown = matches.slice(0, flags.limit);
|
|
190
|
-
const rows = shown.map((match) => ({
|
|
191
|
-
key: match.key,
|
|
192
|
-
repo: match.repo,
|
|
193
|
-
versions: match.versions.join(", "),
|
|
194
|
-
installed: pinnedCell(match.installed, match.linkedPath),
|
|
195
|
-
description:
|
|
196
|
-
match.description.length > 0 ? match.description : "no description published",
|
|
197
|
-
}));
|
|
198
|
-
|
|
199
|
-
// Narrowed to what is installed, the installed version sits right after
|
|
200
|
-
// the recipe, ahead of every version the repository publishes.
|
|
201
|
-
const columns = flags.installed
|
|
202
|
-
? [COLUMNS[0]!, INSTALLED_COLUMN, ...COLUMNS.slice(1)]
|
|
203
|
-
: COLUMNS;
|
|
204
|
-
|
|
205
|
-
for (const line of renderTable(columns, rows, { indent: INDENT })) {
|
|
206
|
-
log(indent(line, INDENT));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (matches.length > shown.length) {
|
|
210
|
-
summary.push(
|
|
211
|
-
`${matches.length - shown.length} more matches are not shown. Raise the ` +
|
|
212
|
-
`number with '--limit'.`
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (notFetched.length > 0) {
|
|
218
|
-
summary.push(
|
|
219
|
-
`Nothing has been fetched from these repositories yet, so they were not ` +
|
|
220
|
-
`searched: ${notFetched.join(", ")}.`
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (notChecked.length > 0) {
|
|
225
|
-
summary.push(
|
|
226
|
-
`These repositories could not be reached, so they were searched as the cache ` +
|
|
227
|
-
`has them and were not checked: ${notChecked.join(", ")}.`
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (summary.length > 0) {
|
|
232
|
-
blankLine();
|
|
233
|
-
for (const line of summary) paragraph(line);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (matches.slice(0, flags.limit).some((match) => match.linkedPath !== undefined)) {
|
|
237
|
-
blankLine();
|
|
238
|
-
note(LINKED_NOTE);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
footer();
|
|
242
|
-
}
|
|
243
|
-
}
|