@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,463 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a Rocket.Chat version to its MongoDB pairing and runtime knobs.
|
|
4
|
+
*
|
|
5
|
+
* Two tiers:
|
|
6
|
+
*
|
|
7
|
+
* 1. LIVE -- releases.rocket.chat/<version>/info, the authoritative per-release
|
|
8
|
+
* compatibility data (pick the highest supported MongoDB).
|
|
9
|
+
* 2. FALLBACK -- the shipped data/versions.yaml, used when offline or for old
|
|
10
|
+
* releases that lack the field.
|
|
11
|
+
*
|
|
12
|
+
* flavor / shell / oplog are always derived from the RC and MongoDB majors, so there is
|
|
13
|
+
* one rule (the MongoDB tag) to maintain, not four.
|
|
14
|
+
*
|
|
15
|
+
* TWO SHAPES OF THIS MODULE, both deliberate:
|
|
16
|
+
*
|
|
17
|
+
* 1. `resolveOnline` takes its fetcher as an argument and defaults to null. The
|
|
18
|
+
* network is a SEAM, which this module ranks below; it resolves offline in full,
|
|
19
|
+
* and a caller may inject a fetch. The default is therefore
|
|
20
|
+
* "no live lookup available", which takes exactly the same code path as an
|
|
21
|
+
* unreachable endpoint.
|
|
22
|
+
*
|
|
23
|
+
* 2. The map load is a module-level memo, process-wide and invisible, with an explicit
|
|
24
|
+
* reset for tests.
|
|
25
|
+
*/
|
|
26
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
29
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
30
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
31
|
+
}
|
|
32
|
+
Object.defineProperty(o, k2, desc);
|
|
33
|
+
}) : (function(o, m, k, k2) {
|
|
34
|
+
if (k2 === undefined) k2 = k;
|
|
35
|
+
o[k2] = m[k];
|
|
36
|
+
}));
|
|
37
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
38
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
39
|
+
}) : function(o, v) {
|
|
40
|
+
o["default"] = v;
|
|
41
|
+
});
|
|
42
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
43
|
+
var ownKeys = function(o) {
|
|
44
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
45
|
+
var ar = [];
|
|
46
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
47
|
+
return ar;
|
|
48
|
+
};
|
|
49
|
+
return ownKeys(o);
|
|
50
|
+
};
|
|
51
|
+
return function (mod) {
|
|
52
|
+
if (mod && mod.__esModule) return mod;
|
|
53
|
+
var result = {};
|
|
54
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
55
|
+
__setModuleDefault(result, mod);
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.InvalidVersionError = exports.NOT_A_RELEASE = exports.MONGO_TAG_RE = exports.BUILD_SOURCE = exports.BUILD_TAG_RE = exports.BUILD_IMAGE = exports.RELEASES_URL = void 0;
|
|
61
|
+
exports.isBuildTag = isBuildTag;
|
|
62
|
+
exports.buildPackageUrl = buildPackageUrl;
|
|
63
|
+
exports.baseVersion = baseVersion;
|
|
64
|
+
exports.lookupUrl = lookupUrl;
|
|
65
|
+
exports.requireValidMongoTag = requireValidMongoTag;
|
|
66
|
+
exports.resetMapCache = resetMapCache;
|
|
67
|
+
exports.flavor = flavor;
|
|
68
|
+
exports.shell = shell;
|
|
69
|
+
exports.applyMongoOverride = applyMongoOverride;
|
|
70
|
+
exports.seriesTag = seriesTag;
|
|
71
|
+
exports.mongoNote = mongoNote;
|
|
72
|
+
exports.resolveOnline = resolveOnline;
|
|
73
|
+
exports.isValidVersion = isValidVersion;
|
|
74
|
+
exports.resolve = resolve;
|
|
75
|
+
const fs = __importStar(require("fs"));
|
|
76
|
+
const YAML = __importStar(require("yaml"));
|
|
77
|
+
const config_1 = require("./config");
|
|
78
|
+
const format_1 = require("./format");
|
|
79
|
+
const errors_1 = require("./errors");
|
|
80
|
+
const version_spec_1 = require("./version-spec");
|
|
81
|
+
exports.RELEASES_URL = 'https://releases.rocket.chat/{version}/info';
|
|
82
|
+
/** Where Rocket.Chat's CI publishes every `develop` and pull-request build, anonymously. */
|
|
83
|
+
exports.BUILD_IMAGE = 'ghcr.io/rocketchat/rocket.chat';
|
|
84
|
+
/**
|
|
85
|
+
* A CI build's tag: `develop` or `pr-<N>`, then optionally `-fips` or `-cov`, then optionally
|
|
86
|
+
* `-gha-run-<id>` for one run's build rather than the latest. Measured against the 100k+
|
|
87
|
+
* tags ghcr holds (2026-10-08); the per-architecture `-amd64`/`-arm64` tags are left out,
|
|
88
|
+
* because the plain tag is the multi-architecture index.
|
|
89
|
+
*/
|
|
90
|
+
exports.BUILD_TAG_RE = /^(develop|pr-([1-9][0-9]{0,6}))(-(?:fips|cov))?(-gha-run-[0-9]{1,15})?$/;
|
|
91
|
+
/** `Resolved.source` for a CI build. */
|
|
92
|
+
exports.BUILD_SOURCE = 'ci build';
|
|
93
|
+
/** Whether `version` names a CI build rather than a release. */
|
|
94
|
+
function isBuildTag(version) {
|
|
95
|
+
return exports.BUILD_TAG_RE.test(version);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The `package.json` holding a build's version, at the ref it was built from. The image
|
|
99
|
+
* carries no version label of its own (measured: only the build-run URL), so this is the
|
|
100
|
+
* one place the version can be read without pulling 1.6 GB.
|
|
101
|
+
*/
|
|
102
|
+
function buildPackageUrl(tag) {
|
|
103
|
+
const pr = exports.BUILD_TAG_RE.exec(tag)?.[2];
|
|
104
|
+
const ref = pr === undefined ? 'develop' : `refs/pull/${pr}/head`;
|
|
105
|
+
return `https://raw.githubusercontent.com/RocketChat/Rocket.Chat/${ref}/apps/meteor/package.json`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A build's `package.json` version as a version every reader of a record can parse and order:
|
|
109
|
+
* `8.10.0-develop` -> `8.10.0.dev0`, which sorts below 8.10.0, so moving to the release is
|
|
110
|
+
* an upgrade. Anything else is kept as written.
|
|
111
|
+
*/
|
|
112
|
+
function baseVersion(packageVersion) {
|
|
113
|
+
return packageVersion.replace(/-develop$/u, '.dev0');
|
|
114
|
+
}
|
|
115
|
+
/** The URL `resolve` will ask about `version`, or null when nothing should be asked. */
|
|
116
|
+
function lookupUrl(version) {
|
|
117
|
+
if (isBuildTag(version))
|
|
118
|
+
return buildPackageUrl(version);
|
|
119
|
+
if (!isValidVersion(version))
|
|
120
|
+
return null;
|
|
121
|
+
// A `.devN` is a build's version, recorded or restored: no release endpoint knows it.
|
|
122
|
+
if ((0, version_spec_1.parseVersion)(version).dev !== null)
|
|
123
|
+
return null;
|
|
124
|
+
return exports.RELEASES_URL.replace('{version}', version);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The OCI image-tag grammar, and the reason it is enforced rather than assumed.
|
|
128
|
+
*
|
|
129
|
+
* The Kubernetes Mongo manifest is built by interpolation, so a `--mongo` value carrying
|
|
130
|
+
* a NEWLINE was substituted verbatim and the result was VALID YAML that `kubectl apply`
|
|
131
|
+
* accepts -- a tag of
|
|
132
|
+
* "8.0\n securityContext:\n privileged: true\n hostPID: true"
|
|
133
|
+
* rendered a privileged container with host PID. `mongo` is a plain request field and is
|
|
134
|
+
* not privileged, so any member+ GUI account could reach it, bypassing the very control
|
|
135
|
+
* that exists to stop a member choosing what code runs.
|
|
136
|
+
*
|
|
137
|
+
* Refused at the boundary rather than escaped at the template, because there are two
|
|
138
|
+
* templates and one entry point: every caller that can supply a tag comes through
|
|
139
|
+
* `applyMongoOverride`, and a tag that is not an OCI tag cannot name a real image anyway.
|
|
140
|
+
*
|
|
141
|
+
* **The `$` is the whole point of the anchor.** A `$` that also matches just before a
|
|
142
|
+
* TRAILING NEWLINE, as it does in some regex dialects, let `"8.0\n"` satisfy it and the
|
|
143
|
+
* guard let through the one character it exists to refuse; an end-of-string anchor was
|
|
144
|
+
* the fix in earlier releases. JavaScript's `$` without the
|
|
145
|
+
* `m` flag does NOT match before a trailing newline, so the plain anchor is already
|
|
146
|
+
* correct here -- and it is spelled out because "it happens to be right in this
|
|
147
|
+
* language" is exactly the kind of thing that gets refactored away.
|
|
148
|
+
*/
|
|
149
|
+
exports.MONGO_TAG_RE = /^[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$/;
|
|
150
|
+
/** Refuse a `--mongo` value that is not an OCI image tag. See MONGO_TAG_RE. */
|
|
151
|
+
function requireValidMongoTag(tag) {
|
|
152
|
+
if (!exports.MONGO_TAG_RE.test(tag || '')) {
|
|
153
|
+
throw new errors_1.ValidationError(`--mongo ${JSON.stringify(tag)} is not a MongoDB image tag (want something like ` +
|
|
154
|
+
"'8.0' or '7.0.14': letters, digits, '.', '_' and '-', starting with " +
|
|
155
|
+
"a letter, digit or '_')");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
let mapCache = null;
|
|
159
|
+
function loadMap() {
|
|
160
|
+
if (mapCache !== null)
|
|
161
|
+
return mapCache;
|
|
162
|
+
const text = fs.readFileSync((0, config_1.dataPath)('versions.yaml'), 'utf8');
|
|
163
|
+
const data = YAML.parse(text, { uniqueKeys: false });
|
|
164
|
+
if (data === null || !Array.isArray(data.rules)) {
|
|
165
|
+
throw new Error('data/versions.yaml is missing or has no rules');
|
|
166
|
+
}
|
|
167
|
+
mapCache = data;
|
|
168
|
+
return data;
|
|
169
|
+
}
|
|
170
|
+
/** For tests: drop the memoised map. */
|
|
171
|
+
function resetMapCache() {
|
|
172
|
+
mapCache = null;
|
|
173
|
+
}
|
|
174
|
+
function mongoMajor(mongoTag) {
|
|
175
|
+
const head = mongoTag.split('.')[0] ?? '';
|
|
176
|
+
// The major is the integer before the first dot, or 0 when that is not one. `Number("")`
|
|
177
|
+
// is 0 and `Number("x")` is NaN, so both non-numeric shapes have to land on 0 here.
|
|
178
|
+
const n = Number(head);
|
|
179
|
+
return Number.isInteger(n) ? n : 0;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Image flavor keyed on the MONGODB version. Mongo 8+ uses the official multi-arch
|
|
183
|
+
* image; older tags use bitnami-legacy (Bitnami's public images were deprecated and
|
|
184
|
+
* moved to the `bitnamilegacy` namespace).
|
|
185
|
+
*/
|
|
186
|
+
function flavor(mongoTag) {
|
|
187
|
+
return mongoMajor(mongoTag) >= 8 ? 'official' : 'bitnami-legacy';
|
|
188
|
+
}
|
|
189
|
+
function shell(mongoTag) {
|
|
190
|
+
return mongoMajor(mongoTag) >= 5 ? 'mongosh' : 'mongo';
|
|
191
|
+
}
|
|
192
|
+
function oplogFor(rcMajor) {
|
|
193
|
+
return rcMajor < 8;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Apply a manual `--mongo` override, re-deriving flavor + shell from the tag.
|
|
197
|
+
*
|
|
198
|
+
* Validated here because this is the one place a caller-supplied tag enters: both
|
|
199
|
+
* runtimes read `mongoTag` afterwards, and the Kubernetes one templates it into a
|
|
200
|
+
* manifest. See MONGO_TAG_RE.
|
|
201
|
+
*/
|
|
202
|
+
function applyMongoOverride(resolved, mongoTag) {
|
|
203
|
+
requireValidMongoTag(mongoTag);
|
|
204
|
+
resolved.mongoTag = mongoTag;
|
|
205
|
+
resolved.mongoFlavor = flavor(mongoTag);
|
|
206
|
+
resolved.mongoShell = shell(mongoTag);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A `compatibleMongoVersions` entry as a tag the registry actually publishes.
|
|
210
|
+
*
|
|
211
|
+
* releases.rocket.chat is not consistent about the shape of this field. RC 7.12 and
|
|
212
|
+
* below answer ["5.0","6.0","7.0"] and 8.x answers ["8.0"] -- but RC 7.13.x answers
|
|
213
|
+
* ["5","6","7","8"], a bare major. The value was used verbatim as a docker tag, and
|
|
214
|
+
* `mongodb/mongodb-community-server` publishes only <major>.<minor>, so RC 7.13.x
|
|
215
|
+
* resolved to `8-ubi8` and every boot died on "failed to resolve reference ... not
|
|
216
|
+
* found". Checked against the registry: 8-ubi8 and 7-ubi8 are 404; 8.0-ubi8 and 7.0-ubi8
|
|
217
|
+
* are 200.
|
|
218
|
+
*
|
|
219
|
+
* A bare major means the GA series for that major, which is always `.0`. Anything that
|
|
220
|
+
* already carries a minor is left alone, including a three-part tag like 8.0.4.
|
|
221
|
+
*
|
|
222
|
+
* Null for anything that is not a plain numeric version, so the caller falls back to
|
|
223
|
+
* the curated map instead of inventing a tag out of something it cannot read.
|
|
224
|
+
*/
|
|
225
|
+
function seriesTag(value) {
|
|
226
|
+
const parts = value.split('.');
|
|
227
|
+
if (parts.length === 0 || !parts.every((p) => p !== '' && /^[0-9]+$/.test(p)))
|
|
228
|
+
return null;
|
|
229
|
+
return parts.length === 1 ? `${parts[0]}.0` : value;
|
|
230
|
+
}
|
|
231
|
+
/** Why this MongoDB tag, in the words the caller prints. */
|
|
232
|
+
function mongoNote(best, compatible, tag) {
|
|
233
|
+
// WHICH END WAS TAKEN, SAID OUT LOUD. The newest compatible MongoDB is chosen, and
|
|
234
|
+
// for a support reproduction the interesting one is usually the customer's, which for
|
|
235
|
+
// an older Rocket.Chat is usually the OLDEST supported. RC 4.8.7 offers
|
|
236
|
+
// 3.6,4.0,4.2,4.4,5.0: this resolves 5.0 while the shipped versions.yaml rule gives
|
|
237
|
+
// 4.4 -- so `up -v 4.8.7` and `up -v 4.8.7 --offline` pair a different MongoDB MAJOR,
|
|
238
|
+
// and one of them changes whether the oplog path is exercised at all.
|
|
239
|
+
let note = `compatibleMongoVersions=${compatible.join(',')}`;
|
|
240
|
+
if (compatible.length > 1) {
|
|
241
|
+
note +=
|
|
242
|
+
` (took the NEWEST, ${best}; the oldest supported is ` +
|
|
243
|
+
`${(0, version_spec_1.lowest)(compatible) ?? ''} — \`--mongo <tag>\` to pin the customer's)`;
|
|
244
|
+
}
|
|
245
|
+
if (tag !== best) {
|
|
246
|
+
// Said out loud in `houston versions <x>`: the pairing on screen is then
|
|
247
|
+
// explainable, instead of a number that appears nowhere in the API's answer.
|
|
248
|
+
note += ` (bare major ${JSON.stringify(best)} -> ${tag}, the series the registry publishes)`;
|
|
249
|
+
}
|
|
250
|
+
return note;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Set when the release endpoint answered 404 -- i.e. it was reachable and said this
|
|
254
|
+
* version does not exist. Distinct from "could not ask", which is the only thing
|
|
255
|
+
* returning null used to mean.
|
|
256
|
+
*/
|
|
257
|
+
exports.NOT_A_RELEASE = 'not_a_release';
|
|
258
|
+
/**
|
|
259
|
+
* Query releases.rocket.chat. Returns null on any problem (the caller falls back).
|
|
260
|
+
*
|
|
261
|
+
* `why` collects WHY, because the caller has been unable to tell the difference. A 404
|
|
262
|
+
* from a reachable endpoint means the version was never released; anything else means
|
|
263
|
+
* the lookup failed. Both returned null, so `houston versions 99.99.99` fell through to
|
|
264
|
+
* the curated map, found a rule matching the series, and exited 0 with a confident
|
|
265
|
+
* pairing for a release that does not exist -- as did `8.5.1-rc.1`.
|
|
266
|
+
*/
|
|
267
|
+
function resolveOnline(version, rcMajor, fetcher, why) {
|
|
268
|
+
let resp;
|
|
269
|
+
try {
|
|
270
|
+
resp = fetcher(exports.RELEASES_URL.replace('{version}', version));
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
if (resp === null)
|
|
276
|
+
return null;
|
|
277
|
+
if (resp.status === 404 && why !== undefined)
|
|
278
|
+
why.push(exports.NOT_A_RELEASE);
|
|
279
|
+
if (resp.status !== 200)
|
|
280
|
+
return null;
|
|
281
|
+
let payload;
|
|
282
|
+
try {
|
|
283
|
+
payload = resp.json();
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const compatibleRaw = payload !== null && typeof payload === 'object'
|
|
289
|
+
? payload.compatibleMongoVersions
|
|
290
|
+
: undefined;
|
|
291
|
+
const compatible = Array.isArray(compatibleRaw) ? compatibleRaw.map(String) : [];
|
|
292
|
+
const best = (0, version_spec_1.highest)(compatible);
|
|
293
|
+
if (best === null)
|
|
294
|
+
return null; // old releases omit the field
|
|
295
|
+
// The API's answer is not necessarily a tag. Returning null here rather than guessing
|
|
296
|
+
// means the curated map decides, which is the better answer when the live value
|
|
297
|
+
// cannot be read at all.
|
|
298
|
+
const tag = seriesTag(best);
|
|
299
|
+
if (tag === null)
|
|
300
|
+
return null;
|
|
301
|
+
return {
|
|
302
|
+
rcVersion: version,
|
|
303
|
+
rcImage: '', // filled in by resolve()
|
|
304
|
+
mongoTag: tag,
|
|
305
|
+
mongoFlavor: flavor(tag),
|
|
306
|
+
mongoShell: shell(tag),
|
|
307
|
+
oplog: oplogFor(rcMajor),
|
|
308
|
+
source: 'releases.rocket.chat',
|
|
309
|
+
note: mongoNote(best, compatible, tag),
|
|
310
|
+
supports: compatible.map((entry) => seriesTag(entry)).filter((entry) => entry !== null),
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* The refusal `resolve` raises for an unusable version string, or one no rule can match.
|
|
315
|
+
* A class of its own, so a caller can catch exactly this without also swallowing the
|
|
316
|
+
* other errors that pass through.
|
|
317
|
+
*/
|
|
318
|
+
class InvalidVersionError extends Error {
|
|
319
|
+
}
|
|
320
|
+
exports.InvalidVersionError = InvalidVersionError;
|
|
321
|
+
/**
|
|
322
|
+
* Whether `resolve` would accept `version` at all -- the check it makes FIRST.
|
|
323
|
+
*
|
|
324
|
+
* Every caller has to fetch the release info before calling `resolve`, because `resolve` is
|
|
325
|
+
* synchronous and HTTP is not. The version must be parsed before anything goes online, so
|
|
326
|
+
* an unusable string never reaches the network; the callers here once fetched
|
|
327
|
+
* first, and an invalid version sent `https://releases.rocket.chat/<whatever was typed>/info`
|
|
328
|
+
* over the wire before being refused. A caller asks this, and skips the fetch, so the
|
|
329
|
+
* refusal `resolve` then raises is unchanged and nothing is asked on the way to it.
|
|
330
|
+
*/
|
|
331
|
+
function isValidVersion(version) {
|
|
332
|
+
try {
|
|
333
|
+
(0, version_spec_1.parseVersion)(version);
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/** The shipped rule for a release, or undefined. */
|
|
341
|
+
function ruleFor(data, version) {
|
|
342
|
+
return data.rules.find((rule) => new version_spec_1.SpecifierSet(rule.rc).contains(version));
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A CI build: its version from the branch's `package.json`, its MongoDB from the shipped rule
|
|
346
|
+
* for that version's RELEASE (a `.dev0` sorts below every rule's floor), its image the build.
|
|
347
|
+
*/
|
|
348
|
+
function resolveBuild(tag, options) {
|
|
349
|
+
const url = buildPackageUrl(tag);
|
|
350
|
+
// `up`'s own flags, said as such: `versions` and `upgrade` reach this too, and neither has
|
|
351
|
+
// `--rc-image`, so "Or name the image yourself: --rc-image ..." named a flag they refuse.
|
|
352
|
+
const hatch = `\`up\` can name the image itself instead: --rc-image ${exports.BUILD_IMAGE}:${tag} --version <its x.y.z>.`;
|
|
353
|
+
if (options.offline === true || options.fetcher === undefined) {
|
|
354
|
+
throw new InvalidVersionError(`${(0, format_1.quotedText)(tag)} is a CI build, and its version is read from ${url}, which needs ` +
|
|
355
|
+
`the network. ${hatch}`);
|
|
356
|
+
}
|
|
357
|
+
let resp;
|
|
358
|
+
try {
|
|
359
|
+
resp = options.fetcher(url);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
resp = null;
|
|
363
|
+
}
|
|
364
|
+
let packageVersion = '';
|
|
365
|
+
if (resp !== null && resp.status === 200) {
|
|
366
|
+
try {
|
|
367
|
+
const body = resp.json();
|
|
368
|
+
if (body !== null && typeof body === 'object') {
|
|
369
|
+
packageVersion = String(body.version ?? '');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
packageVersion = '';
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const rcVersion = baseVersion(packageVersion);
|
|
377
|
+
let parsed;
|
|
378
|
+
try {
|
|
379
|
+
parsed = (0, version_spec_1.parseVersion)(rcVersion);
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
parsed = null;
|
|
383
|
+
}
|
|
384
|
+
if (parsed === null) {
|
|
385
|
+
const said = resp === null ? 'did not answer' : `answered ${String(resp.status)}`;
|
|
386
|
+
throw new InvalidVersionError(`no CI build ${(0, format_1.quotedText)(tag)}: ${url} ${resp?.status === 200 ? 'held no readable version' : said}. ${hatch}`);
|
|
387
|
+
}
|
|
388
|
+
const rule = ruleFor(loadMap(), (0, version_spec_1.parseVersion)(parsed.release.join('.')));
|
|
389
|
+
if (rule === undefined) {
|
|
390
|
+
throw new InvalidVersionError(`no rule matches RC ${rcVersion}, the version of CI build ${tag}`);
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
rcVersion,
|
|
394
|
+
rcImage: `${exports.BUILD_IMAGE}:${tag}`,
|
|
395
|
+
mongoTag: rule.mongo,
|
|
396
|
+
mongoFlavor: flavor(rule.mongo),
|
|
397
|
+
mongoShell: shell(rule.mongo),
|
|
398
|
+
oplog: oplogFor(parsed.release[0] ?? 0),
|
|
399
|
+
source: exports.BUILD_SOURCE,
|
|
400
|
+
note: `CI build ${tag}: ${url} says ${packageVersion}`,
|
|
401
|
+
supports: rule.supports ?? [rule.mongo],
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
/** Resolve `version` to a full MongoDB pairing. */
|
|
405
|
+
function resolve(version, options = {}) {
|
|
406
|
+
if (isBuildTag(version))
|
|
407
|
+
return resolveBuild(version, options);
|
|
408
|
+
let rcMajor;
|
|
409
|
+
try {
|
|
410
|
+
rcMajor = (0, version_spec_1.parseVersion)(version).release[0] ?? 0;
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
// `quotedText`, not `JSON.stringify`: the established message quotes the version in single
|
|
414
|
+
// quotes, and `upgrade.plan` surfaces this sentence to whoever typed `--to`.
|
|
415
|
+
throw new InvalidVersionError(`${(0, format_1.quotedText)(version)} is not a valid version (want e.g. 6.5.3)`);
|
|
416
|
+
}
|
|
417
|
+
const data = loadMap();
|
|
418
|
+
const rcImage = data.default_rc_image ?? 'registry.rocket.chat/rocketchat/rocket.chat';
|
|
419
|
+
const why = [];
|
|
420
|
+
if (options.offline !== true && options.fetcher !== undefined) {
|
|
421
|
+
const online = resolveOnline(version, rcMajor, options.fetcher, why);
|
|
422
|
+
if (online !== null) {
|
|
423
|
+
online.rcImage = rcImage;
|
|
424
|
+
return online;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// A build's `.devN` (a restored or re-upped CI build) pairs as its release does; every
|
|
428
|
+
// rule's floor excludes a dev release, so it would otherwise match nothing.
|
|
429
|
+
const parsed = (0, version_spec_1.parseVersion)(version);
|
|
430
|
+
const candidate = parsed.dev !== null && parsed.pre === null ? (0, version_spec_1.parseVersion)(parsed.release.join('.')) : parsed;
|
|
431
|
+
for (const rule of data.rules) {
|
|
432
|
+
if (new version_spec_1.SpecifierSet(rule.rc).contains(candidate)) {
|
|
433
|
+
let note = rule.note ?? '';
|
|
434
|
+
if (why.includes(exports.NOT_A_RELEASE)) {
|
|
435
|
+
// SAID, rather than resolved silently. The pairing below is a rule for the
|
|
436
|
+
// SERIES and is the best guess available -- but the endpoint was reachable and
|
|
437
|
+
// answered 404, which is positive evidence that this version was never
|
|
438
|
+
// published, and a caller that gets a clean answer for a typo will spend the
|
|
439
|
+
// next ten minutes on a failing image pull.
|
|
440
|
+
note =
|
|
441
|
+
`releases.rocket.chat has no ${version} — it may be a typo, ` +
|
|
442
|
+
'unreleased, or a pre-release tag. The pairing below comes ' +
|
|
443
|
+
'from the series rule, not from that release.' +
|
|
444
|
+
(note ? ` ${note}` : '');
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
rcVersion: version,
|
|
448
|
+
rcImage,
|
|
449
|
+
mongoTag: rule.mongo,
|
|
450
|
+
mongoFlavor: flavor(rule.mongo),
|
|
451
|
+
mongoShell: shell(rule.mongo),
|
|
452
|
+
oplog: oplogFor(rcMajor),
|
|
453
|
+
source: why.includes(exports.NOT_A_RELEASE) ? 'map (no such release)' : 'map (fallback)',
|
|
454
|
+
note,
|
|
455
|
+
supports: rule.supports ?? [rule.mongo],
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// `8.0rc1` lands here and it is SUPPOSED TO. A pre-release sorts below its release so
|
|
460
|
+
// it fails `>=8.0.0`, and the specifier standard forbids `<8.0.0` from admitting a pre-release of
|
|
461
|
+
// 8.0.0 -- so no rule matches. See `version-spec.ts`; this is behaviour, not a gap.
|
|
462
|
+
throw new InvalidVersionError(`no rule matches RC ${version} and the live lookup was unavailable`);
|
|
463
|
+
}
|