|
|
@ -1,6 +1,7 @@ |
|
|
|
import { promises as fs } from 'fs'; |
|
|
|
import { promises as fs } from 'fs'; |
|
|
|
import path from 'path'; |
|
|
|
import path from 'path'; |
|
|
|
import axios from 'axios'; |
|
|
|
import axios from 'axios'; |
|
|
|
|
|
|
|
import type { AxiosResponse } from 'axios'; |
|
|
|
|
|
|
|
|
|
|
|
const sqliteFilePath = (parallelId: string) => { |
|
|
|
const sqliteFilePath = (parallelId: string) => { |
|
|
|
const rootDir = process.cwd(); |
|
|
|
const rootDir = process.cwd(); |
|
|
@ -46,15 +47,28 @@ const resetMetaSakilaSqliteProject = async ({ |
|
|
|
|
|
|
|
|
|
|
|
if (!isEmptyProject) await seedSakilaSqliteFile(parallelId); |
|
|
|
if (!isEmptyProject) await seedSakilaSqliteFile(parallelId); |
|
|
|
|
|
|
|
|
|
|
|
await createProject(token, title, parallelId); |
|
|
|
await createProject(token, title, parallelId, isEmptyProject); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const createProject = async ( |
|
|
|
const createProject = async ( |
|
|
|
token: string, |
|
|
|
token: string, |
|
|
|
title: string, |
|
|
|
title: string, |
|
|
|
parallelId: string, |
|
|
|
parallelId: string, |
|
|
|
|
|
|
|
isEmptyProject: boolean, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
const response = await axios.post( |
|
|
|
let response: AxiosResponse; |
|
|
|
|
|
|
|
if (isEmptyProject) { |
|
|
|
|
|
|
|
response = await axios.post( |
|
|
|
|
|
|
|
'http://localhost:8080/api/v1/db/meta/projects/', |
|
|
|
|
|
|
|
{ title }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
'xc-auth': token, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
response = await axios.post( |
|
|
|
'http://localhost:8080/api/v1/db/meta/projects/', |
|
|
|
'http://localhost:8080/api/v1/db/meta/projects/', |
|
|
|
sakilaProjectConfig(title, parallelId), |
|
|
|
sakilaProjectConfig(title, parallelId), |
|
|
|
{ |
|
|
|
{ |
|
|
@ -63,6 +77,7 @@ const createProject = async ( |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
if (response.status !== 200) { |
|
|
|
if (response.status !== 200) { |
|
|
|
console.error('Error creating project', response.data); |
|
|
|
console.error('Error creating project', response.data); |
|
|
|
} |
|
|
|
} |
|
|
|