@qodalis/cli 2.1.0 → 2.1.1
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/assets/cli-panel.css +28 -0
- package/package.json +2 -2
- package/public-api.d.mts +7 -1
- package/public-api.d.ts +7 -1
- package/public-api.js +67 -7
- package/public-api.js.map +1 -1
- package/public-api.mjs +67 -7
- package/public-api.mjs.map +1 -1
package/public-api.mjs
CHANGED
|
@@ -518,7 +518,7 @@ var CliKeyValueStore_TOKEN = createCliToken("cli-key-value-store");
|
|
|
518
518
|
var SyntaxHighlighterRegistry_TOKEN = createCliToken("syntax-highlighter-registry");
|
|
519
519
|
|
|
520
520
|
// src/lib/version.ts
|
|
521
|
-
var LIBRARY_VERSION = "2.1.
|
|
521
|
+
var LIBRARY_VERSION = "2.1.1";
|
|
522
522
|
var API_VERSION = 2;
|
|
523
523
|
var ANONYMOUS = "\0anonymous";
|
|
524
524
|
function aliasOwner(context2) {
|
|
@@ -5397,6 +5397,7 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
5397
5397
|
this._eventServiceRegistered = false;
|
|
5398
5398
|
this._healthCheckTimer = null;
|
|
5399
5399
|
this._healthCheckAttempts = 0;
|
|
5400
|
+
this._needsSignIn = false;
|
|
5400
5401
|
}
|
|
5401
5402
|
static {
|
|
5402
5403
|
this.WS_MAX_RECONNECT_ATTEMPTS = 5;
|
|
@@ -5413,6 +5414,13 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
5413
5414
|
get config() {
|
|
5414
5415
|
return this._config;
|
|
5415
5416
|
}
|
|
5417
|
+
/**
|
|
5418
|
+
* The last connect was refused for want of a sign-in (401 or 403 on the
|
|
5419
|
+
* command list): the server is up, and a sign-in reconnects it.
|
|
5420
|
+
*/
|
|
5421
|
+
get needsSignIn() {
|
|
5422
|
+
return this._needsSignIn;
|
|
5423
|
+
}
|
|
5416
5424
|
get connected() {
|
|
5417
5425
|
return this._connected;
|
|
5418
5426
|
}
|
|
@@ -5452,6 +5460,7 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
5452
5460
|
});
|
|
5453
5461
|
}
|
|
5454
5462
|
async connect() {
|
|
5463
|
+
this._needsSignIn = false;
|
|
5455
5464
|
try {
|
|
5456
5465
|
const baseUrl = this.normalizeUrl(this._config.url);
|
|
5457
5466
|
const negotiated = await ServerVersionNegotiator.discover(
|
|
@@ -5534,6 +5543,7 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
5534
5543
|
const url = `${this._basePath}/commands`;
|
|
5535
5544
|
const response = await this.httpFetch(url);
|
|
5536
5545
|
if (!response.ok) {
|
|
5546
|
+
if (response.status === 401 || response.status === 403) this._needsSignIn = true;
|
|
5537
5547
|
throw new Error(
|
|
5538
5548
|
`Server ${this._config.name} returned ${response.status}`
|
|
5539
5549
|
);
|
|
@@ -6224,6 +6234,10 @@ var CliServerManager = class {
|
|
|
6224
6234
|
);
|
|
6225
6235
|
this.registerProxyProcessors(connection, config.name);
|
|
6226
6236
|
this.emitConnected(connection, false);
|
|
6237
|
+
} else if (connection.needsSignIn) {
|
|
6238
|
+
logger?.info(
|
|
6239
|
+
`Server '${config.name}' needs a sign-in; its commands load once you are signed in.`
|
|
6240
|
+
);
|
|
6227
6241
|
} else {
|
|
6228
6242
|
logger?.warn(
|
|
6229
6243
|
`Could not connect to server '${config.name}' at ${config.url}. Commands from this server will not be available.`
|
|
@@ -19293,8 +19307,9 @@ var welcomeModule = {
|
|
|
19293
19307
|
);
|
|
19294
19308
|
await configureStore.initialize();
|
|
19295
19309
|
const state = configureStore.getState();
|
|
19296
|
-
|
|
19297
|
-
|
|
19310
|
+
const stored = state?.["system"]?.["welcomeMessage"];
|
|
19311
|
+
if (stored && stored !== "always") {
|
|
19312
|
+
showOption = stored;
|
|
19298
19313
|
}
|
|
19299
19314
|
}
|
|
19300
19315
|
if (showOption) {
|
|
@@ -19307,10 +19322,11 @@ var welcomeModule = {
|
|
|
19307
19322
|
context2.terminal.writeln(config.message);
|
|
19308
19323
|
} else {
|
|
19309
19324
|
const branding = resolveCliBranding(context2.options?.branding);
|
|
19325
|
+
const art = branding.art(context2.terminal.cols);
|
|
19310
19326
|
const lines = [
|
|
19311
19327
|
`\u{1F680} Welcome to ${branding.name} [Version ${context2.writer.wrapInColor(LIBRARY_VERSION, CliForegroundColor.Green)}]`,
|
|
19312
19328
|
`(c) ${(/* @__PURE__ */ new Date()).getFullYear()} Qodalis Solutions. All rights reserved.`,
|
|
19313
|
-
|
|
19329
|
+
art,
|
|
19314
19330
|
"",
|
|
19315
19331
|
`\u{1F4D6} ${context2.writer.wrapInColor("Documentation:", CliForegroundColor.Green)} https://cli.qodalis.com/docs/`,
|
|
19316
19332
|
"",
|
|
@@ -19318,7 +19334,10 @@ var welcomeModule = {
|
|
|
19318
19334
|
""
|
|
19319
19335
|
];
|
|
19320
19336
|
lines.forEach((line2) => {
|
|
19321
|
-
context2.terminal.
|
|
19337
|
+
const wrapped = line2 === art ? [line2] : wrapWelcomeLine(line2, context2.terminal.cols);
|
|
19338
|
+
wrapped.forEach(
|
|
19339
|
+
(part) => context2.terminal.write(part + "\r\n")
|
|
19340
|
+
);
|
|
19322
19341
|
});
|
|
19323
19342
|
}
|
|
19324
19343
|
recordWelcomeMessageDisplay();
|
|
@@ -19350,12 +19369,51 @@ var greetingModule = {
|
|
|
19350
19369
|
if (host.typedDuringBoot || host.isReadingInput || context2.currentLine) {
|
|
19351
19370
|
return;
|
|
19352
19371
|
}
|
|
19353
|
-
|
|
19372
|
+
const buffer = context2.terminal.buffer?.active;
|
|
19373
|
+
const room = context2.terminal.cols - (buffer?.cursorX ?? 0) - 1;
|
|
19374
|
+
const greeting = fitGreeting(getGreetingBasedOnTime(), room);
|
|
19375
|
+
if (!greeting) return;
|
|
19376
|
+
await context2.textAnimator?.showText(greeting, {
|
|
19354
19377
|
speed: 60,
|
|
19355
19378
|
removeAfterTyping: true
|
|
19356
19379
|
});
|
|
19357
19380
|
}
|
|
19358
19381
|
};
|
|
19382
|
+
function fitGreeting(text, room) {
|
|
19383
|
+
const width = (value) => Array.from(value).reduce(
|
|
19384
|
+
(sum, ch) => sum + (ch.codePointAt(0) > 65535 || /\p{Extended_Pictographic}/u.test(ch) ? 2 : ch === "\uFE0F" ? 0 : 1),
|
|
19385
|
+
0
|
|
19386
|
+
);
|
|
19387
|
+
if (width(text) <= room) return text;
|
|
19388
|
+
const words = text.split(" ");
|
|
19389
|
+
let fitted = "";
|
|
19390
|
+
for (const word of words) {
|
|
19391
|
+
const next = fitted ? `${fitted} ${word}` : word;
|
|
19392
|
+
if (width(next) > room) break;
|
|
19393
|
+
fitted = next;
|
|
19394
|
+
}
|
|
19395
|
+
return fitted.split(" ").length >= 3 ? fitted.replace(/[,;:]$/, "") : null;
|
|
19396
|
+
}
|
|
19397
|
+
function wrapWelcomeLine(line2, cols) {
|
|
19398
|
+
const width = Math.max(20, cols - 1);
|
|
19399
|
+
const visible = (value) => Array.from(value.replace(/\x1b\[[0-9;]*m/g, "")).reduce(
|
|
19400
|
+
(sum, ch) => sum + (ch.codePointAt(0) > 65535 ? 2 : ch === "\uFE0F" ? 0 : 1),
|
|
19401
|
+
0
|
|
19402
|
+
);
|
|
19403
|
+
if (visible(line2) <= width) return [line2];
|
|
19404
|
+
const lines = [];
|
|
19405
|
+
let current = "";
|
|
19406
|
+
for (const word of line2.split(" ")) {
|
|
19407
|
+
if (current && visible(current) + 1 + visible(word) > width) {
|
|
19408
|
+
lines.push(current);
|
|
19409
|
+
current = word;
|
|
19410
|
+
} else {
|
|
19411
|
+
current = current ? `${current} ${word}` : word;
|
|
19412
|
+
}
|
|
19413
|
+
}
|
|
19414
|
+
if (current) lines.push(current);
|
|
19415
|
+
return lines;
|
|
19416
|
+
}
|
|
19359
19417
|
function shouldDisplayWelcomeMessage(showOption) {
|
|
19360
19418
|
const lastDisplayed = localStorage.getItem(
|
|
19361
19419
|
"cliWelcomeMessageLastDisplayed"
|
|
@@ -24087,7 +24145,9 @@ var CliPanelController = class {
|
|
|
24087
24145
|
unhide() {
|
|
24088
24146
|
if (!this.snapshot.hidden) return;
|
|
24089
24147
|
this.updateHidden(false);
|
|
24090
|
-
|
|
24148
|
+
const collapsed = this.snapshot.initialized ? this.preHideCollapsed : false;
|
|
24149
|
+
if (this.snapshot.collapsed !== collapsed) this.updateCollapsed(collapsed);
|
|
24150
|
+
if (!collapsed) this.ensureInitialized();
|
|
24091
24151
|
}
|
|
24092
24152
|
toggleHide() {
|
|
24093
24153
|
if (this.snapshot.hidden) this.unhide();
|