(
zmodel: string,
options?: {
customPrelude?: boolean;
provider?: 'sqlite' | 'postgresql' | 'mysql';
datasourceFields?: Record<string, string | string[]>;
},
)
| 97 | } |
| 98 | |
| 99 | export async function createProject( |
| 100 | zmodel: string, |
| 101 | options?: { |
| 102 | customPrelude?: boolean; |
| 103 | provider?: 'sqlite' | 'postgresql' | 'mysql'; |
| 104 | datasourceFields?: Record<string, string | string[]>; |
| 105 | }, |
| 106 | ) { |
| 107 | const workDir = createTestProject(); |
| 108 | fs.mkdirSync(path.join(workDir, 'zenstack'), { recursive: true }); |
| 109 | const schemaPath = path.join(workDir, 'zenstack/schema.zmodel'); |
| 110 | const content = options?.customPrelude |
| 111 | ? zmodel |
| 112 | : `${getDefaultPrelude({ provider: options?.provider, datasourceFields: options?.datasourceFields })}\n\n${zmodel}`; |
| 113 | const schema = await formatDocument(content); |
| 114 | fs.writeFileSync(schemaPath, schema); |
| 115 | return { workDir, schema }; |
| 116 | } |
| 117 | |
| 118 | export function runCli(command: string, cwd: string) { |
| 119 | const cli = path.join(__dirname, '../dist/index.mjs'); |
no test coverage detected