@mittwald/cli 1.2.5 → 1.2.6
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/dist/lib/resources/app/flags.js +1 -1
- package/dist/lib/resources/database/common.js +1 -1
- package/dist/lib/resources/login/useOwnAccount.d.ts +18 -5
- package/dist/lib/resources/login/useOwnAccount.js +1 -1
- package/dist/lib/resources/ssh/appinstall.js +1 -1
- package/dist/lib/resources/ssh/project.js +1 -1
- package/dist/lib/units/Duration.test.d.ts +1 -0
- package/dist/lib/units/Duration.test.js +59 -0
- package/package.json +2 -2
|
@@ -159,7 +159,7 @@ export function provideSupportedFlags(requestedFlagNames, appName) {
|
|
|
159
159
|
return flagsToReturn;
|
|
160
160
|
}
|
|
161
161
|
export async function autofillFlags(apiClient, process, necessaryFlags, flags, projectId, appName, defaults) {
|
|
162
|
-
const ownUser = await apiClient.user.
|
|
162
|
+
const ownUser = await apiClient.user.getUser({ userId: "self" });
|
|
163
163
|
assertStatus(ownUser, 200);
|
|
164
164
|
// Version
|
|
165
165
|
if (necessaryFlags.includes("version") && !flags.version) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assertStatus } from "@mittwald/api-client-commons";
|
|
2
2
|
export async function getUser(apiClient, p) {
|
|
3
3
|
return await p.runStep("fetching user", async () => {
|
|
4
|
-
const r = await apiClient.user.
|
|
4
|
+
const r = await apiClient.user.getUser({ userId: "self" });
|
|
5
5
|
assertStatus(r, 200);
|
|
6
6
|
return r.data;
|
|
7
7
|
});
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { MittwaldAPIV2Client } from "@mittwald/api-client";
|
|
2
2
|
export default function useOwnAccount(client: MittwaldAPIV2Client): {
|
|
3
|
+
avatarRef?: string | undefined;
|
|
4
|
+
customerMemberships?: {
|
|
5
|
+
[k: string]: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.UserCustomerMembership;
|
|
6
|
+
} | undefined;
|
|
3
7
|
email?: string | undefined;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
employeeInformation?: {
|
|
9
|
+
department: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
isEmployee?: boolean | undefined;
|
|
12
|
+
mfa?: {
|
|
13
|
+
active: boolean;
|
|
14
|
+
setup: boolean;
|
|
7
15
|
} | undefined;
|
|
8
16
|
passwordUpdatedAt?: string | undefined;
|
|
9
|
-
person
|
|
10
|
-
|
|
17
|
+
person: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.CommonsPerson;
|
|
18
|
+
phoneNumber?: string | undefined;
|
|
19
|
+
projectMemberships?: {
|
|
20
|
+
[k: string]: import("@mittwald/api-client").MittwaldAPIV2.Components.Schemas.UserProjectMembership;
|
|
21
|
+
} | undefined;
|
|
22
|
+
registeredAt?: string | undefined;
|
|
23
|
+
userId: string;
|
|
11
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assertStatus } from "@mittwald/api-client";
|
|
2
2
|
import { usePromise } from "@mittwald/react-use-promise";
|
|
3
3
|
export default function useOwnAccount(client) {
|
|
4
|
-
const result = usePromise(() => client.user.
|
|
4
|
+
const result = usePromise(() => client.user.getUser({ userId: "self" }), []);
|
|
5
5
|
assertStatus(result, 200);
|
|
6
6
|
return result.data;
|
|
7
7
|
}
|
|
@@ -13,7 +13,7 @@ export async function getSSHConnectionForAppInstallation(client, appInstallation
|
|
|
13
13
|
});
|
|
14
14
|
assertStatus(projectResponse, 200);
|
|
15
15
|
if (sshUser === undefined) {
|
|
16
|
-
const userResponse = await client.user.
|
|
16
|
+
const userResponse = await client.user.getUser({ userId: "self" });
|
|
17
17
|
assertStatus(userResponse, 200);
|
|
18
18
|
sshUser = userResponse.data.email;
|
|
19
19
|
}
|
|
@@ -3,7 +3,7 @@ export async function getSSHConnectionForProject(client, projectId, sshUser) {
|
|
|
3
3
|
const projectResponse = await client.project.getProject({ projectId });
|
|
4
4
|
assertStatus(projectResponse, 200);
|
|
5
5
|
if (sshUser === undefined) {
|
|
6
|
-
const userResponse = await client.user.
|
|
6
|
+
const userResponse = await client.user.getUser({ userId: "self" });
|
|
7
7
|
assertStatus(userResponse, 200);
|
|
8
8
|
sshUser = userResponse.data.email;
|
|
9
9
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import Duration from "./Duration.js";
|
|
3
|
+
describe("Duration class", () => {
|
|
4
|
+
describe("Static factory methods", () => {
|
|
5
|
+
test("fromZero should return a Duration of 0 milliseconds", () => {
|
|
6
|
+
const duration = Duration.fromZero();
|
|
7
|
+
expect(duration.milliseconds).toBe(0);
|
|
8
|
+
});
|
|
9
|
+
test("fromMilliseconds should return a Duration with the given milliseconds", () => {
|
|
10
|
+
const duration = Duration.fromMilliseconds(500);
|
|
11
|
+
expect(duration.milliseconds).toBe(500);
|
|
12
|
+
});
|
|
13
|
+
test("fromSeconds should return a Duration with the given seconds converted to milliseconds", () => {
|
|
14
|
+
const duration = Duration.fromSeconds(2);
|
|
15
|
+
expect(duration.milliseconds).toBe(2000);
|
|
16
|
+
});
|
|
17
|
+
test("fromString should parse valid duration strings", () => {
|
|
18
|
+
const duration = Duration.fromString("2s");
|
|
19
|
+
expect(duration.milliseconds).toBe(2000);
|
|
20
|
+
});
|
|
21
|
+
test("fromString should throw an error for invalid input", () => {
|
|
22
|
+
expect(() => Duration.fromString("invalid")).toThrow("could not parse duration: invalid");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("Instance methods", () => {
|
|
26
|
+
test("seconds should return duration in seconds", () => {
|
|
27
|
+
const duration = Duration.fromMilliseconds(3000);
|
|
28
|
+
expect(duration.seconds).toBe(3);
|
|
29
|
+
});
|
|
30
|
+
test("from should return a Date object offset by the duration", () => {
|
|
31
|
+
const baseDate = new Date("2023-01-01T00:00:00Z");
|
|
32
|
+
const duration = Duration.fromSeconds(10);
|
|
33
|
+
expect(duration.from(baseDate)).toEqual(new Date("2023-01-01T00:00:10Z"));
|
|
34
|
+
});
|
|
35
|
+
test("fromNow should return a future Date object", () => {
|
|
36
|
+
const duration = Duration.fromSeconds(5);
|
|
37
|
+
const now = new Date();
|
|
38
|
+
const future = duration.fromNow();
|
|
39
|
+
expect(future.getTime()).toBeGreaterThan(now.getTime());
|
|
40
|
+
});
|
|
41
|
+
test("add should correctly add two durations", () => {
|
|
42
|
+
const duration1 = Duration.fromSeconds(10);
|
|
43
|
+
const duration2 = Duration.fromSeconds(5);
|
|
44
|
+
const result = duration1.add(duration2);
|
|
45
|
+
expect(result.milliseconds).toBe(15000);
|
|
46
|
+
});
|
|
47
|
+
test("compare should return correct comparison results", () => {
|
|
48
|
+
const duration1 = Duration.fromSeconds(10);
|
|
49
|
+
const duration2 = Duration.fromSeconds(5);
|
|
50
|
+
expect(duration1.compare(duration2)).toBeGreaterThan(0);
|
|
51
|
+
expect(duration2.compare(duration1)).toBeLessThan(0);
|
|
52
|
+
expect(duration1.compare(duration1)).toBe(0);
|
|
53
|
+
});
|
|
54
|
+
test("toString should return formatted duration string", () => {
|
|
55
|
+
expect(Duration.fromMilliseconds(500).toString()).toBe("500ms");
|
|
56
|
+
expect(Duration.fromSeconds(3).toString()).toBe("3s");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Hand-crafted CLI for the mittwald API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"marked": "^12.0.0",
|
|
60
60
|
"marked-terminal": "^6.0.0",
|
|
61
61
|
"open": "^10.0.3",
|
|
62
|
-
"parse-duration": "^
|
|
62
|
+
"parse-duration": "^2.0.1",
|
|
63
63
|
"pretty-bytes": "^6.1.0",
|
|
64
64
|
"react": "^18.2.0",
|
|
65
65
|
"semver": "^7.5.4",
|