From bc119674fef243304ea23b4af0bc1f143007fcc5 Mon Sep 17 00:00:00 2001 From: Timo Stamm Date: Thu, 10 Oct 2024 17:53:24 +0200 Subject: [PATCH] V2: Fix Connect-Query v2.0.0-beta.1 in connect-migrate (#1266) --- .../src/migrations/v2.0.0.spec.ts | 117 +++++++++--------- .../connect-migrate/src/migrations/v2.0.0.ts | 21 ++-- 2 files changed, 68 insertions(+), 70 deletions(-) diff --git a/packages/connect-migrate/src/migrations/v2.0.0.spec.ts b/packages/connect-migrate/src/migrations/v2.0.0.spec.ts index 84444e821..71da40abf 100644 --- a/packages/connect-migrate/src/migrations/v2.0.0.spec.ts +++ b/packages/connect-migrate/src/migrations/v2.0.0.spec.ts @@ -193,63 +193,62 @@ plugins: `); }); }); - // TODO - // describe("for connect-query-es v1", () => { - // beforeEach(function () { - // opt.scanned.packageFiles = [ - // { - // path: "package.json", - // pkg: { - // dependencies: { - // "@connectrpc/connect-query": "^1.4.2", - // "@connectrpc/protoc-gen-connect-query": "^1.4.2", - // }, - // }, - // }, - // ]; - // opt.scanned.bufGenYamlFiles = [ - // { - // path: "buf.gen.yaml", - // yaml: parseBufGenYaml( - // `version: v2 - // plugins: - // - remote: buf.build/connectrpc/query-es:v1.4.1 - // out: src/gen - // `, - // ), - // }, - // ]; - // }); - // it("should be applicable", () => { - // expect(v2_0_0.applicable(opt.scanned)).toBeTrue(); - // }); - // it("should migrate packages", () => { - // const result = v2_0_0.migrate(opt); - // expect(result).toEqual({ - // ok: true, - // }); - // expect(packageJsonWritten.length).toBe(1); - // expect(packageJsonWritten[0].pkg).toEqual({ - // dependencies: { - // "@connectrpc/connect-query": `^${targetVersionConnectQuery}`, - // "@connectrpc/protoc-gen-connect-query": `^${targetVersionConnectQuery}`, - // }, - // }); - // expect(lockFilesUpdated.length).toBe(1); - // }); - // it("should migrate buf.gen.yaml", () => { - // const result = v2_0_0.migrate(opt); - // expect(result).toEqual({ - // ok: true, - // }); - // expect(bufGenYamlWritten.length).toBe(1); - // expect(bufGenYamlWritten[0]?.yaml).toEqual(`version: v2 - // plugins: - // - remote: buf.build/connectrpc/query-es:v1.4.2 - // out: src/gen - // `); - // }); - // }); + describe("for connect-query-es v1", () => { + beforeEach(function () { + opt.scanned.packageFiles = [ + { + path: "package.json", + pkg: { + dependencies: { + "@connectrpc/connect-query": "^1.4.2", + "@connectrpc/protoc-gen-connect-query": "^1.4.2", + }, + }, + }, + ]; + opt.scanned.bufGenYamlFiles = [ + { + path: "buf.gen.yaml", + yaml: parseBufGenYaml( + `version: v2 +plugins: + - remote: buf.build/connectrpc/query-es:v1.4.1 + out: src/gen +`, + ), + }, + ]; + }); + it("should be applicable", () => { + expect(v2_0_0.applicable(opt.scanned)).toBeTrue(); + }); + it("should migrate packages", () => { + const result = v2_0_0.migrate(opt); + expect(result).toEqual({ + ok: true, + }); + expect(packageJsonWritten.length).toBe(1); + expect(packageJsonWritten[0].pkg).toEqual({ + dependencies: { + "@connectrpc/connect-query": `^${targetVersionConnectQuery}`, + "@connectrpc/protoc-gen-connect-query": `^${targetVersionConnectQuery}`, + }, + }); + expect(lockFilesUpdated.length).toBe(1); + }); + it("should migrate buf.gen.yaml", () => { + const result = v2_0_0.migrate(opt); + expect(result).toEqual({ + ok: true, + }); + expect(bufGenYamlWritten.length).toBe(1); + expect(bufGenYamlWritten[0]?.yaml).toEqual(`version: v2 +plugins: + - remote: buf.build/connectrpc/query-es:v2.0.0-beta.1 + out: src/gen +`); + }); + }); describe("for connect-playwright-es v1", () => { beforeEach(function () { opt.scanned.packageFiles = [ @@ -322,7 +321,7 @@ plugins: out: src/gen - remote: buf.build/bufbuild/es:v2.0.0 out: src/gen - - remote: buf.build/connectrpc/query-es:v1.4.2 + - remote: buf.build/connectrpc/query-es:v${targetVersionConnectQuery} out: src/gen `, "buf.gen.yaml", @@ -342,7 +341,7 @@ plugins: out: src/gen - plugin: buf.build/bufbuild/es:v2.0.0 out: src/gen - - plugin: buf.build/connectrpc/query-es:v1.4.2 + - plugin: buf.build/connectrpc/query-es:v${targetVersionConnectQuery} out: src/gen `, ), diff --git a/packages/connect-migrate/src/migrations/v2.0.0.ts b/packages/connect-migrate/src/migrations/v2.0.0.ts index 06708e6e8..e0c593c0c 100644 --- a/packages/connect-migrate/src/migrations/v2.0.0.ts +++ b/packages/connect-migrate/src/migrations/v2.0.0.ts @@ -83,16 +83,15 @@ const dependencyMigrations: DependencyMigration[] = [ remove: { name: "@connectrpc/protoc-gen-connect-es", range: "^1.0.0" }, }, - // TODO - // // https://github.com/connectrpc/connect-query-es - // { - // from: { name: "@connectrpc/connect-query", range: "^1.0.0" }, - // to: { version: targetVersionConnectQuery }, - // }, - // { - // from: { name: "@connectrpc/protoc-gen-connect-query", range: "^1.0.0" }, - // to: { version: targetVersionConnectQuery }, - // }, + // https://github.com/connectrpc/connect-query-es + { + from: { name: "@connectrpc/connect-query", range: "^1.0.0" }, + to: { version: targetVersionConnectQuery }, + }, + { + from: { name: "@connectrpc/protoc-gen-connect-query", range: "^1.0.0" }, + to: { version: targetVersionConnectQuery }, + }, // https://github.com/connectrpc/connect-playwright-es { @@ -119,7 +118,7 @@ const bufGenYamlMigrations: BufGenYamlMigration[] = [ updatePlugin: { remote: "buf.build/connectrpc/query-es", from: "^1.0.0", - to: "1.4.2", // TODO + to: targetVersionConnectQuery, }, }, ];