The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Follow up dev and build (#17364)
martmulle72f652723da
diff --git a/packages/create-twenty-app/src/constants/base-application/tsconfig.json b/packages/create-twenty-app/src/constants/base-application/tsconfig.jsonindex 07fd3e1d2d6..3816867c053 100644--- a/packages/create-twenty-app/src/constants/base-application/tsconfig.json+++ b/packages/create-twenty-app/src/constants/base-application/tsconfig.json@@ -22,6 +22,10 @@"skipLibCheck": true,"skipDefaultLibCheck": true,"resolveJsonModule": true,+ "paths": {+ "src/*": ["./src/*"],+ "~/*": ["./*"]+ }},"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]}diff --git a/packages/create-twenty-app/src/utils/__tests__/app-template.spec.ts b/packages/create-twenty-app/src/utils/__tests__/app-template.spec.tsindex 4bd1d24fa4a..1f5cae81179 100644--- a/packages/create-twenty-app/src/utils/__tests__/app-template.spec.ts+++ b/packages/create-twenty-app/src/utils/__tests__/app-template.spec.ts@@ -41,7 +41,7 @@ describe('copyBaseApplicationProject', () => {});// Verify src/app/ folder exists- const srcAppPath = join(testAppDirectory, 'src', 'app');+ const srcAppPath = join(testAppDirectory, 'src');expect(await fs.pathExists(srcAppPath)).toBe(true);// Verify application.config.ts exists in src/app/@@ -114,7 +114,6 @@ describe('copyBaseApplicationProject', () => {const appConfigPath = join(testAppDirectory,'src',- 'app','application.config.ts',);const appConfigContent = await fs.readFile(appConfigPath, 'utf8');@@ -127,7 +126,7 @@ describe('copyBaseApplicationProject', () => {// Verify it imports the role identifierexpect(appConfigContent).toContain(- "import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from './default-function.role'",+ "import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from 'src/default-function.role'",);// Verify display name and description@@ -156,7 +155,6 @@ describe('copyBaseApplicationProject', () => {const roleConfigPath = join(testAppDirectory,'src',- 'app','default-function.role.ts',);const roleConfigContent = await fs.readFile(roleConfigPath, 'utf8');@@ -216,7 +214,6 @@ describe('copyBaseApplicationProject', () => {const appConfigPath = join(testAppDirectory,'src',- 'app','application.config.ts',);const appConfigContent = await fs.readFile(appConfigPath, 'utf8');@@ -247,11 +244,11 @@ describe('copyBaseApplicationProject', () => {// Read both app configsconst firstAppConfig = await fs.readFile(- join(firstAppDir, 'src', 'app', 'application.config.ts'),+ join(firstAppDir, 'src', 'application.config.ts'),'utf8',);const secondAppConfig = await fs.readFile(- join(secondAppDir, 'src', 'app', 'application.config.ts'),+ join(secondAppDir, 'src', 'application.config.ts'),'utf8',);@@ -289,11 +286,11 @@ describe('copyBaseApplicationProject', () => {// Read both role configsconst firstRoleConfig = await fs.readFile(- join(firstAppDir, 'src', 'app', 'default-function.role.ts'),+ join(firstAppDir, 'src', 'default-function.role.ts'),'utf8',);const secondRoleConfig = await fs.readFile(- join(secondAppDir, 'src', 'app', 'default-function.role.ts'),+ join(secondAppDir, 'src', 'default-function.role.ts'),'utf8',);diff --git a/packages/create-twenty-app/src/utils/app-template.ts b/packages/create-twenty-app/src/utils/app-template.tsindex a563df1ee1b..4e2223c2862 100644--- a/packages/create-twenty-app/src/utils/app-template.ts+++ b/packages/create-twenty-app/src/utils/app-template.ts@@ -2,7 +2,7 @@ import * as fs from 'fs-extra';import { join } from 'path';import { v4 } from 'uuid';-const APP_FOLDER = 'src/app';+const APP_FOLDER = 'src';export const copyBaseApplicationProject = async ({appName,@@ -36,6 +36,10 @@ export const copyBaseApplicationProject = async ({appDirectory: appFolderPath,});+ await createDefaultFunction({+ appDirectory: appFolderPath,+ });+await createApplicationConfig({displayName: appDisplayName,description: appDescription,@@ -67,6 +71,7 @@ generated# dev/dist/+.twenty# production/build@@ -139,7 +144,7 @@ export const HelloWorld = () => {export default defineFrontComponent({universalIdentifier: '${universalIdentifier}',- name: 'hello-world',+ name: 'hello-world-front-component',description: 'A sample front component',component: HelloWorld,});@@ -151,6 +156,41 @@ export default defineFrontComponent({);};+const createDefaultFunction = async ({+ appDirectory,+}: {+ appDirectory: string;+}) => {+ const universalIdentifier = v4();+ const triggerUniversalIdentifier = v4();++ const content = `import { defineFunction } from 'twenty-sdk';++const handler = async (): Promise<{ message: string }> => {+ return { message: 'Hello, World!' };+};++export default defineFunction({+ universalIdentifier: '${universalIdentifier}',+ name: 'hello-world-function',+ description: 'A sample serverless function',+ timeoutSeconds: 5,+ handler,+ triggers: [+ {+ universalIdentifier: '${triggerUniversalIdentifier}',+ type: 'route',+ path: '/hello-world-function',+ httpMethod: 'GET',+ isAuthRequired: false,+ },+ ],+});+`;++ await fs.writeFile(join(appDirectory, 'hello-world.function.ts'), content);+};+const createApplicationConfig = async ({displayName,description,@@ -161,7 +201,7 @@ const createApplicationConfig = async ({appDirectory: string;}) => {const content = `import { defineApp } from 'twenty-sdk';-import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from './default-function.role';+import { DEFAULT_FUNCTION_ROLE_UNIVERSAL_IDENTIFIER } from 'src/default-function.role';export default defineApp({universalIdentifier: '${v4()}',diff --git a/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-front-component-base-file.spec.ts b/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-front-component-base-file.spec.tsindex 05984e693c3..aca1faa8a8c 100644--- a/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-front-component-base-file.spec.ts+++ b/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-front-component-base-file.spec.ts@@ -16,9 +16,9 @@ describe('getFrontComponentBaseFile', () => {"universalIdentifier: '71e45a58-41da-4ae4-8b73-a543c0a9d3d4'",);expect(result).toContain("name: 'my-component'");- expect(result).toContain('component: HelloWorld,');+ expect(result).toContain('component: Component,');- expect(result).toContain('export const HelloWorld = () => {');+ expect(result).toContain('const Component = () => {');expect(result).toContain("description: 'Add a description for your front component'",@@ -49,7 +49,7 @@ describe('getFrontComponentBaseFile', () => {});expect(result).toContain('<div');- expect(result).toContain('<h1>Hello, World!</h1>');+ expect(result).toContain('<h1>My new component!</h1>');expect(result).toContain('</div>');});});diff --git a/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-function-base-file.spec.ts b/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-function-base-file.spec.tsindex 54604a2fbd2..c901d7790f0 100644--- a/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-function-base-file.spec.ts+++ b/packages/twenty-sdk/src/cli/utilities/entity/utils/__tests__/get-function-base-file.spec.ts@@ -18,7 +18,7 @@ describe('getFunctionBaseFile', () => {expect(result).toContain('handler,');expect(result).toContain('triggers: [');- expect(result).toContain('export const handler = async');+ expect(result).toContain('const handler = async');expect(result).toContain("description: 'Add a description for your function'",diff --git a/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-front-component-template.ts b/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-front-component-template.tsindex b872db8bdea..7e62be4aaaa 100644--- a/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-front-component-template.ts+++ b/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-front-component-template.ts@@ -13,10 +13,10 @@ export const getFrontComponentBaseFile = ({return `import { defineFrontComponent } from 'twenty-sdk';// React component - implement your UI here-export const HelloWorld = () => {+const Component = () => {return (<div style={{ padding: '20px', fontFamily: 'sans-serif' }}>- <h1>Hello, World!</h1>+ <h1>My new component!</h1><p>This is your front component: ${kebabCaseName}</p></div>);@@ -26,7 +26,7 @@ export default defineFrontComponent({universalIdentifier: '${universalIdentifier}',name: '${kebabCaseName}',description: 'Add a description for your front component',- component: HelloWorld,+ component: Component,});`;};diff --git a/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-function-template.ts b/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-function-template.tsindex b2dcf00c824..a6d8695f1de 100644--- a/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-function-template.ts+++ b/packages/twenty-sdk/src/cli/utilities/entity/utils/entity-function-template.ts@@ -14,7 +14,7 @@ export const getFunctionBaseFile = ({return `import { defineFunction } from 'twenty-sdk';// Handler function - rename and implement your logic-export const handler = async (params: {+const handler = async (params: {a: string;b: number;}): Promise<{ message: string }> => {