"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 _pluginLibWebpackServe = _interopRequireDefault(require("@start/plugin-lib-webpack-serve"));

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

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

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

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

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

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

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

var _isWorkspace = _interopRequireDefault(require("./utils/isWorkspace"));

var _buildPackages = _interopRequireDefault(require("./plugins/buildPackages"));

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

/**
 * Run development build on local machine with hot module reloading on
 * @param force
 */
var _default = /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2.default)(function* ({
    port,
    force,
    theme = null,
    i18n = null,
    customScript = null
  }) {
    if (yield (0, _isWorkspace.default)()) {
      return (0, _pluginSequence.default)((0, _buildInfo.default)(['node', 'yarn'], {
        force
      }), (0, _buildPackages.default)(true));
    } else {
      const webpackConfig = require('../configs/webpack/webpack.config.development');

      webpackConfig.serve.port = port;
      return (0, _pluginSequence.default)((0, _buildInfo.default)(['node', 'yarn'], {
        force
      }), (0, _pluginEnv.default)({
        THEME: theme
      }), (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, _pluginLibWebpackServe.default)({
        config: webpackConfig
      }));
    }
  });

  return function (_x) {
    return _ref.apply(this, arguments);
  };
}();

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