执行过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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
'use strict';
 
Object.defineProperty(exports, '__esModule', {
  value: true
});
exports.wrapAnsiString = exports.getSummary = exports.relativePath = exports.formatTestPath = exports.trimAndFormatPath = exports.printDisplayName = void 0;
 
function _path() {
  const data = _interopRequireDefault(require('path'));
 
  _path = function _path() {
    return data;
  };
 
  return data;
}
 
function _chalk() {
  const data = _interopRequireDefault(require('chalk'));
 
  _chalk = function _chalk() {
    return data;
  };
 
  return data;
}
 
function _slash() {
  const data = _interopRequireDefault(require('slash'));
 
  _slash = function _slash() {
    return data;
  };
 
  return data;
}
 
function _jestUtil() {
  const data = require('jest-util');
 
  _jestUtil = function _jestUtil() {
    return data;
  };
 
  return data;
}
 
function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : {default: obj};
}
 
/**
 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
const PROGRESS_BAR_WIDTH = 40;
 
const printDisplayName = config => {
  const displayName = config.displayName;
 
  const white = _chalk().default.reset.inverse.white;
 
  if (!displayName) {
    return '';
  }
 
  if (typeof displayName === 'string') {
    return _chalk().default.supportsColor
      ? white(` ${displayName} `)
      : displayName;
  }
 
  const name = displayName.name,
    color = displayName.color;
  const chosenColor = _chalk().default.reset.inverse[color]
    ? _chalk().default.reset.inverse[color]
    : white;
  return _chalk().default.supportsColor ? chosenColor(` ${name} `) : name;
};
 
exports.printDisplayName = printDisplayName;
 
const trimAndFormatPath = (pad, config, testPath, columns) => {
  const maxLength = columns - pad;
  const relative = relativePath(config, testPath);
  const basename = relative.basename;
  let dirname = relative.dirname; // length is ok
 
  if ((dirname + _path().default.sep + basename).length <= maxLength) {
    return (0, _slash().default)(
      _chalk().default.dim(dirname + _path().default.sep) +
        _chalk().default.bold(basename)
    );
  } // we can fit trimmed dirname and full basename
 
  const basenameLength = basename.length;
 
  if (basenameLength + 4 < maxLength) {
    const dirnameLength = maxLength - 4 - basenameLength;
    dirname =
      '...' + dirname.slice(dirname.length - dirnameLength, dirname.length);
    return (0, _slash().default)(
      _chalk().default.dim(dirname + _path().default.sep) +
        _chalk().default.bold(basename)
    );
  }
 
  if (basenameLength + 4 === maxLength) {
    return (0, _slash().default)(
      _chalk().default.dim('...' + _path().default.sep) +
        _chalk().default.bold(basename)
    );
  } // can't fit dirname, but can fit trimmed basename
 
  return (0, _slash().default)(
    _chalk().default.bold(
      '...' + basename.slice(basename.length - maxLength - 4, basename.length)
    )
  );
};
 
exports.trimAndFormatPath = trimAndFormatPath;
 
const formatTestPath = (config, testPath) => {
  const _relativePath = relativePath(config, testPath),
    dirname = _relativePath.dirname,
    basename = _relativePath.basename;
 
  return (0, _slash().default)(
    _chalk().default.dim(dirname + _path().default.sep) +
      _chalk().default.bold(basename)
  );
};
 
exports.formatTestPath = formatTestPath;
 
const relativePath = (config, testPath) => {
  // this function can be called with ProjectConfigs or GlobalConfigs. GlobalConfigs
  // do not have config.cwd, only config.rootDir. Try using config.cwd, fallback
  // to config.rootDir. (Also, some unit just use config.rootDir, which is ok)
  testPath = _path().default.relative(config.cwd || config.rootDir, testPath);
 
  const dirname = _path().default.dirname(testPath);
 
  const basename = _path().default.basename(testPath);
 
  return {
    basename,
    dirname
  };
};
 
exports.relativePath = relativePath;
 
const getSummary = (aggregatedResults, options) => {
  let runTime = (Date.now() - aggregatedResults.startTime) / 1000;
 
  if (options && options.roundTime) {
    runTime = Math.floor(runTime);
  }
 
  const estimatedTime = (options && options.estimatedTime) || 0;
  const snapshotResults = aggregatedResults.snapshot;
  const snapshotsAdded = snapshotResults.added;
  const snapshotsFailed = snapshotResults.unmatched;
  const snapshotsOutdated = snapshotResults.unchecked;
  const snapshotsFilesRemoved = snapshotResults.filesRemoved;
  const snapshotsDidUpdate = snapshotResults.didUpdate;
  const snapshotsPassed = snapshotResults.matched;
  const snapshotsTotal = snapshotResults.total;
  const snapshotsUpdated = snapshotResults.updated;
  const suitesFailed = aggregatedResults.numFailedTestSuites;
  const suitesPassed = aggregatedResults.numPassedTestSuites;
  const suitesPending = aggregatedResults.numPendingTestSuites;
  const suitesRun = suitesFailed + suitesPassed;
  const suitesTotal = aggregatedResults.numTotalTestSuites;
  const testsFailed = aggregatedResults.numFailedTests;
  const testsPassed = aggregatedResults.numPassedTests;
  const testsPending = aggregatedResults.numPendingTests;
  const testsTodo = aggregatedResults.numTodoTests;
  const testsTotal = aggregatedResults.numTotalTests;
  const width = (options && options.width) || 0;
  const suites =
    _chalk().default.bold('Test Suites: ') +
    (suitesFailed
      ? _chalk().default.bold.red(`${suitesFailed} failed`) + ', '
      : '') +
    (suitesPending
      ? _chalk().default.bold.yellow(`${suitesPending} skipped`) + ', '
      : '') +
    (suitesPassed
      ? _chalk().default.bold.green(`${suitesPassed} passed`) + ', '
      : '') +
    (suitesRun !== suitesTotal
      ? suitesRun + ' of ' + suitesTotal
      : suitesTotal) +
    ` total`;
  const tests =
    _chalk().default.bold('Tests:       ') +
    (testsFailed
      ? _chalk().default.bold.red(`${testsFailed} failed`) + ', '
      : '') +
    (testsPending
      ? _chalk().default.bold.yellow(`${testsPending} skipped`) + ', '
      : '') +
    (testsTodo
      ? _chalk().default.bold.magenta(`${testsTodo} todo`) + ', '
      : '') +
    (testsPassed
      ? _chalk().default.bold.green(`${testsPassed} passed`) + ', '
      : '') +
    `${testsTotal} total`;
  const snapshots =
    _chalk().default.bold('Snapshots:   ') +
    (snapshotsFailed
      ? _chalk().default.bold.red(`${snapshotsFailed} failed`) + ', '
      : '') +
    (snapshotsOutdated && !snapshotsDidUpdate
      ? _chalk().default.bold.yellow(`${snapshotsOutdated} obsolete`) + ', '
      : '') +
    (snapshotsOutdated && snapshotsDidUpdate
      ? _chalk().default.bold.green(`${snapshotsOutdated} removed`) + ', '
      : '') +
    (snapshotsFilesRemoved && !snapshotsDidUpdate
      ? _chalk().default.bold.yellow(
          (0, _jestUtil().pluralize)('file', snapshotsFilesRemoved) +
            ' obsolete'
        ) + ', '
      : '') +
    (snapshotsFilesRemoved && snapshotsDidUpdate
      ? _chalk().default.bold.green(
          (0, _jestUtil().pluralize)('file', snapshotsFilesRemoved) + ' removed'
        ) + ', '
      : '') +
    (snapshotsUpdated
      ? _chalk().default.bold.green(`${snapshotsUpdated} updated`) + ', '
      : '') +
    (snapshotsAdded
      ? _chalk().default.bold.green(`${snapshotsAdded} written`) + ', '
      : '') +
    (snapshotsPassed
      ? _chalk().default.bold.green(`${snapshotsPassed} passed`) + ', '
      : '') +
    `${snapshotsTotal} total`;
  const time = renderTime(runTime, estimatedTime, width);
  return [suites, tests, snapshots, time].join('\n');
};
 
exports.getSummary = getSummary;
 
const renderTime = (runTime, estimatedTime, width) => {
  // If we are more than one second over the estimated time, highlight it.
  const renderedTime =
    estimatedTime && runTime >= estimatedTime + 1
      ? _chalk().default.bold.yellow(runTime + 's')
      : runTime + 's';
  let time = _chalk().default.bold(`Time:`) + `        ${renderedTime}`;
 
  if (runTime < estimatedTime) {
    time += `, estimated ${estimatedTime}s`;
  } // Only show a progress bar if the test run is actually going to take
  // some time.
 
  if (estimatedTime > 2 && runTime < estimatedTime && width) {
    const availableWidth = Math.min(PROGRESS_BAR_WIDTH, width);
    const length = Math.min(
      Math.floor((runTime / estimatedTime) * availableWidth),
      availableWidth
    );
 
    if (availableWidth >= 2) {
      time +=
        '\n' +
        _chalk()
          .default.green('█')
          .repeat(length) +
        _chalk()
          .default.white('█')
          .repeat(availableWidth - length);
    }
  }
 
  return time;
}; // word-wrap a string that contains ANSI escape sequences.
// ANSI escape sequences do not add to the string length.
 
const wrapAnsiString = (string, terminalWidth) => {
  if (terminalWidth === 0) {
    // if the terminal width is zero, don't bother word-wrapping
    return string;
  }
 
  const ANSI_REGEXP = /[\u001b\u009b]\[\d{1,2}m/g;
  const tokens = [];
  let lastIndex = 0;
  let match;
 
  while ((match = ANSI_REGEXP.exec(string))) {
    const ansi = match[0];
    const index = match['index'];
 
    if (index != lastIndex) {
      tokens.push(['string', string.slice(lastIndex, index)]);
    }
 
    tokens.push(['ansi', ansi]);
    lastIndex = index + ansi.length;
  }
 
  if (lastIndex != string.length - 1) {
    tokens.push(['string', string.slice(lastIndex, string.length)]);
  }
 
  let lastLineLength = 0;
  return tokens
    .reduce(
      (lines, [kind, token]) => {
        if (kind === 'string') {
          if (lastLineLength + token.length > terminalWidth) {
            while (token.length) {
              const chunk = token.slice(0, terminalWidth - lastLineLength);
              const remaining = token.slice(
                terminalWidth - lastLineLength,
                token.length
              );
              lines[lines.length - 1] += chunk;
              lastLineLength += chunk.length;
              token = remaining;
 
              if (token.length) {
                lines.push('');
                lastLineLength = 0;
              }
            }
          } else {
            lines[lines.length - 1] += token;
            lastLineLength += token.length;
          }
        } else {
          lines[lines.length - 1] += token;
        }
 
        return lines;
      },
      ['']
    )
    .join('\n');
};
 
exports.wrapAnsiString = wrapAnsiString;