mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
wanr and fail if clibhaviour is higher than the current cli supports
This commit is contained in:
@@ -45,6 +45,7 @@ import {
|
||||
import {
|
||||
getEffectiveSettings,
|
||||
mergeConfigWithConfigFile,
|
||||
parseCliBehavior,
|
||||
SyncOptions,
|
||||
validateBranchConfiguration,
|
||||
} from "../../core/conf.ts";
|
||||
@@ -104,13 +105,6 @@ import {
|
||||
getNonDottedPaths,
|
||||
} from "../../utils/resource_folders.ts";
|
||||
|
||||
// Parse cliBehavior version string (e.g. "v1", "v2") into a number. Returns 0 if absent/invalid.
|
||||
export function parseCliBehavior(value?: string): number {
|
||||
if (!value) return 0;
|
||||
const match = value.match(/^v(\d+)$/);
|
||||
return match ? parseInt(match[1], 10) : 0;
|
||||
}
|
||||
|
||||
// Merge CLI options with effective settings, preserving CLI flags as overrides
|
||||
function mergeCliWithEffectiveOptions<
|
||||
T extends GlobalOptions & SyncOptions & { repository?: string },
|
||||
|
||||
@@ -14,6 +14,15 @@ import { execSync } from "node:child_process";
|
||||
import { setNonDottedPaths } from "../utils/resource_folders.ts";
|
||||
import type { PermissionedAsRule } from "./permissioned_as.ts";
|
||||
|
||||
export const SUPPORTED_CLI_BEHAVIOR_VERSION = 1;
|
||||
|
||||
// Parse cliBehavior version string (e.g. "v1", "v2") into a number. Returns 0 if absent/invalid.
|
||||
export function parseCliBehavior(value?: string): number {
|
||||
if (!value) return 0;
|
||||
const match = value.match(/^v(\d+)$/);
|
||||
return match ? parseInt(match[1], 10) : 0;
|
||||
}
|
||||
|
||||
export let showDiffs = false;
|
||||
export function setShowDiffs(value: boolean) {
|
||||
showDiffs = value;
|
||||
@@ -294,6 +303,15 @@ export async function readConfigFile(): Promise<SyncOptions> {
|
||||
// Initialize global nonDottedPaths setting from config
|
||||
setNonDottedPaths(conf?.nonDottedPaths ?? false);
|
||||
|
||||
// Exit if the config specifies a cliBehavior version higher than what this CLI supports
|
||||
const cliBehaviorVersion = parseCliBehavior(conf?.cliBehavior);
|
||||
if (cliBehaviorVersion > SUPPORTED_CLI_BEHAVIOR_VERSION) {
|
||||
log.error(
|
||||
`Your wmill.yaml specifies cliBehavior: ${conf!.cliBehavior}, but this CLI only supports up to v${SUPPORTED_CLI_BEHAVIOR_VERSION}. Run 'wmill upgrade' to update.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
return typeof conf == "object" ? conf : ({} as SyncOptions);
|
||||
} catch (e) {
|
||||
if (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, test, describe } from "bun:test";
|
||||
import { parseCliBehavior } from "../src/commands/sync/sync.ts";
|
||||
import { parseCliBehavior } from "../src/core/conf.ts";
|
||||
|
||||
describe("parseCliBehavior", () => {
|
||||
test("parses v1 to 1", () => {
|
||||
|
||||
Reference in New Issue
Block a user