Skip to content

Commit

Permalink
refactor(infra): remove hack moncomptepro imports
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Sep 20, 2024
1 parent 4c09935 commit 03b1c8a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 45 deletions.
20 changes: 20 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//

import { $ } from "bun";

const minify = true;

{
Expand Down Expand Up @@ -41,4 +43,22 @@ const minify = true;
console.log({ logs, outputs, success });
}

{
console.log("> @numerique-gouv/moncomptepro install");
const { stdout } = await $`npm i`
.cwd("node_modules/@numerique-gouv/moncomptepro")
.env({
...process.env,
CYPRESS_INSTALL_BINARY: "0",
});
console.log(stdout.toString());
}
{
console.log("> @numerique-gouv/moncomptepro build");
const { stdout } = await $`npm exec tsc`.cwd(
"node_modules/@numerique-gouv/moncomptepro",
);
console.log(stdout.toString());
}

export {};
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/~/infra/moncomptepro/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"dependencies": {
"@numerique-gouv/moncomptepro": "numerique-gouv/moncomptepro#f26af544c636f071bf6efc4343bfe4f9e98fddb5",
"@numerique-gouv/moncomptepro": "numerique-gouv/moncomptepro#0769297f523ad4a57ba878cb57be27dcecbbf896",
"@~/app.core": "workspace:*",
"consola": "3.2.3",
"zod": "3.23.8"
Expand Down
47 changes: 3 additions & 44 deletions packages/~/infra/moncomptepro/lib/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
//

import type Pg from "pg";
import type { MCP_EmailDomain_Type } from "./moncomptepro";

//
//
//

// HACK(douglasduteil): disable typescript check on @numerique-gouv/moncomptepro
//
// As the @numerique-gouv/moncomptepro/database is not yet published as a standalone package
// we need to disable the typescript check on it to avoid many typescript errors
//

const MONCOMPTEPRO_MODULE = "@numerique-gouv/moncomptepro";

// import "@numerique-gouv/moncomptepro/src/connectors/postgres";
const POSTGRES_CONNECTOR_MODULE: {
setDatabaseConnection(newPool: Pg.Pool): void;
} = await import(`${MONCOMPTEPRO_MODULE}/src/connectors/postgres`);

// import "@numerique-gouv/moncomptepro/src/managers/organization/main";
const MAIN_ORGANIZATION_MANAGER_MODULE: {
markDomainAsVerified(options: {
organization_id: number;
domain: string;
domain_verification_type: MCP_EmailDomain_Type;
}): Promise<void>;
} = await import(`${MONCOMPTEPRO_MODULE}/src/managers/organization/main`);

// import "@numerique-gouv/moncomptepro/src/managers/organization/join";
const JOIN_ORGANIZATION_MANAGER_MODULE: {
forceJoinOrganization(options: {
organization_id: number;
user_id: number;
is_external?: boolean;
}): Promise<UserOrganizationLink>;
} = await import(`${MONCOMPTEPRO_MODULE}/src/managers/organization/join`);

//
//
//

export const setDatabaseConnection =
POSTGRES_CONNECTOR_MODULE.setDatabaseConnection;
export const markDomainAsVerified =
MAIN_ORGANIZATION_MANAGER_MODULE.markDomainAsVerified;
export const forceJoinOrganization =
JOIN_ORGANIZATION_MANAGER_MODULE.forceJoinOrganization;
export { setDatabaseConnection } from "@numerique-gouv/moncomptepro/connectors/postgres";
export { forceJoinOrganization } from "@numerique-gouv/moncomptepro/managers/organization/join";
export { markDomainAsVerified } from "@numerique-gouv/moncomptepro/managers/organization/markDomainAsVerified";

0 comments on commit 03b1c8a

Please sign in to comment.