执行过npm install命令的vue-element-admin源码
康凯
2022-05-20 aa4c235a8ca67ea8b731f90c951a465e92c0a865
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
'use strict';
 
Object.defineProperty(exports, '__esModule', {
  value: true
});
exports.default = validateCLIOptions;
exports.DOCUMENTATION_NOTE = void 0;
 
function _chalk() {
  const data = _interopRequireDefault(require('chalk'));
 
  _chalk = function _chalk() {
    return data;
  };
 
  return data;
}
 
function _camelcase() {
  const data = _interopRequireDefault(require('camelcase'));
 
  _camelcase = function _camelcase() {
    return data;
  };
 
  return data;
}
 
var _utils = require('./utils');
 
var _deprecated = require('./deprecated');
 
var _defaultConfig = _interopRequireDefault(require('./defaultConfig'));
 
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {default: obj};
}
 
function _objectSpread(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i] != null ? arguments[i] : {};
    var ownKeys = Object.keys(source);
    if (typeof Object.getOwnPropertySymbols === 'function') {
      ownKeys = ownKeys.concat(
        Object.getOwnPropertySymbols(source).filter(function(sym) {
          return Object.getOwnPropertyDescriptor(source, sym).enumerable;
        })
      );
    }
    ownKeys.forEach(function(key) {
      _defineProperty(target, key, source[key]);
    });
  }
  return target;
}
 
function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  return obj;
}
 
const BULLET = _chalk().default.bold('\u25cf');
 
const DOCUMENTATION_NOTE = `  ${_chalk().default.bold(
  'CLI Options Documentation:'
)}
  https://jestjs.io/docs/en/cli.html
`;
exports.DOCUMENTATION_NOTE = DOCUMENTATION_NOTE;
 
const createCLIValidationError = (unrecognizedOptions, allowedOptions) => {
  let title = `${BULLET} Unrecognized CLI Parameter`;
  let message;
  const comment =
    `  ${_chalk().default.bold('CLI Options Documentation')}:\n` +
    `  https://jestjs.io/docs/en/cli.html\n`;
 
  if (unrecognizedOptions.length === 1) {
    const unrecognized = unrecognizedOptions[0];
    const didYouMeanMessage = (0, _utils.createDidYouMeanMessage)(
      unrecognized,
      Array.from(allowedOptions)
    );
    message =
      `  Unrecognized option ${_chalk().default.bold(
        (0, _utils.format)(unrecognized)
      )}.` + (didYouMeanMessage ? ` ${didYouMeanMessage}` : '');
  } else {
    title += 's';
    message =
      `  Following options were not recognized:\n` +
      `  ${_chalk().default.bold((0, _utils.format)(unrecognizedOptions))}`;
  }
 
  return new _utils.ValidationError(title, message, comment);
};
 
const logDeprecatedOptions = (deprecatedOptions, deprecationEntries, argv) => {
  deprecatedOptions.forEach(opt => {
    (0, _deprecated.deprecationWarning)(
      argv,
      opt,
      deprecationEntries,
      _objectSpread({}, _defaultConfig.default, {
        comment: DOCUMENTATION_NOTE
      })
    );
  });
};
 
function validateCLIOptions(argv, options, rawArgv = []) {
  const yargsSpecialOptions = ['$0', '_', 'help', 'h'];
  const deprecationEntries = options.deprecationEntries || {};
  const allowedOptions = Object.keys(options).reduce(
    (acc, option) => acc.add(option).add(options[option].alias || option),
    new Set(yargsSpecialOptions)
  );
  const unrecognizedOptions = Object.keys(argv).filter(
    arg =>
      !allowedOptions.has((0, _camelcase().default)(arg)) &&
      (!rawArgv.length || rawArgv.includes(arg)),
    []
  );
 
  if (unrecognizedOptions.length) {
    throw createCLIValidationError(unrecognizedOptions, allowedOptions);
  }
 
  const CLIDeprecations = Object.keys(deprecationEntries).reduce(
    (acc, entry) => {
      if (options[entry]) {
        acc[entry] = deprecationEntries[entry];
        const alias = options[entry].alias;
 
        if (alias) {
          acc[alias] = deprecationEntries[entry];
        }
      }
 
      return acc;
    },
    {}
  );
  const deprecations = new Set(Object.keys(CLIDeprecations));
  const deprecatedOptions = Object.keys(argv).filter(
    arg => deprecations.has(arg) && argv[arg] != null
  );
 
  if (deprecatedOptions.length) {
    logDeprecatedOptions(deprecatedOptions, CLIDeprecations, argv);
  }
 
  return true;
}