Skip to content

Commit ce2f8ac

Browse files
committed
Add the dist directory
1 parent bdb4a9f commit ce2f8ac

685 files changed

Lines changed: 9590 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
*.log
22
node_modules
33
coverage*
4-
dist

dist/cli.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export declare const go: () => {
2+
[x: string]: unknown;
3+
target: "shell" | "node" | "http" | "r" | "c" | "clojure" | "csharp" | "go" | "java" | "javascript" | "kotlin" | "objc" | "ocaml" | "php" | "powershell" | "python" | "ruby" | "swift";
4+
client?: string | undefined;
5+
output?: string | undefined;
6+
harFilePath: string;
7+
options?: any;
8+
_: (string | number)[];
9+
$0: string;
10+
} | Promise<{
11+
[x: string]: unknown;
12+
target: "shell" | "node" | "http" | "r" | "c" | "clojure" | "csharp" | "go" | "java" | "javascript" | "kotlin" | "objc" | "ocaml" | "php" | "powershell" | "python" | "ruby" | "swift";
13+
client?: string | undefined;
14+
output?: string | undefined;
15+
harFilePath: string;
16+
options?: any;
17+
_: (string | number)[];
18+
$0: string;
19+
}>;
20+
//# sourceMappingURL=cli.d.ts.map

dist/cli.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cli.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
exports.__esModule = true;
6+
exports.go = void 0;
7+
var chalk_1 = __importDefault(require("chalk"));
8+
var fs_1 = require("fs");
9+
var path_1 = __importDefault(require("path"));
10+
var helpers_1 = require("yargs/helpers");
11+
var yargs_1 = __importDefault(require("yargs/yargs"));
12+
// eslint-disable-next-line @typescript-eslint/no-var-requires -- require() to avoid package.json being included in build output.
13+
var packageJson = require('../package.json');
14+
var httpsnippet_1 = require("./httpsnippet");
15+
var targets_1 = require("./targets/targets");
16+
var cyan = chalk_1["default"].cyan, green = chalk_1["default"].green, red = chalk_1["default"].red, yellow = chalk_1["default"].yellow;
17+
var bad = function (message) { return console.error("".concat(red('✖'), " ").concat(message)); };
18+
var good = function (message) { return console.log("".concat(green('✓'), " ").concat(message)); };
19+
var go = function () {
20+
return (0, yargs_1["default"])((0, helpers_1.hideBin)(process.argv))
21+
.version(packageJson.version)
22+
.command('$0 [harFilePath]', 'the default command', function (builder) {
23+
builder
24+
.option('target', {
25+
alias: 't',
26+
type: 'string',
27+
description: 'target output',
28+
requiresArg: true
29+
})
30+
.option('client', {
31+
alias: 'c',
32+
type: 'string',
33+
description: 'language client',
34+
requiresArg: true
35+
})
36+
.option('output', {
37+
alias: 'o',
38+
type: 'string',
39+
description: 'write output to directory'
40+
})
41+
.option('options', {
42+
alias: 'x',
43+
type: 'string',
44+
description: 'provide extra options for the target/client',
45+
requiresArg: true
46+
})
47+
.demandOption(['target'], 'please provide a target')
48+
.strict()
49+
.showHelpOnFail(true)
50+
.help();
51+
}, function (_a) {
52+
var targetId = _a.target, client = _a.client, output = _a.output, options = _a.options, harFilePath = _a.harFilePath;
53+
var har = JSON.parse((0, fs_1.readFileSync)(harFilePath).toString());
54+
var httpsnippet = new httpsnippet_1.HTTPSnippet(har);
55+
try {
56+
if (options) {
57+
options = JSON.parse(options);
58+
}
59+
}
60+
catch (error) {
61+
if (error instanceof Error) {
62+
bad("".concat(cyan.bold(harFilePath), " failed to read JSON: ").concat(red(error.message)));
63+
}
64+
return;
65+
}
66+
var result = httpsnippet.convert(targetId, client, options);
67+
if (!result) {
68+
throw new Error('something went wrong');
69+
}
70+
if (!output) {
71+
console.log(result);
72+
return;
73+
}
74+
var file = path_1["default"].parse(harFilePath).name;
75+
var writeFilePath = path_1["default"].join(output, "".concat(file).concat((0, httpsnippet_1.extname)(targetId)));
76+
(0, fs_1.writeFileSync)(writeFilePath, String(result));
77+
var target = targets_1.targets[targetId];
78+
var clientId = target.clientsById[client || target.info["default"]].info.key;
79+
good("converted ".concat(cyan.bold(harFilePath), " with ").concat(yellow(targetId), "[").concat(yellow(clientId), "] at ").concat(cyan(writeFilePath), "\n\n").concat(result));
80+
})
81+
.example('$0 my_har.json', '--target rust --client actix --output my_src_directory').argv;
82+
};
83+
exports.go = go;

