text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.default = void 0;
  
  function _react() {
    const data = _interopRequireDefault(require("react"));
  
    _react = function _react() {
      return data;
    };
  
    return data;
  }
  
  function _path() {
    const data = require("path");
  
    _path = function _path() {
      return data;
    };
  
    return data;
  }
  
  function _randomColor() {
    const data = _interopRequireDefault(require("random-color"));
  
    _randomColor = function _randomColor() {
      return data;
    };
  
    return data;
  }
  
  function _assert() {
    const data = _interopRequireDefault(require("assert"));
  
    _assert = function _assert() {
      return data;
    };
  
    return data;
  }
  
  function _chalk() {
    const data = _interopRequireDefault(require("chalk"));
  
    _chalk = function _chalk() {
      return data;
    };
  
    return data;
  }
  
  function _getUserConfig() {
    const data = require("umi-core/lib/getUserConfig");
  
    _getUserConfig = function _getUserConfig() {
      return data;
    };
  
    return data;
  }
  
  var _writeNewRoute = _interopRequireDefault(require("../../../../../utils/writeNewRoute"));
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  var _default = api => {
    const paths = api.paths,
          config = api.config,
          log = api.log,
          cwd = api.cwd;
    return class Generator extends api.Generator {
      constructor(args, options) {
        super(args, options);
        (0, _assert().default)(typeof this.args[0] === 'string', `
  ${_chalk().default.underline.cyan('name')} should be supplied
  
  Example: 
  
    umi g page users
          `.trim());
      }
  
      writing() {
        const path = this.args[0].toString();
        const jsxExt = this.isTypeScript ? 'tsx' : 'js';
        const cssExt = this.options.less ? 'less' : 'css';
        const context = {
          name: (0, _path().basename)(path),
          color: (0, _randomColor().default)().hexString(),
          isTypeScript: this.isTypeScript,
          cssExt,
          jsxExt
        };
        this.fs.copyTpl(this.templatePath('page.js.tpl'), (0, _path().join)(paths.absPagesPath, `${path}.${jsxExt}`), context);
        this.fs.copyTpl(this.templatePath('page.css.tpl'), (0, _path().join)(paths.absPagesPath, `${path}.${cssExt}`), context);
  
        if (config.routes) {
          (0, _writeNewRoute.default)({
            path: `/${path === 'index' ? '' : path}`,
            component: `./${path}`
          }, (0, _getUserConfig().getConfigFile)(cwd), paths.absSrcPath); // log.warn(
          //   `You should config the routes in config.routes manunally since ${chalk.red(
          //     'config.routes',
          //   )} exists`,
          // );
  
          console.log();
        }
      }
  
    };
  };
  
  exports.default = _default;