Skip to content

Commit 57dc1ae

Browse files
authored
Fix create twenty app template (#16708)
Adds a default function role to scaffolded application
1 parent 936b803 commit 57dc1ae

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

packages/create-twenty-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-twenty-app",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Command-line interface to create Twenty application",
55
"main": "dist/cli.cjs",
66
"bin": "dist/cli.cjs",

packages/create-twenty-app/src/utils/app-template.ts

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as fs from 'fs-extra';
22
import { join } from 'path';
33
import { v4 } from 'uuid';
44

5+
const SOURCE_FOLDER = 'src';
6+
57
export const copyBaseApplicationProject = async ({
68
appName,
79
appDisplayName,
@@ -21,10 +23,23 @@ export const copyBaseApplicationProject = async ({
2123

2224
await createYarnLock(appDirectory);
2325

26+
const sourceFolderPath = join(appDirectory, SOURCE_FOLDER);
27+
28+
await fs.ensureDir(sourceFolderPath);
29+
30+
const defaultServerlessFunctionRoleUniversalIdentifier = v4();
31+
32+
await createDefaultServerlessFunctionRoleConfig({
33+
displayName: appDisplayName,
34+
appDirectory: sourceFolderPath,
35+
defaultServerlessFunctionRoleUniversalIdentifier,
36+
});
37+
2438
await createApplicationConfig({
2539
displayName: appDisplayName,
2640
description: appDescription,
27-
appDirectory,
41+
appDirectory: sourceFolderPath,
42+
defaultServerlessFunctionRoleUniversalIdentifier,
2843
});
2944
};
3045

@@ -76,21 +91,49 @@ yarn-error.log*
7691
await fs.writeFile(join(appDirectory, '.gitignore'), gitignoreContent);
7792
};
7893

94+
const createDefaultServerlessFunctionRoleConfig = async ({
95+
displayName,
96+
appDirectory,
97+
defaultServerlessFunctionRoleUniversalIdentifier,
98+
}: {
99+
displayName: string;
100+
appDirectory: string;
101+
defaultServerlessFunctionRoleUniversalIdentifier: string;
102+
}) => {
103+
const content = `import { PermissionFlag, type RoleConfig } from 'twenty-sdk';
104+
105+
export const functionRole: RoleConfig = {
106+
universalIdentifier: '${defaultServerlessFunctionRoleUniversalIdentifier}',
107+
label: '${displayName} default function role',
108+
description: '${displayName} default function role',
109+
canReadAllObjectRecords: true,
110+
canUpdateAllObjectRecords: true,
111+
canSoftDeleteAllObjectRecords: true,
112+
canDestroyAllObjectRecords: false,
113+
};
114+
`;
115+
116+
await fs.writeFile(join(appDirectory, 'role.config.ts'), content);
117+
};
118+
79119
const createApplicationConfig = async ({
80120
displayName,
81121
description,
82122
appDirectory,
123+
defaultServerlessFunctionRoleUniversalIdentifier,
83124
}: {
84125
displayName: string;
85126
description?: string;
86127
appDirectory: string;
128+
defaultServerlessFunctionRoleUniversalIdentifier: string;
87129
}) => {
88130
const content = `import { type ApplicationConfig } from 'twenty-sdk';
89131
90132
const config: ApplicationConfig = {
91133
universalIdentifier: '${v4()}',
92134
displayName: '${displayName}',
93135
description: '${description ?? ''}',
136+
functionRoleUniversalIdentifier: '${defaultServerlessFunctionRoleUniversalIdentifier}',
94137
};
95138
96139
export default config;
@@ -127,7 +170,7 @@ const createPackageJson = async ({
127170
auth: 'twenty auth login',
128171
},
129172
dependencies: {
130-
'twenty-sdk': '0.2.2',
173+
'twenty-sdk': '0.2.3',
131174
},
132175
devDependencies: {
133176
'@types/node': '^24.7.2',

packages/twenty-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twenty-sdk",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"main": "dist/index.cjs",
55
"module": "dist/index.mjs",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)