Skip to content

Commit

Permalink
Disable migration for connect-query-es
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Stamm <ts@timostamm.de>
  • Loading branch information
timostamm committed Sep 20, 2024
1 parent 0dedf53 commit 3903f43
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 73 deletions.
121 changes: 60 additions & 61 deletions packages/connect-migrate/src/migrations/v2.0.0.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ plugins:
expect(bufGenYamlWritten.length).toBe(1);
expect(bufGenYamlWritten[0]?.yaml).toEqual(`version: v2
plugins:
- remote: buf.build/bufbuild/es:v2.0.0
- remote: buf.build/bufbuild/es:v2.1.0
out: src/gen
`);
});
Expand Down Expand Up @@ -193,62 +193,63 @@ plugins:
`);
});
});
describe("for connect-query-es v1", () => {
beforeEach(function () {
opt.scanned.packageFiles = [
{
path: "package.json",
pkg: {
dependencies: {
"@connectrpc/connect-query": "^1.4.1",
"@connectrpc/protoc-gen-connect-query": "^1.4.1",
},
},
},
];
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
out: src/gen
`);
});
});
// 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-playwright-es v1", () => {
beforeEach(function () {
opt.scanned.packageFiles = [
Expand Down Expand Up @@ -300,7 +301,6 @@ plugins:

"@connectrpc/connect-query": `^${targetVersionConnectQuery}`,
"@connectrpc/protoc-gen-connect-query": `^${targetVersionConnectQuery}`,
"@connectrpc/protoc-gen-connect-query-react": `^${targetVersionConnectQuery}`,

"@connectrpc/connect-playwright": `^${targetVersionConnectPlaywright}`,
},
Expand All @@ -322,7 +322,7 @@ plugins:
out: src/gen
- remote: buf.build/bufbuild/es:v2.0.0
out: src/gen
- remote: buf.build/connectrpc/query-es:v2.0.0
- remote: buf.build/connectrpc/query-es:v1.4.2
out: src/gen
`,
"buf.gen.yaml",
Expand All @@ -342,7 +342,7 @@ plugins:
out: src/gen
- plugin: buf.build/bufbuild/es:v2.0.0
out: src/gen
- plugin: buf.build/connectrpc/query-es:v2.0.0
- plugin: buf.build/connectrpc/query-es:v1.4.2
out: src/gen
`,
),
Expand Down Expand Up @@ -418,7 +418,6 @@ plugins:
dependencies: {
"@bufbuild/connect-query": "*",
"@bufbuild/protoc-gen-connect-query": "*",
"@bufbuild/protoc-gen-connect-query-react": "*",
},
},
},
Expand Down
27 changes: 15 additions & 12 deletions packages/connect-migrate/src/migrations/v2.0.0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { writeBufGenYamlFile } from "../lib/bufgenyaml";

export const targetVersionProtobufEs = "2.1.0";
export const targetVersionConnectEs = "2.0.0-alpha.1"; // TODO
export const targetVersionConnectQuery = "1.4.2"; // TODO
export const targetVersionConnectPlaywright = "0.3.2"; // TODO
export const targetVersionConnectQuery = "2.0.0"; // TODO
export const targetVersionConnectPlaywright = "0.4.0"; // TODO

const dependencyMigrations: DependencyMigration[] = [
// https://github.com/bufbuild/protobuf-es
Expand Down Expand Up @@ -83,15 +83,16 @@ const dependencyMigrations: DependencyMigration[] = [
remove: { name: "@connectrpc/protoc-gen-connect-es", range: "^1.0.0" },
},

// 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 },
},
// 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-playwright-es
{
Expand Down Expand Up @@ -133,7 +134,9 @@ export const v2_0_0: Migration = {
({ yaml }) => migrateBufGenYaml(yaml, bufGenYamlMigrations) !== null,
) ||
scanned.packageFiles.some(
({ pkg }) => migrateDependencies(pkg, dependencyMigrations) !== null,
({ pkg }) =>
migrateDependencies(structuredClone(pkg), dependencyMigrations) !==
null,
)
);
},
Expand Down

0 comments on commit 3903f43

Please sign in to comment.