@multiplatform.one/utils 5.0.27 → 6.0.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/lib/dev.cjs +22622 -84
- package/lib/dev.mjs +22604 -0
- package/lib/index.cjs +4 -3
- package/lib/index.mjs +5 -0
- package/package.json +44 -36
- package/src/dev.ts +10 -37
- package/src/index.ts +0 -21
- package/src/wait.spec.ts +35 -0
- package/src/wait.ts +29 -47
- package/types/.tsbuildinfo +1 -1
- package/types/dev.d.ts.map +1 -1
- package/types/index.d.ts +0 -20
- package/types/index.d.ts.map +1 -1
- package/types/wait.d.ts +2 -2
- package/types/wait.d.ts.map +1 -1
- package/types/wait.spec.d.ts +2 -0
- package/types/wait.spec.d.ts.map +1 -0
- package/lib/chunk-55ZF3CTQ.cjs +0 -84
- package/lib/chunk-QMKU5DBF.js +0 -84
- package/lib/dev.js +0 -102
- package/lib/index.js +0 -5
- package/lib/meshConfig.cjs +0 -98
- package/lib/meshConfig.js +0 -98
- package/lib/wait.cjs +0 -16
- package/lib/wait.js +0 -16
- package/src/meshConfig.ts +0 -130
- package/types/meshConfig.d.ts +0 -86
- package/types/meshConfig.d.ts.map +0 -1
package/lib/index.cjs
CHANGED
package/lib/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "utilities for multiplatform.one",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"multiplatform.one",
|
|
7
|
+
"utils"
|
|
8
|
+
],
|
|
8
9
|
"homepage": "https://multiplatform.one",
|
|
9
10
|
"bugs": {
|
|
10
11
|
"url": "https://gitlab.com/bitspur/multiplatform.one/multiplatform.one/issues",
|
|
@@ -12,51 +13,58 @@
|
|
|
12
13
|
},
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"author": "BitSpur <support@risserlabs.com> (https://risserlabs.com)",
|
|
15
|
-
"main": "lib/index.cjs",
|
|
16
|
-
"module": "lib/index.js",
|
|
17
|
-
"source": "src/index.ts",
|
|
18
|
-
"types": "types/index.d.ts",
|
|
19
|
-
"scripts": {
|
|
20
|
-
"typecheck": "tsc --noEmit",
|
|
21
|
-
"build": "rm -rf lib types 2>/dev/null && tsc -b --emitDeclarationOnly && tsup",
|
|
22
|
-
"test": "vitest run --coverage --coverage.provider=v8 --coverage.reporter=text --coverage.reporter=lcov --coverage.reporter=html"
|
|
23
|
-
},
|
|
24
|
-
"files": ["bin", "lib", "types", "src"],
|
|
25
16
|
"repository": {
|
|
26
17
|
"type": "git",
|
|
27
18
|
"url": "https://gitlab.com/bitspur/multiplatform.one/multiplatform.one"
|
|
28
19
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"pg": "^8.13.1",
|
|
42
|
-
"yaml": "^2.7.0"
|
|
43
|
-
},
|
|
20
|
+
"source": "src/index.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"lib",
|
|
24
|
+
"types",
|
|
25
|
+
"src"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"main": "lib/index.cjs",
|
|
30
|
+
"module": "lib/index.js",
|
|
31
|
+
"types": "types/index.d.ts",
|
|
44
32
|
"exports": {
|
|
45
33
|
".": {
|
|
34
|
+
"source": "./src/index.ts",
|
|
46
35
|
"types": "./types/index.d.ts",
|
|
47
36
|
"import": "./lib/index.js",
|
|
48
37
|
"require": "./lib/index.cjs"
|
|
49
38
|
},
|
|
50
39
|
"./dev": {
|
|
40
|
+
"source": "./src/dev.ts",
|
|
51
41
|
"types": "./types/dev.d.ts",
|
|
52
|
-
"import": "./lib/dev.
|
|
42
|
+
"import": "./lib/dev.mjs",
|
|
53
43
|
"require": "./lib/dev.cjs"
|
|
54
44
|
},
|
|
55
|
-
"./meshConfig": {
|
|
56
|
-
"types": "./types/meshConfig.d.ts",
|
|
57
|
-
"import": "./lib/meshConfig.js",
|
|
58
|
-
"require": "./lib/meshConfig.cjs"
|
|
59
|
-
},
|
|
60
45
|
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"axios": "^1.15.2",
|
|
52
|
+
"pg": "^8.20.0",
|
|
53
|
+
"yaml": "^2.8.3"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^25.6.0",
|
|
57
|
+
"@types/pg": "^8.20.0",
|
|
58
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
59
|
+
"typescript": "~5.9.3",
|
|
60
|
+
"vitest": "^4.1.5"
|
|
61
|
+
},
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": ">=6.0.0"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"build": "rm -rf lib types 2>/dev/null && tsc -b --emitDeclarationOnly && tsdown",
|
|
68
|
+
"test": "vitest run --coverage --coverage.provider=v8 --coverage.reporter=text --coverage.reporter=lcov --coverage.reporter=html"
|
|
61
69
|
}
|
|
62
|
-
}
|
|
70
|
+
}
|
package/src/dev.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* File: /src/dev.ts
|
|
3
|
-
* Project: @multiplatform.one/utils
|
|
4
|
-
* File Created: 17-01-2025 23:30:37
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* BitSpur (c) Copyright 2021 - 2025
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License.
|
|
11
|
-
* You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
1
|
import { spawnSync } from "node:child_process";
|
|
23
2
|
import fs from "node:fs";
|
|
24
3
|
import path from "node:path";
|
|
@@ -44,16 +23,14 @@ export function lookupTranspileModules(
|
|
|
44
23
|
...new Set([
|
|
45
24
|
projectRoot,
|
|
46
25
|
path.resolve(projectRoot, "app"),
|
|
47
|
-
path.resolve(projectRoot, "
|
|
26
|
+
path.resolve(projectRoot, "features"),
|
|
48
27
|
...(packageDirs || []),
|
|
49
28
|
]),
|
|
50
29
|
].map((packageDir) => {
|
|
30
|
+
const pkgPath = path.join(packageDir, "package.json");
|
|
31
|
+
if (!fs.existsSync(pkgPath)) return [];
|
|
51
32
|
try {
|
|
52
|
-
return (
|
|
53
|
-
JSON.parse(
|
|
54
|
-
fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"),
|
|
55
|
-
).transpileModules || []
|
|
56
|
-
);
|
|
33
|
+
return JSON.parse(fs.readFileSync(pkgPath, "utf-8")).transpileModules || [];
|
|
57
34
|
} catch (err) {
|
|
58
35
|
if (log) logger.error(err);
|
|
59
36
|
return [];
|
|
@@ -77,16 +54,14 @@ export function lookupTamaguiModules(
|
|
|
77
54
|
...new Set([
|
|
78
55
|
projectRoot,
|
|
79
56
|
path.resolve(projectRoot, "app"),
|
|
80
|
-
path.resolve(projectRoot, "
|
|
57
|
+
path.resolve(projectRoot, "features"),
|
|
81
58
|
...(packageDirs || []),
|
|
82
59
|
]),
|
|
83
60
|
].map((packageDir) => {
|
|
61
|
+
const pkgPath = path.join(packageDir, "package.json");
|
|
62
|
+
if (!fs.existsSync(pkgPath)) return [];
|
|
84
63
|
try {
|
|
85
|
-
return (
|
|
86
|
-
JSON.parse(
|
|
87
|
-
fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"),
|
|
88
|
-
).tamaguiModules || []
|
|
89
|
-
);
|
|
64
|
+
return JSON.parse(fs.readFileSync(pkgPath, "utf-8")).tamaguiModules || [];
|
|
90
65
|
} catch (err) {
|
|
91
66
|
if (log) logger.error(err);
|
|
92
67
|
return [];
|
|
@@ -98,9 +73,7 @@ export function lookupTamaguiModules(
|
|
|
98
73
|
return tamaguiModules;
|
|
99
74
|
}
|
|
100
75
|
|
|
101
|
-
export function resolveConfig(
|
|
102
|
-
keys: string[] = [],
|
|
103
|
-
): Record<string, string | undefined> {
|
|
76
|
+
export function resolveConfig(keys: string[] = []): Record<string, string | undefined> {
|
|
104
77
|
return keys.reduce(
|
|
105
78
|
(acc: Record<string, string | undefined>, key: string) => {
|
|
106
79
|
if (process.env[key]) acc[key] = process.env[key];
|
|
@@ -119,7 +92,7 @@ export function lookupProjectRoot() {
|
|
|
119
92
|
});
|
|
120
93
|
_projectRoot = stdout.trim();
|
|
121
94
|
return _projectRoot;
|
|
122
|
-
} catch
|
|
95
|
+
} catch {
|
|
123
96
|
_projectRoot = process.cwd();
|
|
124
97
|
return _projectRoot;
|
|
125
98
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File: /src/index.ts
|
|
3
|
-
* Project: @multiplatform.one/utils
|
|
4
|
-
* File Created: 19-11-2024 20:26:31
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* BitSpur (c) Copyright 2021 - 2024
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License.
|
|
11
|
-
* You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
1
|
export default {};
|
package/src/wait.spec.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { formatServiceList, waitServices } from "./wait";
|
|
3
|
+
|
|
4
|
+
describe("formatServiceList", () => {
|
|
5
|
+
it("returns single service as-is", () => {
|
|
6
|
+
expect(formatServiceList(["frappe"])).toBe("frappe");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("joins two services with 'and'", () => {
|
|
10
|
+
expect(formatServiceList(["frappe", "postgres"])).toBe("frappe and postgres");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("joins three services with commas and 'and'", () => {
|
|
14
|
+
expect(formatServiceList(["frappe", "postgres", "keycloak"])).toBe(
|
|
15
|
+
"frappe, postgres and keycloak",
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("joins four services correctly", () => {
|
|
20
|
+
expect(formatServiceList(["a", "b", "c", "d"])).toBe("a, b, c and d");
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("waitServices", () => {
|
|
25
|
+
it("contains the expected service names", () => {
|
|
26
|
+
expect(waitServices).toContain("frappe");
|
|
27
|
+
expect(waitServices).toContain("postgres");
|
|
28
|
+
expect(waitServices).toContain("mariadb");
|
|
29
|
+
expect(waitServices).toContain("keycloak");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("has exactly 4 services", () => {
|
|
33
|
+
expect(waitServices).toHaveLength(4);
|
|
34
|
+
});
|
|
35
|
+
});
|
package/src/wait.ts
CHANGED
|
@@ -1,49 +1,15 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* File: /src/wait.ts
|
|
3
|
-
* Project: @multiplatform.one/utils
|
|
4
|
-
* File Created: 18-01-2025 18:38:49
|
|
5
|
-
* Author: Clay Risser
|
|
6
|
-
* -----
|
|
7
|
-
* BitSpur (c) Copyright 2021 - 2025
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License.
|
|
11
|
-
* You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
1
|
import axios from "axios";
|
|
23
2
|
import pg from "pg";
|
|
24
3
|
|
|
25
|
-
export async function waitForApi(interval: number) {
|
|
26
|
-
try {
|
|
27
|
-
const res = await axios.get(
|
|
28
|
-
`http://localhost:${process.env.API_PORT || "5001"}/healthz`,
|
|
29
|
-
);
|
|
30
|
-
if ((res?.status || 500) < 300) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
} catch (err) {}
|
|
34
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
35
|
-
return waitForApi(interval);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
4
|
export async function waitForFrappe(interval: number) {
|
|
39
5
|
try {
|
|
40
6
|
const res = await axios.get(
|
|
41
|
-
`${process.env.
|
|
7
|
+
`${process.env.BASE_URL || "http://frappe.localhost"}/api/method/ping`,
|
|
42
8
|
);
|
|
43
9
|
if ((res?.status || 500) < 300) {
|
|
44
10
|
return;
|
|
45
11
|
}
|
|
46
|
-
} catch
|
|
12
|
+
} catch {}
|
|
47
13
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
48
14
|
return waitForFrappe(interval);
|
|
49
15
|
}
|
|
@@ -62,7 +28,7 @@ export async function waitForPostgres(interval: number) {
|
|
|
62
28
|
try {
|
|
63
29
|
await client.query("SELECT 1");
|
|
64
30
|
return;
|
|
65
|
-
} catch
|
|
31
|
+
} catch {}
|
|
66
32
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
67
33
|
}
|
|
68
34
|
} finally {
|
|
@@ -70,15 +36,36 @@ export async function waitForPostgres(interval: number) {
|
|
|
70
36
|
}
|
|
71
37
|
}
|
|
72
38
|
|
|
39
|
+
export async function waitForMariaDB(interval: number) {
|
|
40
|
+
const mysql = require("mysql2/promise");
|
|
41
|
+
const connection = await mysql.createConnection({
|
|
42
|
+
host: process.env.MARIADB_HOSTNAME || "localhost",
|
|
43
|
+
port: Number.parseInt(process.env.MARIADB_PORT || "3306"),
|
|
44
|
+
user: process.env.MARIADB_USERNAME || "root",
|
|
45
|
+
password: process.env.MARIADB_PASSWORD || "root",
|
|
46
|
+
database: process.env.MARIADB_DATABASE || "frappe",
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
while (true) {
|
|
50
|
+
try {
|
|
51
|
+
await connection.execute("SELECT 1");
|
|
52
|
+
return;
|
|
53
|
+
} catch {}
|
|
54
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
55
|
+
}
|
|
56
|
+
} finally {
|
|
57
|
+
await connection.end();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
73
61
|
export async function waitForKeycloak(interval: number) {
|
|
62
|
+
const baseUrl = process.env.BASE_URL || "http://localhost:8000";
|
|
74
63
|
try {
|
|
75
|
-
const res = await axios.get(
|
|
76
|
-
`${process.env.KEYCLOAK_BASE_URL || "http://localhost:8080"}/realms/master/.well-known/openid-configuration`,
|
|
77
|
-
);
|
|
64
|
+
const res = await axios.get(`${baseUrl}/auth/realms/master/.well-known/openid-configuration`);
|
|
78
65
|
if ((res?.status || 500) < 300) {
|
|
79
66
|
return;
|
|
80
67
|
}
|
|
81
|
-
} catch
|
|
68
|
+
} catch {}
|
|
82
69
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
83
70
|
return waitForKeycloak(interval);
|
|
84
71
|
}
|
|
@@ -89,11 +76,6 @@ export function formatServiceList(services: readonly string[]): string {
|
|
|
89
76
|
return `${services.slice(0, -1).join(", ")} and ${services[services.length - 1]}`;
|
|
90
77
|
}
|
|
91
78
|
|
|
92
|
-
export const waitServices = [
|
|
93
|
-
"graphql",
|
|
94
|
-
"frappe",
|
|
95
|
-
"postgres",
|
|
96
|
-
"keycloak",
|
|
97
|
-
] as const;
|
|
79
|
+
export const waitServices = ["frappe", "postgres", "mariadb", "keycloak"] as const;
|
|
98
80
|
|
|
99
81
|
export type WaitService = (typeof waitServices)[number];
|