#!/usr/bin/env node
// (C) 2021-2023 GoodData Corporation
const path = require('path');
const { logLn } = require('./logger');
const { exportTigerFixture } = require('./fixture_tiger');

require('./helpers/env');

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(__dirname, `./assets/fixtures/TigerLayout/tiger_${fixtureType}_declarative_layout.json`);
    await exportTigerFixture(
        fixtureType,
        testWorkspaceId,
        tigerApiToken,
        host,
        sdkBackend,
        fixtureFile,
    );

    logLn('Export workspace fixtures successfully');
}

module.exports = {
    exportTigerWorkspaceToFixture
};
