From 96edde3ff3da91da75a906a7c7e09cda48261925 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Tue, 9 Apr 2024 17:17:56 -0500 Subject: [PATCH 1/3] chore: use non-deprecated vscode setting --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2472a73d7..c256ef48a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" }, "editor.defaultFormatter": "esbenp.prettier-vscode", From c755ef05caa0c2e3664c9dd09583a82db7adc877 Mon Sep 17 00:00:00 2001 From: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:39:20 -0500 Subject: [PATCH 2/3] fix(breaking): always return array (#225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🧰 Changes I had DX concerns about the `string[] | string` setup in the `.convert()` method and talked offline with @erunion and agreed that it should always return a `string[]`, so this PR makes that change. This is a breaking change. ## 🧬 QA & Testing Is this everything? I saw this line below but I think it's unrelated so I left it, but let me know if I'm wrong about this. https://github.com/readmeio/httpsnippet/blob/fc92e4000714ec677bbf712fc9537fd616e8ae65/src/targets/index.ts#L41 --- src/fixtures/runCustomFixtures.ts | 2 +- src/index.ts | 2 +- src/targets/index.test.ts | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fixtures/runCustomFixtures.ts b/src/fixtures/runCustomFixtures.ts index faf323aa5..60a665d8f 100644 --- a/src/fixtures/runCustomFixtures.ts +++ b/src/fixtures/runCustomFixtures.ts @@ -31,7 +31,7 @@ export const runCustomFixtures = ({ targetId, clientId, tests }: CustomFixture) } const snippet = new HTTPSnippet(request, opts); - const result = snippet.convert(targetId, clientId, options); + const result = snippet.convert(targetId, clientId, options)[0]; const filePath = path.join(__dirname, '..', 'targets', targetId, clientId, 'fixtures', fixtureFile); if (process.env.OVERWRITE_EVERYTHING) { writeFileSync(filePath, String(result)); diff --git a/src/index.ts b/src/index.ts index 5e762c840..ed8c4b0cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -334,6 +334,6 @@ export class HTTPSnippet { const { convert } = target.clientsById[clientId || target.info.default]; const results = this.requests.map(request => convert(request, options)); - return results.length === 1 ? results[0] : results; + return results; } } diff --git a/src/targets/index.test.ts b/src/targets/index.test.ts index e2e3d231d..97eaade1f 100644 --- a/src/targets/index.test.ts +++ b/src/targets/index.test.ts @@ -74,8 +74,8 @@ describe('request validation', () => { `${fixture}${extname(targetId, clientId)}`, ); - let result; - let expected; + let result: string[] | false; + let expected: string; try { const options: HTTPSnippetOptions = {}; @@ -88,7 +88,7 @@ describe('request validation', () => { expected = readFileSync(expectedPath).toString(); const snippet = new HTTPSnippet(request, options); - result = snippet.convert(targetId, clientId); + result = snippet.convert(targetId, clientId)[0]; if (OVERWRITE_EVERYTHING && result) { writeFileSync(expectedPath, String(result)); @@ -313,7 +313,7 @@ describe('addTargetClient', () => { const snippet = new HTTPSnippet(short.log.entries[0].request as Request, {}); - const result = snippet.convert('node', 'custom'); + const result = snippet.convert('node', 'custom')[0]; expect(result).toBe('This was generated from a custom client.'); }); @@ -345,7 +345,7 @@ describe('addClientPlugin', () => { const snippet = new HTTPSnippet(short.log.entries[0].request as Request, {}); - const result = snippet.convert('node', 'custom'); + const result = snippet.convert('node', 'custom')[0]; expect(result).toBe('This was generated from a custom client.'); }); From 94f9897ed06a5d514741ea3be8e99cb29c48f429 Mon Sep 17 00:00:00 2001 From: Jon Ursenbach Date: Tue, 9 Apr 2024 15:42:19 -0700 Subject: [PATCH 3/3] build: 10.0.0 release --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d637f5da..e37574c82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@readme/httpsnippet", - "version": "9.0.0", + "version": "10.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@readme/httpsnippet", - "version": "9.0.0", + "version": "10.0.0", "license": "MIT", "dependencies": { "qs": "^6.11.2", diff --git a/package.json b/package.json index 10d314ddd..baed23819 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@readme/httpsnippet", - "version": "9.0.0", + "version": "10.0.0", "description": "HTTP Request snippet generator for *most* languages", "homepage": "https://github.com/readmeio/httpsnippet", "license": "MIT",