dist/fixtures/customTarget.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Target } from '../targets/targets';
2+
export declare const customTarget: Target;
3+
//# sourceMappingURL=customTarget.d.ts.map

dist/fixtures/customTarget.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/fixtures/customTarget.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
exports.__esModule = true;
3+
exports.customTarget = void 0;
4+
var client_1 = require("../targets/node/request/client");
5+
exports.customTarget = {
6+
info: {
7+
key: 'js-variant',
8+
title: 'JavaScript Variant',
9+
extname: '.js',
10+
"default": 'request'
11+
},
12+
clientsById: {
13+
request: client_1.request
14+
}
15+
};

dist/fixtures/mimetypes.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Request } from '../httpsnippet';
2+
export declare const mimetypes: {
3+
'multipart/mixed': Request;
4+
'multipart/related': Request;
5+
'multipart/form-data': Request;
6+
'multipart/alternative': Request;
7+
'application/x-www-form-urlencoded': Request;
8+
'text/json': Request;
9+
'text/x-json': Request;
10+
'application/x-json': Request;
11+
'invalid-json': Request;
12+
};
13+
//# sourceMappingURL=mimetypes.d.ts.map

dist/fixtures/mimetypes.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/fixtures/mimetypes.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"use strict";
2+
exports.__esModule = true;
3+
exports.mimetypes = void 0;
4+
exports.mimetypes = {
5+
'multipart/mixed': {
6+
method: 'POST',
7+
url: 'http://mockbin.com/har',
8+
postData: {
9+
mimeType: 'multipart/mixed',
10+
text: ''
11+
}
12+
},
13+
'multipart/related': {
14+
method: 'POST',
15+
url: 'http://mockbin.com/har',
16+
postData: {
17+
mimeType: 'multipart/related',
18+
text: ''
19+
}
20+
},
21+
'multipart/form-data': {
22+
method: 'POST',
23+
url: 'http://mockbin.com/har',
24+
postData: {
25+
mimeType: 'multipart/form-data',
26+
text: ''
27+
}
28+
},
29+
'multipart/alternative': {
30+
method: 'POST',
31+
url: 'http://mockbin.com/har',
32+
postData: {
33+
mimeType: 'multipart/alternative',
34+
text: ''
35+
}
36+
},
37+
'application/x-www-form-urlencoded': {
38+
method: 'POST',
39+
url: 'http://mockbin.com/har',
40+
postData: {
41+
mimeType: 'application/x-www-form-urlencoded',
42+
text: ''
43+
}
44+
},
45+
'text/json': {
46+
method: 'POST',
47+
url: 'http://mockbin.com/har',
48+
postData: {
49+
mimeType: 'text/json',
50+
text: ''
51+
}
52+
},
53+
'text/x-json': {
54+
method: 'POST',
55+
url: 'http://mockbin.com/har',
56+
postData: {
57+
mimeType: 'text/x-json',
58+
text: ''
59+
}
60+
},
61+
'application/x-json': {
62+
method: 'POST',
63+
url: 'http://mockbin.com/har',
64+
postData: {
65+
mimeType: 'application/x-json',
66+
text: ''
67+
}
68+
},
69+
'invalid-json': {
70+
method: 'POST',
71+
url: 'http://mockbin.com/har',
72+
postData: {
73+
mimeType: 'application/json',
74+
text: 'foo/bar'
75+
}
76+
}
77+
};

0 commit comments

Comments
 (0)