Skip to content

Commit

Permalink
V2: Fix Connect-Query v2.0.0-beta.1 in connect-migrate (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Oct 10, 2024
1 parent f637557 commit bc11967
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 70 deletions.
117 changes: 58 additions & 59 deletions packages/connect-migrate/src/migrations/v2.0.0.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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",
Expand All @@ -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
`,
),
Expand Down
21 changes: 10 additions & 11 deletions packages/connect-migrate/src/migrations/v2.0.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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,
},
},
];
Expand Down

0 comments on commit bc11967

Please sign in to comment.