Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add user agent #4

Merged
merged 2 commits into from
Nov 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hip-parrots-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jakzo/aoc": patch
---

Added custom user agent
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,37 @@ The template files exist at [./templates](./templates) with commands for the tem

The tool also exposes individual commands in case you want to compose some functionality together with another tool. For example you can save the input for a challenge to another file with `aoc input --year 2016 --day 5 > another-file.txt`.

Documentation for individual commands can be found by running `aoc --help`.
Documentation for individual commands can be found by running `aoc --help`:

```
$ aoc --help
Commands:
aoc Counts down, saves input, prints
description and prompts for
answers to the upcoming challenge
[default]
aoc start [language] Creates and run files from a
template for a language (does not
overwrite)
aoc login Prompts for a new session token
aoc template <output> Copies a template folder (does
not overwrite)
aoc countdown Counts down until the next
challenge starts then exits
aoc description Prints the description of a
challenge
aoc input Prints the input to a challenge
aoc submit [answer] Submits an answer to a challenge
aoc leaderboard <id> Outputs a CSV of times to
completion for a private
leaderboard

Options:
-y, --year The year of the challenge [number]
-d, --day The day of the challenge [number]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
```

Individual commands can also be accessed from the npm module like:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"jest": "26.6.3",
"lint-staged": "10.5.4",
"node-notifier": "9.0.1",
"pkg": "^5.0.0",
"pkg": "^5.4.1",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"ts-jest": "26.5.4",
Expand Down
2 changes: 1 addition & 1 deletion src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const templateCommands = declareTemplates({
"-macosx_version_min",
"10.8",
"-no_pie",
"-lc",
"-static",
"-o",
path.join(ctx.tempDir, "wip"),
path.join(ctx.tempDir, "wip.o"),
Expand Down
7 changes: 7 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const BACKOFF_RATE = 1.1;
const BACKOFF_INITIAL = 1000;
const BACKOFF_MAX = 30000;

// eslint-disable-next-line @typescript-eslint/no-var-requires
const PACKAGE_JSON = require("../package.json") as {
version: string;
homepage: string;
};

export const logHtml = (html: string): void => {
console.log(cliHtml(html).replace(/\n+$/, ""));
};
Expand Down Expand Up @@ -112,6 +118,7 @@ export const makeRequest = async (
url: `${BASE_URL}${url}`,
method: data ? "POST" : "GET",
headers: {
"User-Agent": `Mozilla/5.0 (compatible; jakzo-aoc/${PACKAGE_JSON.version}; +${PACKAGE_JSON.homepage})`,
...(data
? { "Content-Type": "application/x-www-form-urlencoded" }
: undefined),
Expand Down
4 changes: 2 additions & 2 deletions templates/assembly-x86-mac/wip.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PROT_WRITE equ 0x02
MAP_ANON equ 0x1000
%define mmap(addr, len, prot, flags, fd, pos) oscall 197, addr, len, prot, flags, fd, pos

global _main
global start

section .text

Expand Down Expand Up @@ -82,7 +82,7 @@ write(1, rsp, rbx)
add rsp, rbx
%endmacro

_main:
start:
part 1, 2020
part 2, 30000000
exit(0)
Expand Down
70 changes: 59 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,13 @@ acorn@^8.1.0:
version "8.1.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.1.1.tgz#fb0026885b9ac9f48bac1e185e4af472971149ff"

agent-base@6:
version "6.0.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==
dependencies:
debug "4"

aggregate-error@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a"
Expand Down Expand Up @@ -1244,7 +1251,7 @@ aws4@^1.8.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59"

axios@^0.21.0, axios@^0.21.1:
axios@^0.21.0:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
dependencies:
Expand Down Expand Up @@ -1973,6 +1980,13 @@ dateformat@~1.0.4-1.2.3:
get-stdin "^4.0.1"
meow "^3.3.0"

debug@4:
version "4.3.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==
dependencies:
ms "2.1.2"

debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand Down Expand Up @@ -2976,6 +2990,14 @@ http-signature@~1.2.0:
jsprim "^1.2.2"
sshpk "^1.7.0"

https-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
dependencies:
agent-base "6"
debug "4"

human-id@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/human-id/-/human-id-1.0.2.tgz#e654d4b2b0d8b07e45da9f6020d8af17ec0a5df3"
Expand Down Expand Up @@ -4362,6 +4384,13 @@ node-addon-api@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.1.0.tgz#98b21931557466c6729e51cb77cd39c965f42239"

node-fetch@^2.6.1:
version "2.6.6"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
dependencies:
whatwg-url "^5.0.0"

node-gyp-build@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.2.3.tgz#ce6277f853835f718829efb47db20f3e4d9c4739"
Expand Down Expand Up @@ -4827,22 +4856,23 @@ pkg-dir@^4.2.0:
dependencies:
find-up "^4.0.0"

pkg-fetch@3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/pkg-fetch/-/pkg-fetch-3.0.3.tgz#3395e02f0164c971a98e6a59a20b386d483ad909"
integrity sha512-w8Nn7EZZFtTcdeERUH5IcMRAbrn4xL55X05dtjIaBlrkkNzMvbgAyTAwEDGmK3cxBU1d/Eh+uZVueeUzIG0AEA==
pkg-fetch@3.2.4:
version "3.2.4"
resolved "https://registry.yarnpkg.com/pkg-fetch/-/pkg-fetch-3.2.4.tgz#5372734b12167d4bacd872be348217461b517390"
integrity sha512-ewUD26GP86/8+Fu93zrb30CpJjKOtT4maSgm4SwTX9Ujy1pfdUdv+1PubsY9tTJES0iBYItAtqbfkf7Wu5LV9w==
dependencies:
axios "^0.21.1"
chalk "^4.1.0"
fs-extra "^9.1.0"
https-proxy-agent "^5.0.0"
node-fetch "^2.6.1"
progress "^2.0.3"
semver "^7.3.5"
yargs "^16.2.0"

pkg@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/pkg/-/pkg-5.0.0.tgz#616f8d51c6a0ac50c6c0a22c2f385492c285bacb"
integrity sha512-B/bZZp51wUP00XHme4qoA/VHsRDIL1ldN+oEdg/L8E7mE9B8Oz/mximyQWbKFrMu85Uh3H9jy55ln5Ms6jspwg==
pkg@^5.4.1:
version "5.4.1"
resolved "https://registry.yarnpkg.com/pkg/-/pkg-5.4.1.tgz#4d824e42c454f32131e471d7cd8d14bfdb3e1c4c"
integrity sha512-iJs3W6MCgeZ4MrH7iZtX6HTqsNzoh2U9rGILL3eOLbQFV43U8WPAzrqRK7cBQGuHx38UXxcGT6G/2yDl/GveRg==
dependencies:
"@babel/parser" "7.13.13"
"@babel/types" "7.13.12"
Expand All @@ -4853,7 +4883,7 @@ pkg@^5.0.0:
into-stream "^6.0.0"
minimist "^1.2.5"
multistream "^4.1.0"
pkg-fetch "3.0.3"
pkg-fetch "3.2.4"
prebuild-install "6.0.1"
progress "^2.0.3"
resolve "^1.20.0"
Expand Down Expand Up @@ -5946,6 +5976,11 @@ tr46@^2.0.2:
dependencies:
punycode "^2.1.1"

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=

tree-kill@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.2.tgz#4ca09a9092c88b73a7cdc5e8a01b507b0790a0cc"
Expand Down Expand Up @@ -6311,6 +6346,11 @@ wcwidth@^1.0.1:
dependencies:
defaults "^1.0.3"

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=

webidl-conversions@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
Expand All @@ -6329,6 +6369,14 @@ whatwg-mimetype@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"

whatwg-url@^8.0.0, whatwg-url@^8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.5.0.tgz#7752b8464fc0903fec89aa9846fc9efe07351fd3"
Expand Down