Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* `feature-flags list` — print every flag with its enabled-state,
|
||||
* rule-count and parent dependency.
|
||||
*/
|
||||
import { defineCommand } from "citty";
|
||||
import consola from "consola";
|
||||
|
||||
export const featureFlagsListCommand = defineCommand({
|
||||
meta: {
|
||||
name: "list",
|
||||
description: "List every feature flag with current state.",
|
||||
},
|
||||
args: {
|
||||
enabled: {
|
||||
type: "string",
|
||||
description: "Filter: 'true' for enabled only, 'false' for disabled only.",
|
||||
},
|
||||
},
|
||||
async run({ args }) {
|
||||
const filter = args.enabled === undefined ? undefined : String(args.enabled) === "true";
|
||||
const { getDbClient } = await import("@toolctrl/db/client.server");
|
||||
const prisma = getDbClient();
|
||||
const where = filter === undefined ? {} : { enabled: filter };
|
||||
const flags = await prisma.featureFlag.findMany({
|
||||
where,
|
||||
orderBy: { name: "asc" },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
enabled: true,
|
||||
description: true,
|
||||
rules: true,
|
||||
parentFlagId: true,
|
||||
enabledFrom: true,
|
||||
enabledUntil: true,
|
||||
},
|
||||
});
|
||||
if (flags.length === 0) {
|
||||
consola.info("No feature flags found.");
|
||||
return;
|
||||
}
|
||||
for (const flag of flags) {
|
||||
const ruleTag = flag.rules ? "rules" : "no-rules";
|
||||
const depTag = flag.parentFlagId ? `parent=${flag.parentFlagId}` : "no-parent";
|
||||
const stateTag = flag.enabled ? "ON" : "OFF";
|
||||
consola.log(`${stateTag.padEnd(3)} ${flag.name.padEnd(40)} ${ruleTag.padEnd(10)} ${depTag}`);
|
||||
}
|
||||
consola.success(`${flags.length} flags listed.`);
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user