Move twenty-client-sdk to dev dep (#21611)
# Introduction The `twenty-client-sdk` is always provided and injected at runtime by the twenty-server instance Which mean that even if in your app locally you're using twenty-client-sdk `1.0` installing this app on twenty instance `2.0` will result in injecting another `twenty-client-sdk` That's the expected behavior and tradeof The twenty-app devdep should only be used to guide local devxp following typesafety and so on A user can still locally generated its own twenty-client-sdk and publish it if necessary <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/21611?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This commit is contained in:
+19
-3
@@ -304,6 +304,11 @@ export class LogicFunctionResourceService {
|
||||
);
|
||||
}
|
||||
|
||||
// twenty-sdk is build-time only and twenty-client-sdk is injected at runtime
|
||||
// by Twenty (Lambda SDK layer / server-served modules), so neither needs to
|
||||
// be resolved by the Lambda yarn install. Apps should already declare them as
|
||||
// devDependencies (skipped by `yarn workspaces focus --production`); this is a
|
||||
// safety net for apps that still list them under "dependencies".
|
||||
private async removeBuildTimeSdkFromDependencies(
|
||||
packageJsonPath: string,
|
||||
): Promise<void> {
|
||||
@@ -312,13 +317,24 @@ export class LogicFunctionResourceService {
|
||||
) as { dependencies?: Record<string, string> };
|
||||
|
||||
const dependencies = packageJson.dependencies;
|
||||
const sdkVersionRange = dependencies?.['twenty-sdk'];
|
||||
|
||||
if (!isDefined(dependencies) || !isDefined(sdkVersionRange)) {
|
||||
if (!isDefined(dependencies)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete dependencies['twenty-sdk'];
|
||||
const packagesToRemove = ['twenty-sdk', 'twenty-client-sdk'];
|
||||
|
||||
const packagesToRemoveFromDependencies = packagesToRemove.filter(
|
||||
(packageName) => isDefined(dependencies[packageName]),
|
||||
);
|
||||
|
||||
if (packagesToRemoveFromDependencies.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const packageName of packagesToRemoveFromDependencies) {
|
||||
delete dependencies[packageName];
|
||||
}
|
||||
|
||||
await fs.writeFile(
|
||||
packageJsonPath,
|
||||
|
||||
Reference in New Issue
Block a user