@mittwald/cli 1.0.0-alpha.31 → 1.0.0-alpha.32
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { normalizeProjectIdToUuid } from "../../Helpers.js";
|
|
1
|
+
import { isUuid, normalizeProjectIdToUuid } from "../../Helpers.js";
|
|
2
2
|
import { makeFlagSet, makeMissingContextInputError, } from "../context_flags.js";
|
|
3
|
+
import { Context } from "../context.js";
|
|
3
4
|
import { Args, Flags } from "@oclif/core";
|
|
4
5
|
export const { flags: projectFlags, args: projectArgs, withId: withProjectId, } = makeFlagSet("project", "p", { normalize: normalizeProjectIdToUuid });
|
|
5
6
|
export function makeProjectFlagSet(name, char, opts = {}) {
|
|
@@ -37,11 +38,18 @@ export function makeProjectFlagSet(name, char, opts = {}) {
|
|
|
37
38
|
return undefined;
|
|
38
39
|
};
|
|
39
40
|
const withId = async (apiClient, commandType, flags, args, cfg) => {
|
|
40
|
-
const projectId = await withProjectId(apiClient, commandType, flags, args, cfg);
|
|
41
41
|
const idInput = idFromArgsOrFlag(flags, args);
|
|
42
42
|
if (idInput) {
|
|
43
|
+
if (isUuid(idInput)) {
|
|
44
|
+
return idInput;
|
|
45
|
+
}
|
|
46
|
+
const projectId = await withProjectId(apiClient, commandType, flags, args, cfg);
|
|
43
47
|
return normalize(apiClient, projectId, idInput);
|
|
44
48
|
}
|
|
49
|
+
const idFromContext = await new Context(cfg).getContextValue(flagName);
|
|
50
|
+
if (idFromContext) {
|
|
51
|
+
return idFromContext.value;
|
|
52
|
+
}
|
|
45
53
|
throw makeMissingContextInputError(commandType, name, flagName, false);
|
|
46
54
|
};
|
|
47
55
|
return {
|