'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var fs_fs = require('../fs/fs.js');
var nodejs_fs = require('../nodejs/fs.js');
var nodejs_path = require('../nodejs/path.js');
var fs_fsUtil = require('../fs/fs-util.js');
require('../nodejs/crypto.js');
require('../nodejs/os.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../time/time.js');

/**
 * 统计页面个数
 * @example
 * statisticsPages('dist/build/mp-weixin/app.json')
 */
function statisticsPages(pagesJsonPath) {
  var pagesJson = fs_fs.readFileSync(nodejs_path.getPath().resolve(process.cwd(), pagesJsonPath), true);
  var _pagesJson$pages = pagesJson.pages,
    pages = _pagesJson$pages === void 0 ? [] : _pagesJson$pages,
    _pagesJson$subPackage = pagesJson.subPackages,
    subPackages = _pagesJson$subPackage === void 0 ? [] : _pagesJson$subPackage;
  var res = pages.length + subPackages.reduce(function (acc, item) {
    return acc + item.pages.length;
  }, 0);
  console.log('[statisticsPages] res: ', res);
  return res;
}
/**
 * 统计组件个数
 * @example
 * statisticsComponent('dist/build/mp-weixin');
 */
function statisticsComponent(dir) {
  var fs = nodejs_fs.getFs();
  var array = [];
  if (fs.existsSync(dir)) {
    fs_fsUtil.traverseFolder(function (file) {
      if (file.endsWith('.wxml')) {
        array.push(file);
      }
    }, dir);
  }
  console.log('[statisticsComponent] array.length: ', array.length);
  return array.length;
}

exports.statisticsComponent = statisticsComponent;
exports.statisticsPages = statisticsPages;
