Remove twenty-sdk from package.json before build (#21305)
Follow up of https://github.com/twentyhq/twenty/pull/21179 Removes twenty-sdk from dependencies when building lambda layer
This commit is contained in:
+27
-1
@@ -4,7 +4,6 @@ import crypto from 'crypto';
|
||||
import { promises as fs } from 'fs';
|
||||
import { dirname, join } from 'path';
|
||||
import { type QueryRunner } from 'typeorm';
|
||||
|
||||
import { FileFolder } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
@@ -299,6 +298,33 @@ export class LogicFunctionResourceService {
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
await this.removeBuildTimeSdkFromDependencies(
|
||||
join(inMemoryFolderPath, 'package.json'),
|
||||
);
|
||||
}
|
||||
|
||||
private async removeBuildTimeSdkFromDependencies(
|
||||
packageJsonPath: string,
|
||||
): Promise<void> {
|
||||
const packageJson = JSON.parse(
|
||||
await fs.readFile(packageJsonPath, 'utf-8'),
|
||||
) as { dependencies?: Record<string, string> };
|
||||
|
||||
const dependencies = packageJson.dependencies;
|
||||
const sdkVersionRange = dependencies?.['twenty-sdk'];
|
||||
|
||||
if (!isDefined(dependencies) || !isDefined(sdkVersionRange)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete dependencies['twenty-sdk'];
|
||||
|
||||
await fs.writeFile(
|
||||
packageJsonPath,
|
||||
`${JSON.stringify(packageJson, null, 2)}\n`,
|
||||
'utf-8',
|
||||
);
|
||||
}
|
||||
|
||||
async getBuiltCode({
|
||||
|
||||
Reference in New Issue
Block a user