Release v0.10.4: Built-in rule linter, dynamic TS plugin loader with fault-tolerant fallback, and default-disabled global config
This commit is contained in:
1 parent
cdab1e2009
commit
1cf35dfd78
23 files changed
+914
-77
No files matched your search
@@ -104,7 +104,14 @@ describe("loadCorpConfigs", () => {
|
||||
test("defaults global config to stateless", () => {
|
||||
process.env.SEAL_USE_CONFIG_FILE = join(makeTempDir(), "config.json");
|
||||
|
||||
expect(loadGlobalConfig()).toEqual({ stateful: false });
|
||||
expect(loadGlobalConfig()).toEqual({
|
||||
stateful: false,
|
||||
lint: {
|
||||
enabled: false,
|
||||
activeLinter: "builtin",
|
||||
minScore: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("saves and loads the global state mode", () => {
|
||||
@@ -113,10 +120,23 @@ describe("loadCorpConfigs", () => {
|
||||
|
||||
expect(saveGlobalConfig({ stateful: true, defaultCorpId: "corp-a" })).toEqual({
|
||||
stateful: true,
|
||||
defaultCorpId: "corp-a"
|
||||
defaultCorpId: "corp-a",
|
||||
lint: {
|
||||
enabled: false,
|
||||
activeLinter: "builtin",
|
||||
minScore: 0
|
||||
}
|
||||
});
|
||||
expect(resolveGlobalConfigFile()).toBe(file);
|
||||
expect(loadGlobalConfig()).toEqual({ stateful: true, defaultCorpId: "corp-a" });
|
||||
expect(loadGlobalConfig()).toEqual({
|
||||
stateful: true,
|
||||
defaultCorpId: "corp-a",
|
||||
lint: {
|
||||
enabled: false,
|
||||
activeLinter: "builtin",
|
||||
minScore: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { CorpConfig, CorpConfigSchema, GlobalConfig, GlobalConfigSchema } from "./types.js";
|
||||
import { CorpConfig, CorpConfigSchema, GlobalConfig, GlobalConfigInput, GlobalConfigSchema } from "./types.js";
|
||||
|
||||
const ENTERPRISES_DIR = "enterprises";
|
||||
const CONFIG_ENV = "SEAL_USE_ENTERPRISES_DIR";
|
||||
@@ -101,7 +101,7 @@ export function loadGlobalConfig(): GlobalConfig {
|
||||
return GlobalConfigSchema.parse(JSON.parse(readFileSync(file, "utf-8")));
|
||||
}
|
||||
|
||||
export function saveGlobalConfig(config: GlobalConfig): GlobalConfig {
|
||||
export function saveGlobalConfig(config: GlobalConfigInput): GlobalConfig {
|
||||
const normalized = GlobalConfigSchema.parse(config);
|
||||
const configured = (process.env[GLOBAL_CONFIG_ENV] ?? process.env[LEGACY_GLOBAL_CONFIG_ENV])?.trim();
|
||||
const file = configured || PRIMARY_GLOBAL_CONFIG_FILE;
|
||||
|
||||
@@ -82,7 +82,14 @@ describe("CorpConfigSchema", () => {
|
||||
|
||||
describe("GlobalConfigSchema", () => {
|
||||
test("defaults to stateless mode", () => {
|
||||
expect(GlobalConfigSchema.parse({})).toEqual({ stateful: false });
|
||||
expect(GlobalConfigSchema.parse({})).toEqual({
|
||||
stateful: false,
|
||||
lint: {
|
||||
enabled: false,
|
||||
activeLinter: "builtin",
|
||||
minScore: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test("accepts a stateful default enterprise", () => {
|
||||
@@ -91,7 +98,12 @@ describe("GlobalConfigSchema", () => {
|
||||
defaultCorpId: "corp-a"
|
||||
})).toEqual({
|
||||
stateful: true,
|
||||
defaultCorpId: "corp-a"
|
||||
defaultCorpId: "corp-a",
|
||||
lint: {
|
||||
enabled: false,
|
||||
activeLinter: "builtin",
|
||||
minScore: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -84,9 +84,20 @@ export const CorpConfigSchema = z.object({
|
||||
auth: CorpAuthConfigSchema
|
||||
});
|
||||
|
||||
export const GlobalLintConfigSchema = z.object({
|
||||
enabled: z.boolean().default(false),
|
||||
activeLinter: z.string().default("builtin"),
|
||||
minScore: z.number().min(0).max(100).default(0)
|
||||
}).default({
|
||||
enabled: false,
|
||||
activeLinter: "builtin",
|
||||
minScore: 0
|
||||
});
|
||||
|
||||
export const GlobalConfigSchema = z.object({
|
||||
stateful: z.boolean().default(false),
|
||||
defaultCorpId: z.string().min(1).optional()
|
||||
defaultCorpId: z.string().min(1).optional(),
|
||||
lint: GlobalLintConfigSchema
|
||||
});
|
||||
|
||||
export type HoseSealSource = z.infer<typeof HoseSealSourceSchema>;
|
||||
@@ -95,4 +106,6 @@ export type NativeSealSource = z.infer<typeof NativeSealSourceSchema>;
|
||||
export type SealSource = z.infer<typeof SealSourceSchema>;
|
||||
export type CorpAuthConfig = z.infer<typeof CorpAuthConfigSchema>;
|
||||
export type CorpConfig = z.infer<typeof CorpConfigSchema>;
|
||||
export type GlobalLintConfig = z.infer<typeof GlobalLintConfigSchema>;
|
||||
export type GlobalConfig = z.infer<typeof GlobalConfigSchema>;
|
||||
export type GlobalConfigInput = z.input<typeof GlobalConfigSchema>;
|
||||
Reference in new issue
Block a user