mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-10 19:16:55 +02:00
Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,22 +1,22 @@
|
||||
import { parseTemplate } from '@yaakapp-internal/templates';
|
||||
import { activeEnvironmentIdAtom } from '../hooks/useActiveEnvironment';
|
||||
import { activeWorkspaceIdAtom } from '../hooks/useActiveWorkspace';
|
||||
import { jotaiStore } from './jotai';
|
||||
import { invokeCmd } from './tauri';
|
||||
import { parseTemplate } from "@yaakapp-internal/templates";
|
||||
import { activeEnvironmentIdAtom } from "../hooks/useActiveEnvironment";
|
||||
import { activeWorkspaceIdAtom } from "../hooks/useActiveWorkspace";
|
||||
import { jotaiStore } from "./jotai";
|
||||
import { invokeCmd } from "./tauri";
|
||||
|
||||
export function analyzeTemplate(template: string): 'global_secured' | 'local_secured' | 'insecure' {
|
||||
export function analyzeTemplate(template: string): "global_secured" | "local_secured" | "insecure" {
|
||||
let secureTags = 0;
|
||||
let insecureTags = 0;
|
||||
let totalTags = 0;
|
||||
for (const t of parseTemplate(template).tokens) {
|
||||
if (t.type === 'eof') continue;
|
||||
if (t.type === "eof") continue;
|
||||
|
||||
totalTags++;
|
||||
if (t.type === 'tag' && t.val.type === 'fn' && t.val.name === 'secure') {
|
||||
if (t.type === "tag" && t.val.type === "fn" && t.val.name === "secure") {
|
||||
secureTags++;
|
||||
} else if (t.type === 'tag' && t.val.type === 'var') {
|
||||
} else if (t.type === "tag" && t.val.type === "var") {
|
||||
// Variables are secure
|
||||
} else if (t.type === 'tag' && t.val.type === 'bool') {
|
||||
} else if (t.type === "tag" && t.val.type === "bool") {
|
||||
// Booleans are secure
|
||||
} else {
|
||||
insecureTags++;
|
||||
@@ -24,34 +24,34 @@ export function analyzeTemplate(template: string): 'global_secured' | 'local_sec
|
||||
}
|
||||
|
||||
if (secureTags === 1 && totalTags === 1) {
|
||||
return 'global_secured';
|
||||
return "global_secured";
|
||||
}
|
||||
if (insecureTags === 0) {
|
||||
return 'local_secured';
|
||||
return "local_secured";
|
||||
}
|
||||
return 'insecure';
|
||||
return "insecure";
|
||||
}
|
||||
|
||||
export async function convertTemplateToInsecure(template: string) {
|
||||
if (template === '') {
|
||||
return '';
|
||||
if (template === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
const workspaceId = jotaiStore.get(activeWorkspaceIdAtom) ?? 'n/a';
|
||||
const workspaceId = jotaiStore.get(activeWorkspaceIdAtom) ?? "n/a";
|
||||
const environmentId = jotaiStore.get(activeEnvironmentIdAtom) ?? null;
|
||||
return invokeCmd<string>('cmd_decrypt_template', { template, workspaceId, environmentId });
|
||||
return invokeCmd<string>("cmd_decrypt_template", { template, workspaceId, environmentId });
|
||||
}
|
||||
|
||||
export async function convertTemplateToSecure(template: string): Promise<string> {
|
||||
if (template === '') {
|
||||
return '';
|
||||
if (template === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (analyzeTemplate(template) === 'global_secured') {
|
||||
if (analyzeTemplate(template) === "global_secured") {
|
||||
return template;
|
||||
}
|
||||
|
||||
const workspaceId = jotaiStore.get(activeWorkspaceIdAtom) ?? 'n/a';
|
||||
const workspaceId = jotaiStore.get(activeWorkspaceIdAtom) ?? "n/a";
|
||||
const environmentId = jotaiStore.get(activeEnvironmentIdAtom) ?? null;
|
||||
return invokeCmd<string>('cmd_secure_template', { template, workspaceId, environmentId });
|
||||
return invokeCmd<string>("cmd_secure_template", { template, workspaceId, environmentId });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user