@rocket.chat/houston 0.27.0-next.3 → 2.1.8
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/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -194
- package/dist/outputCI.js +0 -59
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -28
- package/src/outputCI.ts +0 -12
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A hand-written subset of the version-specifier standard: enough to read `data/versions.yaml` and no more.
|
|
4
|
+
*
|
|
5
|
+
* The surface is what `versions.ts` asks of the specifier standard: parse a version, order two versions,
|
|
6
|
+
* and test a version against a specifier. `versions.yaml` uses exactly
|
|
7
|
+
* three specifier shapes -- `>=X`, `>=X,<Y` and `<X` -- so those three are implemented and
|
|
8
|
+
* **everything else throws**. A silent mistranslation of a specifier nobody implemented would
|
|
9
|
+
* pair the wrong MongoDB with a customer's Rocket.Chat, which is the one job this tool has.
|
|
10
|
+
*
|
|
11
|
+
* TWO RULES THAT LOOK LIKE EDGE CASES AND ARE NOT. Both were measured against the specifier standard
|
|
12
|
+
* reference implementation:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Pre-releases sort BELOW their release.** `8.0rc1 < 8.0.0`, so `8.0rc1` fails
|
|
15
|
+
* `>=8.0.0` and falls through to the next rule.
|
|
16
|
+
*
|
|
17
|
+
* 2. **`<V` excludes a pre-release OF V**, per the specifier standard: "The exclusive ordered
|
|
18
|
+
* comparison <V MUST NOT allow a pre-release of the specified version unless the
|
|
19
|
+
* specified version is itself a pre-release." So `8.0rc1 < 8.0.0` is *false* as a
|
|
20
|
+
* SPECIFIER even though it is true as an ordering, and `8.0rc1` therefore matches
|
|
21
|
+
* no rule in `versions.yaml` at all and `resolve()` raises.
|
|
22
|
+
*
|
|
23
|
+
* **That last outcome is BEHAVIOUR, not a bug to fix.** It is the established behaviour,
|
|
24
|
+
* and `versions.test.ts` pins it. Rules 1 and 2 together are the only reason `8.0rc1`
|
|
25
|
+
* behaves differently from `8.1.0rc2`, which does match.
|
|
26
|
+
*
|
|
27
|
+
* NOT IMPLEMENTED, deliberately, each of which throws rather than guessing: `==`, `!=`,
|
|
28
|
+
* `~=`, `===`, `>`, `<=`, wildcards, and a specifier's pre-release override. Add one
|
|
29
|
+
* when `versions.yaml` needs it, with a corpus row proving it agrees.
|
|
30
|
+
*/
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.SpecifierSet = exports.InvalidSpecifier = exports.InvalidVersion = void 0;
|
|
33
|
+
exports.parseVersion = parseVersion;
|
|
34
|
+
exports.compareVersions = compareVersions;
|
|
35
|
+
exports.matches = matches;
|
|
36
|
+
exports.highest = highest;
|
|
37
|
+
exports.lowest = lowest;
|
|
38
|
+
const float_text_1 = require("./float-text");
|
|
39
|
+
/** Which kind of pre-release, in the order the specifier standard sorts them. */
|
|
40
|
+
const PRE_ORDER = Object.freeze({ a: 0, b: 1, rc: 2 });
|
|
41
|
+
/** The spellings the specifier standard normalises onto each canonical pre-release letter. */
|
|
42
|
+
const PRE_ALIASES = Object.freeze({
|
|
43
|
+
alpha: 'a',
|
|
44
|
+
a: 'a',
|
|
45
|
+
beta: 'b',
|
|
46
|
+
b: 'b',
|
|
47
|
+
c: 'rc',
|
|
48
|
+
pre: 'rc',
|
|
49
|
+
preview: 'rc',
|
|
50
|
+
rc: 'rc',
|
|
51
|
+
});
|
|
52
|
+
const POST_ALIASES = new Set(['post', 'rev', 'r']);
|
|
53
|
+
/**
|
|
54
|
+
* The specifier standard's own grammar, transcribed. It is anchored with `\s*` at both ends, so
|
|
55
|
+
* surrounding whitespace is accepted -- `8.0\n` parses, which is exactly why
|
|
56
|
+
* `versions.MONGO_TAG_RE` needs its own stricter anchor and gets one. That `\s` is the
|
|
57
|
+
* `STRIP_CHARS` set, not JavaScript's: the input is stripped with stripText before the
|
|
58
|
+
* match, because the two sets part ways -- `\x1c`-`\x1f` and NEL are in the one and not in
|
|
59
|
+
* JavaScript's, so `versions $'\x1c8.5.1'` resolved in earlier releases and was "not a
|
|
60
|
+
* valid version" here, and a BOM is whitespace to JavaScript alone.
|
|
61
|
+
*/
|
|
62
|
+
const VERSION_RE = new RegExp('^' +
|
|
63
|
+
'v?' +
|
|
64
|
+
'(?:(?<epoch>[0-9]+)!)?' +
|
|
65
|
+
'(?<release>[0-9]+(?:\\.[0-9]+)*)' +
|
|
66
|
+
'(?<pre>[._-]?(?<preL>alpha|a|beta|b|preview|pre|c|rc)[._-]?(?<preN>[0-9]+)?)?' +
|
|
67
|
+
'(?<post>(?:-(?<postN1>[0-9]+))|(?:[._-]?(?<postL>post|rev|r)[._-]?(?<postN2>[0-9]+)?))?' +
|
|
68
|
+
'(?<dev>[._-]?(?<devL>dev)[._-]?(?<devN>[0-9]+)?)?' +
|
|
69
|
+
'(?:\\+(?<local>[a-z0-9]+(?:[._-][a-z0-9]+)*))?' +
|
|
70
|
+
'$', 'i');
|
|
71
|
+
class InvalidVersion extends Error {
|
|
72
|
+
}
|
|
73
|
+
exports.InvalidVersion = InvalidVersion;
|
|
74
|
+
class InvalidSpecifier extends Error {
|
|
75
|
+
}
|
|
76
|
+
exports.InvalidSpecifier = InvalidSpecifier;
|
|
77
|
+
function num(value) {
|
|
78
|
+
return value === undefined || value === '' ? 0 : Number(value);
|
|
79
|
+
}
|
|
80
|
+
/** Parse a version string, or throw `InvalidVersion`. */
|
|
81
|
+
function parseVersion(text) {
|
|
82
|
+
const m = VERSION_RE.exec((0, float_text_1.stripText)(text));
|
|
83
|
+
if (m === null || m.groups === undefined) {
|
|
84
|
+
throw new InvalidVersion(`${JSON.stringify(text)} is not a valid version`);
|
|
85
|
+
}
|
|
86
|
+
const g = m.groups;
|
|
87
|
+
const release = g.release.split('.').map(Number);
|
|
88
|
+
const epoch = num(g.epoch);
|
|
89
|
+
let pre = null;
|
|
90
|
+
if (g.preL !== undefined) {
|
|
91
|
+
const letter = PRE_ALIASES[g.preL.toLowerCase()];
|
|
92
|
+
// Unreachable via VERSION_RE, which only matches the aliased spellings. Kept so a
|
|
93
|
+
// future edit to the grammar cannot introduce a silently unranked pre-release.
|
|
94
|
+
if (letter === undefined)
|
|
95
|
+
throw new InvalidVersion(`unknown pre-release ${g.preL}`);
|
|
96
|
+
pre = [letter, num(g.preN)];
|
|
97
|
+
}
|
|
98
|
+
let post = null;
|
|
99
|
+
if (g.postN1 !== undefined) {
|
|
100
|
+
// The implicit `-N` form, as in `1.0-1`, which the specifier standard reads as `1.0.post1`.
|
|
101
|
+
post = num(g.postN1);
|
|
102
|
+
}
|
|
103
|
+
else if (g.postL !== undefined && POST_ALIASES.has(g.postL.toLowerCase())) {
|
|
104
|
+
post = num(g.postN2);
|
|
105
|
+
}
|
|
106
|
+
const dev = g.devL !== undefined ? num(g.devN) : null;
|
|
107
|
+
const local = g.local === undefined ? null : g.local.toLowerCase().replace(/[._-]/g, '.');
|
|
108
|
+
// A dev release is a pre-release too: `8.5.1.dev0` is a pre-release to the specifier standard
|
|
109
|
+
// reference implementation, and the corpus has a row for it.
|
|
110
|
+
const isPrerelease = pre !== null || dev !== null;
|
|
111
|
+
return {
|
|
112
|
+
text: renderVersion({ epoch, release, pre, post, dev, local }),
|
|
113
|
+
epoch,
|
|
114
|
+
release,
|
|
115
|
+
pre,
|
|
116
|
+
post,
|
|
117
|
+
dev,
|
|
118
|
+
local,
|
|
119
|
+
isPrerelease,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function renderVersion(v) {
|
|
123
|
+
let out = '';
|
|
124
|
+
if (v.epoch !== 0)
|
|
125
|
+
out += `${v.epoch}!`;
|
|
126
|
+
out += v.release.join('.');
|
|
127
|
+
if (v.pre !== null)
|
|
128
|
+
out += `${v.pre[0]}${v.pre[1]}`;
|
|
129
|
+
if (v.post !== null)
|
|
130
|
+
out += `.post${v.post}`;
|
|
131
|
+
if (v.dev !== null)
|
|
132
|
+
out += `.dev${v.dev}`;
|
|
133
|
+
if (v.local !== null)
|
|
134
|
+
out += `+${v.local}`;
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
/** Trailing zeros are not significant: `8.0` and `8.0.0` are the same release. */
|
|
138
|
+
function compareRelease(left, right) {
|
|
139
|
+
const width = Math.max(left.length, right.length);
|
|
140
|
+
for (let i = 0; i < width; i += 1) {
|
|
141
|
+
const a = left[i] ?? 0;
|
|
142
|
+
const b = right[i] ?? 0;
|
|
143
|
+
if (a !== b)
|
|
144
|
+
return a < b ? -1 : 1;
|
|
145
|
+
}
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The sort key for the pre/post/dev block, as the specifier standard orders it:
|
|
150
|
+
*
|
|
151
|
+
* X.devN < X{a|b|rc}N < X < X.postN
|
|
152
|
+
*
|
|
153
|
+
* Encoded as a tuple compared left to right. `-1` is the sentinel that sorts below every
|
|
154
|
+
* real value and `Infinity` the one that sorts above.
|
|
155
|
+
*/
|
|
156
|
+
function preKey(v) {
|
|
157
|
+
if (v.pre !== null) {
|
|
158
|
+
const rank = PRE_ORDER[v.pre[0]];
|
|
159
|
+
return [rank ?? 0, v.pre[1]];
|
|
160
|
+
}
|
|
161
|
+
// No pre-release. A bare dev release (`1.0.dev1`) sorts below every pre-release of
|
|
162
|
+
// the same release; anything else sorts above all of them.
|
|
163
|
+
if (v.dev !== null && v.post === null)
|
|
164
|
+
return [-1, 0];
|
|
165
|
+
return [Infinity, 0];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The local-version sort key, as the specifier standard defines it.
|
|
169
|
+
*
|
|
170
|
+
* Each dot-separated segment is compared as a NUMBER when it is all digits and as a
|
|
171
|
+
* STRING otherwise, and a numeric segment always sorts above an alphanumeric one. A
|
|
172
|
+
* version with no local label sorts below every version that has one.
|
|
173
|
+
*
|
|
174
|
+
* `[-1, segment]` for the alphanumeric case is the sentinel pair: -1 is below every real
|
|
175
|
+
* segment number, so any alphanumeric segment loses to any numeric one, and the string
|
|
176
|
+
* only breaks ties between two alphanumerics.
|
|
177
|
+
*/
|
|
178
|
+
function localKey(v) {
|
|
179
|
+
if (v.local === null)
|
|
180
|
+
return null;
|
|
181
|
+
return v.local
|
|
182
|
+
.split('.')
|
|
183
|
+
.map((part) => (/^[0-9]+$/.test(part) ? [Number(part), ''] : [-1, part]));
|
|
184
|
+
}
|
|
185
|
+
function compareLocal(left, right) {
|
|
186
|
+
const a = localKey(left);
|
|
187
|
+
const b = localKey(right);
|
|
188
|
+
// No local label at all sorts BELOW any local label: `1.0 < 1.0+abc`.
|
|
189
|
+
if (a === null && b === null)
|
|
190
|
+
return 0;
|
|
191
|
+
if (a === null)
|
|
192
|
+
return -1;
|
|
193
|
+
if (b === null)
|
|
194
|
+
return 1;
|
|
195
|
+
const width = Math.max(a.length, b.length);
|
|
196
|
+
for (let i = 0; i < width; i += 1) {
|
|
197
|
+
const x = a[i];
|
|
198
|
+
const y = b[i];
|
|
199
|
+
// A shorter local label sorts below a longer one that shares its prefix:
|
|
200
|
+
// `1.0+local < 1.0+local.1`.
|
|
201
|
+
if (x === undefined)
|
|
202
|
+
return -1;
|
|
203
|
+
if (y === undefined)
|
|
204
|
+
return 1;
|
|
205
|
+
if (x[0] !== y[0])
|
|
206
|
+
return x[0] < y[0] ? -1 : 1;
|
|
207
|
+
if (x[1] !== y[1])
|
|
208
|
+
return x[1] < y[1] ? -1 : 1;
|
|
209
|
+
}
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* -1, 0 or 1, ordering two versions exactly as `packaging` does.
|
|
214
|
+
*
|
|
215
|
+
* THE LOCAL LABEL IS COMPARED HERE, and it is deliberately NOT compared by the `>=` and
|
|
216
|
+
* `<` specifiers, which strip it first (see `publicOf`). Those really are two different
|
|
217
|
+
* rules in the specifier standard and conflating them is easy: this function started out ignoring the
|
|
218
|
+
* local label, which is right for a specifier and wrong for an ordering, and a comparison
|
|
219
|
+
* against packaging caught it on `8.5.1+local` against `8.5.1+local.1`.
|
|
220
|
+
*/
|
|
221
|
+
function compareVersions(left, right) {
|
|
222
|
+
if (left.epoch !== right.epoch)
|
|
223
|
+
return left.epoch < right.epoch ? -1 : 1;
|
|
224
|
+
const byRelease = compareRelease(left.release, right.release);
|
|
225
|
+
if (byRelease !== 0)
|
|
226
|
+
return byRelease;
|
|
227
|
+
const [lp, ln] = preKey(left);
|
|
228
|
+
const [rp, rn] = preKey(right);
|
|
229
|
+
if (lp !== rp)
|
|
230
|
+
return lp < rp ? -1 : 1;
|
|
231
|
+
if (ln !== rn)
|
|
232
|
+
return ln < rn ? -1 : 1;
|
|
233
|
+
const lpost = left.post ?? -1;
|
|
234
|
+
const rpost = right.post ?? -1;
|
|
235
|
+
if (lpost !== rpost)
|
|
236
|
+
return lpost < rpost ? -1 : 1;
|
|
237
|
+
const ldev = left.dev ?? Infinity;
|
|
238
|
+
const rdev = right.dev ?? Infinity;
|
|
239
|
+
if (ldev !== rdev)
|
|
240
|
+
return ldev < rdev ? -1 : 1;
|
|
241
|
+
return compareLocal(left, right);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The same version with its local label removed -- `Version.public` in `packaging`.
|
|
245
|
+
*
|
|
246
|
+
* The specifier standard: "local version labels MUST be ignored entirely when checking if candidate
|
|
247
|
+
* versions match a given version specifier". So `1.0+abc` satisfies `>=1.0` and `<1.0`
|
|
248
|
+
* behaves as though the label were not there.
|
|
249
|
+
*/
|
|
250
|
+
function publicOf(v) {
|
|
251
|
+
return v.local === null ? v : { ...v, local: null };
|
|
252
|
+
}
|
|
253
|
+
/** The two operators `versions.yaml` uses. Anything else is refused at parse time. */
|
|
254
|
+
const SUPPORTED = new Set(['>=', '<']);
|
|
255
|
+
/**
|
|
256
|
+
* A comma-separated specifier set: `>=8.0.0,<8.2.0`. Comma means AND.
|
|
257
|
+
*
|
|
258
|
+
* Throws `InvalidSpecifier` on any operator outside `{>=, <}` -- including perfectly
|
|
259
|
+
* valid forms of the specifier standard such as `==`, `!=` and `~=`. Refusing is the point: a shape this
|
|
260
|
+
* module does not implement must not be answered with a plausible boolean.
|
|
261
|
+
*/
|
|
262
|
+
class SpecifierSet {
|
|
263
|
+
constructor(text) {
|
|
264
|
+
this.text = text;
|
|
265
|
+
this.clauses = [];
|
|
266
|
+
for (const raw of text.split(',')) {
|
|
267
|
+
const part = raw.trim();
|
|
268
|
+
if (part === '')
|
|
269
|
+
continue;
|
|
270
|
+
const m = /^(>=|<=|==|!=|~=|===|>|<)\s*(.+)$/.exec(part);
|
|
271
|
+
if (m === null) {
|
|
272
|
+
throw new InvalidSpecifier(`${JSON.stringify(part)} is not a version specifier`);
|
|
273
|
+
}
|
|
274
|
+
const operator = m[1];
|
|
275
|
+
if (!SUPPORTED.has(operator)) {
|
|
276
|
+
throw new InvalidSpecifier(`specifier ${JSON.stringify(part)} uses '${operator}', which this build does ` +
|
|
277
|
+
`not implement (only ${[...SUPPORTED].join(' and ')}). Add it with a corpus ` +
|
|
278
|
+
'row proving it agrees with packaging rather than guessing.');
|
|
279
|
+
}
|
|
280
|
+
this.clauses.push({ operator, version: parseVersion(m[2]) });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/** Whether `candidate` satisfies every clause. An empty set contains everything. */
|
|
284
|
+
contains(candidate) {
|
|
285
|
+
return this.clauses.every((clause) => satisfies(candidate, clause));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
exports.SpecifierSet = SpecifierSet;
|
|
289
|
+
function satisfies(raw, clause) {
|
|
290
|
+
const { operator, version: spec } = clause;
|
|
291
|
+
// A local label is ignored ENTIRELY when matching a specifier, so it is stripped once
|
|
292
|
+
// here rather than at each comparison below.
|
|
293
|
+
const candidate = publicOf(raw);
|
|
294
|
+
if (operator === '>=') {
|
|
295
|
+
// Nothing else is special about `>=`: a pre-release simply sorts below its release,
|
|
296
|
+
// which is why `8.0rc1 >= 8.0.0` is false.
|
|
297
|
+
return compareVersions(candidate, spec) >= 0;
|
|
298
|
+
}
|
|
299
|
+
// operator === '<'. Two conditions, and the second is the one that surprises people.
|
|
300
|
+
if (compareVersions(candidate, spec) >= 0)
|
|
301
|
+
return false;
|
|
302
|
+
// The specifier standard: "<V MUST NOT allow a pre-release of the specified version unless the
|
|
303
|
+
// specified version is itself a pre-release." `8.0rc1` is a pre-release of `8.0.0`,
|
|
304
|
+
// so `<8.0.0` excludes it even though it sorts below.
|
|
305
|
+
if (!spec.isPrerelease && candidate.isPrerelease) {
|
|
306
|
+
if (compareRelease(candidate.release, spec.release) === 0)
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
/** Convenience: does this version string satisfy this specifier string? */
|
|
312
|
+
function matches(version, specifier) {
|
|
313
|
+
return new SpecifierSet(specifier).contains(parseVersion(version));
|
|
314
|
+
}
|
|
315
|
+
/** The highest parseable entry, or null. Unparseable entries are skipped. */
|
|
316
|
+
function highest(tags) {
|
|
317
|
+
let bestRaw = null;
|
|
318
|
+
let bestVer = null;
|
|
319
|
+
for (const tag of tags) {
|
|
320
|
+
let v;
|
|
321
|
+
try {
|
|
322
|
+
v = parseVersion(tag);
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (bestVer === null || compareVersions(v, bestVer) > 0) {
|
|
328
|
+
bestVer = v;
|
|
329
|
+
bestRaw = tag;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return bestRaw;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The oldest parseable entry, or null.
|
|
336
|
+
*
|
|
337
|
+
* Reported beside the chosen one, NEVER chosen: changing which end is taken would
|
|
338
|
+
* repair one class of reproduction and break another.
|
|
339
|
+
*/
|
|
340
|
+
function lowest(tags) {
|
|
341
|
+
let bestRaw = null;
|
|
342
|
+
let bestVer = null;
|
|
343
|
+
for (const tag of tags) {
|
|
344
|
+
let v;
|
|
345
|
+
try {
|
|
346
|
+
v = parseVersion(tag);
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
if (bestVer === null || compareVersions(v, bestVer) < 0) {
|
|
352
|
+
bestVer = v;
|
|
353
|
+
bestRaw = tag;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return bestRaw;
|
|
357
|
+
}
|