@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,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `sous subscription update [ref]`.
|
|
3
|
-
*
|
|
4
|
-
* Moves the lockfile's pins to the newest versions their ranges allow. With no
|
|
5
|
-
* reference it covers every subscription; a reference narrows it to one
|
|
6
|
-
* repository, one namespace or one recipe:
|
|
7
|
-
*
|
|
8
|
-
* sous subscription update
|
|
9
|
-
* sous subscription update sous-recipes
|
|
10
|
-
* sous subscription update workflow
|
|
11
|
-
* sous subscription update workflow/task-files
|
|
12
|
-
*
|
|
13
|
-
* Every trusted repository's index is fetched fresh first. A pin moves only
|
|
14
|
-
* within the range its subscription (or the recipe depending on it) declares,
|
|
15
|
-
* and dependencies move with the closure. Only the lockfile changes; the
|
|
16
|
-
* subscriptions themselves are never edited. The whole change is printed as a
|
|
17
|
-
* plan and asked about once, and the project is rebuilt afterwards.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { Args, Flags } from "@oclif/core";
|
|
21
|
-
import { BaseCommand } from "../../base-command.js";
|
|
22
|
-
import { runProjectBuild } from "../../lib/build-service.js";
|
|
23
|
-
import { ConfigError } from "../../lib/errors.js";
|
|
24
|
-
import { subscriptionServiceFor } from "../../lib/repos/subscription-service.js";
|
|
25
|
-
import { describeUpdateScope } from "../../lib/repos/update-plan.js";
|
|
26
|
-
import { formatAskReport } from "../../lib/vars/ask.js";
|
|
27
|
-
import { collectProvidedAnswers } from "../../lib/vars/index.js";
|
|
28
|
-
import {
|
|
29
|
-
blankLine,
|
|
30
|
-
dryRunNotice,
|
|
31
|
-
footer,
|
|
32
|
-
heading,
|
|
33
|
-
indent,
|
|
34
|
-
log,
|
|
35
|
-
paragraph,
|
|
36
|
-
showCommandVars,
|
|
37
|
-
subheading,
|
|
38
|
-
warning,
|
|
39
|
-
} from "../../utils/formatting.js";
|
|
40
|
-
import { answerFlags, confirmationFlag } from "../../utils/flags.js";
|
|
41
|
-
|
|
42
|
-
export default class SubscriptionUpdate extends BaseCommand {
|
|
43
|
-
static description =
|
|
44
|
-
"Move this project's pinned recipe versions to the newest ones their ranges allow";
|
|
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 = ["subscriptions:update"];
|
|
51
|
-
|
|
52
|
-
static examples = [
|
|
53
|
-
"<%= config.bin %> subscription update",
|
|
54
|
-
"<%= config.bin %> subscription update sous-recipes",
|
|
55
|
-
"<%= config.bin %> subscription update workflow/task-files",
|
|
56
|
-
"<%= config.bin %> subscription update --dry-run",
|
|
57
|
-
"<%= config.bin %> subscription update --yes",
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
static args = {
|
|
61
|
-
ref: Args.string({
|
|
62
|
-
description:
|
|
63
|
-
"What to update: a repository, a namespace or a recipe. Leave it out to update everything",
|
|
64
|
-
required: false,
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
static flags = {
|
|
69
|
-
...BaseCommand.baseFlags,
|
|
70
|
-
// One flag answers both questions this command can ask: the plan, and the
|
|
71
|
-
// trust question for a repository a newer version needs.
|
|
72
|
-
yes: confirmationFlag({ extraAliases: ["trust"] }),
|
|
73
|
-
"accept-first": Flags.boolean({
|
|
74
|
-
description:
|
|
75
|
-
"When the reference matches several things, take the first one listed",
|
|
76
|
-
default: false,
|
|
77
|
-
}),
|
|
78
|
-
"dry-run": Flags.boolean({
|
|
79
|
-
description:
|
|
80
|
-
"Print what would change without writing anything or downloading any recipe",
|
|
81
|
-
default: false,
|
|
82
|
-
}),
|
|
83
|
-
"no-build": Flags.boolean({
|
|
84
|
-
description: "Change the lockfile without rebuilding the project",
|
|
85
|
-
default: false,
|
|
86
|
-
}),
|
|
87
|
-
...answerFlags(),
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
async run(): Promise<void> {
|
|
91
|
-
const { args, flags } = await this.parse(SubscriptionUpdate);
|
|
92
|
-
const dryRun = flags["dry-run"];
|
|
93
|
-
|
|
94
|
-
showCommandVars({
|
|
95
|
-
Project: this.projectLabel,
|
|
96
|
-
Config: this.configContext.configPath,
|
|
97
|
-
Updating: args.ref ?? "every subscription",
|
|
98
|
-
"Dry Run": dryRun,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
heading("Updating");
|
|
102
|
-
|
|
103
|
-
if (dryRun) {
|
|
104
|
-
dryRunNotice(
|
|
105
|
-
"The indexes are fetched so the plan is current; no recipe is downloaded and " +
|
|
106
|
-
"nothing in this project is written."
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const service = subscriptionServiceFor({
|
|
111
|
-
configContext: this.configContext,
|
|
112
|
-
settings: this.settings,
|
|
113
|
-
shellEnv: this.shellEnv,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const provided = collectProvidedAnswers({
|
|
117
|
-
...(flags.answer === undefined ? {} : { answer: flags.answer }),
|
|
118
|
-
...(flags["answers-file"] === undefined ? {} : { answersFile: flags["answers-file"] }),
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const outcome = await service.update({
|
|
122
|
-
...(args.ref === undefined ? {} : { ref: args.ref }),
|
|
123
|
-
yes: flags.yes,
|
|
124
|
-
acceptFirst: flags["accept-first"],
|
|
125
|
-
answers: provided,
|
|
126
|
-
dryRun,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const scope = describeUpdateScope(outcome.scope);
|
|
130
|
-
|
|
131
|
-
if (outcome.nothingToUpdate) {
|
|
132
|
-
footer();
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (dryRun) {
|
|
137
|
-
paragraph(
|
|
138
|
-
`Nothing was written. Run the same command without '--dry-run' to update ${scope}.`
|
|
139
|
-
);
|
|
140
|
-
footer();
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
blankLine();
|
|
145
|
-
subheading("Lockfile");
|
|
146
|
-
blankLine();
|
|
147
|
-
if (outcome.diff.unchanged) {
|
|
148
|
-
paragraph("Nothing changed.");
|
|
149
|
-
} else {
|
|
150
|
-
for (const line of outcome.diff.lines) log(indent(line));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (outcome.trusted.length > 0) {
|
|
154
|
-
blankLine();
|
|
155
|
-
paragraph(
|
|
156
|
-
`Repositories trusted along the way: ${outcome.trusted.join(", ")}. They are ` +
|
|
157
|
-
`now recorded in this project's config, and your colleagues inherit them.`
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (outcome.answers !== undefined) {
|
|
162
|
-
blankLine();
|
|
163
|
-
subheading("Variables");
|
|
164
|
-
for (const line of formatAskReport(outcome.answers)) {
|
|
165
|
-
log(line === "" ? "" : indent(line));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (outcome.cycles.length > 0) {
|
|
170
|
-
warning(
|
|
171
|
-
`Some of these recipes co-subscribe to each other in a circle:\n` +
|
|
172
|
-
outcome.cycles.map((cycle) => ` ${cycle.join(" -> ")}`).join("\n") +
|
|
173
|
-
`\nThat is unusual but not broken, and the lockfile was updated.`
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const rebuilding = !flags["no-build"] && !outcome.diff.unchanged;
|
|
178
|
-
|
|
179
|
-
blankLine();
|
|
180
|
-
paragraph(
|
|
181
|
-
`The lockfile now pins the newest versions the ranges allow for ${scope}. ` +
|
|
182
|
-
`This project's subscriptions are exactly as they were.` +
|
|
183
|
-
(rebuilding || outcome.diff.unchanged ? "" : " The project was not rebuilt.")
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
footer();
|
|
187
|
-
|
|
188
|
-
if (rebuilding) await this.rebuildProject();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Rebuilds the project now that the lockfile has moved, so the outputs match
|
|
193
|
-
* the new versions when this command returns. The config is reloaded first,
|
|
194
|
-
* because a repository trusted along the way was written into a managed layer.
|
|
195
|
-
* A build that fails leaves the update in place, because it is already
|
|
196
|
-
* written; the message says so.
|
|
197
|
-
*/
|
|
198
|
-
private async rebuildProject(): Promise<void> {
|
|
199
|
-
await this.reloadDiscoveredConfig();
|
|
200
|
-
|
|
201
|
-
const succeeded = await runProjectBuild({
|
|
202
|
-
settings: this.settings,
|
|
203
|
-
configContext: this.configContext,
|
|
204
|
-
shellEnv: this.shellEnv,
|
|
205
|
-
heading: "Building the project",
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
if (!succeeded) {
|
|
209
|
-
throw new ConfigError(
|
|
210
|
-
`The lockfile was updated, but the build that followed it failed, so this ` +
|
|
211
|
-
`project's outputs may not match the new versions yet. The update itself is ` +
|
|
212
|
-
`recorded; fix what the build reported above and run 'sous build' again.`
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
package/src/commands/update.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `sous update` moves sous itself to a newer (or a chosen) version, for the
|
|
3
|
-
* global install, the project's own install, or both, through whichever
|
|
4
|
-
* package manager owns each one (sous-io/sous#135).
|
|
5
|
-
*
|
|
6
|
-
* sous update
|
|
7
|
-
* sous update --global
|
|
8
|
-
* sous update --major
|
|
9
|
-
* sous update --version 0.2.18
|
|
10
|
-
* sous update --dry-run
|
|
11
|
-
*
|
|
12
|
-
* It runs outside a project as readily as inside one, so it opts out of the
|
|
13
|
-
* config requirement, as `sous init` does. `bin/run.js` never hands this
|
|
14
|
-
* command to a project's own copy: updating the copy that was invoked is the
|
|
15
|
-
* point. The flow itself lives in `lib/self-update/run.ts`; this class turns
|
|
16
|
-
* the flags into its options and decides the exit code.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import path from "node:path";
|
|
20
|
-
import { Flags } from "@oclif/core";
|
|
21
|
-
import { BaseCommand } from "../base-command.js";
|
|
22
|
-
import { SOUS_DIR_NAME, findConfigInSousDir } from "../lib/config-discovery.js";
|
|
23
|
-
import { ConfigError, isConfigError } from "../lib/errors.js";
|
|
24
|
-
import { CLI_ROOT } from "../lib/package-info.js";
|
|
25
|
-
import { registryUrl, runSelfUpdate } from "../lib/self-update/run.js";
|
|
26
|
-
import type { UpdateScope, VersionRequest } from "../lib/self-update/index.js";
|
|
27
|
-
import { confirmationFlag } from "../utils/flags.js";
|
|
28
|
-
import { footer, showCommandVars } from "../utils/formatting.js";
|
|
29
|
-
|
|
30
|
-
export default class Update extends BaseCommand {
|
|
31
|
-
static description =
|
|
32
|
-
"Update sous itself, globally and in this project, through the package manager that installed each copy";
|
|
33
|
-
|
|
34
|
-
/** This command updates sous wherever it is installed; a project config is optional. */
|
|
35
|
-
static override requiresConfig = false;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A config this copy cannot load (one written for a newer sous, say) is the
|
|
39
|
-
* very thing an update may fix, so it is a warning here rather than a stop.
|
|
40
|
-
*/
|
|
41
|
-
static override toleratesConfigErrors = true;
|
|
42
|
-
|
|
43
|
-
static examples = [
|
|
44
|
-
"<%= config.bin %> update",
|
|
45
|
-
"<%= config.bin %> update --global",
|
|
46
|
-
"<%= config.bin %> update --major",
|
|
47
|
-
"<%= config.bin %> update --version 0.2.18",
|
|
48
|
-
"<%= config.bin %> update --version next",
|
|
49
|
-
"<%= config.bin %> update --dry-run",
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
static flags = {
|
|
53
|
-
...BaseCommand.baseFlags,
|
|
54
|
-
major: Flags.boolean({
|
|
55
|
-
description: "Install the newest published version, whatever its major version",
|
|
56
|
-
default: false,
|
|
57
|
-
exclusive: ["version"],
|
|
58
|
-
}),
|
|
59
|
-
version: Flags.string({
|
|
60
|
-
description: "Install this version, the newest version in this range, or the version this dist-tag names",
|
|
61
|
-
exclusive: ["major"],
|
|
62
|
-
}),
|
|
63
|
-
prerelease: Flags.boolean({
|
|
64
|
-
description:
|
|
65
|
-
"Count prerelease versions as candidates; on by default when the installed version is a prerelease",
|
|
66
|
-
allowNo: true,
|
|
67
|
-
aliases: ["pre"],
|
|
68
|
-
}),
|
|
69
|
-
global: Flags.boolean({
|
|
70
|
-
description: "Update only the global install",
|
|
71
|
-
default: false,
|
|
72
|
-
exclusive: ["project"],
|
|
73
|
-
}),
|
|
74
|
-
project: Flags.boolean({
|
|
75
|
-
description: "Update only this project's own install",
|
|
76
|
-
default: false,
|
|
77
|
-
exclusive: ["global"],
|
|
78
|
-
}),
|
|
79
|
-
yes: confirmationFlag(),
|
|
80
|
-
"dry-run": Flags.boolean({
|
|
81
|
-
description: "Print every install's plan without installing anything",
|
|
82
|
-
default: false,
|
|
83
|
-
}),
|
|
84
|
-
"no-build": Flags.boolean({
|
|
85
|
-
description: "Update the project install without building the project afterwards",
|
|
86
|
-
default: false,
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
async run(): Promise<void> {
|
|
91
|
-
const { flags } = await this.parse(Update);
|
|
92
|
-
const dryRun = flags["dry-run"];
|
|
93
|
-
const request: VersionRequest =
|
|
94
|
-
flags.version !== undefined
|
|
95
|
-
? { kind: "spec", spec: flags.version }
|
|
96
|
-
: flags.major
|
|
97
|
-
? { kind: "major" }
|
|
98
|
-
: { kind: "default" };
|
|
99
|
-
const only: UpdateScope | undefined = flags.global
|
|
100
|
-
? "global"
|
|
101
|
-
: flags.project
|
|
102
|
-
? "project"
|
|
103
|
-
: undefined;
|
|
104
|
-
|
|
105
|
-
showCommandVars({
|
|
106
|
-
Directory: this.configLocator.cwd,
|
|
107
|
-
Installs: only === undefined ? "global and project" : `${only} only`,
|
|
108
|
-
Version: describeRequest(request),
|
|
109
|
-
Prereleases:
|
|
110
|
-
flags.prerelease === undefined
|
|
111
|
-
? "counted when the installed version is one"
|
|
112
|
-
: flags.prerelease
|
|
113
|
-
? "counted"
|
|
114
|
-
: "not counted",
|
|
115
|
-
Registry: registryUrl(),
|
|
116
|
-
"Dry Run": dryRun,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const outcome = await runSelfUpdate({
|
|
120
|
-
cwd: this.configLocator.cwd,
|
|
121
|
-
ownRoot: CLI_ROOT,
|
|
122
|
-
request,
|
|
123
|
-
...(flags.prerelease === undefined ? {} : { prerelease: flags.prerelease }),
|
|
124
|
-
...(only === undefined ? {} : { only }),
|
|
125
|
-
dryRun,
|
|
126
|
-
yes: flags.yes,
|
|
127
|
-
interactive: this.interactive,
|
|
128
|
-
build: !flags["no-build"],
|
|
129
|
-
buildDirFor: (projectRoot) => this.buildDirFor(projectRoot),
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
footer();
|
|
133
|
-
|
|
134
|
-
if (outcome.failed) {
|
|
135
|
-
throw new ConfigError(
|
|
136
|
-
"Not every step of the update succeeded; the summary above lists what completed and what failed."
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Where a build after a project update runs: the directory of the config
|
|
143
|
-
* discovery found, when it lies inside the project that was updated, and
|
|
144
|
-
* otherwise the project root when its own `.sous/` holds a primary config.
|
|
145
|
-
* A config this copy could not load counts as found: the new copy may
|
|
146
|
-
* understand it, and its build is where any real problem is reported.
|
|
147
|
-
* Undefined means the project has no sous config, so nothing is built.
|
|
148
|
-
*/
|
|
149
|
-
private buildDirFor(projectRoot: string): string | undefined {
|
|
150
|
-
const found = this.hasConfig ? this.discovered.sousDir : this.rejectedConfig?.sousDir;
|
|
151
|
-
if (found !== undefined) {
|
|
152
|
-
const configDir = path.dirname(found);
|
|
153
|
-
const relative = path.relative(projectRoot, configDir);
|
|
154
|
-
if (!relative.startsWith("..") && !path.isAbsolute(relative)) return configDir;
|
|
155
|
-
}
|
|
156
|
-
return holdsPrimaryConfig(path.join(projectRoot, SOUS_DIR_NAME)) ? projectRoot : undefined;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Whether a `.sous/` directory holds a primary config. Holding several is
|
|
162
|
-
* still holding one: the build that follows reports that mistake itself.
|
|
163
|
-
*/
|
|
164
|
-
function holdsPrimaryConfig(sousDir: string): boolean {
|
|
165
|
-
try {
|
|
166
|
-
return findConfigInSousDir(sousDir) !== null;
|
|
167
|
-
} catch (error) {
|
|
168
|
-
if (isConfigError(error)) return true;
|
|
169
|
-
throw error;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/** The version request, as the opening block says it. */
|
|
174
|
-
function describeRequest(request: VersionRequest): string {
|
|
175
|
-
if (request.kind === "default") return "the newest in each install's major version";
|
|
176
|
-
if (request.kind === "major") return "the newest published, whatever its major version";
|
|
177
|
-
return request.spec;
|
|
178
|
-
}
|