"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCreateTask = void 0;
const upath_1 = require("upath");
const I18n_1 = require("../../../modules/I18n");
function getCreateTask(baseDir, layoutsDir, layoutName, options) {
    var _a, _b;
    const isUpdateEnabled = Boolean((_b = (_a = options.target) !== null && _a !== void 0 ? _a : options.theme) !== null && _b !== void 0 ? _b : options.scheme);
    const buildDir = upath_1.join(baseDir, 'build', options.command);
    const { fromMasterTemplate } = options;
    const ctx = {
        layoutPath: fromMasterTemplate ? baseDir : upath_1.join(baseDir, layoutsDir, layoutName),
        dest: upath_1.join(buildDir, layoutName),
        baseDir,
        buildDir,
        layoutName,
        options,
    };
    return {
        title: I18n_1.default.info('CREATE_TASK_TITLE', options.command, layoutName),
        subtasks: [
            {
                title: I18n_1.default.info('CREATE_SUBTASK_VALIDATE'),
                taskData: {
                    method: 'validateLayout',
                },
            },
            {
                title: I18n_1.default.info('CREATE_SUBTASK_GENERATE'),
                taskData: {
                    method: 'initTemplate',
                },
            },
            {
                title: I18n_1.default.info('CREATE_SUBTASK_UPDATE'),
                taskData: {
                    method: 'updateSettings',
                },
                enabled: isUpdateEnabled,
            },
            {
                title: I18n_1.default.info('CREATE_SUBTASK_LINK'),
                taskData: {
                    method: 'linkModules',
                },
            },
            {
                title: I18n_1.default.info('CREATE_SUBTASK_BUILD'),
                taskData: {
                    method: 'build',
                },
            },
            {
                title: I18n_1.default.info('CREATE_SUBTASK_ARCHIVE'),
                taskData: {
                    method: 'archive',
                },
                enabled: options.archive,
            },
        ],
        subtasksOptions: { concurrent: false, ctx },
    };
}
exports.getCreateTask = getCreateTask;
//# sourceMappingURL=getCreateTask.js.map