MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / createProject

Function createProject

packages/cli/test/utils.ts:99–116  ·  view source on GitHub ↗
(
    zmodel: string,
    options?: {
        customPrelude?: boolean;
        provider?: 'sqlite' | 'postgresql' | 'mysql';
        datasourceFields?: Record<string, string | string[]>;
    },
)

Source from the content-addressed store, hash-verified

97}
98
99export 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
118export function runCli(command: string, cwd: string) {
119 const cli = path.join(__dirname, '../dist/index.mjs');

Callers 11

format.test.tsFile · 0.90
generate.test.tsFile · 0.90
check.test.tsFile · 0.90
migrate.test.tsFile · 0.90
db.test.tsFile · 0.90
pull.test.tsFile · 0.90
push.test.tsFile · 0.90

Calls 3

createTestProjectFunction · 0.90
formatDocumentFunction · 0.90
getDefaultPreludeFunction · 0.85

Tested by

no test coverage detected