@qelos/plugins-cli 0.0.12 → 0.0.13
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/package.json +1 -1
- package/services/configurations.mjs +20 -0
- package/services/sdk.mjs +27 -21
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { logger } from './logger.mjs';
|
|
4
|
+
import { appUrl } from './sdk.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Push configurations from local directory to remote
|
|
@@ -38,6 +39,25 @@ export async function pushConfigurations(sdk, path) {
|
|
|
38
39
|
|
|
39
40
|
logger.step(`Pushing configuration: ${key}`);
|
|
40
41
|
|
|
42
|
+
// Special handling for app-configuration: ensure QELOS_URL hostname is in websiteUrls
|
|
43
|
+
if (key === 'app-configuration') {
|
|
44
|
+
try {
|
|
45
|
+
const qelosUrl = new URL(appUrl);
|
|
46
|
+
const hostname = qelosUrl.hostname;
|
|
47
|
+
|
|
48
|
+
if (!configData.metadata.websiteUrls) {
|
|
49
|
+
configData.metadata.websiteUrls = [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!configData.metadata.websiteUrls.includes(hostname)) {
|
|
53
|
+
configData.metadata.websiteUrls.push(hostname);
|
|
54
|
+
logger.info(`Added ${hostname} to websiteUrls`);
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
logger.warning(`Failed to parse QELOS_URL: ${error.message}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
const existingConfig = existingConfigurations.find(
|
|
42
62
|
config => config.key === key
|
|
43
63
|
);
|
package/services/sdk.mjs
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
import { createJiti } from
|
|
2
|
-
import { logger } from
|
|
1
|
+
import { createJiti } from "jiti";
|
|
2
|
+
import { logger } from "./logger.mjs";
|
|
3
3
|
|
|
4
4
|
const jiti = createJiti(import.meta.url);
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
const appUrl = process.env.QELOS_URL || "http://localhost:3000";
|
|
8
|
-
const username = process.env.QELOS_USERNAME || 'test@test.com';
|
|
9
|
-
const password = process.env.QELOS_PASSWORD || 'admin';
|
|
6
|
+
export const appUrl = process.env.QELOS_URL || "http://localhost:3000";
|
|
10
7
|
|
|
8
|
+
export async function initializeSdk() {
|
|
9
|
+
const username = process.env.QELOS_USERNAME || "test@test.com";
|
|
10
|
+
const password = process.env.QELOS_PASSWORD || "admin";
|
|
11
11
|
try {
|
|
12
|
-
logger.debug(
|
|
13
|
-
|
|
12
|
+
logger.debug("Initializing Qelos SDK...");
|
|
13
|
+
|
|
14
14
|
if (process.env.VERBOSE) {
|
|
15
15
|
logger.showConfig({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
QELOS_URL: appUrl,
|
|
17
|
+
QELOS_USERNAME: username,
|
|
18
|
+
QELOS_PASSWORD: password,
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const QelosAdministratorSDK = await jiti(
|
|
22
|
+
const QelosAdministratorSDK = await jiti(
|
|
23
|
+
"@qelos/sdk/src/administrator/index.ts"
|
|
24
|
+
);
|
|
23
25
|
|
|
24
26
|
const sdk = new QelosAdministratorSDK.default({
|
|
25
27
|
appUrl,
|
|
@@ -32,24 +34,28 @@ export async function initializeSdk() {
|
|
|
32
34
|
password,
|
|
33
35
|
});
|
|
34
36
|
|
|
35
|
-
logger.debug(
|
|
37
|
+
logger.debug("Authentication successful");
|
|
36
38
|
return sdk;
|
|
37
|
-
|
|
38
39
|
} catch (error) {
|
|
39
40
|
// Handle connection errors
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (
|
|
42
|
+
error.cause?.code === "UND_ERR_CONNECT_TIMEOUT" ||
|
|
43
|
+
error.cause?.code === "ENOTFOUND" ||
|
|
44
|
+
error.cause?.code === "ECONNREFUSED" ||
|
|
45
|
+
error.message?.includes("fetch failed")
|
|
46
|
+
) {
|
|
44
47
|
logger.connectionError(appUrl, error.cause || error);
|
|
45
|
-
}
|
|
48
|
+
}
|
|
46
49
|
// Handle authentication errors
|
|
47
|
-
else if (
|
|
50
|
+
else if (
|
|
51
|
+
error.response?.status === 401 ||
|
|
52
|
+
error.message?.includes("authentication")
|
|
53
|
+
) {
|
|
48
54
|
logger.authError(username, appUrl);
|
|
49
55
|
}
|
|
50
56
|
// Handle other errors
|
|
51
57
|
else {
|
|
52
|
-
logger.error(
|
|
58
|
+
logger.error("Failed to initialize SDK", error);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
process.exit(1);
|