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

Bump ts-node from 9.1.1 to 10.9.1 #508

Merged
merged 16 commits into from
Oct 25, 2023
43 changes: 6 additions & 37 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
version: 2.1

executors:
node10:
docker:
- image: cimg/node:10.24.0
resource_class: small
working_directory: ~/repo

node12:
docker:
- image: cimg/node:12.13.1
resource_class: small
working_directory: ~/repo

node14:
docker:
- image: cimg/node:14.21.3
Expand Down Expand Up @@ -65,16 +53,6 @@ commands:


jobs:
test-node10:
executor: node10
steps:
- run-tests

test-node12:
executor: node12
steps:
- run-tests

test-node14:
executor: node14
steps:
Expand All @@ -91,14 +69,15 @@ jobs:
- run-tests

build-and-run:
executor: node10
executor: node14
steps:
- checkout
- install-dependencies
- run: yarn build
- run: sudo npm link
- run: npm link
- run: npx proxay --help
- run: |
proxay -m record -h https://www.google.com -t tapes/ &
npx proxay -m record -h https://www.google.com -t tapes/ &
# Wait until it loads.
until (curl http://localhost:3000 2>&1 | grep Google &>/dev/null)
do
Expand All @@ -107,7 +86,7 @@ jobs:
done

lint-check:
executor: node10
executor: node14
steps:
- checkout
- install-dependencies
Expand All @@ -116,7 +95,7 @@ jobs:
command: yarn lint:check

publish:
executor: node10
executor: node14
steps:
- checkout
- install-dependencies
Expand All @@ -132,14 +111,6 @@ jobs:
workflows:
build-and-test:
jobs:
- test-node10:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
- test-node12:
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
- test-node14:
filters:
tags:
Expand All @@ -162,8 +133,6 @@ workflows:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
- publish:
requires:
- test-node10
- test-node12
- test-node14
- test-node16
- test-node18
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
"@types/rimraf": "^3.0.0",
"@types/string-similarity": "^4.0.1",
"express": "^4.18.2",
"jest": "^25.5.4",
"jest": "^29.0.0",
"jest-junit": "^16.0.0",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-jest": "^25.5.1",
"ts-node": "^9.1.1",
"ts-node-dev": "^1.1.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.9.5"
Expand Down
3 changes: 2 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ async function main(argv: string[]) {
const host: string = program.host;
const port = parseInt(program.port, 10);
const redactHeaders: string[] = program.redactHeaders;
const preventConditionalRequests: boolean = !!program.dropConditionalRequestHeaders;
const preventConditionalRequests: boolean =
!!program.dropConditionalRequestHeaders;
const httpsCA: string = program.httpsCa || "";
const httpsKey: string = program.httpsKey;
const httpsCert: string = program.httpsCert;
Expand Down
52 changes: 4 additions & 48 deletions src/persistence.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,14 @@ const UTF8_RESPONSE = "Hello 💩 Hello 💩 Hello 💩";

const BINARY_REQUEST = Buffer.from([
// These are not valid UTF-8 characters, on purpose.
2,
48,
34,
104,
155,
1,
234,
140,
2,
48,
34,
104,
155,
1,
234,
140,
2,
48,
34,
104,
155,
1,
234,
140,
2, 48, 34, 104, 155, 1, 234, 140, 2, 48, 34, 104, 155, 1, 234, 140, 2, 48, 34,
104, 155, 1, 234, 140,
]);

const BINARY_RESPONSE = Buffer.from([
// These are not valid UTF-8 characters, on purpose.
12,
48,
249,
104,
255,
33,
203,
179,
12,
48,
249,
104,
255,
33,
203,
179,
12,
48,
249,
104,
255,
33,
203,
179,
12, 48, 249, 104, 255, 33, 203, 179, 12, 48, 249, 104, 255, 33, 203, 179, 12,
48, 249, 104, 255, 33, 203, 179,
]);

const UTF8_REQUEST_BROTLI = Buffer.from(
Expand Down
6 changes: 3 additions & 3 deletions src/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class Persistence {
if (!fs.existsSync(tapePath)) {
throw new Error(`No tape found with name ${tapeName}`);
}
const persistedTapeRecords = yaml.safeLoad(
fs.readFileSync(tapePath, "utf8")
const persistedTapeRecords = (
yaml.safeLoad(fs.readFileSync(tapePath, "utf8")) as Record<string, any>
).http_interactions as PersistedTapeRecord[];
return persistedTapeRecords.map(reviveTape);
}
Expand Down Expand Up @@ -140,7 +140,7 @@ export function serialiseBuffer(
try {
// Can it be safely stored and recreated in YAML?
const recreatedBuffer = Buffer.from(
yaml.safeLoad(yaml.safeDump(utf8Representation)),
yaml.safeLoad(yaml.safeDump(utf8Representation)) as string,
"utf8"
);
if (Buffer.compare(buffer, recreatedBuffer) === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/rewrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class RewriteRules {
if (typeof value === "object" && value !== null) {
// If the object is an array, iterate through each element and call the function recursively
if (Array.isArray(value)) {
return (value.map((v) => this._apply(v)) as any) as T;
return value.map((v) => this._apply(v)) as any as T;
}

// If the object is not an array, create a new object with the same keys,
Expand All @@ -55,7 +55,7 @@ export class RewriteRules {
for (const rule of this.rules) {
s = rule.apply(value);
}
return (s as any) as T;
return s as any as T;
} else {
return value;
}
Expand Down
78 changes: 6 additions & 72 deletions src/tests/passthrough.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,42 +69,9 @@ describe("Passthrough with grpc-web+json unframing with explicit whitelisted hos

test("unframes a grpc-web+json request", async () => {
const requestBody = Buffer.from([
0,
0,
0,
0,
31,
123,
34,
101,
109,
97,
105,
108,
34,
58,
34,
102,
111,
111,
46,
98,
97,
114,
64,
101,
120,
97,
109,
112,
108,
101,
46,
99,
111,
109,
34,
125,
0, 0, 0, 0, 31, 123, 34, 101, 109, 97, 105, 108, 34, 58, 34, 102, 111,
111, 46, 98, 97, 114, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111,
109, 34, 125,
]);
const response = await axios.post(
`${PROXAY_HOST}${GRPC_WEB_JSON_PATH}`,
Expand Down Expand Up @@ -154,42 +121,9 @@ describe("Passthrough with grpc-web+json unframing with wildcard whitelisted hos

test("unframes a grpc-web+json request", async () => {
const requestBody = Buffer.from([
0,
0,
0,
0,
31,
123,
34,
101,
109,
97,
105,
108,
34,
58,
34,
102,
111,
111,
46,
98,
97,
114,
64,
101,
120,
97,
109,
112,
108,
101,
46,
99,
111,
109,
34,
125,
0, 0, 0, 0, 31, 123, 34, 101, 109, 97, 105, 108, 34, 58, 34, 102, 111,
111, 46, 98, 97, 114, 64, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111,
109, 34, 125,
]);
const response = await axios.post(
`${PROXAY_HOST}${GRPC_WEB_JSON_PATH}`,
Expand Down
6 changes: 2 additions & 4 deletions src/tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function setupServers({
}
});

beforeAll(async (done) => {
beforeAll(async () => {
servers.backend = new TestServer();
servers.proxy = new RecordReplayServer({
initialMode: mode,
Expand All @@ -43,12 +43,10 @@ export function setupServers({
servers.proxy.start(PROXAY_PORT),
servers.backend.start(TEST_SERVER_PORT),
]);
done();
});

afterAll(async (done) => {
afterAll(async () => {
await Promise.all([servers.backend.stop(), servers.proxy.stop()]);
done();
});

return servers;
Expand Down
9 changes: 1 addition & 8 deletions src/tests/testserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ export const JSON_IDENTITY_PATH = "/json/identity";
export const BINARY_PATH = "/binary";
export const BINARY_RESPONSE = Buffer.from([
// These are not valid UTF-8 characters, on purpose.
12,
48,
249,
104,
255,
33,
203,
179,
12, 48, 249, 104, 255, 33, 203, 179,
]);

export const GRPC_WEB_JSON_PATH = "/grpc-web-json";
Expand Down
Loading