@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,492 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PROCESS_CONSOLE = void 0;
|
|
37
|
+
exports.characterCells = characterCells;
|
|
38
|
+
exports.cellLen = cellLen;
|
|
39
|
+
exports.wrap = wrap;
|
|
40
|
+
exports.printed = printed;
|
|
41
|
+
exports.errorPanel = errorPanel;
|
|
42
|
+
exports.consoleWidth = consoleWidth;
|
|
43
|
+
exports.consoleColumns = consoleColumns;
|
|
44
|
+
exports.formatterColumns = formatterColumns;
|
|
45
|
+
/**
|
|
46
|
+
* What a usage error is drawn with: the console's width, word wrapping in terminal cells,
|
|
47
|
+
* and the rounded `Error` panel.
|
|
48
|
+
*
|
|
49
|
+
* The frozen CLI reports a usage error as one block: the Usage line, a
|
|
50
|
+
* `Try '<command> --help' for help.` line, then the message inside a panel as wide as the
|
|
51
|
+
* console. The owner's decision is that the TypeScript CLI prints those bytes exactly as
|
|
52
|
+
* earlier releases did, uncoloured -- so the width, the wrap and the point where a message
|
|
53
|
+
* is cut are the established ones. Every function here reproduces one step of that
|
|
54
|
+
* rendering exactly; nothing is a lookalike.
|
|
55
|
+
*
|
|
56
|
+
* LEFT OUT, on purpose: colour and styles (the owner chose uncoloured output; on a terminal
|
|
57
|
+
* the established output also carries SGR codes and this does not), legacy Windows consoles,
|
|
58
|
+
* Jupyter, the ASCII box substituted on a non-UTF-8 stream, and the `UNICODE_VERSION`
|
|
59
|
+
* override -- the width table is the latest one, which is what applies when that is unset.
|
|
60
|
+
*/
|
|
61
|
+
const tty = __importStar(require("node:tty"));
|
|
62
|
+
const format_1 = require("../lib/format");
|
|
63
|
+
const cell_widths_1 = require("./cell-widths");
|
|
64
|
+
// ---------------------------------------------------------------------------- cells
|
|
65
|
+
/** Characters known to be one cell wide without a table lookup. */
|
|
66
|
+
const SINGLE_CELL_RANGES = [
|
|
67
|
+
[0x20, 0x7e],
|
|
68
|
+
[0xa0, 0xac],
|
|
69
|
+
[0xae, 0x2ff],
|
|
70
|
+
[0x370, 0x482],
|
|
71
|
+
[0x2500, 0x25fc],
|
|
72
|
+
[0x2800, 0x28ff],
|
|
73
|
+
];
|
|
74
|
+
const ZWJ = 0x200d;
|
|
75
|
+
const VS16 = 0xfe0f;
|
|
76
|
+
function codes(text) {
|
|
77
|
+
return Array.from(text, (ch) => ch.codePointAt(0));
|
|
78
|
+
}
|
|
79
|
+
function fromCodes(points) {
|
|
80
|
+
return String.fromCodePoint(...points);
|
|
81
|
+
}
|
|
82
|
+
function isSingleCell(point) {
|
|
83
|
+
return SINGLE_CELL_RANGES.some(([start, end]) => point >= start && point <= end);
|
|
84
|
+
}
|
|
85
|
+
/** A code point's width: 0, 1 or 2 cells. */
|
|
86
|
+
function characterCells(point) {
|
|
87
|
+
if ((point && point < 32) || (point >= 0x7f && point < 0xa0))
|
|
88
|
+
return 0;
|
|
89
|
+
const last = cell_widths_1.CELL_WIDTHS[cell_widths_1.CELL_WIDTHS.length - 1];
|
|
90
|
+
if (point > last[1])
|
|
91
|
+
return 1;
|
|
92
|
+
let lower = 0;
|
|
93
|
+
let upper = cell_widths_1.CELL_WIDTHS.length - 1;
|
|
94
|
+
while (lower <= upper) {
|
|
95
|
+
const index = (lower + upper) >> 1;
|
|
96
|
+
const [start, end, width] = cell_widths_1.CELL_WIDTHS[index];
|
|
97
|
+
if (point < start)
|
|
98
|
+
upper = index - 1;
|
|
99
|
+
else if (point > end)
|
|
100
|
+
lower = index + 1;
|
|
101
|
+
else
|
|
102
|
+
return width;
|
|
103
|
+
}
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
/** The cells `text` occupies, zero-width joiners and VS16 included. */
|
|
107
|
+
function cellLen(text) {
|
|
108
|
+
return cellLenOf(codes(text));
|
|
109
|
+
}
|
|
110
|
+
function cellLenOf(points) {
|
|
111
|
+
if (points.every(isSingleCell))
|
|
112
|
+
return points.length;
|
|
113
|
+
if (!points.includes(ZWJ) && !points.includes(VS16)) {
|
|
114
|
+
return points.reduce((sum, point) => sum + characterCells(point), 0);
|
|
115
|
+
}
|
|
116
|
+
let total = 0;
|
|
117
|
+
let last = null;
|
|
118
|
+
for (let index = 0; index < points.length; index += 1) {
|
|
119
|
+
const point = points[index];
|
|
120
|
+
if (point === ZWJ) {
|
|
121
|
+
// The joiner AND the character it joins are skipped: the count advances twice here.
|
|
122
|
+
index += 1;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (point === VS16) {
|
|
126
|
+
if (last !== null) {
|
|
127
|
+
total += cell_widths_1.NARROW_TO_WIDE.has(last) ? 1 : 0;
|
|
128
|
+
last = null;
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const width = characterCells(point);
|
|
133
|
+
if (width) {
|
|
134
|
+
last = point;
|
|
135
|
+
total += width;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return total;
|
|
139
|
+
}
|
|
140
|
+
/** One span per grapheme, covering every code point. */
|
|
141
|
+
function splitGraphemes(points) {
|
|
142
|
+
const spans = [];
|
|
143
|
+
let index = 0;
|
|
144
|
+
let last = null;
|
|
145
|
+
while (index < points.length) {
|
|
146
|
+
const point = points[index];
|
|
147
|
+
if (point === ZWJ || point === VS16) {
|
|
148
|
+
if (spans.length === 0) {
|
|
149
|
+
spans.push([index, index + 1, 0]);
|
|
150
|
+
index += 1;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const previous = spans[spans.length - 1];
|
|
154
|
+
if (point === ZWJ) {
|
|
155
|
+
index += index < points.length - 1 ? 2 : 1;
|
|
156
|
+
spans[spans.length - 1] = [previous[0], index, previous[2]];
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
index += 1;
|
|
160
|
+
let cells = previous[2];
|
|
161
|
+
if (last !== null && cell_widths_1.NARROW_TO_WIDE.has(last)) {
|
|
162
|
+
last = null;
|
|
163
|
+
cells += 1;
|
|
164
|
+
}
|
|
165
|
+
spans[spans.length - 1] = [previous[0], index, cells];
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const width = characterCells(point);
|
|
170
|
+
if (width) {
|
|
171
|
+
last = point;
|
|
172
|
+
spans.push([index, index + 1, width]);
|
|
173
|
+
}
|
|
174
|
+
else if (spans.length > 0) {
|
|
175
|
+
const previous = spans[spans.length - 1];
|
|
176
|
+
spans[spans.length - 1] = [previous[0], index + 1, previous[2]];
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
spans.push([index, index + 1, 0]);
|
|
180
|
+
}
|
|
181
|
+
index += 1;
|
|
182
|
+
}
|
|
183
|
+
return spans;
|
|
184
|
+
}
|
|
185
|
+
/** `text` in pieces of at most `width` cells. */
|
|
186
|
+
function chopCells(points, width) {
|
|
187
|
+
// The established rendering fails outright on a zero width; a console that narrow draws
|
|
188
|
+
// nothing useful either way, and this must not loop.
|
|
189
|
+
if (width < 1)
|
|
190
|
+
return [[...points]];
|
|
191
|
+
if (points.every(isSingleCell)) {
|
|
192
|
+
const out = [];
|
|
193
|
+
for (let at = 0; at < points.length; at += width)
|
|
194
|
+
out.push(points.slice(at, at + width));
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
const lines = [];
|
|
198
|
+
let size = 0;
|
|
199
|
+
let offset = 0;
|
|
200
|
+
for (const [start, , cells] of splitGraphemes(points)) {
|
|
201
|
+
if (size + cells > width) {
|
|
202
|
+
lines.push(points.slice(offset, start));
|
|
203
|
+
offset = start;
|
|
204
|
+
size = 0;
|
|
205
|
+
}
|
|
206
|
+
size += cells;
|
|
207
|
+
}
|
|
208
|
+
if (size)
|
|
209
|
+
lines.push(points.slice(offset));
|
|
210
|
+
return lines;
|
|
211
|
+
}
|
|
212
|
+
/** A crop: the longest prefix within `total` cells. */
|
|
213
|
+
function cropCells(points, total) {
|
|
214
|
+
if (points.every(isSingleCell))
|
|
215
|
+
return points.slice(0, total);
|
|
216
|
+
if (total <= 0)
|
|
217
|
+
return [];
|
|
218
|
+
const out = [];
|
|
219
|
+
let size = 0;
|
|
220
|
+
for (const [start, end, cells] of splitGraphemes(points)) {
|
|
221
|
+
if (size + cells > total) {
|
|
222
|
+
// A double-width character cut in half becomes a space.
|
|
223
|
+
if (size < total)
|
|
224
|
+
out.push(0x20);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
out.push(...points.slice(start, end));
|
|
228
|
+
size += cells;
|
|
229
|
+
}
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
// -------------------------------------------------------------------------- wrapping
|
|
233
|
+
/**
|
|
234
|
+
* What the wrap treats as whitespace: TAB through CR, the separators 0x1C-0x1F, space, NEL,
|
|
235
|
+
* and every Unicode space, line and paragraph separator.
|
|
236
|
+
*/
|
|
237
|
+
const SPACE_CHARS = new Set([
|
|
238
|
+
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x85, 0xa0, 0x1680, 0x2000, 0x2001,
|
|
239
|
+
0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x2028, 0x2029, 0x202f,
|
|
240
|
+
0x205f, 0x3000,
|
|
241
|
+
]);
|
|
242
|
+
/** A line's words: `\s*\S+\s*` matched repeatedly from the start, `\s` being `SPACE_CHARS`. */
|
|
243
|
+
function words(points) {
|
|
244
|
+
const out = [];
|
|
245
|
+
let at = 0;
|
|
246
|
+
while (at < points.length) {
|
|
247
|
+
const start = at;
|
|
248
|
+
while (at < points.length && SPACE_CHARS.has(points[at]))
|
|
249
|
+
at += 1;
|
|
250
|
+
if (at === points.length)
|
|
251
|
+
break;
|
|
252
|
+
while (at < points.length && !SPACE_CHARS.has(points[at]))
|
|
253
|
+
at += 1;
|
|
254
|
+
while (at < points.length && SPACE_CHARS.has(points[at]))
|
|
255
|
+
at += 1;
|
|
256
|
+
out.push([start, points.slice(start, at)]);
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
function rstripped(points) {
|
|
261
|
+
let end = points.length;
|
|
262
|
+
while (end > 0 && SPACE_CHARS.has(points[end - 1]))
|
|
263
|
+
end -= 1;
|
|
264
|
+
return points.slice(0, end);
|
|
265
|
+
}
|
|
266
|
+
/** The code point offsets to break `text` at, a word wider than `width` folded. */
|
|
267
|
+
function divideLine(points, width) {
|
|
268
|
+
const breaks = [];
|
|
269
|
+
let offset = 0;
|
|
270
|
+
for (const [begin, word] of words(points)) {
|
|
271
|
+
let start = begin;
|
|
272
|
+
const wordLength = cellLenOf(rstripped(word));
|
|
273
|
+
const remaining = width - offset;
|
|
274
|
+
if (remaining >= wordLength) {
|
|
275
|
+
offset += cellLenOf(word);
|
|
276
|
+
}
|
|
277
|
+
else if (wordLength > width) {
|
|
278
|
+
const folded = chopCells(word, width);
|
|
279
|
+
folded.forEach((line, index) => {
|
|
280
|
+
if (start)
|
|
281
|
+
breaks.push(start);
|
|
282
|
+
if (index === folded.length - 1)
|
|
283
|
+
offset = cellLenOf(line);
|
|
284
|
+
else
|
|
285
|
+
start += line.length;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
else if (offset && start) {
|
|
289
|
+
breaks.push(start);
|
|
290
|
+
offset = cellLenOf(word);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return breaks;
|
|
294
|
+
}
|
|
295
|
+
/** BEL, BS, VT, FF and CR, which are removed from the text on the way in. */
|
|
296
|
+
const STRIPPED = new Set([0x07, 0x08, 0x0b, 0x0c, 0x0d]);
|
|
297
|
+
function stripControlCodes(text) {
|
|
298
|
+
return Array.from(text)
|
|
299
|
+
.filter((ch) => !STRIPPED.has(ch.codePointAt(0)))
|
|
300
|
+
.join('');
|
|
301
|
+
}
|
|
302
|
+
/** Tabs expanded at 8: each tab to a space, then out to the next multiple of eight. */
|
|
303
|
+
function expandTabs(points) {
|
|
304
|
+
if (!points.includes(0x09))
|
|
305
|
+
return [...points];
|
|
306
|
+
const out = [];
|
|
307
|
+
let part = [];
|
|
308
|
+
let position = 0;
|
|
309
|
+
for (const point of points) {
|
|
310
|
+
part.push(point);
|
|
311
|
+
if (point === 0x09) {
|
|
312
|
+
part[part.length - 1] = 0x20;
|
|
313
|
+
position += cellLenOf(part);
|
|
314
|
+
const remainder = position % 8;
|
|
315
|
+
if (remainder) {
|
|
316
|
+
for (let pad = 0; pad < 8 - remainder; pad += 1)
|
|
317
|
+
part.push(0x20);
|
|
318
|
+
position += 8 - remainder;
|
|
319
|
+
}
|
|
320
|
+
out.push(...part);
|
|
321
|
+
part = [];
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
out.push(...part);
|
|
325
|
+
return out;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* `text` wrapped at `width` -- no justification, a word wider than the line folded -- as
|
|
329
|
+
* its lines. A line may end in a space: whitespace a break leaves at the end of a line is
|
|
330
|
+
* kept unless the line is longer than `width`.
|
|
331
|
+
*/
|
|
332
|
+
function wrap(text, width) {
|
|
333
|
+
const out = [];
|
|
334
|
+
for (const raw of stripControlCodes(text).split('\n')) {
|
|
335
|
+
const points = expandTabs(codes(raw));
|
|
336
|
+
const offsets = divideLine(points, width);
|
|
337
|
+
const bounds = [0, ...offsets, points.length];
|
|
338
|
+
for (let at = 0; at < bounds.length - 1; at += 1) {
|
|
339
|
+
let line = points.slice(bounds[at], bounds[at + 1]);
|
|
340
|
+
if (line.length > width) {
|
|
341
|
+
const trailing = line.length - rstripped(line).length;
|
|
342
|
+
line = line.slice(0, line.length - Math.min(trailing, line.length - width));
|
|
343
|
+
}
|
|
344
|
+
if (cellLenOf(line) > width)
|
|
345
|
+
line = cropCells(line, width);
|
|
346
|
+
out.push(fromCodes(line));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
/** `text` printed at `width`: each wrapped line and a newline. */
|
|
352
|
+
function printed(text, width) {
|
|
353
|
+
return wrap(text, width)
|
|
354
|
+
.map((line) => `${line}\n`)
|
|
355
|
+
.join('');
|
|
356
|
+
}
|
|
357
|
+
/** A line padded with spaces, or cropped, to exactly `width` cells. */
|
|
358
|
+
function fitCells(line, width) {
|
|
359
|
+
const points = codes(line);
|
|
360
|
+
const size = cellLenOf(points);
|
|
361
|
+
if (size > width)
|
|
362
|
+
return fromCodes(cropCells(points, width));
|
|
363
|
+
return line + ' '.repeat(width - size);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The boxed error panel printed at `width`: the ROUNDED box, the `Error` title on the left
|
|
367
|
+
* and padded by one space each side, the message wrapped inside one space of padding on
|
|
368
|
+
* each side.
|
|
369
|
+
*/
|
|
370
|
+
function errorPanel(message, width) {
|
|
371
|
+
const title = ' Error ';
|
|
372
|
+
const inner = width - 2;
|
|
373
|
+
let top;
|
|
374
|
+
if (width <= 4)
|
|
375
|
+
top = `╭${'─'.repeat(Math.max(0, inner))}╮`;
|
|
376
|
+
else {
|
|
377
|
+
// The title left-aligned in `width - 4`: cropped to the room, then rule.
|
|
378
|
+
const room = width - 4;
|
|
379
|
+
const shown = cellLen(title) > room ? fromCodes(cropCells(codes(title), room)) : title;
|
|
380
|
+
top = `╭─${shown}${'─'.repeat(room - cellLen(shown))}─╮`;
|
|
381
|
+
}
|
|
382
|
+
const body = wrap(message, Math.max(0, inner - 2)).map((line) => `│ ${fitCells(line, Math.max(0, inner - 2))} │`);
|
|
383
|
+
return `${[top, ...body, `╰${'─'.repeat(Math.max(0, inner))}╯`].join('\n')}\n`;
|
|
384
|
+
}
|
|
385
|
+
function terminalColumns(fd) {
|
|
386
|
+
if (!tty.isatty(fd))
|
|
387
|
+
return null;
|
|
388
|
+
if (fd === 1 && process.stdout.isTTY)
|
|
389
|
+
return process.stdout.columns;
|
|
390
|
+
if (fd === 2 && process.stderr.isTTY)
|
|
391
|
+
return process.stderr.columns;
|
|
392
|
+
// Nothing in Node sizes a terminal on stdin, so a write stream is opened on it just long
|
|
393
|
+
// enough to ask. This only runs on the way out of a usage error.
|
|
394
|
+
try {
|
|
395
|
+
const stream = new tty.WriteStream(fd);
|
|
396
|
+
const columns = stream.columns;
|
|
397
|
+
stream.destroy();
|
|
398
|
+
return columns;
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
exports.PROCESS_CONSOLE = {
|
|
405
|
+
env: process.env,
|
|
406
|
+
isatty: (fd) => tty.isatty(fd),
|
|
407
|
+
columns: terminalColumns,
|
|
408
|
+
};
|
|
409
|
+
const DIGITS = /^[0-9]+$/u;
|
|
410
|
+
/** Whether stderr counts as a terminal, the environment's overrides decided first. */
|
|
411
|
+
function isTerminal(host) {
|
|
412
|
+
const env = host.env;
|
|
413
|
+
if (env._TYPER_FORCE_DISABLE_TERMINAL)
|
|
414
|
+
return false;
|
|
415
|
+
if (env.GITHUB_ACTIONS || env.FORCE_COLOR || env.PY_COLORS)
|
|
416
|
+
return true;
|
|
417
|
+
if (env.TTY_COMPATIBLE === '0')
|
|
418
|
+
return false;
|
|
419
|
+
if (env.TTY_COMPATIBLE === '1')
|
|
420
|
+
return true;
|
|
421
|
+
if (env.FORCE_COLOR !== undefined)
|
|
422
|
+
return env.FORCE_COLOR !== '';
|
|
423
|
+
return host.isatty(2);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* The width a usage error is drawn at, on stderr.
|
|
427
|
+
*
|
|
428
|
+
* `TERMINAL_WIDTH`, else `COLUMNS`, fixes it -- but only wins outright together with
|
|
429
|
+
* `LINES`; otherwise a dumb terminal is 80 first. Without either, the size of the first of
|
|
430
|
+
* stdin, stdout and stderr that is a terminal, and 80 when none is. The terminal size is
|
|
431
|
+
* read from STDIN first, so `houston up --bogus 2>err.txt` at a terminal is as wide as that
|
|
432
|
+
* terminal.
|
|
433
|
+
*/
|
|
434
|
+
function consoleWidth(host = exports.PROCESS_CONSOLE) {
|
|
435
|
+
const env = host.env;
|
|
436
|
+
const terminalWidth = env.TERMINAL_WIDTH;
|
|
437
|
+
let fixed = null;
|
|
438
|
+
if (terminalWidth)
|
|
439
|
+
fixed = strictInt(terminalWidth);
|
|
440
|
+
else if (env.COLUMNS !== undefined && DIGITS.test(env.COLUMNS))
|
|
441
|
+
fixed = Number(env.COLUMNS);
|
|
442
|
+
const lines = env.LINES !== undefined && DIGITS.test(env.LINES) ? Number(env.LINES) : null;
|
|
443
|
+
if (fixed !== null && lines !== null)
|
|
444
|
+
return fixed;
|
|
445
|
+
const term = (env.TERM ?? '').toLowerCase();
|
|
446
|
+
if (isTerminal(host) && (term === 'dumb' || term === 'unknown'))
|
|
447
|
+
return 80;
|
|
448
|
+
if (fixed !== null)
|
|
449
|
+
return fixed;
|
|
450
|
+
let width = null;
|
|
451
|
+
for (const fd of [0, 1, 2]) {
|
|
452
|
+
width = host.isatty(fd) ? host.columns(fd) : null;
|
|
453
|
+
if (width !== null)
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
if (env.COLUMNS !== undefined && DIGITS.test(env.COLUMNS))
|
|
457
|
+
width = Number(env.COLUMNS);
|
|
458
|
+
return width || 80;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* The terminal's columns: `COLUMNS` when `toInt` reads a positive number from it, else
|
|
462
|
+
* STDOUT's terminal, else `fallback`.
|
|
463
|
+
*
|
|
464
|
+
* `toInt`, not `parseInt`: `COLUMNS=100abc` is no width, so the terminal is asked, while
|
|
465
|
+
* `parseInt` reads 100; `COLUMNS=' 60 '` and `6_0` are 60, and so are `٦٠` and `60`, since
|
|
466
|
+
* any Unicode decimal digit reads as its ASCII value -- which `toInt` first did not, drawing
|
|
467
|
+
* an 84-column `houston presets` box where earlier releases drew a 56-column one. A
|
|
468
|
+
* terminal that answers 0 columns is the fallback.
|
|
469
|
+
*/
|
|
470
|
+
function consoleColumns(fallback, host = exports.PROCESS_CONSOLE) {
|
|
471
|
+
const columns = host.env.COLUMNS === undefined ? null : strictInt(host.env.COLUMNS);
|
|
472
|
+
if (columns !== null && columns > 0)
|
|
473
|
+
return columns;
|
|
474
|
+
const stdout = host.isatty(1) ? host.columns(1) : null;
|
|
475
|
+
return stdout || fallback;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* The columns the help formatter sizes the Usage line by: `COLUMNS` when it is a positive
|
|
479
|
+
* integer, else STDOUT's terminal, else 80.
|
|
480
|
+
*/
|
|
481
|
+
function formatterColumns(host = exports.PROCESS_CONSOLE) {
|
|
482
|
+
return consoleColumns(80, host);
|
|
483
|
+
}
|
|
484
|
+
/** `toInt(text)`, or null where it throws. */
|
|
485
|
+
function strictInt(text) {
|
|
486
|
+
try {
|
|
487
|
+
return (0, format_1.toInt)(text);
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.cliActorAndOrigin = cliActorAndOrigin;
|
|
37
|
+
/**
|
|
38
|
+
* Who is running the CLI, and how confident the answer is.
|
|
39
|
+
*
|
|
40
|
+
* An earlier version had no equivalent at all: the web layer sets the acting user per
|
|
41
|
+
* request, and nothing set it for the CLI. So with accounts present, two people running
|
|
42
|
+
* `houston up -v 8.5.1` derived the SAME workspace name -- the exact data-loss bug per-user
|
|
43
|
+
* naming exists to prevent -- every owner gate compared an empty actor, `down --volumes`
|
|
44
|
+
* could not say whose data it was about to delete, and every audit line read `-`.
|
|
45
|
+
*
|
|
46
|
+
* The origin is the audit log's evidence column:
|
|
47
|
+
* local the OS login matched a known account -- the OS said so;
|
|
48
|
+
* asserted HOUSTON_USER was set, honoured even for an unknown name -- a claim;
|
|
49
|
+
* system no accounts (team mode is opt-in, from the first `users add`), or no match.
|
|
50
|
+
*/
|
|
51
|
+
const config = __importStar(require("../../lib/config"));
|
|
52
|
+
const login_name_1 = require("../../lib/login-name");
|
|
53
|
+
const float_text_1 = require("../../lib/float-text");
|
|
54
|
+
/**
|
|
55
|
+
* The login name (`getlogin`), falling back to `$USER` where there is none (cron, a
|
|
56
|
+
* container).
|
|
57
|
+
*
|
|
58
|
+
* An earlier version read `os.userInfo()` -- the EFFECTIVE uid's name, with `$USER` only for a
|
|
59
|
+
* uid the password database lacks. Under `sudo -u vbob` that named the target account where
|
|
60
|
+
* the established actor is the person who logged in, so a member ran an admin's chown; and
|
|
61
|
+
* in a container or under cron, where there is no login uid, it named `root` or a service
|
|
62
|
+
* account -- no account here, so an empty actor, which the owner gates allow -- where the
|
|
63
|
+
* established actor is `$USER`.
|
|
64
|
+
*/
|
|
65
|
+
function loginName() {
|
|
66
|
+
return (0, login_name_1.getlogin)() ?? process.env.USER ?? '';
|
|
67
|
+
}
|
|
68
|
+
function cliActorAndOrigin() {
|
|
69
|
+
const users = require('../../core/users');
|
|
70
|
+
if (!users.anyUsers())
|
|
71
|
+
return ['', 'system'];
|
|
72
|
+
const known = new Set(users.listUsers().map((user) => user.name));
|
|
73
|
+
// `stripText`, which is not `trim()`: it strips \x1c-\x1f and NEL and keeps a BOM, so
|
|
74
|
+
// HOUSTON_USER=$'\x1falice' is alice to it and was a stranger here -- refused a chown
|
|
75
|
+
// alice may make -- while $'\ufeffalice' was alice here and a stranger there. Every gate,
|
|
76
|
+
// audit line and event-log actor the CLI writes starts from this.
|
|
77
|
+
const named = (0, float_text_1.stripText)(config.env('HOUSTON_USER')).toLowerCase();
|
|
78
|
+
// Explicit: honoured even if unknown, so the mismatch shows up in `list` rather than
|
|
79
|
+
// silently falling back to the shared namespace.
|
|
80
|
+
if (named !== '')
|
|
81
|
+
return [named, 'asserted'];
|
|
82
|
+
const login = (0, float_text_1.stripText)(loginName()).toLowerCase();
|
|
83
|
+
return known.has(login) ? [login, 'local'] : ['', 'system'];
|
|
84
|
+
}
|