@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,461 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { Args, Flags } from "@oclif/core";
|
|
4
|
-
import { BaseCommand } from "../../base-command.js";
|
|
5
|
-
import { runProjectBuild } from "../../lib/build-service.js";
|
|
6
|
-
import { ConfigError, isConfigError } from "../../lib/errors.js";
|
|
7
|
-
import {
|
|
8
|
-
NonInteractiveError,
|
|
9
|
-
isInteractive,
|
|
10
|
-
nonInteractiveError,
|
|
11
|
-
wantsHelp,
|
|
12
|
-
} from "../../lib/interactive.js";
|
|
13
|
-
import {
|
|
14
|
-
globalReposDir,
|
|
15
|
-
projectReposDir,
|
|
16
|
-
readGlobalLinks,
|
|
17
|
-
readProjectLinks,
|
|
18
|
-
writeGlobalLinks,
|
|
19
|
-
writeProjectLinks,
|
|
20
|
-
} from "../../lib/repos/links.js";
|
|
21
|
-
import { hasNoUnsavedWork, unsavedWork, type UnsavedWork } from "../../lib/repos/git-clone.js";
|
|
22
|
-
import {
|
|
23
|
-
subscriptionServiceFor,
|
|
24
|
-
type SubscriptionService,
|
|
25
|
-
} from "../../lib/repos/subscription-service.js";
|
|
26
|
-
import type { RepoLink } from "../../lib/repos/formats/links-map.js";
|
|
27
|
-
import { collectProvidedAnswers } from "../../lib/vars/index.js";
|
|
28
|
-
import { formatAskReport } from "../../lib/vars/ask.js";
|
|
29
|
-
import {
|
|
30
|
-
BULLET,
|
|
31
|
-
blankLine,
|
|
32
|
-
dryRunNotice,
|
|
33
|
-
footer,
|
|
34
|
-
heading,
|
|
35
|
-
indent,
|
|
36
|
-
log,
|
|
37
|
-
note,
|
|
38
|
-
paragraph,
|
|
39
|
-
section,
|
|
40
|
-
showCommandVars,
|
|
41
|
-
showVariables,
|
|
42
|
-
subheading,
|
|
43
|
-
warning,
|
|
44
|
-
} from "../../utils/formatting.js";
|
|
45
|
-
import { askYesNo } from "../../utils/prompts.js";
|
|
46
|
-
import { answerFlags, confirmationFlag } from "../../utils/flags.js";
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* `sous repo unlink` stops reading a repository from a working copy, goes back
|
|
50
|
-
* to the versions the lockfile pins, and rebuilds the project.
|
|
51
|
-
*
|
|
52
|
-
* Linking never touches the lockfile, so unlinking returns to exactly the
|
|
53
|
-
* versions pinned before the link. Three ways to finish, one per flag:
|
|
54
|
-
*
|
|
55
|
-
* - On its own, it fetches the repository's index with a short timeout and
|
|
56
|
-
* reports, as a fact, any newer published version the ranges allow. Nothing
|
|
57
|
-
* moves.
|
|
58
|
-
* - `--update` runs the same code as `sous subscription update <repository>`,
|
|
59
|
-
* so the pins move to those newer versions before the rebuild.
|
|
60
|
-
* - `--remove` deletes the checkout, and only one sous cloned itself. A
|
|
61
|
-
* checkout linked by path belongs to its owner and is never deleted. Work
|
|
62
|
-
* that exists nowhere else is listed first and asked about.
|
|
63
|
-
*
|
|
64
|
-
* Without `--remove` the checkout stays exactly where it is, because `sous repo
|
|
65
|
-
* submit` uses a leftover checkout to revise a proposal that is still open.
|
|
66
|
-
*/
|
|
67
|
-
export default class RepoUnlink extends BaseCommand {
|
|
68
|
-
static description =
|
|
69
|
-
"Stop reading a repository from a working copy and go back to its pinned versions";
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The other spelling of the topic. It lives under a hidden topic, so it is
|
|
73
|
-
* typable everywhere without ever reaching the top-level listing.
|
|
74
|
-
*/
|
|
75
|
-
static aliases = ["repos:unlink"];
|
|
76
|
-
|
|
77
|
-
static examples = [
|
|
78
|
-
"<%= config.bin %> repo unlink sous-recipes",
|
|
79
|
-
"<%= config.bin %> repo unlink sous-recipes --update",
|
|
80
|
-
"<%= config.bin %> repo unlink sous-recipes --remove",
|
|
81
|
-
"<%= config.bin %> repo unlink sous-recipes --global",
|
|
82
|
-
];
|
|
83
|
-
|
|
84
|
-
static args = {
|
|
85
|
-
repo: Args.string({
|
|
86
|
-
description: "The repository's short name, as it appears in the links map",
|
|
87
|
-
required: true,
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
static flags = {
|
|
92
|
-
...BaseCommand.baseFlags,
|
|
93
|
-
global: Flags.boolean({
|
|
94
|
-
description: "Remove the machine-wide link rather than this project's link",
|
|
95
|
-
default: false,
|
|
96
|
-
}),
|
|
97
|
-
update: Flags.boolean({
|
|
98
|
-
description:
|
|
99
|
-
"Move this repository's pins to the newest versions their ranges allow before rebuilding",
|
|
100
|
-
default: false,
|
|
101
|
-
}),
|
|
102
|
-
remove: Flags.boolean({
|
|
103
|
-
description: "Delete the checkout as well, when sous cloned it",
|
|
104
|
-
default: false,
|
|
105
|
-
}),
|
|
106
|
-
// One flag answers every question this command can ask: deleting a
|
|
107
|
-
// checkout that holds work, the update plan, and the trust question for a
|
|
108
|
-
// repository a newer version needs.
|
|
109
|
-
yes: confirmationFlag({ extraAliases: ["trust"] }),
|
|
110
|
-
"dry-run": Flags.boolean({
|
|
111
|
-
description: "Print what would change without writing anything",
|
|
112
|
-
default: false,
|
|
113
|
-
}),
|
|
114
|
-
"no-build": Flags.boolean({
|
|
115
|
-
description: "Unlink without rebuilding the project",
|
|
116
|
-
default: false,
|
|
117
|
-
}),
|
|
118
|
-
...answerFlags(),
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
async run(): Promise<void> {
|
|
122
|
-
const { args, flags } = await this.parse(RepoUnlink);
|
|
123
|
-
const { sousDir } = this.configContext;
|
|
124
|
-
const isGlobal = flags.global;
|
|
125
|
-
const name = args.repo;
|
|
126
|
-
const dryRun = flags["dry-run"];
|
|
127
|
-
|
|
128
|
-
showCommandVars({
|
|
129
|
-
Project: this.projectLabel,
|
|
130
|
-
Repository: name,
|
|
131
|
-
Scope: isGlobal ? "this machine" : "this project",
|
|
132
|
-
"Dry Run": dryRun,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
section("Unlinking a repository");
|
|
136
|
-
|
|
137
|
-
const map = isGlobal ? readGlobalLinks() : readProjectLinks(sousDir);
|
|
138
|
-
const entry = map.links[name];
|
|
139
|
-
|
|
140
|
-
if (entry === undefined) {
|
|
141
|
-
throw new ConfigError(this.notLinkedMessage(name, isGlobal, sousDir));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const service = subscriptionServiceFor({
|
|
145
|
-
configContext: this.configContext,
|
|
146
|
-
settings: this.settings,
|
|
147
|
-
shellEnv: this.shellEnv,
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// Everything that can refuse is settled before anything is written, so a
|
|
151
|
-
// refusal leaves the link exactly as it was.
|
|
152
|
-
if (flags.update && service.currentRepos()[name] === undefined) {
|
|
153
|
-
throw new ConfigError(
|
|
154
|
-
`'${name}' is linked, but this project does not trust a repository by that ` +
|
|
155
|
-
`name, so it has no pins to update.\n` +
|
|
156
|
-
` Nothing was changed; the link is still in place.`
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
if (flags.remove) this.assertRemovable(name, entry, isGlobal, sousDir);
|
|
160
|
-
const work = flags.remove ? unsavedWork(entry.path) : undefined;
|
|
161
|
-
|
|
162
|
-
if (dryRun) {
|
|
163
|
-
dryRunNotice(`would unlink '${name}', which points at ${entry.path}`);
|
|
164
|
-
dryRunNotice(
|
|
165
|
-
flags.remove
|
|
166
|
-
? "the checkout would be deleted"
|
|
167
|
-
: "the checkout itself would be left where it is"
|
|
168
|
-
);
|
|
169
|
-
if (work !== undefined && !hasNoUnsavedWork(work)) this.describeUnsavedWork(work);
|
|
170
|
-
if (flags.update) await service.update({ repo: name, dryRun: true });
|
|
171
|
-
footer();
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (work !== undefined) await this.confirmRemoval(entry.path, work, flags.yes);
|
|
176
|
-
|
|
177
|
-
delete map.links[name];
|
|
178
|
-
const linksPath = isGlobal ? writeGlobalLinks(map) : writeProjectLinks(sousDir, map);
|
|
179
|
-
|
|
180
|
-
showVariables({
|
|
181
|
-
Repository: name,
|
|
182
|
-
Checkout: entry.path,
|
|
183
|
-
Updated: linksPath,
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
blankLine();
|
|
187
|
-
paragraph(`'${name}' is read from the versions the lockfile pins again.`);
|
|
188
|
-
|
|
189
|
-
if (flags.update) {
|
|
190
|
-
await this.updatePins(service, name, flags);
|
|
191
|
-
} else {
|
|
192
|
-
await this.reportNewerVersions(service, name);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (flags.remove) {
|
|
196
|
-
fs.rmSync(entry.path, { recursive: true, force: true });
|
|
197
|
-
blankLine();
|
|
198
|
-
paragraph(`The checkout sous cloned at ${entry.path} was deleted.`);
|
|
199
|
-
} else {
|
|
200
|
-
blankLine();
|
|
201
|
-
paragraph(
|
|
202
|
-
entry.origin === "clone"
|
|
203
|
-
? `The checkout sous cloned is still at ${entry.path}.`
|
|
204
|
-
: `The checkout at ${entry.path} was yours to begin with, and has not been touched.`
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
footer();
|
|
209
|
-
|
|
210
|
-
if (!flags["no-build"]) await this.rebuildProject(name);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Refuses to delete a checkout sous did not create, or one that is not where
|
|
215
|
-
* sous clones to. The link records its origin; a path-linked checkout belongs
|
|
216
|
-
* to whoever linked it.
|
|
217
|
-
*
|
|
218
|
-
* @param name - The repository's short name.
|
|
219
|
-
* @param entry - The link being removed.
|
|
220
|
-
* @param isGlobal - Whether it is the machine-wide link.
|
|
221
|
-
* @param sousDir - The project's `.sous/` directory.
|
|
222
|
-
*/
|
|
223
|
-
private assertRemovable(
|
|
224
|
-
name: string,
|
|
225
|
-
entry: RepoLink,
|
|
226
|
-
isGlobal: boolean,
|
|
227
|
-
sousDir: string
|
|
228
|
-
): void {
|
|
229
|
-
if (entry.origin !== "clone") {
|
|
230
|
-
throw new ConfigError(
|
|
231
|
-
`Sous did not create the checkout at ${entry.path}, so it will not delete it.\n` +
|
|
232
|
-
` '${name}' was linked to a checkout that was already there. Nothing was ` +
|
|
233
|
-
`changed; unlink without '--remove' to keep the checkout, and delete it ` +
|
|
234
|
-
`yourself if you want it gone.`
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const root = isGlobal ? globalReposDir() : projectReposDir(sousDir);
|
|
239
|
-
const relative = path.relative(root, entry.path);
|
|
240
|
-
if (relative === "" || relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
241
|
-
throw new ConfigError(
|
|
242
|
-
`The checkout at ${entry.path} is not inside ${root}, where sous clones ` +
|
|
243
|
-
`checkouts, so sous will not delete it.\n` +
|
|
244
|
-
` Nothing was changed; unlink without '--remove' and delete it yourself if ` +
|
|
245
|
-
`you want it gone.`
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Lists what deleting the checkout would lose, and asks before going on. A
|
|
252
|
-
* checkout with nothing to lose is deleted without a question.
|
|
253
|
-
*
|
|
254
|
-
* @param checkout - The checkout's path.
|
|
255
|
-
* @param work - What an inspection of it found.
|
|
256
|
-
* @param yes - Whether the confirmation flag answered the question already.
|
|
257
|
-
*/
|
|
258
|
-
private async confirmRemoval(
|
|
259
|
-
checkout: string,
|
|
260
|
-
work: UnsavedWork,
|
|
261
|
-
yes: boolean
|
|
262
|
-
): Promise<void> {
|
|
263
|
-
if (hasNoUnsavedWork(work)) return;
|
|
264
|
-
|
|
265
|
-
this.describeUnsavedWork(work);
|
|
266
|
-
if (yes) return;
|
|
267
|
-
|
|
268
|
-
if (!isInteractive()) {
|
|
269
|
-
throw nonInteractiveError({
|
|
270
|
-
prompt: `whether to delete the checkout at ${checkout}, and the work listed above`,
|
|
271
|
-
remedy:
|
|
272
|
-
"pass '--yes' (spelled '-y', '--force' or '-f' if you prefer) to delete it " +
|
|
273
|
-
"without being asked.",
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const proceed = await askYesNo("Delete the checkout, and this work with it?");
|
|
278
|
-
if (!proceed) {
|
|
279
|
-
throw new ConfigError(
|
|
280
|
-
`Nothing was changed: the checkout at ${checkout} was not deleted, and the ` +
|
|
281
|
-
`link is still in place.`
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Prints what exists only in the checkout, as a list.
|
|
288
|
-
*
|
|
289
|
-
* @param work - What an inspection of the checkout found.
|
|
290
|
-
*/
|
|
291
|
-
private describeUnsavedWork(work: UnsavedWork): void {
|
|
292
|
-
blankLine();
|
|
293
|
-
warning("The checkout holds work that exists nowhere else, and deleting it loses that work.");
|
|
294
|
-
blankLine();
|
|
295
|
-
|
|
296
|
-
const group = (title: string, items: string[]): void => {
|
|
297
|
-
if (items.length === 0) return;
|
|
298
|
-
log(indent(title));
|
|
299
|
-
for (const item of items) log(indent(`${BULLET} ${item}`, 4));
|
|
300
|
-
blankLine();
|
|
301
|
-
};
|
|
302
|
-
|
|
303
|
-
if (work.unknown !== undefined) {
|
|
304
|
-
group("Sous could not inspect it, so it may hold anything:", [work.unknown]);
|
|
305
|
-
}
|
|
306
|
-
group("Uncommitted changes:", work.uncommitted);
|
|
307
|
-
group("Commits no remote has:", work.unpushed);
|
|
308
|
-
group("Stashes:", work.stashes);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Moves the repository's pins through the same code `sous subscription
|
|
313
|
-
* update` runs. A failure there is reported with the fact that the link is
|
|
314
|
-
* already gone, since that part has happened.
|
|
315
|
-
*
|
|
316
|
-
* @param service - The subscription service.
|
|
317
|
-
* @param name - The repository's short name.
|
|
318
|
-
* @param flags - The confirmation and answer flags.
|
|
319
|
-
*/
|
|
320
|
-
private async updatePins(
|
|
321
|
-
service: SubscriptionService,
|
|
322
|
-
name: string,
|
|
323
|
-
flags: { yes: boolean; answer?: string[]; "answers-file"?: string }
|
|
324
|
-
): Promise<void> {
|
|
325
|
-
blankLine();
|
|
326
|
-
subheading("Updating the pins");
|
|
327
|
-
|
|
328
|
-
const provided = collectProvidedAnswers({
|
|
329
|
-
...(flags.answer === undefined ? {} : { answer: flags.answer }),
|
|
330
|
-
...(flags["answers-file"] === undefined ? {} : { answersFile: flags["answers-file"] }),
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
let outcome;
|
|
334
|
-
try {
|
|
335
|
-
outcome = await service.update({ repo: name, yes: flags.yes, answers: provided });
|
|
336
|
-
} catch (error) {
|
|
337
|
-
if (!isConfigError(error)) throw error;
|
|
338
|
-
// The unlink has already happened, so the message says so before the
|
|
339
|
-
// reason the update stopped. A blocked question keeps its kind, so the
|
|
340
|
-
// command's help is still printed under it.
|
|
341
|
-
const message =
|
|
342
|
-
`'${name}' was unlinked, but its pins were not updated.\n` +
|
|
343
|
-
`${(error as ConfigError).message}`;
|
|
344
|
-
throw wantsHelp(error) ? new NonInteractiveError(message) : new ConfigError(message);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (outcome.nothingToUpdate) return;
|
|
348
|
-
|
|
349
|
-
blankLine();
|
|
350
|
-
paragraph("The lockfile now pins the versions listed above.");
|
|
351
|
-
|
|
352
|
-
if (outcome.answers !== undefined) {
|
|
353
|
-
blankLine();
|
|
354
|
-
subheading("Variables");
|
|
355
|
-
for (const line of formatAskReport(outcome.answers)) log(line === "" ? "" : indent(line));
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Says whether the repository publishes newer versions the ranges allow,
|
|
361
|
-
* without moving anything. The index is fetched with a short timeout; when it
|
|
362
|
-
* cannot be fetched, that is what is reported.
|
|
363
|
-
*
|
|
364
|
-
* @param service - The subscription service.
|
|
365
|
-
* @param name - The repository's short name.
|
|
366
|
-
*/
|
|
367
|
-
private async reportNewerVersions(service: SubscriptionService, name: string): Promise<void> {
|
|
368
|
-
if (service.currentRepos()[name] === undefined) return;
|
|
369
|
-
|
|
370
|
-
blankLine();
|
|
371
|
-
subheading("Published versions");
|
|
372
|
-
blankLine();
|
|
373
|
-
|
|
374
|
-
const report = await service.newerPublishedVersions(name);
|
|
375
|
-
if (!report.checked) {
|
|
376
|
-
note(
|
|
377
|
-
`Sous could not check '${name}' for newer published versions. ` +
|
|
378
|
-
`${report.reason.split("\n")[0]!.trim()}`
|
|
379
|
-
);
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
if (report.newer.length === 0) {
|
|
384
|
-
paragraph(
|
|
385
|
-
`Every pin from '${name}' is the newest published version its range allows.`
|
|
386
|
-
);
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
paragraph(
|
|
391
|
-
`'${name}' publishes newer versions within range. The lockfile still pins the ` +
|
|
392
|
-
`older ones:`
|
|
393
|
-
);
|
|
394
|
-
blankLine();
|
|
395
|
-
showVariables(
|
|
396
|
-
report.newer.map((entry) => ({
|
|
397
|
-
label: entry.key,
|
|
398
|
-
value: `${entry.from} pinned, ${entry.to} published`,
|
|
399
|
-
}))
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Rebuilds the project, so its outputs come from the pinned versions rather
|
|
405
|
-
* than the checkout when this command returns.
|
|
406
|
-
*
|
|
407
|
-
* @param name - The repository that was unlinked, for the failure message.
|
|
408
|
-
*/
|
|
409
|
-
private async rebuildProject(name: string): Promise<void> {
|
|
410
|
-
await this.reloadDiscoveredConfig();
|
|
411
|
-
|
|
412
|
-
const succeeded = await runProjectBuild({
|
|
413
|
-
settings: this.settings,
|
|
414
|
-
configContext: this.configContext,
|
|
415
|
-
shellEnv: this.shellEnv,
|
|
416
|
-
heading: "Building the project",
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
if (!succeeded) {
|
|
420
|
-
throw new ConfigError(
|
|
421
|
-
`'${name}' was unlinked, but the build that followed failed, so this project's ` +
|
|
422
|
-
`outputs may still hold what the checkout contributed. The unlink itself is ` +
|
|
423
|
-
`recorded; fix what the build reported above and run 'sous build' again.`
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Explains that nothing was unlinked, and says where the link actually is
|
|
430
|
-
* when the user asked about the wrong scope; getting the scope wrong is the
|
|
431
|
-
* easiest mistake to make here.
|
|
432
|
-
*
|
|
433
|
-
* @param name - The repository's short name, as the user typed it.
|
|
434
|
-
* @param isGlobal - Which map was searched.
|
|
435
|
-
* @param sousDir - The project's discovered `.sous/` directory.
|
|
436
|
-
*/
|
|
437
|
-
private notLinkedMessage(name: string, isGlobal: boolean, sousDir: string): string {
|
|
438
|
-
const searched = isGlobal ? "the machine-wide links map" : "this project's links map";
|
|
439
|
-
const other = isGlobal ? readProjectLinks(sousDir) : readGlobalLinks();
|
|
440
|
-
|
|
441
|
-
if (other.links[name] !== undefined) {
|
|
442
|
-
const flag = isGlobal ? "without --global" : "with --global";
|
|
443
|
-
return (
|
|
444
|
-
`'${name}' is not linked in ${searched}.\n` +
|
|
445
|
-
` It is linked in the ${isGlobal ? "project" : "machine-wide"} map, at ` +
|
|
446
|
-
`${other.links[name]!.path}.\n` +
|
|
447
|
-
` Run the same command ${flag} to remove that one.`
|
|
448
|
-
);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const map = isGlobal ? readGlobalLinks() : readProjectLinks(sousDir);
|
|
452
|
-
const linked = Object.keys(map.links).sort();
|
|
453
|
-
return (
|
|
454
|
-
`'${name}' is not linked in ${searched}.\n` +
|
|
455
|
-
(linked.length > 0
|
|
456
|
-
? ` Linked there: ${linked.join(", ")}.\n`
|
|
457
|
-
: ` Nothing is linked there.\n`) +
|
|
458
|
-
` Run 'sous repo link ${name}' to link it.`
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
}
|