"use strict";

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = void 0;

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));

var _pluginSequence = _interopRequireDefault(require("@start/plugin-sequence"));

var _pluginEnv = _interopRequireDefault(require("@start/plugin-env"));

var _gitBranch = _interopRequireDefault(require("git-branch"));

var _plugin = _interopRequireDefault(require("@start/plugin"));

var _getNewPackageVersion = _interopRequireDefault(require("../utils/getNewPackageVersion"));

var _yarnInstall = _interopRequireDefault(require("./yarnInstall"));

var _buildInfo = _interopRequireDefault(require("./buildInfo"));

var _updateVersionNumber = _interopRequireDefault(require("./updateVersionNumber"));

var _build = _interopRequireDefault(require("./build"));

var _setCosmicResolutions = _interopRequireDefault(require("./setCosmicResolutions"));

var _createDoc = _interopRequireDefault(require("./createDoc"));

var _mergeTheme = _interopRequireDefault(require("./mergeTheme"));

var _runCustomScript = _interopRequireDefault(require("./runCustomScript"));

var _createConfig = _interopRequireDefault(require("./createConfig"));

var _optionalStep = _interopRequireDefault(require("./optionalStep"));

var _copyLocalization = _interopRequireDefault(require("./copyLocalization"));

var _default = ({
  force,
  nugetPackageName,
  theme = null,
  locals,
  noYarn,
  mode,
  latestCosmic,
  i18n = null,
  versionNumber = true,
  customScript = null,
  docs = null,
  apiKey = null,
  allowRelease = false,
  windowVersion = null
}) => (0, _plugin.default)('CREATE ARTIFACT', ({
  reporter
}) => /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
  let yarnParams = '--prod';

  try {
    if (_gitBranch.default && _gitBranch.default.sync() === 'develop') {
      yarnParams = '';
    }
  } catch (err) {//No git branch
  }

  const newVersion = versionNumber ? yield (0, _getNewPackageVersion.default)(nugetPackageName, 'internal-nuget-artifacts', apiKey, allowRelease) : windowVersion || 'local_build';
  return (0, _pluginSequence.default)((0, _buildInfo.default)(['node', 'yarn', 'octo', 'nuget'], {
    force
  }), (0, _pluginEnv.default)({
    THEME: theme,
    BUILD_VERSION: newVersion
  }), (0, _optionalStep.default)(Boolean(theme), _mergeTheme.default, theme, 'MERGE THEME'), (0, _createConfig.default)(), (0, _optionalStep.default)(Boolean(customScript), _runCustomScript.default, customScript, 'RUN CUSTOM SCRIPT'), (0, _optionalStep.default)(Boolean(i18n), _copyLocalization.default, null, 'COPY I18N'), (0, _optionalStep.default)(latestCosmic, _setCosmicResolutions.default, null, 'SET COSMIC RESOLUTIONS'), (0, _optionalStep.default)(versionNumber, () => (0, _updateVersionNumber.default)(newVersion), null, 'UPDATE VERSION NUMBER'), //optionalStep(!noYarn, yarnInstall, yarnParams, 'YARN INSTALL'),
  (0, _build.default)(locals, mode), (0, _optionalStep.default)(Boolean(docs), _createDoc.default, null, 'CREATE DOCS'))(reporter)();
}));

exports.default = _default;
module.exports = exports.default;