Copy as curl

This commit is contained in:
Gregory Schier
2024-05-08 00:00:50 -07:00
parent edc4fe3d9a
commit b196e51f1f
32 changed files with 4352 additions and 507 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,11 +2,10 @@
"name": "importer-curl",
"version": "0.0.1",
"dependencies": {
"shell-quote": "^1.8.1",
"url": "^0.11.3"
"shell-quote": "^1.8.1"
},
"devDependencies": {
"@types/shell-quote": "^1.7.5",
"random-seedable": "^1.0.8"
"vitest": "^1.4.0"
}
}

View File

@@ -43,7 +43,7 @@ type Pair = string | boolean;
type PairsByName = Record<string, Pair[]>;
export const pluginHookImport = (rawData: string) => {
export function pluginHookImport(rawData: string) {
if (!rawData.match(/^\s*curl /)) {
return null;
}
@@ -125,7 +125,7 @@ export const pluginHookImport = (rawData: string) => {
workspaces: [workspace],
},
};
};
}
export function importCommand(parseEntries: ParseEntry[], workspaceId: string) {
// ~~~~~~~~~~~~~~~~~~~~~ //

View File

@@ -1,22 +1,8 @@
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { describe, expect, test } from 'vitest';
import { HttpRequest, Model, Workspace } from '../../../src-web/lib/models';
import { pluginHookImport } from '../src';
import { XORShift } from 'random-seedable';
let originalRandom = Math.random;
describe('importer-curl', () => {
beforeEach(() => {
const rand = new XORShift(123456789);
Math.random = vi.fn(() => {
return rand.float();
});
});
afterEach(() => {
Math.random = originalRandom;
});
test('Imports basic GET', () => {
expect(pluginHookImport('curl https://yaak.app')).toEqual({
resources: {