#!/usr/bin/env node
// (C) 2021-2023 GoodData Corporation
import path from 'path';
import { fileURLToPath } from 'url';
import { logLn } from './logger.mjs';
import { exportTigerFixture } from './fixture_tiger.js';
import './helpers/env.mjs';

async function exportTigerWorkspaceToFixture(
    host, tigerApiToken, testWorkspaceId, sdkBackend, fixtureType
) {
    if (!testWorkspaceId) {
        logLn('TEST_WORKSPACE_ID not specified in the .env file. Skipping.');
        return;
    }

    const fixtureFile = path.join(path.dirname(fileURLToPath(import.meta.url)), `./assets/fixtures/TigerLayout/tiger_${fixtureType}_declarative_layout.json`);
    await exportTigerFixture(
        fixtureType,
        testWorkspaceId,
        tigerApiToken,
        host,
        sdkBackend,
        fixtureFile,
    );

    logLn('Export workspace fixtures successfully');
}

export {
    exportTigerWorkspaceToFixture
};
