Migrate to Vite+ unified toolchain (#428)

This commit is contained in:
Gregory Schier
2026-03-13 09:27:56 -07:00
committed by GitHub
parent aed7bd12ea
commit 45262edfbd
166 changed files with 1762 additions and 1519 deletions

View File

@@ -12,6 +12,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { convertToCurl } from '../src';
describe('exporter-curl', () => {

View File

@@ -12,6 +12,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { convert } from '../src';
describe('exporter-curl', () => {

View File

@@ -12,6 +12,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,5 +1,5 @@
import type { Context } from '@yaakapp/api';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { plugin } from '../src';
const ctx = {} as Context;

View File

@@ -12,6 +12,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,5 +1,5 @@
import type { Context } from '@yaakapp/api';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { plugin } from '../src';
const ctx = {} as Context;

View File

@@ -12,7 +12,7 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
},
"dependencies": {
"httpntlm": "^1.8.13"

View File

@@ -1,5 +1,5 @@
import type { Context } from '@yaakapp/api';
import { beforeEach, describe, expect, test, vi } from 'vitest';
import { beforeEach, describe, expect, test, vi } from 'vite-plus/test';
const ntlmMock = vi.hoisted(() => ({
createType1Message: vi.fn(),
@@ -17,6 +17,7 @@ describe('auth-ntlm', () => {
ntlmMock.parseType2Message.mockReset();
ntlmMock.createType3Message.mockReset();
ntlmMock.createType1Message.mockReturnValue('NTLM TYPE1');
// oxlint-disable-next-line no-explicit-any
ntlmMock.parseType2Message.mockReturnValue({} as any);
ntlmMock.createType3Message.mockReturnValue('NTLM TYPE3');
});

View File

@@ -12,7 +12,7 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
},
"dependencies": {
"jsonwebtoken": "^9.0.2"

View File

@@ -71,7 +71,7 @@ export async function fetchAccessToken(
throw new Error(`Failed to fetch access token with status=${resp.status} and body=${body}`);
}
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
let response: any;
try {
response = JSON.parse(body);

View File

@@ -91,7 +91,7 @@ export async function getOrRefreshAccessToken(
throw new Error(`Failed to refresh access token with status=${resp.status} and body=${body}`);
}
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
let response: any;
try {
response = JSON.parse(body);

View File

@@ -148,7 +148,7 @@ async function getCodeViaEmbeddedBrowser(
const authorizationUrlStr = authorizationUrl.toString();
console.log('[oauth2] Authorizing via embedded browser', authorizationUrlStr);
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: Required for this pattern
// oxlint-disable-next-line no-async-promise-executor -- Required for this pattern
return new Promise<string>(async (resolve, reject) => {
let foundCode = false;
const { close } = await ctx.window.openUrl({

View File

@@ -53,6 +53,7 @@ function buildClientAssertionJwt(params: {
signingKey = secret;
} else if (trimmed.startsWith('{')) {
// Looks like JSON - treat as JWK. There is surely a better way to detect JWK vs a raw secret, but this should work in most cases.
// oxlint-disable-next-line no-explicit-any
let jwk: any;
try {
jwk = JSON.parse(trimmed);

View File

@@ -105,7 +105,7 @@ async function getTokenViaEmbeddedBrowser(
const authorizationUrlStr = authorizationUrl.toString();
console.log('[oauth2] Authorizing via embedded browser (implicit)', authorizationUrlStr);
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: Required for this pattern
// oxlint-disable-next-line no-async-promise-executor -- Required for this pattern
return new Promise<AccessToken>(async (resolve, reject) => {
let foundAccessToken = false;
const { close } = await ctx.window.openUrl({

View File

@@ -590,11 +590,11 @@ export const plugin: PluginDefinition = {
credentialsInBody,
});
} else {
throw new Error(`Invalid grant type ${grantType}`);
throw new Error(`Invalid grant type ${String(grantType)}`);
}
const headerName = stringArg(values, 'headerName') || 'Authorization';
const headerValue = `${headerPrefix} ${token.response[tokenName]}`.trim();
const headerValue = `${headerPrefix} ${token.response[tokenName] ?? ''}`.trim();
return { setHeaders: [{ name: headerName, value: headerValue }] };
},
},

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { extractCode } from '../src/util';
describe('extractCode', () => {

View File

@@ -11,7 +11,7 @@ export const plugin: PluginDefinition = {
const filtered = JSONPath({ path: args.filter, json: parsed });
return { content: JSON.stringify(filtered, null, 2) };
} catch (err) {
return { content: '', error: `Invalid filter: ${err}` };
return { content: '', error: `Invalid filter: ${err instanceof Error ? err.message : String(err)}` };
}
},
},

View File

@@ -1,3 +1,4 @@
/* oxlint-disable no-base-to-string */
import { DOMParser } from '@xmldom/xmldom';
import type { PluginDefinition } from '@yaakapp/api';
import xpath from 'xpath';
@@ -7,7 +8,7 @@ export const plugin: PluginDefinition = {
name: 'XPath',
description: 'Filter XPath',
onFilter(_ctx, args) {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
const doc: any = new DOMParser().parseFromString(args.payload, 'text/xml');
try {
const result = xpath.select(args.filter, doc, false);
@@ -17,7 +18,7 @@ export const plugin: PluginDefinition = {
// Not sure what cases this happens in (?)
return { content: String(result) };
} catch (err) {
return { content: '', error: `Invalid filter: ${err}` };
return { content: '', error: `Invalid filter: ${err instanceof Error ? err.message : String(err)}` };
}
},
},

View File

@@ -7,7 +7,7 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
},
"dependencies": {
"shlex": "^3.0.0"

View File

@@ -48,7 +48,7 @@ export const plugin: PluginDefinition = {
name: 'cURL',
description: 'Import cURL commands',
onImport(_ctx: Context, args: { text: string }) {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
return convertCurl(args.text) as any;
},
},

View File

@@ -1,5 +1,5 @@
import type { HttpRequest, Workspace } from '@yaakapp/api';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { convertCurl } from '../src';
describe('importer-curl', () => {

View File

@@ -7,7 +7,7 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
},
"dependencies": {
"yaml": "^2.4.2"

View File

@@ -30,7 +30,7 @@ export function deleteUndefinedAttrs<T>(obj: T): T {
/** Recursively render all nested object properties */
export function convertTemplateSyntax<T>(obj: T): T {
if (typeof obj === 'string') {
// biome-ignore lint/suspicious/noTemplateCurlyInString: Yaak template syntax
// oxlint-disable-next-line no-template-curly-in-string -- Yaak template syntax
return obj.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, '${[$2]}') as T;
}
if (Array.isArray(obj) && obj != null) {

View File

@@ -1,4 +1,4 @@
// biome-ignore-all lint/suspicious/noExplicitAny: too flexible for strict types
/* oxlint-disable no-explicit-any */
import type { PartialImportResources } from '@yaakapp/api';
import { convertId, convertTemplateSyntax, isJSObject } from './common';
@@ -203,7 +203,7 @@ function importEnvironment(
variables: Object.entries(e.data).map(([name, value]) => ({
enabled: true,
name,
value: `${value}`,
value: String(value),
})),
};
}

View File

@@ -1,4 +1,4 @@
// biome-ignore-all lint/suspicious/noExplicitAny: too flexible for strict types
/* oxlint-disable no-explicit-any */
import type { PartialImportResources } from '@yaakapp/api';
import { convertId, convertTemplateSyntax, isJSObject } from './common';
@@ -261,7 +261,7 @@ function importFolder(
variables: Object.entries(f.environment ?? {}).map(([name, value]) => ({
enabled: true,
name,
value: `${value}`,
value: String(value),
})),
};
}
@@ -308,7 +308,7 @@ function importEnvironment(
variables: Object.entries(e.data ?? {}).map(([name, value]) => ({
enabled: true,
name,
value: `${value}`,
value: String(value),
})),
};
}

View File

@@ -1,6 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import YAML from 'yaml';
import { convertInsomnia } from '../src';

View File

@@ -7,7 +7,7 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
},
"dependencies": {
"openapi-to-postmanv2": "^5.8.0",

View File

@@ -14,11 +14,11 @@ export const plugin: PluginDefinition = {
};
export async function convertOpenApi(contents: string): Promise<ImportPluginResponse | undefined> {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
let postmanCollection: any;
try {
postmanCollection = await new Promise((resolve, reject) => {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
convert({ type: 'string', data: contents }, {}, (err, result: any) => {
if (err != null) reject(err);

View File

@@ -1,6 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { convertOpenApi } from '../src';
describe('importer-openapi', () => {

View File

@@ -8,6 +8,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,3 +1,4 @@
/* oxlint-disable no-base-to-string */
import type {
Context,
Environment,
@@ -84,7 +85,7 @@ function parseJSONToRecord<T>(jsonStr: string): Record<string, T> | null {
}
}
function toRecord<T>(value: Record<string, T> | unknown): Record<string, T> {
function toRecord<T>(value: unknown): Record<string, T> {
if (value && typeof value === 'object' && !Array.isArray(value)) {
return value as Record<string, T>;
}

View File

@@ -1,6 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { convertPostmanEnvironment } from '../src';
describe('importer-postman-environment', () => {

View File

@@ -8,6 +8,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,3 +1,4 @@
/* oxlint-disable no-base-to-string */
import type {
Context,
Environment,
@@ -158,7 +159,7 @@ export function convertPostman(contents: string): ImportPluginResponse | undefin
return { resources };
}
function convertUrl(rawUrl: string | unknown): Pick<HttpRequest, 'url' | 'urlParameters'> {
function convertUrl(rawUrl: unknown): Pick<HttpRequest, 'url' | 'urlParameters'> {
if (typeof rawUrl === 'string') {
return { url: rawUrl, urlParameters: [] };
}
@@ -172,7 +173,7 @@ function convertUrl(rawUrl: string | unknown): Pick<HttpRequest, 'url' | 'urlPar
}
if ('host' in url) {
v += `${Array.isArray(url.host) ? url.host.join('.') : url.host}`;
v += `${Array.isArray(url.host) ? url.host.join('.') : String(url.host)}`;
}
if ('port' in url && typeof url.port === 'string') {
@@ -489,7 +490,7 @@ function parseJSONToRecord<T>(jsonStr: string): Record<string, T> | null {
}
}
function toRecord<T>(value: Record<string, T> | unknown): Record<string, T> {
function toRecord<T>(value: unknown): Record<string, T> {
if (value && typeof value === 'object' && !Array.isArray(value)) {
return value as Record<string, T>;
}

View File

@@ -1,6 +1,6 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { convertPostman } from '../src';
describe('importer-postman', () => {

View File

@@ -7,6 +7,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -11,7 +11,7 @@ export const plugin: PluginDefinition = {
};
export function migrateImport(contents: string) {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
let parsed: any;
try {
parsed = JSON.parse(contents);

View File

@@ -1,4 +1,4 @@
import { describe, expect, test } from 'vitest';
import { describe, expect, test } from 'vite-plus/test';
import { migrateImport } from '../src';
describe('importer-yaak', () => {

View File

@@ -55,7 +55,8 @@ async function op(
}
}
return { client: _clients[hash], clientHash: hash };
// oxlint-disable-next-line no-non-null-assertion
return { client: _clients[hash]!, clientHash: hash };
}
async function getValue(
@@ -123,7 +124,7 @@ export const plugin: PluginDefinition = {
{
name: 'token',
type: 'text',
// biome-ignore lint/suspicious/noTemplateCurlyInString: Yaak template syntax
// oxlint-disable-next-line no-template-curly-in-string -- Yaak template syntax
defaultValue: '${[1PASSWORD_TOKEN]}',
dynamic(_ctx, args) {
switch (args.values.authMethod) {

View File

@@ -53,7 +53,7 @@ export const plugin: PluginDefinition = {
type: 'text',
name: 'namespace',
label: 'Namespace',
// biome-ignore lint/suspicious/noTemplateCurlyInString: Yaak template syntax
// oxlint-disable-next-line no-template-curly-in-string -- Yaak template syntax
defaultValue: '${[ctx.workspace()]}',
optional: true,
},

View File

@@ -7,6 +7,6 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
}
}

View File

@@ -1,5 +1,5 @@
import type { Context } from '@yaakapp/api';
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from 'vite-plus/test';
import { plugin } from '../src';
describe('regex.match', () => {

View File

@@ -7,7 +7,7 @@
"scripts": {
"build": "yaakcli build",
"dev": "yaakcli dev",
"test": "vitest --run tests"
"test": "vp test --run tests"
},
"dependencies": {
"@date-fns/tz": "^1.4.1",

View File

@@ -1,5 +1,5 @@
import { tz } from '@date-fns/tz';
import { describe, expect, it } from 'vitest';
import { describe, expect, it } from 'vite-plus/test';
import { calculateDatetime, formatDatetime } from '../src';
describe('formatDatetime', () => {

View File

@@ -1,3 +1,4 @@
/* oxlint-disable no-base-to-string */
import { DOMParser } from '@xmldom/xmldom';
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
import xpath from 'xpath';
@@ -68,7 +69,7 @@ export function filterXPath(
result: XPathResult,
join: string | null,
): string {
// biome-ignore lint/suspicious/noExplicitAny: none
// oxlint-disable-next-line no-explicit-any
const doc: any = new DOMParser().parseFromString(body, 'text/xml');
const items = xpath.select(path, doc, false);